| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const store_user = require("../../store/user.js");
- const api_login = require("../../api/login.js");
- const utils_is = require("../../utils/is.js");
- const utils_utils = require("../../utils/utils.js");
- const _sfc_main = {
- __name: "setPhone",
- setup(__props) {
- store_user.useUserStore();
- const phone = common_vendor.ref("");
- const code = common_vendor.ref("");
- const countdown = common_vendor.ref(0);
- let countdownTimer = null;
- const canGetCode = common_vendor.computed(() => {
- return utils_is.isPhone(phone.value);
- });
- const canSubmit = common_vendor.computed(() => {
- return utils_is.isPhone(phone.value) && code.value.length >= 4;
- });
- const handleGetCode = async () => {
- if (countdown.value > 0 || !canGetCode.value) {
- return;
- }
- try {
- const res = await api_login.LoginSendCode({
- phone: phone.value
- });
- common_vendor.index.showToast({
- title: "验证码已发送",
- icon: "success"
- });
- countdown.value = 60;
- countdownTimer = setInterval(() => {
- countdown.value--;
- if (countdown.value <= 0) {
- clearInterval(countdownTimer);
- countdownTimer = null;
- }
- }, 1e3);
- } catch (error) {
- common_vendor.index.__f__("error", "at pages/personal/setPhone.vue:89", "发送验证码失败:", error);
- common_vendor.index.showToast({
- title: (error == null ? void 0 : error.msg) || "发送验证码失败",
- icon: "none"
- });
- }
- };
- const handleSubmit = async () => {
- if (!canSubmit.value) {
- return;
- }
- try {
- common_vendor.index.showToast({
- title: "修改成功",
- icon: "success"
- });
- setTimeout(() => {
- utils_utils.go(-1);
- }, 1500);
- } catch (error) {
- common_vendor.index.__f__("error", "at pages/personal/setPhone.vue:121", "修改手机号失败:", error);
- common_vendor.index.showToast({
- title: (error == null ? void 0 : error.msg) || "修改失败,请重试",
- icon: "none"
- });
- }
- };
- common_vendor.onUnmounted(() => {
- if (countdownTimer) {
- clearInterval(countdownTimer);
- }
- });
- return (_ctx, _cache) => {
- return {
- a: phone.value,
- b: common_vendor.o(($event) => phone.value = $event.detail.value),
- c: code.value,
- d: common_vendor.o(($event) => code.value = $event.detail.value),
- e: common_vendor.t(countdown.value > 0 ? `${countdown.value}秒` : "获取验证码"),
- f: countdown.value > 0 || !canGetCode.value ? 1 : "",
- g: common_vendor.o(handleGetCode),
- h: common_vendor.o(handleSubmit)
- };
- };
- }
- };
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-ad35e069"]]);
- wx.createPage(MiniProgramPage);
- //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/personal/setPhone.js.map
|