import { Apis } from '@/gen/Apis'
import { getApiLoading } from '@/common/libraries/apiLoading'
import useModel from './model'
const getUserHoueInfo = (phone?: string) => {
  getApiLoading(Apis.Archive.HouseOccupants.GetCustomerHouse, { phone }).then(res => {
    useModel.userHouse.value = res?.data
    console.log(res)
  })
}
export default {
  getUserHoueInfo,
  handleUnbind(e: any) {
    uni.showModal({
      title: '再次确认',
      content: '房屋人员解绑申请！此操作需后台审核，结果会以系统通知告知，敬请留意～',
      success: function (res) {
        if (res.confirm) {
          getApiLoading(Apis.Archive.HouseRegisters.RemoveOwner, {
            house_occupants_id: e?.id
          }).then(res => {
            getUserHoueInfo(useModel?.formData?.value?.phone)
            console.log(res)
          })
          console.log('用户点击确定')
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  },
  handleBindHouse() {
    uni.navigateTo({
      url: `/CUSTOMER/bind_house/index?phone=${useModel?.formData?.value?.phone}&name=${useModel?.formData?.value?.name}`
    })
  }
}
