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

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

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