1 line
12 KiB
Plaintext
1 line
12 KiB
Plaintext
{"version":3,"file":"result.js","sources":["../../../../../../src/modules/mall/pay/result.vue","../../../../../../uniPage:/bW9kdWxlc1xtYWxsXHBheVxyZXN1bHQudnVl"],"sourcesContent":["<!-- 支付结果页面 -->\r\n<template>\r\n <s-layout title=\"支付结果\" :bgStyle=\"{ color: '#FFF' }\">\r\n <view class=\"pay-result-box ss-flex-col ss-row-center ss-col-center\">\r\n <!-- 信息展示 -->\r\n <view class=\"pay-waiting ss-m-b-30\" v-if=\"payResult === 'waiting'\" />\r\n <image\r\n class=\"pay-img ss-m-b-30\"\r\n v-if=\"payResult === 'success'\"\r\n :src=\"sheep.$url.static('/static/img/shop/order/order_pay_success.gif')\"\r\n />\r\n <image\r\n class=\"pay-img ss-m-b-30\"\r\n v-if=\"['failed', 'closed'].includes(payResult)\"\r\n :src=\"sheep.$url.static('/static/img/shop/order/order_paty_fail.gif')\"\r\n />\r\n <view class=\"tip-text ss-m-b-30\" v-if=\"payResult === 'success'\">支付成功</view>\r\n <view class=\"tip-text ss-m-b-30\" v-if=\"payResult === 'failed'\">支付失败</view>\r\n <view class=\"tip-text ss-m-b-30\" v-if=\"payResult === 'closed'\">该订单已关闭</view>\r\n <view class=\"tip-text ss-m-b-30\" v-if=\"payResult === 'waiting'\">检测支付结果...</view>\r\n <view class=\"pay-total-num ss-flex\" v-if=\"payResult === 'success'\">\r\n <view>¥{{ fen2yuan(state.orderInfo.price) }}</view>\r\n </view>\r\n\r\n <!-- 操作区 -->\r\n <view class=\"btn-box ss-flex ss-row-center ss-m-t-50\">\r\n <button class=\"back-btn ss-reset-button\" @tap=\"sheep.$router.go('/modules/mall/index/index')\">\r\n 返回首页\r\n </button>\r\n <button\r\n class=\"check-btn ss-reset-button\"\r\n v-if=\"payResult === 'failed'\"\r\n @tap=\"\r\n sheep.$router.redirect('/modules/mall/pay/index', {\r\n id: state.id,\r\n orderType: state.orderType,\r\n })\r\n \"\r\n >\r\n 重新支付\r\n </button>\r\n <button class=\"check-btn ss-reset-button\" v-if=\"payResult === 'success'\" @tap=\"onOrder\">\r\n 查看订单\r\n </button>\r\n <!-- TODO 芋艿:拼团接入 -->\r\n <button\r\n class=\"check-btn ss-reset-button\"\r\n v-if=\"payResult === 'success' && state.tradeOrder.type === 3\"\r\n @tap=\"sheep.$router.redirect('/modules/mall/activity/groupon/order')\"\r\n >\r\n 我的拼团\r\n </button>\r\n </view>\r\n\r\n <!-- #ifdef MP -->\r\n <view\r\n class=\"subscribe-box ss-flex ss-m-t-44\"\r\n v-if=\"showSubscribeBtn && state.orderType === 'goods'\"\r\n >\r\n <image class=\"subscribe-img\" :src=\"sheep.$url.static('/static/img/shop/order/cargo.png')\" />\r\n <view class=\"subscribe-title ss-m-r-48 ss-m-l-16\">获取实时发货信息与订单状态</view>\r\n <view class=\"subscribe-start\" @tap=\"subscribeMessage\">立即订阅</view>\r\n </view>\r\n <!-- #endif -->\r\n </view>\r\n </s-layout>\r\n</template>\r\n\r\n<script setup>\r\nimport { onLoad, onHide, onShow } from '@dcloudio/uni-app'\r\nimport { reactive, computed, ref } from 'vue'\r\nimport { isEmpty } from 'lodash-es'\r\nimport sheep from '@/sheep'\r\nimport PayOrderApi from '@/sheep/api/pay/order'\r\nimport { fen2yuan } from '@/sheep/hooks/useGoods'\r\nimport OrderApi from '@/sheep/api/trade/order'\r\nimport { WxaSubscribeTemplate } from '@/sheep/util/const'\r\n\r\nconst state = reactive({\r\n id: 0, // 支付单号\r\n orderType: 'goods', // 订单类型\r\n result: 'unpaid', // 支付状态\r\n orderInfo: {}, // 支付订单信息\r\n tradeOrder: {}, // 商品订单信息,只有在 orderType 为 goods 才会请求。目的:【我的拼团】按钮的展示\r\n counter: 0, // 获取结果次数\r\n})\r\n\r\n// 支付结果 result => payResult\r\nconst payResult = computed(() => {\r\n if (state.result === 'unpaid') {\r\n return 'waiting'\r\n }\r\n if (state.result === 'paid') {\r\n return 'success'\r\n }\r\n if (state.result === 'failed') {\r\n return 'failed'\r\n }\r\n if (state.result === 'closed') {\r\n return 'closed'\r\n }\r\n})\r\n\r\n// 获得订单信息\r\nasync function getOrderInfo(id) {\r\n state.counter++\r\n // 1. 加载订单信息\r\n const { data, code } = await PayOrderApi.getOrder(id)\r\n if (code === 0) {\r\n state.orderInfo = data\r\n if (!state.orderInfo || state.orderInfo.status === 30) {\r\n // 支付关闭\r\n state.result = 'closed'\r\n return\r\n }\r\n if (state.orderInfo.status !== 0) {\r\n // 非待支付,可能是已支付,可能是已退款\r\n state.result = 'paid'\r\n // #ifdef MP\r\n uni.showModal({\r\n title: '支付结果',\r\n showCancel: false, // 不要取消按钮\r\n content: '支付成功',\r\n success: () => {\r\n // 订阅只能由用户主动触发,只能包一层 showModal 诱导用户点击\r\n autoSubscribeMessage()\r\n },\r\n })\r\n\r\n // #endif\r\n // 特殊:获得商品订单信息\r\n if (state.orderType === 'goods') {\r\n const { data, code } = await OrderApi.getOrder(state.orderInfo.merchantOrderId)\r\n if (code === 0) {\r\n state.tradeOrder = data\r\n }\r\n }\r\n return\r\n }\r\n }\r\n // 2.1 情况三一:未支付,且轮询次数小于三次,则继续轮询\r\n if (state.counter < 3 && state.result === 'unpaid') {\r\n setTimeout(() => {\r\n getOrderInfo(id)\r\n }, 1500)\r\n }\r\n // 2.2 情况二:超过三次检测才判断为支付失败\r\n if (state.counter >= 3) {\r\n state.result = 'failed'\r\n }\r\n}\r\n\r\nfunction onOrder() {\r\n if (state.orderType === 'recharge') {\r\n sheep.$router.redirect('/modules/mall/pay/recharge-log')\r\n } else {\r\n sheep.$router.redirect('/modules/mall/order/list')\r\n }\r\n}\r\n\r\n// #ifdef MP\r\nconst showSubscribeBtn = ref(false) // 默认隐藏\r\nconst SUBSCRIBE_BTN_STATUS_STORAGE_KEY = 'subscribe_btn_status'\r\nfunction subscribeMessage() {\r\n if (state.orderType !== 'goods') {\r\n return\r\n }\r\n const event = [WxaSubscribeTemplate.TRADE_ORDER_DELIVERY]\r\n if (state.tradeOrder.type === 3) {\r\n event.push(WxaSubscribeTemplate.PROMOTION_COMBINATION_SUCCESS)\r\n }\r\n sheep.$platform.useProvider('wechat').subscribeMessage(event, () => {\r\n // 订阅后记录一下订阅状态\r\n uni.removeStorageSync(SUBSCRIBE_BTN_STATUS_STORAGE_KEY)\r\n uni.setStorageSync(SUBSCRIBE_BTN_STATUS_STORAGE_KEY, '已订阅')\r\n // 隐藏订阅按钮\r\n showSubscribeBtn.value = false\r\n })\r\n}\r\nasync function autoSubscribeMessage() {\r\n // 1. 校验是否手动订阅过\r\n const subscribeBtnStatus = uni.getStorageSync(SUBSCRIBE_BTN_STATUS_STORAGE_KEY)\r\n if (!subscribeBtnStatus) {\r\n showSubscribeBtn.value = true\r\n return\r\n }\r\n\r\n // 2. 订阅消息\r\n subscribeMessage()\r\n}\r\n// #endif\r\n\r\nonLoad(async (options) => {\r\n // 支付订单号\r\n if (options.id) {\r\n state.id = options.id\r\n }\r\n // 订单类型\r\n if (options.orderType) {\r\n state.orderType = options.orderType\r\n }\r\n\r\n // 支付结果传值过来是失败,则直接显示失败界面\r\n if (options.payState === 'fail') {\r\n state.result = 'failed'\r\n } else {\r\n // 轮询三次检测订单支付结果\r\n await getOrderInfo(state.id)\r\n }\r\n})\r\n\r\nonShow(() => {\r\n if (isEmpty(state.orderInfo)) {\r\n return\r\n }\r\n getOrderInfo(state.id)\r\n})\r\n\r\nonHide(() => {\r\n state.result = 'unpaid'\r\n state.counter = 0\r\n})\r\n</script>\r\n\r\n<style lang=\"scss\" scoped>\r\n \r\n@keyframes rotation {\r\n 0% {\r\n transform: rotate(0deg);\r\n }\r\n\r\n 100% {\r\n transform: rotate(360deg);\r\n }\r\n}\r\n\r\n.score-img {\r\n width: 36rpx;\r\n height: 36rpx;\r\n margin: 0 4rpx;\r\n}\r\n\r\n.pay-result-box {\r\n padding: 60rpx 0;\r\n\r\n .pay-waiting {\r\n display: inline-block;\r\n width: 60rpx;\r\n height: 60rpx;\r\n margin-top: 20rpx;\r\n border: 10rpx solid rgb(233, 231, 231);\r\n border-bottom-color: rgb(204, 204, 204);\r\n border-radius: 50%;\r\n // -webkit-animation: rotation 1s linear infinite;\r\n animation: rotation 1s linear infinite;\r\n }\r\n\r\n .pay-img {\r\n width: 130rpx;\r\n height: 130rpx;\r\n }\r\n\r\n .tip-text {\r\n font-size: 30rpx;\r\n font-weight: bold;\r\n color: #333333;\r\n }\r\n\r\n .pay-total-num {\r\n font-family: OPPOSANS;\r\n font-size: 36rpx;\r\n font-weight: 500;\r\n color: #333333;\r\n }\r\n\r\n .btn-box {\r\n width: 100%;\r\n\r\n .back-btn {\r\n width: 190rpx;\r\n height: 70rpx;\r\n font-size: 28rpx;\r\n font-weight: 400;\r\n color: #595959;\r\n border: 2rpx solid #dfdfdf;\r\n border-radius: 35rpx;\r\n }\r\n\r\n .check-btn {\r\n width: 190rpx;\r\n height: 70rpx;\r\n margin-left: 32rpx;\r\n font-size: 28rpx;\r\n font-weight: 400;\r\n color: #595959;\r\n border: 2rpx solid #dfdfdf;\r\n border-radius: 35rpx;\r\n }\r\n }\r\n\r\n .subscribe-box {\r\n .subscribe-img {\r\n width: 44rpx;\r\n height: 44rpx;\r\n }\r\n\r\n .subscribe-title {\r\n font-size: 32rpx;\r\n font-weight: 500;\r\n line-height: 36rpx;\r\n color: #434343;\r\n }\r\n\r\n .subscribe-start {\r\n font-size: 32rpx;\r\n font-weight: 700;\r\n line-height: 36rpx;\r\n color: var(--ui-BG-Main);\r\n }\r\n }\r\n}\r\n</style>\r\n","import MiniProgramPage from 'D:/App/Work/addr/acdr-ui/src/modules/mall/pay/result.vue'\nwx.createPage(MiniProgramPage)"],"names":["reactive","computed","PayOrderApi","uni","data","code","OrderApi","sheep","ref","WxaSubscribeTemplate","onLoad","onShow","isEmpty","onHide"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkKA,MAAA,mCAAA;;;;AApFA,UAAA,QAAAA,cAAAA,SAAA;AAAA,MACA,IAAA;AAAA;AAA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