12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- const app = getApp()
- const httpUtils = require('../../utils/http.js')
- const ui = require('../../utils/ui.js')
- Page({
- data: {
- tab: 1
- },
- onShow(){
- if(wx.getStorageSync('token')){
- this.setData({
- tab: 2
- })
- }else{
- this.setData({
- tab: 1
- })
- }
- },
- toOut(){
- wx.removeStorageSync('token')
- wx.removeStorageSync('phone')
- wx.removeStorageSync('openId')
- wx.removeStorageSync('code')
- this.setData({
- tab: 1
- })
- },
- toLogin(){
- wx.login({
- success (res) {
- if (res.code) {
- console.log("code",res)
- let code = res.code
- wx.setStorageSync('code', res.code)
- // 调userinfo接口
- let obj = {
- url: '/userInfo',
- data: {
- code: code
- }
- }
- httpUtils.request(obj).then(res1=>{
- console.log("userInfo",res1)
- wx.setStorageSync('openId', res1.data.data)
- wx.navigateTo({
- url: '/pages/submitPhone/index',
- })
- }).catch(err=>{
- console.log('ERROR',err)
- });
- }
- }
- })
- }
- })
|