import Api from "../../../api/index.js" import { requestFnc } from "../../../utils/request.js" import { getStore } from "../../../utils/index.js" let timeInterVal = null Page({ data: { vehicle_code_info: "", cpuInfo: {}, obus: {}, imgCode: "", identitys: { number: getStore("mobile"), imgCode: "", }, disabled: false, notifyMsg: "", showNotify: false, isLoading: false, cpuInfo: {}, obus: {}, smsName: "获取验证码", carType: getStore("carType"), orderNo: "", steps:["注销申请","注销审核","注销确认"], stepsIndex:2 }, onLoad: function (options) { let { afterOrderNo = "" } = options this.setData({ orderNo: afterOrderNo, }) this.getCode() }, onUnload: function () { timeInterVal && clearInterval(timeInterVal) }, // 获取签信息 getObuInfo() { let params = { filename: Api.getObuInfo.filename, data: { plateNum: getStore("plateNum"), plateColor: getStore("plateColor"), accountId: getStore("accountId"), }, } requestFnc( Api.getObuInfo.url, params, (res) => { let { data = [] } = res let { obuId = "" } = data[0] this.setData({ obus: { obuId, }, }) }, (error) => { this.setData({ obus: { obuId: "", }, }) } ) }, // 获取卡信息 getCpuInfo() { let params = { data: { plateNum: getStore("plateNum"), plateColor: getStore("plateColor"), accountId: getStore("accountId"), }, filename: Api.getCpuInfo.filename, } requestFnc( Api.getCpuInfo.url, params, (res) => { let { data = [] } = res let { cardId = "", status } = data[0] this.setData({ cpuInfo: { cardId, }, }) }, (error) => { this.setData({ cpuInfo: { cardId: "", }, }) } ) }, onSubmitAction() { const { identitys = {} } = this.data let { code = "" } = identitys let msg = "" if (!code) { msg = "请输入手机验证码" } if (msg) { this.setData({ notifyMsg: msg, showNotify: true, }) setTimeout(() => { this.setData({ showNotify: false, }) }, 2 * 1000) return } this.aftersalesWriteoffReq() }, aftersalesWriteoffReq() { this.setData({ isLoading: true, }) let params = { filename: Api.aftersalesWriteoffReq.filename, data: { accountId: getStore("accountId"), openId: getStore("openId"), code: this.data.identitys.code, orderNo: this.data.orderNo, }, } requestFnc( Api.aftersalesWriteoffReq.url, params, (res) => { wx.redirectTo({ url: "plugin://issuer-plugin/logOffResult", }) }, () => { this.setData({ isLoading: false, }) } ) }, // 获取图形验证码 getCode() { let params = { filename: Api.getImgCode.filename, data: { mobile: this.data.identitys.number, }, } requestFnc(Api.getImgCode.url, params, (res) => { console.log("获取图形验证码res", res) this.setData({ imgCode: res.authCode, }) }) }, onSend() { console.log("this.data", this.data) if (!this.data.disabled) this.getSsoSendlossmsgReq() }, getSsoSendlossmsgReq() { let params = { filename: Api.getSsoSendlossmsgReq.filename, data: { accountId: getStore("accountId"), authCode: this.data.identitys.imgCode, }, } requestFnc(Api.getSsoSendlossmsgReq.url, params, (res) => { let countdown = 60 timeInterVal = setInterval(() => { countdown = countdown - 1 console.log("countdown", countdown, countdown === 0) this.setData({ smsName: `重新获取(${countdown}s)`, }) if (countdown === 0) { clearInterval(timeInterVal) timeInterVal = null this.setData({ disabled: false, smsName: "获取验证码", }) } }, 1000) this.setData({ disabled: true, }) }) }, changeInput(e) { let key = e.currentTarget.dataset.type this.data.identitys[key] = e.detail this.setData({ identitys: { ...this.data.identitys, }, }) }, })