"use strict";const e=require("../../common/vendor.js"),o=require("./model.js"),l=require("../../common/libraries/apiLoading.js"),s=require("../../gen/Apis.js");require("../../common/libraries/request.js");const a=require("../../common/store/useWeAppAuthStore.js");require("../../common/store/useWorkStore.js");const u=require("../../common/libraries/naviHelper.js"),i=require("../../common/libraries/userUserLogin.js"),n=a.useWeAppAuthStore(),d=()=>{var a,u,i;l.getApiLoading(s.Apis.Archive.HouseRegisters.Store,{...o.useModel.formData.value,is_live_in:(null==(i=null==(u=null==(a=o.useModel)?void 0:a.formData)?void 0:u.value)?void 0:i.is_live_in)?1:0,customer_info:[o.useModel.formData.value]}).then((l=>{o.useModel.loading.value=!1,o.useModel.show.value=!1,e.index.redirectTo({url:"/INDEX/binding/success"}),null==n||n.getIsHouseExist(),console.log(l)})).catch((e=>{o.useModel.loading.value=!1,o.useModel.show.value=!1}))},r={handleSubmitStore:d,handleSelectProject:e=>{var l;e[3]?o.useModel.formData.value.asset_houses_id=null==(l=e[3])?void 0:l.id:o.useModel.formData.value.asset_houses_id="",console.log(e,"e")},init(e){var l,s;o.useModel.defaultHouseValueName.value=(null==e?void 0:e.houseName)||"",o.useModel.formData.value={asset_houses_id:(null==e?void 0:e.id)||"",type:"",customer_info:[],name:"",phone:(null==(s=null==(l=null==n?void 0:n.data)?void 0:l.user)?void 0:s.phone)||"",card_front_image:[],card_back_image:[],house_relation:"",card_type:"MainlandID",relation_with_owner:"",ownership_info:[],id_card:"",move_in_date:"",is_live_in:!0}},handleIsLiveIn(e){var l;o.useModel.formData.value.is_live_in=null==(l=null==e?void 0:e.detail)?void 0:l.value,console.log(e,"e")},handleSubmit:l=>{var s,a,n,r,t,v,m,c,h;return!!(null==(s=i.getUserLogin)?void 0:s.onBindPhone())&&(o.useModel.formData.value.asset_houses_id?o.useModel.formData.value.type?o.useModel.formData.value.name&&o.useModel.formData.value.phone?o.useModel.formData.value.id_card?(null==(a=o.useModel.formData.value.card_front_image)?void 0:a.length)&&(null==(n=o.useModel.formData.value.card_back_image)?void 0:n.length)?"AddOwner"!==o.useModel.formData.value.type||(null==(t=null==(r=o.useModel.formData.value)?void 0:r.ownership_info)?void 0:t.length)?void("AddOwner"===o.useModel.formData.value.type&&(null==(c=null==(m=null==(v=o.useModel)?void 0:v.ownerList)?void 0:m.value)?void 0:c.length)?o.useModel.show.value=!0:(o.useModel.loading.value=!0,console.log(null==(h=o.useModel)?void 0:h.formData.value,"formData"),e.index.requestSubscribeMessage({tmplIds:["0nIVHQNvIco7zeTWv-W3_MbZFR9ibIXejLxh2OFo5mg"],success(e){console.log(e),d()},fail(e){d(),console.log(e,"res定远失败")}}))):u.showToast("请先上传房产证！"):u.showToast("请先上传身份证正反面！"):u.showToast("请设置身份证号！"):u.showToast("请设置姓名和手机号！"):u.showToast("请先选择身份！"):u.showToast("请先选择房屋！"))},handleClose(){o.useModel.show.value=!1},handleSelectType(e){o.useModel.formData.value.house_relation="AddOwner"===(null==e?void 0:e.value)?"Owner":"NonOwner",console.log(e)},handleSelectResidentialRelation(){var e,a,u,i,n,d;(null==(u=null==(a=null==(e=o.useModel)?void 0:e.formData)?void 0:a.value)?void 0:u.asset_houses_id)&&l.getApiLoading(s.Apis.Archive.HouseOccupants.GetOwner,{asset_houses_id:null==(d=null==(n=null==(i=o.useModel)?void 0:i.formData)?void 0:n.value)?void 0:d.asset_houses_id}).then((e=>{o.useModel.ownerList.value=(null==e?void 0:e.data)||[],console.log(e)}))}};exports.method=r;
