Commit c69dc8f7 by hxx

小程序手机号逻辑更新

parent ec41953c
...@@ -57,5 +57,9 @@ console.log(process.env,'-----------------config------') ...@@ -57,5 +57,9 @@ console.log(process.env,'-----------------config------')
addCustomerRel(data) { addCustomerRel(data) {
return requestGET(`${process.env.OLSHOP_URL}/user/addCustomerRel?tagId=${data}`) return requestGET(`${process.env.OLSHOP_URL}/user/addCustomerRel?tagId=${data}`)
}, },
// 根据 code 获取用户手机号
getPhoneNumber(code) {
return requestGET(`${process.env.OLSHOP_URL}/getPhoneNumber?code=${code}`)
},
} }
\ No newline at end of file
...@@ -67,14 +67,16 @@ ...@@ -67,14 +67,16 @@
<p class="hint">绑定手机号,同步历史订单</p> <p class="hint">绑定手机号,同步历史订单</p>
<button <button
class="btn" class="btn"
v-if="showGetPhoneBtn" v-if="showGetPhoneBtn && tempData.isBindingPhoneMethod != 1"
open-type="getPhoneNumber" open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber" @getphonenumber="getPhoneNumber"
> >
微信授权一键绑定 微信授权一键绑定
</button> </button>
<div class="btn2" @click="handbindHandle">手动绑定手机号</div> <div class="btn2" v-if="tempData.isBindingPhoneMethod != 0" @click="handbindHandle">手动绑定手机号</div>
<div class="cancelLogin" @click="cancelLogin">暂不登录</div> <div class="cancelLogin" @click="cancelLogin">
{{ tempData.isForceUnion == 'true' ? '暂不登录' : '暂不绑定' }}
</div>
</div> </div>
</div> </div>
<!-- 选择企业 --> <!-- 选择企业 -->
...@@ -730,17 +732,22 @@ export default { ...@@ -730,17 +732,22 @@ export default {
} }
wx.checkSession({ wx.checkSession({
success: () => { success: async () => {
//session_key 未过期,并且在本生命周期一直有效 //session_key 未过期,并且在本生命周期一直有效
if (e.target.errMsg == "getPhoneNumber:ok") { if (e.target.errMsg == "getPhoneNumber:ok") {
// this.isShowPhone = false; if (e.mp.detail.code) { // 新组件处理方法
this.phoneNumber = wx_decode( const res = await login.getPhoneNumber(e.mp.detail.code);
this.appid, if (res.data.code == 200) {
this.session_key, this.phoneNumber = res.data.data;
e.mp.detail.encryptedData, }
e.mp.detail.iv + "" } else { // 旧组件处理方法
).phoneNumber; this.phoneNumber = wx_decode(
log.info("生命周期一直", this.phoneNumber); this.appid,
this.session_key,
e.mp.detail.encryptedData,
e.mp.detail.iv + ""
).phoneNumber;
}
this.bindUser(); this.bindUser();
} }
}, },
...@@ -868,6 +875,13 @@ export default { ...@@ -868,6 +875,13 @@ export default {
}); });
}, },
cancelLogin(){ cancelLogin(){
if (this.tempData.isForceUnion == 'false') { // 不强制绑定
wx.setStorage({
key: "sessionid",
data: this.tempData.sessionId
});
return this.checkLogin();
}
// wx.reLaunch({ // wx.reLaunch({
// url : '/pages/home/main' // url : '/pages/home/main'
// }) // })
......
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