diff --git a/f/web-kboss/src/api/ncmatch/index.js b/f/web-kboss/src/api/ncmatch/index.js index 7050981..587f4d7 100644 --- a/f/web-kboss/src/api/ncmatch/index.js +++ b/f/web-kboss/src/api/ncmatch/index.js @@ -238,4 +238,41 @@ export function reqFavoriteDelete(data){ headers: { 'Content-Type': 'application/json' }, data }) +} +//浏览记录 /user/user_browse_history_search.dspy +export function reqUserBrowseHistorySearch(data){ + return request({ + url: '/user/user_browse_history_search.dspy', + method: 'post', + headers: { 'Content-Type': 'application/json' }, + data + }) +} +//删除浏览记录 /user/user_browse_history_delete.dspy +export function reqUserBrowseHistoryDeleteById(data){ + return request({ + url: '/user/user_browse_history_delete.dspy', + method: 'post', + headers: { 'Content-Type': 'application/json' }, + data + }) +} + +//删除关注记录 /user/favorite_delete.dspy +export function reqFavoriteDeleteById(data){ + return request({ + url: '/user/favorite_delete.dspy', + method: 'post', + headers: { 'Content-Type': 'application/json' }, + data + }) +} +//全部收藏列表 /user/favorite_search.dspy +export function reqFavoriteSearch(data){ + return request({ + url: '/user/favorite_search.dspy', + method: 'post', + headers: { 'Content-Type': 'application/json' }, + data + }) } \ No newline at end of file diff --git a/f/web-kboss/src/router/index.js b/f/web-kboss/src/router/index.js index a470274..b3a4d9d 100644 --- a/f/web-kboss/src/router/index.js +++ b/f/web-kboss/src/router/index.js @@ -192,6 +192,20 @@ export const constantRoutes = [ hidden: true, meta: { title: "产品查询", fullPath: "/ncmatch/searchBox" }, }, + { + path: "historyBox", + component: () => import("@/views/homePage/ncmatch/historyBox/index.vue"), + name: "historyBox", + hidden: true, + meta: { title: "浏览记录", fullPath: "/ncmatch/historyBox" }, + }, + { + path: "favoriteBox", + component: () => import("@/views/homePage/ncmatch/favoriteBox/index.vue"), + name: "favoriteBox", + hidden: true, + meta: { title: "我的关注", fullPath: "/ncmatch/favoriteBox" }, + }, ] }, { diff --git a/f/web-kboss/src/views/homePage/ncmatch/favoriteBox/index.vue b/f/web-kboss/src/views/homePage/ncmatch/favoriteBox/index.vue new file mode 100644 index 0000000..c43fc49 --- /dev/null +++ b/f/web-kboss/src/views/homePage/ncmatch/favoriteBox/index.vue @@ -0,0 +1,298 @@ + + + \ No newline at end of file diff --git a/f/web-kboss/src/views/homePage/ncmatch/favoriteBox/tool.js b/f/web-kboss/src/views/homePage/ncmatch/favoriteBox/tool.js new file mode 100644 index 0000000..4826180 --- /dev/null +++ b/f/web-kboss/src/views/homePage/ncmatch/favoriteBox/tool.js @@ -0,0 +1,75 @@ +// 日期格式化工具函数 +/** + * 如果是今年之展示xx月xxx日 + * 如果是去年之展示xx年xx月xx日 + * 如果是今年之前之展示xx年xx月xx日 + * 如果是今年之后之展示xx月xx日 + */ + +/** + * 格式化浏览日期 + * @param {string|Date} date - 日期字符串或Date对象 + * @returns {string} 格式化后的日期字符串 + */ +export function formatBrowseDate(date) { + if (!date) return ''; + + const targetDate = new Date(date); + const currentDate = new Date(); + const currentYear = currentDate.getFullYear(); + const targetYear = targetDate.getFullYear(); + + // 获取月份和日期 + const month = targetDate.getMonth() + 1; + const day = targetDate.getDate(); + + // 如果是今年 + if (targetYear === currentYear) { + return `${month}月${day}日`; + } + // 如果是去年 + else if (targetYear === currentYear - 1) { + return `${targetYear}年${month}月${day}日`; + } + // 如果是今年之前 + else if (targetYear < currentYear) { + return `${targetYear}年${month}月${day}日`; + } + // 如果是今年之后(未来日期) + else { + return `${month}月${day}日`; + } +} + +/** + * 获取相对时间描述 + * @param {string|Date} date - 日期字符串或Date对象 + * @returns {string} 相对时间描述 + */ +export function getRelativeTime(date) { + if (!date) return ''; + + const targetDate = new Date(date); + const currentDate = new Date(); + const diffTime = currentDate - targetDate; + const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24)); + + if (diffDays === 0) { + return '今天'; + } else if (diffDays === 1) { + return '昨天'; + } else if (diffDays === 2) { + return '前天'; + } else if (diffDays < 7) { + return `${diffDays}天前`; + } else if (diffDays < 30) { + const weeks = Math.floor(diffDays / 7); + return `${weeks}周前`; + } else if (diffDays < 365) { + const months = Math.floor(diffDays / 30); + return `${months}个月前`; + } else { + const years = Math.floor(diffDays / 365); + return `${years}年前`; + } +} diff --git a/f/web-kboss/src/views/homePage/ncmatch/historyBox/index.vue b/f/web-kboss/src/views/homePage/ncmatch/historyBox/index.vue new file mode 100644 index 0000000..2d6cc42 --- /dev/null +++ b/f/web-kboss/src/views/homePage/ncmatch/historyBox/index.vue @@ -0,0 +1,298 @@ + + + \ No newline at end of file diff --git a/f/web-kboss/src/views/homePage/ncmatch/historyBox/tool.js b/f/web-kboss/src/views/homePage/ncmatch/historyBox/tool.js new file mode 100644 index 0000000..4826180 --- /dev/null +++ b/f/web-kboss/src/views/homePage/ncmatch/historyBox/tool.js @@ -0,0 +1,75 @@ +// 日期格式化工具函数 +/** + * 如果是今年之展示xx月xxx日 + * 如果是去年之展示xx年xx月xx日 + * 如果是今年之前之展示xx年xx月xx日 + * 如果是今年之后之展示xx月xx日 + */ + +/** + * 格式化浏览日期 + * @param {string|Date} date - 日期字符串或Date对象 + * @returns {string} 格式化后的日期字符串 + */ +export function formatBrowseDate(date) { + if (!date) return ''; + + const targetDate = new Date(date); + const currentDate = new Date(); + const currentYear = currentDate.getFullYear(); + const targetYear = targetDate.getFullYear(); + + // 获取月份和日期 + const month = targetDate.getMonth() + 1; + const day = targetDate.getDate(); + + // 如果是今年 + if (targetYear === currentYear) { + return `${month}月${day}日`; + } + // 如果是去年 + else if (targetYear === currentYear - 1) { + return `${targetYear}年${month}月${day}日`; + } + // 如果是今年之前 + else if (targetYear < currentYear) { + return `${targetYear}年${month}月${day}日`; + } + // 如果是今年之后(未来日期) + else { + return `${month}月${day}日`; + } +} + +/** + * 获取相对时间描述 + * @param {string|Date} date - 日期字符串或Date对象 + * @returns {string} 相对时间描述 + */ +export function getRelativeTime(date) { + if (!date) return ''; + + const targetDate = new Date(date); + const currentDate = new Date(); + const diffTime = currentDate - targetDate; + const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24)); + + if (diffDays === 0) { + return '今天'; + } else if (diffDays === 1) { + return '昨天'; + } else if (diffDays === 2) { + return '前天'; + } else if (diffDays < 7) { + return `${diffDays}天前`; + } else if (diffDays < 30) { + const weeks = Math.floor(diffDays / 7); + return `${weeks}周前`; + } else if (diffDays < 365) { + const months = Math.floor(diffDays / 30); + return `${months}个月前`; + } else { + const years = Math.floor(diffDays / 365); + return `${years}年前`; + } +} diff --git a/f/web-kboss/src/views/homePage/ncmatch/mainPage/index.vue b/f/web-kboss/src/views/homePage/ncmatch/mainPage/index.vue index c7a37d3..b7d9097 100644 --- a/f/web-kboss/src/views/homePage/ncmatch/mainPage/index.vue +++ b/f/web-kboss/src/views/homePage/ncmatch/mainPage/index.vue @@ -16,7 +16,7 @@ export default Vue.extend({ }, data() { return { - boxLoading:false, + boxLoading: false, selectedCategory: "", showTip: false, total: 0, @@ -177,11 +177,11 @@ export default Vue.extend({ const hasAuditInfo = Array.isArray(dataList) && dataList.length !== 0 const roles = sessionStorage.getItem('jueseNew') const isCustomer = roles ? roles.includes('客户') : true - + // 安全检查:确保 data[0] 存在 if (hasAuditInfo && dataList[0]) { const auditStatus = dataList[0].audit_status - + if (auditStatus === 'pending') { this.$message.warning('您的审核状态为待审核,请等待审核通过后发布~') } else if (auditStatus === 'rejected') { @@ -302,11 +302,11 @@ export default Vue.extend({ 发布需求 发布商品 - + @@ -355,12 +355,20 @@ export default Vue.extend({ justify-content: center; transition: all 0.3s; + * { + img { + width: 20px !important; + height: 20px !important; + } + } + &:hover { transition: all 0.3s; cursor: pointer; color: #2c96fc; svg { + path { fill: #2c96fc !important; } @@ -482,7 +490,7 @@ export default Vue.extend({ display: flex; justify-content: center; align-items: center; - + margin-top: 50px; .activeMenu { background: linear-gradient(90deg, #275AFF 0%, #2EBDFA 100%); color: white; @@ -697,8 +705,9 @@ export default Vue.extend({ .user-sidebar { height: 100%; - *{ - font-size: 20px!important; + + * { + font-size: 20px !important; } } diff --git a/f/web-kboss/src/views/homePage/ncmatch/mainPage/productCard/index.vue b/f/web-kboss/src/views/homePage/ncmatch/mainPage/productCard/index.vue index 3bc3664..099a7aa 100644 --- a/f/web-kboss/src/views/homePage/ncmatch/mainPage/productCard/index.vue +++ b/f/web-kboss/src/views/homePage/ncmatch/mainPage/productCard/index.vue @@ -1,6 +1,7 @@