2025-05-26 16:48:12 +08:00
|
|
|
"use strict";
|
|
|
|
const common_vendor = require("../../common/vendor.js");
|
|
|
|
const common_assets = require("../../common/assets.js");
|
2025-05-28 17:36:42 +08:00
|
|
|
if (!Array) {
|
|
|
|
const _component_transition = common_vendor.resolveComponent("transition");
|
|
|
|
_component_transition();
|
|
|
|
}
|
2025-05-26 16:48:12 +08:00
|
|
|
const _sfc_main = {
|
|
|
|
__name: "code",
|
|
|
|
setup(__props) {
|
|
|
|
const phonenumber = common_vendor.ref("");
|
|
|
|
const captcha = common_vendor.ref(["", "", "", ""]);
|
|
|
|
const focusedIndex = common_vendor.ref(0);
|
2025-05-28 17:36:42 +08:00
|
|
|
const isFadingOut = common_vendor.ref(false);
|
|
|
|
const maskColor = common_vendor.ref("rgba(0, 0, 0, 0.5)");
|
|
|
|
function closeModal() {
|
|
|
|
isFadingOut.value = false;
|
|
|
|
}
|
2025-05-26 16:48:12 +08:00
|
|
|
const handleInput = (index) => {
|
|
|
|
if (captcha.value[index]) {
|
|
|
|
if (index < 3) {
|
|
|
|
focusedIndex.value = index + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let isFour = true;
|
|
|
|
captcha.value.forEach((number) => {
|
|
|
|
if (!number) {
|
|
|
|
isFour = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
common_vendor.nextTick$1(() => {
|
|
|
|
if (isFour) {
|
|
|
|
submitCaptcha();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
const handleKeydown = (index, event) => {
|
|
|
|
if (event.key === "Backspace" && !captcha.value[index]) {
|
|
|
|
if (index > 0) {
|
|
|
|
focusedIndex.value = index - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const submitCaptcha = () => {
|
|
|
|
const code = captcha.value.join("");
|
|
|
|
if (code.length === 4) {
|
2025-05-28 17:36:42 +08:00
|
|
|
common_vendor.index.__f__("log", "at pages/index/code.vue:118", "提交验证码:", code);
|
2025-05-26 16:48:12 +08:00
|
|
|
} else {
|
2025-05-28 17:36:42 +08:00
|
|
|
common_vendor.index.__f__("log", "at pages/index/code.vue:121", "验证码未输入完整");
|
2025-05-26 16:48:12 +08:00
|
|
|
}
|
|
|
|
};
|
2025-05-28 17:36:42 +08:00
|
|
|
const getcode = () => {
|
|
|
|
const url = `https://www.focusnu.com/nursing-unit/sys/randomImage/${Date.now()}`;
|
|
|
|
fetch(url).then((res) => res.json()).then((data) => {
|
|
|
|
common_vendor.index.__f__("log", "at pages/index/code.vue:148", "code测试", data);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
const countdown = common_vendor.ref(60);
|
|
|
|
let timerId = null;
|
|
|
|
common_vendor.onUnmounted(() => {
|
|
|
|
if (timerId) {
|
|
|
|
clearInterval(timerId);
|
|
|
|
}
|
|
|
|
});
|
2025-05-26 16:48:12 +08:00
|
|
|
common_vendor.onLoad((options) => {
|
|
|
|
phonenumber.value = options.phonenumber;
|
2025-05-28 17:36:42 +08:00
|
|
|
getcode();
|
|
|
|
countdown.value = 60;
|
|
|
|
timerId = setInterval(() => {
|
|
|
|
if (countdown.value > 0) {
|
|
|
|
countdown.value--;
|
|
|
|
} else {
|
|
|
|
clearInterval(timerId);
|
|
|
|
timerId = null;
|
|
|
|
}
|
|
|
|
}, 1e3);
|
2025-05-26 16:48:12 +08:00
|
|
|
});
|
|
|
|
return (_ctx, _cache) => {
|
2025-05-28 17:36:42 +08:00
|
|
|
return common_vendor.e({
|
2025-05-26 16:48:12 +08:00
|
|
|
a: common_assets._imports_0,
|
|
|
|
b: common_assets._imports_1,
|
|
|
|
c: common_assets._imports_2,
|
|
|
|
d: common_vendor.t(phonenumber.value),
|
|
|
|
e: common_vendor.f(captcha.value, (digit, index, i0) => {
|
|
|
|
return {
|
|
|
|
a: index < 3 ? "" : " ",
|
|
|
|
b: common_vendor.o([($event) => captcha.value[index] = $event.detail.value, index, ($event) => handleInput(index), index], index),
|
|
|
|
c: common_vendor.o(($event) => handleKeydown(index, $event), index),
|
|
|
|
d: focusedIndex.value === index,
|
|
|
|
e: captcha.value[index],
|
|
|
|
f: index
|
|
|
|
};
|
2025-05-28 17:36:42 +08:00
|
|
|
}),
|
|
|
|
f: !countdown.value,
|
|
|
|
g: common_vendor.t(countdown.value),
|
|
|
|
h: countdown.value,
|
|
|
|
i: common_vendor.o(($event) => isFadingOut.value = true),
|
|
|
|
j: isFadingOut.value
|
|
|
|
}, isFadingOut.value ? {
|
|
|
|
k: common_vendor.o(closeModal),
|
|
|
|
l: maskColor.value
|
|
|
|
} : {}, {
|
|
|
|
m: common_vendor.p({
|
|
|
|
name: "fade"
|
|
|
|
}),
|
|
|
|
n: isFadingOut.value
|
|
|
|
}, isFadingOut.value ? {} : {}, {
|
|
|
|
o: common_vendor.p({
|
|
|
|
name: "slide-up"
|
2025-05-26 16:48:12 +08:00
|
|
|
})
|
2025-05-28 17:36:42 +08:00
|
|
|
});
|
2025-05-26 16:48:12 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-7e06bee2"]]);
|
|
|
|
wx.createPage(MiniProgramPage);
|
|
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/code.js.map
|