<template>
  <view>
    <view class="customer_item_unbind" @click="popupShow = true"> 解绑 </view>
    <hs-popup-custom :show="popupShow" mode="center" title="再次确认" @close="popupShow = false">
      <view>
        <view class="popup_contents">
          是否解除{{ props?.data?.asset_house?.full_name }}的绑定？
        </view>
        <view class="popup_footer">
          <hs-button label="确认解绑" @click="handleUnBind" type="primary" size="md"></hs-button>
          <hs-button label="点错了，返回" @click="popupShow = false" size="md"></hs-button>
        </view>
      </view>
    </hs-popup-custom>
  </view>
</template>

<style lang="scss" scoped>
.customer_item_unbind {
  color: #0082fa;
  font-size: 24rpx;
}
.popup_contents {
  text-align: center;
  padding: 0 30rpx 50rpx 30rpx;
}
.popup_footer {
  padding: 0 50rpx;
}
</style>

<script setup lang="ts">
import { ref } from 'vue'
import { Apis } from '@/gen/Apis'
import { getApiLoading } from '@/common/libraries/apiLoading'
const props = defineProps(['data'])
const emit = defineEmits(['success'])
const popupShow = ref(false)
import { showToast } from '@/common/libraries/naviHelper'
const handleUnBind = () => {
  getApiLoading(Apis.Archive.HouseRegisters.Unbind, {
    external_userid: props?.data?.external_userid,
    asset_houses_id: props?.data?.asset_houses_id
  }).then(res => {
    showToast('解除成功！')
    emit('success')
    console.log(res)
  })
}
</script>
