const util = require('../func/request') //获取登录code const getWxCode = () => { wx.login({ success: res => { app.data.wxCode = res.code } }) } //检测是否获取手机号 const isGetPhone = (e) => { if (e.detail.errMsg == 'getPhoneNumber:ok') { return true } else { return false } } //获取手机号 const getPhone = (e) => { return new Promise((reslove, reject) => { wx.showLoading({ title: '获取中...', mask: true }); if (!isGetPhone(e)) { wx.hideLoading(); wx.showToast({ title: '我们需要获取您的手机号才能进行实名登录哦', icon: 'none' }) reject(); } else { util.request_wxrlxf({ url: '/api/next/doGetPhone', data: { code: app.data.wxCode, iv: e.detail.iv, encryptedData: e.detail.encryptedData, type:3 }, method: 'post', type: 'application/json' }) .then((suc) => { wx.hideLoading() getWxCode(); reslove (suc.data) }) } }) } module.exports = getPhone