const util = require('../func/request') //获取登录code const getWxCode = () => { wx.login({ success: res => { wx.setStorageSync('wxCode', res.code) } }) } //检测是否获取手机号 const isGetPhone = (e) => { if (e.detail.errMsg == 'getPhoneNumber:ok') { return true } else { return false } } //获取手机号 const getPhone = (e) => { if (!isGetPhone(e)) { return({ state: false, msg: '我们需要获取您的手机号才能进行实名登录哦!' }) }; var code = wx.getStorageSync('wxCode'); return util.request_rlxf({ url: '/api/next/doGetPhone', data: { code: code, iv: e.detail.iv, encryptedData: e.detail.encryptedData }, method: 'post', type: 'application/json' }) .then((suc) => { getWxCode(); return ({ state: true, msg: suc }) }) .catch((err) => { getWxCode(); return ({ state: false, msg: err }) }) } module.exports = getPhone