import {
  imgServerUrl
} from '../../../../config/config';
import {
  getMoneyAccountDetail,
  getHpMemberDetail
} from '../../../../services/index'
Page({
  data: {
    moneyBalance: '0.00',
    imgServerUrl: imgServerUrl,
    confirm: '',
    model_message: '',
    cover: true,
    cancel: false,
  },
  tixian() {
    wx.showModal({
      title: '提示',
      content: '如果您有提现需求，请联系客服400-690-0099',
      confirmText: '知道了',
      showCancel: false,
      success: res => {
        if (res.confirm) {
          wx.makePhoneCall({
            phoneNumber: '4006900099',
          })
          // wx.showModal({
          //   title: '提示',
          //   content: '是否立即拨打电话',
          //   success: res => {
          //     if (res.confirm) {

          //     }
          //   }
          // })
        }
      }
    })
    return
    const cover = !this.data.cover;
    getHpMemberDetail({
      user_id: wx.getStorageSync('user_id'),
      user_token: wx.getStorageSync('user_token'),
      member_id: wx.getStorageSync('member_id'),
    }).then(res => {
      if (res.errcode === 0) {
        let _json = {
          0: {
            confirm: '好的',
            cancel: true,
            model_message: '为了保证资金安全，请先进行实名认证。'
          },
          1: {
            confirm: '好的',
            cancel: true,
            model_message: '实名认证正在审核中，请耐心等待。'
          },
          3: {
            confirm: '去下载',
            cancel: false,
            model_message: '为了保证资金安全，您需要在app上进行提现。'
          },
        }

        this.setData({
          cover,
          ..._json[res.data.hpMember.authenticationStatus]
        })
      }
    })
  },
  confirm() {
    this.setData({
      cover: true
    })
  },
  cancel() {
    this.setData({
      cover: true
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    getMoneyAccountDetail({
      user_id: wx.getStorageSync('user_id'),
      user_token: wx.getStorageSync('user_token'),
      member_id: wx.getStorageSync('member_id'),
    }).then(res => {
      if (res.errcode === 0) {
        this.setData({
          moneyBalance: res.data.MpMemberAccountAPI.moneyBalance.toFixed(2)
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },
})