diff --git a/components/diy_seckill/diy_seckill.js b/components/diy_seckill/diy_seckill.js index bf2acc6..3a42c9f 100644 --- a/components/diy_seckill/diy_seckill.js +++ b/components/diy_seckill/diy_seckill.js @@ -78,23 +78,26 @@ Component({ // 这里是一个自定义方法 customMethod: function () { }, init: function (g_id) { - var th = this, app = getApp(), goodsidlist = ""; + var th = this, app = getApp(), goodsidlist = "", idlist = ""; if (g_id.data_type == 2) { if (g_id.data && g_id.data.length > 0) { //--先把商品ID串起来-- g_id.data.forEach(function (val, ind) { var item = {}; goodsidlist += val.goodsid + ","; + idlist += val.flashid + ","; }) goodsidlist = ut.sub_last(goodsidlist); + idlist = ut.sub_last(idlist); var user_id=getApp().globalData.user_id; if(!user_id){ user_id=0;} //--调用接口,读取秒杀-- - app.request.promiseGet("/api/ms/flash_sale/getGoodsList?store_id=" - + os.stoid + "&goodsidlist=" + goodsidlist+"&user_id="+user_id+"&type=1", {}).then(res => { - console.log(res); + // var gUrl = "/api/ms/flash_sale/getGoodsList?store_id=" + os.stoid + "&goodsidlist=" + goodsidlist+"&user_id="+user_id+"&type=1"; + var gUrl = "/api/ms/flash_sale/getGoodsList?store_id=" + os.stoid + "&idlist=" + idlist + "&user_id="+user_id+"&type=1"; + app.request.promiseGet(gUrl, {}).then(res => { + //如果秒杀的数组为空的时候 var goodslist = res.data.data; //就算是添加的活动已经过期,就要用最新的进行中活动 @@ -153,15 +156,9 @@ Component({ for(let i in all_array){ let item=all_array[i]; if(item.user_price) item.price=item.user_price; - - if(item.start_time > newTime) { //活动即将开始 + if(item.start_time > newTime) { item.status = 0; - }; - if(item.end_time <= newTime) { //活动结束 - item.status = 3; - }; - - if(item.start_time < newTime && item.goods_num > item.buy_num) { + } else if(item.end_time > newTime) { item.status = 1; }; diff --git a/pages/index/index/index.js b/pages/index/index/index.js index c475908..72f8320 100644 --- a/pages/index/index/index.js +++ b/pages/index/index/index.js @@ -506,7 +506,7 @@ Page({ if (data && data.length > 0) { var temp_data = data[0]; var t_arr = JSON.parse(temp_data.json_str); - console.log(t_arr); + th.setData({ template_arr: t_arr, isTemplate: 1, diff --git a/pages/index/index/index.wxml b/pages/index/index/index.wxml index 6e7b9d0..90a0652 100644 --- a/pages/index/index/index.wxml +++ b/pages/index/index/index.wxml @@ -171,7 +171,7 @@ - +