288 lines
10 KiB
JavaScript
288 lines
10 KiB
JavaScript
|
"use strict";
|
|||
|
const common_vendor = require("../../common/vendor.js");
|
|||
|
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
|||
|
__name: "indexnew",
|
|||
|
setup(__props) {
|
|||
|
common_vendor.ref(false);
|
|||
|
const timearr = common_vendor.ref([]);
|
|||
|
const buttonArray = common_vendor.ref(["全部", "日常", "周期"]);
|
|||
|
const buttonTarget = common_vendor.ref(0);
|
|||
|
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";
|
|||
|
};
|
|||
|
const moveDownNumber = common_vendor.ref(0);
|
|||
|
function handleScrolltime(e) {
|
|||
|
let num = e.detail.scrollTop;
|
|||
|
let formattedNum = parseFloat(num.toFixed(2));
|
|||
|
moveDownNumber.value = formattedNum;
|
|||
|
}
|
|||
|
const getClassItem = (index) => {
|
|||
|
if (buttonTarget.value !== index) {
|
|||
|
return `titlebutton`;
|
|||
|
} else {
|
|||
|
switch (index) {
|
|||
|
case 0:
|
|||
|
return `titlebutton-target`;
|
|||
|
case 1:
|
|||
|
return `titlebutton-target-yellow`;
|
|||
|
case 2:
|
|||
|
return `titlebutton-target-pouple`;
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
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);
|
|||
|
const changetimearr = common_vendor.ref([]);
|
|||
|
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));
|
|||
|
scrollLeft.value = 740;
|
|||
|
});
|
|||
|
const openX = common_vendor.ref(0);
|
|||
|
const openY = common_vendor.ref(0);
|
|||
|
const isopen = common_vendor.ref(false);
|
|||
|
const isopacity = common_vendor.ref(false);
|
|||
|
const clickX = common_vendor.ref(-1);
|
|||
|
const clickY = common_vendor.ref(-1);
|
|||
|
common_vendor.ref(null);
|
|||
|
const rulerTouchClick = (item, index0, index1, e) => {
|
|||
|
if (item.directiveName) {
|
|||
|
clickX.value = index0;
|
|||
|
clickY.value = index1;
|
|||
|
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);
|
|||
|
}
|
|||
|
});
|
|||
|
}).exec();
|
|||
|
}
|
|||
|
};
|
|||
|
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 changeWhiteLine = () => {
|
|||
|
let emptyChildIndices = [];
|
|||
|
changetimearr.value.forEach((res, rowIndex) => {
|
|||
|
emptyChildIndices = [];
|
|||
|
res.children.forEach((child, index) => {
|
|||
|
if (child.directiveName === null || child.directiveName === "" || child.directiveName === void 0) {
|
|||
|
const isEmptyInAllRows = changetimearr.value.every((otherRes) => {
|
|||
|
const otherChild = otherRes.children[index];
|
|||
|
return otherChild.directiveName === "";
|
|||
|
});
|
|||
|
if (isEmptyInAllRows) {
|
|||
|
emptyChildIndices.push(index);
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
const sortedIndices = [...emptyChildIndices].sort((a, b) => b - a);
|
|||
|
changetimearr.value.forEach((element) => {
|
|||
|
sortedIndices.forEach((idx) => {
|
|||
|
element.children.splice(idx, 1);
|
|||
|
});
|
|||
|
});
|
|||
|
if (changetimearr.value[0].children.length < 8) {
|
|||
|
changetimearr.value.forEach((element) => {
|
|||
|
while (element.children.length < 8) {
|
|||
|
element.children.push({ directiveName: "" });
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
};
|
|||
|
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 = "";
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
changeWhiteLine();
|
|||
|
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 = "";
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
changeWhiteLine();
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
const lastTap = common_vendor.ref(0);
|
|||
|
const clickTimer = common_vendor.ref(null);
|
|||
|
function handleTap(item, index0, index1, e) {
|
|||
|
const now = Date.now();
|
|||
|
if (clickTimer.value != null) {
|
|||
|
clearTimeout(clickTimer.value);
|
|||
|
}
|
|||
|
if (now - lastTap.value < 250) {
|
|||
|
closeIsOpen(index0, index1);
|
|||
|
lastTap.value = 0;
|
|||
|
} else {
|
|||
|
clickTimer.value = setTimeout(() => {
|
|||
|
rulerTouchClick(item, index0, index1);
|
|||
|
}, 250);
|
|||
|
lastTap.value = now;
|
|||
|
}
|
|||
|
}
|
|||
|
return (_ctx, _cache) => {
|
|||
|
var _a, _b;
|
|||
|
return {
|
|||
|
a: common_vendor.f(buttonArray.value, (item, index, i0) => {
|
|||
|
return {
|
|||
|
a: common_vendor.t(item),
|
|||
|
b: common_vendor.n(getClassItem(index)),
|
|||
|
c: common_vendor.o(($event) => changeTarget(index), index),
|
|||
|
d: index
|
|||
|
};
|
|||
|
}),
|
|||
|
b: common_vendor.o(routerBack),
|
|||
|
c: common_vendor.f(changetimearr.value, (item0, index0, i0) => {
|
|||
|
return {
|
|||
|
a: common_vendor.t((item0.positioning.length == 1 ? "0" + item0.positioning : item0.positioning) + ":00"),
|
|||
|
b: index0
|
|||
|
};
|
|||
|
}),
|
|||
|
d: common_vendor.f(changetimearr.value, (item0, index0, i0) => {
|
|||
|
return {
|
|||
|
a: common_vendor.f(item0.children, (item1, index1, i1) => {
|
|||
|
return common_vendor.e({
|
|||
|
a: item1.startTime
|
|||
|
}, item1.startTime ? {
|
|||
|
b: common_vendor.t(item1.startTime + `-` + item1.endTime),
|
|||
|
c: item1.cycleType == "日常" ? `/static/index/yellowbian.png` : `/static/index/puoplebian.png`,
|
|||
|
d: common_vendor.t(item1.cycleType)
|
|||
|
} : {}, {
|
|||
|
e: common_vendor.t(splitString(item1.directiveName)[0]),
|
|||
|
f: common_vendor.s(splitString(item1.directiveName)[1] ? {} : {
|
|||
|
marginTop: `20rpx`
|
|||
|
}),
|
|||
|
g: splitString(item1.directiveName)[1]
|
|||
|
}, splitString(item1.directiveName)[1] ? {
|
|||
|
h: common_vendor.f(splitString(item1.directiveName).slice(1), (item, index, i2) => {
|
|||
|
return {
|
|||
|
a: common_vendor.t(splitString(item1.directiveName)[index + 1]),
|
|||
|
b: index
|
|||
|
};
|
|||
|
}),
|
|||
|
i: common_vendor.s(item1.cycleType != "日常" ? {
|
|||
|
backgroundColor: `rgb(123,97,255)`
|
|||
|
} : {}),
|
|||
|
j: common_vendor.s(item1.cycleType != "日常" ? {
|
|||
|
backgroundColor: `rgb(212,203,255)`
|
|||
|
} : {})
|
|||
|
} : {}, {
|
|||
|
k: common_vendor.n(getClass(item1)),
|
|||
|
l: common_vendor.n(clickX.value === index0 && clickY.value === index1 ? `title-time-border-blue` : ``),
|
|||
|
m: common_vendor.o(($event) => handleTap(item1, index0, index1), index1),
|
|||
|
n: index1,
|
|||
|
o: index1
|
|||
|
});
|
|||
|
}),
|
|||
|
b: index0,
|
|||
|
c: index0
|
|||
|
};
|
|||
|
}),
|
|||
|
e: common_vendor.o(handleScrolltime),
|
|||
|
f: scrollLeft.value,
|
|||
|
g: `/static/index/teeth.png`,
|
|||
|
h: 2 * openY.value - 350 + "rpx",
|
|||
|
i: 2 * openX.value - 780 + "rpx",
|
|||
|
j: isopacity.value ? 1 : 0,
|
|||
|
k: ((_b = (_a = timearr.value[clickY.value]) == null ? void 0 : _a.children[clickX.value]) == null ? void 0 : _b.type) === "日常" ? "#fffcf6" : "rgb(246, 244, 254)",
|
|||
|
l: common_vendor.o(() => {
|
|||
|
}),
|
|||
|
m: isopen.value,
|
|||
|
n: common_vendor.o(($event) => isopen.value = false)
|
|||
|
};
|
|||
|
};
|
|||
|
}
|
|||
|
});
|
|||
|
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
|