12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- 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) => {
- 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: wx.getStorageSync('wxCode'),
- iv: e.detail.iv,
- encryptedData: e.detail.encryptedData
- },
- method: 'post',
- type: 'application/json'
- })
- .then((suc) => {
- wx.hideLoading()
- getWxCode();
- reslove (suc.data)
- })
- }
- })
- }
- module.exports = getPhone
|