Commit b6fddd95 by 李嘉林

商品列表新增属性等

parent f1307067
......@@ -26,4 +26,8 @@ export default {
query_product_attribute_values_list(data) {
return requestPOST(`${process.env.OLSHOP_URL}/product/query_product_attribute_values_list`, data)
},
// 已加购
query_goods_cart_info(data) {
return requestPOST(`${process.env.OLSHOP_URL}/cart/query_goods_cart_info`, data)
}
};
......@@ -92,6 +92,7 @@
</view>
<!-- 商品详情 -->
<view class="info" style="text-align:{{datas.componentData['initcharAlign']}};">
<view class="itemNo" wx:if="{{datas.componentData['itemNo']}}">{{items.productCode}}</view>
<view class="info-top flex">
<view
class="name"
......@@ -111,6 +112,9 @@
<view class="follower-text">关注人数</view>
</view>
</view>
<view class="attributeValueList flex" wx:if="{{items!=null && items.attributeValueList && items.attributeValueList.length>0}}">
<view class="item" wx:for="{{items.attributeValueList}}" wx:key="index">{{item}}</view>
</view>
<!-- 已售 -->
<view class="Sold">
<text wx:if="{{datas.componentData['alSaleShow']}}">已售{{items!=null ? items['totalSalesCount'] :0}}件</text>
......@@ -128,6 +132,7 @@
{{item.label}}
</view>
</view>
<view class="purchased" wx:if="{{items!= null && items.purchased && datas.componentData['purchased']}}">已加购</view>
<!-- 底部 -->
<view class="bottom" wx:if="{{datas.componentData['goodsType'] !=1}}">
<!-- 价格 -->
......
......@@ -148,6 +148,13 @@ align-items: flex-start;
overflow: hidden;
justify-content: space-between;
}
.info .itemNo{
word-break: break-all;
margin-bottom: 8rpx;
color: #666;
line-height: 32rpx;
font-size: 24rpx;
}
.info .name{
flex: 1;
overflow: hidden;
......@@ -247,6 +254,22 @@ align-items: flex-start;
-ms-border-radius: 12rpx;
-o-border-radius: 12rpx;
}
.attributeValueList{
flex-wrap: wrap;
margin: 8rpx 0;
}
.attributeValueList .item{
margin: 0 12rpx 12rpx 0;
padding: 4rpx 12rpx;
background: #e5e5e5;
color: #666;
border-radius: 4rpx;
font-size: 24rpx;
-webkit-border-radius: 4rpx;
-moz-border-radius: 4rpx;
-ms-border-radius: 4rpx;
-o-border-radius: 4rpx;
}
.Sold{
overflow: hidden;
color: #999;
......@@ -343,6 +366,21 @@ margin-right: 8rpx;
-ms-border-radius: 40rpx;
-o-border-radius: 40rpx;
}
.purchased{
margin-top: 8rpx;
margin-right: 8rpx;
font-size: 20rpx;
padding: 0 12rpx;
border: 2rpx solid #ff5500;
color: #ff5500;
border-radius: 40rpx;
width: 88rpx;
text-align: center;
-webkit-border-radius: 40rpx;
-moz-border-radius: 40rpx;
-ms-border-radius: 40rpx;
-o-border-radius: 40rpx;
}
.bottom {
position: relative;
}
......
......@@ -235,7 +235,7 @@ const componentOptions = {
}
},
getProductList(code, type) {
let { goodsSort } = this.data.datas.componentData;
let { goodsSort,attributeValueList } = this.data.datas.componentData;
let goodsList = [];
if (type == 2) {
goodsList = this.data.pageGoodsList[this.data.datasIndex];
......@@ -288,6 +288,7 @@ const componentOptions = {
whetherFindMultiShopFlag: 1,
brandIdList: this.data.submitFliterVal.brandIdList || [],
categoryIdList: this.data.submitFliterVal.categoryIdList || [],
whetherQueryGoodsAttributeFlag: attributeValueList.length>0?1:0,
}; // 当前页 // 一页多少条 //查询销售数量 //查询收藏数 //是否使用虚拟销售数量 //是否使用虚拟收藏人数 //是否查询商品佣金(0:不查询,1:展示,为空不查佣金) //是否查询会员价 1是 0否 //是否展示营销标签 1是 0否 //是否查询多商户 //商城使用
if(this.data.datas.componentData['goodsSource'] == 'classify') {
query.rows = this.data.datas.componentData.classificationLoadNum;
......@@ -311,7 +312,7 @@ const componentOptions = {
let goodsLists = res.data.data.list;
if (type == 1) {
goodsList = goodsLists;
} else {
} else if(goodsLists.length>0) {
goodsList = [...goodsList, ...goodsLists];
}
if (goodsLists && goodsLists.length < query.rows) {
......@@ -389,7 +390,8 @@ const componentOptions = {
vipPrice,
marketingTag,
whetherFindDistributionCommission,
goodsList
goodsList,
attributeValueList
} = this.data.datas.componentData;
let moreQuery = {
terminalProductIds,
......@@ -399,7 +401,8 @@ const componentOptions = {
whetherFindDistributionCommission: whetherFindDistributionCommission, //是否查询商品佣金(0:不查询,1:展示,为空不查佣金)
whetherFindRecommendedCardFlag: vipPrice ? 1 : 0, //是否查询会员价 1是 0否
whetherShowGoodsDefaultTagFlag: marketingTag ? 1 : 0, //是否展示营销标签 1是 0否
whetherFindMultiShopFlag: 1 //是否查询多商户 //商城使用
whetherFindMultiShopFlag: 1, //是否查询多商户 //商城使用
whetherQueryGoodsAttributeFlag: attributeValueList.length>0?1:0,
};
goodsApi.queryMoreProductInfo(moreQuery).then(res => {
if (res.data.code == 200) {
......@@ -409,6 +412,7 @@ const componentOptions = {
});
},
goodsListVal(goodsList, type,flag) {
let { attributeValueList } = this.data.datas.componentData;
console.log(goodsList, "------------goodsListVal");
goodsList.forEach((item, index) => {
item.marketingTag = item.defaultTags
......@@ -440,14 +444,26 @@ const componentOptions = {
item.getSaleTime = 0;
item.getSaleTime = this.getSaleTime(item.saleTime);
}
item.attributeValueList = [];
if (attributeValueList.length > 0) {
// 过滤商品属性
if (item.attributeList) {
let list = item.attributeList.filter(item1=>attributeValueList.includes(item1.attributeName)) || [];
console.log("list",list)
console.log(item.attributeValueList,'--item.attributeValueList')
item.attributeValueList = list ? list.map(item1 => item1.attributeValue) : [];
}
}
});
var that = this
// 是否加购
this.getPurchased(goodsList,(list) => {
let that = this
let pageGoodsList = this.getStorageSync('pageGoodsList') || []
if (flag) {
pageGoodsList[that.data.goodsListIndex] = goodsList;
pageGoodsList[that.data.goodsListIndex] = list;
}else{
pageGoodsList[that.data.datasIndex] = goodsList;
pageGoodsList[that.data.datasIndex] = list;
console.log(pageGoodsList[that.data.datasIndex],'--pageGoodsList[that.data.datasIndex]')
}
this.setStorageSync('pageGoodsList', pageGoodsList);
......@@ -458,44 +474,52 @@ const componentOptions = {
loadingFlag[that.data.datasIndex] = false
this.setStorageSync('loadingFlag', loadingFlag);
that.setData({
"datas.componentData.goodsList": list,
pageGoodsList,
})
this.setData({
"datas.componentData.goodsList": goodsList,
// goodsList
loadingFlag,
scrollLoading: false,
},function () {
// that.lazyloading();
// 节点布局方案在组件嵌套层级过深测试无效
// let goodsList = this.data.goodsList // 获取原数据
// goodsList.forEach((item,index)=>{
// wx.createIntersectionObserver().relativeToViewport({bottom: 20}).observe(`.goodsItemIndex${index}`, (ret) => {
// // if (ret.intersectionRatio > 0){
// // group[i].show = true
// // }
// // this.setData({ // 更新数据
// // group
// // })
// console.log('1111');
// })
// })
})
if (type == 1) {
// 初始化
if (this.selectComponent("#waterfallFlow")) {
this.selectComponent("#waterfallFlow").initList(goodsList);
this.selectComponent("#waterfallFlow").initList(list);
}
} else {
// 滚动加载
if (this.selectComponent("#waterfallFlow")) {
this.selectComponent("#waterfallFlow").reLoadPro(goodsList);
this.selectComponent("#waterfallFlow").reLoadPro(list);
}
}
},
});
},
// 加购状态
getPurchased(goodsList,callback) {
let { purchased } = this.data.datas.componentData;
let list = goodsList.map(item=>item.productId);
if(purchased) {
console.log("getPurchased-list",list)
// if(!this.render) return;
goodsApi.query_goods_cart_info(list).then(res=>{
if (res.data.code == 200) {
let purchasedList = res.data.data || [];
let purchasedListIds = [...new Set(purchasedList.map(item=>item.productId))];
console.log(purchasedListIds,'---purchasedListIds')
goodsList.forEach(item=>{
item.purchased = false;
if(purchasedListIds.includes(item.productId)) {
item.purchased = true;
console.log("---------------1039")
}
})
callback(goodsList);
console.log(goodsList,'getPurchased---goodsList')
}
})
} else {
callback(goodsList);
}
},
// 触发图片加载
lazyloading(){
var that = this
......@@ -709,7 +733,7 @@ const componentOptions = {
getStorageSync(key) {
console.log(`${this.data.storageKey}_${key}`,'-------------537')
return wx.getStorageSync(`${this.data.storageKey}_${key}`)
}
},
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment