const config = require('../../../../config/config.js')
const Http = require('../../../../utils/HttpBasics.js')
const util = require('../../../../utils/util.js')
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    id: '',//
    organizationType: "",//2企业 /4个人
    idDocType: 1,
    certificateIndex: 0, //证件下标
    // certificateType: null, //证件类型
    businessLicenseInfo: {
      license_copy_info: { ///营业执照
        url: "",
        media_id: ""
      },
      license_number: "", //营业执照注册号
      license_address: "", //注册地址


      period_type: "1", //1=定期 2=长期
      period_begin: "", //有效期限开始日期
      period_end: "", //有效期限结束日期,长期直接传“长期”

      merchant_name: "", //商户名称
      legal_person: "", //经营者/法人姓名
    },

    idCardInfo: { //身份证类型
      id_card_copy_info: { //身份证人像照片
        url: "",
        media_id: ""
      },
      id_card_national_info: { //身份证国徽照片
        url: "",
        media_id: ""
      },
      id_card_name: "", //身份证姓名
      id_card_number: "", //身份证号码
      id_card_address: "", //身份证居住地址
      card_period_type: "1", // 1=定期 2=长期
      card_period_begin: "", //身份证有效期开始时间
      card_period_end: "", //身份证有效期结束时间
    },

    idDocInfo: { //非身份证国徽照片
      id_doc_copy_info: { //证件正面照片
        url: "",
        media_id: ""
      },
      id_doc_copy_back_info: { //证件反面照片 护照可不填
        url: "",
        media_id: ""
      },
      id_doc_name: "", //证件姓名
      id_doc_number: "", //证件号码
      id_doc_address: "", //证件居住地址
      doc_period_type: "1", //1=定期 2=长期
      doc_period_begin: "", //证件有效期开始时间
      doc_period_end: "" //证件有效期结束时间
    },


    licenseSite: "", //营业执照注册地址
    licenseEffectiveIdentityType: 1, ///身份证有效期类型
    licenseEffectiveBusiness: "", //执照生效日期
    licenseLoseBusiness: "", //执照失效日期
    licenseEffectiveIdentity: "", //身份证生效日期
    licenseLoseIdentity: "", //身份证失效日期

    picturesUrl: "", //营业执照
    identityZUrl: "",
    identityFUrl: "",
    owner: 1, //主体为企业时，必传，其他不传 1是 0否
    earningsindex: 1,
    earningsList: [{
      id: 0,
      name: "否"
    },
    {
      id: 1,
      name: "是"
    }
    ],
    uboInfoList: [{
      ubo_id_doc_index: "0",//类型下标
      ubo_id_doc_type: 1, //证件类型
      ubo_id_doc_copy_info: { //证件正面照片
        url: "",
        media_id: ""
      },
      ubo_id_doc_copy_back_info: { //证件反面照片（护照不传）
        url: "",
        media_id: ""
      },
      ubo_id_doc_name: "", //证件姓名
      ubo_id_doc_number: "", //证件号码
      ubo_id_doc_address: "", //证件地址
      doc_period_type: "1", //1=定期 2=长期
      ubo_period_begin: "", //证件有效期开始时间
      ubo_period_end: "" //证件有效期结束时间
    },],
    certificateLsit: [{
      id: 1,
      name: "中国大陆居民-身份证"
    },
    {
      id: 2,
      name: "其他国家或地区居民-护照"
    },
    {
      id: 3,
      name: "中国香港居民--来往内地通行证"
    },
    {
      id: 4,
      name: "中国澳门居民--来往内地通行证"
    },
    {
      id: 5,
      name: "中国台湾居民--来往内地通行证"
    },
    {
      id: 6,
      name: "外国人居留证"
    },
    {
      id: 7,
      name: "港澳居民证"
    },
    {
      id: 8,
      name: "台湾居民证"
    },
    ],
    // 激活图片预览
    active1: false,
    active2: false,
    active3: false
  },

  getReceiverApply() {
    wx.showLoading({
      title: '加载中...',
    })
    Http.get({
      url: config.api.getReceiverApply,
      data: {
        merchantId: app.globalData.merchant.merchant_id

      }
    }).then(res => {

      if (res.data && res.data.organizationType) {
        this.setData({
          organizationType: res.data.organizationType
        })
      }

      if (res.data && res.data.id) {
        this.setData({
          id: res.data.id
        })
      }

      if (res.data && res.data.owner || res.data.owner == 0) {
        let index1 = null
        this.data.earningsList.map((item, index) => {
          if (res.data.owner == item.id) {
            index1 = index
          }
        })
        console.log(index1)
        this.setData({
          owner: res.data.owner,
          earningsindex: index1
        })
      }

      if (res.data && res.data.idDocType) {
        this.setData({
          idDocType: res.data.idDocType
        })
      }


      if (res.data && res.data.businessLicenseInfo) {

        this.setData({
          businessLicenseInfo: JSON.parse(res.data.businessLicenseInfo)
        })
      }
      if (res.data && res.data.idDocType == 1 && res.data.idCardInfo) {
        this.setData({
          idCardInfo: JSON.parse(res.data.idCardInfo)
        })
      } else if (res.data && res.data.idDocInfo) {
        this.setData({
          idDocInfo: JSON.parse(res.data.idDocInfo)
        })
      }

      if (res.data.organizationType == 2 && res.data.uboInfoList && res.data.uboInfoList != "[]") {
        this.setData({
          uboInfoList: JSON.parse(res.data.uboInfoList)
        })
      }

      // parame = {
      //   id: this.data.id,
      //   organizationType: this.data.organizationType,
      //   owner: this.data.owner,
      //   idDocType: this.data.idDocType,
      //   businessLicenseInfo: JSON.stringify(this.data.businessLicenseInfo),
      //   // uboInfoList: JSON.stringify(this.data.uboInfoList),

      // }
      // if (this.data.idDocType == 1) {
      //   parame.idCardInfo = JSON.stringify(this.data.idCardInfo)
      // } else {
      //   parame.idDocInfo = JSON.stringify(this.data.idDocInfo)
      // }


      wx.hideLoading();

    }).catch(err => {
      wx.hideLoading();
      wx.showToast({
        title: err.message,
        icon: "none",
        duration: 2000
      })
    })
  },

  normalImage(e) {
    let type = e.currentTarget.dataset.type
    if (type == 1) {
      this.setData({
        active1: false
      })
    } else if (type == 2) {
      this.setData({
        active2: false
      })
    } else if (type == 3) {
      this.setData({
        active3: false
      })
    }
    console.log('normalImage');
  },

  previewImage(e) {
    let type = e.currentTarget.dataset.type
    if (type == 1) {
      this.setData({
        active1: true
      })
    } else if (type == 2) {
      this.setData({
        active2: true
      })
    } else if (type == 3) {
      this.setData({
        active3: true
      })
    }
    console.log('previewImage');
  },

  save(e) {
    let flag = e.currentTarget.dataset.flag
    let errMeg = "";
    let errFlag = false;
    if (!this.data.businessLicenseInfo.license_copy_info.url) {
      errMeg = '请上传营业执照'
      errFlag = true
    } else if (!this.data.businessLicenseInfo.license_number) {
      errMeg = '请填写注册号'
      errFlag = true
    } else if (!this.data.businessLicenseInfo.license_address) {
      errMeg = '请填写执照注册地址'
      errFlag = true
    } else if (!this.data.businessLicenseInfo.merchant_name) {
      errMeg = '请填写商户名称'
      errFlag = true
    } else if (!this.data.businessLicenseInfo.legal_person) {
      errMeg = '请填写经营者姓名'
      errFlag = true
    } else if (this.data.idDocType == 1) {
      if (!this.data.idCardInfo.id_card_copy_info.url) {
        errMeg = "请上传身份证正面照"
        errFlag = true
      } else if (!this.data.idCardInfo.id_card_national_info.url) {
        errMeg = "请上传身份证反面照"
        errFlag = true
      } else if (!this.data.idCardInfo.id_card_name) {
        errMeg = "请填写身份证姓名"
        errFlag = true
      } else if (!this.data.idCardInfo.id_card_number) {
        errMeg = "请填写身份证号码"
        errFlag = true
      } else if (!this.data.idCardInfo.id_card_address) {
        errMeg = "请填写身份证居住地址"
        errFlag = true
      }
    } else if (this.data.idDocType == 2) {
      if (!this.data.idDocInfo.id_doc_copy_info.url) {
        errMeg = "请上传证件正面照"
        errFlag = true
      } else if (!this.data.idDocInfo.id_doc_name) {
        errMeg = "请输入证件名称"
        errFlag = true
      } else if (!this.data.idDocInfo.id_doc_number) {
        errMeg = "请输入证件号码"
        errFlag = true
      } else if (!this.data.idDocInfo.id_doc_address) {
        errMeg = "请输入证件居住地"
        errFlag = true
      }
    } else {
      if (!this.data.idDocInfo.id_doc_copy_info.url) {
        errMeg = "请上传证件正面照"
        errFlag = true
      } else if (!this.data.idDocInfo.id_doc_copy_back_info.url) {
        errMeg = "请上传证件反面照"
        errFlag = true
      } else if (!this.data.idDocInfo.id_doc_name) {
        errMeg = "请输入证件名称"
        errFlag = true
      } else if (!this.data.idDocInfo.id_doc_number) {
        errMeg = "请输入证件号码"
        errFlag = true
      } else if (!this.data.idDocInfo.id_doc_address) {
        errMeg = "请输入证件居住地"
        errFlag = true
      }
    }
    if (this.data.owner == 0) {
      this.data.uboInfoList.map(item => {
        if (!item.ubo_id_doc_copy_info.url) {
          errMeg = "请上传受益人正面正件照"
          errFlag = true
        } else if (!item.ubo_id_doc_copy_back_info.url) {
          errMeg = "请上传受益人反面正件照"
          errFlag = true
        } else if (!item.ubo_id_doc_name) {
          errMeg = "请输入受益人证件姓名"
          errFlag = true
        } else if (!item.ubo_id_doc_number) {
          errMeg = "请输入受益人证件证件号码"
          errFlag = true
        } else if (!item.ubo_id_doc_address) {
          errMeg = "请输入受益人证件居住地"
          errFlag = true
        }
      })
    }

    if (errFlag) {
      wx.showToast({
        title: errMeg,
        icon: "none",
        duration: 2000
      })
      return
    }

    if (this.data.businessLicenseInfo.period_type == 2) {
      let tempBus = this.data.businessLicenseInfo
      tempBus.period_end = "长期"
      this.setData({
        businessLicenseInfo: tempBus
      })
    }

    if (this.data.idCardInfo.card_period_type == 2 && this.data.idDocType == 1) {
      let tempBus = this.data.idCardInfo
      tempBus.card_period_end = "长期"

      this.setData({
        idCardInfo: tempBus
      })
    }


    if (this.data.idDocInfo.doc_period_type == 2 && this.data.idDocType != 1) {
      let tempBus = this.data.idDocInfo
      tempBus.doc_period_end = "长期"

      this.setData({
        idDocInfo: tempBus
      })
    }

    if (this.data.owner == 0) {
      let tempBus = this.data.uboInfoList
      tempBus.map(item => {
        if (item.doc_period_type == 2) {
          item.ubo_period_end == "长期"
        }
      })
      this.setData({
        uboInfoList: tempBus
      })
    }

    let parame = "";
    if (this.data.organizationType == 4) {//个人
      parame = {
        id: this.data.id,
        organizationType: this.data.organizationType,
        owner: this.data.owner,
        idDocType: this.data.idDocType,
        businessLicenseInfo: JSON.stringify(this.data.businessLicenseInfo),
        // uboInfoList: JSON.stringify(this.data.uboInfoList),

      }
      if (this.data.idDocType == 1) {
        parame.idCardInfo = JSON.stringify(this.data.idCardInfo)
      } else {
        parame.idDocInfo = JSON.stringify(this.data.idDocInfo)
      }
    } else {//企业
      parame = {
        id: this.data.id,
        organizationType: this.data.organizationType,
        owner: this.data.owner,
        idDocType: this.data.idDocType,
        businessLicenseInfo: JSON.stringify(this.data.businessLicenseInfo),
        uboInfoList: JSON.stringify(this.data.uboInfoList),

      }
      if (this.data.idDocType == 1) {
        parame.idCardInfo = JSON.stringify(this.data.idCardInfo)
      } else {
        parame.idDocInfo = JSON.stringify(this.data.idDocInfo)
      }
    }

    console.log(parame, "parame")

    Http.post({
      url: config.api.receiverAdd,
      data: parame
    }).then(res => {
      console.log(res, "res")
      if (flag == "save") {
        wx.reLaunch({
          url: '/pages/warehouse/warehouse',
        })
      } else if (flag == "next") {
        wx.navigateTo({
          url: '/pages/warehouse/detail/manageFirm/manageFirm',
        })
      }

    }).catch(err => {
      wx.showToast({
        title: err.message,
        icon: "none",
        duration: 2000
      })
    })

  },
  setUboInfoListItem(e) {

    let value = e.detail.value
    let index = e.currentTarget.dataset.index
    let flag = e.currentTarget.dataset.flag
    let tempObj = this.data.uboInfoList
    tempObj[index][flag] = value
    this.setData({
      uboInfoList: tempObj
    })

    console.log(this.data.uboInfoList)
  },

  setCardName(e) {
    let value = e.detail.value.trim()
    let tempObj = this.data.idCardInfo
    tempObj.id_card_name = value
    this.setData({
      idCardInfo: tempObj
    })
  },
  setBocName(e) {
    let value = e.detail.value
    let tempObj = this.data.idDocInfo
    tempObj.id_doc_name = value
    this.setData({
      idDocInfo: tempObj
    })
  },

  setCardNum(e) {
    let value = e.detail.value.trim()
    let tempObj = this.data.idCardInfo
    tempObj.id_card_number = value
    this.setData({
      idCardInfo: tempObj
    })
  },
  setBocNum(e) {
    let value = e.detail.value
    let tempObj = this.data.idDocInfo
    tempObj.id_doc_number = value
    this.setData({
      idDocInfo: tempObj
    })
  },

  setCardAddress(e) {
    let value = e.detail.value.trim()
    let tempObj = this.data.idCardInfo
    tempObj.id_card_address = value
    this.setData({
      idCardInfo: tempObj
    })
  },

  setBocAddress(e) {
    let value = e.detail.value
    let tempObj = this.data.idDocInfo
    tempObj.id_doc_address = value
    this.setData({
      idDocInfo: tempObj
    })
  },

  setLicenserNum(e) {
    let value = e.detail.value.trim()
    let tempObj = this.data.businessLicenseInfo
    tempObj.license_number = value
    this.setData({
      businessLicenseInfo: tempObj
    })
  },
  setLicenseSite(e) {
    let value = e.detail.value.trim()
    let tempObj = this.data.businessLicenseInfo
    tempObj.license_address = value
    this.setData({
      businessLicenseInfo: tempObj
    })
  },

  setCommercialName(e) {
    let value = e.detail.value.trim()
    let tempObj = this.data.businessLicenseInfo
    tempObj.merchant_name = value
    this.setData({
      businessLicenseInfo: tempObj
    })
  },

  setManageName(e) {
    let value = e.detail.value.trim()
    let tempObj = this.data.businessLicenseInfo
    tempObj.legal_person = value
    this.setData({
      businessLicenseInfo: tempObj
    })
  },


  setPeriodType(e) {
    let value = e.currentTarget.dataset.index
    let tempObj = this.data.businessLicenseInfo
    tempObj.period_type = value
    this.setData({
      businessLicenseInfo: tempObj
    })
  },
  setlicenseEffectiveIdentityType(e) {
    let tempObj = this.data.idCardInfo
    let index = e.currentTarget.dataset.index
    tempObj.card_period_type = index

    this.setData({
      idCardInfo: tempObj
    })
  },
  setlicenseEffectiveIdentityTypeBoc(e) {
    let tempObj = this.data.idDocInfo
    let index = e.currentTarget.dataset.index
    tempObj.doc_period_type = index

    this.setData({
      idDocInfo: tempObj
    })
  },

  setlicenseEffectiveIdentityTypeS(e) {
    let index = e.currentTarget.dataset.index
    let id = e.currentTarget.dataset.id
    let tempObj = this.data.uboInfoList
    tempObj[index].doc_period_type = id
    this.setData({
      uboInfoList: tempObj
    })
  },

  bindDateChange1: function (e) {

    // this.setData({
    //   licenseEffectiveBusiness: e.detail.value,
    // })
    let value = e.detail.value
    let tempObj = this.data.businessLicenseInfo
    tempObj.period_begin = value
    this.setData({
      businessLicenseInfo: tempObj
    })
  },


  bindDateChange2: function (e) {
    let value = e.detail.value
    let tempObj = this.data.businessLicenseInfo
    tempObj.period_end = value
    this.setData({
      businessLicenseInfo: tempObj
    })
  },
  bindDateChange3: function (e) {

    let id = this.data.certificateLsit[e.detail.value].id

    this.setData({
      certificateIndex: e.detail.value,
      idDocType: id
    })
    console.log(id)
  },
  bindDateChange4: function (e) {
    let tempObj = this.data.idCardInfo
    tempObj.card_period_begin = e.detail.value
    this.setData({
      idCardInfo: tempObj,
    })
  },
  bindDateChangeBoc4: function (e) {
    let tempObj = this.data.idDocInfo
    tempObj.doc_period_begin = e.detail.value
    this.setData({
      idDocInfo: tempObj,
    })
  },

  bindDateChange5: function (e) {
    let tempObj = this.data.idCardInfo
    tempObj.card_period_end = e.detail.value
    this.setData({
      idCardInfo: tempObj,
    })
  },
  bindDateChangeBoc5: function (e) {
    let tempObj = this.data.idDocInfo
    tempObj.doc_period_end = e.detail.value
    this.setData({
      idDocInfo: tempObj,
    })
  },

  bindDateChange6: function (e) {
    let id = this.data.earningsList[e.detail.value].id
    console.log(id)
    this.setData({
      earningsindex: e.detail.value,
      owner: id,
    })
  },

  beneficiaryCertificate(e) {
    let id = this.data.certificateLsit[e.detail.value].id
    let index = e.currentTarget.dataset.index;
    let tempArr = this.data.uboInfoList
    tempArr[index].ubo_id_doc_type = id
    tempArr[index].ubo_id_doc_index = e.detail.value
    this.setData({
      uboInfoList: tempArr,
    })
    console.log(this.data.uboInfoList)
  },


  upPictures() {
    let that = this;
    wx.chooseImage({
      success(res) {
        const tempFilePaths = res.tempFilePaths
        wx.uploadFile({
          url: config.api.merchantUpload, // 仅为示例，非真实的接口地址
          filePath: tempFilePaths[0],
          name: 'file',
          header: {
            'token': app.globalData.token
          },
          success(res) {
            let tempObj = that.data.businessLicenseInfo
            tempObj.license_copy_info = JSON.parse(res.data).data
            that.setData({
              // picturesUrl: JSON.parse(res.data).data.url
              businessLicenseInfo: tempObj
            })
            console.log(that.data.businessLicenseInfo, "businessLicenseInfo")
            // do something
          },
        })
      }
    })
  },

  delPicturesUrl() {
    let tempObj = this.data.businessLicenseInfo
    tempObj.license_copy_info.url = ""
    this.setData({
      businessLicenseInfo: tempObj
    })
  },
  beneficiaryUpIdentityZ(e) {

    let that = this;
    let index = e.currentTarget.dataset.index
    let tempObj = that.data.uboInfoList

    wx.chooseImage({
      success(res) {
        const tempFilePaths = res.tempFilePaths
        wx.uploadFile({
          url: config.api.merchantUpload, // 仅为示例，非真实的接口地址
          filePath: tempFilePaths[0],
          name: 'file',
          header: {
            'token': app.globalData.token
          },
          success(res) {

            tempObj[index].ubo_id_doc_copy_info = JSON.parse(res.data).data
            that.setData({
              // picturesUrl: JSON.parse(res.data).data.url
              uboInfoList: tempObj
            })
            console.log(that.data.owner, that.data.organizationType)
            // do something
          }
        })
      }
    })
  },

  beneficiaryUpIdentityF(e) {
    let that = this
    let index = e.currentTarget.dataset.index
    let tempObj = that.data.uboInfoList
    wx.chooseImage({
      success(res) {
        const tempFilePaths = res.tempFilePaths
        wx.uploadFile({
          url: config.api.merchantUpload, // 仅为示例，非真实的接口地址
          filePath: tempFilePaths[0],
          name: 'file',
          header: {
            'token': app.globalData.token
          },
          success(res) {
            const data = res.data
            tempObj[index].ubo_id_doc_copy_back_info = JSON.parse(res.data).data
            that.setData({
              uboInfoList: tempObj
            })
            // do something
          }
        })
      }
    })
  },


  delIdentityZUrl() {
    let tempObj = this.data.idCardInfo
    tempObj.id_card_copy_info.url = "",
      this.setData({
        idCardInfo: tempObj,
      })
  },

  delIdentityZUrlRest() {
    let tempObj = this.data.idDocInfo
    tempObj.id_doc_copy_info.url = "",
      this.setData({
        idDocInfo: tempObj,
      })
  },

  upIdentityZ() { //身份证正面照片
    let that = this;
    let tempObj = that.data.idCardInfo
    wx.chooseImage({
      success(res) {
        const tempFilePaths = res.tempFilePaths
        wx.uploadFile({
          url: config.api.merchantUpload, // 仅为示例，非真实的接口地址
          filePath: tempFilePaths[0],
          name: 'file',
          header: {
            'token': app.globalData.token
          },
          success(res) {
            const data = res.data
            tempObj.id_card_copy_info = JSON.parse(res.data).data
            that.setData({
              idCardInfo: tempObj
            })
            // do something
          }
        })
      }
    })
  },

  upIdentityZRest() { //身份证正面照片
    let that = this;
    let tempObj = that.data.idDocInfo
    wx.chooseImage({
      success(res) {
        const tempFilePaths = res.tempFilePaths
        wx.uploadFile({
          url: config.api.merchantUpload, // 仅为示例，非真实的接口地址
          filePath: tempFilePaths[0],
          name: 'file',
          header: {
            'token': app.globalData.token
          },
          success(res) {
            const data = res.data
            tempObj.id_doc_copy_info = JSON.parse(res.data).data
            that.setData({
              idDocInfo: tempObj
            })
            // do something
          }
        })
      }
    })
  },


  delIdentityZUrlS(e) {
    let index = e.currentTarget.dataset.index
    let tempObj = this.data.uboInfoList
    tempObj[index].ubo_id_doc_copy_info.url = ""
    this.setData({
      uboInfoList: tempObj
    })
  },

  delIdentityFUrlS(e) {
    let index = e.currentTarget.dataset.index
    let tempObj = this.data.uboInfoList
    tempObj[index].ubo_id_doc_copy_back_info.url = ""
    this.setData({
      uboInfoList: tempObj
    })
  },

  delIdentityFUrl() {
    let tempObj = this.data.idCardInfo
    tempObj.id_card_national_info.url = "",
      this.setData({
        idCardInfo: tempObj,
      })
  },
  delIdentityFUrlRest() {
    let tempObj = this.data.idDocInfo
    tempObj.id_doc_copy_back_info.url = "",
      this.setData({
        idDocInfo: tempObj,
      })
  },
  upIdentityF() {
    let that = this;
    let tempObj = that.data.idCardInfo
    wx.chooseImage({
      success(res) {
        const tempFilePaths = res.tempFilePaths
        wx.uploadFile({
          url: config.api.merchantUpload, // 仅为示例，非真实的接口地址
          filePath: tempFilePaths[0],
          name: 'file',
          header: {
            'token': app.globalData.token
          },
          success(res) {
            const data = res.data
            tempObj.id_card_national_info = JSON.parse(res.data).data
            that.setData({
              idCardInfo: tempObj
            })
            // do something
          }
        })
      }
    })
  },

  upIdentityFRest() {
    let that = this;
    let tempObj = that.data.idDocInfo
    wx.chooseImage({
      success(res) {
        const tempFilePaths = res.tempFilePaths
        wx.uploadFile({
          url: config.api.merchantUpload, // 仅为示例，非真实的接口地址
          filePath: tempFilePaths[0],
          name: 'file',
          header: {
            'token': app.globalData.token
          },
          success(res) {
            const data = res.data
            tempObj.id_doc_copy_back_info = JSON.parse(res.data).data
            that.setData({
              idDocInfo: tempObj
            })
            // do something
          }
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getReceiverApply()
    let that = this;
    //获取完整的日期
    let date = new Date;
    let year = date.getFullYear();
    let month = date.getMonth() + 1;
    let day = date.getDate();
    let tempObj = that.data.businessLicenseInfo;
    let tempObjCard = that.data.idCardInfo;
    let tempObjBoc = that.data.idDocInfo;
    let tempObjUbo = that.data.uboInfoList;

    if (month < 10) {
      month = "0" + month
    }
    if (day < 10) {
      day = "0" + day
    }
    tempObj.period_begin = year + '-' + month + '-' + day
    tempObj.period_end = year + '-' + month + '-' + day

    tempObjCard.card_period_begin = year + '-' + month + '-' + day
    tempObjCard.card_period_end = year + '-' + month + '-' + day

    tempObjBoc.doc_period_begin = year + '-' + month + '-' + day
    tempObjBoc.doc_period_end = year + '-' + month + '-' + day
    tempObjUbo.map(item => {
      item.ubo_period_begin = year + '-' + month + '-' + day
      item.ubo_period_end = year + '-' + month + '-' + day
    })

    that.setData({
      // licenseEffectiveBusiness: year + '-' + month + '-' + day,
      licenseEffectiveIdentity: year + '-' + month + '-' + day,
      // licenseLoseBusiness: year + '-' + month + '-' + day,
      licenseLoseIdentity: year + '-' + month + '-' + day,
      businessLicenseInfo: tempObj,
      idCardInfo: tempObjCard,
      idDocInfo: tempObjBoc,
      uboInfoList: tempObjUbo
    })
  },

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

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

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

  },

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

  },

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

  },

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

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})