Commit 7e35809d by 李嘉林

微信一键登录绑定企业账号

parent bcc6faa4
......@@ -15,7 +15,7 @@ module.exports = merge(prodEnv, {//zjgyl
NODE_ENV: '"development"',
// BASE_URL:"'https://shop.mayi888.com'",
// BASE_URL:"'http://192.168.1.146:3005'",
// BASE_URL:"'http://192.168.1.127:3000'",
// BASE_URL:"'http://172.16.1.18:3000'",
BASE_URL:"'https://test-m-shop.mayi888.cn'",
ADMIN_URL:"'https://test-ant.mayi888.cn'",
// BASE_URL:"'http://192.168.137.1:3004'",
......
......@@ -142,7 +142,6 @@ export default {
fromType:'',//来源类型 mini:小程序跳转到当前登录页
scene:'',//场景
ossLink: '',//第三方点击进入链接
wxUserInfo:{},
queryOptions:{},
isOnLoad: false,
systemInfo : {},
......@@ -150,13 +149,19 @@ export default {
pageInfo: {},
pageData: {},
hideBack: 0, //0显示返回按钮 1隐藏
selectEnterpriseAccountOpenType: 0, //0输入手机号登录 1微信一键登录 2一键登录后绑定手机号登录
sessionId: "",
};
},
computed: {
showGetPhoneBtn() {
// 梵蜜琳隐藏一键获取手机号
return this.$store.state.mixid != 'sivrl5';
}
},
// 是否开启企业要货
whetherOpenEnterprisesWantGoods(){
return this.mpApp.globalData.shopInfo.whetherOpenEnterprisesWantGoods==1?1:0
},
},
onShow() {
if(!this.isOnLoad){
......@@ -390,8 +395,8 @@ export default {
spokesmanRelId : '',
spokesmanGroupId : '',
spokesmanShopId : '',
nickname: _this.wxUserInfo.nickName,
headImgUrl: _this.wxUserInfo.avatarUrl
nickname: _this.userInfo.nickName,
headImgUrl: _this.userInfo.avatarUrl
};
login
.miniLogin(query)
......@@ -449,11 +454,12 @@ export default {
wx.getUserProfile({
desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (e) => {
_this.wxUserInfo = e.userInfo;
log.info('获取wx.getUserProfile用户信息',_this.wxUserInfo);
console.log(_this.wxUserInfo,'--_this.wxUserInfo')
this.userInfo = e.userInfo;
log.info('获取wx.getUserProfile用户信息',this.userInfo);
console.log(this.userInfo,'--this.userInfo')
this.initUser()
.then(res => {
wx.hideLoading();
//存入openid
try {
wx.setStorageSync('openid', res.data.data.openid)
......@@ -464,35 +470,40 @@ export default {
// haveBindUserPhone
// 是否必须绑定手机号(0必须绑定,1不需要绑定
//有账号或不需要绑定手机号
this.appid = res.data.data.appid;
this.session_key = res.data.data.session_key;
this.openid = res.data.data.openid;
this.unionId = res.data.data.unionId || '';
this.sessionId = res.data.data.sessionId || '';
this.isShow = true;
if (res.data.data.isHaveUnion == "true" || this.mpApp.globalData.shopInfo.haveBindUserPhone == '1') {
this.backParams += `&sessionid=${
res.data.data.sessionId
}&needCertified=${res.data.data.NEED_CERTIFIED}`;
this.NEED_CERTIFIED = res.data.data.NEED_CERTIFIED;
wx.setStorage({
key: "sessionid",
data: res.data.data.sessionId
});
this.isHaveUnion = true;
console.log(this.whetherOpenEnterprisesWantGoods == 1, res.data.data.masterAccount,'-----------------------------482')
if(this.whetherOpenEnterprisesWantGoods == 1 && res.data.data.masterAccount && res.data.data.masterAccount.length>0){
this.selectEnterpriseAccountOpenType = 1;
this.$refs.SelectEnterpriseAccount.open(res.data.data.masterAccount);
} else {
wx.setStorage({
key: "sessionid",
data: res.data.data.sessionId
});
this.checkLogin();
}
} else {
//需要绑定
this.isHaveUnion = false;
}
this.appid = res.data.data.appid;
this.session_key = res.data.data.session_key;
this.openid = res.data.data.openid;
this.unionId = res.data.data.unionId || '';
this.isShow = true;
//checkLogind
this.checkLogin(e);
//checkLogind
this.checkLogin();
}
})
.catch(err => {
log.info("err", err);
wx.hideLoading();
wx.showToast({ title: err, icon: "none" });
});
},
fail: (e) => {
......@@ -501,8 +512,7 @@ export default {
}
})
},
checkLogin(e) {
this.userInfo = e.userInfo;
checkLogin() {
this.$store.commit('setUserInfo',this.userInfo)
if (this.isHaveUnion) {
wx.hideLoading();
......@@ -518,23 +528,24 @@ export default {
log.info('checkUnionid',res)
wx.hideLoading();
if (res.data.code == 200) {
this.sessionId = res.data.data.sessionId || '';
if (res.data.data.isHaveUnion == "true") {
this.NEED_CERTIFIED = res.data.data.NEED_CERTIFIED;
this.backParams += `&sessionid=${
res.data.data.sessionId
}&needCertified=${res.data.data.NEED_CERTIFIED}`;
wx.setStorage({
key: "sessionid",
data: res.data.data.sessionId
});
this.addRecord(false)
// 跳转回小程序页面
this.pushPageType();
// wx.reLaunch({
// url: `../index/main?from=login&backpath=${
// this.backPath
// }&params=${encodeURIComponent(this.backParams)}`
// });
if(this.whetherOpenEnterprisesWantGoods == 1 && res.data.data.masterAccount && res.data.data.masterAccount.length>0){
this.selectEnterpriseAccountOpenType = 0;
this.$refs.SelectEnterpriseAccount.open(res.data.data.masterAccount);
} else {
wx.setStorage({
key: "sessionid",
data: res.data.data.sessionId
});
this.pushPageType();
}
} else {
//不是会员需要绑定手机号
this.isShowPhone = true;
......@@ -692,21 +703,21 @@ export default {
wx.hideLoading();
if (res.data.code == 200) {
wx.setStorageSync(this.$store.state.mixid+'articleId',false)
this.sessionId = res.data.data.sessionId || '';
this.NEED_CERTIFIED = res.data.data.NEED_CERTIFIED;
this.backParams += `&sessionid=${
res.data.data.sessionId
}&needCertified=${res.data.data.NEED_CERTIFIED}`;
wx.setStorage({
key: "sessionid",
data: res.data.data.sessionId
});
// 跳转回小程序页面
this.pushPageType();
// wx.reLaunch({
// url: `../index/main?from=login&backpath=${
// this.backPath
// }&params=${encodeURIComponent(this.backParams)}`
// });
if(this.whetherOpenEnterprisesWantGoods == 1 && res.data.data.masterAccount && res.data.data.masterAccount.length>0){
this.selectEnterpriseAccountOpenType = 0;
this.$refs.SelectEnterpriseAccount.open(res.data.data.masterAccount);
} else {
wx.setStorage({
key: "sessionid",
data: res.data.data.sessionId
});
this.pushPageType();
}
}
})
.catch(err => {
......@@ -798,17 +809,15 @@ export default {
.then(res => {
wx.hideLoading();
if (res.data.code == 200) {
this.sessionId = res.data.data.sessionId || '';
this.backParams += `&sessionid=${
res.data.data.sessionId
}&needCertified=${res.data.data.NEED_CERTIFIED}`;
this.NEED_CERTIFIED = res.data.data.NEED_CERTIFIED;
console.log(this.mpApp.globalData.shopInfo,"------------------this.mpApp.globalData.shopInfo")
if(this.mpApp.globalData.shopInfo.whetherOpenEnterprisesWantGoods == 1 && res.data.data.masterAccount && res.data.data.masterAccount.length>0){
if(this.whetherOpenEnterprisesWantGoods == 1 && res.data.data.masterAccount && res.data.data.masterAccount.length>0){
this.selectEnterpriseAccountOpenType = 0;
this.$refs.SelectEnterpriseAccount.open(res.data.data.masterAccount);
wx.setStorage({
key: "sessionid",
data: res.data.data.sessionId
});
} else {
wx.setStorage({
key: "sessionid",
......@@ -855,10 +864,18 @@ export default {
},
getEnterpriseAccount(val) {
console.log(val,'----getEnterpriseAccount')
wx.setStorage({
key: "sessionid",
data: this.sessionId
});
if(val) {
this.backParams += `&enterpriseAccount=${wx.getStorageSync("enterpriseAccount")}`
}
this.pushPageType();
if(this.selectEnterpriseAccountOpenType == 0) {
this.pushPageType();
} else {
this.checkLogin();
}
},
}
};
......
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