

// app.js
const homeApi_empower = "https://aipush.aidsleep.cn";
App({
  onLaunch() {
    wx.hideTabBar()
    // 展示本地存储能力
    // const logs = wx.getStorageSync('logs') || []
    // logs.unshift(Date.now())
    // wx.setStorageSync('logs', logs)
    // this.globalData.selectedTabIndex = wx.getStorageSync("selectedTabIndex") || 0;
    
    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
        wx.request({
          url: `${homeApi_empower}/wxssk`,
          method: 'POST',
          data: {
            code: res.code,
          },
          success: function (loginRes) {
            // 处理服务器返回的结果  
            console.log('登录获取结果:', loginRes.data);
            if (loginRes.data) { 
              wx.setStorageSync("openid", loginRes.data.openid);
              wx.setStorageSync("token", loginRes.data.token);
              wx.setStorageSync("unionid", loginRes.data.unionid);

            }
          }
        })
      }
    })
  },
onShow(){
},
  globalData: {
    userInfo: null,
    selectedTabIndex:0
  }
})
