mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-11-07 17:38:55 +08:00
feat(buyer): 新增功能并优化样式,提升用户体验
- 新增 `getMemberMessage` 接口方法,用于获取会员消息 - 调整全局及商品列表样式,提升可读性与一致性 - 精简 `Search.vue`,移除不必要的店铺搜索切换 - 放宽 `addressManage` 中地址别名的输入长度 - 优化 `ShowGoods.vue` 和 `ShowGoodsDetail.vue` 的布局与样式 - 更新 `Cart.vue` 中的购物车步骤展示,让流程导航更清晰 - 调整多个组件,统一字号并优化界面元素
This commit is contained in:
@@ -1,59 +1,16 @@
|
||||
/**
|
||||
* 买家端登录态与商品详情跳转校验
|
||||
* 买家端内部链接跳转(首页装修、列表等共用)
|
||||
*
|
||||
* @author Mike
|
||||
* @date 2026-08-05
|
||||
*/
|
||||
import storage from "@/plugins/storage";
|
||||
|
||||
export function isBuyerLoggedIn() {
|
||||
const rawUserInfo = storage.getItem("userInfo");
|
||||
if (rawUserInfo) {
|
||||
try {
|
||||
return !!JSON.parse(rawUserInfo).username;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return !!storage.getItem("accessToken");
|
||||
}
|
||||
|
||||
export function parseInternalLink(url) {
|
||||
const [path, search = ""] = url.split("?");
|
||||
const query = {};
|
||||
if (search) {
|
||||
new URLSearchParams(search).forEach((value, key) => {
|
||||
query[key] = value;
|
||||
});
|
||||
}
|
||||
return { path, query };
|
||||
}
|
||||
|
||||
export function isGoodsDetailPath(path) {
|
||||
return path === "/goodsDetail";
|
||||
}
|
||||
|
||||
export function redirectToLogin(router, location) {
|
||||
router.push({
|
||||
path: "/login",
|
||||
query: {
|
||||
rePath: location.path,
|
||||
query: JSON.stringify(location.query || {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/** 内部链接跳转;访问商品详情前校验登录(首页装修、列表等共用) */
|
||||
/** 内部链接新窗口打开,外链直接打开。浏览商品详情不要求登录。 */
|
||||
export function openLink(url, router) {
|
||||
if (!url) return;
|
||||
if (url.charAt(0) !== "/") {
|
||||
window.open(url, "_blank");
|
||||
return;
|
||||
}
|
||||
const location = parseInternalLink(url);
|
||||
if (!isBuyerLoggedIn() && isGoodsDetailPath(location.path)) {
|
||||
redirectToLogin(router, location);
|
||||
return;
|
||||
}
|
||||
window.open(router.resolve(url).href, "_blank");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user