"use strict"; const common_vendor = require("../../common/vendor.js"); const _sfc_main = { data() { return { phone: "", code: "", //时间标志 time: null, //倒计时数字 timeCount: 60, //显示倒计时还是发送验证码 sendCodeFlag: "发送验证码", userId: "", resultId: "" }; }, onLoad(options) { if (options.userId && options.resultId) { this.userId = options.userId; this.resultId = options.resultId; } }, onUnload() { clearInterval(this.time); this.phone = ""; this.code = ""; this.timeCount = 60; this.sendCodeFlag = "发送验证码"; }, methods: { //对手机号进行校验 checkPhone() { var phoneReg = /^[1][3,4,5,7,8][0-9]{9}$/; if (phoneReg.test(this.phone)) { return true; } else { common_vendor.index.showToast({ title: "请输入正确手机号", icon: "error" }); return false; } }, sendCode() { if (!this.checkPhone()) { return; } if (this.sendCodeFlag == "重新发送" || this.sendCodeFlag == "发送验证码") { this.timeCount = 60; clearInterval(this.time); this.sendCodeFlag = this.timeCount + "s"; this.time = setInterval(() => { this.timeCount -= 1; this.sendCodeFlag = this.timeCount + "s"; if (this.timeCount == 0) { clearInterval(this.time); this.sendCodeFlag = "重新发送"; } }, 1e3); this.$request.get({ url: "user/authCode", loadingTip: "加载中...", data: { phone: this.phone } }).then((res) => { common_vendor.index.showToast({ title: "验证码已发送", icon: "success" }); }); } }, // 绑定手机号并查看报告 saveAndView() { if (this.checkPhone() && this.code != "") { this.$request.get({ url: "user/updateMobile", loadingTip: "加载中...", data: { id: this.userId, mobile: this.phone, authCode: this.code } }).then((res) => { if (res.code == 200) { common_vendor.index.showToast({ icon: "success", title: "保存成功" }); common_vendor.index.navigateTo({ url: `/scaleTestResults/testResults/index?resultId=${this.resultId}&messageShare=1` }); } else { common_vendor.index.showToast({ icon: "none", title: res.msg }); } }); } } } }; if (!Array) { const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput"); _easycom_uni_easyinput2(); } const _easycom_uni_easyinput = () => "../../node-modules/@dcloudio/uni-ui/lib/uni-easyinput/uni-easyinput.js"; if (!Math) { _easycom_uni_easyinput(); } function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return { a: common_vendor.o(($event) => $options.checkPhone()), b: common_vendor.o(($event) => $data.phone = $event), c: common_vendor.p({ trim: "all", placeholder: "请输入手机号", ["placeholder-style"]: "font-size:32rpx", modelValue: $data.phone }), d: common_vendor.t($data.sendCodeFlag), e: common_vendor.o(($event) => $options.sendCode()), f: common_vendor.o(($event) => $data.code = $event), g: common_vendor.p({ placeholder: "请输入验证码", ["placeholder-style"]: "font-size:32rpx", modelValue: $data.code }), h: common_vendor.o(($event) => $options.saveAndView()) }; } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-25e10d82"], ["__file", "E:/psy_web_share/paymentPage/phoneSave/index.vue"]]); tt.createPage(MiniProgramPage);