Merge branch 'feature/task1.0.0' into feature/task1.0.0-0507-zz

merge-requests/78/merge
张征 3 years ago
commit 0d918cadfc

@ -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

@ -92,8 +92,17 @@ export default {
computed: {
...mapState(["userInfo", "token"]),
},
watch: {
userInfo: {
deep: true,
handler(val) {
if (val && Object.keys(val).length > 0) {
this.initData();
}
},
},
},
created() {
this.initData();
this.getOssConfig();
},
methods: {

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

@ -1,21 +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) {
// app.store.dispatch("getUserInfo");
// }
// next();
// return;
// }
// // 未登录打开需要登录的页面,跳首页
// const needLoginPage = [/\/account/, /\/cart/];
// const result = needLoginPage.some((item) => item.test(to.path));
// if (result) {
// next("/");
// return;
// }
// 获取用户信息
const { token, userInfo } = app.store.state;
if (token && Object.keys(userInfo).length === 0) {
app.store.dispatch("getUserInfo");
}
next();
});
};

Loading…
Cancel
Save