hldy_app/unpackage/dist/dev/mp-weixin/pages/timeMatrix/indexnew.js

448 lines
14 KiB
JavaScript
Raw Normal View History

2025-05-20 16:10:53 +08:00
"use strict";
const common_vendor = require("../../common/vendor.js");
2025-08-21 16:51:53 +08:00
const common_assets = require("../../common/assets.js");
if (!Array) {
const _component_arrowkeys = common_vendor.resolveComponent("arrowkeys");
_component_arrowkeys();
}
if (!Math) {
(rightroll + specialDrawerVue)();
}
const specialDrawerVue = () => "./drawer/specialDrawer.js";
const rightroll = () => "./drawer/index.js";
const totalColumns = 24;
const totalRows = 11;
const visibleWidth = 2220;
const visibleHeight = 562.5;
2025-05-20 16:10:53 +08:00
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
__name: "indexnew",
setup(__props) {
common_vendor.ref(false);
const timearr = common_vendor.ref([]);
2025-08-21 16:51:53 +08:00
common_vendor.ref(["全部", "日常", "周期"]);
common_vendor.ref(["放大", "缩小"]);
2025-05-20 16:10:53 +08:00
const buttonTarget = common_vendor.ref(0);
2025-08-21 16:51:53 +08:00
const sysInfo = common_vendor.index.getSystemInfoSync();
sysInfo.windowWidth / 750;
2025-05-20 16:10:53 +08:00
const getClass = (item, index0, index1) => {
if (item.cycleType === "日常") {
return "title-time-border-yellow";
} else if (item.cycleType) {
return "title-time-border-pouple";
}
return "title-time-border";
};
2025-08-21 16:51:53 +08:00
const clickball = (index) => {
switch (index) {
case 0:
changeTarget(2);
break;
case 1:
changeType(0);
break;
case 2:
changeTarget(1);
break;
case 3:
changeType(1);
break;
case 4:
changeTarget(0);
break;
case 5:
if (scalcType.value === 7) {
changeRuler(false);
} else {
changeRuler(true);
}
break;
2025-05-20 16:10:53 +08:00
}
};
function splitString(str) {
if (str) {
let result = [];
let remainingStr = str;
let regex = /([^(]*)[(]([^)]+)[)]/;
while (regex.test(remainingStr)) {
let match = remainingStr.match(regex);
if (match) {
if (match[1].trim()) {
result.push(match[1].trim());
}
if (match[2].trim()) {
result.push(match[2].trim());
}
remainingStr = remainingStr.replace(match[0], "").trim();
}
}
if (remainingStr.trim()) {
result.push(remainingStr.trim());
}
return result;
} else {
return [];
}
}
const scrollLeft = common_vendor.ref(0);
2025-08-21 16:51:53 +08:00
const scrollTop = common_vendor.ref(0);
2025-05-20 16:10:53 +08:00
const changetimearr = common_vendor.ref([]);
2025-08-21 16:51:53 +08:00
const scalcType = common_vendor.ref(0);
const widthType = common_vendor.ref(247);
const heightType = common_vendor.ref(180);
const cardFont = common_vendor.ref(0);
common_vendor.ref(0);
2025-05-20 16:10:53 +08:00
common_vendor.onLoad((options) => {
let arr = common_vendor.index.getStorageSync("myArray");
timearr.value = arr;
if (timearr.value[0].children.length < 8) {
timearr.value.forEach((element) => {
while (element.children.length < 8) {
element.children.push({ directiveName: "" });
}
});
}
changetimearr.value = JSON.parse(JSON.stringify(timearr.value));
2025-08-21 16:51:53 +08:00
scalcType.value = 7;
centerCell();
2025-05-20 16:10:53 +08:00
});
2025-08-21 16:51:53 +08:00
const changeType = (number) => {
if (number) {
if (scalcType.value < 24) {
scalcType.value++;
}
} else {
if (scalcType.value > 7) {
scalcType.value--;
}
}
};
function centerCell() {
if (clickX.value >= 0 && clickX.value <= totalColumns && clickY.value >= 0 && clickY.value <= totalRows) {
const cellCenterX = (clickX.value + 0.5) * widthType.value;
const cellCenterY = (clickY.value - 0.5) * heightType.value;
scrollLeft.value = cellCenterX - visibleWidth / 2;
scrollTop.value = cellCenterY - visibleHeight / 2;
const totalWidth = totalColumns * widthType.value;
const totalHeight = totalRows * heightType.value;
scrollLeft.value = Math.max(0, Math.min(scrollLeft.value, totalWidth - visibleWidth)) / 2;
scrollTop.value = Math.max(0, Math.min(scrollTop.value, totalHeight - visibleHeight)) / 2;
}
}
const clickX = common_vendor.ref(10);
const clickY = common_vendor.ref(0);
common_vendor.watch([clickX, clickY], () => {
centerCell();
});
common_vendor.watch(
scalcType,
(newVal, oldVal) => {
if (oldVal !== newVal) {
const BASE_WIDTH = 92.5;
const BASE_HEIGHT = 102.5;
const VIEW_ROWS = 11;
const VIEWPORT_HEIGHT = BASE_HEIGHT * VIEW_ROWS;
switch (newVal) {
case 24:
widthType.value = 92.5;
cardFont.value = 18;
break;
case 23:
widthType.value = 96.5;
cardFont.value = 18;
break;
case 22:
widthType.value = 101;
cardFont.value = 18;
break;
case 21:
widthType.value = 106;
cardFont.value = 19;
break;
case 20:
widthType.value = 112;
cardFont.value = 20;
break;
case 19:
widthType.value = 117;
cardFont.value = 21;
break;
case 18:
widthType.value = 124;
cardFont.value = 22;
break;
case 17:
widthType.value = 131;
cardFont.value = 23;
break;
case 16:
widthType.value = 139;
cardFont.value = 24;
break;
case 15:
widthType.value = 148;
cardFont.value = 25;
break;
case 14:
widthType.value = 159;
cardFont.value = 26;
break;
case 13:
widthType.value = 171;
cardFont.value = 27;
break;
case 12:
widthType.value = 185;
cardFont.value = 28;
break;
case 11:
widthType.value = 202;
cardFont.value = 29;
break;
case 10:
widthType.value = 222;
cardFont.value = 30;
break;
case 9:
widthType.value = 247;
cardFont.value = 30;
break;
case 8:
widthType.value = 280;
cardFont.value = 30;
break;
case 7:
widthType.value = 320;
cardFont.value = 30;
break;
default:
widthType.value = BASE_WIDTH;
cardFont.value = 18;
break;
}
const tentativeHeight = BASE_HEIGHT * (widthType.value / BASE_WIDTH);
let rows = Math.floor(VIEWPORT_HEIGHT / tentativeHeight);
if (rows < 1)
rows = 1;
if (rows > VIEW_ROWS)
rows = VIEW_ROWS;
heightType.value = VIEWPORT_HEIGHT / rows;
centerCell();
return;
}
}
);
const lastTap = common_vendor.ref(0);
const clickTimer = common_vendor.ref(null);
function handleTap(item, index0, index1) {
const now = Date.now();
if (clickTimer.value != null) {
clearTimeout(clickTimer.value);
}
if (now - lastTap.value < 250) {
if (item.startTime) {
closeIsOpen(index0, index1);
}
lastTap.value = 0;
} else {
if (item.directiveName) {
clickX.value = index0;
clickY.value = index1;
}
lastTap.value = now;
}
}
2025-05-20 16:10:53 +08:00
const openX = common_vendor.ref(0);
const openY = common_vendor.ref(0);
const isopen = common_vendor.ref(false);
const isopacity = common_vendor.ref(false);
common_vendor.ref(null);
2025-08-21 16:51:53 +08:00
const rulerTouchClick = (item, index0, index1) => {
2025-05-20 16:10:53 +08:00
if (item.directiveName) {
2025-08-21 16:51:53 +08:00
common_vendor.nextTick$1(() => {
const query = common_vendor.index.createSelectorQuery();
query.selectAll(".super-card-time-card").boundingClientRect((data) => {
data.forEach(async (res) => {
if (res.dataset.index0 == index0 && res.dataset.index1 == index1) {
if (res.left < 500) {
openX.value = Math.floor(res.left) + 510;
} else {
openX.value = Math.floor(res.left) - 10;
}
if (res.top < 300) {
openY.value = Math.floor(res.top) + 250;
} else {
openY.value = Math.floor(res.top);
}
await common_vendor.nextTick$1();
isopen.value = true;
isopacity.value = false;
setTimeout(() => {
isopacity.value = true;
}, 100);
2025-05-20 16:10:53 +08:00
}
2025-08-21 16:51:53 +08:00
});
}).exec();
});
2025-05-20 16:10:53 +08:00
}
};
const routerBack = () => {
common_vendor.index.navigateBack();
};
const closeIsOpen = (index0, index1) => {
common_vendor.index.navigateBack({
delta: 1,
success: () => {
common_vendor.index.$emit("where", {
index0,
index1
});
}
});
};
const changeTarget = (index) => {
if (buttonTarget.value !== index) {
changetimearr.value = [];
buttonTarget.value = index;
switch (index) {
case 0:
changetimearr.value = JSON.parse(JSON.stringify(timearr.value));
break;
case 1:
changetimearr.value = JSON.parse(JSON.stringify(timearr.value));
changetimearr.value.forEach((element0) => {
element0.children.forEach((element1) => {
if (element1.directiveName && element1.cycleType !== "日常") {
element1.directiveName = "";
element1.cycleType = "";
element1.startTime = "";
}
});
});
break;
case 2:
changetimearr.value = JSON.parse(JSON.stringify(timearr.value));
changetimearr.value.forEach((element0) => {
element0.children.forEach((element1) => {
if (element1.directiveName && element1.cycleType === "日常") {
element1.directiveName = "";
element1.cycleType = "";
element1.startTime = "";
}
});
});
break;
}
}
};
2025-08-21 16:51:53 +08:00
const movecard = (type) => {
isopen.value = false;
switch (type) {
case 0:
if (clickY.value > 0) {
clickY.value--;
}
break;
case 1:
if (clickX.value < 23) {
clickX.value++;
}
break;
case 2:
if (clickY.value < 11) {
clickY.value++;
}
break;
case 3:
if (clickX.value > 0) {
clickX.value--;
}
break;
case 4:
rulerTouchClick(changetimearr.value[clickX.value].children[clickY.value], clickX.value, clickY.value);
break;
case 5:
routerBack();
break;
2025-05-20 16:10:53 +08:00
}
2025-08-21 16:51:53 +08:00
};
function changeRuler(type) {
if (type) {
scalcType.value = 11;
2025-05-20 16:10:53 +08:00
} else {
2025-08-21 16:51:53 +08:00
scalcType.value = 24;
2025-05-20 16:10:53 +08:00
}
}
return (_ctx, _cache) => {
var _a, _b;
return {
2025-08-21 16:51:53 +08:00
a: common_vendor.f(changetimearr.value, (item0, index0, i0) => {
2025-05-20 16:10:53 +08:00
return {
a: common_vendor.t((item0.positioning.length == 1 ? "0" + item0.positioning : item0.positioning) + ":00"),
b: index0
};
}),
2025-08-21 16:51:53 +08:00
b: widthType.value + `rpx`,
c: widthType.value * 24 + `rpx`,
2025-05-20 16:10:53 +08:00
d: common_vendor.f(changetimearr.value, (item0, index0, i0) => {
return {
a: common_vendor.f(item0.children, (item1, index1, i1) => {
return common_vendor.e({
2025-08-21 16:51:53 +08:00
a: clickX.value == index0 && clickY.value == index1,
b: item1.startTime
}, item1.startTime ? common_vendor.e({
c: item1.startTime,
d: common_assets._imports_0$9,
e: common_vendor.t(item1.startTime + `-` + item1.endTime),
f: scalcType.value < 10,
g: item1.cycleType != "日常"
}, item1.cycleType != "日常" ? {
h: common_assets._imports_1$6,
i: scalcType.value < 14
2025-05-20 16:10:53 +08:00
} : {}, {
2025-08-21 16:51:53 +08:00
j: item1.cycleType != "日常"
}, item1.cycleType != "日常" ? {
k: common_vendor.t(item1.cycleType),
l: scalcType.value < 14
} : {}) : {}, {
m: item1.startTime
}, item1.startTime ? {
n: common_vendor.t(splitString(item1.directiveName)[0]),
o: scalcType.value < 15
2025-05-20 16:10:53 +08:00
} : {}, {
2025-08-21 16:51:53 +08:00
p: common_vendor.n(getClass(item1)),
q: common_vendor.o(($event) => handleTap(item1, index0, index1), index1),
r: index1,
s: index1
2025-05-20 16:10:53 +08:00
});
}),
b: index0,
c: index0
};
}),
2025-08-21 16:51:53 +08:00
e: heightType.value + `rpx`,
f: widthType.value + `rpx`,
g: scrollTop.value,
h: widthType.value * 24 + `rpx`,
i: scrollLeft.value,
j: common_vendor.o(clickball),
k: common_vendor.p({
changerightbottom: scalcType.value === 7 ? "缩略图" : "标准"
2025-05-20 16:10:53 +08:00
}),
2025-08-21 16:51:53 +08:00
l: common_vendor.sr("gobackdrawer", "d5065f48-0"),
m: common_vendor.o(movecard),
n: `/static/index/teeth.png`,
o: isopen.value,
p: 2 * openY.value - 350 + "rpx",
q: 2 * openX.value - 780 + "rpx",
r: isopacity.value ? 1 : 0,
s: ((_b = (_a = timearr.value[clickY.value]) == null ? void 0 : _a.children[clickX.value]) == null ? void 0 : _b.type) === "日常" ? "#fffcf6" : "rgb(246, 244, 254)",
t: common_vendor.o(() => {
})
2025-05-20 16:10:53 +08:00
};
};
}
});
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d5065f48"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/timeMatrix/indexnew.js.map