Commit c394f8c5 authored by yyh's avatar yyh

存证详情bugfix

parent c2ff9f86
...@@ -37,11 +37,11 @@ export default class ProofItem extends Vue { ...@@ -37,11 +37,11 @@ export default class ProofItem extends Vue {
} }
get statusStr() { get statusStr() {
let {status} = this.proof;
return { return {
text: ChainStatusStr[this.proof.status], text: ChainStatusStr[status],
class: classEnum[this.proof.status], class: classEnum[status],
}; };
// ChainStatusStr[this.proof.status];
} }
} }
</script> </script>
......
...@@ -6,7 +6,18 @@ import axios from 'axios'; ...@@ -6,7 +6,18 @@ import axios from 'axios';
import router from '../router'; import router from '../router';
import store from '../store/index'; import store from '../store/index';
import { Toast } from 'vant'; import { Toast } from 'vant';
import user from '@/api/user'; let pendingAjax: any = [];
const fastClickMsg = '数据请求中,请稍后';
const CancelToken = axios.CancelToken;
const removePendingAjax = (config: any, c?: any) => {
const url = config.url;
const index = pendingAjax.findIndex((i: any) => i === url);
if (index > -1) {
c ? c(fastClickMsg) : pendingAjax.splice(index, 1);
} else {
c && pendingAjax.push(url);
}
};
/** /**
* 提示函数 * 提示函数
* 禁止点击蒙层、显示一秒后关闭 * 禁止点击蒙层、显示一秒后关闭
...@@ -75,6 +86,10 @@ instance.interceptors.request.use( ...@@ -75,6 +86,10 @@ instance.interceptors.request.use(
// 后台根据携带的token判断用户的登录情况,并返回给我们对应的状态码 // 后台根据携带的token判断用户的登录情况,并返回给我们对应的状态码
// 而后我们可以在响应拦截器中,根据状态码进行一些统一的操作。 // 而后我们可以在响应拦截器中,根据状态码进行一些统一的操作。
// token && (config.headers.Authorization = token); // token && (config.headers.Authorization = token);
config.cancelToken = new CancelToken((c) => {
removePendingAjax(config, c);
});
let userInfo = localStorage.getItem('userInfo'); let userInfo = localStorage.getItem('userInfo');
userInfo = userInfo ? JSON.parse(userInfo) : {}; userInfo = userInfo ? JSON.parse(userInfo) : {};
config.headers.Authorization = (userInfo as any ).token || ''; config.headers.Authorization = (userInfo as any ).token || '';
...@@ -86,6 +101,7 @@ instance.interceptors.request.use( ...@@ -86,6 +101,7 @@ instance.interceptors.request.use(
instance.interceptors.response.use( instance.interceptors.response.use(
// 请求成功 // 请求成功
(res: any) => { (res: any) => {
removePendingAjax(res.config);
if ( res.status === 200) { if ( res.status === 200) {
if (res.data.code === 200) { if (res.data.code === 200) {
return Promise.resolve(res.data.data); return Promise.resolve(res.data.data);
...@@ -116,6 +132,8 @@ instance.interceptors.response.use( ...@@ -116,6 +132,8 @@ instance.interceptors.response.use(
} else { } else {
if (error.message.includes('timeout')) { if (error.message.includes('timeout')) {
tip('请求超时'); tip('请求超时');
} else {
tip(error.message);
} }
return Promise.reject(error); return Promise.reject(error);
} }
......
...@@ -92,11 +92,11 @@ export default class ProofDetail extends Vue { ...@@ -92,11 +92,11 @@ export default class ProofDetail extends Vue {
key: '存证名称', key: '存证名称',
label: '存证名称', label: '存证名称',
}; };
this.detail = [this.detail, nameType]; let detail = [this.detail, nameType];
if (this.id) { if (this.id) {
await this.$api.proof.update(this.id, this.name, this.detail); await this.$api.proof.update(this.id, this.name, detail);
} else { } else {
await this.$api.proof.add(this.name, this.detail); await this.$api.proof.add(this.name, detail);
} }
this.checkEdited = false; this.checkEdited = false;
this.$router.push({name: 'ProofList'}); this.$router.push({name: 'ProofList'});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment