Merge branch 'feature/task1.0.0' into 'msb_test'

Feature/task1.0.0

See merge request yanxuan-frontend/shop-pc!75
merge-requests/77/merge
肖广 3 years ago
commit 0ed9fc9885

@ -116,6 +116,7 @@
<script>
import { mapState } from "vuex";
import { CATEGROY_LEVEL } from "@/constants";
import { ApiGetHomeSeckill } from "@/plugins/api/seckill";
import HeaderInfoBar from "./HeaderInfoBar.vue";
import HeaderCategory from "./HeaderCategory.vue";
import HeaderCart from "./HeaderCart.vue";
@ -173,7 +174,16 @@ export default {
}
},
},
created() {
this.getSeckillData();
},
methods: {
async getSeckillData() {
const { result } = await ApiGetHomeSeckill();
if (result && result.activityTimeVO) {
this.$store.commit("setSeckillTabVisible", true);
}
},
onLoginClick() {
this.$isLoginValidate();
},

@ -0,0 +1,10 @@
export default function ({ app, route, redirect }) {
if (!app.store.state.token) {
// 未登录直接打开需要登录的页面,跳转首页
const needLoginPage = [/\/account/, /\/cart/];
const result = needLoginPage.some((item) => item.test(route.path));
if (result) {
redirect("/");
}
}
}

@ -29,7 +29,8 @@ export default {
path: '/',
component: resolve(__dirname, 'pages/index/index.vue')
})
}
},
middleware: ['redirect']
},
// Global CSS: https://go.nuxtjs.dev/config-css

@ -74,8 +74,6 @@ export default {
seckillData = seckillDataResult;
}
if (seckillData.activityTimeVO) {
store.commit("setSeckillTabVisible", true);
//
const { result } = await ApiGetSeckillGoods({
pageIndex: 1,

@ -1,13 +1,10 @@
export default ({ app }) => {
app.router.beforeEach((to, from, next) => {
// 获取用户信息
const { token, userInfo } = app.store.state;
if (token) {
if (Object.keys(userInfo).length === 0) {
if (token && Object.keys(userInfo).length === 0) {
app.store.dispatch("getUserInfo");
}
next();
return;
}
next();
});
};

Loading…
Cancel
Save