mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-08-06 10:57:26 +08:00
feat: 增强用户登录体验与组件逻辑优化
- 在多个组件中添加用户登录状态检查,确保用户在进行特定操作前已登录。 - 更新购物车、消息中心等组件的点击事件,未登录时提示用户登录。 - 优化优惠券领取逻辑,未登录时引导用户登录。 - 调整样式以提升组件一致性,确保用户界面友好。
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
|
||||
<script>
|
||||
import { getIconUrl } from "@/assets/iconfont/iconMap";
|
||||
import storage from "@/plugins/storage.js";
|
||||
|
||||
export default {
|
||||
name: "fixed-index",
|
||||
@@ -19,22 +20,26 @@ export default {
|
||||
{
|
||||
icon:"user",
|
||||
label:"会员中心",
|
||||
path:"/home"
|
||||
path:"/home",
|
||||
requireLogin: true,
|
||||
},
|
||||
{
|
||||
icon:"carts",
|
||||
label:"购物车",
|
||||
path:"/cart"
|
||||
path:"/cart",
|
||||
requireLogin: true,
|
||||
},
|
||||
{
|
||||
icon:"notification",
|
||||
label:"消息",
|
||||
path:"/home/MsgList"
|
||||
path:"/home/MsgList",
|
||||
requireLogin: true,
|
||||
},
|
||||
{
|
||||
icon:"collage",
|
||||
label:"收藏",
|
||||
path:"/home/Favorites"
|
||||
path:"/home/Favorites",
|
||||
requireLogin: true,
|
||||
},
|
||||
{
|
||||
icon:"back",
|
||||
@@ -71,13 +76,37 @@ export default {
|
||||
this.isScrolling = false;
|
||||
}
|
||||
},
|
||||
handleClickIcon(val){
|
||||
if(val.path === 'back'){
|
||||
this.scrollToTop()
|
||||
}else{
|
||||
this.$router.push(val.path)
|
||||
isLoggedIn () {
|
||||
const rawUserInfo = storage.getItem('userInfo');
|
||||
if (rawUserInfo) {
|
||||
try {
|
||||
return !!JSON.parse(rawUserInfo).username;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return !!storage.getItem('accessToken');
|
||||
},
|
||||
goLogin (rePath) {
|
||||
this.$router.push({
|
||||
path: '/login',
|
||||
query: {
|
||||
rePath,
|
||||
query: JSON.stringify(this.$route.query || {}),
|
||||
},
|
||||
});
|
||||
},
|
||||
handleClickIcon (val) {
|
||||
if (val.path === 'back') {
|
||||
this.scrollToTop();
|
||||
return;
|
||||
}
|
||||
if (val.requireLogin && !this.isLoggedIn()) {
|
||||
this.goLogin(val.path);
|
||||
return;
|
||||
}
|
||||
this.$router.push(val.path);
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user