1 line
10 KiB
Plaintext
1 line
10 KiB
Plaintext
{"version":3,"file":"index.js","sources":["../../../../../../src/modules/mall/pay/index.vue","../../../../../../uniPage:/bW9kdWxlc1xtYWxsXHBheVxpbmRleC52dWU"],"sourcesContent":["<!-- 收银台 -->\r\n<template>\r\n <s-layout title=\"收银台\">\r\n <view class=\"bg-white ss-modal-box ss-flex-col\">\r\n <!-- 订单信息 -->\r\n <view class=\"modal-header ss-flex-col ss-col-center ss-row-center\">\r\n <view class=\"money-box ss-m-b-20\">\r\n <text class=\"money-text\">{{ fen2yuan(state.orderInfo.price) }}</text>\r\n </view>\r\n <view class=\"time-text\">\r\n <text>{{ payDescText }}</text>\r\n </view>\r\n </view>\r\n\r\n <!-- 支付方式 -->\r\n <view class=\"modal-content ss-flex-1\">\r\n <view class=\"pay-title ss-p-l-30 ss-m-y-30\">选择支付方式</view>\r\n <radio-group @change=\"onTapPay\">\r\n <label class=\"pay-type-item\" v-for=\"item in state.payMethods\" :key=\"item.title\">\r\n <view\r\n class=\"pay-item ss-flex ss-col-center ss-row-between ss-p-x-30 border-bottom\"\r\n :class=\"{ 'disabled-pay-item': item.disabled }\"\r\n >\r\n <view class=\"ss-flex ss-col-center\">\r\n <image\r\n class=\"pay-icon\"\r\n v-if=\"item.disabled\"\r\n :src=\"sheep.$url.static('/static/img/shop/pay/cod_disabled.png')\"\r\n mode=\"aspectFit\"\r\n />\r\n <image\r\n class=\"pay-icon\"\r\n v-else\r\n :src=\"sheep.$url.static(item.icon)\"\r\n mode=\"aspectFit\"\r\n />\r\n <text class=\"pay-title\">{{ item.title }}</text>\r\n </view>\r\n <view class=\"check-box ss-flex ss-col-center ss-p-l-10\">\r\n <view class=\"userInfo-money ss-m-r-10\" v-if=\"item.value === 'wallet'\">\r\n 余额: {{ fen2yuan(userWallet.balance) }}元\r\n </view>\r\n <radio\r\n :value=\"item.value\"\r\n color=\"var(--ui-BG-Main)\"\r\n style=\"transform: scale(0.8)\"\r\n :disabled=\"item.disabled\"\r\n :checked=\"state.payment === item.value\"\r\n />\r\n </view>\r\n </view>\r\n </label>\r\n </radio-group>\r\n </view>\r\n\r\n <!-- 工具 -->\r\n <view class=\"modal-footer ss-flex ss-row-center ss-col-center ss-m-t-80 ss-m-b-40\">\r\n <button v-if=\"state.payStatus === 0\" class=\"ss-reset-button past-due-btn\">\r\n 检测支付环境中\r\n </button>\r\n <button v-else-if=\"state.payStatus === -1\" class=\"ss-reset-button past-due-btn\" disabled>\r\n 支付已过期\r\n </button>\r\n <button\r\n v-else\r\n class=\"ss-reset-button save-btn\"\r\n @tap=\"onPay\"\r\n :disabled=\"state.payStatus !== 1\"\r\n :class=\"{ 'disabled-btn': state.payStatus !== 1 }\"\r\n >\r\n 立即支付\r\n </button>\r\n </view>\r\n </view>\r\n </s-layout>\r\n</template>\r\n<script setup>\r\nimport { computed, reactive } from 'vue'\r\nimport { onLoad } from '@dcloudio/uni-app'\r\nimport sheep from '@/sheep'\r\nimport { fen2yuan, useDurationTime } from '@/sheep/hooks/useGoods'\r\nimport PayOrderApi from '@/sheep/api/pay/order'\r\nimport PayChannelApi from '@/sheep/api/pay/channel'\r\nimport { getPayMethods } from '@/sheep/platform/pay'\r\n\r\nconst userWallet = computed(() => sheep.$store('user').userWallet)\r\n\r\n// 检测支付环境\r\nconst state = reactive({\r\n orderType: 'goods', // 订单类型; goods - 商品订单, recharge - 充值订单\r\n orderInfo: {}, // 支付单信息\r\n payStatus: 0, // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付\r\n payMethods: [], // 可选的支付方式\r\n payment: '', // 选中的支付方式\r\n})\r\n\r\nconst onPay = () => {\r\n if (state.payment === '') {\r\n sheep.$helper.toast('请选择支付方式')\r\n return\r\n }\r\n if (state.payment === 'wallet') {\r\n uni.showModal({\r\n title: '提示',\r\n content: '确定要支付吗?',\r\n success: function (res) {\r\n if (res.confirm) {\r\n sheep.$platform.pay(state.payment, state.orderType, state.orderInfo.id)\r\n }\r\n },\r\n })\r\n } else {\r\n sheep.$platform.pay(state.payment, state.orderType, state.orderInfo.id)\r\n }\r\n}\r\n\r\n// 支付文案提示\r\nconst payDescText = computed(() => {\r\n if (state.payStatus === 2) {\r\n return '该订单已支付'\r\n }\r\n if (state.payStatus === 1) {\r\n const time = useDurationTime(state.orderInfo.expireTime)\r\n if (time.ms <= 0) {\r\n state.payStatus = -1\r\n return ''\r\n }\r\n return `剩余支付时间 ${time.h}:${time.m}:${time.s} `\r\n }\r\n if (state.payStatus === -2) {\r\n return '未查询到支付单信息'\r\n }\r\n return ''\r\n})\r\n\r\n// 状态转换:payOrder.status => payStatus\r\nfunction checkPayStatus() {\r\n if (state.orderInfo.status === 10 || state.orderInfo.status === 20) {\r\n // 支付成功\r\n state.payStatus = 2\r\n return\r\n }\r\n if (state.orderInfo.status === 30) {\r\n // 支付关闭\r\n state.payStatus = -1\r\n return\r\n }\r\n state.payStatus = 1 // 待支付\r\n}\r\n\r\n// 切换支付方式\r\nfunction onTapPay(e) {\r\n state.payment = e.detail.value\r\n}\r\n\r\n// 设置支付订单信息\r\nasync function setOrder(id) {\r\n // 获得支付订单信息\r\n const { data, code } = await PayOrderApi.getOrder(id)\r\n if (code !== 0 || !data) {\r\n state.payStatus = -2\r\n return\r\n }\r\n state.orderInfo = data\r\n // 获得支付方式\r\n await setPayMethods()\r\n // 设置支付状态\r\n checkPayStatus()\r\n}\r\n\r\n// 获得支付方式\r\nasync function setPayMethods() {\r\n const { data, code } = await PayChannelApi.getEnableChannelCodeList(state.orderInfo.appId)\r\n if (code !== 0) {\r\n return\r\n }\r\n state.payMethods = getPayMethods(data)\r\n}\r\n\r\nonLoad((options) => {\r\n if (\r\n sheep.$platform.name === 'WechatOfficialAccount' &&\r\n sheep.$platform.os === 'ios' &&\r\n !sheep.$platform.landingPage.includes('pages/pay/index')\r\n ) {\r\n location.reload()\r\n return\r\n }\r\n // 获得支付订单信息\r\n const id = options.id\r\n if (options.orderType) {\r\n state.orderType = options.orderType\r\n }\r\n setOrder(id)\r\n // 刷新钱包的缓存\r\n sheep.$store('user').getWallet()\r\n})\r\n</script>\r\n\r\n<style lang=\"scss\" scoped>\r\n \r\n.pay-icon {\r\n width: 36rpx;\r\n height: 36rpx;\r\n margin-right: 26rpx;\r\n}\r\n\r\n.ss-modal-box {\r\n // max-height: 1000rpx;\r\n\r\n .modal-header {\r\n position: relative;\r\n padding: 60rpx 20rpx 40rpx;\r\n\r\n .money-text {\r\n font-family: OPPOSANS;\r\n font-size: 46rpx;\r\n font-weight: bold;\r\n color: $red;\r\n\r\n &::before {\r\n font-size: 30rpx;\r\n content: '¥';\r\n }\r\n }\r\n\r\n .time-text {\r\n font-size: 26rpx;\r\n color: $gray-b;\r\n }\r\n\r\n .close-icon {\r\n position: absolute;\r\n top: 10rpx;\r\n right: 20rpx;\r\n font-size: 46rpx;\r\n opacity: 0.2;\r\n }\r\n }\r\n\r\n .modal-content {\r\n overflow-y: auto;\r\n\r\n .pay-title {\r\n font-size: 26rpx;\r\n font-weight: 500;\r\n color: #333333;\r\n }\r\n\r\n .pay-tip {\r\n font-size: 26rpx;\r\n color: #bbbbbb;\r\n }\r\n\r\n .pay-item {\r\n height: 86rpx;\r\n }\r\n .disabled-pay-item {\r\n .pay-title {\r\n color: #999999;\r\n }\r\n }\r\n\r\n .userInfo-money {\r\n font-size: 26rpx;\r\n line-height: normal;\r\n color: #bbbbbb;\r\n }\r\n }\r\n\r\n .save-btn {\r\n width: 710rpx;\r\n height: 80rpx;\r\n color: $white;\r\n background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));\r\n border-radius: 40rpx;\r\n }\r\n .disabled-btn {\r\n color: #999999;\r\n background: #e5e5e5;\r\n }\r\n\r\n .past-due-btn {\r\n width: 710rpx;\r\n height: 80rpx;\r\n color: #fff;\r\n background-color: #999;\r\n border-radius: 40rpx;\r\n }\r\n}\r\n</style>\r\n","import MiniProgramPage from 'D:/App/Work/addr/acdr-ui/src/modules/mall/pay/index.vue'\nwx.createPage(MiniProgramPage)"],"names":["computed","sheep","reactive","uni","useDurationTime","PayOrderApi","PayChannelApi","getPayMethods","onLoad"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFA,UAAA,aAAAA,cAAA,SAAA,MAAAC,YAAAA,MAAA,OAAA,MAAA,EAAA,UAAA;AAGA,UAAA,QAAAC,cAAAA,SAAA;AAAA,MACA,WAAA;AAAA;AAAA,MACA,WAAA,CAAA;AAAA;AAAA,MACA,WAAA;AAAA;AAAA,MACA,YAAA,CAAA;AAAA;AAAA,MACA,SAAA;AAAA;AAAA,IACA,CAAA;AAEA,UAAA,QAAA,MAAA;AACA,UAAA,MAAA,YAAA,IAAA;AACAD,0BAAA,QAAA,MAAA,SAAA;AACA;AAAA,MACA;AACA,UAAA,MAAA,YAAA,UAAA;AACAE,sBAAAA,MAAA,UAAA;AAAA,UACA,OAAA;AAAA,UACA,SAAA;AAAA,UACA,SAAA,SAAA,KAAA;AACA,gBAAA,IAAA,SAAA;AACAF,gCAAA,UAAA,IAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,EAAA;AAAA,YACA;AAAA,UACA;AAAA,QACA,CAAA;AAAA,MACA,OAAA;AACAA,0BAAA,UAAA,IAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,EAAA;AAAA,MACA;AAAA,IACA;AAGA,UAAA,cAAAD,cAAA,SAAA,MAAA;AACA,UAAA,MAAA,cAAA,GAAA;AACA,eAAA;AAAA,MACA;AACA,UAAA,MAAA,cAAA,GAAA;AACA,cAAA,OAAAI,qBAAA,gBAAA,MAAA,UAAA,UAAA;AACA,YAAA,KAAA,MAAA,GAAA;AACA,gBAAA,YAAA;AACA,iBAAA;AAAA,QACA;AACA,eAAA,UAAA,KAAA,CAAA,IAAA,KAAA,CAAA,IAAA,KAAA,CAAA;AAAA,MACA;AACA,UAAA,MAAA,cAAA,IAAA;AACA,eAAA;AAAA,MACA;AACA,aAAA;AAAA,IACA,C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