问题模块 | 框架类型 | 问题类型 | API/组件名称 | 终端类型 | 微信版本 | 基础库版本 |
---|---|---|---|---|---|---|
API和组件 | 小程序 | Bug | getPhoneNumber | 客户端 | 6.7.3 | 2.3.2 |
//点击微信登录授权手机号
getPhoneNumber(e) {
var that = this;
console.log("微信授权手机号", e.detail)
wx.login({
success: res => {
console.log("login code", res.code);
//是否授权,授权通过进入下单页面,授权拒绝则手机号登录
if (e.detail.errMsg == 'getPhoneNumber:ok') {
wx.request({
url: app.globalData.url + 'api/Account/WxLogin/',
data: {
encryptedData: e.detail.encryptedData, //encodeURIComponent(e.detail.encryptedData),
iv: e.detail.iv,
code: res.code
},
method: 'GET',
header: {
'content-type': 'application/json'
},
success: function(res) {
console.log("success", res)
if (res.data.Code == 200) {
wx.showToast({
title: '授权成功',
})
wx.navigateTo({
url: '../order_company/order_company',
})
} else {
wx.showToast({
title: res.data.Message,
icon: 'none'
})
}
},
fail: function(res) {
console.log("fail", res);
wx.showToast({
title: res.errMsg,
icon: 'none'
})
}
})
} else if (e.detail.errMsg === 'getPhoneNumber:fail user deny') { //拒绝授权
wx.showToast({
title: '您拒绝了授权',
icon: 'none',
duration: 2000
})
wx.navigateTo({
url: '../telLogin/telLogin',
})
} else if (e.detail.errMsg === 'getPhoneNumber:fail 用户未绑定手机,请先在微信客户端进行绑定后重试') {
wx.showToast({
title: '您的微信未绑定手机号',
icon: 'none',
duration: 3000
})
wx.navigateTo({
url: '../telLogin/telLogin',
})
} else {
wx.showToast({
title: '网络繁忙,请稍候再试',
icon: 'none',
})
}
},
fail: function(res) {
wx.showToast({
title: '获取登录态失败,请检查网络',
icon: 'none',
duration: 2000
})
}
});
},
网友回复
你将获取手机号码的片段单独放出来,不做判断以及其他的时间处理试试
测试的时候没有问题,正式发布之后,不论点击确认授权还是取消都没有反应 非个人开发者