"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: `/newScale/EQtest/testResult?resultId=${this.resultId}&messageShare=1` }); } else { common_vendor.index.showToast({ icon: "none", title: res.msg }); } }); } } } }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return { a: common_vendor.o(($event) => $options.checkPhone()), b: $data.phone, c: common_vendor.o(($event) => $data.phone = $event.detail.value), d: $data.code, e: common_vendor.o(($event) => $data.code = $event.detail.value), f: common_vendor.t($data.sendCodeFlag), g: common_vendor.o(($event) => $options.sendCode()), h: common_vendor.o((...args) => $options.saveAndView && $options.saveAndView(...args)) }; } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-02edb9a7"], ["__file", "E:/psy_web_share/newScale/EQtest/paySuccess.vue"]]); tt.createPage(MiniProgramPage);