Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mayi-mp-shop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
程默
mayi-mp-shop
Commits
b6fddd95
Commit
b6fddd95
authored
Sep 28, 2022
by
李嘉林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
商品列表新增属性等
parent
f1307067
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
103 additions
and
32 deletions
+103
-32
src/api/goods.js
+4
-0
static/nativeComponents/GoodsList/GoodsItem/index.wxml
+5
-0
static/nativeComponents/GoodsList/GoodsItem/index.wxss
+38
-0
static/nativeComponents/GoodsList/index.js
+56
-32
No files found.
src/api/goods.js
View file @
b6fddd95
...
@@ -26,4 +26,8 @@ export default {
...
@@ -26,4 +26,8 @@ export default {
query_product_attribute_values_list
(
data
)
{
query_product_attribute_values_list
(
data
)
{
return
requestPOST
(
`
${
process
.
env
.
OLSHOP_URL
}
/product/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
)
}
};
};
static/nativeComponents/GoodsList/GoodsItem/index.wxml
View file @
b6fddd95
...
@@ -92,6 +92,7 @@
...
@@ -92,6 +92,7 @@
</view>
</view>
<!-- 商品详情 -->
<!-- 商品详情 -->
<view class="info" style="text-align:{{datas.componentData['initcharAlign']}};">
<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="info-top flex">
<view
<view
class="name"
class="name"
...
@@ -111,6 +112,9 @@
...
@@ -111,6 +112,9 @@
<view class="follower-text">关注人数</view>
<view class="follower-text">关注人数</view>
</view>
</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">
<view class="Sold">
<text wx:if="{{datas.componentData['alSaleShow']}}">已售{{items!=null ? items['totalSalesCount'] :0}}件</text>
<text wx:if="{{datas.componentData['alSaleShow']}}">已售{{items!=null ? items['totalSalesCount'] :0}}件</text>
...
@@ -128,6 +132,7 @@
...
@@ -128,6 +132,7 @@
{{item.label}}
{{item.label}}
</view>
</view>
</view>
</view>
<view class="purchased" wx:if="{{items!= null && items.purchased && datas.componentData['purchased']}}">已加购</view>
<!-- 底部 -->
<!-- 底部 -->
<view class="bottom" wx:if="{{datas.componentData['goodsType'] !=1}}">
<view class="bottom" wx:if="{{datas.componentData['goodsType'] !=1}}">
<!-- 价格 -->
<!-- 价格 -->
...
...
static/nativeComponents/GoodsList/GoodsItem/index.wxss
View file @
b6fddd95
...
@@ -148,6 +148,13 @@ align-items: flex-start;
...
@@ -148,6 +148,13 @@ align-items: flex-start;
overflow: hidden;
overflow: hidden;
justify-content: space-between;
justify-content: space-between;
}
}
.info .itemNo{
word-break: break-all;
margin-bottom: 8rpx;
color: #666;
line-height: 32rpx;
font-size: 24rpx;
}
.info .name{
.info .name{
flex: 1;
flex: 1;
overflow: hidden;
overflow: hidden;
...
@@ -247,6 +254,22 @@ align-items: flex-start;
...
@@ -247,6 +254,22 @@ align-items: flex-start;
-ms-border-radius: 12rpx;
-ms-border-radius: 12rpx;
-o-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{
.Sold{
overflow: hidden;
overflow: hidden;
color: #999;
color: #999;
...
@@ -343,6 +366,21 @@ margin-right: 8rpx;
...
@@ -343,6 +366,21 @@ margin-right: 8rpx;
-ms-border-radius: 40rpx;
-ms-border-radius: 40rpx;
-o-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 {
.bottom {
position: relative;
position: relative;
}
}
...
...
static/nativeComponents/GoodsList/index.js
View file @
b6fddd95
...
@@ -235,7 +235,7 @@ const componentOptions = {
...
@@ -235,7 +235,7 @@ const componentOptions = {
}
}
},
},
getProductList
(
code
,
type
)
{
getProductList
(
code
,
type
)
{
let
{
goodsSort
}
=
this
.
data
.
datas
.
componentData
;
let
{
goodsSort
,
attributeValueList
}
=
this
.
data
.
datas
.
componentData
;
let
goodsList
=
[];
let
goodsList
=
[];
if
(
type
==
2
)
{
if
(
type
==
2
)
{
goodsList
=
this
.
data
.
pageGoodsList
[
this
.
data
.
datasIndex
];
goodsList
=
this
.
data
.
pageGoodsList
[
this
.
data
.
datasIndex
];
...
@@ -288,6 +288,7 @@ const componentOptions = {
...
@@ -288,6 +288,7 @@ const componentOptions = {
whetherFindMultiShopFlag
:
1
,
whetherFindMultiShopFlag
:
1
,
brandIdList
:
this
.
data
.
submitFliterVal
.
brandIdList
||
[],
brandIdList
:
this
.
data
.
submitFliterVal
.
brandIdList
||
[],
categoryIdList
:
this
.
data
.
submitFliterVal
.
categoryIdList
||
[],
categoryIdList
:
this
.
data
.
submitFliterVal
.
categoryIdList
||
[],
whetherQueryGoodsAttributeFlag
:
attributeValueList
.
length
>
0
?
1
:
0
,
};
// 当前页 // 一页多少条 //查询销售数量 //查询收藏数 //是否使用虚拟销售数量 //是否使用虚拟收藏人数 //是否查询商品佣金(0:不查询,1:展示,为空不查佣金) //是否查询会员价 1是 0否 //是否展示营销标签 1是 0否 //是否查询多商户 //商城使用
};
// 当前页 // 一页多少条 //查询销售数量 //查询收藏数 //是否使用虚拟销售数量 //是否使用虚拟收藏人数 //是否查询商品佣金(0:不查询,1:展示,为空不查佣金) //是否查询会员价 1是 0否 //是否展示营销标签 1是 0否 //是否查询多商户 //商城使用
if
(
this
.
data
.
datas
.
componentData
[
'goodsSource'
]
==
'classify'
)
{
if
(
this
.
data
.
datas
.
componentData
[
'goodsSource'
]
==
'classify'
)
{
query
.
rows
=
this
.
data
.
datas
.
componentData
.
classificationLoadNum
;
query
.
rows
=
this
.
data
.
datas
.
componentData
.
classificationLoadNum
;
...
@@ -311,7 +312,7 @@ const componentOptions = {
...
@@ -311,7 +312,7 @@ const componentOptions = {
let
goodsLists
=
res
.
data
.
data
.
list
;
let
goodsLists
=
res
.
data
.
data
.
list
;
if
(
type
==
1
)
{
if
(
type
==
1
)
{
goodsList
=
goodsLists
;
goodsList
=
goodsLists
;
}
else
{
}
else
if
(
goodsLists
.
length
>
0
)
{
goodsList
=
[...
goodsList
,
...
goodsLists
];
goodsList
=
[...
goodsList
,
...
goodsLists
];
}
}
if
(
goodsLists
&&
goodsLists
.
length
<
query
.
rows
)
{
if
(
goodsLists
&&
goodsLists
.
length
<
query
.
rows
)
{
...
@@ -389,7 +390,8 @@ const componentOptions = {
...
@@ -389,7 +390,8 @@ const componentOptions = {
vipPrice
,
vipPrice
,
marketingTag
,
marketingTag
,
whetherFindDistributionCommission
,
whetherFindDistributionCommission
,
goodsList
goodsList
,
attributeValueList
}
=
this
.
data
.
datas
.
componentData
;
}
=
this
.
data
.
datas
.
componentData
;
let
moreQuery
=
{
let
moreQuery
=
{
terminalProductIds
,
terminalProductIds
,
...
@@ -399,7 +401,8 @@ const componentOptions = {
...
@@ -399,7 +401,8 @@ const componentOptions = {
whetherFindDistributionCommission
:
whetherFindDistributionCommission
,
//是否查询商品佣金(0:不查询,1:展示,为空不查佣金)
whetherFindDistributionCommission
:
whetherFindDistributionCommission
,
//是否查询商品佣金(0:不查询,1:展示,为空不查佣金)
whetherFindRecommendedCardFlag
:
vipPrice
?
1
:
0
,
//是否查询会员价 1是 0否
whetherFindRecommendedCardFlag
:
vipPrice
?
1
:
0
,
//是否查询会员价 1是 0否
whetherShowGoodsDefaultTagFlag
:
marketingTag
?
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
=>
{
goodsApi
.
queryMoreProductInfo
(
moreQuery
).
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
)
{
if
(
res
.
data
.
code
==
200
)
{
...
@@ -409,6 +412,7 @@ const componentOptions = {
...
@@ -409,6 +412,7 @@ const componentOptions = {
});
});
},
},
goodsListVal
(
goodsList
,
type
,
flag
)
{
goodsListVal
(
goodsList
,
type
,
flag
)
{
let
{
attributeValueList
}
=
this
.
data
.
datas
.
componentData
;
console
.
log
(
goodsList
,
"------------goodsListVal"
);
console
.
log
(
goodsList
,
"------------goodsListVal"
);
goodsList
.
forEach
((
item
,
index
)
=>
{
goodsList
.
forEach
((
item
,
index
)
=>
{
item
.
marketingTag
=
item
.
defaultTags
item
.
marketingTag
=
item
.
defaultTags
...
@@ -440,14 +444,26 @@ const componentOptions = {
...
@@ -440,14 +444,26 @@ const componentOptions = {
item
.
getSaleTime
=
0
;
item
.
getSaleTime
=
0
;
item
.
getSaleTime
=
this
.
getSaleTime
(
item
.
saleTime
);
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'
)
||
[]
let
pageGoodsList
=
this
.
getStorageSync
(
'pageGoodsList'
)
||
[]
if
(
flag
)
{
if
(
flag
)
{
pageGoodsList
[
that
.
data
.
goodsListIndex
]
=
goodsL
ist
;
pageGoodsList
[
that
.
data
.
goodsListIndex
]
=
l
ist
;
}
else
{
}
else
{
pageGoodsList
[
that
.
data
.
datasIndex
]
=
goodsL
ist
;
pageGoodsList
[
that
.
data
.
datasIndex
]
=
l
ist
;
console
.
log
(
pageGoodsList
[
that
.
data
.
datasIndex
],
'--pageGoodsList[that.data.datasIndex]'
)
console
.
log
(
pageGoodsList
[
that
.
data
.
datasIndex
],
'--pageGoodsList[that.data.datasIndex]'
)
}
}
this
.
setStorageSync
(
'pageGoodsList'
,
pageGoodsList
);
this
.
setStorageSync
(
'pageGoodsList'
,
pageGoodsList
);
...
@@ -458,44 +474,52 @@ const componentOptions = {
...
@@ -458,44 +474,52 @@ const componentOptions = {
loadingFlag
[
that
.
data
.
datasIndex
]
=
false
loadingFlag
[
that
.
data
.
datasIndex
]
=
false
this
.
setStorageSync
(
'loadingFlag'
,
loadingFlag
);
this
.
setStorageSync
(
'loadingFlag'
,
loadingFlag
);
that
.
setData
({
that
.
setData
({
"datas.componentData.goodsList"
:
list
,
pageGoodsList
,
pageGoodsList
,
})
this
.
setData
({
"datas.componentData.goodsList"
:
goodsList
,
// goodsList
loadingFlag
,
loadingFlag
,
scrollLoading
:
false
,
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
(
type
==
1
)
{
// 初始化
// 初始化
if
(
this
.
selectComponent
(
"#waterfallFlow"
))
{
if
(
this
.
selectComponent
(
"#waterfallFlow"
))
{
this
.
selectComponent
(
"#waterfallFlow"
).
initList
(
goodsL
ist
);
this
.
selectComponent
(
"#waterfallFlow"
).
initList
(
l
ist
);
}
}
}
else
{
}
else
{
// 滚动加载
// 滚动加载
if
(
this
.
selectComponent
(
"#waterfallFlow"
))
{
if
(
this
.
selectComponent
(
"#waterfallFlow"
))
{
this
.
selectComponent
(
"#waterfallFlow"
).
reLoadPro
(
goodsL
ist
);
this
.
selectComponent
(
"#waterfallFlow"
).
reLoadPro
(
l
ist
);
}
}
}
}
},
});
},
// 加购状态
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
(){
lazyloading
(){
var
that
=
this
var
that
=
this
...
@@ -709,7 +733,7 @@ const componentOptions = {
...
@@ -709,7 +733,7 @@ const componentOptions = {
getStorageSync
(
key
)
{
getStorageSync
(
key
)
{
console
.
log
(
`
${
this
.
data
.
storageKey
}
_
${
key
}
`
,
'-------------537'
)
console
.
log
(
`
${
this
.
data
.
storageKey
}
_
${
key
}
`
,
'-------------537'
)
return
wx
.
getStorageSync
(
`
${
this
.
data
.
storageKey
}
_
${
key
}
`
)
return
wx
.
getStorageSync
(
`
${
this
.
data
.
storageKey
}
_
${
key
}
`
)
}
}
,
}
}
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment