Commit 4b9a80fe62a035e02fc6412302be42c85be94379
1 parent
e846192a
5.自定义模板添加秒杀组件,若是手动选择秒杀的卡项,则小程序商城不显示卡项的秒杀活动
Showing
3 changed files
with
11 additions
and
14 deletions
components/diy_seckill/diy_seckill.js
| ... | ... | @@ -78,23 +78,26 @@ Component({ |
| 78 | 78 | // 这里是一个自定义方法 |
| 79 | 79 | customMethod: function () { }, |
| 80 | 80 | init: function (g_id) { |
| 81 | - var th = this, app = getApp(), goodsidlist = ""; | |
| 81 | + var th = this, app = getApp(), goodsidlist = "", idlist = ""; | |
| 82 | 82 | if (g_id.data_type == 2) { |
| 83 | 83 | if (g_id.data && g_id.data.length > 0) { |
| 84 | 84 | //--先把商品ID串起来-- |
| 85 | 85 | g_id.data.forEach(function (val, ind) { |
| 86 | 86 | var item = {}; |
| 87 | 87 | goodsidlist += val.goodsid + ","; |
| 88 | + idlist += val.flashid + ","; | |
| 88 | 89 | }) |
| 89 | 90 | goodsidlist = ut.sub_last(goodsidlist); |
| 91 | + idlist = ut.sub_last(idlist); | |
| 90 | 92 | |
| 91 | 93 | var user_id=getApp().globalData.user_id; |
| 92 | 94 | if(!user_id){ user_id=0;} |
| 93 | 95 | |
| 94 | 96 | //--调用接口,读取秒杀-- |
| 95 | - app.request.promiseGet("/api/ms/flash_sale/getGoodsList?store_id=" | |
| 96 | - + os.stoid + "&goodsidlist=" + goodsidlist+"&user_id="+user_id+"&type=1", {}).then(res => { | |
| 97 | - console.log(res); | |
| 97 | + // var gUrl = "/api/ms/flash_sale/getGoodsList?store_id=" + os.stoid + "&goodsidlist=" + goodsidlist+"&user_id="+user_id+"&type=1"; | |
| 98 | + var gUrl = "/api/ms/flash_sale/getGoodsList?store_id=" + os.stoid + "&idlist=" + idlist + "&user_id="+user_id+"&type=1"; | |
| 99 | + app.request.promiseGet(gUrl, {}).then(res => { | |
| 100 | + | |
| 98 | 101 | //如果秒杀的数组为空的时候 |
| 99 | 102 | var goodslist = res.data.data; |
| 100 | 103 | //就算是添加的活动已经过期,就要用最新的进行中活动 |
| ... | ... | @@ -153,15 +156,9 @@ Component({ |
| 153 | 156 | for(let i in all_array){ |
| 154 | 157 | let item=all_array[i]; |
| 155 | 158 | if(item.user_price) item.price=item.user_price; |
| 156 | - | |
| 157 | - if(item.start_time > newTime) { //活动即将开始 | |
| 159 | + if(item.start_time > newTime) { | |
| 158 | 160 | item.status = 0; |
| 159 | - }; | |
| 160 | - if(item.end_time <= newTime) { //活动结束 | |
| 161 | - item.status = 3; | |
| 162 | - }; | |
| 163 | - | |
| 164 | - if(item.start_time < newTime && item.goods_num > item.buy_num) { | |
| 161 | + } else if(item.end_time > newTime) { | |
| 165 | 162 | item.status = 1; |
| 166 | 163 | }; |
| 167 | 164 | ... | ... |
pages/index/index/index.js
pages/index/index/index.wxml
| ... | ... | @@ -171,7 +171,7 @@ |
| 171 | 171 | </navigator> |
| 172 | 172 | <view class="seckill-list"> |
| 173 | 173 | <swiper class="s_prom" indicator-dots="{{false}}" bindchange="flashSwiperChange"> |
| 174 | - <swiper-item wx:for="{{saleGoods}}" wx:key="{{index}}" class="p_swiper" wx:key="saleGoods" style="740rpx !important;padding: 0; margin-left: 10rpx"> | |
| 174 | + <swiper-item wx:for="{{saleGoods}}" wx:key="{{index}}" class="p_swiper" wx:key="saleGoods" style="padding: 0; margin-left: 10rpx"> | |
| 175 | 175 | <navigator style="flex-shrink: 0;width: 247rpx" class="nav" hover-class="none" url="{{aitem.goods_type == 0 ? ('/pages/goods/goodsInfo/goodsInfo?goods_id=' + aitem.goods_id + '&title=' + aitem.goods_name + '&prom_type=1&prom_id=' + aitem.id):('/packageA/pages/goodsInfo/goodsInfo?goods_id=' + aitem.goods_id + '&title=' + aitem.goods_name + '&prom_type=1&prom_id=' + aitem.id )}}" wx:for="{{item}}" wx:key="item" wx:for-item="aitem" wx:for-index="aind"> |
| 176 | 176 | <view class="imgview"> |
| 177 | 177 | <image src="{{url+aitem.original_img}}" mode="aspectFill" lazy-load="true" data-errorimg="saleGoods[{{index}}][{{aind}}].original_img" binderror="bind_bnerr3" data-img="{{aitem.original_img}}"></image> | ... | ... |