<template>
  <div class="insured-info-container pb60 redRadioCheckbox">
    <!-- 基本信息 -->
<!--    <index-bar  :key="renovate"></index-bar>-->
    <!-- 项目信息 -->
    <van-cell-group :border="false" v-if="branchType == '13'">
      <p style="border-bottom: 1px solid #ebedf0" class="fs15 fwb pl10 pv12">项目信息</p>
      <van-field v-model="projectDTO.projectCode" label="项目编号" name="项目编号" readonly placeholder="请输入"/>
      <van-field v-model="projectDTO.projectName" label="项目名称" name="项目名称" readonly placeholder="请输入"/>
      <van-field v-model="projectDTO.teamCode" label="团队组代码" name="团队组代码" readonly placeholder="请输入"/>
      <van-field v-model="projectDTO.teamName" label="小组名称" name="小组名称" readonly placeholder="请输入"/>
      <van-field v-model="projectDTO.personCode" label="业务员工号" name="业务员工号" readonly placeholder="请输入"/>
      <van-field v-model="projectDTO.personName" label="业务员姓名" name="业务员姓名" readonly placeholder="请输入"/>
<!--      <van-field :value="projectDTO.departmentName" @click="toSelect('GBCKS')" readonly required label="部门/科室" name="部门/科室" right-icon="arrow" placeholder="请选择"/>-->
    </van-cell-group>
    <van-cell-group class="mt10">
      <p style="border-bottom: 1px solid #ebedf0" class="fs15 fwb pl10 pv12">基本信息</p>
      <van-field v-show="branchType == '13'" v-model="projectDTO.departmentName" @click="toSelect('GBCKS')" readonly required v-validate="'required'" label="部门/科室" name="部门/科室" right-icon="arrow" placeholder="请选择"/>
      <customer-picker
              @on-choose="chooseCustomer"
              v-validate="'required|salename'"
              name="姓名"
              label="姓名"
              required
              :parentShowPicker.sync="customerShowPicker"
              v-model="userInfo.name"
              @nameChange="nameChange"
              @on-click="selectClick('1')"
      ></customer-picker>
      <van-field
              :value="userInfo.idType | idToText('insuredIdType')"
              v-validate="'required'"
              readonly
              required
              label="证件类型"
              name="证件类型"
              right-icon="arrow"
              placeholder="请选择"
              @click="toSelect('2')"
      />
      <!-- <van-field v-model="userInfo.idNo" v-validate="'required|idNo'" maxlength="18" label="证件号码" name="证件号码" placeholder="请输入" clearable> -->
      <van-field
              v-model="userInfo.idNo"
              maxlength="18"
              required
              label="证件号码"
              v-validate="'required'"
              name="证件号码"
              placeholder="手工录入或点击右侧证件扫描"
              clearable
              @blur="getRelatedData(userInfo.idNo)"
      >
        <van-button v-if="userInfo.idType == 1" slot="button" size="small" type="danger" round @click="selectClick('3')">证件扫描</van-button>
      </van-field>
      <FieldDatePicter
              v-validate="'required'"
              label="证件起始日期"
              name="证件起始日期"
              required
              :value.sync="userInfo.certificateValidate"
              type="date"
              @confirm="onDateConfirm($event, '0')"
              ref="certificateValidate"
              :flag="true"
      ></FieldDatePicter>
      <FieldDatePicter
              :v-validate="{ required: certiexpiredateRequired }"
              required
              label="证件截止日期"
              name="证件截止日期"
              :value.sync="userInfo.certiexpiredate"
              type="date"
              @confirm="onDateConfirm($event, '1')"
              ref="certiexpiredate"
              :flag="true"
              :readonly="idLimit"
      ></FieldDatePicter>
      <div class="border-bt relative fs14 p10 flex align-center">
        <van-checkbox v-model="userInfo.effectiveDateType" :disabled="effectiveDateTypeAble" @change="effectiveDataTypeChange">长期</van-checkbox>
      </div>
      <van-field
              :value="userInfo.riskName"
              readonly
              required
              label="产品名称"
              name="产品名称"
              v-validate="'required'"
              right-icon="arrow"
              placeholder="请选择"
              @click="GBCproductChoosePopupShow = true"
      />
      <select-radio :radios="sexRadio" :required="false" label="性别" name="性别" :value.sync="userInfo.sex"></select-radio>
      <van-field
              :value="userInfo.marriageStatus"
              readonly
              label="婚姻状况"
              name="婚姻状况"
              right-icon="arrow"
              placeholder="请选择"
              @click="toSelect('10')"
      />
      <van-field
              :value="userInfo.nativeplace | idToText('nativeplace')"
              readonly
              label="国籍"
              name="国籍"
              right-icon="arrow"
              placeholder="请选择"
              @click="toSelect('1')"
      />
      <FieldDatePicter
              v-validate="'required'"
              label="出生日期"
              name="出生日期"
              :value.sync="userInfo.birthday"
              type="date"
              :flag="true"
              @confirm="onDateConfirm($event, '2')"
              ref="birthday"
              :maxDate="maxDate"
      ></FieldDatePicter>

      <van-field
              required
              v-model="userInfo.mobile"
              clearable
              label="移动电话"
              name="移动电话"
              placeholder="请输入"
              v-validate="'required|mobileLength11|mobileStartWith1|mobile'"
              maxlength="11"
      />
      <van-field
              v-model="userInfo.email"
              label="电子邮箱"
              name="电子邮箱"
              placeholder="请输入"
              v-validate="'email'"
              clearable />
      <van-field
              v-model="userInfo.stature"
              label="身高(cm)"
              name="身高"
              placeholder="请输入，单位cm"
              v-validate="'onlyNumber|stature'"
              clearable
              @blur="checkStature(userInfo.stature)"
              maxlength="5"
      />
      <van-field
              v-model="userInfo.avoirdupois"
              label="体重(kg)"
              name="体重"
              placeholder="请输入，单位kg"
              v-validate="'onlyNumber|avoirdupois'"
              clearable
              @blur="checkAvoirdupois(userInfo.avoirdupois)"
      />
      <div class="p15 pl8 fs14" style="border-bottom: 1px solid #eee;display: flex;justify-content: space-between;align-items: center;" v-if="manageComCode == '45'">
        <van-radio-group v-model="userInfo.isNewPeopleFlag" class="flex">
          <label style="margin-left: 8px;">
            新市民身份
          </label>
          <van-radio name="1" class="ml30">是</van-radio>
          <van-radio name="0" class="ml20">否</van-radio>
        </van-radio-group>
        <van-icon name="question-o" size="20" @click="isNewPeopleFlagTip"/>
      </div>
      <van-field
              v-if="userInfo.isNewPeopleFlag == 1"
              :value="userInfo.npType | idToText('npType')"
              readonly
              label="新市民类型"
              name="新市民类型"
              right-icon="arrow"
              placeholder="请选择"
              v-validate="'required'"
              @click="toSelect('11')"
      />
    </van-cell-group>
    <!-- 工作信息 -->
    <van-cell-group :border="false">
      <p style="border-bottom: 1px solid #ebedf0" class="fs15 fwb pl10 mt10 pv12">工作信息</p>
      <select-radio :radios="medicalRadio" label="有无社保" name="有无社保" :required="false" :value.sync="userInfo.medical"></select-radio>
      <van-field
              :value="userInfo.taxResidentId | idToText('taxIdentity')"
              readonly
              label="税收居民身份"
              name="税收居民身份"
              right-icon="arrow"
              placeholder="请选择"
              @click="toSelect('5')"
      />

      <occupation-picker
              :value.sync="userInfo.occupationCode"
              :chooseName.sync="userInfo.occupationName"
              :lifeGrade.sync="userInfo.lifeGrade"
              :healthGrade.sync="userInfo.healthGrade"
              clearable
              label="职业类别"
              name="职业类别"
              placeholder="请选择"
              :parentShowPicker.sync="occupationShowPicker"
              @on-click="selectClick('2')"
              @on-choose="chooseOccupation"
      />
      <van-field
              :value="userInfo.salarySource | idToText('salarySource')"
              readonly
              label="收入来源"
              name="收入来源"
              right-icon="arrow"
              placeholder="请选择"
              @click="toSelect('8')"
      />
      <van-field
              v-show="isShowOthenSalarySource"
              v-model="userInfo.otherSalarySource"
              label
              name="其他来源"
              placeholder="请输入其它收入来源"
              clearable
              maxlength="30"
      />
      <van-field
              v-model="userInfo.averageAnnualIncome"
              label="平均年收入（万元）"
              name="平均年收入"
              placeholder="请输入，单位万元"
              v-validate="'onlyNumber'"
              clearable
              maxlength="5"
      />
      <van-field
              v-model="userInfo.liabilitiesMoney"
              name="负债金额"
              placeholder="请输入，单位万元"
              v-validate="'onlyNumber'"
              clearable
              maxlength="5"
      >
        <div slot="label" class="flex flex-wrap">
          <span>负债金额</span>
          <span>（万元）</span>
        </div>
      </van-field>
      <select-radio :required="false" :radios="Asyncs" label="是否协同工作单位" name="是否协同工作单位" :value.sync="userInfo.isAsync"></select-radio>
      <SearchField
              :isAsync="userInfo.isAsync == 1"
              @workcompanys="workcompanys"
              v-model="userInfo.workcompany"
              label="工作单位"
              :required="false"
              placeholder="无工作单位，请输入无"
              name="工作单位"
      />
    </van-cell-group>
    <!-- 家庭信息 -->
    <van-cell-group>
      <p style="border-bottom: 1px solid #ebedf0" class="fs15 mt10 fwb pl10 pv12">地址信息</p>
      <van-field
              v-model="homeName"
              readonly
              label="联系地址"
              name="联系地址"
              right-icon="arrow"
              placeholder="请选择"
              @click="homeShow = true"
      />
      <van-field
              v-model="userInfo.homeAddress"
              label
              name="详细地址"
              placeholder="具体到街道、门牌号、楼号、单元号、室号"
              clearable
              maxlength="30"
              style="font-size: 3.5vw"
      />
    </van-cell-group>
    <div class="bottom-btn" style="display: flex;justify-content: space-between;">
      <van-button type="default" plain style="width: 50%;" v-no-more-click="1000">
        总保费：<span style="color: #ee0a24;">0</span> 元
      </van-button>
      <van-button type="danger"  style="width: 50%;" @click="nextStep" v-no-more-click="1000">
        提交
      </van-button>
    </div>

    <!-- 字段选择 -->
    <van-popup v-model="popupShow" position="bottom"><van-picker show-toolbar :columns="columns" @confirm="onConfirm" @cancel="popupShow = false" /></van-popup>
    <!-- 联系地址选择 -->
    <van-popup v-model="homeShow" position="bottom"
    ><van-area :area-list="areaLists" :value="areaValue" @confirm="sureArea($event, '2')" @cancel="homeShow = false"
    /></van-popup>
    <!-- 户籍选择 -->
    <!-- <van-popup v-model="censusShow" position="bottom">
      <van-area :area-list="areaList" value="110101" :columns-num="2" @confirm="sureArea($event, '3')" @cancel="censusShow = false" />
    </van-popup> -->
    <!--身份证扫描 -->
    <van-popup v-model="isScan" position="bottom"><IdentityCardScan @getScanInfo="getIdentityInfo"></IdentityCardScan></van-popup>
    <van-dialog v-model="isNewPeopleFlagTipshow" :showConfirmButton="false">
      <div slot="title">
        <p style="color: #E9332E;">新市民身份说明</p>
      </div>
      <div style="padding: 20px 30px 30px;font-size: 14px;">
        <div style="line-height: 25px;">新市民是指因本人创业就业、子女上学、投靠子女等原因来到城镇常住，未获得当地户籍或获得当地户籍不满三年的各类群体，包括但不限于进城务工人员、新就业大中专毕业生等。</div>
      </div>
      <div style="text-align: center;margin-bottom: 30px;">
        <van-button round type="danger" size="small" style="padding:0px 35px;font-size: 14px;" @click="isNewPeopleFlagTipshow = false">我知道了</van-button>
      </div>
    </van-dialog>
    <van-dialog v-model="thisdoubledialogshow" :showConfirmButton="false">
      <div slot="title">
        <p style="color: #E9332E;">提示</p>
      </div>
      <div style="padding: 20px 30px 30px;font-size: 14px;">
        <div style="line-height: 25px;">根据监管要求，本单需要您配合对销售过程进行录音录像！</div>
      </div>
      <div style="text-align: center;">
        <van-button type="danger" block style="font-size: 14px;" @click="thisdoubledialogfunc">确定</van-button>
      </div>
    </van-dialog>
    <!--产品选择 -->
    <van-popup v-model="GBCproductChoosePopupShow" position="bottom" style="height:30vh;border-top-left-radius: 5px;border-top-right-radius: 5px;" >
      <div style="display: flex;justify-content: space-between;padding: 15px;">
        <p style="color: #ee0a24;" @click="GBCproductChoosePopupShowCancel">取消</p>
        <p style="color: #ee0a24;" @click="GBCproductChoosePopupShowSure">确定</p>
      </div>
      <div style="padding: 0px 15px 15px;overflow: auto;height: calc(100% - 50px);">
        <van-radio-group v-model="userInfo.riskProductCode">
          <van-cell-group>
            <van-cell v-for="(item,index) in gbcProductList" :key="index">
              <template #title>
                <p style="line-height: 25px;color: #666;font-size: 13px;">{{item.riskProductCode}}</p>
                <p style="line-height: 25px;color: #333;font-size: 15px;">{{item.riskName}}</p>
              </template>
              <template #right-icon>
                <van-radio :name="item.riskProductCode"/>
              </template>
            </van-cell>
          </van-cell-group>
        </van-radio-group>
      </div>
    </van-popup>
  </div>
</template>
<script>
  import { Field, CellGroup, Checkbox, Popup, Picker, Area, RadioGroup, Radio, Dialog } from 'vant'
  import SelectRadio from '@/components/ebiz/SelectRadio'
  import IndexBar from '@/components/ebiz/sale/IndexBar'
  import FieldDatePicter from '@/components/ebiz/FieldDatePicter'
  import OccupationPicker from '@/components/ebiz/occipation/OccupationPicker'
  import CustomerPicker from '@/components/ebiz/customer/CustomerPicker'
  import DataDictionary from '@/assets/js/utils/data-dictionary'
  import areaList from '@/assets/js/utils/areaForSale'
  import countCredentialValidity from '@/assets/js/utils/countCredentialValidity'
  import areaLists from '@/assets/js/utils/areaNewForSale'
  import { saveOrUpdateOrderInfo, getOrderDetail, getCompany } from '@/api/ebiz/sale/sale'
  import utilsAge from '@/assets/js/utils/age'
  import getAreaName from '@/assets/js/utils/getAreaNameForSale'
  import IdentityCardScan from '@/components/ebiz/sale/IdentityCardScan'
  import idNoCheck from '@/assets/js/utils/idNoCheck'
  import beforeDate from '@/assets/js/utils/getBeforeDate.js'
  import { idToData } from '@/views/ebiz/sale/js/verification'
  import { selectComp, getIdentityInfo } from '@/views/ebiz/sale/js/methods'
  import SearchField from '@/components/common/SearchField'
  import riskRules from '@/views/ebiz/common/risk-rules'
  import { gbcProjectDetail, getDepartmentByProjectNo,getGBCRiskList,gbcAppntCheckProdect, saveOrUpdateGbc } from '@/api/GBC/GBC'

  export default {
    name: 'insuredInfo',
    components: {
      [SelectRadio.name]: SelectRadio,
      [FieldDatePicter.name]: FieldDatePicter,
      [OccupationPicker.name]: OccupationPicker,
      [CustomerPicker.name]: CustomerPicker,
      [Field.name]: Field,
      [CellGroup.name]: CellGroup,
      [Checkbox.name]: Checkbox,
      [Popup.name]: Popup,
      [Picker.name]: Picker,
      [Area.name]: Area,
      [RadioGroup.name]: RadioGroup,
      [Radio.name]: Radio,
      [IdentityCardScan.name]: IdentityCardScan,
      [IndexBar.name]: IndexBar,
      [Dialog.name]: Dialog,
      SearchField,
    },
    data() {
      return {
        branchType: '',
        projectDTO:{
          platformName:'',
          projectName:'',
          teamCode:'',
          endDate:'',
          personCode:'',
          leaderCode:'',
          departmentName:'',
          departmentCode:'',
        },
        departmentList:[],
        thisdoubledialogshow: false,
        thismyorderNo: '',
        thismystr: '',
        isNewPeopleFlagTipshow: false,
        renovate: '',
        specilFlag: '', //特殊显示-为桂企产品专写 1-桂企 undefind-其他
        productCodes: [], //产品编码-用于“产品允许投保人单位列表获取”接口，作为请求参数
        isScan: false, //是否显示证件扫描组件
        Asyncs: [
          {
            label: '是',
            value: '1'
          },
          {
            label: '否',
            value: '0'
          }
        ],
        sexRadio: [
          {
            label: '男',
            value: '0',
          },
          {
            label: '女',
            value: '1',
          },
        ],
        medicalRadio: [
          {
            label: '有',
            value: '0',
          },
          {
            label: '无',
            value: '1',
          },
        ],
        maxDate: beforeDate.getBeforeYear(16),
        certiexpiredateRequired: true, //证件截止日期是否需要校验
        popupShow: false,
        homeShow: false,
        pickerType: undefined,
        columns: [],
        valueKey: 'text',
        homeName: '', //联系地址
        companyDefault: false, //设置公司地址为默认地址
        homeDefault: false, //设置联系地址为默认地址
        setDefaultAddress: false, //设为联系地址
        sessionId: '', //后台返回的 id
        effectiveDateTypeAble: false, //长期按钮是否禁用
        userInfo: {
          marriageStatus: '',
          name: '', //投保人姓名
          sex: '', //投保人性别
          nativeplace: '1', //国家地区
          birthday: '',
          idType: '1', //证件类型
          idNo: '', //证件号码
          certificateValidate: '', //证件起始日期
          certiexpiredate: '', //证件到期时间
          effectiveDateType: false, //是否长期
          occupationCode: '', //职业类别编码
          occupationName: '', //职业类别名称
          salarySource: '', // 收入来源
          otherSalarySource: '', // 其他来源
          lifeGrade: '', //寿险等级
          healthGrade: '', //健康等级
          mobile: '', //移动电话
          stature: '', //身高
          avoirdupois: '', //体重
          medical: '', //有无社保
          taxResidentId: '', //税收居民身份
          averageAnnualIncome: '', //平均年收入
          workcompany: '', //工作单位
          isAsync: '', //是否协同工作单位 0否 1是
          province: '',
          area: '',
          marriage: '', //婚姻状况
          email: '', //电子邮箱
          liabilitiesMoney: '', //负债金额
          postcode: '', //邮编
          officeTel: '', //单位电话
          homeProvince: '', //家庭省
          homeCity: '', //家庭市
          homeArea: '', //家庭区
          homeAddress: '', //家庭详细地址
          isNewPeopleFlag: '', //新市民身份
          npType: '', //新市民类型
        },
        areaList: areaList,
        areaLists: areaLists,
        currentPopupIndex: '',
        customerShowPicker: false,
        occupationShowPicker: false,
        timeId: null,
        idLimit: false, //证件起止日期是否只读
        salePageFlag: '1',
        userWorkcompanys: [], //单位数据
        manageComCode:'',//代理人管理机构 52贵州 45广西
        areaValue:'', //代理人管理机构--省级编号
        gbcProductList:[],
        GBCproductChoosePopupShow:false,
        radioaaa:'',
      }
    },
    created() {
      this.specilFlag = this.$route.query.specilFlag
      localStorage.removeItem('bankCardUrlPath')
      localStorage.removeItem('bankCard')
      localStorage.removeItem('bankCardUrlInsuredPath')
      localStorage.removeItem('bankCardInsured')
      localStorage.removeItem('imgfrontPath')
      localStorage.removeItem('imgfrontInsuredPath')
      localStorage.removeItem('imgBackPath')
      localStorage.removeItem('imgBackInsuredPath')

      //如果是编辑/导航进来
      if (this.$route.query.edit) {
        const orderNo = this.$route.query.orderNo
        getOrderDetail({ orderNo: orderNo }).then((res) => {
          if (res.result == 0) {
            this.renovate = new Date().getTime()
            //投保人信息返显
            this.userInfo = res.orderDTO.appntDTO
            this.setCustomerMarriage(res.orderDTO.appntDTO.marriage)
            //是否长期
            this.userInfo.effectiveDateType = res.orderDTO.appntDTO.effectiveDateType == 'false' ? false : true
            //有无社保
            this.userInfo.medical = res.orderDTO.appntDTO.medical
            //设为联系地址
            // this.userInfo.addressStatus = '0'
            //证件类型
            // this.userInfo.idType = '1'
            //国家/地区
            // this.userInfo.nativeplace = '1'
            this.$utils.intLocalStorage(res)

            if (this.$route.query.edit && !this.$route.query.salePageFlag) {
              //如果从保单列表点击编辑按钮进入
              this.salePageFlag = '1'
              localStorage.setItem('salePageFlag', this.salePageFlag)
            } else {
              this.homeName = getAreaName([
                { code: res.orderDTO.appntDTO.homeProvince },
                { code: res.orderDTO.appntDTO.homeCity },
                { code: res.orderDTO.appntDTO.homeArea },
              ]) //获取联系地址
              // this.census = getAreaName([{ code: res.orderDTO.appntDTO.householdProvince }, { code: res.orderDTO.appntDTO.householdCity }]) //获取户籍
            }
            //------------------------专为桂企写死--begin---------------//
            if (res.orderDTO.insuredDTOs[0] && res.orderDTO.insuredDTOs[0].riskDTOLst) {
              this.specilFlag = res.orderDTO.insuredDTOs[0].riskDTOLst.some((v) => {
                return v.riskCode == 'GFRS_M0024' || v.riskCode == 'GFRS_M0040'
              })
                      ? '1'
                      : '0'
            } else if (res.orderDTO.orderInfoDTO.productCode == 'GFRS_M0024') {
              this.specilFlag = '1'
            } else if (res.orderDTO.orderInfoDTO.productCode == 'GFRS_M0040') {
              this.specilFlag = '1'
            }
            if(this.$route.query.orderNo) {
              this.projectDTO.platformName = res.orderDTO.ebizOrderGbcRelDTO.unitName
              this.projectDTO.projectName = res.orderDTO.ebizOrderGbcRelDTO.projectName
              this.projectDTO.teamCode = res.orderDTO.ebizOrderGbcRelDTO.teamCode
              this.projectDTO.endDate = res.orderDTO.ebizOrderGbcRelDTO.projectEndDate
              this.projectDTO.personCode = res.orderDTO.ebizOrderGbcRelDTO.personCode
              this.projectDTO.leaderCode = res.orderDTO.ebizOrderGbcRelDTO.teamLeaderCode
              this.projectDTO.departmentName = res.orderDTO.ebizOrderGbcRelDTO.departmentName
              this.projectDTO.departmentCode = res.orderDTO.ebizOrderGbcRelDTO.departmentCode
            }

            // ------------------------专为桂企写死--end---------------//
          }
        })
      } else {
        localStorage.setItem('salePageFlag', this.salePageFlag)
        this.$CacheUtils.setLocItem('saleInsuredInfo', '')
      }
    },
    async mounted() {
      setTimeout(() => {
        // eslint-disable-next-line no-undef
        EWebBridge.webCallAppInJs('webview_left_button', {
          img: this.$assetsUrl + 'images/del-close-btn@3x.png',
          intercept: '1', //是否拦截原生返回事件 1是 其他否
        })
      }, 100)
      // 筛选按钮的点击事件
      window.appCallBack = this.appCallBack
      //获取代理人管理机构 52贵州 45广西
      let dataReturn = await riskRules.getAgentInfoFunc(this)
      this.manageComCode = dataReturn.manageComCode
      if(this.manageComCode == '45'){
        areaLists.province_list = {
          450000: '广西壮族自治区'
        }
        this.areaValue = '450000'
      }else{
        areaLists.province_list = {
          520000: '贵州省'
        }
        this.areaValue = '520000'
      }
      this.areaLists = areaLists
      if(window.localStorage.getItem('branchType') == '13') {
        this.branchType = '13'
        if(!this.$route.query.orderNo) {
          this.gbcProjectDetail()
        }
        this.getDepartmentByProjectNo()
        this.getGBCRiskList()
      }
    },
    methods: {
      getGBCRiskList(){
        let params = {

        }
        getGBCRiskList(params).then(res=>{
          if(res.result == 0) {
            this.gbcProductList = []
            if(res.gbcProductList && res.gbcProductList.length != 0) {
              this.gbcProductList = res.gbcProductList
            }
          } else {
            this.$toast(res.resultMessage)
          }
        })
      },
      GBCproductChoosePopupShowCancel(){
        this.userInfo.riskProductCode = ''
        this.userInfo.riskName = ''
        this.GBCproductChoosePopupShow = false
      },
      GBCproductChoosePopupShowSure(){
        this.gbcProductList.forEach(item=>{
          if(item.riskProductCode == this.userInfo.riskProductCode) {
            this.userInfo.riskProductCode = item.riskProductCode
            this.userInfo.riskName = item.riskName
          }
        })
        if(this.userInfo.riskName) {
          let params = {
            idType: this.userInfo.idType,
            idNo: this.userInfo.idNo,
            productNo: this.userInfo.riskProductCode
          }
          gbcAppntCheckProdect(params).then(res=>{
            if(res.result == 0) {
              this.GBCproductChoosePopupShow = false
            } else {
              this.$toast(res.resultMessage)
            }
          })
        } else {
          this.$toast("请选择产品")
        }
      },
      chooseProductList(data){
        this.gbcProductList.forEach(item=>{
          if(item.riskProductCode == data.riskProductCode) {
            item.GBCProductChecked = true
          } else {
            item.GBCProductChecked = false
          }
        })
      },
      getDepartmentByProjectNo(){
        let params = {

        }
        getDepartmentByProjectNo(params).then(res=>{
          if(res.result == '0'){
            this.departmentList = []
            if(res.content && res.content.length != 0) {
              res.content.forEach(item=>{
                this.departmentList.push({
                  id: item.departmentCode,
                  text: item.departmentName
                })
              })
            }
          } else {
            this.$toast(res.resultMessage)
          }
        })
      },
      gbcProjectDetail(){
        let params = {

        }
        gbcProjectDetail(params).then(res=>{
          if(res.result == '0') {
            this.projectDTO = res.content
          } else {
            this.$toast(res.resultMessage)
          }
        })
      },
      isNewPeopleFlagTip(){
        this.isNewPeopleFlagTipshow = true
      },
      workcompanys(list) {
        // 单位数据
        console.log(list)
        this.userWorkcompanys = list
      },
      setCustomerMarriage(marriageCode) {
        for (let status of DataDictionary.marriage) {
          if (status.id == marriageCode) {
            this.userInfo.marriageStatus = status.text
            this.userInfo.marriage = status.id
          }
        }
      },
      //监听名字变化
      nameChange(name) {
        this.userInfo.name = name
      },
      selectClick(index) {
        selectComp(this, index, '1')
      },
      appCallBack(data) {
        if (data.trigger == 'left_button_click') {
          return this.$dialog
                  .confirm({
                    className: 'dialog-delete',
                    title: '提示',
                    message: '退出流程可能会丢失部分数据，是否确认退出？',
                    cancelButtonColor: '#E9332E',
                    confirmButtonColor: '#FFFFFF',
                  })
                  .then(() => {
                    this.$jump({
                      flag: 'h5',
                      extra: {
                        title: '电子投保单列表',
                        forbidSwipeBack: 1, //当前页面禁止右滑返回
                        url: location.origin + `/#/sale/list`,
                      },
                      routerInfo: {
                        path: `/sale/list`,
                        type: '1',
                      },
                    })
                  })
                  .catch(() => {
                    return
                  })
        } else {
          // 筛选按钮的点击事件
          this.$jump({
            flag: 'navigation',
            extra: {
              title: '投保人信息',
              hiddenRight: '1',
            },
          })
          if (this.currentPopupIndex == 1) {
            this.customerShowPicker = false
          } else if (this.currentPopupIndex == 2) {
            this.occupationShowPicker = false
          } else if (this.currentPopupIndex == 3) {
            this.isScan = false
          }
        }
      },
      chooseOccupation() {
        this.$jump({
          flag: 'navigation',
          extra: {
            title: '投保人信息',
            hiddenRight: '1',
          },
        })
        this.occupationShowPicker = false
      },
      //弹框选择
      toSelect(pickerType, valueKey) {
        console.log(valueKey)
        //pickerType 1、国家地区 2、证件类型 3、文化程度 4、有无社保(弃用) 5、税收居民身份 6、婚姻状况 7、在职情况 8、收入来源 11、新市民类型
        ;[this.popupShow, this.pickerType] = [true, pickerType]
        if (valueKey) this.valueKey = valueKey

        switch (pickerType) {
          case '1':
            this.columns = DataDictionary.nativeplace
            break
          case '2':
            this.columns = DataDictionary.insuredIdType
            break
          case '4':
            this.columns = [
              { id: 0, text: '有' },
              { id: 1, text: '无' },
            ]
            break
          case '5':
            this.columns = DataDictionary.taxIdentity
            break
          case '8':
            this.columns = DataDictionary.salarySource
            break
          case '9':
            this.productCodes.length = 0
            // 已丢弃
            this.productCodes.push('GFRS_M0024')
            getCompany({ productCodes: this.productCodes }).then((res) => {
              if (res.result == 0) {
                this.columns = res.content
              } else {
                this.$toast(res.resultMessage)
              }
            })
            break
          case '10':
            this.columns = DataDictionary.marriage
            break
          case '11':
            this.columns = DataDictionary.npType
            break
          case 'GBCKS':
            this.columns = this.departmentList
            break
        }
      },
      //确认选择字段
      onConfirm(value) {
        this.popupShow = false
        if (this.pickerType == '1') {
          this.userInfo.nativeplace = value.id
        } else if (this.pickerType == '2') {
          //身份证以外的证件类型可以使用长期
          if (value.id != '1') {
            this.effectiveDateTypeAble = false
          } else {
            //若身份证件类型为身份证，自动带入年龄
            let age = utilsAge.getAge(this.userInfo.birthday, new Date())
            this.effectiveDateTypeAble = !(age > 45)
            // 身份证号码不存在时赋默认值
            if (!this.userInfo.idNo) {
              this.userInfo.idNo = ''
            }
            //若身份证件类型为身份证，自动带入性别
            let sexSign =
                    this.userInfo.idNo.length == 18 ? this.userInfo.idNo.substr(16, 1) : this.userInfo.idNo.length == 15 ? this.userInfo.idNo.substr(14, 1) : ''
            //18位身份证第17位是性别位, 奇男偶女;15位身份证第15位是性别位, 奇男偶女
            if (sexSign) {
              if (parseInt(sexSign) % 2 == 0) {
                this.userInfo.sex = '1'
              } else {
                this.userInfo.sex = '0'
              }
            }
          }
          this.userInfo.idType = value.id
        } /*else if (this.pickerType == '3') {
        this.userInfo.degree = value.id
      }*/ else if (this.pickerType == '4') {
          this.userInfo.socialSecurity = value.id
        } else if (this.pickerType == '5') {
          this.userInfo.taxResidentId = value.id
        } /*else if (this.pickerType == '6') {
        this.userInfo.marriage = value.id
      } else if (this.pickerType == '7') {
        this.userInfo.jobStatus = value.id
      } */ else if (
                this.pickerType == '8'
        ) {
          this.userInfo.salarySource = value.id
        } else if (this.pickerType == '9') {
          this.userInfo.workcompany = value
        } else if (this.pickerType === '10') {
          this.userInfo.marriageStatus = value.text
        } else if (this.pickerType === '11') {
          this.userInfo.npType = value.id
        } else if (this.pickerType === 'GBCKS') {
          this.projectDTO.departmentCode = value.id
          this.projectDTO.departmentName = value.text
        }
      },
      //证件起始截止日期
      onDateConfirm(val, type) {
        switch (type) {
          case '0':
          {
            //证件起始日期
            //如果录入日期早于出生日期或晚于当前日期
            if (Date.parse(val) > Date.parse(new Date()) || Date.parse(val) < Date.parse(this.userInfo.birthday)) {
              this.userInfo.certificateValidate = ''
              this.$refs.certificateValidate.date = ''
              return this.$toast('证件起始日期填写错误')
            }

            // 计算年龄
            if (this.userInfo.idType == '1') {
              let age = utilsAge.getAge(this.userInfo.birthday, new Date())
              // 长期按钮是否禁用
              this.effectiveDateTypeAble = age <= 45
              if(this.userInfo.birthday){
                this.userInfo.certiexpiredate = countCredentialValidity.getEndDate(this.userInfo.birthday,val)
                if(this.userInfo.certiexpiredate) {
                  this.effectiveDateTypeAble = true
                  this.userInfo.effectiveDateType = false
                }
              }
            }
          }
            break
          case '1':
          {
            this.userInfo.effectiveDateType = false
            //如果录入日期早于当前日期
            if (Date.parse(val) < Date.parse(new Date())) {
              this.userInfo.certiexpiredate = ''
              this.$refs.certiexpiredate.date = ''
              return this.$toast('亲，请您核实投保人身份证件有效期~')
            }
            //身份证证件类型的判断
            if (this.userInfo.idType == '1') {
              if(this.userInfo.birthday){
                this.userInfo.certificateValidate = countCredentialValidity.getStartDate(this.userInfo.birthday,val)
              }
            }
          }
            break
          case '2':
          {
            //出生日期
            //如果录入日期晚于当前日期
            if (Date.parse(val) > Date.parse(new Date())) {
              this.userInfo.birthday = ''
              this.$refs.birthday.date = ''
              return this.$toast('出生日期不晚于当日')
            }
            //长期判断
            let age = utilsAge.getAge(this.userInfo.birthday, new Date())
            if (this.userInfo.idType == '1') {
              this.effectiveDateTypeAble = !(age > 45)
            }
            //年龄18周岁，工作单位默认值为‘无’
            if (age < 18) {
              this.userInfo.workcompany = this.userInfo.workcompany || '无'
            }
            if (this.userInfo.certificateValidate && !this.userInfo.certiexpiredate) {
              this.userInfo.certiexpiredate = countCredentialValidity.getEndDate(this.userInfo.birthday,this.userInfo.certificateValidate)
            }
            if (this.userInfo.certiexpiredate && !this.userInfo.certificateValidate) {
              this.userInfo.certificateValidate = countCredentialValidity.getEndDate(this.userInfo.birthday,this.userInfo.certiexpiredate)
            }
          }
            break
        }
      },
      //选择客户
      chooseCustomer(data) {
        console.log('data :>> ', data)
        this.customerShowPicker = false
        this.$jump({
          flag: 'navigation',
          extra: {
            title: '投保人信息',
            hiddenRight: '1',
          },
        })
        let { customerName, customerSex } = data
        this.userInfo.name = customerName //用户名
        this.userInfo.sex = String(customerSex) //性别
        this.userInfo.nativeplace = data.country //国家地区
        this.userInfo.birthday = data.birthday //出生日期
        this.userInfo.idType = data.customerIdType //证件类型
        this.userInfo.idNo = data.customerIdNumber //证件类别
        this.userInfo.certificateValidate = data.idEffectStartDate //证件起始日期
        if (data.idEffectEndDate == '9999-12-31') {
          this.userInfo.effectiveDateType = true //是否长期
        } else {
          this.userInfo.certiexpiredate = data.idEffectEndDate //证件截止日期
        }
        this.userInfo.occupationCode = data.occupationCode //职业类别编码
        this.userInfo.occupationName = data.occupationName //职业类别名称
        this.userInfo.salarySource = data.salarySource //收入来源
        this.userInfo.otherSalarySource = data.otherSalarySource // 其他收入来源
        this.userInfo.lifeGrade = data.lifeGrade //寿险等级
        this.userInfo.healthGrade = data.healthGrade //健康等级
        this.userInfo.mobile = data.customerPhone //移动电话
        this.userInfo.stature = data.height //身高
        this.userInfo.avoirdupois = data.weight //体重
        // this.userInfo.degree = data.educationLevel //教育水平
        this.userInfo.medical = data.socialSecurity //有无社保
        this.userInfo.taxResidentId = data.residentStatus //税收居民身份
        this.userInfo.averageAnnualIncome = data.averageYearlyIncome //平均年收入
        this.userInfo.workcompany = this.specilFlag == '1' ? '' : data.workUnits //工作单位
        // this.userInfo.jobStatus = data.jobStatus //工作情况
        this.setCustomerMarriage(data.marryStatus)
        // this.userInfo.familyAnnualIncome = data.familyAnnualIncome //家庭年收入
        this.userInfo.email = data.email //电子邮箱
        this.userInfo.liabilitiesMoney = data.liabilitiesMoney //负债金额
        // this.userInfo.companyProvince = data.companyProvince //单位省
        // this.userInfo.companyCity = data.companyCity //单位市
        // this.userInfo.companyArea = data.companyArea //单位区
        // this.userInfo.companyAddress = data.companyAddress //单位详细地址
        // this.userInfo.companyZip = data.companyZip //单位邮编
        // this.userInfo.companyPhone = data.companyPhone //单位电话
        this.userInfo.homeProvince = data.homeProvince //家庭省
        this.userInfo.homeCity = data.homeCity //家庭市
        this.userInfo.homeArea = data.homeArea //家庭区
        this.userInfo.homeAddress = data.homeAddress //家庭详细地址
        this.userInfo.isNewPeopleFlag = data.isNewPeopleFlag //新市民身份
        this.userInfo.npType = data.npType //新市民类型
        if (data.homeProvince.length) {
          this.homeName = getAreaName([{ code: data.homeProvince }, { code: data.homeCity }, { code: data.homeArea }]) //联系地址
        }
        // 计算年龄
        let age = utilsAge.getAge(this.userInfo.birthday, new Date())
        // 长期按钮是否禁用
        this.effectiveDateTypeAble = age <= 45

        this.getRelatedData(this.userInfo.idNo, '1')
      },
      async nextStep() {
        //表单校验, 成功跳转
        let valid = await this.$validator.validate()
        if (true === valid) {
          localStorage.chooseProductCodesNew = localStorage.chooseProductCodes
          // 计算年龄
          let age = utilsAge.getAge(this.userInfo.birthday, new Date())
          // 如果是未成年人
          // if (age < 18) {
          //   return this.$toast('投保人必须是具有民事行为能力且有固定职业和收入的自然人，请确定')
          // }

          //如果证件类型是身份证
          if (this.userInfo.idType == '1') {
            if (this.userInfo.nativeplace != '1') {
              return this.$toast('证件类型”为“身份证，国籍必须为中国哦')
            }
            if (this.userInfo.idNo.length == '18') {
              //18位身份证第17位是性别位, 奇男偶女
              let sexSign = this.userInfo.idNo.substr(16, 1)
              if ((parseInt(sexSign) % 2 == 0 && this.userInfo.sex != 1) || (parseInt(sexSign) % 2 != 0 && this.userInfo.sex != 0)) {
                return this.$toast('性别录入与身份证不符')
              }

              //18位身份证第7-14位是生日位, 年月日
              let birthSign = this.userInfo.idNo.substr(6, 8)
              if (
                      this.userInfo.birthday.substr(0, 4) != birthSign.substr(0, 4) ||
                      this.userInfo.birthday.substr(5, 2) != birthSign.substr(4, 2) ||
                      this.userInfo.birthday.substr(8, 2) != birthSign.substr(6, 2)
              ) {
                return this.$toast('生日录入与身份证不符')
              }
            }

            // 证件号码规则校验
            if (!idNoCheck.isIdno(this.userInfo.idNo)) {
              return this.$toast('您填写的证件号码有误')
            }

            //年龄在小于周岁（不含46周岁），证件有效期不能为长期
            if (age < 46 && this.userInfo.effectiveDateType == true) {
              return this.$toast('证件有效期错误，年龄小于46周岁，证件有效期不能为长期')
            }

            //身份证证件类型的判断
            //证件止期
            let val = this.userInfo.certiexpiredate
            if (Date.parse(val) < Date.parse(new Date())) {
              this.userInfo.certiexpiredate = ''
              this.$refs.certiexpiredate.date = ''
              return this.$toast('您的证件已过期')
            }
            //年龄在16周岁以下
            if (age < 16) {
              if (new Date(val).getFullYear() - new Date(this.userInfo.certificateValidate).getFullYear() != 5) {
                return this.$toast('16周岁以下的证件有效期为5年')
              }
              //年龄在16-21周岁之间
            }else if (age >= 16 && age <= 21) {
              if (new Date(val).getFullYear() - new Date(this.userInfo.certificateValidate).getFullYear() != 10 && new Date(val).getFullYear() - new Date(this.userInfo.certificateValidate).getFullYear() != 5) {
                return this.$toast('16周岁~21周岁的证件有效期为10年或5年')
              }
              //年龄在22-25周岁之间
            }else if (age >= 22 && age <= 25) {
              if (new Date(val).getFullYear() - new Date(this.userInfo.certificateValidate).getFullYear() != 10) {
                return this.$toast('22周岁~25周岁的证件有效期为10年')
              }
              //年龄在26-35周岁之间
            }else if (age >= 26 && age <= 35) {
              if (new Date(val).getFullYear() - new Date(this.userInfo.certificateValidate).getFullYear() != 20 && new Date(val).getFullYear() - new Date(this.userInfo.certificateValidate).getFullYear() != 10) {
                return this.$toast('26周岁~35周岁的证件有效期为20年或10年')
              }
              //年龄在36-45周岁之间
            } else if (age >= 36 && age <= 45) {
              if (new Date(val).getFullYear() - new Date(this.userInfo.certificateValidate).getFullYear() != 20) {
                return this.$toast('36周岁~45周岁的证件有效期为20年')
              }
              //年龄在46-65周岁之间
            } else if (age >= 46 && age <= 65) {
              if (new Date(val).getFullYear() - new Date(this.userInfo.certificateValidate).getFullYear() != 20 && this.userInfo.effectiveDateType == false) {
                return this.$toast('46周岁~65周岁的证件有效期为20年或长期')
              }
              //年龄在65周岁以上
            } else if (age > 65) {
              if (this.userInfo.effectiveDateType == false) {
                return this.$toast('65周岁以上的证件有效期为长期')
              }
            }
            //证件类型是户口本
          } else if (this.userInfo.idType == '2') {
            if (age > 16) {
              return this.$toast('客户年龄在16周岁以上，不能使用户口本作为有效证件')
            }
          } else if (this.userInfo.idType == '3') {
            if (age >= 2) {
              return this.$toast('客户年龄在2周岁及以上，不能使用出生证作为有效证件')
            }
          } else if (this.userInfo.idType == '4') {
            if (this.userInfo.nativeplace == '1') {
              return this.$toast('“证件类型”为“外国人护照”，“国籍”不能选择为“中国”哦~')
            }
          } else if (this.userInfo.idType == '5') {
            console.log(this.userInfo.nativeplace, 'nativeplace')
            if (this.userInfo.nativeplace != 2 && this.userInfo.nativeplace != 3) {
              return this.$toast('“证件类型”为“港澳居民来往内地通行证”，“国籍”请选择“中国香港”或“中国澳门”哦~')
            }
          } else if (this.userInfo.idType == '6') {
            if (this.userInfo.nativeplace != 4) {
              return this.$toast('“证件类型”为“台湾居民来往大陆通行证”，“国籍”请选择“中国台湾”~')
            }
          } else if (this.userInfo.idType == '9') {
            if (this.userInfo.nativeplace != 2 && this.userInfo.nativeplace != 3 && this.userInfo.nativeplace != 4) {
              return this.$toast('“证件类型”为“港澳台居民居住证”，“国籍”请选择“中国香港”、“中国澳门”或“中国台湾”~')
            }
          }
          // 投保人年龄必须大于等于16周岁哦
          if (age < 16) {
            return this.$toast('亲，投保人年龄必须大于等于16周岁哦~')
          }

          //职业类型不能为 '一般学生'
          if (this.userInfo.occupationCode == '2099907') {
            this.userInfo.occupationName = ''
            return this.$toast('学生不可以作为投保人，请更换投保人投保')
          }
          if (!this.userInfo.workcompany) {
            this.userInfo.workcompany = '无'
          }

          if (this.userInfo.salarySource == '4') {
            if (!this.userInfo.otherSalarySource) {
              return this.$toast('请输入其它收入来源')
            }
          }

          // 婚姻状况处理: 使用computed/watch可能会出现检测不到的情况
          for (let status of DataDictionary.marriage) {
            if (status.text === this.userInfo.marriageStatus) {
              this.userInfo.marriage = status.id
            }
          }

          // 通过国籍判断 证件是否符合要求
          // 如果是国籍选择中国大陆

          if (Number(this.userInfo.nativeplace) <= 4) {
            // “身份证”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证”
            let obj = {
              1: true,
              5: true,
              6: true,
              9: true
            }
            let idType = this.userInfo.idType
            // 通过年龄 判断证件是否符合要求
            // 小于2岁
            if (age < 2) {
              // “出生证”,"户口本"
              obj['2'] = true
              obj['3'] = true
              if (obj[idType] === undefined) {
                return this.$toast(
                        '亲，国籍为中国，且未满2周岁儿童，证件类型必须“身份证”或“户口本”或“出生证”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证”'
                )
              }
            } else if (age < 16) {
              // 小于16岁
              // “户口本”
              obj['2'] = true
              if (obj[idType] === undefined) {
                return this.$toast(
                        '亲，国籍为中国，且大于2周岁小于16周岁的未成年人，证件类型必须为“身份证”或“户口本”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证”'
                )
              }
            } else {
              // 大于16岁
              if (obj[idType] === undefined) {
                return this.$toast('亲，国籍为中国，证件类型必须为“身份证”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证”')
              }
            }
          } else {
            // 非大陆人员按外籍人员
            let obj = {
              4: true,
              8: true
            }
            let idType = this.userInfo.idType
            if (obj[idType] === undefined) {
              return this.$toast('亲，国籍为外籍，证件类型必须为护照或外国人永久居留身份证投保')
            }
          }
          if (this.userInfo.isAsync == 1) {
            if (
                    !this.userWorkcompanys.some((item) => {
                      return item.asscompanies == this.userInfo.workcompany
                    })
            ) {
              if (
                      this.userWorkcompanys.some((item) => {
                        return item.asscompanies.search(this.userInfo.workcompany) != -1
                      })
              ) {
                return this.$toast('请填写完整的协同单位名称')
              }
              return this.$toast('您选择的为非协同单位，请重新选择。')
            }
          }
          this.infoUpdate()
        } else {
          return this.$toast(this.$validator.errors.all()[0])
        }
      },
      //信息变更
      infoUpdate() {
        //local 里面是否存有险种信息
        let chooseProductCodes = localStorage.chooseProductCodes && JSON.parse(localStorage.chooseProductCodes)
        // if (chooseProductCodes && chooseProductCodes.length) {
        if (this.$CacheUtils.getLocItem('saleInsuredInfo')) {
          console.log('haha')
          //获取险种列表
          //取出local中的投保人信息
          let saleInsuredInfo = JSON.parse(this.$CacheUtils.getLocItem('saleInsuredInfo'))
          //如果 姓名， 性别, 出生日期, 有无社保, 职业 ，婚姻情况，发生变化
          if (this.userInfo.sex != saleInsuredInfo.sex || this.userInfo.birthday != saleInsuredInfo.birthday) {
            //提示用户
            if (chooseProductCodes && chooseProductCodes.length)
              return this.$dialog
                .confirm({
                  className: 'dialog-delete',
                  title: '提示',
                  message: '当前信息已经发生改变，有可能影响险种费率，是否确认修改并清除险种信息?',
                  cancelButtonColor: '#E9332E',
                  confirmButtonColor: '#FFFFFF',
                })
                .then(() => {
                  this.save()
                })
                .catch(() => {
                  return
                })
          }
        }
        this.save()
      },

      async save() {
        let params = {
          appntDTO: this.userInfo,
          riskDTO:{
            riskName: this.userInfo.riskName,
            riskCode: this.userInfo.riskProductCode
          },
          ebizOrderGbcRelDTO:{
            departmentCode: this.projectDTO.departmentCode,
            departmentName: this.projectDTO.departmentName,
          },
        }
        this.thismystr = ''
        // if(this.branchType == '13'){
        //   params.orderDTO.ebizOrderGbcRelDTO = {
        //     projectCode: this.projectDTO.projectCode,
        //     departmentCode: this.projectDTO.departmentCode,
        //     teamCode:this.projectDTO.teamCode,
        //   }
        // }
        // console.log('params :>> ', params)
        //------------------------专为桂企写死--begin---------------//
        if (this.specilFlag == '1') {
          params.orderDTO.orderInfoDTO.productCode = 'GFRS_M0040'
          this.thismystr = 'specilFlag=1&'
          //params.orderDTO.orderInfoDTO.productCode = 'GFRS_M0024'
        }
        // ------------------------专为桂企写死--end---------------//
        let resultData = await saveOrUpdateGbc(params)
        if (resultData.result == 0) {
          this.$jump({
            flag: 'h5',
            extra: {
              url: location.origin + `/#/GBC/submitResult`,
            },
            routerInfo: {
              path: `/GBC/submitResult`,
            },
          })
        } else {
          this.$toast(resultData.resultMessage)
        }
      },
      thisdoubledialogfunc(){
        this.thisdoubledialogshow = false
        this.$jump({
          flag: 'h5',
          extra: {
            url: location.origin + `/#/GBC/submitResult`,
          },
          routerInfo: {
            path: `/GBC/submitResult`,
          },
        })
      },
      //区域选择
      sureArea(area, type) {
        console.log('area :>> ', area)
        switch (type) {
          case '2': //联系地址
            this.homeName = `${area[0].name}-${area[1].name}-${area[2].name}`
            ;[this.userInfo.homeProvince, this.userInfo.homeCity, this.userInfo.homeArea] = [area[0].code, area[1].code, area[2].code]
            this.homeShow = false
            break
        }
      },

      //长期状态改变时
      effectiveDataTypeChange(val) {
        //勾选长期状态时,证件截止日期置空
        if (val) {
          this.userInfo.certiexpiredate = ''
          this.certiexpiredateRequired = false
        } else {
          this.certiexpiredateRequired = true
        }
      },
      //获取身份证扫描信息
      getIdentityInfo(data) {
        getIdentityInfo(this, data, '1')
      },
      //校验身高
      checkStature(val) {
        if (val.trim().length == 0) {
          return this.$toast('身高不能为空')
        }

        let res = /^[0-9]{0,3}([.]{1}[0-9]{1})?$/.test(val) && val < 300 && val > 10
        if (!res) {
          this.userInfo.stature = ''
          return this.$toast('身高输入有误')
        }
      },
      //校验体重
      checkAvoirdupois(val) {
        if (val.trim().length == 0) {
          return this.$toast('体重不能为空')
        }

        let res = /^[0-9]+([.]{1}[0-9]{1})?$/.test(val) && val > 0.1
        if (!res) {
          this.userInfo.avoirdupois = ''
          return this.$toast('体重输入有误')
        }
      },
      getRelatedData(val, source) {
        if (this.userInfo.idType != '1') {
          return
        }
        //如果证件校验不通过,恢复默认值
        if (idToData(val).text) {
          ;[this.userInfo.idNo, this.userInfo.sex, this.userInfo.birthday, this.effectiveDateTypeAble] = ['', '0', '', false]
          return this.$toast(idToData(val).text)
        }

        this.userInfo.effectiveDateType = false
        this.effectiveDateTypeAble = idToData(val).age <= 45
        this.userInfo.birthday = idToData(val).birthday
        this.userInfo.sex = idToData(val).sex
        //年龄小于18周岁，工作单位默认值为‘无’
        if (idToData(val).age < 18) {
          this.userInfo.workcompany = this.userInfo.workcompany || '无'
        }
        if (idToData(val).age > 45) {
          if (source) {
            this.userInfo.effectiveDateType = true
          }
          this.effectiveDateTypeAble = false
        } else {
          // this.userInfo.effectiveDateType = false
        }
      },
    },

    computed: {
      isShowOthenSalarySource() {
        return this.userInfo.salarySource == '4'
      },
    },
    watch: {
      isShowOthenSalarySource(nVal) {
        if (!nVal) {
          this.userInfo.otherSalarySource = ''
        }
      },
      'userInfo.marriageStatus'(nv) {
        for (let status of DataDictionary.marriage) {
          if (status.text === nv) {
            this.userInfo.marriage = status.id
          }
        }
      }
    }
  }
</script>
<style lang="scss" scoped>
  .insured-info-container {
    /deep/.van-checkbox {
      margin-left: auto;
    }
    /deep/.van-radio {
      margin-left: auto;
    }
    .isNewPeopleFlagTipClass{
      margin-top: 45px;line-height: 24px;text-indent: 2em;letter-spacing: 1px;padding: 2px 10px;
    }
  }
</style>
