"use strict";const e=require("../../common/vendor.js");require("../../common/libraries/request.js"),require("../../common/store/useWatermarkStore.js");const o=require("../../common/store/useWeAppAuthStore.js");require("../../common/store/useWorkStore.js");const l=require("../../common/libraries/apiLoading.js"),n=require("../../common/libraries/naviHelper.js"),i=require("../../common/libraries/sendWxWork.js"),u=require("../../common/libraries/userUserLogin.js"),s=require("../../gen/Apis.js"),a=require("./model.js"),r=o.useWeAppAuthStore(),d={nextStep(o){var i,r,d;let t=null==(r=null==(i=a.useModel)?void 0:i.formData)?void 0:r.value;if(!(null==(d=u.getUser)?void 0:d.toPageLogin()))return(null==t?void 0:t.phone)&&(null==t?void 0:t.name)?void l.getApiLoading(s.Apis.Archive.HouseOccupants.GetCustomerHouse,{phone:null==t?void 0:t.phone}).then(l=>{var n,i,u,s,r,d,t,v,m,h,c,g,p;(null==(n=null==l?void 0:l.data)?void 0:n.length)?(a.useModel.bindHouseSelectPage.value=!0,a.useModel.bindHouseFormPage.value=!1,a.useModel.listData.value=null==l?void 0:l.data):"phone"===o?e.index.redirectTo({url:`/CUSTOMER/house_select/index?phone=${null==(s=null==(u=null==(i=a.useModel)?void 0:i.formData)?void 0:u.value)?void 0:s.phone}&name=${null==(t=null==(d=null==(r=a.useModel)?void 0:r.formData)?void 0:d.value)?void 0:t.name}`}):e.index.navigateTo({url:`/CUSTOMER/house_select/index?phone=${null==(h=null==(m=null==(v=a.useModel)?void 0:v.formData)?void 0:m.value)?void 0:h.phone}&name=${null==(p=null==(g=null==(c=a.useModel)?void 0:c.formData)?void 0:g.value)?void 0:p.name}`}),console.log(l)}):n.showToast("请填写姓名/手机号")},selectHouse(e,o){var l,n,i;let u=null==(i=null==(n=null==(l=a.useModel)?void 0:l.listData)?void 0:n.value[o])?void 0:i.isSelect;a.useModel.listData.value[o].isSelect=!u},handleBack(){var o,l,n,i,u,s,r,d;(null==(l=null==(o=a.useModel)?void 0:o.bindPhone)?void 0:l.value)?e.index.navigateTo({url:`/CUSTOMER/house_select/index?phone=${null==(u=null==(i=null==(n=a.useModel)?void 0:n.formData)?void 0:i.value)?void 0:u.phone}&name=${null==(d=null==(r=null==(s=a.useModel)?void 0:s.formData)?void 0:r.value)?void 0:d.name}`}):(a.useModel.bindHouseSelectPage.value=!1,a.useModel.bindHouseFormPage.value=!0)},handleBindHouse(){var o,i,u,r;let d=null==(i=null==(o=a.useModel)?void 0:o.formData)?void 0:i.value,t=[];if(null==(r=null==(u=a.useModel)?void 0:u.listData)||r.value.map(e=>{(null==e?void 0:e.isSelect)&&t.push({asset_houses_id:null==e?void 0:e.asset_houses_id,residential_relation:null==e?void 0:e.residential_relation})}),!(null==t?void 0:t.length))return n.showToast("请至少选择一套房屋！");console.log(t),l.getApiLoading(s.Apis.Archive.HouseRegisters.Store,{...d,house_info:t}).then(o=>{n.showToastBack("绑定成功",1,!1,()=>{e.index.reLaunch({url:"/CUSTOMER/house_list/index"})}),console.log(o)})},handleInviteCustomer(){var e;"wxwork"===(null==(e=null==r?void 0:r.data)?void 0:e.environment)?i.sendChatMessage({page:"/INDEX/binding/index.html",title:"邀请你绑定房屋"}):i.navigateToMiniProgram({path:"/pages/forward/index?source=HouseholdRegistration",envVersion:"develop",extraData:{source:"HouseholdRegistration"}})}};exports.method=d;
