feat: 优化在微信小程序中接口返回的错误信息 会被uni.hideLoading取消展示错误信息问题

master
学习很差啦 2023-04-11 18:41:34 +08:00
parent c070ed01f7
commit 2bdb8682e1
38 changed files with 70 additions and 58 deletions

View File

@ -98,7 +98,7 @@
}) : "",
getAllCoupons(submitData)
.then((res) => {
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
uni.stopPullDownRefresh();
if (res.data.code == 200) {
//
@ -113,7 +113,7 @@
}
})
.catch((err) => {
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
});
},
/**

View File

@ -217,7 +217,7 @@ export default {
this.navList[index].dataList.push(...data);
}
}
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
});
},

View File

@ -244,7 +244,7 @@
//
await API_Trade.initiatePay(paymentMethod, paymentClient, params).then(
(signXml) => {
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
//
if (!signXml.data.success) {
uni.showToast({
@ -334,7 +334,7 @@
}
}
);
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
} else {
window.location.href = JSON.parse(response.result).h5_url;
const searchParams = {
@ -352,7 +352,7 @@
})
},3000)
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
}
} else if (paymentMethod === "WALLET") {
uni.showToast({

View File

@ -204,7 +204,7 @@ export default {
this.goodsDetail = response.data.result.data;
this.selectedGoods = response.data.result.data;
this.goodsSpec = response.data.result.specs;
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
this.PromotionList = response.data.result.promotionMap;
//

View File

@ -133,7 +133,7 @@ export default {
this.form.consigneeAddressPath = val.data.result.name; // ''
this.form.lat = val.latitude; //
this.form.lon = val.longitude; //
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
}
this.mapFlag = !this.mapFlag; //
@ -276,10 +276,10 @@ export default {
params.___path = params.consigneeAddressPath;
this.$set(this, "form", params);
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
});
}
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
},
// rulesonReadyonLoad
onReady() {

View File

@ -101,7 +101,7 @@ export default {
this.addressList = res.data.result.records;
console.log(this.addressList);
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
});
},
//

View File

@ -103,7 +103,7 @@ export default {
});
this.addressList = res.data.result.records;
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
});
},
//

View File

@ -76,7 +76,7 @@ export default {
this.storeAddressList = res.data.result.records;
console.log(this.storeAddressList);
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
});
},
},

View File

@ -96,7 +96,7 @@ export default {
this.status = "nomore";
this.empty = true;
}
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
});
},
//
@ -111,7 +111,7 @@ export default {
this.status = "nomore";
this.empty = true;
}
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
});
},
},

View File

@ -78,7 +78,7 @@ export default {
if (res.data.result) {
this.distributionData = res.data.result;
}
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
});
},
},

View File

@ -75,7 +75,7 @@ export default {
if (res.data.result) {
this.distributionData = res.data.result;
}
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
});
},
},

View File

@ -110,7 +110,7 @@ export default {
title: "加载中",
});
getTalkList(params).then((res) => {
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
if (res.data.success) {
this.talkList = res.data.result;
console.log(this.talkList, 'this.talkListthis.talkList');

View File

@ -58,7 +58,7 @@ export default {
title:"加载中"
})
API_Message.getLogisticsMessages(this.params).then(async response => {
uni.hideLoading()
if (this.$store.state.isShowToast){ uni.hideLoading() }
const { data } = response
if (!data || !data.length) {
this.messageList.push(...data.data)

View File

@ -59,7 +59,7 @@ export default {
title: "加载中"
});
API_Message.getMessages(this.params).then(async response => {
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
const { data } = response;
if (!data || !data.length) {
this.messageList.push(...data.data);

View File

@ -197,7 +197,7 @@
title: "加载中",
});
getGoodsCollection(this.navList[0].params, "GOODS").then((res) => {
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
uni.stopPullDownRefresh();
if (res.data.success) {
let data = res.data.result;
@ -225,7 +225,7 @@
title: "加载中",
});
getGoodsCollection(this.navList[1].params, "store").then((res) => {
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
uni.stopPullDownRefresh();
if (res.data.success) {
let data = res.data.result;

View File

@ -114,7 +114,7 @@
});
myTrackList(this.params).then((res) => {
uni.stopPullDownRefresh();
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
if (res.statusCode == 200) {
res.data.result.records.length &&
res.data.result.records.forEach((item) => {

View File

@ -72,7 +72,7 @@ export default {
title: "加载中",
});
getPointsData(params).then((res) => {
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
if (res.data.success) {
let data = res.data.result.records;
if (data.length < 10) {

View File

@ -115,7 +115,7 @@
title: "正在获取验证码",
});
sendMobile(this.codeForm.mobile, "FIND_USER").then((res) => {
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
// this.start()
if (res.data.success) {
this.$refs.uCode.start();

View File

@ -636,7 +636,7 @@ export default {
this.goodsList.push(...goodsList.data.result.records);
this.initSortGoods();
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
},
//

View File

@ -309,7 +309,7 @@ export default {
mask: true,
});
getOrderList(this.params).then((res) => {
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
const orderList = res.data.result.records;
if (orderList.length > 0) {
this.orderList = this.orderList.concat(orderList);
@ -345,7 +345,7 @@ export default {
this.orderList = [];
this.searchOrderList(this.current);
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
},
/**

View File

@ -224,7 +224,7 @@ export default {
this.reasonList = action;
}
});
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
},
//
showCitySelect() {
@ -288,7 +288,7 @@ export default {
this.form.applyRefundPrice = this.applyInfo.applyRefundPrice;
applyReturn(this.sn, this.form).then((resp) => {
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
if (resp.data.success) {
this.$refs.uToast.show({ title: "提交成功", type: "success" });
uni.redirectTo({

View File

@ -128,7 +128,7 @@ export default {
});
delete this.form.courierCompany;
fillShipInfo(this.serviceDetail.sn, this.form).then((res) => {
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
if (res.statusCode === 200) {
this.$refs.uToast.show({
title: "提交成功",

View File

@ -352,7 +352,7 @@ export default {
title: "加载中",
});
getServiceDetail(this.sn).then((res) => {
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
this.serviceDetail = res.data.result;
if (
this.serviceDetail.serviceType == "RETURN_GOODS" ||

View File

@ -178,7 +178,7 @@ export default {
this.order = order.order;
this.orderGoodsList = order.orderItems;
this.orderDetail = res.data.result;
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
});
},

View File

@ -95,7 +95,7 @@ export default {
icon: "none",
});
}
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
});
},
},

View File

@ -140,7 +140,7 @@ export default {
} else {
this.empty = true;
}
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
});
},
},

View File

@ -202,7 +202,7 @@ export default {
title: "加载中",
});
getOrderList(this.params).then((res) => {
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
const orderList = res.data.result.records;
if (orderList.length < 10) {
this.params.loadStatus = "noMore";
@ -234,7 +234,7 @@ export default {
title: "加载中",
});
getComments(this.params).then((res) => {
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
let orderList = res.data.result.records;
if (orderList.length < 10) {
this.params.loadStatus = "noMore";

View File

@ -137,7 +137,7 @@ export default {
title: "加载中",
});
commentsMemberOrder(this.form).then((res) => {
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
if (res.data.success) {
uni.showToast({
title: "发布评价成功",

View File

@ -373,7 +373,7 @@ export default {
});
await this.getOrderList();
await this.getDistribution();
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
if (this.routerVal.way == "PINTUAN") {
this.isAssemble = true;
this.routerVal.parentOrder = JSON.parse(

View File

@ -392,7 +392,7 @@ export default {
if (res.data.result.length >= 1) {
this.cancelList = res.data.result;
}
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
});
},
@ -473,7 +473,7 @@ export default {
});
setTimeout(() => {
this.navList[this.tabCurrentIndex].orderList.splice(index, 1);
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
}, 600);
},
//
@ -493,7 +493,7 @@ export default {
let list = this.navList[1].orderList;
let index = list.findIndex((val) => val.id === item.id);
index !== -1 && list.splice(index, 1);
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
}, 600);
},

View File

@ -361,7 +361,7 @@ export default {
if (this.order.deliveryMethod === 'LOGISTICS') {
this.loadLogistics(sn)
}
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
});
},
@ -413,7 +413,7 @@ export default {
});
setTimeout(() => {
this.navList[this.tabCurrentIndex].orderList.splice(index, 1);
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
}, 600);
},
//
@ -427,7 +427,7 @@ export default {
if (res.data.result.length >= 1) {
this.cancelList = res.data.result;
}
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
});
this.cancelShow = true;

View File

@ -321,7 +321,7 @@
//
uni.showLoading({});
let res = await sendMobile(this.mobile);
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
// this.start()
if (res.data.success) {
this.current = 1;
@ -708,7 +708,7 @@
clearInterval(timer);
}, 100);
}
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
}
if (!this.flage) {
this.$refs.verification.error(); //

View File

@ -70,7 +70,7 @@ export default {
title: "请填写内容!",
icon: "none",
});
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
return false;
}
API_MEM.consultating(
@ -86,11 +86,11 @@ export default {
});
this.askValue = "";
}
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
})
.catch((err) => {
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
});
},
radioGroupChange(e) {

View File

@ -1,7 +1,7 @@
<template>
<div class="wrapper">
<!-- 空白页-->
<view v-if="cartDetail.cartList == '' || cartDetail.cartList == [] || !cartDetail" class="empty">
<view v-if="!loading && (cartDetail.cartList == '' || cartDetail.cartList == [] || !cartDetail)" class="empty">
<image src="/static/emptyCart.png" mode="aspectFit"></image>
<view class="empty-tips">
空空如也
@ -184,6 +184,7 @@ import { debounce } from "@/utils/tools.js";
export default {
data() {
return {
loading:false,
lightColor: this.$lightColor,
discountDetailsFlag: false, //
//
@ -508,6 +509,7 @@ export default {
});
API_Trade.getCarts()
.then((result) => {
this.loading = false;
uni.stopPullDownRefresh();
if (result.data.success) {
this.cartDetail = result.data.result;
@ -541,10 +543,10 @@ export default {
uni.stopPullDownRefresh();
}
})
.catch((err) => {});
uni.hideLoading();
.catch((err) => {this.loading = false;});
if (this.$store.state.isShowToast){ uni.hideLoading() };
} else {
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
}
},

View File

@ -56,7 +56,7 @@
})
this.params.keyword = this.goods.goodsName;
getGoodsList(this.params).then(res => {
uni.hideLoading()
if (this.$store.state.isShowToast){ uni.hideLoading() }
if (res.statusCode == 200) {
let data = res.data;
if (data.data_total == 0) {

View File

@ -6,6 +6,7 @@ Vue.use(Vuex);
const store = new Vuex.Store({
state: {
isShowToast:false, // 是否在展示Toast中
shareLink:"", //分享链接
verificationKey: "", //获取key表示验证通过
distributionId:"", //分销员Id 如果当前账户从未登录过时记录

View File

@ -11,7 +11,7 @@ import api from "@/config/api.js";
import uuid from "@/utils/uuid.modified.js";
import jwt from '@/js_sdk/t-jwt/jwt.js'
import store from "../store";
let isNavigateTo = false
@ -131,7 +131,7 @@ http.interceptors.response.use(
// cleanStorage();
// isRefreshing = false;
// }
uni.showLoading() ? uni.hideLoading() : ''
let token = storage.getAccessToken();
if (
(token && response.statusCode === 403) ||
@ -196,6 +196,15 @@ http.interceptors.response.use(
title: response.data.message,
icon: "none",
duration: 1500,
success: function () {
store.state.isShowToast = true;
},
fail: function () {
store.state.isShowToast = false;
},
complete: function () {
store.state.isShowToast = false;
}
});
}
}

View File

@ -417,7 +417,7 @@ export default {
this.uploadError(index, e);
},
complete: res => {
uni.hideLoading();
if (this.$store.state.isShowToast){ uni.hideLoading() };
this.uploading = false;
this.uploadFile(index + 1);
this.$emit('on-change', res, index, this.lists);