From 2c18f68f2e102f8dec78548773463daf60786b6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E7=93=9C=E4=B8=80=E5=9D=97=E5=85=AB?= <2523890936@qq.com> Date: Fri, 22 Aug 2025 11:24:29 +0800 Subject: [PATCH 01/10] bugfix --- f/web-kboss/src/api/ncmatch/index.js | 19 ++++ .../ncmatch/mainPage/productCard/index.vue | 92 ++++++++++++++++--- .../operation/consultingMangement/index.vue | 10 +- 3 files changed, 105 insertions(+), 16 deletions(-) diff --git a/f/web-kboss/src/api/ncmatch/index.js b/f/web-kboss/src/api/ncmatch/index.js index 86a39d5..7050981 100644 --- a/f/web-kboss/src/api/ncmatch/index.js +++ b/f/web-kboss/src/api/ncmatch/index.js @@ -219,4 +219,23 @@ export function reqSupplyAndDemandSecondCategory(data){ headers: { 'Content-Type': 'application/json' }, data }) +} + +//收藏 /product/publish_product_collect.dspy +export function reqPublishProductCollect(data){ + return request({ + url: '/user/favorite_add.dspy', + method: 'post', + headers: { 'Content-Type': 'application/json' }, + data + }) +} +//取消收藏 /user/favorite_delete.dspy +export function reqFavoriteDelete(data){ + return request({ + url: '/user/favorite_delete.dspy', + method: 'post', + headers: { 'Content-Type': 'application/json' }, + data + }) } \ No newline at end of file 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 3be6828..3bc3664 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 @@ -52,13 +52,29 @@
¥{{ item.discount_price }} - {{ item.unit }} {{ item.short_term === '1' ? '(可短租)' : '' }} + {{ item.unit }} {{ item.short_term === '1' ? '(可短租)' : '' }} 已收藏 +
+
+ 立即咨询 + + 详情 >> + + + {{ item.favorite === '1' ? '取消收藏' : '收藏' }} + + +
-
-立即咨询 详情 >> -
@@ -94,10 +110,25 @@ ¥{{ item.discount_price }} {{ item.unit }} {{ item.short_term === '1' ? '(可短租)' : '' }} -
- - 立即咨询 详情 >> +
+ 立即咨询 + + 详情 >> + + + {{ item.favorite === '1' ? '取消收藏' : '收藏' }} + + +
@@ -107,7 +138,7 @@ + \ 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 @@ \ No newline at end of file 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 6ff2c0b..c300be3 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 @@ -248,7 +248,7 @@ export default { }else if(item.favorite=='0'){ reqPublishProductCollect({ - productid:item.productid, + productid:item.productid?item.productid:item.id, favorite_type:item.publish_type }).then(res=>{ item.favorite='1' -- 2.34.1 From 90e00d7d4f0daa540db72603037bcdb639df4d9b Mon Sep 17 00:00:00 2001 From: ping <1017253325@qq.com> Date: Wed, 27 Aug 2025 14:05:00 +0800 Subject: [PATCH 10/10] updsate --- b/user/favorite_delete.dspy | 5 ++--- b/user/favorite_search.dspy | 28 ++++++++++++++++++++++++-- b/user/user_browse_history_search.dspy | 15 ++++++++++++-- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/b/user/favorite_delete.dspy b/b/user/favorite_delete.dspy index 795251f..b4a78b2 100644 --- a/b/user/favorite_delete.dspy +++ b/b/user/favorite_delete.dspy @@ -14,14 +14,13 @@ async def favorite_delete(ns={}): db = DBPools() async with db.sqlorContext('kboss') as sor: try: - if ns.get('id'): # 根据收藏ID删除 update_sql = """ UPDATE user_favorite SET del_flg = '1' - WHERE productid = '%s' AND userid = '%s' - """ % (ns.get('id'), ns['userid']) + WHERE userid = '%s' AND productid = '%s' + """ % (ns.get('userid'), ns.get('id')) await sor.sqlExe(update_sql, {}) else: return { diff --git a/b/user/favorite_search.dspy b/b/user/favorite_search.dspy index 15af9be..c85253a 100644 --- a/b/user/favorite_search.dspy +++ b/b/user/favorite_search.dspy @@ -24,8 +24,8 @@ async def favorite_search(ns={}): where_conditions = ["f.del_flg = '0'"] if ns.get('userid'): where_conditions.append("f.userid = '%s'" % ns.get('userid')) - if ns.get('favorite_type'): - where_conditions.append("f.favorite_type = '%s'" % ns.get('favorite_type')) + if ns.get('publish_type'): + where_conditions.append("f.favorite_type = '%s'" % ns.get('publish_type')) where_clause = " AND ".join(where_conditions) @@ -58,11 +58,35 @@ async def favorite_search(ns={}): product_info_li = await sor.sqlExe(product_sql, {}) if product_info_li: product['product_info'] = product_info_li[0] + # 增加收藏状态 + product['product_info']['favorite'] = '1' # 手机号加* if product['product_info'].get('phone_number'): product['product_info']['phone_number'] = '**************' + if product['product_info'].get('img'): + product['product_info']['img'] = 'https://' + product['product_info']['domain_name'] + '/idfile?path=' + product['product_info']['img'] + else: product['product_info'] = None + + date_groups = {} + for item in result: + # 提取日期部分(如"2025-08-22 15:58:52" → "2025-08-22") + browse_date = datetime.datetime.strptime(item["create_at"], "%Y-%m-%d %H:%M:%S").strftime("%Y-%m-%d") + if browse_date not in date_groups: + date_groups[browse_date] = [] + + date_groups[browse_date].append(item) + + # 按日期升序排序并添加序号 + sorted_dates = sorted(date_groups.keys(), reverse=True) # 按日期升序排列 + result = [] + for idx, date in enumerate(sorted_dates, start=1): + result.append({ + "id": str(idx), # 序号从1开始 + "browse_date": date, + "products": date_groups[date] # 该日期下的所有浏览记录 + }) return { 'status': True, diff --git a/b/user/user_browse_history_search.dspy b/b/user/user_browse_history_search.dspy index df2d8d4..46a4dc5 100644 --- a/b/user/user_browse_history_search.dspy +++ b/b/user/user_browse_history_search.dspy @@ -63,13 +63,24 @@ async def user_browse_history_search(ns={}): SELECT * FROM user_publish_product WHERE id = '{product['productid']}' AND del_flg = '0' AND listing_status = 'listing'; """ + favorite_sql = f""" + SELECT * FROM user_favorite + WHERE productid = '{product['productid']}' AND userid = '{userid}' AND del_flg = '0'; + """ + favorite_status = await sor.sqlExe(favorite_sql, {}) product_info_li = await sor.sqlExe(product_sql, {}) if product_info_li: product['product_info'] = product_info_li[0] + + if favorite_status: + product['product_info']['favorite'] = '1' + else: + product['product_info']['favorite'] = '0' + if product['product_info'].get('phone_number'): product['product_info']['phone_number'] = '***************' - if product['product_info'].get('img') and domain_name: - product['product_info']['img'] = 'https://' + domain_name + '/idfile?path=' + product['product_info']['img'] + if product['product_info'].get('img'): + product['product_info']['img'] = 'https://' + product['product_info']['domain_name'] + '/idfile?path=' + product['product_info']['img'] else: product['product_info'] = None -- 2.34.1