Commit c69dc8f7 by hxx

小程序手机号逻辑更新

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