|
|
@@ -2,14 +2,45 @@
|
|
|
import type { wxpay } from '@/api/globals'
|
|
|
import router from '@/router'
|
|
|
|
|
|
-definePage({ name: 'smqjh-threePay', islogin: false, style: { navigationBarTitleText: '支付' } })
|
|
|
+definePage({ name: 'smqjh-threePay', islogin: false, style: { navigationBarTitleText: '支付', navigationStyle: 'custom' } })
|
|
|
|
|
|
+const { token } = storeToRefs(useUserStore())
|
|
|
const orderNumber = ref()
|
|
|
onLoad((options: any) => {
|
|
|
orderNumber.value = options.orderNumber
|
|
|
- handlePay()
|
|
|
+ if (options.phone && !token.value) {
|
|
|
+ handleLogin(options.phone)
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ handlePay()
|
|
|
+ }
|
|
|
+ console.log(options, '============options=======')
|
|
|
})
|
|
|
const priceInfo = ref<wxpay>()
|
|
|
+function handleLogin(phoneCode: string) {
|
|
|
+ uni.showLoading({ mask: true })
|
|
|
+ uni.login({
|
|
|
+ provider: 'weixin',
|
|
|
+ success: async (res) => {
|
|
|
+ const data = await Apis.sys.auth({
|
|
|
+ params: {
|
|
|
+ grant_type: 'wechat',
|
|
|
+ code: res.code,
|
|
|
+ phoneCode,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ console.log(data, '============data=======')
|
|
|
+
|
|
|
+ token.value = `Bearer ${data.data.access_token}`
|
|
|
+ useUserStore().getUserInfo()
|
|
|
+ handlePay()
|
|
|
+ },
|
|
|
+ complete: () => {
|
|
|
+ uni.hideLoading()
|
|
|
+ },
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
async function handlePay() {
|
|
|
const res = await useUserStore().handleCommonPayMent(orderNumber.value)
|
|
|
priceInfo.value = res
|
|
|
@@ -22,7 +53,6 @@ async function handleGoPay() {
|
|
|
}
|
|
|
catch {
|
|
|
// console.log(111)
|
|
|
- useGlobalToast().show({ msg: '支付失败!请重试' })
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -91,18 +121,21 @@ onUnload(() => {
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <view class="px20rpx pt20rpx">
|
|
|
- <view class="text-center text-48rpx text-#FF4A39">
|
|
|
- ¥{{ priceInfo?.price }}
|
|
|
- </view>
|
|
|
- <view class="mb20rpx mt24rpx text-center text-26rpx text-[#999]">
|
|
|
- 支付剩余时间:<text class="text-[#FF4A39] font-semibold">
|
|
|
- {{ countdownText }}
|
|
|
- </text>
|
|
|
+ <view>
|
|
|
+ <wd-navbar title="支付" :bordered="false" :z-index="99" safe-area-inset-top fixed />
|
|
|
+ <view v-if="priceInfo" class="px20rpx pt20rpx">
|
|
|
+ <view class="text-center text-48rpx text-#FF4A39">
|
|
|
+ ¥{{ (priceInfo?.price / 100).toFixed(2) }}
|
|
|
+ </view>
|
|
|
+ <view class="mb20rpx mt24rpx text-center text-26rpx text-[#999]">
|
|
|
+ 支付剩余时间:<text class="text-[#FF4A39] font-semibold">
|
|
|
+ {{ countdownText }}
|
|
|
+ </text>
|
|
|
+ </view>
|
|
|
+ <wd-button block @click="handleGoPay">
|
|
|
+ 确认支付
|
|
|
+ </wd-button>
|
|
|
</view>
|
|
|
- <wd-button block @click="handleGoPay">
|
|
|
- 确认支付
|
|
|
- </wd-button>
|
|
|
</view>
|
|
|
</template>
|
|
|
|