import { getApiLoading } from '@/common/libraries/apiLoading'
import { showToast } from '@/common/libraries/naviHelper'
import { sendChatMessage } from '@/common/libraries/sendWxWork'
import { Apis } from '@/gen/Apis'
import useModel from './model'
export default {
  handleBindHouse() {
    let data = useModel?.formData?.value
    if (!data?.residential_relation) {
      return showToast('请选择身份！')
    }
    let house_info = [
      {
        asset_houses_id: data?.asset_houses_id,
        residential_relation: data?.residential_relation
      }
    ]
    getApiLoading(Apis.Archive.HouseRegisters.Store, { ...data, house_info: house_info }).then(
      res => {
        uni.reLaunch({
          url: `/CUSTOMER/house_Identity/success?asset_houses_id=${data?.asset_houses_id}&name=${data?.name}&phone=${data?.phone}}`
        })
        console.log(res)
      }
    )
  },
  handleFindLinkClick(e: { url?: string; type?: string }) {
    if (e?.type === 'link') {
      uni.navigateTo({
        url: `${e?.url}?asset_houses_id=${useModel.formData.value?.asset_houses_id}&name=${useModel.formData.value?.name}&phone=${useModel.formData.value?.phone}`
      })
    }
    if (e?.type === 'invitation') {
      //默认发送小程序信息
      sendChatMessage({ page: '/INDEX/binding/index.html', title: '邀请你绑定房屋' })
    }
    console.log(e, 'eee')
  }
}
