|
@@ -0,0 +1,90 @@
|
|
|
+<route lang="json">
|
|
|
+{ "style": { "navigationBarTitleText": "扫码结果", "navigationBarBackgroundColor": "#fff" } }
|
|
|
+</route>
|
|
|
+<script setup lang="ts">
|
|
|
+import { pointsPay } from '../../../../core/libs/requests'
|
|
|
+import { QrCodeBusinessType } from '../../../../core/libs/models'
|
|
|
+import { qrCodeString2Object, requestToast } from '../../../../core/utils/common'
|
|
|
+import { useUserStore } from '@/store'
|
|
|
+import { storeToRefs } from 'pinia'
|
|
|
+import { useRouter } from '../../../../core/utils/router'
|
|
|
+
|
|
|
+const router = useRouter()
|
|
|
+const userStore = useUserStore()
|
|
|
+const { userInfo } = storeToRefs(userStore)
|
|
|
+const msg = ref()
|
|
|
+const scanType = ref()
|
|
|
+const data = ref<{
|
|
|
+ id?: string
|
|
|
+ amount?: string
|
|
|
+ points?: string
|
|
|
+ avatar?: string
|
|
|
+ name?: string
|
|
|
+}>()
|
|
|
+const isPointsCheckout = computed(() => scanType.value === QrCodeBusinessType.PointsCheckout)
|
|
|
+const handleSubmit = async () => {
|
|
|
+ if (isPointsCheckout.value) {
|
|
|
+ const { code } = await requestToast(() =>
|
|
|
+ pointsPay({
|
|
|
+ vendorId: Number(data.value?.id),
|
|
|
+ userId: userInfo.value.userId,
|
|
|
+ points: Number(data.value?.points),
|
|
|
+ }),
|
|
|
+ )
|
|
|
+ if (code === 0) {
|
|
|
+ router.replace(`/pages/common/status/success/index?title=支付成功`)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+onLoad(async (query: { result: string }) => {
|
|
|
+ try {
|
|
|
+ const { type, options } = qrCodeString2Object(query.result)
|
|
|
+ scanType.value = type
|
|
|
+ data.value = options
|
|
|
+ console.log(scanType.value)
|
|
|
+ console.log(data.value)
|
|
|
+
|
|
|
+ if (isPointsCheckout.value) uni.setNavigationBarTitle({ title: '付款' })
|
|
|
+ } catch (error) {
|
|
|
+ msg.value = error.message
|
|
|
+ }
|
|
|
+})
|
|
|
+</script>
|
|
|
+<template>
|
|
|
+ <div class="flex-grow flex flex-col items-center justify-center">
|
|
|
+ <template v-if="isPointsCheckout">
|
|
|
+ <div class="flex items-center">
|
|
|
+ <wd-img
|
|
|
+ class="rounded-full"
|
|
|
+ width="45"
|
|
|
+ height="45"
|
|
|
+ custom-class="border border-[#f2f2f2] border-solid"
|
|
|
+ :src="data?.avatar"
|
|
|
+ />
|
|
|
+ <div class="text-black/90 text-base font-normal font-['PingFang_SC'] leading-[10.18px]">
|
|
|
+ {{ data?.name }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <div class="text-black/90 text-3xl font-normal font-['PingFang_SC'] leading-none">¥</div>
|
|
|
+ <div class="text-black/90 text-[50px] font-medium font-['DIN'] leading-none">
|
|
|
+ {{ data?.amount }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <div class="text-black/40 text-base font-normal font-['PingFang_SC'] leading-none">
|
|
|
+ 积分:{{ data?.points }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div><wd-button @click="handleSubmit">确认付款</wd-button></div>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <div class="text-black/60 text-base font-normal font-['PingFang_SC'] leading-none">
|
|
|
+ 不支持此二维码/条码
|
|
|
+ </div>
|
|
|
+ <div class="text-black/60 text-base font-normal font-['PingFang_SC'] leading-none">
|
|
|
+ {{ msg }}
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+</template>
|