| | |
| | | import { |
| | | wxLoginCustomer, |
| | | getDictData, |
| | | getWxMiniPhone |
| | | getWxMiniPhone, |
| | | binDingPhone |
| | | } from '../../api/index' |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | agreementFalg: false, |
| | | primary: '', |
| | | bottomLift: 0, |
| | | |
| | | showModal: false, |
| | | serviceHtml: '', |
| | |
| | | activeHtml: '' |
| | | }, |
| | | initData(){ |
| | | var app = getApp().globalData |
| | | this.setData({ |
| | | bottomLift: app.bottomLift |
| | | }) |
| | | getDictData({ |
| | | code: 'ZBOM_CUSTOMIZED', |
| | | label: 'SERVER_AGREEMENT' |
| | |
| | | }) |
| | | }) |
| | | }, |
| | | getPhoneNumber (e) { |
| | | console.log(e.detail) |
| | | console.log(e.detail.iv) |
| | | console.log(e.detail.encryptedData) |
| | | const data = { ...e.detail } |
| | | getWxMiniPhone({ |
| | | encryptedData: data.encryptedData, |
| | | iv: data.iv, |
| | | sessionKey: wx.getStorageSync('sessionKey'), |
| | | }) |
| | | handleJudge(e) { |
| | | const flag = e.currentTarget.dataset.flag |
| | | console.log(e); |
| | | this.setData({ agreementFalg: flag, showModal: false }) |
| | | }, |
| | | loginIn() { |
| | | const { agreementFalg } = this.data |
| | |
| | | icon: 'none', |
| | | duration: 2000 |
| | | }) |
| | | wx.login({ |
| | | success: (res) => { |
| | | if (res.code) { |
| | | // 获取到用户登录凭证 code |
| | | const code = res.code; |
| | | wx.setStorageSync('code', res.code) |
| | | // 将 code 发送给后端服务器 |
| | | wxLoginCustomer({code}).then(ress => { |
| | | wx.setStorageSync('token', ress.data.token) |
| | | wx.setStorageSync('member', ress.data.member) |
| | | wx.redirectTo({ |
| | | url: '/pages/index/index', |
| | | }) |
| | | }) |
| | | } else { |
| | | console.error('获取用户登录凭证失败', res.errMsg); |
| | | }, |
| | | getPhoneNumber (e) { |
| | | console.log(e.detail) |
| | | console.log(e.detail.iv) |
| | | console.log(e.detail.encryptedData) |
| | | const data = { ...e.detail } |
| | | getWxMiniPhone({ |
| | | encryptedData: data.encryptedData, |
| | | iv: data.iv, |
| | | sessionKey: wx.getStorageSync('sessionKey') || data.iv, |
| | | }).then(res => { |
| | | binDingPhone({ |
| | | phone: res.data |
| | | }).then((res) => { |
| | | if(res.code == 200){ |
| | | wx.setStorageSync('member', res.data) |
| | | wx.navigateBack() |
| | | } |
| | | }, |
| | | fail: (err) => { |
| | | console.error('调用 wx.login 失败', err); |
| | | }, |
| | | }) |
| | | }) |
| | | }, |
| | | onOpen(e){ |