2025-08-29 09:51:02 +08:00
|
|
|
import { ref } from 'vue'
|
|
|
|
|
import useModel from './model'
|
|
|
|
|
import { getApiLoading } from '@/common/libraries/apiLoading'
|
|
|
|
|
import { Apis } from '@/gen/Apis'
|
2025-12-15 18:19:04 +08:00
|
|
|
import { useWeAppAuthStore } from '@/common'
|
2025-08-29 09:51:02 +08:00
|
|
|
import { showToastBack, showToast } from '@/common/libraries/naviHelper'
|
2025-12-15 18:19:04 +08:00
|
|
|
import userLoginStatus from '@/common/libraries/userUserLogin'
|
2025-08-29 09:51:02 +08:00
|
|
|
|
2025-12-15 18:19:04 +08:00
|
|
|
const auth = useWeAppAuthStore()
|
2025-08-29 09:51:02 +08:00
|
|
|
const handleSubmitStore = () => {
|
|
|
|
|
getApiLoading(Apis.Archive.HouseRegisters.Store, {
|
|
|
|
|
...useModel.formData.value,
|
|
|
|
|
is_live_in: useModel?.formData?.value?.is_live_in ? 1 : 0,
|
|
|
|
|
customer_info: [useModel.formData.value]
|
|
|
|
|
}).then(res => {
|
2025-12-15 18:19:04 +08:00
|
|
|
useModel.loading.value = false
|
2025-08-29 09:51:02 +08:00
|
|
|
useModel.show.value = false
|
2025-12-15 18:19:04 +08:00
|
|
|
uni.redirectTo({ url: '/INDEX/binding/success' })
|
|
|
|
|
auth?.getIsHouseExist()
|
|
|
|
|
// showToastBack('提交成功,等待审核!', 1, true)
|
2025-08-29 09:51:02 +08:00
|
|
|
console.log(res)
|
2026-01-30 09:54:26 +08:00
|
|
|
}).catch(e =>{
|
|
|
|
|
useModel.loading.value = false
|
|
|
|
|
useModel.show.value = false
|
2025-08-29 09:51:02 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-15 16:18:34 +08:00
|
|
|
export default {
|
2025-08-29 09:51:02 +08:00
|
|
|
handleSubmitStore,
|
|
|
|
|
handleSelectProject: (e: any) => {
|
|
|
|
|
if (e[3]) {
|
|
|
|
|
useModel.formData.value.asset_houses_id = e[3]?.id
|
|
|
|
|
} else {
|
|
|
|
|
useModel.formData.value.asset_houses_id = ''
|
|
|
|
|
}
|
|
|
|
|
console.log(e, 'e')
|
|
|
|
|
},
|
2025-12-15 18:19:04 +08:00
|
|
|
init(e: any) {
|
|
|
|
|
useModel.defaultHouseValueName.value = e?.houseName || ''
|
2025-08-29 09:51:02 +08:00
|
|
|
useModel.formData.value = {
|
2025-12-15 18:19:04 +08:00
|
|
|
asset_houses_id: e?.id || '',
|
2025-08-29 09:51:02 +08:00
|
|
|
type: '',
|
|
|
|
|
customer_info: [],
|
|
|
|
|
name: '',
|
2025-12-15 18:19:04 +08:00
|
|
|
phone: auth?.data?.user?.phone || '',
|
2025-08-29 09:51:02 +08:00
|
|
|
card_front_image: [],
|
|
|
|
|
card_back_image: [],
|
|
|
|
|
house_relation: '',
|
|
|
|
|
card_type: 'MainlandID',
|
|
|
|
|
relation_with_owner: '',
|
|
|
|
|
ownership_info: [],
|
|
|
|
|
id_card: '',
|
|
|
|
|
move_in_date: '',
|
|
|
|
|
is_live_in: true
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handleIsLiveIn(e: any) {
|
|
|
|
|
useModel.formData.value.is_live_in = e?.detail?.value
|
|
|
|
|
console.log(e, 'e')
|
|
|
|
|
},
|
|
|
|
|
handleSubmit: (e: any) => {
|
2025-12-15 18:19:04 +08:00
|
|
|
if (!userLoginStatus?.onBindPhone()) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2025-08-29 09:51:02 +08:00
|
|
|
if (!useModel.formData.value.asset_houses_id) {
|
|
|
|
|
return showToast('请先选择房屋!')
|
|
|
|
|
}
|
|
|
|
|
if (!useModel.formData.value.type) {
|
|
|
|
|
return showToast('请先选择身份!')
|
|
|
|
|
}
|
|
|
|
|
if (!useModel.formData.value.name || !useModel.formData.value.phone) {
|
|
|
|
|
return showToast('请设置姓名和手机号!')
|
|
|
|
|
}
|
2026-01-30 09:54:26 +08:00
|
|
|
if (!useModel.formData.value.id_card) {
|
|
|
|
|
return showToast('请设置身份证号!')
|
|
|
|
|
}
|
2025-08-29 09:51:02 +08:00
|
|
|
if (
|
|
|
|
|
!useModel.formData.value.card_front_image?.length ||
|
|
|
|
|
!useModel.formData.value.card_back_image?.length
|
|
|
|
|
) {
|
|
|
|
|
return showToast('请先上传身份证正反面!')
|
|
|
|
|
}
|
|
|
|
|
if (
|
|
|
|
|
useModel.formData.value.type === 'AddOwner' &&
|
|
|
|
|
!useModel.formData.value?.ownership_info?.length
|
|
|
|
|
) {
|
|
|
|
|
return showToast('请先上传房产证!')
|
|
|
|
|
}
|
|
|
|
|
if (useModel.formData.value.type === 'AddOwner' && useModel?.ownerList?.value?.length) {
|
|
|
|
|
useModel.show.value = true
|
|
|
|
|
return
|
|
|
|
|
}
|
2025-12-15 18:19:04 +08:00
|
|
|
useModel.loading.value = true
|
2025-08-29 09:51:02 +08:00
|
|
|
console.log(useModel?.formData.value, 'formData')
|
2025-12-15 18:19:04 +08:00
|
|
|
uni.requestSubscribeMessage({
|
|
|
|
|
tmplIds: ['0nIVHQNvIco7zeTWv-W3_MbZFR9ibIXejLxh2OFo5mg'],
|
|
|
|
|
success(res) {
|
|
|
|
|
console.log(res)
|
|
|
|
|
handleSubmitStore()
|
|
|
|
|
},
|
|
|
|
|
fail(res: any) {
|
|
|
|
|
handleSubmitStore()
|
|
|
|
|
console.log(res, 'res定远失败')
|
|
|
|
|
}
|
|
|
|
|
})
|
2025-08-29 09:51:02 +08:00
|
|
|
},
|
|
|
|
|
handleClose() {
|
|
|
|
|
useModel.show.value = false
|
|
|
|
|
},
|
|
|
|
|
handleSelectType(e: { value: string }) {
|
|
|
|
|
useModel.formData.value.house_relation = e?.value === 'AddOwner' ? 'Owner' : 'NonOwner'
|
|
|
|
|
console.log(e)
|
|
|
|
|
},
|
|
|
|
|
handleSelectResidentialRelation() {
|
|
|
|
|
if (useModel?.formData?.value?.asset_houses_id) {
|
|
|
|
|
getApiLoading(Apis.Archive.HouseOccupants.GetOwner, {
|
|
|
|
|
asset_houses_id: useModel?.formData?.value?.asset_houses_id
|
|
|
|
|
}).then(res => {
|
|
|
|
|
useModel.ownerList.value = res?.data || []
|
|
|
|
|
console.log(res)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|