APP({
login() {
    // 登录方法
    wx.login({
      success: res => {
        const code = res.code
        wx.request({
          url: 'http://123.207.32.32:3000/login',
          method: 'post',
          data: {
            code
          },
          success: (res) => {
            console.log(res)
            const token = res.data.token
            wx.setStorageSync('token', token)
          }
        })

      }
    })
  },
  checkToken(token){
    wx.request({
      url: 'http://123.207.32.32:3000/auth',
      method:'post',
      header:{
        token
      },
    success:(res)=>{
    console.log(res)
    }
    })
  },
  onLaunch: function () {
    //登陆
    const token =wx.getStorageSync('token')
    if(token&&token.length>0){
      this.checkToken(token)
    }else{
      this.login()
    }
})