123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const _sfc_main = {
- data() {
- return {
- newPhone: "",
- code: "",
- countdown: 0,
- timer: null
- };
- },
- methods: {
- sendCode() {
- if (!/^1[3-9]\d{9}$/.test(this.newPhone)) {
- common_vendor.index.showToast({ title: "请输入正确手机号", icon: "none" });
- return;
- }
- common_vendor.index.request({
- url: "http://localhost:9527/api/sendCode",
- method: "POST",
- data: { phone: this.newPhone }
- });
- common_vendor.index.showToast({ title: "验证码已发送", icon: "success" });
- this.countdown = 60;
- this.timer = setInterval(() => {
- this.countdown--;
- if (this.countdown <= 0)
- clearInterval(this.timer);
- }, 1e3);
- },
- submit() {
- if (!/^1[3-9]\d{9}$/.test(this.newPhone)) {
- common_vendor.index.showToast({ title: "请输入正确手机号", icon: "none" });
- return;
- }
- if (!/^\d{6}$/.test(this.code)) {
- common_vendor.index.showToast({ title: "请输入6位验证码", icon: "none" });
- return;
- }
- common_vendor.index.request({
- url: "http://localhost:9527/api/updatePhone",
- method: "POST",
- data: {
- uid: common_vendor.index.getStorageSync("uid"),
- phone: this.newPhone,
- code: this.code
- },
- success: (res) => {
- if (res.statusCode === 200 && res.data.code === 200) {
- common_vendor.index.showToast({ title: "更换成功", icon: "success" });
- setTimeout(() => common_vendor.index.navigateBack(), 1e3);
- } else {
- common_vendor.index.showToast({ title: res.data.message || "更换失败", icon: "none" });
- }
- }
- });
- }
- },
- onUnload() {
- if (this.timer)
- clearInterval(this.timer);
- }
- };
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
- return {
- a: $data.newPhone,
- b: common_vendor.o(($event) => $data.newPhone = $event.detail.value),
- c: $data.code,
- d: common_vendor.o(($event) => $data.code = $event.detail.value),
- e: common_vendor.t($data.countdown > 0 ? $data.countdown + "s" : "获取验证码"),
- f: $data.countdown > 0,
- g: common_vendor.o((...args) => $options.sendCode && $options.sendCode(...args)),
- h: common_vendor.o((...args) => $options.submit && $options.submit(...args))
- };
- }
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-a44ae884"]]);
- wx.createPage(MiniProgramPage);
- //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/mine/changePhone.js.map
|