| | |
| | | getDictData, |
| | | getWxMiniPhone, |
| | | loginByPhone, |
| | | bindingOpenid |
| | | bindingOpenid, |
| | | wxLoginCustomer |
| | | } from '../../api/index' |
| | | Page({ |
| | | |
| | |
| | | status: '0', // 标识 |
| | | countDown: 0, |
| | | phone: '', |
| | | openid:'', |
| | | code: '', |
| | | showModal: false, |
| | | activeHtml: '', |
| | |
| | | loginPhone() { |
| | | const { |
| | | code, |
| | | phone |
| | | phone, |
| | | openid |
| | | } = this.data |
| | | if (!this.data.agreementFalg) { |
| | | return wx.showToast({ |
| | |
| | | |
| | | loginByPhone({ |
| | | code, |
| | | openid, |
| | | phone |
| | | }).then(res => { |
| | | if (res.data && res.data.token) { |
| | | wx.login({ |
| | | timeout: 5000, |
| | | success: (loginRes) => { |
| | | if (loginRes.code) { |
| | | this.bindingOpenid(loginRes.code, res.data.token) |
| | | } |
| | | } |
| | | }) |
| | | // wx.login({ |
| | | // timeout: 5000, |
| | | // success: (loginRes) => { |
| | | // if (loginRes.code) { |
| | | // this.bindingOpenid(loginRes.code, res.data.token) |
| | | // } |
| | | // } |
| | | // }) |
| | | if(res.data.phone){ |
| | | res.data.users.phone = res.data.phone || res.data.users.phone |
| | | } |
| | |
| | | primary: app.primary, |
| | | bottomLift: app.bottomLift |
| | | }) |
| | | this.autoLogin() |
| | | this.initData() |
| | | }, |
| | | autoLogin(){ |
| | | var that =this |
| | | wx.login({ |
| | | timeout: 5000, |
| | | success(res) { |
| | | if (res.code) { |
| | | //发起网络请求 |
| | | wxLoginCustomer({ |
| | | code: res.code |
| | | }).then(res => { |
| | | console.log(res) |
| | | wx.setStorageSync('sessionKey', res.data.sessionKey) |
| | | that.setData({openid:res.data.openid}) |
| | | if (res && res.data !=null && res.data.token!=null) { |
| | | console.log(res) |
| | | wx.setStorageSync('member', res.data.users || '') |
| | | wx.setStorageSync('token', res.data.token || '') |
| | | wx.switchTab({ |
| | | url: '/pages/index/index', |
| | | }) |
| | | } |
| | | }) |
| | | } else { |
| | | wx.navigateTo({ |
| | | url: '/pages/login/index', |
| | | }) |
| | | console.log('登录失败!' + res) |
| | | } |
| | | }, |
| | | fail(err) { |
| | | console.log(err) |
| | | } |
| | | }) |
| | | }, |
| | | getPhoneNumber(e) { |
| | | const data = { |
| | | ...e.detail |