72 lines
3.2 KiB
JavaScript
72 lines
3.2 KiB
JavaScript
|
|
"use strict";
|
||
|
|
const gen_Apis = require("../../gen/Apis.js");
|
||
|
|
const ME_pass_model = require("./model.js");
|
||
|
|
require("../../common/libraries/request.js");
|
||
|
|
const common_store_useWeAppAuthStore = require("../../common/store/useWeAppAuthStore.js");
|
||
|
|
require("../../common/store/useWorkStore.js");
|
||
|
|
const common_libraries_apiLoading = require("../../common/libraries/apiLoading.js");
|
||
|
|
const common_libraries_day = require("../../common/libraries/day.js");
|
||
|
|
common_store_useWeAppAuthStore.useWeAppAuthStore();
|
||
|
|
const getList = () => {
|
||
|
|
common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Visitor.VisitorApplies.Codes, {}).then((res) => {
|
||
|
|
var _a, _b, _c, _d, _e, _f, _g;
|
||
|
|
let data = (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.map((i) => {
|
||
|
|
var _a2, _b2, _c2, _d2, _e2;
|
||
|
|
return {
|
||
|
|
asset_house_id: (_a2 = i == null ? void 0 : i.asset_house) == null ? void 0 : _a2.id,
|
||
|
|
full_name: (_b2 = i == null ? void 0 : i.asset_house) == null ? void 0 : _b2.full_name,
|
||
|
|
id: i == null ? void 0 : i.id,
|
||
|
|
renovation_workers: ((_c2 = i == null ? void 0 : i.renovation_workers) == null ? void 0 : _c2.length) ? (_e2 = (_d2 = i == null ? void 0 : i.renovation_workers[0]) == null ? void 0 : _d2.worker_photo) == null ? void 0 : _e2[0] : {},
|
||
|
|
remark: i == null ? void 0 : i.remark,
|
||
|
|
visit_start_time: i == null ? void 0 : i.visit_start_time,
|
||
|
|
code_expired_at: i == null ? void 0 : i.code_expired_at,
|
||
|
|
type: 2
|
||
|
|
};
|
||
|
|
});
|
||
|
|
ME_pass_model.useModel.listData.value = [...ME_pass_model.useModel.listData.value, ...data];
|
||
|
|
if ((_b = ME_pass_model.useModel.listData.value) == null ? void 0 : _b.length) {
|
||
|
|
ME_pass_model.useModel.currentHouse.value = (_d = (_c = ME_pass_model.useModel) == null ? void 0 : _c.listData) == null ? void 0 : _d.value[0];
|
||
|
|
if (((_g = (_f = (_e = ME_pass_model.useModel) == null ? void 0 : _e.currentHouse) == null ? void 0 : _f.value) == null ? void 0 : _g.type) === 2) {
|
||
|
|
getQrCode();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
};
|
||
|
|
const getQrCode = () => {
|
||
|
|
var _a, _b, _c;
|
||
|
|
common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Visitor.VisitorApplies.VisitorQrCode, {
|
||
|
|
id: (_c = (_b = (_a = ME_pass_model.useModel) == null ? void 0 : _a.currentHouse) == null ? void 0 : _b.value) == null ? void 0 : _c.id
|
||
|
|
}).then((res) => {
|
||
|
|
var _a2;
|
||
|
|
ME_pass_model.useModel.qrCode.value = (_a2 = res == null ? void 0 : res.data) == null ? void 0 : _a2.qr_code;
|
||
|
|
console.log(res);
|
||
|
|
});
|
||
|
|
};
|
||
|
|
const getHouseList = () => {
|
||
|
|
common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Archive.HouseOccupants.List, {}).then((res) => {
|
||
|
|
var _a;
|
||
|
|
let data = (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.map((i) => {
|
||
|
|
return {
|
||
|
|
...i == null ? void 0 : i.asset_house,
|
||
|
|
house_relation: i == null ? void 0 : i.house_relation,
|
||
|
|
type: 1
|
||
|
|
};
|
||
|
|
});
|
||
|
|
ME_pass_model.useModel.listData.value = data || [];
|
||
|
|
getList();
|
||
|
|
});
|
||
|
|
};
|
||
|
|
const getShowCurrentTime = () => {
|
||
|
|
ME_pass_model.useModel.showCurrentTime.value = common_libraries_day.showCurrentTime();
|
||
|
|
ME_pass_model.useModel.timeoutObj.value = setTimeout(() => {
|
||
|
|
getShowCurrentTime();
|
||
|
|
}, 1e3);
|
||
|
|
};
|
||
|
|
const method = {
|
||
|
|
getList,
|
||
|
|
getHouseList,
|
||
|
|
getQrCode,
|
||
|
|
getShowCurrentTime
|
||
|
|
};
|
||
|
|
exports.method = method;
|