优化列表刷新加载
This commit is contained in:
+26
-22
@@ -20,29 +20,33 @@ App({
|
||||
//通过分享链接/小程序码冷启动时缓存推广人,随登录请求一起绑定
|
||||
savePendingPromoter(options && options.query);
|
||||
this.loggingIn = true;
|
||||
// 登录
|
||||
wx.login({
|
||||
success: (res) => {
|
||||
util.request(api.AuthLoginByWeixin, {
|
||||
code: res.code,
|
||||
[PROMOTER_KEY]: getPendingPromoter(),
|
||||
}, 'POST').then((res) => {
|
||||
this.loggingIn = false;
|
||||
if (res.code === 1) {
|
||||
let userInfo = res.data.userinfo;
|
||||
wx.setStorageSync('token', res.data.token);
|
||||
wx.setStorageSync('userInfo', userInfo);
|
||||
//推广关系为永久绑定,登录成功后无论是否绑定都无需再次提交
|
||||
clearPendingPromoter();
|
||||
}
|
||||
}).catch((err) => {
|
||||
this.loggingIn = false;
|
||||
console.error('wxLogin failed:', err);
|
||||
});
|
||||
},
|
||||
fail: () => {
|
||||
// 登录。loginReady 给需要鉴权的请求等待,避免首屏带着空 token 发出去
|
||||
this.loginReady = new Promise((resolve) => {
|
||||
const finish = () => {
|
||||
this.loggingIn = false;
|
||||
},
|
||||
resolve();
|
||||
};
|
||||
wx.login({
|
||||
success: (loginRes) => {
|
||||
util.request(api.AuthLoginByWeixin, {
|
||||
code: loginRes.code,
|
||||
[PROMOTER_KEY]: getPendingPromoter(),
|
||||
}, 'POST', { auth: false }).then((res) => {
|
||||
if (res.code === 1) {
|
||||
let userInfo = res.data.userinfo;
|
||||
util.setToken(res.data.token);
|
||||
wx.setStorageSync('userInfo', userInfo);
|
||||
//推广关系为永久绑定,登录成功后无论是否绑定都无需再次提交
|
||||
clearPendingPromoter();
|
||||
}
|
||||
}).catch((err) => {
|
||||
console.error('wxLogin failed:', err);
|
||||
}).then(finish);
|
||||
},
|
||||
fail: () => {
|
||||
finish();
|
||||
},
|
||||
});
|
||||
});
|
||||
},
|
||||
onShow: function (options) {
|
||||
|
||||
Reference in New Issue
Block a user