<template>
  <view class="customer_page">
    <view class="customer_card">
      <view class="card_user_header">
        <view class="avatar"> <up-avatar size="50px" /></view>
        <view class="user_info">
          <view class="name"> {{ useModel?.showData?.value?.name || '请补充姓名' }} </view>
          <!-- <view class="phone"> 手机号码信息缺失 </view> -->
        </view>
        <!-- <view
          class="edit_btn"
          @click="
            toPage(
              `/CUSTOMER/update/index?name=${useModel?.showData?.value?.name}&phone=${useModel?.showData?.value?.phone}`
            )
          "
        >
          编辑
        </view> -->
      </view>
      <view>
        <hs-cell
          title="手机号"
          placeholder="手机号码信息缺失"
          :value="useModel?.showData?.value?.phone"
        />
      </view>
    </view>

    <view class="customer_card">
      <view class="customer_item_head">
        资产信息
        <text
          @click="
            toPage(
              `/CUSTOMER/assets/index?name=${useModel?.showData?.value?.name}&phone=${useModel?.showData?.value?.phone}`
            )
          "
        >
          编辑
        </text>
      </view>
      <view class="customer_item_body">
        <view
          class="item"
          v-for="(i, index) in useModel?.userHouse?.value"
          :key="`items_${index}`"
          @click="toPage(`/BILL/outstanding_fee/show/index?id=${i?.asset_houses_id}`)"
        >
          <view class="item_name_relation">
            {{ i?.asset_project?.name }}{{ i?.asset_building?.name }}{{ i?.asset_unit?.name
            }}{{ i?.asset_house?.name }}
            <view class="status_tab" v-if="i?.house_relation === 'Owner'"> (产权人) </view>
            <view class="status_tab" v-else>
              (<hs-enum-tag
                :Enums="HouseOccupantsResidentialRelationEnum"
                :value="i?.residential_relation"
              />)
            </view>
          </view>

          <!-- <view class="status_tab" v-if="i?.is_contact">(常用联系人)</view> -->

          <uni-icons type="right" size="13" color="#999"></uni-icons>
        </view>
      </view>
    </view>

    <view class="customer_card customer_item">
      <view class="customer_item_head"> 房屋账单 </view>
      <view class="customer_item_body">
        <hs-empty
          :baseStyle="{ height: '200rpx', padding: '30rpx 0' }"
          v-if="!useModel?.arrearageHouses?.value?.length"
        />
        <view
          class="item_houses"
          v-for="(i, index) in useModel?.arrearageHouses?.value"
          :key="`items_${index}`"
        >
          <view class="name">
            {{ i?.full_name }}
          </view>
          <view class="fee"> 欠费：¥{{ i?.total_overdue_amount }} </view>
          <view class="item_footer">
            <view
              class="btn"
              @click="
                toPage(
                  `/CUSTOMER/list_bill/index?asset_houses_id=${i?.asset_houses_id}&name=${i?.full_name}`
                )
              "
            >
              查看详情
            </view>
            <view class="btn" @click="method?.shareBill()"> 分享账单 </view>
          </view>
        </view>
      </view>
    </view>

    <hs-footer btnParimaryName="拨打电话" @handleParmaryClick="method?.handleMakePhoneCall()" />
  </view>
</template>
<script setup lang="ts">
import { onLoad } from '@dcloudio/uni-app'
import { getCurrentInstance } from 'vue'
import method from './method'
import useModel from './model'
import { HouseOccupantsHouseRelationEnum, HouseOccupantsResidentialRelationEnum } from '@/gen/Enums'
const toPage = (url: string) => {
  uni.navigateTo({
    url: url
  })
}

onLoad(async e => {
  await getCurrentInstance()?.appContext.config.globalProperties.$onLaunched
  method?.getShow(e?.id)
  // uni.qy.getCurExternalContact({
  //   success: function (res) {
  //     console.log('开始2', res)
  //   }
  // })
})
</script>
<style lang="scss">
@import './style.scss';
</style>
