Authored by QC-L

更新逻辑判断优化登录部分异常处理 review by 黄敬囿

... ... @@ -18,7 +18,7 @@ export default {
// MINI_APP_DOMAIN: 'miniapp.yohobuy.com',
appid: 'wx193403dfd8cf74a1',
business_line: 'miniapp', // 业务线
mini_app_type: '0',
mini_app_type: '62',
},
production: {
domains: {
... ...
... ... @@ -54,6 +54,7 @@ const handleLoginData = (loginData) => {
*/
export const decodeUnionId = (srd_session, result) => {
let res = result.detail;
let fromPage = result.currentTarget.dataset.from;
let globalData = getGlobalData();
// 存储 userInfo
if (res && res.userInfo) {
... ... @@ -75,7 +76,6 @@ export const decodeUnionId = (srd_session, result) => {
} else {
union_id = globalData.union_id;
}
if (!union_id) {
throw new Error('union_id is null');
}
... ... @@ -184,8 +184,8 @@ export const getUserInfo = (e) => {
return;
}
decodeUnionId(loginData.srd_session, e).then(data => {
if (!data.union_id) throw new Error('union_id is null');
wechatUserIsBind(data.union_id, data.userInfo).then(message => {
if (message.code === 10003) {
event.emit(checkEventName(USER_LOGIN_SUCCESS, fromPage));
setTimeout(() => {
... ... @@ -209,12 +209,12 @@ export const getUserInfo = (e) => {
}
event.emit(checkEventName(USER_LOGIN_CALLBACK, fromPage), message);
}).catch(error => {
console.log(error);
event.emit(checkEventName(USER_LOGIN_CALLBACK, fromPage), error);
event.emit(checkEventName(USER_GET_PHONENUMBER_ERROR, fromPage), error.message);
});
}).catch(error => {
console.log(error);
event.emit(checkEventName(USER_LOGIN_CALLBACK, fromPage), error);
event.emit(checkEventName(USER_GET_PHONENUMBER_ERROR, fromPage), error.message);
});
});
} else {
... ...
import BaseService from '../services/baseService.js';
import config from '../../config.js';
const WECHAT_SMALLPROGRAM_ONLOGIN = 'wechat.smallProgram.onLogin';
const WECHAT_SMALLPROGRAM_DECODEUSERINFO = 'wechat.smallProgram.decodeUserInfo';
... ... @@ -13,7 +14,7 @@ export class LoginService extends BaseService {
return await this.GET({
method: WECHAT_SMALLPROGRAM_ONLOGIN,
jsCode: code,
miniapp_type: '0' // 暂时为 0
miniapp_type: config.mini_app_type
}, {
path: WechatPath
}).then((data) => {
... ...