Commit f3a7167d authored by 李驰骋's avatar 李驰骋

未安装门户情况进入首页异常解决,门户登录地址不能访问情况不提示加载中

parent 6dd4917d
......@@ -21,9 +21,13 @@
onShow: function() {
// #ifdef APP-PLUS
setTimeout(function() { // 被唤醒获取参数 需异步一下
const args = plus.runtime.arguments
if (plus.runtime.arguments && typeof args === 'string') {
const data = nativePlugin.handleOpenURL(args)
try {
const args = plus.runtime.arguments
if (plus.runtime.arguments && typeof args === 'string') {
const data = nativePlugin.handleOpenURL(args)
}
} catch (e) {
console.error('handleOpenURL error:', e)
}
}, 100);
// #endif
......
......@@ -132,6 +132,10 @@
ToastPlusModule && this.initEx()
},
onShow() {
// 如果用户已经登录,不调用 authEx
if (this.userInfo && this.userInfo.code) {
return
}
// 判断是否正在等待authEx的返回结果,第一次进入页面默认是false
if (!this.flag && !this.accessToken) {
ToastPlusModule && this.authEx()
......@@ -160,13 +164,22 @@
uni.showLoading({
title: '加载中'
});
// 调用同步方法
var obj = ToastPlusModule.registerSyncFunc({
appKey: 'com.wuliangye.emobilewlycrm',
secretKey: '9ab24ae4bfb349cca739ab15b78f1c7f8737eb73',
packageName: 'com.uusafe.portal.wly'
})
console.log(obj)
try {
// 调用同步方法
var obj = ToastPlusModule.registerSyncFunc({
appKey: 'com.wuliangye.emobilewlycrm',
secretKey: '9ab24ae4bfb349cca739ab15b78f1c7f8737eb73',
packageName: 'com.uusafe.portal.wly'
})
console.log(obj)
} catch (e) {
console.error('initEx error:', e)
} finally {
// 确保隐藏 loading
setTimeout(() => {
uni.hideLoading()
}, 500)
}
},
checkboxChangeNum(){
if (e.detail.value.length == 1) {
......@@ -200,14 +213,49 @@
});
// 开启等待被唤醒
this.flag = true
ToastPlusModule.registerExSyncFunc({}, res => {
// 设置超时,确保 loading 一定会被隐藏
const timeoutId = setTimeout(() => {
if (this.flag) {
this.flag = false
uni.hideLoading()
}
}, 5000)
try {
if (ToastPlusModule && typeof ToastPlusModule.registerExSyncFunc === 'function') {
ToastPlusModule.registerExSyncFunc({}, res => {
clearTimeout(timeoutId)
this.flag = false
// 只有从第三方APP进入且返回有效token时才调用getIdToken
// 检查返回结果:必须有token且是有效字符串
const token = res?.data?.token || (typeof res === 'string' ? res : null)
if (token && typeof token === 'string' && token.trim() !== '') {
this.accessToken = token
this.getIdToken()
} else {
// 不是从第三方APP进入,或者返回数据无效,不执行getIdToken
uni.hideLoading()
}
})
} else {
clearTimeout(timeoutId)
this.flag = false
uni.hideLoading()
}
} catch (e) {
clearTimeout(timeoutId)
this.flag = false
this.accessToken = res.data?.token || res
this.getIdToken()
})
uni.hideLoading()
console.error('authEx error:', e)
}
},
async getIdToken(){
// 再次检查 accessToken 是否有效,确保只有从第三方APP进入才执行
if (!this.accessToken || typeof this.accessToken !== 'string' || this.accessToken.trim() === '') {
uni.hideLoading()
return
}
uni.showLoading({
title: '加载中'
});
......@@ -241,6 +289,7 @@
}
}catch(e){
uni.hideLoading()
uni.showToast({
title: e,
icon: 'none',
......
......@@ -76,8 +76,18 @@ const install = (Vue, vm) => {
if(!res.status&&!res.msgtype&&!res.MSGTYPE){
return res;
}
// 获取错误信息
let errorMsg = res.MESSAGE || res.msg || res.message || res.ErrMsg || ''
if (res.errors && Array.isArray(res.errors) && res.errors.length > 0) {
errorMsg = res.errors[0]
}
// 过滤技术错误信息,不显示给用户
if (errorMsg && typeof errorMsg === 'string' &&
(errorMsg.indexOf('cannot be cast') !== -1 || errorMsg.indexOf('DCloudApplication') !== -1)) {
return false
}
uni.showToast({
title: res.MESSAGE || res.msg || res.message || res.ErrMsg,
title: errorMsg,
duration: 4000,
icon: 'none'
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment