<template>
  <view class="bangding_form_data">
    <view class="form_card">
      <!-- <hs-cell title="选择房屋" required borderTop :isLink="true" :value="useModel?.formData?.value?.full_name"
        isPlaceholder="请选择房屋" @click="method?.handleToSelectHouse" /> -->

      <hs-popup-project-houer title="选择房屋" @change="method?.handleSelectProject"
        :defaultValueName="useModel?.formData?.value?.full_name" />




      <hs-radio-cell-picker :Enums="HouseRegistersTypeEnum" title="类型" borderTop
        v-model:valueModel="useModel.formData.value.type" required />
      <hs-radio-cell-picker :Enums="HouseOccupantsResidentialRelationEnum" title="居住关系" borderTop
        v-if="useModel.formData.value.type === 'AddOccupant'"
        v-model:valueModel="useModel.formData.value.residential_relation" required />
    </view>

    <view class="form_card">
      <view class="form_card_title"> <text></text> 个人信息 </view>
      <hs-cell title="真实姓名" required borderTop>
        <hs-input v-model:valueModel="useModel.formData.value.name" textAlign="right" />
      </hs-cell>
      <hs-cell title="手机号" required borderTop>
        <hs-input v-model:valueModel="useModel.formData.value.phone" maxLength="11" textAlign="right" type="number" />
      </hs-cell>
      <hs-cell title="身份证号" required borderTop>
        <hs-input v-model:valueModel="useModel.formData.value.id_card" maxLength="18" textAlign="right" />
      </hs-cell>
    </view>

    <view class="form_card">
      <hs-upload-id-card required v-model:valueFrontModel="useModel.formData.value.card_front_image"
        v-model:valueBackModel="useModel.formData.value.card_back_image" />

      <hs-upload title="上传房产证" :count="10" :size="4" required v-if="useModel.formData.value.type === 'AddOwner'"
        borderTop v-model:valueModel="useModel.formData.value.ownership_info" />
    </view>
    <hs-footer btnParimaryName="绑定房屋" :loading="useModel?.loading?.value" @handleParmaryClick="method?.handleSubmit" />
  </view>
</template>

<script setup lang="ts">
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app'
import method from './method'
import useModel from './model'
const HouseRegistersTypeEnum = {
  AddOccupant: { text: '添加住户', value: 'AddOccupant' },
  AddOwner: { text: '添加产权人', value: 'AddOwner' }
}
const HouseOccupantsResidentialRelationEnum = {
  Tenant: { text: '租客', color: '#fa8c16', value: 'Tenant' },
  Resident: { text: '住户', color: '#2db7f5', value: 'Resident' },
  PrimaryTenant: { text: '主租人', color: '#87d068', value: 'PrimaryTenant' }
}

onLoad((e: any) => {
  useModel.formData.value.asset_houses_id = e?.asset_houses_id
  console.log(e, '222')
  // uni.qy.getCurExternalContact({
  //   success: function (res: any) {
  //     useModel.formData.value.external_userid = res?.userId
  //   },
  //   fail: function (res: any) {}
  // })
})

onShow(() => {
  method?.init()
})

onUnload(() => {
  useModel.formData.value = { type: 'AddOwner', card_type: 'MainlandID', house_relation: 'Owner' }
})
</script>

<style lang="scss">
@import './style.scss';
</style>
