Skip to content

Commit

Permalink
fix: 修复验证码登录需要图形验证码问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Honye committed Jul 22, 2023
1 parent 6efccb9 commit 7814afe
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions miniprogram/packages/douban/pages/login-phone/login-phone.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ Page({
this.setData({
captchaData: err.payload,
});
wx.showToast({
icon: 'none',
title: err.description,
});
}
wx.showToast({
icon: 'none',
title: err.description,
});
return Promise.reject(err);
});
wx.showToast({
Expand All @@ -48,19 +48,29 @@ Page({

async submit (e) {
const { value } = e.detail;

const params = {
number: value.phone,
code: value.code,
};
const res = await verifyCaptcha(params)
.catch((err) => {
wx.showToast({
icon: 'none',
title: err.description,
const params = {
number: value.phone,
code: value.code,
};
const { captchaData, captcha } = this.data;
if (captchaData) {
params.captcha_id = captchaData.captcha_id;
params.captcha_solution = captcha;
}

const res = await verifyCaptcha(params)
.catch((err) => {
if (err.message === 'captcha_required') {
this.setData({
captchaData: err.payload,
});
return Promise.reject(err);
}
wx.showToast({
icon: 'none',
title: err.description,
});
return Promise.reject(err);
});
const { access_token, refresh_token, account_info } = res;
this.updateDouban({
accessToken: access_token,
Expand Down

0 comments on commit 7814afe

Please sign in to comment.