officialAccount/unpackage/dist/dev/mp-weixin/pages/index/index.js

191 lines
6.3 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const tu = "https://www.focusnu.com/media/directive/index/tu.png";
const _sfc_main = {
__name: "index",
setup(__props) {
const itemArray = ["NU", "动态", "我的"];
const buttonArray = common_vendor.ref(["护理流程", "服务指令", "实时监控", "客户信息", "缴费账单", "充值缴费", "退住管理"]);
const itemTarget = common_vendor.ref(0);
const which = common_vendor.ref(0);
const scaning = common_vendor.ref(false);
function preview() {
common_vendor.index.previewImage({
urls: [tu]
// 需要预览的所有图片地址数组
// current: imgList.value[currentIndex], // 当前点击的那张
});
}
const jumpTo = () => {
common_vendor.index.navigateTo({
url: "/pages/index/indexone"
});
};
const month = common_vendor.ref("01");
const day = common_vendor.ref("01");
const weekday = common_vendor.ref("周一");
const weekMap = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
const hours = common_vendor.ref("00");
const minutes = common_vendor.ref("00");
const seconds = common_vendor.ref("00");
let timer = null;
function updateTime() {
const now = /* @__PURE__ */ new Date();
month.value = String(now.getMonth() + 1).padStart(2, "0");
day.value = String(now.getDate()).padStart(2, "0");
weekday.value = weekMap[now.getDay()];
hours.value = String(now.getHours()).padStart(2, "0");
minutes.value = String(now.getMinutes()).padStart(2, "0");
seconds.value = String(now.getSeconds()).padStart(2, "0");
}
const whichMenu = common_vendor.ref(0);
const swiperchange = (res) => {
whichMenu.value = res.detail.current;
};
const addoldman = () => {
common_vendor.index.navigateTo({
url: "/pages/addoldman/IDcard"
});
};
const gotoPay = () => {
common_vendor.index.navigateTo({
url: "/pages/pay/index"
});
};
const qrResult = common_vendor.ref("");
const scanning = common_vendor.ref(false);
let html5QrCode = null;
async function cancelScan() {
if (html5QrCode && scanning.value) {
try {
await html5QrCode.stop();
} catch (e) {
common_vendor.index.__f__("warn", "at pages/index/index.vue:253", "停止扫码出错", e);
}
}
scanning.value = false;
}
function scanQrCode() {
if (html5QrCode && scanning.value) {
html5QrCode.stop().catch(() => {
}).finally(() => {
scanning.value = false;
});
return;
}
scanning.value = true;
qrResult.value = "";
html5QrCode = new Html5Qrcode("reader");
const config = {
fps: 10,
qrbox: {
width: 350,
height: 350
}
};
html5QrCode.start(
{
facingMode: "environment"
},
// 后置摄像头
config,
(decodedText) => {
qrResult.value = decodedText;
html5QrCode.stop().catch(console.warn).finally(() => {
scanning.value = false;
});
},
(errorMessage) => {
}
).catch((err) => {
common_vendor.index.__f__("error", "at pages/index/index.vue:300", "扫码启动失败", err);
scanning.value = false;
});
}
const gotoWindy = () => {
common_vendor.index.navigateTo({
url: "/pages/selectunit/map"
});
};
const goback = () => {
common_vendor.index.navigateBack();
};
common_vendor.onMounted(async () => {
updateTime();
timer = setInterval(updateTime, 1e3);
});
common_vendor.onUnmounted(() => {
clearInterval(timer);
html5QrCode && html5QrCode.stop().catch(console.warn);
});
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.o(goback),
b: scanning.value
}, scanning.value ? {
c: common_vendor.o(cancelScan),
d: common_vendor.o(() => {
})
} : {}, {
e: common_vendor.o(gotoPay),
f: common_vendor.o(jumpTo),
g: tu,
h: common_vendor.o(($event) => preview()),
i: scaning.value
}, scaning.value ? common_vendor.e({
j: common_vendor.o(($event) => {
scaning.value = false;
}),
k: qrResult.value
}, qrResult.value ? {
l: common_vendor.t(qrResult.value)
} : {}, {
m: common_vendor.o(scanQrCode)
}) : {}, {
n: !scaning.value
}, !scaning.value ? {
o: common_vendor.t(hours.value),
p: common_vendor.t(minutes.value),
q: common_vendor.t(seconds.value),
r: common_vendor.t(month.value),
s: common_vendor.t(day.value),
t: common_vendor.t(weekday.value)
} : {}, {
v: !scaning.value
}, !scaning.value ? {
w: common_vendor.o(gotoWindy),
x: common_vendor.o(($event) => scaning.value = true),
y: common_vendor.o(($event) => scaning.value = true),
z: common_vendor.o(addoldman),
A: common_vendor.f(buttonArray.value, (item, index, i0) => {
return {
a: `https://www.focusnu.com/media/directive/index/jumpbutton/${index}.png`,
b: common_vendor.t(item),
c: index
};
}),
B: `600rpx`,
C: which.value,
D: common_vendor.o(swiperchange)
} : {}, {
E: whichMenu.value === 2
}, whichMenu.value === 2 ? {} : {}, {
F: common_vendor.f(itemArray, (item, index, i0) => {
return {
a: `https://www.focusnu.com/media/directive/index/itemsbutton/${index}${itemTarget.value === index ? 1 : 0}.png`,
b: common_vendor.t(item),
c: common_vendor.s(!index ? {
fontWeight: 600
} : {}),
d: common_vendor.n(itemTarget.value === index ? `bottom-button-target` : `bottom-button`),
e: common_vendor.o(($event) => itemTarget.value = index)
};
})
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1cf27b2a"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/index.js.map