Commit 03634695 by 李嘉林

商品列表点击事件

parent 61e3b697
......@@ -153,6 +153,9 @@ export default {
} else if (options.from && (options.from == "home" || options.from == "livedToIndex")) {
//来自直播详情
this.page = decodeURIComponent(options.backpath);
if(this.page.includes("?")){
this.params="&mixid=" + this.shopId;
}
options.params && (this.params += "&" + serialize(options.params));
} else if (options.from && options.from == "livedBackShop") {
//直播页back到商城
......
......@@ -77,9 +77,9 @@ export function $themeToLink(data) {
}
}
function toPage(backPath, backParams) {
function toPage(backPath, backParams = "") {
wx.navigateTo({
url: `../index/main?from=home&backpath=${backPath}&params=${encodeURIComponent(backParams)}`
url: `../index/main?from=home&backpath=${encodeURIComponent(backPath)}&params=${encodeURIComponent(backParams)}`
});
}
......
const app = getApp();
const { goodsApi, DFSImg, $themeToLink } = app;
const componentOptions = {
// 组件选项
options: {
......@@ -18,7 +20,7 @@ const componentOptions = {
// 组件数据
data: {
isPageHidden: false, // 页面是否处于隐藏状态
timeData: {},
timeData: {}
},
// 数据监听器
observers: {},
......@@ -54,7 +56,49 @@ const componentOptions = {
},
onChange(e) {
this.setData({ timeData: e.detail });
}
},
onclickProduct() {
let { goodsType } = this.data.datas.componentData;
let {
productId,
terminalProductId,
terminalGoodsMixId
} = this.data.items;
let linkVal = "";
if (goodsType == 0) {
linkVal = `/goods/${productId}?terminalProductId=${terminalProductId}`;
} else if (goodsType == 1) {
linkVal = `/pointShop/goodsDetail?productId${productId}&terminalProductId=${terminalProductId}&terminalGoodsMixId=${terminalGoodsMixId}`;
}
$themeToLink({
type: 1,
link: linkVal
});
},
onclickBuynow() {
let { btnType } = this.data.datas.componentData;
let {
minProductGoodsMixid,
minProductGoodsId,
minGoodsId
} = this.data.items;
let linkVal = "";
if (btnType < 6) {
// 加入购物车
console.log("加入购物车");
// this.$themeAddToCard(item);
} else {
// 进入确认订单
linkVal = `/order/orderConfirm?productGoodsMixId=${minProductGoodsMixid}&productGoodsId=${minProductGoodsId}&goodsId=${minGoodsId}&qty=1&goodsString=null&source=3`;
}
console.log(linkVal, "-------90");
$themeToLink({ type: 1, link: linkVal });
},
toMerchants() {
let { orgId } = this.data.items;
$themeToLink({ type: 1, link: `/merchantsDetail/${orgId}` });
},
},
// 组件生命周期
lifetimes: {
......
<!-- 商品列表item -->
<view class="goodsItem {{datas.componentData.style==='rowList'?'goodsRowList':''}} {{datas.componentData.style==='heap'?'goodsRowList goodsHeapItem':''}}" style="--proGap2:{{datas.componentData.proGap*2}}rpx;">
<view
class="goodsItem {{datas.componentData.style==='rowList'?'goodsRowList':''}} {{datas.componentData.style==='heap'?'goodsRowList goodsHeapItem':''}}"
style="--proGap2:{{datas.componentData.proGap*2}}rpx;"
bindtap="onclickProduct"
>
<view class="goods-item-child {{datas.componentData['borderColorShow']?'goods-item-child-bd':''}}" style="border-radius:{{datas.componentData.borderRadius}}em;--border_color:{{datas.componentData['borderColor']}};box-shadow:{{datas.componentData['cardShadow']?'0rpx 0rpx 10rpx '+datas.componentData['cardShadowSize']*2+'rpx #ccc':''}};">
<!-- 商户入口-顶部 -->
<view class="merchantsEntrance flex" wx:if="{{datas.componentData['merchantsEntrance'] && datas.componentData['merchantsEntranceType'] == 0 && datas.componentData.style!='heap'}}">
<view
class="merchantsEntrance flex"
bindtoMerchants="toMerchants"
wx:if="{{datas.componentData['merchantsEntrance'] && datas.componentData['merchantsEntranceType'] == 0 && datas.componentData.style!='heap'}}"
>
<view class="left flex" wx:if="{{items != null}}">
<view class="logo">
<image mode='widthFix' src="{{items.shopLogoUrl}}" />
......@@ -152,7 +160,7 @@
>
已售罄
</view>
<view wx:if="{{(items&&items.totalQty-0>0||items&&items.oversoldFlag==1)&& datas.componentData['paynow']}}">
<view wx:if="{{(items&&items.totalQty-0>0||items&&items.oversoldFlag==1)&& datas.componentData['paynow']}}" catchtap="onclickBuynow">
<text wx:if="{{datas.componentData.btnType<6}}" style="color:{{datas.componentData.btnColor}}" class="buy-now-icon iconfont-common {{datas.componentData.btnIcon}}"></text>
<view
wx:else
......@@ -191,7 +199,11 @@
</block>
</view>
<!-- 商户入口二 -->
<view class="merchantsEntrance flex" wx:if="{{datas.componentData.merchantsEntrance&&datas.componentData.merchantsEntranceType==1 && datas.componentData.style!='heap'}}">
<view
class="merchantsEntrance flex"
bindtoMerchants="toMerchants"
wx:if="{{datas.componentData.merchantsEntrance&&datas.componentData.merchantsEntranceType==1 && datas.componentData.style!='heap'}}"
>
<view class="left flex" wx:if="{{items!=null}}">
<view class="logo">
<image mode='widthFix' src="http://test-bucket-ant.oss-cn-shanghai.aliyuncs.com/product/ppefWK8BS6.png?x-oss-process=image/resize,limit_1,w_150,h_150" />
......
......@@ -5,11 +5,10 @@
wx:key="index"
data-index="{{index}}"
class="{{'card-swiper-item curdistance' + (swiperCurIndex + index) + (!!item.slideClass? item.slideClass: '')}}"
bindtap="next"
catchtouchstart="touchCard.start"
catchtouchmove="touchCard.move"
catchtouchend="touchCard.end"
catchtouchcancel="touchCard.cancel"
bindtouchstart="touchCard.start"
bindtouchmove="touchCard.move"
bindtouchend="touchCard.end"
bindtouchcancel="touchCard.cancel"
>
<goods-item
style="width:100%"
......
const app = getApp();
const { goodsApi,DFSImg } = app;
const { goodsApi, DFSImg, $themeToLink } = app;
const componentOptions = {
// 组件选项
options: {
......@@ -96,7 +96,12 @@ const componentOptions = {
},
getProductList(code, type) {
let { goodsList, goodsSort } = this.data.datas.componentData;
let { classificationLoadPage,loading,finished,queryProductInfoLoading } = this.data;
let {
classificationLoadPage,
loading,
finished,
queryProductInfoLoading
} = this.data;
if (queryProductInfoLoading == true) {
return;
}
......@@ -111,9 +116,32 @@ const componentOptions = {
loading = true;
}
this.setData({ classificationLoadPage, loading });
let query = { categoryId: this.data.datas.componentData.categoryId, page: this.showRowNum() ? classificationLoadPage : 1, rows: this.showRowNum() ? this.data.classificationLoadNum:this.getItemNum(), sortColumn: goodsSort, sortType: goodsSort != 2 ? 1 : 0, whetherShowSoldOutGoods: this.data.datas.componentData.whetherShowSoldOutGoods, whetherQueryCollectCount: true, whetherUseVirtualSalesQty: true, whetherUseVirtualCollectCount: true, whetherFindDistributionCommission: this.whetherFindDistributionCommission, whetherFindRecommendedCardFlag: this.data.datas.componentData.vipPrice ? 1 : 0, whetherShowGoodsDefaultTagFlag: this.data.datas.componentData.marketingTag ? 1 : 0, whetherFindMultiShopFlag: 1 }; // 当前页 // 一页多少条 //查询销售数量 //查询收藏数 //是否使用虚拟销售数量 //是否使用虚拟收藏人数 //是否查询商品佣金(0:不查询,1:展示,为空不查佣金) //是否查询会员价 1是 0否 //是否展示营销标签 1是 0否 //是否查询多商户 //商城使用
let query = {
categoryId: this.data.datas.componentData.categoryId,
page: this.showRowNum() ? classificationLoadPage : 1,
rows: this.showRowNum()
? this.data.classificationLoadNum
: this.getItemNum(),
sortColumn: goodsSort,
sortType: goodsSort != 2 ? 1 : 0,
whetherShowSoldOutGoods: this.data.datas.componentData
.whetherShowSoldOutGoods,
whetherQueryCollectCount: true,
whetherUseVirtualSalesQty: true,
whetherUseVirtualCollectCount: true,
whetherFindDistributionCommission: this
.whetherFindDistributionCommission,
whetherFindRecommendedCardFlag: this.data.datas.componentData.vipPrice
? 1
: 0,
whetherShowGoodsDefaultTagFlag: this.data.datas.componentData
.marketingTag
? 1
: 0,
whetherFindMultiShopFlag: 1
}; // 当前页 // 一页多少条 //查询销售数量 //查询收藏数 //是否使用虚拟销售数量 //是否使用虚拟收藏人数 //是否查询商品佣金(0:不查询,1:展示,为空不查佣金) //是否查询会员价 1是 0否 //是否展示营销标签 1是 0否 //是否查询多商户 //商城使用
goodsApi.queryProductInfo(query).then(res => {
this.setData({ loading: false, queryProductInfoLoading:false });
this.setData({ loading: false, queryProductInfoLoading: false });
if (res.data.code == 200) {
let goodsLists = res.data.data.list;
if (type == 1) {
......@@ -122,9 +150,9 @@ const componentOptions = {
goodsList = [...goodsList, ...goodsLists];
}
if (goodsLists && goodsLists.length < 10) {
this.setData({ finished:true });
this.setData({ finished: true });
}
this.goodsListVal(goodsList,type);
this.goodsListVal(goodsList, type);
}
});
} else {
......@@ -178,11 +206,11 @@ const componentOptions = {
goodsApi.queryMoreProductInfo(moreQuery).then(res => {
if (res.data.code == 200) {
goodsList = res.data.data;
this.goodsListVal(goodsList,1);
this.goodsListVal(goodsList, 1);
}
});
},
goodsListVal(goodsList,type) {
goodsListVal(goodsList, type) {
console.log(goodsList, "------------goodsListVal");
goodsList.forEach((item, index) => {
item.marketingTag = item.defaultTags
......@@ -192,7 +220,7 @@ const componentOptions = {
)
: [];
item.shopLogoUrl = DFSImg(item.shopLogoUrl);
item.coverImage = DFSImg(item.coverImage,100,100,0);
item.coverImage = DFSImg(item.coverImage, 100, 100, 0);
item.productImgUrl = DFSImg(item.productImgUrl, 100, 100, 0);
item.minPrice = Number(item.minPrice).toFixed(2);
item.qty = Number(item.qty);
......@@ -311,7 +339,24 @@ const componentOptions = {
// 分页加载
onLoad() {
console.log("---触发分页加载");
this.getProductList(1,2);
this.getProductList(1, 2);
},
viewMore() {
let { goodsType,style, categoryName, categoryId } = this.data.datas.componentData;
let linkVal = "";
if (goodsType != 1) {
if (style == "list") {
linkVal = `/goods/commodityMenu?categoryName=${categoryName}&categoryId=${categoryId}`;
} else {
linkVal = `/goods/commodityMenu`;
}
} else {
linkVal = `/pointShop/productList?categoryName=${categoryName}&categoryId=${categoryId}`;
}
$themeToLink({
type: 1,
link:linkVal,
});
}
}
};
......
......@@ -9,7 +9,11 @@
</view>
<view class="title">{{datas.componentData['titles']}}</view>
</view>
<view class="moreTop" wx:if="{{datas.componentData['moreShow'] && datas.componentData.moreButtonSite=='top' && datas.componentData['goodsSource']!='assign'}}">
<view
class="moreTop"
bindtap="viewMore"
wx:if="{{datas.componentData['moreShow'] && datas.componentData.moreButtonSite=='top' && datas.componentData['goodsSource']!='assign'}}"
>
查看更多
<text class="jt"></text>
</view>
......@@ -91,7 +95,14 @@
<view class="goods-heap-Item" wx:if="{{datas.componentData.style==='heap'}}">
<heap-item datas="{{datas}}"></heap-item>
</view>
<view
class="moreBottom"
bindtap="viewMore"
wx:if="{{datas.componentData['moreShow'] && datas.componentData.moreButtonSite=='bottom' && datas.componentData['goodsSource']!='assign'}}"
>
查看更多
<text class="jt"></text>
</view>
</view>
</view>
......@@ -40,7 +40,7 @@ image{
font-size: 13px;
color: #6b6b6b;
}
.moreTop .jt {
.moreTop .jt,.moreBottom .jt{
display: inline-block;
border-top: 1px solid;
border-right: 1px solid;
......@@ -50,6 +50,12 @@ image{
transform: rotate(405deg);
margin-left: 0px;
}
.moreBottom {
font-size: 13px;
text-align: center;
padding-top: 0.54em;
color: #6b6b6b;
}
.goodsItem-list{
flex-wrap: wrap;
}
......
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