From e9445e732eb9ff95e538641f8d01d224bc811a33 Mon Sep 17 00:00:00 2001 From: luo <17530855@qq.com> Date: Tue, 15 Aug 2023 18:01:21 +0800 Subject: [PATCH] 预售组件1 --- components/diy_public/diy_public.js | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------- components/diy_public/diy_public.wxml | 12 ++++++------ pages/index/index/index.wxml | 3 +++ pages/template/index.wxml | 3 +++ 4 files changed, 81 insertions(+), 27 deletions(-) diff --git a/components/diy_public/diy_public.js b/components/diy_public/diy_public.js index 343b329..2eadc60 100644 --- a/components/diy_public/diy_public.js +++ b/components/diy_public/diy_public.js @@ -1,7 +1,7 @@ // var e = function(e) { // return e && e.__esModule ? e : { // default: e -// }; +// }; // }(require("../../utils/LoadMore3.js")), // n = new e.default(), var t = getApp(), @@ -48,7 +48,8 @@ Component({ imgobj:{ '1':"/miniapp/images/component/seckill.png", '2':"/miniapp/images/component/pingd/pingd.png", - '6':"/miniapp/images/component/pingd/pingd.png" + '6':"/miniapp/images/component/pingd/pingd.png", + '8':"/miniapp/images/component/presale.png", }, nav1:'/packageA/pages/goodsInfo/goodsInfo?', nav2:'/pages/goods/goodsInfo/goodsInfo?', @@ -99,6 +100,13 @@ Component({ nav2:'/pages/goods/goodsInfo/goodsInfo?' }) } + if (this.data.prom_type==8) { //预售 + this.setData({ + prom_text:'已售', + nav1:'/packageC/pages/presell/goodsInfo/goodsInfo?', + nav2:'/packageC/pages/presell/goodsInfo/goodsInfo?' + }) + } var g_id = this.data.object; this.init(g_id); @@ -153,12 +161,21 @@ Component({ +os.stoid+"&aidlist="+goodsidlist + "&user_id="+user_id; } + if (th.data.prom_type==8) { //预售 + gUrl="/api/weshop/marketing/marketingPresellList/page?store_id=" + +os.stoid+"&goodsidlist="+goodsidlist + "&user_id="+user_id+'&is_end=0&timetype=3&isuse=1'; + } - app.request.promiseGet(gUrl, {}).then(res => { + app.request.promiseGet(gUrl, {}).then(res => { + //如果秒杀的数组为空的时候 var goodslist = res.data.data; + if (th.data.prom_type==8) { //预售 + goodslist = res.data.data ? res.data.data.pageData : [] + } + //就算是添加的活动已经过期,就要用最新的进行中活动 if (goodslist && goodslist.length > 0) { th.set_goods_list(g_id.data, goodslist); @@ -197,6 +214,18 @@ Component({ timetype: 2, } } + if (this.data.prom_type==8) { //预售 + gUrl="/api/weshop/marketing/marketingPresellList/page?page=1&pageSize=9" + req={ + store_id:os.stoid, + is_end:0, + timetype:3, + isuse:1, + page:1, + user_id:user_id, + pageSize:9 + } + } getApp().request.promiseGet(gUrl, { isShowLoading: 1, data:req } @@ -211,6 +240,7 @@ Component({ //就算是添加的活动已经过期,就要用最新的活动 set_goods_list(g_id, goodslist) { + let prom_type=this.data.prom_type goodslist.forEach(function (vy, indy) { if(!vy.id) vy.id=vy.prom_id; @@ -240,29 +270,30 @@ Component({ let item=all_array[i]; if(item.user_price) item.price=item.user_price; if(item.start_time > newTime) { - item.status = 0; + item.status = 0; //活动没开始 } else if(item.end_time > newTime) { - item.status = 1; + item.status = 1; // 活动进行中 }; } - var promisies = []; - for (const key in all_array) { - if (Object.hasOwnProperty.call(all_array, key)) { - const val = all_array[key]; - - promisies[key] = getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + - os.stoid + "/"+prom_type+"/" + val.id, - {} - ).then(res => { - if (res.data.code == 0) { - if (res.data.data <= 0) all_array[key].status = 2; - }; - }); - } - } + var promisies = []; + if (th.data.prom_type !=8) { + for (const key in all_array) { + if (Object.hasOwnProperty.call(all_array, key)) { + const val = all_array[key]; + promisies[key] = getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + + os.stoid + "/"+prom_type+"/" + val.id, + {} + ).then(res => { + if (res.data.code == 0) { + if (res.data.data <= 0) all_array[key].status = 2;//已售完 + }; + }); + } + } + } Promise.all(promisies).then(() => { @@ -271,10 +302,24 @@ Component({ for(let i in all_array){ let item=all_array[i]; if(newTime > item.end_time) { - all_array[i].status = 3; + all_array[i].status = 3; //活动结束 }; // let price=all_array[i].price.toFixed(2) let price=all_array[i].price + '' + if (th.data.prom_type==8) { //预售 + price = all_array[i].presell_price + '' + if (all_array[i].status ===0) { + all_array[i].goods_num=all_array[i].presell_sumqty*1 + all_array[i].virtual_qty*1 + all_array[i].buy_num=all_array[i].buy_goodnum + }else{ + all_array[i].goods_num=all_array[i].presell_sumqty*1 + all_array[i].virtual_qty*1 + all_array[i].buy_num=all_array[i].buy_goodnum + all_array[i].virtual_qty*1 + } + + + } + + if (price && price.indexOf('.') > -1) { let priceArr = price.split(".") all_array[i].price_n = priceArr[0] @@ -416,6 +461,9 @@ Component({ if (this.data.prom_type==2) { //团购 url="/packageC/pages/group_list/group_list"; } + if (this.data.prom_type==8) { //预售 + url="/packageC/pages/presell/list/list"; + } wx.navigateTo({ url diff --git a/components/diy_public/diy_public.wxml b/components/diy_public/diy_public.wxml index aa9b237..c5060cf 100644 --- a/components/diy_public/diy_public.wxml +++ b/components/diy_public/diy_public.wxml @@ -16,7 +16,7 @@ - + @@ -76,7 +76,7 @@ - + @@ -130,7 +130,7 @@ - + @@ -178,7 +178,7 @@ - + @@ -231,7 +231,7 @@ - + @@ -422,7 +422,7 @@ - + diff --git a/pages/index/index/index.wxml b/pages/index/index/index.wxml index 28bb6eb..15aa246 100644 --- a/pages/index/index/index.wxml +++ b/pages/index/index/index.wxml @@ -516,6 +516,9 @@ + + + diff --git a/pages/template/index.wxml b/pages/template/index.wxml index f5ca734..4071247 100644 --- a/pages/template/index.wxml +++ b/pages/template/index.wxml @@ -69,6 +69,9 @@ + + + -- libgit2 0.21.4