123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <template>
- <view class="content">
- <kevy-result-page v-if="type" :type="type" :title="title" :primarColor="primarColor" :details="details"
- :primaryBtnText="primaryBtnText" secondaryBtnText="返回" @primaryBtnClick="primaryBtnClick"
- @secondaryBtnClick="secondaryBtnClick" :codeUrlFailureTime="orderData.codeUrlFailureTime" @finish="finish">
- </kevy-result-page>
- </view>
- </template>
- <script>
- import {
- getOrderDetail,
- getWxPay
- } from '@/request/api/workark.js'
- export default {
- data() {
- return {
- type: '',
- title: '',
- details: [],
- primarColor: '',
- primaryBtnText: '',
- orderId: '',
- orderData: {},
- codeUrlFailureTime: ''
- }
- },
- onLoad(body) {
- this.orderId = body.orderId;
- if (this.orderId) this.init();
- },
- methods: {
- async init() {
- let orderData = await getOrderDetail(this.orderId);
- if (!orderData.state) return;
- this.orderData = orderData.data;
- this.details = [{
- label: '订单编号',
- value: orderData.data.orderNo
- }, {
- label: '订单金额',
- value: orderData.data.totalFee
- }, {
- label: '支付状态',
- value: orderData.data.orderStatus
- }];
- this.initStatus();
- },
- initStatus() {
- if (this.orderData.orderStatus === '支付成功') {
- this.type = 'success';
- this.title = '支付成功';
- this.primarColor = '#4fc08d';
- this.primaryBtnText = '查看订单';
- } else if (this.orderData.orderStatus === '未支付') {
- this.type = 'warning';
- this.title = '暂未支付';
- this.primarColor = '#f9b04d';
- this.primaryBtnText = '立即支付';
- } else if (this.orderData.orderStatus === '超时已关闭') {
- this.type = 'error';
- this.title = '订单已失效';
- this.primarColor = '#ff3927';
- this.primaryBtnText = '查看订单';
- }
- },
- async primaryBtnClick() {
- if (this.type === 'success') {
- this.$navigateTo('/subPages/indexPage/orderDetail/orderDetail?orderId=' + this.orderData.id)
- } else if (this.type === 'warning') {
- uni.showLoading({
- title: '订单支付中...'
- })
- let wxConfig = await getWxPay(this.orderData.orderNo, uni.getStorageSync('openId'));
- uni.requestPayment({
- provider: 'wxpay',
- timeStamp: wxConfig.data.timeStamp,
- nonceStr: wxConfig.data.nonceStr,
- package: wxConfig.data.prepayId,
- signType: wxConfig.data.signType,
- paySign: wxConfig.data.paySign,
- success: res => {
- this.init();
- uni.hideLoading();
- },
- fail: err => {
- uni.hideLoading();
- }
- });
- }
- },
- secondaryBtnClick() {
- uni.navigateBack();
- },
- finish() {
- this.init();
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- ::v-deep .uv-count-down {
- .uv-count-down__text {
- color: #fff;
- }
- }
- .content {
- box-sizing: border-box;
- }
- </style>
|