提交 5088d967 authored 作者: 龙菲's avatar 龙菲

修改多个接口返回错误信息提示为仅提示一次

上级 d7b9b70d
......@@ -28,7 +28,10 @@ Vue.use(ElementUI);
// 全局注册动画效果
Vue.use(animated);
// 全局注册修改图片链接方法
Vue.prototype.$getFullUrl = getFullUrl
new Vue({
router,
store,
......
......@@ -4,14 +4,15 @@ import {
Message
} from 'element-ui'
import store from '@/store'
import messageup from './resetMessage'
import {
getToken
} from '@/utils/auth'
console.log('process.env',process.env);
console.log('process.env', process.env);
// create an axios instance
const service = axios.create({
baseURL: process.env.VUE_APP_BASE_API,
timeout: 1000 *10,
timeout: 1000 * 10,
})
// request interceptor
service.interceptors.request.use(
......@@ -39,37 +40,47 @@ service.interceptors.response.use(
// debugger
// if the custom code is not 20000, it is judged as an error.
if (res.code !== 0) {
Message({
message: res.msg || 'Error',
// Message({
// message: res.msg || 'Error',
// type: 'error',
// duration: 5 * 1000
// })
// 401001l令牌过期;
messageup({
type: 'error',
duration: 5 * 1000
showClose: true,
message: res.msg || 'Error'
})
// 401001l令牌过期;
if (res.code === 401001) {
// MessageBox.confirm('登录令牌已过期,请重新登录', '确认退出', {
// confirmButtonText: '重新登录',
// cancelButtonText: '取消',
// type: 'warning'
// }).then(() => {
// if (res.code === 401001) {
// // MessageBox.confirm('登录令牌已过期,请重新登录', '确认退出', {
// // confirmButtonText: '重新登录',
// // cancelButtonText: '取消',
// // type: 'warning'
// // }).then(() => {
// // store.dispatch('user/resetToken').then(() => {
// // location.reload()
// // })
// // })
// store.dispatch('user/resetToken').then(() => {
// location.reload()
// })
// // window.location.reload()
// })
store.dispatch('user/resetToken').then(() => {
// window.location.reload()
})
}
// }
return Promise.reject(new Error(res.msg || 'Error'))
} else {
return res
}
},
error => {
console.log('err' + error) // for debug
Message({
message: error.msg || '网络连接错误,请稍后重试',
// console.log('err' + error) // for debug
// Message({
// message: error.msg || '网络连接错误,请稍后重试',
// type: 'error',
// duration: 5 * 1000
// })
messageup({
type: 'error',
duration: 5 * 1000
showClose: true,
message:error.msg || '网络连接错误,请稍后重试'
})
return Promise.reject(error)
}
......
/**重置message,防止重复点击重复弹出message弹框 */
import { Message } from 'element-ui';
let messageInstance = null;
const resetMessage = (options) => {
if(messageInstance) {
messageInstance.close()
}
messageInstance = Message(options)
};
['error','success','info','warning'].forEach(type => {
resetMessage[type] = options => {
if(typeof options === 'string') {
options = {
message:options
}
}
options.type = type
return resetMessage(options)
}
})
let messageup
export default messageup = resetMessage
\ No newline at end of file
......@@ -434,23 +434,13 @@ export default {
return crPics;
},
},
watch: {
curentUnitPicIndex(value) {
console.log(this.unitPics[value]);
console.log(
`@/assets/imgs/boutique/smgz/3_hall/hall_pics/${
this.curentUnitPicIndex + 1
}-${1}.png`
);
},
},
// mounted() {
// },
methods: {
handleChangeUnit(item) {
this.curentUnitPicIndex = item.index;
this.$refs.mySwiper.swiper.activeIndex = 0;
this.$refs.mySwiper.swiper.realIndex = 0;
console.log('this.$refs.mySwiper.',this.$refs.mySwiper.swiper);
// this.$refs.mySwiper.swiper.slideTo(0)
},
handleChangeCr(item) {
this.curentUnitCrIndex = item.index;
......
<template>
<div class="ccproduct-detail">
<div class="back" @click="handleBack">
<!-- <div class="back" @click="handleBack">
<svg-icon icon-class="mz-fh"></svg-icon>
返回上页</div>
返回上页</div> -->
<div class="wrapper">
<div class="header">
<div class="dc-left wow animate__animated animate__fadeInLeft">
......
......@@ -230,11 +230,11 @@ export default {
handleClick(item) {
const { bccpId } = item;
// const newPage = this.$router.resolve({
// path: "ccProduct/" + bccpId,
// });
// window.open(newPage.href, "_blank");
this.$router.push(`ccProduct/${bccpId}`);
const newPage = this.$router.resolve({
path: "ccProduct/" + bccpId,
});
window.open(newPage.href, "_blank");
// this.$router.push(`ccProduct/${bccpId}`);
},
handleClickThreeD() {
this.onlyShow3d = !this.onlyShow3d;
......
<template>
<div class="cultural-relic">
<ListBanner title="精选文物" />
<ListBanner title="文物展" />
<div class="content-wrapper">
<div class="content">
<div class="search wow animate__animated animate__fadeIn">
......
<template>
<div class="display">
<!-- <NavBar /> -->
<ListBanner title="精选展览" />
<ListBanner title="展览展示" />
<div class="content-wrapper">
<div class="content">
<div class="search wow animate__animated animate__fadeIn">
......@@ -243,11 +243,11 @@ export default {
handleClick(item) {
const { themeType, exhibitionId } = item;
// const newPage = this.$router.resolve({
// path: `display/${themeType}/${exhibitionId}`,
// });
// window.open(newPage.href, "_blank");
this.$router.push(`display/${themeType}/${exhibitionId}`);
const newPage = this.$router.resolve({
path: `display/${themeType}/${exhibitionId}`,
});
window.open(newPage.href, "_blank");
// this.$router.push(`display/${themeType}/${exhibitionId}`);
},
defImg(e) {
e.target.src = require("@/assets/404_images/no-pic.png");
......
......@@ -2,10 +2,10 @@
<template>
<div class="museum-detail">
<div class="wrapper">
<div class="back" @click="handleBack">
<!-- <div class="back" @click="handleBack">
<svg-icon icon-class="mz-fh"></svg-icon>
<span>返回上页 </span>
</div>
</div> -->
<el-row class="detail-container" :gutter="10">
<el-col class="cr-images" :span="24">
<el-image
......
......@@ -207,13 +207,13 @@ export default {
},
handleClick(item) {
const { id } = item;
// const newPage = this.$router.resolve({
// path: `museum/${id}`,
// });
// window.open(newPage.href, "_blank");
this.$router.push({
const newPage = this.$router.resolve({
path: `museum/${id}`,
});
window.open(newPage.href, "_blank");
// this.$router.push({
// path: `museum/${id}`,
// });
},
handleTypeChange(value) {
......
......@@ -49,7 +49,7 @@ module.exports = defineConfig({
proxy: {
'/api': {
// target: 'http://192.168.1.230:9562/api',
target: 'http://222.85.214.245:9602/api',
target: 'http://222.85.214.245:9602',
// target:'http://192.168.1.230:9562/api',
changeOrigin: true,
pathRewrite: {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论