分配客户群二维码

This commit is contained in:
Dev
2026-09-29 16:24:19 +08:00
parent a4b0aaa661
commit 34177dfe86
10 changed files with 445 additions and 84 deletions
+23 -14
View File
@@ -38,24 +38,14 @@ Page({
onShow() {
this.getTabBar().init();
setTimeout(() => {
fetchPerson().then((res) => {
if (res.code === 1) {
let { role } = res.data;
this.setData({
role,
});
}
});
}, 3000);
this.refreshRole();
},
onLoad() {
// 先用本地缓存渲染入口按钮,避免接口返回前闪烁;随后由 onShow 用接口数据校正
const role = (wx.getStorageSync('userInfo') || {}).role || '';
this.setData({ role });
this.init();
let role = wx.getStorageSync('userInfo')?.role;
if (role == 'dev') {
this.toDemandHall();
}
},
onReachBottom() {
@@ -65,12 +55,31 @@ Page({
onPullDownRefresh() {
this.init();
this.refreshRole();
},
init() {
this.loadHomePage();
},
/**
* 拉取最新角色并写回本地缓存
* 入驻审核通过后,用户回到小程序触发 onShow 即可看到「进入接单大厅」入口
*/
refreshRole() {
return fetchPerson().then((res) => {
if (res.code === 1 && res.data) {
const role = res.data.role || '';
this.setData({ role });
const userInfo = wx.getStorageSync('userInfo');
if (userInfo && userInfo.role !== role) {
userInfo.role = role;
wx.setStorageSync('userInfo', userInfo);
}
}
});
},
loadHomePage() {
wx.stopPullDownRefresh();
this.setData({