| | |
| | | import { wxLoginCustomer } from './api/index' |
| | | import { |
| | | wxLoginCustomer |
| | | } from './api/index' |
| | | App({ |
| | | globalData: { |
| | | primary: '#B08771', |
| | | bottomLift: '' |
| | | }, |
| | | onLaunch: function () { |
| | | onLaunch: function (op) { |
| | | console.log('options', op.query.scene) |
| | | let pathMap = [ |
| | | '/pages/detailDis/product', |
| | | '/pages/detailDis/case', |
| | | '/pages/detailDis/realpic', |
| | | '/pages/consult/detail', |
| | | '/pages/productVideo/index', |
| | | ] |
| | | //获取当前设备信息 |
| | | const WindowInfo = wx.getWindowInfo() |
| | | if (WindowInfo.safeArea.top > 20) { |
| | | this.globalData.bottomLift = WindowInfo.screenHeight - WindowInfo.safeArea.bottom; |
| | | this.globalData.bottomLift = WindowInfo.screenHeight - WindowInfo.safeArea.bottom |
| | | } |
| | | // |
| | | const res = wx.getStorageSync('member') |
| | | if (res) { |
| | | this.globalData.userInfo = res |
| | | } else { |
| | | // 登录 |
| | | wx.login({ |
| | | timeout: 5000, |
| | | success(res) { |
| | | if (res.code) { |
| | | //发起网络请求 |
| | | wxLoginCustomer({ |
| | | code: res.code |
| | | }).then(res => { |
| | | console.log(res) |
| | | if (res && res.data.member) { |
| | | wx.setStorageSync('member', res.data.member) |
| | | wx.setStorageSync('openid', res.data.member.openid) |
| | | wx.setStorageSync('sessionKey', res.data.sessionKey) |
| | | wx.setStorageSync('token', res.data.token) |
| | | } else { |
| | | console.log('登录失败!') |
| | | // 授权登录 |
| | | wx.login({ |
| | | timeout: 5000, |
| | | success(res) { |
| | | if (res.code) { |
| | | //发起网络请求 |
| | | wxLoginCustomer({ |
| | | code: res.code |
| | | }).then(res => { |
| | | console.log(res) |
| | | if (res && res.data.member) { |
| | | wx.setStorageSync('member', res.data.member) |
| | | wx.setStorageSync('openid', res.data.member.openid) |
| | | wx.setStorageSync('sessionKey', res.data.sessionKey) |
| | | wx.setStorageSync('token', res.data.token) |
| | | if (op.query.scene) { |
| | | let temp = op.query.scene.split('_') |
| | | wx.navigateTo({ |
| | | url: `${pathMap[temp[1]]}?id=${temp[0]}&userId=${temp[2]}`, |
| | | }) |
| | | } |
| | | }) |
| | | } else { |
| | | console.log('登录失败!' + res) |
| | | } |
| | | }, |
| | | fail(err) { |
| | | console.log(err) |
| | | } else { |
| | | console.log('登录失败!') |
| | | } |
| | | }) |
| | | } else { |
| | | console.log('登录失败!' + res) |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | fail(err) { |
| | | console.log(err) |
| | | } |
| | | }) |
| | | |
| | | |
| | | |
| | | } |
| | | }) |