Quellcode durchsuchen

优化 话费查询页面加载

test
chenJinxu vor 5 Monaten
Ursprung
Commit
d8c43046d7
1 geänderte Dateien mit 70 neuen und 66 gelöschten Zeilen
  1. +70
    -66
      src/views/card-info/index.vue

+ 70
- 66
src/views/card-info/index.vue Datei anzeigen

@@ -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() {


Laden…
Abbrechen
Speichern