69 lines
2.2 KiB
JavaScript
69 lines
2.2 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const common_assets = require("../../common/assets.js");
|
|
const _sfc_main = {
|
|
__name: "code",
|
|
setup(__props) {
|
|
const phonenumber = common_vendor.ref("");
|
|
const captcha = common_vendor.ref(["", "", "", ""]);
|
|
const focusedIndex = common_vendor.ref(0);
|
|
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) {
|
|
common_vendor.index.__f__("log", "at pages/index/code.vue:103", "提交验证码:", code);
|
|
} else {
|
|
common_vendor.index.__f__("log", "at pages/index/code.vue:106", "验证码未输入完整");
|
|
}
|
|
};
|
|
common_vendor.onLoad((options) => {
|
|
phonenumber.value = options.phonenumber;
|
|
});
|
|
return (_ctx, _cache) => {
|
|
return {
|
|
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
|
|
};
|
|
})
|
|
};
|
|
};
|
|
}
|
|
};
|
|
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
|