提交 3928aea4 authored 作者: 王鹏飞's avatar 王鹏飞

bug fixes

上级 d9a4754b
...@@ -16,18 +16,7 @@ import AppBreadcrumb from './breadcrumb' ...@@ -16,18 +16,7 @@ import AppBreadcrumb from './breadcrumb'
export default { export default {
name: 'AppMain', name: 'AppMain',
props: { hasBreadcrumb: { type: Boolean, default: true } }, props: { hasBreadcrumb: { type: Boolean, default: true } },
components: { AppBreadcrumb }, components: { AppBreadcrumb }
watch: {
$route: {
immediate: true,
handler() {
// 没有shopId
if (!this.$store.state.shopId) {
this.$router.push({ path: '/shop' })
}
}
}
}
} }
</script> </script>
......
...@@ -13,7 +13,6 @@ Vue.use(ElementUI) ...@@ -13,7 +13,6 @@ Vue.use(ElementUI)
/* 导航守卫 */ /* 导航守卫 */
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
before.update(to, from, next) before.update(to, from, next)
next()
}) })
Vue.prototype.msgCenter = new Vue() Vue.prototype.msgCenter = new Vue()
......
...@@ -37,10 +37,16 @@ const store = new Vuex.Store({ ...@@ -37,10 +37,16 @@ const store = new Vuex.Store({
}, },
// 获取店铺信息 // 获取店铺信息
getShop({ commit, state }) { getShop({ commit, state }) {
getShopList({ shop_id: state.shopId }).then(response => { getShopList({ shop_id: state.shopId })
const [first = {}] = response.data || [] .then(response => {
commit('setShop', first) const [first = {}] = response.data || []
}) commit('setShop', first)
})
.catch(() => {
commit('setShop', {})
commit('setShopId', '')
window.localStorage.removeItem('shopId')
})
}, },
// 获取商品分组列表 // 获取商品分组列表
getGroups({ commit, state }) { getGroups({ commit, state }) {
......
import axios from 'axios' import axios from 'axios'
import qs from 'qs' import qs from 'qs'
import { Message } from 'element-ui' import { Message } from 'element-ui'
import router from '@/router'
const httpRequest = axios.create({ const httpRequest = axios.create({
// baseURL: webConf.others.baseUrl, // baseURL: webConf.others.baseUrl,
timeout: 60000, timeout: 60000,
...@@ -35,6 +36,11 @@ httpRequest.interceptors.response.use( ...@@ -35,6 +36,11 @@ httpRequest.interceptors.response.use(
function(response) { function(response) {
const { data } = response const { data } = response
if (data.code) { if (data.code) {
if (data.code === 1002) {
window.localStorage.removeItem('shopId')
router.replace('/shop')
return Promise.reject(data)
}
if (![1010, 1001].includes(data.code)) { if (![1010, 1001].includes(data.code)) {
Message.error(data.msg || data.message) Message.error(data.msg || data.message)
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论