diff --git a/packageC/pages/presell/list/list.js b/packageC/pages/presell/list/list.js index abdf9d4..daed25a 100644 --- a/packageC/pages/presell/list/list.js +++ b/packageC/pages/presell/list/list.js @@ -1,34 +1,26 @@ -var e = getApp(), i = e.request, a = e.globalData.setting,os=a,ut = require("../../../../utils/util.js"); +var e = getApp(), i = e.request, os = e.globalData.setting, ut = require("../../../../utils/util.js"); var regeneratorRuntime = require('../../../../utils/runtime.js'); Page({ data: { - url: a.imghost, - killtime: null, - currentPage: 1, - goodlist: null, - type:1, - timer:null, - ismore:1, //是否可以加载更多 - isshow:0, - ad_data:null, - max_sw_height:200, + url: os.imghost, + goodlist:[], + page: 1, + timer: null, + ismore: 1, //是否可以加载更多 + isshow: 0, + ad_data: null, + max_sw_height: 200, }, //------初始化加载---------- - onLoad: function(t) { - // wx.setNavigationBarTitle({ title: "商品秒杀",}) - var first_leader = t.first_leader; - var type=t.type; - if(type!=undefined){ - this.setData({type:type}); - } - - var th=this; + onLoad: function (t) { + var first_leader = t.first_leader; + var th = this; console.log("------------"); - console.log(first_leader); - getApp().getConfig(); + console.log(first_leader); + getApp().getConfig(); if (first_leader) { getApp().globalData.first_leader = first_leader; @@ -39,205 +31,106 @@ Page({ } }) } - - getApp().request.promiseGet("/api/weshop/ad/page?pid=701&store_id=" + os.stoid, { - data: { - enabled: 1 - } - }).then(res => { - if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length>0){ - var a = res.data.data.pageData; - var narr=[]; - for(var i in a){ - var tt = { - 'ad_code': os.imghost + a[i].ad_code, - 'media_link': '', - 'ad_weapplink':a[i].ad_weapplink - }; - narr.push(tt); - } - th.setData({ad_data:narr}); - } - }) - - }, + getApp().request.promiseGet("/api/weshop/ad/page?pid=1202&store_id=" + os.stoid, { + data: { + enabled: 1 + } + }).then(res => { + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { + var a = res.data.data.pageData; + var narr = []; + for (var i in a) { + var tt = { + 'ad_code': os.imghost + a[i].ad_code, + 'media_link': '', + 'ad_weapplink': a[i].ad_weapplink + }; + narr.push(tt); + } + th.setData({ad_data: narr}); + } + }) - onShow: function(t) { - this.data.ismore=1; - this.data.is_timer=1; - this.data.currentPage=1; - var th=this;th.setData({goodlist:null,}) - this.requestSalelist(); - //设置全局定时器 - th.data.timer=setInterval(function () { - th.countDown(); - },1000); + //调用列表 + this.get_list(); }, - onHide:function(){ - //--清理定时器-- - clearInterval(this.timer); - this.setData({isshow:0}); + onShow: function (t) { }, + //---小于10的格式化函数---- + timeFormat(param) { + return param < 10 ? '0' + param : param; }, - //---小于10的格式化函数---- - timeFormat(param) { - return param < 10 ? '0' + param : param; - }, - - //----倒计时函数----- - countDown() { - if(!this.data.is_timer) return false; - var th=this; - // 获取当前时间,同时得到活动结束时间数组 - let newTime =ut.gettimestamp(); - var endTimeList = this.data.goodlist; - if(endTimeList==null) return null - // 对结束时间进行处理渲染到页面 - for (var i = 0; i < endTimeList.length;i++){ - var o = endTimeList[i]; - var endTime = o.end_time; - if(th.data.type==0) endTime = o.start_time; - let obj = null; - // 如果活动未结束,对时间进行处理 - if (endTime - newTime > 0){ - let time = (endTime - newTime); - // 获取天、时、分、秒 - let day = parseInt(time / (60 * 60 * 24)); - let hou = parseInt(time % (60 * 60 * 24) / 3600); - let min = parseInt(time % (60 * 60 * 24) % 3600 / 60); - let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); - obj = { - day: this.timeFormat(day), hou: this.timeFormat(hou), min: this.timeFormat(min), sec: this.timeFormat(sec), hide: 1 - } - }else{ - //活动已结束,全部设置为'00' - obj = { day: '00', hou: '00', min: '00', sec: '00' } - } - var txt ="goodlist["+i+"].djs"; - th.setData({ [txt]: obj}); - } - }, - - async requestSalelist() { - //--没有更多就不调用-- - if(!this.data.ismore) return false; - var e = this,th=e, i = "/api/ms/flash_sale/spikepage?page=" + e.data.currentPage; - var plist=null,alllist=th.data.goodlist; - if(!alllist) alllist=[]; - - await getApp().request.promiseGet(i, - {isShowLoading:1,data:{store_id:os.stoid,timetype:th.data.type,is_end:0,is_show:1}} - ).then(res=>{ - plist=res.data.data.pageData; - console.log("是什么即将开始",plist); - }); - - if(plist.length<=0){ - - getApp().showWarning("没有更多数据"); - th.data.ismore=0; - if(e.data.currentPage==1 && this.data.type==1){ - setTimeout(function () { - th.data.ismore=1; - th.setData({type:0}); - th.requestSalelist(); - },1000); - } - return false; - } - - //--循环读取接口--- - for(var i=0;i{ - if(res.data.code==0){ - plist[i].status=1; - if(res.data.data<=0) plist[i].status=3; - } - }) - alllist.push(plist[i]); - } - e.data.currentPage++; - console.log("秒杀商品列表", alllist); - th.setData({goodlist:alllist,isshow:1}); - }, - onPullDownRefresh: function() { - this.reloadGoodList(); - }, - reloadGoodList: function() { - this.data.goodlist = null, this.data.currentPage = 1, this.requestSalelist(); + onReachBottom: function () { + this.get_list(); }, - onReachBottom: function() { - this.requestSalelist(); + //图片失败,默认图片 + bind_bnerr2: function (e) { + var _errImg = e.target.dataset.errorimg; + var val = e.target.dataset.val; + if (val != undefined && val != null && val != 'null') { + var _errObj = {}; + _errObj[_errImg] = "/public/images/default_goods_image_240.gif"; + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; + } }, - //点击tab事件 - tip:function(e){ - var a=e.currentTarget.dataset.ty,th=this;th.data.ismore=1; - this.setData({type:a,goodlist:null}); - this.reloadGoodList(); + + imageLoad: function (e) { + var imgwidth = e.detail.width; + var imgheight = e.detail.height; + //宽高比 + var ratio = imgwidth / imgheight; + //计算的高度值 + var viewHeight = 750 / ratio; + var hei = this.data.max_sw_height; + if (hei < viewHeight) { + this.setData({max_sw_height: viewHeight}); + } }, - //---------分享配置-------- - onShareAppMessage: function (e) { - var curPage=this; - var pagePath = curPage.route; //当前页面url - if (pagePath.indexOf('/') != 0) { - pagePath = '/' + pagePath; - } - if(getApp().globalData.user_id){ + //获取数据 + get_list(){ + var self = this; + if (this.data.loading) return false; + if (this.data.no_more) return false; + this.data.loading = 1; - if(pagePath.indexOf("?")>0){ - pagePath+="&first_leader="+getApp().globalData.user_id; - }else{ - pagePath+="?first_leader="+getApp().globalData.user_id; - } + var req = { + is_end: 0, + store_id: os.stoid, + page: this.data.page, + pageSize: 10, + timetype: 1 } - console.log("11"+pagePath); - return { - title: "限时秒杀", - path:pagePath, - } - }, + //调用接口获取数据 + getApp().request.get("/api/weshop/marketing/marketingPresellList/page", { + data: req, + success: function (res) { + self.data.loading = 0; + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { + var list = self.data.goodlist ? self.data.goodlist : []; + var arr = res.data.data.pageData; + //数组合起来 + for (var i in arr) { + list.push(arr[i]); + } + self.data.page++; + self.setData({goodlist: list}); + if (arr.length < 10) { + self.setData({no_more: 1}) + } + } else { + self.setData({no_more: 1}) + } + self.setData({is_get: 1}) - //图片失败,默认图片 - bind_bnerr2: function (e) { - var _errImg = e.target.dataset.errorimg; - var val = e.target.dataset.val; - if(val!=undefined && val!=null && val!='null' ){ - var _errObj = {}; - _errObj[_errImg] = "/public/images/default_goods_image_240.gif"; - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; - } + } + }) }, - - onShareTimeline() { - var store_name=getApp().globalData.config?getApp().globalData.config.store_name:''; - if(!store_name) - store_name=getApp().globalData.setting.appName; - return { - title: '秒杀活动-' + store_name, - } - }, - - imageLoad:function(e){ - var imgwidth = e.detail.width; - var imgheight = e.detail.height; - //宽高比 - var ratio = imgwidth / imgheight; - //计算的高度值 - var viewHeight = 750 / ratio; - var hei=this.data.max_sw_height; - - if (hei< viewHeight) { - this.setData({ max_sw_height: viewHeight }); - } - } + }); diff --git a/packageC/pages/presell/list/list.json b/packageC/pages/presell/list/list.json index fccb8ce..137a61b 100644 --- a/packageC/pages/presell/list/list.json +++ b/packageC/pages/presell/list/list.json @@ -2,6 +2,7 @@ "navigationBarTitleText": "预售活动列表", "enablePullDownRefresh": false, "usingComponents": { - "share_box": "/components/share_box/share_box" + "share_box": "/components/share_box/share_box", + "nodata": "/components/nodata/nodata" } } \ No newline at end of file diff --git a/packageC/pages/presell/list/list.wxml b/packageC/pages/presell/list/list.wxml index 928a340..a4b82b1 100644 --- a/packageC/pages/presell/list/list.wxml +++ b/packageC/pages/presell/list/list.wxml @@ -5,8 +5,7 @@ + indicator-dots="true" interval="2500" style="height:{{max_sw_height}}rpx" > @@ -32,71 +31,50 @@ - + - - {{item.title}} + {{item.act_name}} - - - 已预售{{type==1?filters.toFix(100-(item.buy_num+item.virtual)/(item.goods_num+item.virtual)*100,0):'100'}}% + + 已预售{{filters.toFix((item.buy_goodnum+item.virtual_qty)/(item.presell_sumqty+item.virtual_qty)*100,0)}}% - 库存还剩{{item.buy_num+item.virtual}}件 - + 库存还剩{{item.presell_sumqty-item.buy_goodnum}}件 - - - + - + ¥{{item.presell_price}} {{item.price}} 零售价¥{{item.market_price}} 去抢购 - - - -没有相关内容 + +-- 没有更多 -- + + - + diff --git a/packageC/pages/presell/list/list.wxss b/packageC/pages/presell/list/list.wxss index 84af0b5..ce46633 100644 --- a/packageC/pages/presell/list/list.wxss +++ b/packageC/pages/presell/list/list.wxss @@ -138,10 +138,11 @@ padding-top: 4rpx; } .no-more { - font-size: 30rpx; + font-size: 26rpx; line-height: 2; text-align: center; - color: #333; + color: #666; + margin-top: 10rpx; } .kill-btn>navigator.huise{background-color: #999;} @@ -165,7 +166,7 @@ margin-left: 45rpx; } .total{ width:215rpx;height:26rpx;border-radius:20rpx; - background: #ffe3e2; + background: #aaa; } .xc-buttom-money{ align-items: baseline;