fix: 打手端每次进入均向后端校验手机号认证

This commit is contained in:
XingQue
2026-06-22 16:42:36 +08:00
parent 0767e23f11
commit e54846df02
7 changed files with 137 additions and 104 deletions

View File

@@ -3,6 +3,7 @@ const app = getApp();
import request from '../../utils/request.js';
import PopupService from '../../services/popupService.js';
import { reconnectForRole } from '../../utils/role-tab-bar.js';
import { ensurePhoneAuth } from '../../utils/phone-auth.js';
Page({
data: {
@@ -58,7 +59,10 @@ Page({
}
},
onShow() {
async onShow() {
const phoneOk = await ensurePhoneAuth({ redirect: true, role: 'dashou' });
if (!phoneOk) return;
this.registerNotificationComponent();
this.loadGlobalStatus();
if (wx.getStorageSync('uid')) {

View File

@@ -1,7 +1,7 @@
// pages/dashou-chongzhi/index.js
import request from '../../utils/request';
// 引入弹窗服务(路径根据实际调整)
import PopupService from '../../services/popupService.js';
import { ensurePhoneAuth } from '../../utils/phone-auth.js';
Page({
data: {
@@ -83,7 +83,10 @@ onHide() {
}
},
onShow() {
async onShow() {
const phoneOk = await ensurePhoneAuth({ redirect: true, role: 'dashou' });
if (!phoneOk) return;
// 每次显示页面都刷新数据
this.registerNotificationComponent();
this.loadFromGlobalData();

View File

@@ -2,6 +2,7 @@
import { createPage, request, isRoleStatusActive, isCenterPageActive, syncRoleStatuses, syncProfileFields, syncGroupFields, ensureRoleOnCenterPage, clearCacheAndEnterNormal, lockPrimaryRole, migrateLegacyCenterRole, enterLockedRole, parseSceneOptions } from '../../utils/base-page.js'
import { resolveAvatarUrl } from '../../utils/avatar.js'
import { openPrivateChat, buildInviterPeerId } from '../../utils/im-user.js'
import { ensurePhoneAuth } from '../../utils/phone-auth.js'
const PLATFORM_INVITE_CODE = '0000008RffVgKHMj7kQC'
@@ -171,7 +172,10 @@ Page(createPage({
this.checkColdStartPopup('dashouduan');
},
onShow() {
async onShow() {
const phoneOk = await ensurePhoneAuth({ redirect: true, role: 'dashou' });
if (!phoneOk) return;
migrateLegacyCenterRole(getApp());
lockPrimaryRole('dashou', getApp());
wx.setStorageSync('isJinpai', 0);

View File

@@ -1,4 +1,4 @@
import { submit } from '../../utils/phone-auth';
import { submit, getPhoneAuthReturnPage } from '../../utils/phone-auth';
Page({
data: {
@@ -27,8 +27,7 @@ Page({
wx.showLoading({ title: '认证中...', mask: true });
await submit(phoneCode, avatarFile);
wx.hideLoading();
// 成功重启小程序此时check返回false用户无感进入
wx.reLaunch({ url: '/pages/index/index' });
wx.reLaunch({ url: getPhoneAuthReturnPage() });
} catch (e) {
wx.hideLoading();
wx.showToast({ title: e.message, icon: 'none' });
@@ -37,4 +36,4 @@ Page({
exit() {
wx.exitMiniProgram();
}
});
});