mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-11-07 17:38:55 +08:00
feat(buyer): 增强搜索功能并提升用户体验
- 新增 `getStoreById` 接口方法,用于获取包含评分在内的店铺信息 - `Search.vue` 新增搜索建议面板,展示搜索历史和热词,优化搜索体验 - 新增 `SearchSuggest.vue` 组件,用于展示搜索建议和搜索历史 - `App.vue` 根据路由元信息按条件设置页面标题 - 优化多个组件的布局与样式,让整体风格更统一 - 重构多个组件的跳转逻辑,改用路由跳转(`router.push`)替代新开窗口(`window.open`),提升用户体验
This commit is contained in:
@@ -1,16 +1,40 @@
|
||||
/**
|
||||
* 买家端内部链接跳转(首页装修、列表等共用)
|
||||
*
|
||||
* @author Mike
|
||||
* @date 2026-08-05
|
||||
* 商品详情新开标签,其余站内页面在当前页打开。外链仍新开。
|
||||
*/
|
||||
|
||||
/** 内部链接新窗口打开,外链直接打开。浏览商品详情不要求登录。 */
|
||||
const NEW_TAB_PATHS = ["/goodsDetail", "/pointGoodsDetail"];
|
||||
|
||||
function isExternalLink(url) {
|
||||
return /^https?:\/\//i.test(url) || url.startsWith("//");
|
||||
}
|
||||
|
||||
function normalizeInternal(url) {
|
||||
return url.charAt(0) === "/" ? url : `/${url}`;
|
||||
}
|
||||
|
||||
function pathnameOf(url) {
|
||||
return normalizeInternal(url).split("?")[0].split("#")[0];
|
||||
}
|
||||
|
||||
export function shouldOpenNewTab(url) {
|
||||
if (!url) return false;
|
||||
if (isExternalLink(url)) return true;
|
||||
const path = pathnameOf(url);
|
||||
return NEW_TAB_PATHS.indexOf(path) !== -1;
|
||||
}
|
||||
|
||||
export function openLink(url, router) {
|
||||
if (!url) return;
|
||||
if (url.charAt(0) !== "/") {
|
||||
if (isExternalLink(url)) {
|
||||
window.open(url, "_blank");
|
||||
return;
|
||||
}
|
||||
window.open(router.resolve(url).href, "_blank");
|
||||
const internal = normalizeInternal(url);
|
||||
if (shouldOpenNewTab(internal)) {
|
||||
window.open(router.resolve(internal).href, "_blank");
|
||||
return;
|
||||
}
|
||||
return router.push(internal);
|
||||
}
|
||||
|
||||
24
buyer/src/utils/unreadMessage.js
Normal file
24
buyer/src/utils/unreadMessage.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import store from "@/vuex/store";
|
||||
import storage from "@/plugins/storage";
|
||||
import { memberMsgList } from "@/api/member";
|
||||
|
||||
// 用未读消息总数刷新角标,只取 1 条记录
|
||||
export function refreshUnreadMessage() {
|
||||
if (!storage.getItem("userInfo")) {
|
||||
store.commit("SET_UNREAD_MSG", 0);
|
||||
return Promise.resolve(0);
|
||||
}
|
||||
return memberMsgList({
|
||||
pageNumber: 1,
|
||||
pageSize: 1,
|
||||
status: "UN_READY",
|
||||
})
|
||||
.then((res) => {
|
||||
const total = res && res.success ? Number(res.result && res.result.total) || 0 : 0;
|
||||
store.commit("SET_UNREAD_MSG", total);
|
||||
return total;
|
||||
})
|
||||
.catch(() => {
|
||||
return Number(store.state.unreadMsg) || 0;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user