|
@@ -7,83 +7,85 @@ import logoEn from '@/assets/images/logoEn.png'
|
|
import { useUserStore } from '@/stores/user'
|
|
import { useUserStore } from '@/stores/user'
|
|
import QrcodeVue from 'qrcode.vue'
|
|
import QrcodeVue from 'qrcode.vue'
|
|
import { show, showConfirm } from '@/components/Toast'
|
|
import { show, showConfirm } from '@/components/Toast'
|
|
-import { openPay, queryOrderStatus } from '@/api/api'
|
|
|
|
-import { useRouter, useRoute } from 'vue-router';
|
|
|
|
|
|
+import { openPay, queryOrderStatus, getOrderInfo } from '@/api/api'
|
|
|
|
+import { useRouter, useRoute } from 'vue-router'
|
|
import { GetRequest } from '@/utils/index'
|
|
import { GetRequest } from '@/utils/index'
|
|
import { getCurrentInstance } from 'vue'
|
|
import { getCurrentInstance } from 'vue'
|
|
|
|
|
|
-//得到i18n的locale token, info,
|
|
|
|
|
|
+//得到i18n的locale token, info,
|
|
const { locale: language } = useI18n()
|
|
const { locale: language } = useI18n()
|
|
let t1 = null
|
|
let t1 = null
|
|
const route = useRoute()
|
|
const route = useRoute()
|
|
const { isEur, info } = useUserStore()
|
|
const { isEur, info } = useUserStore()
|
|
-console.log('route',route)
|
|
|
|
|
|
+console.log('route', route)
|
|
const orderSn = ref(route.query.id || GetRequest('orderSn'))
|
|
const orderSn = ref(route.query.id || GetRequest('orderSn'))
|
|
-let { $cdn } = getCurrentInstance()?.proxy;
|
|
|
|
|
|
+let { $cdn } = getCurrentInstance()?.proxy
|
|
let PAYSID = {
|
|
let PAYSID = {
|
|
wechatPay: 0,
|
|
wechatPay: 0,
|
|
alipay: 1,
|
|
alipay: 1,
|
|
- paypal: 2,
|
|
|
|
-};
|
|
|
|
|
|
+ paypal: 2
|
|
|
|
+}
|
|
const selectedPayType = ref('alipay')
|
|
const selectedPayType = ref('alipay')
|
|
watch(selectedPayType, () => {
|
|
watch(selectedPayType, () => {
|
|
getCode()
|
|
getCode()
|
|
})
|
|
})
|
|
const qrCodeUrl = ref('')
|
|
const qrCodeUrl = ref('')
|
|
|
|
+const orderDetal = ref({})
|
|
const response = ref({
|
|
const response = ref({
|
|
price: 0.01,
|
|
price: 0.01,
|
|
src: ''
|
|
src: ''
|
|
})
|
|
})
|
|
-console.log('orderSn',orderSn,route)
|
|
|
|
|
|
+console.log('orderSn', orderSn, route)
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
|
+ getDetial()
|
|
getCode()
|
|
getCode()
|
|
})
|
|
})
|
|
|
|
|
|
function inverRequest() {
|
|
function inverRequest() {
|
|
- clearInterval(t1);
|
|
|
|
- t1 = null;
|
|
|
|
- t1 = setInterval(() => {
|
|
|
|
- handleQueryOrderStatus();
|
|
|
|
- }, 5000);
|
|
|
|
|
|
+ clearInterval(t1)
|
|
|
|
+ t1 = null
|
|
|
|
+ t1 = setInterval(() => {
|
|
|
|
+ handleQueryOrderStatus()
|
|
|
|
+ }, 5000)
|
|
}
|
|
}
|
|
async function handleQueryOrderStatus() {
|
|
async function handleQueryOrderStatus() {
|
|
- if (t1) {
|
|
|
|
- let params = {
|
|
|
|
- orderSn:orderSn.value,
|
|
|
|
- // orderType: Number(orderType),//预订单无支付方式
|
|
|
|
- payType: Number(PAYSID[selectedPayType.value]),
|
|
|
|
- };
|
|
|
|
- let res = await queryOrderStatus(params);
|
|
|
|
- let response = res.data;
|
|
|
|
- if (response.code === 0 && response.data) {
|
|
|
|
- t1 = null;
|
|
|
|
- t1 && clearInterval(t1);
|
|
|
|
- showConfirm({
|
|
|
|
- text: '支付成功',
|
|
|
|
- type: 'success',
|
|
|
|
- callback: (val) => {
|
|
|
|
- console.log('点击支付,支付成功', val)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- // this.$store.dispatch('getInfo', {url: '/user/getUserInfo', name: 'info'})
|
|
|
|
- // this.$toast.show('success', this.$t('mall.member.buySuccessTip'), () => {
|
|
|
|
- // this.$router.push('/information')
|
|
|
|
- // })
|
|
|
|
|
|
+ if (t1) {
|
|
|
|
+ let response = await getOrderInfo(orderSn.value)
|
|
|
|
+ console.log('response', response)
|
|
|
|
+ if (response.payStatus === 0) {
|
|
|
|
+ //未支付
|
|
|
|
+ console.log('未支付')
|
|
|
|
+ } else {
|
|
|
|
+ //支付失败
|
|
|
|
+ t1 = null
|
|
|
|
+ t1 && clearInterval(t1)
|
|
|
|
+ showConfirm({
|
|
|
|
+ text: response.payStatus === 2 ? '支付失败' : '支付成功',
|
|
|
|
+ type: response.payStatus === 2 ? 'err' : 'success',
|
|
|
|
+ callback: (val) => {
|
|
|
|
+ console.log('点击支付,支付成功', val)
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+function getDetial() {
|
|
|
|
+ getOrderInfo(orderSn.value).then((res) => {
|
|
|
|
+ orderDetal.value = res
|
|
|
|
+ })
|
|
}
|
|
}
|
|
async function getCode() {
|
|
async function getCode() {
|
|
qrCodeUrl.value = ''
|
|
qrCodeUrl.value = ''
|
|
let paysidtype = {
|
|
let paysidtype = {
|
|
- wechatPay: 2,
|
|
|
|
- alipay: 3,
|
|
|
|
- paypal: 0
|
|
|
|
-}
|
|
|
|
|
|
+ wechatPay: 2,
|
|
|
|
+ alipay: 3,
|
|
|
|
+ paypal: 0
|
|
|
|
+ }
|
|
openPay({
|
|
openPay({
|
|
- orderSn:orderSn.value,
|
|
|
|
- payType:paysidtype[selectedPayType.value],
|
|
|
|
- openId:'',
|
|
|
|
- }).then(res => {
|
|
|
|
|
|
+ orderSn: orderSn.value,
|
|
|
|
+ payType: paysidtype[selectedPayType.value],
|
|
|
|
+ openId: ''
|
|
|
|
+ }).then((res) => {
|
|
qrCodeUrl.value = res.qrCodeUrl
|
|
qrCodeUrl.value = res.qrCodeUrl
|
|
inverRequest()
|
|
inverRequest()
|
|
})
|
|
})
|
|
@@ -128,7 +130,8 @@ async function getCode() {
|
|
<img :src="`${$cdn}images/tag-icon.png`" class="t-click" alt />
|
|
<img :src="`${$cdn}images/tag-icon.png`" class="t-click" alt />
|
|
{{ $t('mall.wechatPay') }}
|
|
{{ $t('mall.wechatPay') }}
|
|
</div>
|
|
</div>
|
|
- <div v-if="isEur"
|
|
|
|
|
|
+ <div
|
|
|
|
+ v-if="isEur"
|
|
class="pay-type paypal-pay"
|
|
class="pay-type paypal-pay"
|
|
@click="selectedPayType = 'paypal'"
|
|
@click="selectedPayType = 'paypal'"
|
|
:class="{ 'is-active': selectedPayType === 'paypal' }"
|
|
:class="{ 'is-active': selectedPayType === 'paypal' }"
|
|
@@ -142,8 +145,9 @@ async function getCode() {
|
|
<div class="pay-info">
|
|
<div class="pay-info">
|
|
<p class="label">{{ $t('mall.payNum') }}:</p>
|
|
<p class="label">{{ $t('mall.payNum') }}:</p>
|
|
<p class="price">¥{{ response.price }}</p>
|
|
<p class="price">¥{{ response.price }}</p>
|
|
- <div class="pay-qrcode" style="min-height:220px">
|
|
|
|
- <QrcodeVue v-if="qrCodeUrl"
|
|
|
|
|
|
+ <div class="pay-qrcode" style="min-height: 220px">
|
|
|
|
+ <QrcodeVue
|
|
|
|
+ v-if="qrCodeUrl"
|
|
:value="qrCodeUrl"
|
|
:value="qrCodeUrl"
|
|
class="enter-x flex justify-center xl:justify-start"
|
|
class="enter-x flex justify-center xl:justify-start"
|
|
:size="190"
|
|
:size="190"
|
|
@@ -251,7 +255,7 @@ async function getCode() {
|
|
line-height: 1;
|
|
line-height: 1;
|
|
font-size: 12px;
|
|
font-size: 12px;
|
|
}
|
|
}
|
|
- .t-icon{
|
|
|
|
|
|
+ .t-icon {
|
|
width: 30px;
|
|
width: 30px;
|
|
height: 30px;
|
|
height: 30px;
|
|
padding: 6px;
|
|
padding: 6px;
|
|
@@ -264,7 +268,7 @@ async function getCode() {
|
|
bottom: 0;
|
|
bottom: 0;
|
|
display: none;
|
|
display: none;
|
|
display: none;
|
|
display: none;
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
.pay-icon {
|
|
.pay-icon {
|
|
position: absolute;
|
|
position: absolute;
|