Authored by QC-L

修复注册不成功的问题 review by 黄敬囿

@@ -74,18 +74,20 @@ export const getPhoneNumber = async (e) => { @@ -74,18 +74,20 @@ export const getPhoneNumber = async (e) => {
74 74
75 let userInfo = wx.getStorageSync('userInfo'); 75 let userInfo = wx.getStorageSync('userInfo');
76 userInfo = Object.assign(userInfo, newUserInfo); 76 userInfo = Object.assign(userInfo, newUserInfo);
77 - await setStorageWithValueForKey('userInfo', userInfo);  
78 - await setStorageWithValueForKey('sessionkey', result.session_key); 77 + await setStorageValueForKey('userInfo', userInfo);
  78 + await setStorageValueForKey('sessionkey', bindResult.session_key);
79 79
80 app.globalData.userInfo = userInfo; 80 app.globalData.userInfo = userInfo;
81 - event.emit('wechat-login-success'); 81 + setTimeout(() => {
  82 + event.emit('wechat-login-success');
  83 + }, 1000);
82 event.emit('user-login-success', newUserInfo); 84 event.emit('user-login-success', newUserInfo);
83 wx.showToast({ 85 wx.showToast({
84 icon: 'none', 86 icon: 'none',
85 title: '手机号授权成功!\r\n为享受更多权益,已为您注册有货会员!', 87 title: '手机号授权成功!\r\n为享受更多权益,已为您注册有货会员!',
86 duration: 3000 88 duration: 3000
87 }); 89 });
88 - } else if (bindResult && bindResult.is_register === 2) { 90 + } else if (bindResult && (bindResult.is_register === 2 || bindResult.is_register === 3 || bindResult.is_register === 4)) {
89 const newUserInfo = { 91 const newUserInfo = {
90 is_bind: bindResult.is_bind, 92 is_bind: bindResult.is_bind,
91 mobile: bindResult.profile, 93 mobile: bindResult.profile,
@@ -98,8 +100,8 @@ export const getPhoneNumber = async (e) => { @@ -98,8 +100,8 @@ export const getPhoneNumber = async (e) => {
98 100
99 let userInfo = wx.getStorageSync('userInfo'); 101 let userInfo = wx.getStorageSync('userInfo');
100 userInfo = Object.assign(userInfo, newUserInfo); 102 userInfo = Object.assign(userInfo, newUserInfo);
101 - await setStorageWithValueForKey('userInfo', userInfo);  
102 - await setStorageWithValueForKey('sessionkey', result.session_key); 103 + await setStorageValueForKey('userInfo', userInfo);
  104 + await setStorageValueForKey('sessionkey', bindResult.session_key);
103 105
104 app.globalData.userInfo = userInfo; 106 app.globalData.userInfo = userInfo;
105 event.emit('wechat-login-success'); 107 event.emit('wechat-login-success');
@@ -162,7 +162,7 @@ Page(Object.assign({ @@ -162,7 +162,7 @@ Page(Object.assign({
162 }); 162 });
163 }) 163 })
164 } else { 164 } else {
165 - this._getReleaseData(); 165 + this._loadReleaseData();
166 } 166 }
167 }, 167 },
168 168
@@ -295,6 +295,34 @@ Page(Object.assign({ @@ -295,6 +295,34 @@ Page(Object.assign({
295 data = res.data; 295 data = res.data;
296 } 296 }
297 this.setData({ 297 this.setData({
  298 + [key]: data,
  299 + [keyPage]: 1
  300 + })
  301 + if (data.length === 0) {
  302 + this.setData({
  303 + footText: '暂无更多内容'
  304 + })
  305 + }
  306 + });
  307 + },
  308 +
  309 + _loadReleaseData(my_page) {
  310 + if (!this.data.isLogin) {
  311 + return;
  312 + }
  313 + let type = 1;
  314 + let my_zero_list = this.data.my_zero_list;
  315 + let page = my_zero_list[type].page;
  316 + let oldData = my_zero_list[type].data;
  317 + let key = `my_zero_list[${type}].data`;
  318 + let keyPage = `my_zero_list[${type}].page`;
  319 + console.log('执行了');
  320 + this.service.getMyList({ type, page }).then(res => {
  321 + let data = []
  322 + if (res && res.code === 200) {
  323 + data = res.data;
  324 + }
  325 + this.setData({
298 [key]: oldData.concat(data), 326 [key]: oldData.concat(data),
299 [keyPage]: ++page 327 [keyPage]: ++page
300 }) 328 })