From d8c43046d7ec4ac0f966bb13ebb660a562f86449 Mon Sep 17 00:00:00 2001 From: chenJinxu <2183691628@qq.com> Date: Fri, 21 Jun 2024 15:49:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E8=AF=9D=E8=B4=B9?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=A1=B5=E9=9D=A2=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/card-info/index.vue | 136 +++++++++++++++++----------------- 1 file changed, 70 insertions(+), 66 deletions(-) diff --git a/src/views/card-info/index.vue b/src/views/card-info/index.vue index 9a4e321..6c7c7db 100644 --- a/src/views/card-info/index.vue +++ b/src/views/card-info/index.vue @@ -117,15 +117,11 @@ export default { return /micromessenger/.test(ua); } }, - async created() { + async mounted() { await this.getAuth(); await this.getToken(); - }, - mounted() { - - this.getParams(); - this.getCardInfo(); - + await this.getParams(); + await this.getCardInfo(); }, methods: { // 获取core token @@ -155,32 +151,36 @@ export default { // 获取url传过来的参数 getParams() { let params = this.$route.query; - if (params) { - this.params = { ...params }; - let url = window.location.href.split("?code=")[1]; - if (isNotNull(url) || window.location.href.indexOf("code") > -1) { - let timeStamp = new Date().getTime(); - let code = url.split("&")[0]; - this.code = code; - if (isNotNull(code)) { - this.isShowPage = true; - if (!params.isHasCode) { - this.getOpenId(code); + return new Promise(resolve => { + if (params) { + this.params = { ...params }; + let url = window.location.href.split("?code=")[1]; + if (isNotNull(url) || window.location.href.indexOf("code") > -1) { + let timeStamp = new Date().getTime(); + let code = url.split("&")[0]; + this.code = code; + if (isNotNull(code)) { + this.isShowPage = true; + if (!params.isHasCode) { + this.getOpenId(code); + } + } else { + this.$dialog({ + message: '系统繁忙,请重新进入' + }) } } else { - this.$dialog({ - message: '系统繁忙,请重新进入' - }) - } - } else { - if (this.isWeChat) { - this.getWxCode(); - } else { - this.isShowPage = true; - } + if (this.isWeChat) { + this.getWxCode(); + } else { + this.isShowPage = true; + } + } } - } + resolve(true); + }) + }, getWxCode() { let params = this.params; @@ -215,43 +215,47 @@ export default { //获取小台风物联网卡信息 getCardInfo() { if (!this.isShowPage) { return } - this.$toast.loading({ message: '查询中...' }); - let reqBody = { - imei: this.$route.query.imei, - iccid: this.$route.query.iccid || '' - } - APIWx.GetCardInfo(reqBody) - .then(res => { - let data = res.data; - if (data.stateCode === 1) { - let item = data.data; - this.setMeal.expireTime = item.expireTime == '' ? "" : this.$dayjs(item.expireTime).format("YYYY-MM-DD"); - this.setMeal.residueVoiceData = item.availableVoiceData; - this.setMeal.residueFlow = item.availableData; - this.setMeal.cardState = item.cardState; - this.setMeal.realname = Number(item.realname) === 1 ? '已实名' : '未实名'; - this.setMeal.msisdn = item.msisdn; - // 截取msisdn 前三位, 148 是移动,其它都是联通 - this.setMeal.isUnicom = item.msisdn.slice(0, 3) === '148' ? false : true; - this.$toast.success({ - message: "查询成功", - duration: 1500 - }); - } else { - this.$toast.success({ - message: `${data.message}`, - duration: 1500 - }); - } - }) - .catch(error => { - console.log("接口报错了", error); - }).finally(() => { - setTimeout(() => { - this.$toast.clear(); - }, 1500); - - }) + return new Promise((resolve) => { + this.$toast.loading({ message: '查询中...' }); + let reqBody = { + imei: this.$route.query.imei, + iccid: this.$route.query.iccid || '' + } + APIWx.GetCardInfo(reqBody) + .then(res => { + let data = res.data; + if (data.stateCode === 1) { + let item = data.data; + this.setMeal.expireTime = item.expireTime == '' ? "" : this.$dayjs(item.expireTime).format("YYYY-MM-DD"); + this.setMeal.residueVoiceData = item.availableVoiceData; + this.setMeal.residueFlow = item.availableData; + this.setMeal.cardState = item.cardState; + this.setMeal.realname = Number(item.realname) === 1 ? '已实名' : '未实名'; + this.setMeal.msisdn = item.msisdn; + // 截取msisdn 前三位, 148 是移动,其它都是联通 + this.setMeal.isUnicom = item.msisdn.slice(0, 3) === '148' ? false : true; + this.$toast.success({ + message: "查询成功", + duration: 1500 + }); + } else { + this.$toast.success({ + message: `${data.message}`, + duration: 1500 + }); + } + }) + .catch(error => { + console.log("接口报错了", error); + }).finally(() => { + setTimeout(() => { + this.$toast.clear(); + }, 1500); + + }) + resolve(true) + }) + }, // 返回 onNavBack() {