<template>
  <view>
    <view class="house_head_card">
      <view class="card_title"> 您已选择房屋： </view>
      <view class="house_name"> {{ useModel?.formData?.value?.full_name }} </view>
      <view class="card_title"> 请选择您的身份： </view>
      <view>
        <hs-radio :Enums="HouseOccupantsResidentialRelationEnum"
          v-model:valueModel="useModel.formData.value.residential_relation" />
      </view>
    </view>

    <view class="house_card">
      <view class="card_title"> 常见问题 </view>
      <view class="card_content">
        <view v-for="(i, index) in useModel?.collapse_list?.value" :key="`collapse_${index}`" class="collapse_list">
          <view class="title" @click="i.isShow = !i.isShow">
            {{ i?.label }}
            <view class="collapse_list_icon">
              {{ i?.isShow ? '收起' : '展开' }}
              <uni-icons :type="i?.isShow ? 'down' : 'right'" size="13" color="#999"></uni-icons>
            </view>
          </view>
          <view class="collapse_find_content" v-if="i?.isShow">
            <view v-for="(k, idx) in i?.children" :key="`collapse_${index}_${idx}`" class="collapse_find_item">
              {{ k?.label }}
              <view v-if="k?.btnName" @click="method?.handleFindLinkClick(k)">
                <text>{{ k?.btnName }}</text>
                <uni-icons type="right" size="13" color="#0082FA"></uni-icons>
              </view>
            </view>
          </view>
        </view>
      </view>
    </view>

    <hs-footer btnParimaryName="绑定新房屋" @handleParmaryClick="method.handleBindHouse" />
  </view>
</template>

<script setup lang="ts">
import { useWeAppAuthStore } from '@/common'
import { HouseOccupantsResidentialRelationEnum } from '@/gen/Enums'
import { onLoad } from '@dcloudio/uni-app'
import { getCurrentInstance } from 'vue'
import method from './method'
import useModel from './model'
const auth = useWeAppAuthStore()
onLoad(async e => {
  await getCurrentInstance()?.appContext.config.globalProperties.$onLaunched
  useModel.formData.value = e
  console.log(e, 'eee')
  if (auth?.data?.environment === 'wxwork') {
    uni.qy.getCurExternalContact({
      success: function (res: any) {
        useModel.formData.value = {
          external_userid: res?.userId,
          ...e
        }
        console.log('开始2', res)
      },
      fail: function (res: any) {
        useModel.formData.value = e
        console.log('失败', res)
      }
    })
  }
})
</script>

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