const app = require('../../utils/util.js');
Page({
  data: {
    info: {},
  },
  wanshan() {
    wx.navigateTo({
      url: '/pages/finishInfo/finishInfo',
    })
  },
  shenfen() {
    if (this.data.info.headPicPath) {
      wx.navigateTo({
        url: '/pages/idCardDetail/idCardDetail',
      })
    } else {
      wx.navigateTo({
        url: '/pages/idCard/idCard',
      })
    }

  },
  xiugai() {
    wx.navigateTo({
      url: '/pages/updatepassword/updatepassword',
    })
  },
  tuichu() {
    wx.showModal({
      showCancel: true,
      content: "您确认要退出吗?",
      success(res) {
        if (res.confirm) {
          wx.showLoading({
            mask: true,
            title: '退出中',
          })
          wx.request({
            url: app.globalData.publicUrl + '/applet/unbind',
            method: "GET",
            data: {
              appletsId: wx.getStorageSync('openId')
            },
            success: (res) => {
              if (res.data.code == 0) {
                wx.hideLoading()
                wx.clearStorageSync();
                wx.switchTab({
                  url: '/pages/index/index',
                })
              }
            },
            fail: () => {
              wx.hideLoading()
            }
          })
        }
      }
    })

  },
  onShow() {
    console.log(wx.getStorageSync('user'), "打印");
    if (wx.getStorageSync('user') == '') {
      wx.redirectTo({
        url: '/pages/login/login',
      })
    }

    wx.request({
      url: app.globalData.publicUrl + '/applet/findUserInfo',
      method: "GET",
      header: {
        appletsId: wx.getStorageSync('openId')
      },
      success: (res) => {
        console.log(res, "000");
        this.setData({
          info: res.data.data
        })
      }
    })
  },
  onLoad() {

  }
})