| | |
| | | import { |
| | | wxLoginCustomer |
| | | wxLoginCustomer, |
| | | getMemberInfo |
| | | } from './api/index' |
| | | App({ |
| | | globalData: { |
| | |
| | | if (WindowInfo.safeArea.top > 20) { |
| | | this.globalData.bottomLift = WindowInfo.screenHeight - WindowInfo.safeArea.bottom; |
| | | } |
| | | wx.login({ |
| | | timeout: 5000, |
| | | success(res) { |
| | | if (res.code) { |
| | | //发起网络请求 |
| | | wxLoginCustomer({ |
| | | code: res.code |
| | | }).then(res => { |
| | | if (res && res.data) { |
| | | wx.setStorageSync('member', res.data.users || '') |
| | | wx.setStorageSync('sessionKey', res.data.sessionKey) |
| | | wx.setStorageSync('token', res.data.token || '') |
| | | } else { |
| | | wx.navigateTo({ |
| | | url: '/pages/login/index', |
| | | }) |
| | | console.log('登录失败!') |
| | | } |
| | | }) |
| | | } else { |
| | | wx.navigateTo({ |
| | | url: '/pages/login/index', |
| | | }) |
| | | console.log('登录失败!' + res) |
| | | } |
| | | }, |
| | | fail(err) { |
| | | console.log(err) |
| | | } |
| | | }) |
| | | } |
| | | let users = wx.getStorageSync('token') |
| | | if(users ==null){ |
| | | wx.navigateTo({ |
| | | url: '/pages/login/index', |
| | | }) |
| | | }else{ |
| | | getMemberInfo({goLogin:true}).then(res => { |
| | | }) |
| | | } |
| | | }, |
| | | }) |