diff --git a/App.vue b/App.vue index 464268e..3f67d8a 100644 --- a/App.vue +++ b/App.vue @@ -25,6 +25,10 @@ const params = new URLSearchParams(query); // 创建一个URLSearchParams对象 ticket=params.get('ticket'); } + + if (!ticket){ + this.closeWindow() + } // alert(ticket) if(ticket){ uni.showLoading({ @@ -66,7 +70,6 @@ // } // }); // } - uni.request({ header: { "Content-Type": "application/json", @@ -78,9 +81,8 @@ }, method: "POST", success: res => { - console.log(res); + uni.hideLoading() if(res.data){ - console.log(res.data) var data=res.data; if(data.data){ var datas=data.data; @@ -93,25 +95,25 @@ uni.switchTab({ url: '/pages/index/index' }); - } - else{ + }else{ uni.showModal({ title: '提示', - content: '获取登录token失败,请重新登录后进入!', + content: '登录失败,请重新登录后进入!', cancelText: '取消', confirmText: '确定', success: ress => { + this.closeWindow() } }); } - } - else{ + }else{ uni.showModal({ title: '提示', - content: '获取登录token失败,请重新登录后进入!', + content: '登录失败,请重新登录后进入!', cancelText: '取消', confirmText: '确定', success: ress => { + this.closeWindow() } }); } @@ -120,10 +122,11 @@ console.log("err",err); uni.showModal({ title: '提示', - content: '获取登录token请求失败,请重新登录后进入!', + content: '登录请求失败,请重新登录后进入!', cancelText: '取消', confirmText: '确定', success: ress => { + this.closeWindow() } }); } @@ -204,7 +207,20 @@ } } }, - + closeWindow(){ + if (window.plus) { // 确保在App环境中运行 + const main = plus.android.runtimeMainActivity(); // Android方式调用退出 + main.finish(); // Android方式调用退出 + // 或者使用iOS方式的调用方式... + } else { + console.log('Not in App environment.'); // 非App环境提示信息 + setTimeout(function() { + uni.redirectTo({ + url: '/pages/login/index' + }); + }, 2000); + } + } } } diff --git a/components/scanQR.vue b/components/scanQR.vue index 41fe49d..bbe5ef6 100644 --- a/components/scanQR.vue +++ b/components/scanQR.vue @@ -174,6 +174,7 @@ }, handleSuccess(result) { + result=result.replace('\r','').replace('\n') uni.vibrateShort(); uni.showModal({ title: '扫码结果', diff --git a/pages/index/index.vue b/pages/index/index.vue index 1a924ea..1b03d66 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -141,19 +141,19 @@ this.initMenu(); }, onShow() { - if (!uni.getStorageSync("token")) { - uni.showToast({ - title: '登录已失效!请您重新登录!', - duration: 2000, - icon: "none" - }); - setTimeout(function() { - uni.redirectTo({ - url: '/pages/login/index' - }); - }, 2000); - - } + // if (!uni.getStorageSync("token")) { + // uni.showToast({ + // title: '登录已失效!请您重新登录!', + // duration: 2000, + // icon: "none" + // }); + // setTimeout(function() { + // uni.redirectTo({ + // url: '/pages/login/index' + // }); + // }, 2000); + // + // } //#ifdef APP-PLUS @@ -197,7 +197,23 @@ }, // 获取菜单权限 gotoMenu(item){ - + const token= uni.getStorageSync("token"); + if(!token){ + if (window.plus) { // 确保在App环境中运行 + const main = plus.android.runtimeMainActivity(); // Android方式调用退出 + main.finish(); // Android方式调用退出 + // 或者使用iOS方式的调用方式... + } else { + console.log('Not in App environment.'); // 非App环境提示信息 + setTimeout(function() { + uni.redirectTo({ + url: '/pages/login/index' + }); + }, 2000); + } + return false; + } + if(item.name=="扫码查询"){ var _that=this,rmbm=""; diff --git a/pages/me/index.vue b/pages/me/index.vue index 44328cd..453d252 100644 --- a/pages/me/index.vue +++ b/pages/me/index.vue @@ -37,9 +37,9 @@ - + @@ -226,9 +226,9 @@ uni.removeStorageSync('token'); uni.removeStorageSync('user'); uni.removeStorageSync('bmmc'); - uni.redirectTo({ - url: '/pages/login/index' - }); + // uni.redirectTo({ + // url: '/pages/login/index' + // }); },500); }, setpsd(){ diff --git a/pages/pallet/ps.vue b/pages/pallet/ps.vue index 144c970..0ca671c 100644 --- a/pages/pallet/ps.vue +++ b/pages/pallet/ps.vue @@ -101,13 +101,13 @@ - +