From c276c9431bf32c029ffe15daf8124a61a3baf694 Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Wed, 15 Jan 2025 15:24:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=A2=9E=E5=8A=A0=E8=BD=AE?= =?UTF-8?q?=E8=AF=A2=EF=BC=8Cstore/common=E5=88=A4=E6=96=AD=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E5=B1=95=E7=A4=BA=E7=BA=A2=E5=8C=85=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/pays/pays.vue | 44 ++++++++++++++++++++++++++++++++++++-------- store/common.js | 12 ++++++------ 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/pages/pays/pays.vue b/pages/pays/pays.vue index 8bed8ee..c43aaa5 100644 --- a/pages/pays/pays.vue +++ b/pages/pays/pays.vue @@ -17,6 +17,7 @@ const state = reactive({ orderId: '', timer: null, + timer1: null, maxAjaxNum: 5, ajaxNum: 0, url: null, //要打开的外部链接 @@ -31,6 +32,8 @@ getOrderInfo({ orderId: state.orderId }).then(res => { + state.ajaxNum+=1 + console.log(res); if (res == 1) { uni.hideLoading() @@ -50,31 +53,56 @@ title: '支付成功', icon: 'none' }) - state.timer = setTimeout(() => { - clearTimeout(state.timer) + state.timer1 = setTimeout(() => { + cleartimer() uni.navigateBack() }, 500) } } else { - // #ifdef APP - uni.showLoading({ - title: '支付中' - }) - // #endif + + } + + if(state.ajaxNum>=state.maxAjaxNum){ + uni.navigateBack() + cleartimer() } }); } + + function cleartimer(){ + console.log('cleartimer'); + uni.hideLoading() + clearInterval(state.timer) + clearTimeout(state.timer1) + state.timer=null + state.timer1=null + state.ajaxNum=0 + } onShow(() => { + // #ifdef APP + uni.showLoading({ + title: '支付中' + }) + // #endif + state.ajaxNum=0; getOrder() + clearInterval(state.timer) + state.timer=setInterval(()=>{ + getOrder() + },2000) }) onHide(() => { + console.log('onHide'); + cleartimer() uni.hideLoading() }) onUnload(() => { + console.log('onUnload'); + cleartimer() + uni.hideLoading() uni.hideLoading() }) onLoad((option) => { - console.log(option); state.url = option.url state.orderId = option.orderId }) diff --git a/store/common.js b/store/common.js index 8f48108..c6d4011 100644 --- a/store/common.js +++ b/store/common.js @@ -46,12 +46,15 @@ export const useCommonStore = defineStore("common", { return { payTips: '付款完成后不要忘记抽红包哦', goldBili: 0, - sysInfo:{} + sysInfo:{}, + isIos:false, + isExamine:1 }; }, actions: { async init() { this.sysInfo=uni.getSystemInfoSync() + this.isIos=this.sysInfo.platform == 'ios' const res = await getCommonConfig() if (res) { for (let i in $map) { @@ -64,13 +67,10 @@ export const useCommonStore = defineStore("common", { } }, isIosExamine() { - const sysInfo = uni.getSystemInfoSync(); - let isIos = sysInfo.platform == 'ios' - if (!isIos) { + if (!this.isIos) { return true } - let isExamine = useCommonStore() - if (isExamine.isExamine == 1) { + if (this.isExamine == 1) { return false } return true