//logs.js
const util = require('../../utils/util.js')
const app = getApp()
Page({
  data: {
    imageUrl: app.globalData.imageUrl,
    logs: [],
    code: ''
  },
  onLoad: function () {
    // this.setData({
    //   logs: (wx.getStorageSync('logs') || []).map(log => {
    //     return util.formatTime(new Date(log))
    //   })
    // })
    this.getCodeFun()
  },
  getCodeFun() {
    let t = this;
    wx.login({
        success: (r) => {
            console.log(r.code)
            t.setData({
                code: r.code,
                // rawData: r.rawData
            })
        }

    });
  },
  //暂不授权
  zhanbsq(){
    // wx.navigateBack({//返回
    //     delta: 1
    // })
    wx.reLaunch({
      url: '/pages/index/index'
    })

  },
  getDenlu(e){
    console.log(e)
    let t = this;
    let u = "common/login";
    let d = {
        code: t.data.code,
        rawData: e.detail.rawData,
    }
    // console.log(t.data.code)
    app.post(u, d).then((res) => {
      // console.log(res)
      if (res.code == 1) {
        console.log(res);
        wx.setStorageSync("token", res.data.userInfo.token)
        wx.navigateBack({//返回
            delta: 1
        })
    } else {
        wx.showToast({
            title: res.msg,
            icon: 'none'
        })
    }
  })
}
})