getPhoneNumber(e) {
let vm = this
wx.login({
success: (res) => {
let code = res.code
// wx.setStorageSync('code', code)
if (e.detail.iv) {
let data = {
code: code,
iv: e.detail.iv,
from_openid: wx.getStorageSync('user_id'),
encryptedData: e.detail.encryptedData
}
vm.$showLoading('手机号获取中...')
vm.$post({url: `${service.host}/wechat`, data}, {
success: ({code, data}) => {
let {phoneNumber, unionid, openid} = data
vm.hideModal()
wx.navigateTo({
url: `/pages/userInfo/basicData?phoneNumber=${phoneNumber}&unionid=${unionid}&openid=${openid}`
})
vm.$apply()
wx.setStorageSync('openid', data.openid)
wx.hideLoading()
}
})
}
},
fail: (res) => {
wx.showToast({
title: '获取手机号失败',
icon: 'error',
duration: 2000
})
}
})
},
尝试过很多办法,都无法解决,求各位大佬帮忙。。