|
@@ -10,6 +10,10 @@ Page({
|
|
|
},
|
|
|
|
|
|
onLoad: function (options) {
|
|
|
+ console.log('页面加载时的全局数据:', {
|
|
|
+ currentAccountInfo: app.globalData.currentAccountInfo,
|
|
|
+ userWxInfo: app.globalData.userWxInfo
|
|
|
+ });
|
|
|
this.getAccountList();
|
|
|
},
|
|
|
|
|
@@ -24,7 +28,7 @@ Page({
|
|
|
url: app.globalData.interfaceUrls.accountList,
|
|
|
method: 'GET',
|
|
|
header: {
|
|
|
- 'content-type': 'application/json', // 默认值
|
|
|
+ 'content-type': 'application/json',
|
|
|
'token': app.globalData.userWxInfo.token,
|
|
|
'source': "wc",
|
|
|
'!SAAS_LOGIN_TOKEN_!': app.globalData.currentAccountInfo.dsKey
|
|
@@ -32,14 +36,35 @@ Page({
|
|
|
success(res) {
|
|
|
wx.hideLoading();
|
|
|
let apiReturnData = res.data;
|
|
|
- debugger;
|
|
|
+
|
|
|
+ // 从全局获取当前账户的信息currentAccountInfo
|
|
|
+ const currentUsernumber = app.globalData.currentAccountInfo.usernumber;
|
|
|
+
|
|
|
+ console.log('当前用户信息:', {
|
|
|
+ currentUsernumber: currentUsernumber,
|
|
|
+ currentAccountInfo: app.globalData.currentAccountInfo
|
|
|
+ });
|
|
|
+
|
|
|
_this.setData({
|
|
|
- huHaoList: apiReturnData.data,
|
|
|
- })
|
|
|
+ huHaoList: apiReturnData.data.map(item => {
|
|
|
+ const isCurrent = item.usernumber === currentUsernumber;
|
|
|
+ console.log('比较户号:', {
|
|
|
+ itemNumber: item.usernumber,
|
|
|
+ currentNumber: currentUsernumber,
|
|
|
+ isCurrent: isCurrent,
|
|
|
+ username: item.username
|
|
|
+ });
|
|
|
+
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ isCurrentUser: isCurrent
|
|
|
+ };
|
|
|
+ })
|
|
|
+ });
|
|
|
},
|
|
|
fail(error) {
|
|
|
- wx.hideLoading()
|
|
|
- utils.simleInfo('获取数据失败,请稍后再试')
|
|
|
+ wx.hideLoading();
|
|
|
+ utils.simleInfo('获取数据失败,请稍后再试');
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -88,13 +113,11 @@ Page({
|
|
|
account: unbindInfo.usernumber,
|
|
|
deKey: unbindInfo.dsKey,
|
|
|
refresh: false,
|
|
|
- //为true 时otherDsKeys最好必填节约后端请求时间
|
|
|
otherDsKeys: []
|
|
|
},
|
|
|
header: {
|
|
|
'content-type': 'application/json', // 默认值
|
|
|
'token': app.globalData.userWxInfo.token,
|
|
|
- // '!SAAS_LOGIN_TOKEN_!': app.globalData.currentAccountInfo.dsKey
|
|
|
},
|
|
|
success(res) {
|
|
|
wx.hideLoading();
|
|
@@ -148,4 +171,36 @@ Page({
|
|
|
goBack: function () {
|
|
|
wx.navigateBack();
|
|
|
},
|
|
|
+
|
|
|
+ switchHuHao(e) {
|
|
|
+ const huHaoInfo = e.currentTarget.dataset.item;
|
|
|
+ // 更新全局数据
|
|
|
+ app.globalData.userWxInfo = {
|
|
|
+ ...app.globalData.userWxInfo,
|
|
|
+ username: huHaoInfo.username,
|
|
|
+ usernumber: huHaoInfo.usernumber,
|
|
|
+ address: huHaoInfo.address,
|
|
|
+ groupName: huHaoInfo.groupName,
|
|
|
+ currentDsKey: huHaoInfo.dsKey // 更新 currentDsKey
|
|
|
+ };
|
|
|
+
|
|
|
+ // 更新当前账户信息
|
|
|
+ app.globalData.currentAccountInfo = huHaoInfo;
|
|
|
+ // 将新选择的户号信息保存到本地存储
|
|
|
+ wx.setStorageSync('currentHuHao', huHaoInfo);
|
|
|
+ wx.showToast({
|
|
|
+ title: '户号切换成功',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 1500
|
|
|
+ });
|
|
|
+ // 设置一个标记表示需要刷新首页
|
|
|
+ wx.setStorageSync('needRefreshHomepage', true);
|
|
|
+
|
|
|
+ // 延迟跳转到首页
|
|
|
+ setTimeout(() => {
|
|
|
+ wx.switchTab({
|
|
|
+ url: '/pages/homepage/homepage'
|
|
|
+ });
|
|
|
+ }, 1500);
|
|
|
+ },
|
|
|
})
|