|
@@ -19,6 +19,13 @@ import GoodsDetail from '../goods-detail'
|
|
|
import ODialog from '@/components/o-dialog'
|
|
|
import { orderStatus } from '@/constant'
|
|
|
import QrcodePayment from './qrcode-payment'
|
|
|
+import { beforeSubmit } from './order-state'
|
|
|
+
|
|
|
+/**
|
|
|
+ * 接入jsdk
|
|
|
+ * 乐团报名-原生js支付
|
|
|
+ * 会员购买-汇付
|
|
|
+ */
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'order-detail',
|
|
@@ -26,6 +33,7 @@ export default defineComponent({
|
|
|
const route = useRoute()
|
|
|
const router = useRouter()
|
|
|
const state = reactive({
|
|
|
+ paymentType: 'adapay' as 'wxpay' | 'adapay', // 支付方式
|
|
|
orderTimer: null as any,
|
|
|
paymentStatus: false,
|
|
|
showQrcode: false,
|
|
@@ -100,17 +108,6 @@ export default defineComponent({
|
|
|
// status
|
|
|
state.dialogStatus = true
|
|
|
state.dialogMessage = '订单' + orderStatus[data.status]
|
|
|
- // showConfirmDialog({
|
|
|
- // message: '订单处理中,请稍等',
|
|
|
- // showCancelButton: false
|
|
|
- // }).then(() => {
|
|
|
- // router.replace({
|
|
|
- // path: '/payment-result',
|
|
|
- // query: {
|
|
|
- // orderNo: state.orderNo
|
|
|
- // }
|
|
|
- // })
|
|
|
- // })
|
|
|
}
|
|
|
} catch {
|
|
|
//
|
|
@@ -120,34 +117,19 @@ export default defineComponent({
|
|
|
const onConfirm = (val: any) => {
|
|
|
const config: any = state.config
|
|
|
state.pay_channel = val.pay_channel
|
|
|
+
|
|
|
+ const params = qs.stringify({
|
|
|
+ pay_channel: val.pay_channel,
|
|
|
+ wxAppId: config.wxAppId,
|
|
|
+ body: config.body,
|
|
|
+ price: config.price,
|
|
|
+ orderNo: config.merOrderNo,
|
|
|
+ userId: config.userId
|
|
|
+ })
|
|
|
if (val.payCode === 'payResult') {
|
|
|
- window.location.href =
|
|
|
- window.location.origin +
|
|
|
- '/orchestra-student/#/payResult?' +
|
|
|
- qs.stringify({
|
|
|
- pay_channel: val.pay_channel,
|
|
|
- wxAppId: config.wxAppId,
|
|
|
- body: config.body,
|
|
|
- price: config.price,
|
|
|
- orderNo: config.merOrderNo,
|
|
|
- userId: config.userId
|
|
|
- })
|
|
|
+ window.location.href = window.location.origin + '/orchestra-student/#/payResult?' + params
|
|
|
} else {
|
|
|
- state.qrCodeUrl =
|
|
|
- window.location.origin +
|
|
|
- '/orchestra-student/#/payDefine?pay_channel=' +
|
|
|
- val.pay_channel +
|
|
|
- '&wxAppId=' +
|
|
|
- config.wxAppId +
|
|
|
- '&body=' +
|
|
|
- config.body +
|
|
|
- '&price=' +
|
|
|
- config.price +
|
|
|
- '&orderNo=' +
|
|
|
- config.merOrderNo +
|
|
|
- '&userId=' +
|
|
|
- config.userId
|
|
|
- console.log(state.qrCodeUrl, 'qrCodeUrl')
|
|
|
+ state.qrCodeUrl = window.location.origin + '/orchestra-student/#/payDefine?' + params
|
|
|
state.showQrcode = true
|
|
|
state.paymentStatus = false
|
|
|
|
|
@@ -194,66 +176,46 @@ export default defineComponent({
|
|
|
}, 5000)
|
|
|
}
|
|
|
|
|
|
- // const locationReplace = (url: any) => {
|
|
|
- // // 只允许同域名
|
|
|
- // console.log(history.replaceState, 'window.history.replaceState', url)
|
|
|
- // if (history.replaceState) {
|
|
|
- // history.replaceState(null, document.title, url)
|
|
|
- // history.go(0)
|
|
|
- // } else {
|
|
|
- // location.replace(url)
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- const beforeSubmit = () => {
|
|
|
- const pt = state.pay_channel
|
|
|
- let payCode = 'qrCode'
|
|
|
- // 判断当前浏览器
|
|
|
- if (browser().weixin) {
|
|
|
- // 微信浏览器
|
|
|
- if (pt == 'alipay_qr' || pt == 'alipay_wap') {
|
|
|
- payCode = 'qrCode'
|
|
|
- } else if (pt == 'wx_pub') {
|
|
|
- payCode = 'pay'
|
|
|
- }
|
|
|
- } else if (browser().alipay) {
|
|
|
- // 支付宝浏览器
|
|
|
- if (pt == 'alipay_wap') {
|
|
|
- // 支付宝 H5 支付
|
|
|
- payCode = 'pay'
|
|
|
- } else {
|
|
|
- payCode = 'qrCode'
|
|
|
- }
|
|
|
- } else {
|
|
|
- payCode = 'qrCode'
|
|
|
- }
|
|
|
-
|
|
|
- onConfirm({
|
|
|
- payCode: payCode == 'qrCode' ? 'payDefine' : 'payResult',
|
|
|
- pay_channel: pt
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
+ // 确定支付
|
|
|
const onSubmit = async () => {
|
|
|
clearInterval(state.orderTimer)
|
|
|
-
|
|
|
if (orderType.value === 'VIP') {
|
|
|
- // onCallback()
|
|
|
buyVip(onCallback)
|
|
|
} else {
|
|
|
buyOrchestra(onCallback)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description 回调,判断是否有支付渠道,如果有则直接去支付
|
|
|
+ * @returns void
|
|
|
+ */
|
|
|
const onCallback = () => {
|
|
|
const pt = state.pay_channel
|
|
|
// 判断是否有支付方式
|
|
|
if (pt) {
|
|
|
- beforeSubmit()
|
|
|
+ const payCode: string = beforeSubmit(state.pay_channel)
|
|
|
+ onConfirm({
|
|
|
+ payCode: payCode === 'qrCode' ? 'payDefine' : 'payResult',
|
|
|
+ pay_channel: pt
|
|
|
+ })
|
|
|
} else {
|
|
|
- state.paymentStatus = true
|
|
|
+ if (orderType.value === 'VIP') {
|
|
|
+ state.paymentStatus = true
|
|
|
+ } else {
|
|
|
+ // 直接去拉取微信支付
|
|
|
+ onConfirm({
|
|
|
+ payCode: 'payResult',
|
|
|
+ pay_channel: 'wx_pub'
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @description 会员购买
|
|
|
+ * @param callback 回调方式
|
|
|
+ */
|
|
|
const buyVip = async (callback?: any) => {
|
|
|
try {
|
|
|
state.submitStatus = true
|
|
@@ -282,6 +244,10 @@ export default defineComponent({
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @description 乐团报名 - 汇付
|
|
|
+ * @param callback 回调方式
|
|
|
+ */
|
|
|
const buyOrchestra = async (callback: any) => {
|
|
|
// 请选择收货地址
|
|
|
if (!addressDetails.value.id) {
|
|
@@ -313,7 +279,6 @@ export default defineComponent({
|
|
|
})
|
|
|
console.log(data)
|
|
|
state.pay_channel = data.paymentChannel
|
|
|
- state.submitStatus = false
|
|
|
if (data.status !== 'WAIT_PAY' && data.status !== 'PAYING') {
|
|
|
checkOrderTypeJump()
|
|
|
} else {
|
|
@@ -321,10 +286,12 @@ export default defineComponent({
|
|
|
}
|
|
|
} catch {
|
|
|
//
|
|
|
+ } finally {
|
|
|
state.submitStatus = false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 有支付结果后回调
|
|
|
const checkOrderTypeJump = () => {
|
|
|
// 判断是否是乐团报名
|
|
|
if (orderType.value === 'ORCHESTRA') {
|
|
@@ -515,48 +482,6 @@ export default defineComponent({
|
|
|
orderType={orderType.value}
|
|
|
/>
|
|
|
</OPopup>
|
|
|
- {/* <Popup
|
|
|
- v-model:show={state.showQrcode}
|
|
|
- style={{ background: 'transparent', overflow: 'initial' }}
|
|
|
- safeAreaInsetBottom={true}
|
|
|
- class={styles.popupCode}
|
|
|
- closeable
|
|
|
- onClose={() => {
|
|
|
- // 二维码关闭时清除定时器
|
|
|
- clearInterval(state.orderTimer)
|
|
|
- }}
|
|
|
- >
|
|
|
- <div class={styles.codeContainer}>
|
|
|
- <div class={styles.codeImg}>
|
|
|
- <div class={styles.codeContent}>
|
|
|
- <h2 class={styles.codeTitle}>
|
|
|
- {orderType.value === 'VIP' ? '开通会员' : '乐团报名'}
|
|
|
- </h2>
|
|
|
- <div class={styles.codeName}>
|
|
|
- 请截图下方二维码 登录{state.pay_channel === 'wx_pub' ? '微信' : '支付宝'}
|
|
|
- 扫码支付
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class={styles.codeQr}>
|
|
|
- <OQrcode text={state.qrCodeUrl} size={'400'} />
|
|
|
- </div>
|
|
|
- <div style={{ textAlign: 'center' }}>
|
|
|
- <span class={styles.codeBtnText}>请在30分钟内扫码支付</span>
|
|
|
- </div>
|
|
|
- <div class={styles.codeTips}>
|
|
|
- <div class={styles.tipsTitle}>使用说明:</div>
|
|
|
- <div class={styles.tipsContent}>
|
|
|
- 1.打开{state.pay_channel === 'wx_pub' ? '微信' : '支付宝'}扫一扫
|
|
|
- <br />
|
|
|
- 2.选择相册中的二维码
|
|
|
- <br />
|
|
|
- 3.请在30分钟内扫码支付
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </Popup> */}
|
|
|
|
|
|
<OPopup v-model:modelValue={state.authShow}>
|
|
|
<UserAuth onSuccess={onAuthSuccess} hideHeader={!browser().isApp} />
|