|
@@ -29,7 +29,8 @@ Page({
|
|
|
verilyCode: '', //验证码
|
|
verilyCode: '', //验证码
|
|
|
s: 0, //获取验证码倒计时 秒/s
|
|
s: 0, //获取验证码倒计时 秒/s
|
|
|
countDown: false,
|
|
countDown: false,
|
|
|
- avatarKey: Date.now() // 用于强制刷新头像显示
|
|
|
|
|
|
|
+ avatarKey: Date.now(), // 用于强制刷新头像显示
|
|
|
|
|
+ isProcessingAuth: false, // 标记是否正在处理授权流程
|
|
|
},
|
|
},
|
|
|
onLoad: async function (options) {
|
|
onLoad: async function (options) {
|
|
|
let Company = new Parse.Query('Company')
|
|
let Company = new Parse.Query('Company')
|
|
@@ -139,7 +140,10 @@ Page({
|
|
|
if (!auth) return
|
|
if (!auth) return
|
|
|
let userProfile = await this.getUserProfile()
|
|
let userProfile = await this.getUserProfile()
|
|
|
if (!userProfile) return
|
|
if (!userProfile) return
|
|
|
|
|
+
|
|
|
|
|
+ // 标记正在处理授权
|
|
|
this.setData({
|
|
this.setData({
|
|
|
|
|
+ isProcessingAuth: true,
|
|
|
phoneModal: true
|
|
phoneModal: true
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
@@ -148,6 +152,12 @@ Page({
|
|
|
if (!auth) return
|
|
if (!auth) return
|
|
|
let userProfile = await this.getUserProfile()
|
|
let userProfile = await this.getUserProfile()
|
|
|
if (!userProfile) return
|
|
if (!userProfile) return
|
|
|
|
|
+
|
|
|
|
|
+ // 标记正在处理授权
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ isProcessingAuth: true
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
let {
|
|
let {
|
|
|
code
|
|
code
|
|
|
} = e.detail
|
|
} = e.detail
|
|
@@ -448,6 +458,12 @@ Page({
|
|
|
});
|
|
});
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 标记正在处理授权
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ isProcessingAuth: true
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
let parsm = {
|
|
let parsm = {
|
|
|
mobile: mobile,
|
|
mobile: mobile,
|
|
|
code:verilyCode
|
|
code:verilyCode
|
|
@@ -457,6 +473,10 @@ Page({
|
|
|
if(isVerify.code == 200){
|
|
if(isVerify.code == 200){
|
|
|
this.authMobileUser(mobile.toString())
|
|
this.authMobileUser(mobile.toString())
|
|
|
}else{
|
|
}else{
|
|
|
|
|
+ // 验证失败,重置标记
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ isProcessingAuth: false
|
|
|
|
|
+ })
|
|
|
wx.showToast({
|
|
wx.showToast({
|
|
|
title:isVerify?.msg || '验证码错误',
|
|
title:isVerify?.msg || '验证码错误',
|
|
|
icon: 'none',
|
|
icon: 'none',
|
|
@@ -470,7 +490,8 @@ Page({
|
|
|
//关闭手机号授权弹窗
|
|
//关闭手机号授权弹窗
|
|
|
hideModal: function () {
|
|
hideModal: function () {
|
|
|
this.setData({
|
|
this.setData({
|
|
|
- phoneModal: false
|
|
|
|
|
|
|
+ phoneModal: false,
|
|
|
|
|
+ isProcessingAuth: false // 重置标记
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
backLoad() {
|
|
backLoad() {
|
|
@@ -481,6 +502,39 @@ Page({
|
|
|
console.log('当前页面栈层数:', pages.length);
|
|
console.log('当前页面栈层数:', pages.length);
|
|
|
console.log('当前页面路由:', pages[pages.length - 1]?.route);
|
|
console.log('当前页面路由:', pages[pages.length - 1]?.route);
|
|
|
|
|
|
|
|
|
|
+ // 检查是否有 returnUrl 参数(从 H5 页面传递过来)
|
|
|
|
|
+ const currentPage = pages[pages.length - 1];
|
|
|
|
|
+ const returnUrl = currentPage?.options?.returnUrl;
|
|
|
|
|
+
|
|
|
|
|
+ if (returnUrl) {
|
|
|
|
|
+ console.log('📍 检测到 returnUrl 参数:', returnUrl);
|
|
|
|
|
+
|
|
|
|
|
+ // 如果是 web-view 页面,跳转回去
|
|
|
|
|
+ const decodedUrl = decodeURIComponent(returnUrl);
|
|
|
|
|
+ console.log('🔙 准备跳转回 H5 页面:', decodedUrl);
|
|
|
|
|
+
|
|
|
|
|
+ wx.navigateTo({
|
|
|
|
|
+ url: `/common-page/pages/web-view/index?path=${encodeURIComponent(decodedUrl)}`,
|
|
|
|
|
+ success: () => {
|
|
|
|
|
+ console.log('✅ 跳转回 H5 页面成功');
|
|
|
|
|
+ console.log('===========================================');
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: (err) => {
|
|
|
|
|
+ console.error('❌ 跳转回 H5 页面失败:', err);
|
|
|
|
|
+ // 降级:正常返回上一页
|
|
|
|
|
+ this.normalBackLoad();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 没有 returnUrl,执行正常的返回逻辑
|
|
|
|
|
+ this.normalBackLoad();
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ normalBackLoad() {
|
|
|
|
|
+ let pages = getCurrentPages();
|
|
|
|
|
+
|
|
|
// 如果页面栈只有1层或没有上一页,直接跳转到首页
|
|
// 如果页面栈只有1层或没有上一页,直接跳转到首页
|
|
|
if (pages.length <= 1) {
|
|
if (pages.length <= 1) {
|
|
|
console.log('⚠️ 没有上一个页面,直接跳转到首页');
|
|
console.log('⚠️ 没有上一个页面,直接跳转到首页');
|
|
@@ -795,7 +849,8 @@ Page({
|
|
|
//关闭头像昵称填写弹窗
|
|
//关闭头像昵称填写弹窗
|
|
|
onClose() {
|
|
onClose() {
|
|
|
this.setData({
|
|
this.setData({
|
|
|
- wxModel: false
|
|
|
|
|
|
|
+ wxModel: false,
|
|
|
|
|
+ isProcessingAuth: false // 重置标记
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
|
|
|
|
@@ -901,10 +956,49 @@ Page({
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
onShow: function () {
|
|
onShow: function () {
|
|
|
|
|
+ console.log('=== onShow 方法被调用 ===');
|
|
|
|
|
+
|
|
|
|
|
+ // 如果正在处理授权流程,不要自动返回
|
|
|
|
|
+ if (this.data.isProcessingAuth) {
|
|
|
|
|
+ console.log('ℹ️ 正在处理授权流程,不自动返回');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果有弹窗显示(手机号弹窗或头像昵称弹窗),不要自动返回
|
|
|
|
|
+ if (this.data.phoneModal || this.data.wxModel) {
|
|
|
|
|
+ console.log('ℹ️ 有弹窗显示,不自动返回');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
let userLogin = wx.getStorageSync('userLogin');
|
|
let userLogin = wx.getStorageSync('userLogin');
|
|
|
- if (userLogin != '') {
|
|
|
|
|
- wx.navigateBack();
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ let currentUser = Parse.User.current();
|
|
|
|
|
+
|
|
|
|
|
+ console.log('userLogin 存储:', userLogin);
|
|
|
|
|
+ console.log('当前用户:', currentUser ? currentUser.id : '无');
|
|
|
|
|
+ console.log('手机号:', currentUser?.get('mobile') || '无');
|
|
|
|
|
+
|
|
|
|
|
+ // 检查是否是从其他页面跳转过来的(有 returnUrl 参数)
|
|
|
|
|
+ const pages = getCurrentPages();
|
|
|
|
|
+ const currentPage = pages[pages.length - 1];
|
|
|
|
|
+ const hasReturnUrl = currentPage?.options?.returnUrl;
|
|
|
|
|
+
|
|
|
|
|
+ if (hasReturnUrl) {
|
|
|
|
|
+ console.log('ℹ️ 检测到 returnUrl 参数,用户需要完成登录流程');
|
|
|
|
|
+ // 不要自动返回,让用户完成登录
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 只有当用户已登录且有手机号,并且不是从其他页面跳转过来时才返回
|
|
|
|
|
+ if (userLogin && currentUser && currentUser.get('mobile')) {
|
|
|
|
|
+ console.log('✅ 用户已完整登录,返回上一页');
|
|
|
|
|
+ wx.navigateBack({
|
|
|
|
|
+ fail: () => {
|
|
|
|
|
+ console.log('⚠️ 返回失败,可能是首页');
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.log('ℹ️ 用户未完整登录,显示授权页面');
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
onReady: function () {
|
|
onReady: function () {
|
|
|
|
|
|