hldy_app/unpackage/dist/dev/mp-weixin/pages/watch/settings/leida.js

404 lines
13 KiB
JavaScript
Raw Normal View History

2025-08-21 16:51:53 +08:00
"use strict";
const common_vendor = require("../../../common/vendor.js");
const common_assets = require("../../../common/assets.js");
const component_Initialization_api = require("../../../component/Initialization/api.js");
if (!Array) {
const _component_arrowkeys = common_vendor.resolveComponent("arrowkeys");
_component_arrowkeys();
}
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
__name: "leida",
setup(__props) {
const goback = () => {
common_vendor.index.navigateBack();
};
const running = common_vendor.ref(true);
const centerAngle = common_vendor.ref(0);
const speed = common_vendor.ref(100);
const renamenummber = common_vendor.ref(-1);
const savevalue = common_vendor.ref("");
const savenuId = common_vendor.ref();
const isdonghua = common_vendor.ref(false);
const rightbutton = common_vendor.ref([
{ url: "/static/index/leida/00.png", targetUrl: "/static/index/leida/01.png", target: false },
{ url: "/static/index/leida/10.png", targetUrl: "/static/index/leida/11.png", target: false },
{ url: "/static/index/leida/20.png", targetUrl: "/static/index/leida/21.png", target: false },
{ url: "/static/index/leida/30.png", targetUrl: "/static/index/leida/31.png", target: false }
]);
const cardarray = common_vendor.ref([]);
const relArray = common_vendor.ref([]);
const scrollTop = common_vendor.ref(0);
let rafId = null;
function raf(cb) {
if (typeof globalThis.requestAnimationFrame === "function") {
return globalThis.requestAnimationFrame(cb);
} else {
return setTimeout(() => cb(Date.now()), 16);
}
}
function caf(id) {
if (typeof globalThis.cancelAnimationFrame === "function") {
globalThis.cancelAnimationFrame(id);
} else {
clearTimeout(id);
}
}
function nowTime(ts) {
var _a;
if (typeof ts === "number")
return ts;
if ((_a = globalThis.performance) == null ? void 0 : _a.now) {
return globalThis.performance.now();
}
return Date.now();
}
let lastT = null;
function loop(ts) {
const now = nowTime(ts);
if (!lastT)
lastT = now;
const dt = (now - lastT) / 1e3;
lastT = now;
if (running.value) {
centerAngle.value = (centerAngle.value + speed.value * dt) % 360;
}
rafId = raf(loop);
}
function onAnimEnd(item) {
item.isNew = false;
}
function cantoggleRun() {
if (count.value === 100) {
startCounter();
toggleRun();
}
}
function toggleRun() {
running.value = !running.value;
if (running.value) {
lastT = nowTime();
startBallGeneration();
} else {
stopBallGeneration();
}
}
const changename = (name, index) => {
if (name) {
cardarray.value[index].nuName = name;
}
renamenummber.value = -1;
};
const insetStyle = common_vendor.computed(() => ({
transform: `rotate(${centerAngle.value}deg)`
}));
const balls = common_vendor.ref([]);
let ballTimer = null;
let ballId = 0;
function createBall() {
const size = Math.random() * 1 + 5;
const left = Math.random() * (200 - size);
const top = Math.random() * (200 - size);
const id = ballId++;
const ball = {
id,
size,
left,
top,
color: "#02a9ff",
opacity: 0
};
balls.value.push(ball);
setTimeout(() => {
ball.opacity = 1;
}, 20);
setTimeout(() => {
ball.opacity = 0;
setTimeout(() => {
balls.value = balls.value.filter((b) => b.id !== id);
}, 500);
}, 2e3);
}
function startBallGeneration() {
if (ballTimer)
return;
ballTimer = setInterval(() => {
createBall();
}, 500);
}
function stopBallGeneration() {
clearInterval(ballTimer);
ballTimer = null;
}
const count = common_vendor.ref(0);
function startCounter() {
let start = Date.now();
let totalTime = 4e3;
let pausePoint = Math.floor(Math.random() * 30) + 30;
let paused = false;
let pauseDuration = Math.floor(Math.random() * 500) + 300;
let pauseStart = 0;
function update() {
let elapsed = Date.now() - start;
if (!paused && count.value >= pausePoint) {
paused = true;
pauseStart = Date.now();
}
if (paused) {
if (Date.now() - pauseStart >= pauseDuration) {
paused = false;
} else {
setTimeout(update, 16);
return;
}
}
let progress = Math.min(elapsed / totalTime, 1);
count.value = Math.floor(progress * 100);
if (count.value === 100) {
toggleRun();
}
if (count.value < 100) {
setTimeout(update, 16);
}
}
component_Initialization_api.getCardList().then((res) => {
res.result.records.forEach((element) => {
element.menu = JSON.parse(JSON.stringify(rightbutton.value));
element.isNew = true;
});
relArray.value = [];
relArray.value.push(JSON.parse(JSON.stringify(res.result.records[0])));
relArray.value.push(JSON.parse(JSON.stringify(res.result.records[0])));
relArray.value.push(JSON.parse(JSON.stringify(res.result.records[0])));
relArray.value.push(JSON.parse(JSON.stringify(res.result.records[0])));
relArray.value.push(JSON.parse(JSON.stringify(res.result.records[0])));
suiji();
});
setTimeout(update, 16);
}
function suiji() {
const n = relArray.value.length;
cardarray.value = [];
const randomWeights = Array.from({ length: n }, () => Math.random());
const totalWeight = randomWeights.reduce((a, b) => a + b, 0);
const intervals = randomWeights.map((w) => w / totalWeight * 4e3);
let cumulative = 0;
for (let i = 0; i < n; i++) {
cumulative += intervals[i];
setTimeout(async () => {
cardarray.value.push(relArray.value[i]);
cardarray.value.length;
}, cumulative);
}
}
const rename = (index, item) => {
renamenummber.value = index;
savevalue.value = item.nuName;
savenuId.value = item.nuId;
isdonghua.value = false;
setTimeout(() => {
isdonghua.value = true;
}, 50);
};
common_vendor.onMounted(() => {
init();
});
const init = () => {
lastT = nowTime();
rafId = raf(loop);
startBallGeneration();
startCounter();
};
const targetNumber = common_vendor.ref(-1);
const infoNumber = common_vendor.ref(-1);
const movecard = (where) => {
if (count.value !== 100) {
return;
}
switch (where) {
case 0:
if (infoNumber.value === 0) {
infoNumber.value = 1;
return;
} else if (infoNumber.value === 1) {
infoNumber.value = 0;
return;
}
if (targetNumber.value - 2 < -1) {
targetNumber.value = -1;
} else {
targetNumber.value = targetNumber.value - 2;
ensureVisible(targetNumber.value);
}
break;
case 1:
if (infoNumber.value === 0) {
infoNumber.value = 1;
return;
} else if (infoNumber.value === 1) {
infoNumber.value = 0;
return;
}
if (targetNumber.value + 1 > cardarray.value.length - 1)
;
else {
targetNumber.value++;
ensureVisible(targetNumber.value);
}
break;
case 2:
if (infoNumber.value === 0) {
infoNumber.value = 1;
return;
} else if (infoNumber.value === 1) {
infoNumber.value = 0;
return;
}
if (targetNumber.value + 1 === cardarray.value.length - 1 || targetNumber.value === -1) {
targetNumber.value++;
ensureVisible(targetNumber.value);
} else if (targetNumber.value + 2 > cardarray.value.length - 1)
;
else {
targetNumber.value = targetNumber.value + 2;
ensureVisible(targetNumber.value);
}
break;
case 3:
if (infoNumber.value === 0) {
infoNumber.value = 1;
return;
} else if (infoNumber.value === 1) {
infoNumber.value = 0;
return;
}
if (targetNumber.value !== -1) {
targetNumber.value--;
ensureVisible(targetNumber.value);
}
break;
case 4:
if (infoNumber.value === 1) {
rename(targetNumber.value, cardarray.value[targetNumber.value]);
return;
}
if (targetNumber.value === -1) {
cantoggleRun();
} else {
infoNumber.value = 0;
}
break;
case 5:
if (infoNumber.value !== -1) {
infoNumber.value = -1;
} else {
goback();
}
break;
}
};
common_vendor.onBeforeUnmount(() => {
if (rafId != null)
caf(rafId);
stopBallGeneration();
});
function ensureVisible(index) {
const count2 = cardarray.value.length;
const COLS = 2;
const ROW_HEIGHT = 245;
const SCROLL_HEIGHT = 475;
if (index < 0)
index = 0;
if (index >= count2)
index = count2 - 1;
common_vendor.nextTick$1(() => {
const rowIndex = Math.floor(index / COLS);
const rowTop = rowIndex * ROW_HEIGHT;
const rowBottom = rowTop + ROW_HEIGHT;
const visibleTop = scrollTop.value;
const visibleBottom = visibleTop + SCROLL_HEIGHT;
let newTop = scrollTop.value;
if (rowTop < visibleTop) {
newTop = rowTop;
} else if (rowBottom > visibleBottom) {
newTop = rowBottom - SCROLL_HEIGHT;
}
const totalRows = Math.ceil(count2 / COLS);
const totalHeight = totalRows * ROW_HEIGHT;
const maxTop = Math.max(0, totalHeight - SCROLL_HEIGHT);
if (newTop < 0)
newTop = 0;
if (newTop > maxTop)
newTop = maxTop;
scrollTop.value = Math.round(newTop);
});
}
return (_ctx, _cache) => {
return common_vendor.e({
a: `/static/index/settings/back.png`,
b: common_vendor.o(goback),
c: common_assets._imports_0$7,
d: common_assets._imports_1$4,
e: common_assets._imports_2$3,
f: common_assets._imports_3$1,
g: common_assets._imports_4$1,
h: common_vendor.s(insetStyle.value),
i: common_vendor.f(balls.value, (ball, k0, i0) => {
return {
a: ball.id,
b: ball.size + "px",
c: ball.size + "px",
d: ball.top + "px",
e: ball.left + "px",
f: ball.color,
g: ball.opacity
};
}),
j: common_vendor.t(count.value === 100 ? `扫描` : `扫描`),
k: common_vendor.n(targetNumber.value == -1 ? "zerotarget" : ""),
l: common_vendor.o(cantoggleRun),
m: count.value + "%",
n: common_vendor.t(count.value),
o: common_vendor.f(cardarray.value, (allitem, allindex, i0) => {
return {
a: common_vendor.t(allitem.nuName),
b: common_vendor.o(() => {
}, allindex),
c: common_vendor.n(targetNumber.value === allindex && infoNumber.value === 0 ? "zerotarget" : ""),
d: common_vendor.n(targetNumber.value === allindex && infoNumber.value === 1 ? "zerotarget" : ""),
e: common_vendor.o(($event) => rename(allindex, allitem), allindex),
f: common_vendor.t(allitem.nuId),
g: allindex,
h: common_vendor.n(targetNumber.value === allindex && infoNumber.value === -1 ? "zerotarget" : ""),
i: common_vendor.n({
"fade-in": allitem.isNew
}),
j: common_vendor.o(($event) => onAnimEnd(allitem), allindex)
};
}),
p: common_assets._imports_5$3,
q: renamenummber.value !== -1
}, renamenummber.value !== -1 ? {
r: common_vendor.o(($event) => renamenummber.value = -1),
s: common_vendor.t(savenuId.value),
t: savevalue.value,
v: common_vendor.o(($event) => savevalue.value = $event.detail.value),
w: savevalue.value,
x: common_assets._imports_5$2,
y: common_vendor.o(($event) => savevalue.value = ``),
z: common_vendor.o(($event) => changename(savevalue.value, renamenummber.value)),
A: common_vendor.s(isdonghua.value ? {
opacity: 1
} : {
opacity: 0
})
} : {}, {
B: scrollTop.value,
C: common_vendor.o(movecard)
});
};
}
});
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-53a8654b"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/watch/settings/leida.js.map