import { API } from './../../../utils/network/api'
const api = new API()
const app = getApp()
Page({
  data: {
    navbarData: {
      showCapsule: 0, //是否显示左上角图标   1表示显示    0表示不显示
      title: '个人中心', //导航栏 中间的标题
    },
    height: app.globalData.height,
    info:{}
  },
  onShow() {
    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
      this.getTabBar().setData({
        active: 1,  //数字是当前页面在tabbar的索引,如我的查询页索引是2，因此这边为2，同理首页就为0，审批页面为1
      })
    }

    api.getPharmacistInfo().then(response => {
      console.log(response.data);
      this.setData({
        info: response.data
      })
    }).catch(errors => {
      console.error(errors);
    })
  },
  logOut(){
    console.log("退出登录");
    let usertype =  wx.getStorageSync('usertype');
    wx.showModal({
      title: '确认退出登录',
      content: '退出登录后您需要重新登录',
      success (res) {
        if (res.confirm) {
          console.log('用户点击确定')
          wx.setStorageSync('AUTH_TOKEN_'+usertype, "");
          wx.setStorageSync('user_id_'+usertype, "");
          wx.setStorageSync('client_user_id_'+usertype, "");
          app.globalData.isLogin=false;
          wx.setStorageSync('usertype','')
          app.go("/Pages/index/index");
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  },
  go(e){
    console.log(e)
    let url = e.currentTarget.dataset.url;
    app.go(url);
  }
  
})