feat: 增强用户登录体验与组件逻辑优化

- 在多个组件中添加用户登录状态检查,确保用户在进行特定操作前已登录。
- 更新购物车、消息中心等组件的点击事件,未登录时提示用户登录。
- 优化优惠券领取逻辑,未登录时引导用户登录。
- 调整样式以提升组件一致性,确保用户界面友好。
This commit is contained in:
田香琪
2026-07-10 13:31:14 +08:00
parent c355194aba
commit d648855533
23 changed files with 302 additions and 760 deletions

View File

@@ -124,9 +124,27 @@ export default {
}
},
methods: {
goToPay() { // 跳转购物车
let url = this.$router.resolve({
path: '/cart'
goToPay() {
if (!this.userInfo.username) {
Modal.confirm({
title: '温馨提示',
content: '请登录后执行此操作',
okText: '立即登录',
cancelText: '取消',
onOk: () => {
this.$router.push({
path: '/login',
query: {
rePath: '/cart',
query: JSON.stringify(this.$route.query || {}),
},
});
},
});
return;
}
const url = this.$router.resolve({
path: '/cart',
});
window.open(url.href, '_blank');
},
@@ -169,16 +187,29 @@ export default {
}
},
shopEntry() {
// 店铺入驻
if (storage.getItem('accessToken')) {
let routeUrl = this.$router.resolve({
const routeUrl = this.$router.resolve({
path: '/shopEntry',
query: {id: 1}
query: { id: 1 },
});
window.open(routeUrl.href, '_blank');
} else {
this.$router.push('login');
return;
}
Modal.confirm({
title: '温馨提示',
content: '请登录后执行此操作',
okText: '立即登录',
cancelText: '取消',
onOk: () => {
this.$router.push({
path: '/login',
query: {
rePath: '/shopEntry',
query: JSON.stringify({ id: 1 }),
},
});
},
});
},
handleCartDropdownVisible(visible) {
if (visible) {