|
|
import {login as loginModel} from '../models';
|
|
|
export default {
|
|
|
/**
|
|
|
* button触发getUserInfo之后立即解析获取unionid
|
|
|
*/
|
|
|
decodeUnionId(srd_session, result, callbackFunc) {
|
|
|
let res = result.detail;
|
|
|
let userInfo = res.userInfo;
|
|
|
let nickName = userInfo.nickName;
|
|
|
|
|
|
//保存用户信息
|
|
|
// app.setUserInfo(res.userInfo)
|
|
|
|
|
|
let param = {
|
|
|
method: 'wechat.smallProgram.decodeUserInfo',
|
|
|
|
|
|
}
|
|
|
loginModel.getDecodeUserInfo({
|
|
|
srdSession: srd_session,
|
|
|
encryptedData: res.encryptedData,
|
|
|
iv: res.iv
|
|
|
}).then(data => {
|
|
|
let responseData = data.data
|
|
|
checkUnionIDExist(responseData.openid + '', responseData.union_id + '', responseData.srd_session + '', param.method)
|
|
|
if (!isStringEmpty(responseData.union_id)) {
|
|
|
//保存并查询该unionID是否有uid
|
|
|
app.setWXUnionID(responseData.union_id);
|
|
|
callbackFunc({
|
|
|
isHaveUnionID: true,
|
|
|
});
|
|
|
sendWeChatUserDataWithUnionId(responseData.union_id, userInfo.nickName, userInfo.avatarUrl)
|
|
|
wechatUserIsBind(responseData.union_id, nickName, userInfo.avatarUrl, callbackFunc);
|
|
|
}
|
|
|
})
|
|
|
.catch(error => {
|
|
|
callbackFunc({
|
|
|
succeed: false,
|
|
|
message: error.message
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
}; |
|
|
\ No newline at end of file |