Compare commits
2 Commits
737878beb9
...
a621c6402a
| Author | SHA1 | Date | |
|---|---|---|---|
| a621c6402a | |||
| 086ccbff0d |
@ -14,13 +14,13 @@
|
||||
<span class="radio-text">企业需求</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="history-list" v-if="productList.length > 0">
|
||||
<div v-loading="loadingBox" class="history-list" v-if="productList.length > 0">
|
||||
<div class="history-item" v-for="item in productList" :key="item.id">
|
||||
<div class="history-date">
|
||||
<span class="date-text">{{ formatBrowseDate(item.create_at) }}</span>
|
||||
<span class="relative-time">{{ getRelativeTime(item.create_at) }}</span>
|
||||
<span class="date-text">{{ formatBrowseDate(item.browse_date) }}</span>
|
||||
<span class="relative-time">{{ getRelativeTime(item.browse_date) }}</span>
|
||||
</div>
|
||||
<div class="follow-content">
|
||||
<div class="history-content">
|
||||
<productCard
|
||||
contentType="favorite"
|
||||
:productList="item.products"
|
||||
@ -44,6 +44,7 @@ export default {
|
||||
name: 'followBox',
|
||||
data() {
|
||||
return {
|
||||
loadingBox:false,
|
||||
productList: [],
|
||||
value1: null,
|
||||
publish_type: '1', // 默认选择企业商品
|
||||
@ -67,10 +68,12 @@ export default {
|
||||
this.reqFavoriteSearch();
|
||||
},
|
||||
reqFavoriteSearch() {
|
||||
this.loadingBox = true;
|
||||
reqFavoriteSearch({
|
||||
url_list: window.location.href,
|
||||
publish_type: this.publish_type // 传递发布类型参数
|
||||
}).then(res => {
|
||||
this.loadingBox = false;
|
||||
if (res.status) {
|
||||
// 处理数据结构,将product_info的子项提升到上一级
|
||||
this.productList = this.flattenProductInfo(res.data.favorites);
|
||||
@ -100,6 +103,9 @@ export default {
|
||||
|
||||
// 遍历product_info的所有属性
|
||||
Object.keys(product.product_info).forEach(key => {
|
||||
if(key == 'id'){
|
||||
flattenedProduct.productid = product.product_info.id;
|
||||
}
|
||||
// 如果上一级已经有同名属性,则跳过(避免覆盖)
|
||||
if (!(key in flattenedProduct)) {
|
||||
flattenedProduct[key] = product.product_info[key];
|
||||
@ -232,11 +238,11 @@ export default {
|
||||
}
|
||||
|
||||
/* 关注记录列表样式 */
|
||||
.follow-list {
|
||||
.history-list {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.follow-item {
|
||||
.history-item {
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
@ -246,12 +252,12 @@ export default {
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.follow-item:hover {
|
||||
.history-item:hover {
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
|
||||
/* transform: translateY(-2px); */
|
||||
}
|
||||
|
||||
.follow-date {
|
||||
.history-date {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 16px;
|
||||
@ -274,7 +280,7 @@ export default {
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.follow-content {
|
||||
.history-content {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<span class="radio-text">企业需求</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="history-list" v-if="productList.length > 0">
|
||||
<div v-loading="loadingBox" class="history-list" v-if="productList.length > 0">
|
||||
<div class="history-item" v-for="item in productList" :key="item.id">
|
||||
<div class="history-date">
|
||||
<span class="date-text">{{ formatBrowseDate(item.browse_date) }}</span>
|
||||
@ -44,6 +44,7 @@ export default {
|
||||
name: 'historyBox',
|
||||
data() {
|
||||
return {
|
||||
loadingBox:false,
|
||||
productList: [],
|
||||
value1: null,
|
||||
publish_type: '1', // 默认选择企业商品
|
||||
@ -67,10 +68,12 @@ export default {
|
||||
this.reqUserBrowseHistorySearch();
|
||||
},
|
||||
reqUserBrowseHistorySearch() {
|
||||
this.loadingBox = true;
|
||||
reqUserBrowseHistorySearch({
|
||||
url_list: window.location.href,
|
||||
publish_type: this.publish_type // 传递发布类型参数
|
||||
}).then(res => {
|
||||
this.loadingBox = false;
|
||||
if (res.status) {
|
||||
// 处理数据结构,将product_info的子项提升到上一级
|
||||
this.productList = this.flattenProductInfo(res.data.history_list);
|
||||
@ -100,6 +103,9 @@ export default {
|
||||
|
||||
// 遍历product_info的所有属性
|
||||
Object.keys(product.product_info).forEach(key => {
|
||||
if(key == 'id'){
|
||||
flattenedProduct.productid = product.product_info.id;
|
||||
}
|
||||
// 如果上一级已经有同名属性,则跳过(避免覆盖)
|
||||
if (!(key in flattenedProduct)) {
|
||||
flattenedProduct[key] = product.product_info[key];
|
||||
|
||||
@ -258,6 +258,20 @@ export default Vue.extend({
|
||||
handleSearch() {
|
||||
console.log('搜索:1', this.searchKeyword)
|
||||
|
||||
},
|
||||
goFavorite() {
|
||||
if (this.loginState) {
|
||||
this.$router.push('/ncmatchHome/favoriteBox')
|
||||
} else {
|
||||
this.$router.push('/login')
|
||||
}
|
||||
},
|
||||
goHistory() {
|
||||
if (this.loginState) {
|
||||
this.$router.push('/ncmatchHome/historyBox')
|
||||
} else {
|
||||
this.$router.push('/login')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -303,8 +317,8 @@ export default Vue.extend({
|
||||
<span class="publish-goods" @click="sendInfo('1')">发布商品</span>
|
||||
|
||||
<ul class="userBtn">
|
||||
<li @click="$router.push('/ncmatchHome/historyBox')"><img style="width: 26px;height: 26px;" src="./img/eye.png" alt="">浏览记录</li>
|
||||
<li @click="$router.push('/ncmatchHome/favoriteBox')"><img style="width: 26px;height: 26px;" src="./img/collect.png" alt="">我的收藏</li>
|
||||
<li @click="goHistory"><img style="width: 26px;height: 26px;" src="./img/eye.png" alt="">浏览记录</li>
|
||||
<li @click="goFavorite"><img style="width: 26px;height: 26px;" src="./img/collect.png" alt="">我的收藏</li>
|
||||
<!-- <li><img src="./img/like.png" alt="">关注需求</li> -->
|
||||
</ul>
|
||||
</aside>
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
<template>
|
||||
<!-- 产品列表 -->
|
||||
<div>
|
||||
{{ contentType }}
|
||||
<ul v-if="type === 'homePage'" class="productListContent" style="padding-top: 16px;">
|
||||
<li class="product-item" v-for="item in productList" :key="item.id">
|
||||
<div v-if="item.img!=null" class="product-image">
|
||||
@ -232,12 +231,10 @@ export default {
|
||||
collect(item){
|
||||
this.$set(this.collectLoadingStates, item.id, true);
|
||||
// 这里添加收藏/取消收藏的逻辑
|
||||
console.log("收藏",item);
|
||||
|
||||
if(item.favorite=='1'){
|
||||
|
||||
reqFavoriteDelete({
|
||||
id:item.id,
|
||||
id:item.productid?item.productid:item.id,
|
||||
}).then(res=>{
|
||||
item.favorite='0'
|
||||
if(res.status){
|
||||
@ -251,7 +248,7 @@ export default {
|
||||
}else if(item.favorite=='0'){
|
||||
|
||||
reqPublishProductCollect({
|
||||
productid:item.id,
|
||||
productid:item.productid,
|
||||
favorite_type:item.publish_type
|
||||
}).then(res=>{
|
||||
item.favorite='1'
|
||||
@ -272,7 +269,7 @@ export default {
|
||||
async openDetail(item) {
|
||||
this.$set(this.loadingStates, item.id, true);
|
||||
reqGetProductDetail({
|
||||
id: item.id,
|
||||
id:item.productid?item.productid:item.id,
|
||||
from:'f'
|
||||
}).then(res => {
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user