102 lines
4.7 KiB
JavaScript
102 lines
4.7 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const CUSTOMER_bind_house_model = require("./model.js");
|
|
const common_libraries_naviHelper = require("../../common/libraries/naviHelper.js");
|
|
const gen_Apis = require("../../gen/Apis.js");
|
|
const common_libraries_apiLoading = require("../../common/libraries/apiLoading.js");
|
|
const common_libraries_userUserLogin = require("../../common/libraries/userUserLogin.js");
|
|
const common_libraries_sendWxWork = require("../../common/libraries/sendWxWork.js");
|
|
require("../../common/libraries/request.js");
|
|
const common_store_useWeAppAuthStore = require("../../common/store/useWeAppAuthStore.js");
|
|
require("../../common/store/useWorkStore.js");
|
|
const auth = common_store_useWeAppAuthStore.useWeAppAuthStore();
|
|
const method = {
|
|
nextStep(type) {
|
|
var _a, _b, _c;
|
|
let data = (_b = (_a = CUSTOMER_bind_house_model.useModel) == null ? void 0 : _a.formData) == null ? void 0 : _b.value;
|
|
if ((_c = common_libraries_userUserLogin.getUser) == null ? void 0 : _c.toPageLogin())
|
|
return;
|
|
if (!(data == null ? void 0 : data.phone) || !(data == null ? void 0 : data.name)) {
|
|
return common_libraries_naviHelper.showToast("请填写姓名/手机号");
|
|
}
|
|
common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Archive.HouseOccupants.GetCustomerHouse, { phone: data == null ? void 0 : data.phone }).then(
|
|
(res) => {
|
|
var _a2;
|
|
if (!((_a2 = res == null ? void 0 : res.data) == null ? void 0 : _a2.length)) {
|
|
if (type === "phone") {
|
|
common_vendor.index.redirectTo({
|
|
url: "/CUSTOMER/house_select/index"
|
|
});
|
|
} else {
|
|
common_vendor.index.navigateTo({
|
|
url: "/CUSTOMER/house_select/index"
|
|
});
|
|
}
|
|
} else {
|
|
CUSTOMER_bind_house_model.useModel.bindHouseSelectPage.value = true;
|
|
CUSTOMER_bind_house_model.useModel.bindHouseFormPage.value = false;
|
|
CUSTOMER_bind_house_model.useModel.listData.value = res == null ? void 0 : res.data;
|
|
}
|
|
console.log(res);
|
|
}
|
|
);
|
|
},
|
|
selectHouse(e, index) {
|
|
var _a, _b, _c;
|
|
let isSelect = (_c = (_b = (_a = CUSTOMER_bind_house_model.useModel) == null ? void 0 : _a.listData) == null ? void 0 : _b.value[index]) == null ? void 0 : _c.isSelect;
|
|
CUSTOMER_bind_house_model.useModel.listData.value[index].isSelect = !isSelect;
|
|
},
|
|
handleBack() {
|
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
if ((_b = (_a = CUSTOMER_bind_house_model.useModel) == null ? void 0 : _a.bindPhone) == null ? void 0 : _b.value) {
|
|
common_vendor.index.navigateTo({
|
|
url: `/CUSTOMER/house_select/index?phone=${(_e = (_d = (_c = CUSTOMER_bind_house_model.useModel) == null ? void 0 : _c.formData) == null ? void 0 : _d.value) == null ? void 0 : _e.phone}&name=${(_h = (_g = (_f = CUSTOMER_bind_house_model.useModel) == null ? void 0 : _f.formData) == null ? void 0 : _g.value) == null ? void 0 : _h.name}`
|
|
});
|
|
} else {
|
|
CUSTOMER_bind_house_model.useModel.bindHouseSelectPage.value = false;
|
|
CUSTOMER_bind_house_model.useModel.bindHouseFormPage.value = true;
|
|
}
|
|
},
|
|
handleBindHouse() {
|
|
var _a, _b, _c, _d;
|
|
let data = (_b = (_a = CUSTOMER_bind_house_model.useModel) == null ? void 0 : _a.formData) == null ? void 0 : _b.value;
|
|
let house_info = [];
|
|
(_d = (_c = CUSTOMER_bind_house_model.useModel) == null ? void 0 : _c.listData) == null ? void 0 : _d.value.map((res) => {
|
|
if (res == null ? void 0 : res.isSelect) {
|
|
house_info.push({
|
|
asset_houses_id: res == null ? void 0 : res.asset_houses_id,
|
|
residential_relation: res == null ? void 0 : res.residential_relation
|
|
});
|
|
}
|
|
});
|
|
if (!(house_info == null ? void 0 : house_info.length)) {
|
|
return common_libraries_naviHelper.showToast("请至少选择一套房屋!");
|
|
}
|
|
console.log(house_info);
|
|
common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Archive.HouseRegisters.Store, {
|
|
...data,
|
|
house_info
|
|
}).then((res) => {
|
|
common_libraries_naviHelper.showToastBack("绑定成功", 1, false, () => {
|
|
common_vendor.index.reLaunch({
|
|
url: `/CUSTOMER/house_list/index`
|
|
});
|
|
});
|
|
console.log(res);
|
|
});
|
|
},
|
|
handleInviteCustomer() {
|
|
var _a;
|
|
if (((_a = auth == null ? void 0 : auth.data) == null ? void 0 : _a.environment) === "wxwork") {
|
|
common_libraries_sendWxWork.sendChatMessage({ page: "/INDEX/binding/index.html", title: "邀请你绑定房屋" });
|
|
} else {
|
|
common_libraries_sendWxWork.navigateToMiniProgram({
|
|
path: "/pages/forward/index?source=HouseholdRegistration",
|
|
envVersion: "develop",
|
|
extraData: { source: "HouseholdRegistration" }
|
|
});
|
|
}
|
|
}
|
|
};
|
|
exports.method = method;
|