Commit e5b30463 by 姜雷

Merge branch 'develop' into test

parents e9f7f59a ac1631f4
...@@ -100,76 +100,88 @@ Page({ ...@@ -100,76 +100,88 @@ Page({
if (this.validateLoginData()) { if (this.validateLoginData()) {
const { account, pwd } = this.data; const { account, pwd } = this.data;
console.log(account, pwd); console.log(account, pwd);
wx.login({ wx.requestSubscribeMessage({
success: res => { tmplIds: ['WU2yMHKM_yNPLGHRsstggsDYnZhKoHIg4heM2fZkD5I'],
if (res.code) { success(res) {
const code = res.code; console.log('in success', res);
wx.showLoading({ title: '' }); },
systemFetch({ fail(res) {
url: '/login/verifyCode', console.log('in fail', res);
}) },
.then((res: wx.RequestSuccessCallbackResult) => { complete(res) {
console.log(res); console.log('in complete', res);
return { wx.login({
verifyCode: res.data.verifyCode, success: res => {
cookie: res.header['Set-Cookie'], if (res.code) {
}; const code = res.code;
}) wx.showLoading({ title: '' });
.then( systemFetch({
({ url: '/login/verifyCode',
verifyCode, })
cookie, .then((res: wx.RequestSuccessCallbackResult) => {
}: { console.log(res);
verifyCode: string; return {
cookie: string; verifyCode: res.data.verifyCode,
}) => { cookie: res.header['Set-Cookie'],
let mixpwd = md5(pwd); };
return systemFetch({ })
url: '/boss/login', .then(
method: 'POST', ({
header: { verifyCode,
cookie: cookie, cookie,
}, }: {
data: { verifyCode: string;
code, cookie: string;
account, }) => {
pwd: mixpwd, let mixpwd = md5(pwd);
varifyCode: verifyCode, return systemFetch({
url: '/boss/login',
method: 'POST',
header: {
cookie: cookie,
},
data: {
code,
account,
pwd: mixpwd,
varifyCode: verifyCode,
},
});
}, },
)
.then(res => {
console.log(res);
const {
token,
data: { userInfo, userRoles },
} = res;
app.globalData.token = token;
app.globalData.userInfo = userInfo;
app.globalData.userRoles = userRoles;
try {
wx.setStorageSync('token', token);
} catch (error) {}
wx.hideLoading();
wx.redirectTo({
url: '/pages/homeAndReport/homeAndReport',
});
})
.catch(err => {
console.log(err);
wx.hideLoading();
wx.showToast({
title: err.errMsg,
icon: 'none',
});
}); });
}, } else {
)
.then(res => {
console.log(res);
const {
token,
data: { userInfo, userRoles },
} = res;
app.globalData.token = token;
app.globalData.userInfo = userInfo;
app.globalData.userRoles = userRoles;
try {
wx.setStorageSync('token', token);
} catch (error) {}
wx.hideLoading();
wx.redirectTo({
url: '/pages/homeAndReport/homeAndReport',
});
})
.catch(err => {
console.log(err);
wx.hideLoading();
wx.showToast({ wx.showToast({
title: err.errMsg, title: '登录获取code失败',
icon: 'none', icon: 'none',
}); });
}); }
} else { },
wx.showToast({ });
title: '登录获取code失败',
icon: 'none',
});
}
}, },
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment