hldy_xcx/unpackage/dist/dev/mp-weixin/pages/oldmanindex/index.js

307 lines
12 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const pages_oldmanindex_api = require("./api.js");
if (!Math) {
(model + downMenu)();
}
const downMenu = () => "../../compontent/public/oldmandownmenu.js";
const model = () => "../../compontent/public/model.js";
const _sfc_main = {
__name: "index",
setup(__props) {
const show = common_vendor.ref(false);
const content = common_vendor.ref("");
const buttonArray = common_vendor.ref(["护理服务", "医疗服务", "账单查询", "视频监视", "外出申请", "长者信息", "监护人"]);
const which = common_vendor.ref(0);
const timeText = common_vendor.ref("");
const dateText = common_vendor.ref("");
const weekdayText = common_vendor.ref("");
const fullText = common_vendor.ref("");
let timer = null;
const pad = (n) => String(n).padStart(2, "0");
function formatParts(d) {
const hh = pad(d.getHours());
const mm = pad(d.getMinutes());
const ss = pad(d.getSeconds());
const month = pad(d.getMonth() + 1);
const day = pad(d.getDate());
const weekdayMap = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
return {
time: `${hh}:${mm}:${ss}`,
date: `${month}${day}`,
weekday: weekdayMap[d.getDay()]
};
}
function parseToDate(dateInput) {
if (!dateInput)
return null;
if (dateInput instanceof Date)
return dateInput;
const s = String(dateInput).trim();
const m = s.match(/^(\d{4})\D+(\d{1,2})\D+(\d{1,2})/);
if (!m)
return null;
const year = parseInt(m[1], 10);
const month = parseInt(m[2], 10) - 1;
const day = parseInt(m[3], 10);
return new Date(year, month, day);
}
function getAge(birth) {
const bd = parseToDate(birth);
if (!bd || Number.isNaN(bd.getTime()))
return null;
const today = /* @__PURE__ */ new Date();
let age = today.getFullYear() - bd.getFullYear();
const monthDiff = today.getMonth() - bd.getMonth();
if (monthDiff < 0 || monthDiff === 0 && today.getDate() < bd.getDate()) {
age -= 1;
}
return age;
}
function updateWithDate(d = /* @__PURE__ */ new Date()) {
const {
time,
date,
weekday
} = formatParts(d);
timeText.value = time;
dateText.value = date;
weekdayText.value = weekday;
fullText.value = `${time} ${date} ${weekday}`;
}
common_vendor.onLoad(() => {
updateWithDate();
timer = setInterval(() => updateWithDate(), 1e3);
});
common_vendor.onUnload(() => {
if (timer)
clearInterval(timer);
});
const clickButton = (item, index) => {
switch (index) {
case 2:
common_vendor.index.navigateTo({
url: `/pages/oldmanindex/moneylist?nuId=${item.nuId}&&orgCode=${item.orgCode}`
});
break;
case 5:
pages_oldmanindex_api.queryElders(item.elderId, item.orgCode).then((res) => {
common_vendor.index.navigateTo({
url: `/pages/addoldman/oldmanall?element=${JSON.stringify(res.result[0])}`
});
});
break;
case 6:
pages_oldmanindex_api.queryElders(item.elderId, item.orgCode).then((res) => {
common_vendor.index.navigateTo({
url: `/pages/addoldman/jianhurenall?element=${JSON.stringify(res.result[0])}`
});
});
break;
}
};
function isAtLeastTenChars(str) {
return typeof str === "string" && str.length >= 10;
}
async function jumpSaoyisao() {
const res = await common_vendor.index.scanCode();
if (isAtLeastTenChars(res.result)) {
pages_oldmanindex_api.getOrgNuId(res.result).then((res0) => {
if (res0.result) {
common_vendor.index.navigateTo({
url: `/pages/oldmanindex/saoyisaothen?element=${JSON.stringify(res0.result)}`
});
} else {
common_vendor.index.showToast({
title: "扫描的二维码有误",
icon: "none",
// 不显示对勾图标
duration: 2e3
});
}
});
} else {
common_vendor.index.showToast({
title: "扫描的二维码有误",
icon: "none",
// 不显示对勾图标
duration: 2e3
});
}
}
const jumpInput = () => {
common_vendor.index.navigateTo({
url: "/pages/oldmanindex/input"
});
};
const clickSmallball = () => {
common_vendor.index.setStorageSync("jumpIndex", 3);
common_vendor.index.navigateTo({
url: "/pages/oldmanindex/message"
});
};
const searchjigou = (item) => {
common_vendor.index.setStorageSync("baddata", "");
common_vendor.index.setStorageSync("specicalid", "");
common_vendor.index.setStorageSync("backhuancun", {});
let data = {
nuId: item.nuId,
orgCode: item.orgCode
};
common_vendor.index.setStorageSync("oldman", data);
common_vendor.index.navigateTo({
url: "/pages/addoldman/oldIDcard"
});
};
const changecard = (e) => {
which.value = e;
whichMenu.value = which.value;
};
const moveend = () => {
which.value = menuArray.value.length;
whichMenu.value = which.value;
};
const whichMenu = common_vendor.ref(0);
const swiperchange = (res) => {
whichMenu.value = res.detail.current;
which.value = res.detail.current;
};
const moveHeight = common_vendor.ref(0);
common_vendor.onMounted(() => {
let capsule = null;
if (typeof common_vendor.index.getMenuButtonBoundingClientRect === "function") {
try {
capsule = common_vendor.index.getMenuButtonBoundingClientRect();
} catch (e) {
capsule = null;
}
moveHeight.value = capsule.top;
common_vendor.index.setStorageSync("moveHeight", moveHeight.value);
}
});
common_vendor.onUnmounted(() => {
});
const menuArray = common_vendor.ref([]);
const loadingData = () => {
common_vendor.index.getStorage({
key: "openid",
success: function(res) {
pages_oldmanindex_api.getIndex(res.data).then((res2) => {
menuArray.value = [];
menuArray.value = res2.result;
menuArray.value.push({
applyStatus: `-1`
});
});
}
});
};
const hong = common_vendor.ref(0);
common_vendor.onShow(() => {
loadingData();
pages_oldmanindex_api.isRead().then((res) => {
if (res.result) {
hong.value = res.result;
}
});
});
common_vendor.onPullDownRefresh(() => {
loadingData();
pages_oldmanindex_api.isRead().then((res) => {
if (res.result) {
hong.value = res.result;
}
});
common_vendor.index.stopPullDownRefresh();
});
return (_ctx, _cache) => {
var _a;
return common_vendor.e({
a: hong.value
}, hong.value ? {
b: common_vendor.t(hong.value)
} : {}, {
c: `${moveHeight.value}px`,
d: common_vendor.o(clickSmallball),
e: common_vendor.o(($event) => show.value = false),
f: common_vendor.p({
show: show.value,
content: content.value
}),
g: common_vendor.f(menuArray.value, (item, index, i0) => {
return common_vendor.e({
a: item.applyStatus != `-1` && item.elderInfo
}, item.applyStatus != `-1` && item.elderInfo ? {
b: common_vendor.t(item.elderInfo && item.elderInfo.nuId),
c: common_vendor.t(timeText.value),
d: common_vendor.t(dateText.value),
e: common_vendor.t(weekdayText.value),
f: common_vendor.t(item.humidDeviceList && item.humidDeviceList[0] && item.humidDeviceList[0].humidity !== void 0 && item.humidDeviceList[0].humidity !== null ? item.humidDeviceList[0].humidity : "—"),
g: common_vendor.t(item.humidDeviceList && item.humidDeviceList[0] && item.humidDeviceList[0].temperature !== void 0 && item.humidDeviceList[0].temperature !== null ? item.humidDeviceList[0].temperature : "—"),
h: `https://www.focusnu.com/media/directive/index/oldmanphoto/${item.elderInfo.sex == "男" ? `old` : `woman`}.png`,
i: common_vendor.t((item.elderInfo && item.elderInfo.name) + "/" + getAge(item.elderInfo.dateOfBirth) + "岁"),
j: common_vendor.t(item.nuName),
k: common_vendor.t(item.departName),
l: common_vendor.f(buttonArray.value, (item0, index2, i1) => {
return {
a: `https://www.focusnu.com/media/directive/index/oldmanphoto/${index2}.png`,
b: common_vendor.t(item0),
c: index2,
d: common_vendor.o(($event) => clickButton(item, index2), index2)
};
}),
m: `https://www.focusnu.com/media/directive/index/oldmanphoto/more.png`
} : {}, {
n: item.applyStatus != `-1` && !item.elderInfo
}, item.applyStatus != `-1` && !item.elderInfo ? {
o: common_vendor.t(timeText.value),
p: common_vendor.t(dateText.value),
q: common_vendor.t(weekdayText.value),
r: common_vendor.t(item.humidDeviceList && item.humidDeviceList[0] && item.humidDeviceList[0].temperature !== void 0 && item.humidDeviceList[0].temperature !== null ? item.humidDeviceList[0].temperature : "—"),
s: common_vendor.t(item.humidDeviceList && item.humidDeviceList[0] && item.humidDeviceList[0].humidity !== void 0 && item.humidDeviceList[0].humidity !== null ? item.humidDeviceList[0].humidity : "—")
} : {}, {
t: item.applyStatus != `-1` && !item.elderInfo
}, item.applyStatus != `-1` && !item.elderInfo ? {
v: common_vendor.t(item.nuName),
w: common_vendor.o(($event) => searchjigou(item), index)
} : {}, {
x: item.applyStatus == `-1`
}, item.applyStatus == `-1` ? {
y: `https://www.focusnu.com/media/directive/index/saoyisaowhite.png`,
z: common_vendor.o(jumpSaoyisao, index),
A: `https://www.focusnu.com/media/directive/index/shoudong.png`,
B: common_vendor.o(jumpInput, index)
} : {}, {
C: index
});
}),
h: `100vh`,
i: which.value,
j: common_vendor.o(swiperchange),
k: common_vendor.f(menuArray.value, (item, index, i0) => {
return common_vendor.e({
a: index != menuArray.value.length - 1
}, index != menuArray.value.length - 1 ? {
b: common_vendor.n(whichMenu.value == index ? `black-box` : `gray-box`)
} : {}, {
c: index == menuArray.value.length - 1
}, index == menuArray.value.length - 1 ? {
d: `https://www.focusnu.com/media/directive/index/bluejia.png`,
e: common_vendor.o(moveend, index)
} : {}, {
f: index,
g: common_vendor.o(($event) => changecard(index), index)
});
}),
l: common_vendor.t((_a = menuArray.value[whichMenu.value]) == null ? void 0 : _a.departName),
m: common_vendor.p({
itemTarget: 0
})
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-9cf2c967"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/oldmanindex/index.js.map