<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">微信授权手机号登录</button>
getPhoneNumber:function(res){
const encryptedData = res.detail.encryptedData
const iv = res.detail.iv
if (res.detail.encryptedData) {
var that = this;
wx.login({
success(res) {
const code = res.code
axios({
url: '/wx/miniProgram/login', method: "POST", data: {
code: code
}
}).then(({ res }) => {
if(res.status === 0){
axios({
url: '/wx/miniProgram/getPhoneNumber', method: "POST", data: {
code: code,
encryptedData: encryptedData,
iv:iv
}
}).then(({ res }) => {
wx.switchTab({
url: '../index/index',
success: (res) => {}
})
})
}
})
}
})
} else {
wx.showModal({
title: '警告',
content: '您点击了拒绝授权,将无法进入小程序,请授权之后再进入!!!',
showCancel: false,
confirmText: '返回授权',
success: function (res) {
if (res.confirm) {
console.log('用户点击了“返回授权”');
}
}
});
}
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现