diff --git a/packageB/pages/zuhegou/list/g_filter.wxs b/packageB/pages/zuhegou/list/g_filter.wxs new file mode 100644 index 0000000..9719e7d --- /dev/null +++ b/packageB/pages/zuhegou/list/g_filter.wxs @@ -0,0 +1,29 @@ +var g_filters = { + has_char:function(url,key){ + if(!url) return -1; + return url.indexOf(key); + }, + beg_time:function(beg_date){ + var fmt1 = beg_date.substring(0, 19); + var reg = getRegExp("-", "g"); + var fmt2 = fmt1.replace(reg, '/'); + var t1 = getDate(fmt2); + var tnow=getDate(); + if(t1<=tnow) return 1; + return 0; + }, + end_time:function(end_date){ + var fmt1 = end_date.substring(0, 19); + var reg = getRegExp("-", "g"); + var fmt2 = fmt1.replace(reg, '/'); + var t1 = getDate(fmt2); + var tnow=getDate(); + if(t1>=tnow) return 1; + return 0; + } +} +module.exports = { + has_char: g_filters.has_char, + beg_time: g_filters.beg_time, + end_time: g_filters.end_time, +} \ No newline at end of file diff --git a/packageB/pages/zuhegou/list/list.js b/packageB/pages/zuhegou/list/list.js new file mode 100644 index 0000000..dc60098 --- /dev/null +++ b/packageB/pages/zuhegou/list/list.js @@ -0,0 +1,248 @@ +var e = getApp(), i = e.request, a = e.globalData.setting,os=a,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, + }, + + //------初始化加载---------- + 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; + + // console.log("------------"); + console.log(first_leader); + getApp().getConfig(); + + if (first_leader) { + getApp().globalData.first_leader = first_leader; + //调用接口判断是不是会员 + getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => { + if (res.data.code == 0) { + getApp().globalData.guide_id = res.data.data.id; + } + }) + } + + + // 广告 + getApp().request.promiseGet("/api/weshop/ad/page?pid=1203&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); + }, + + onHide:function() { + //--清理定时器-- + // clearInterval(this.timer); + this.setData({isshow:0}); + }, + + //---小于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/weshop/prom/zhbuy/page?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,user_id:getApp().globalData.user_id}} + ).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:plist,isshow:1}); + + }, + onPullDownRefresh: function() { + this.reloadGoodList(); + }, + reloadGoodList: function() { + this.data.goodlist = null, this.data.currentPage = 1, this.requestSalelist(); + }, + + onReachBottom: function() { + this.requestSalelist(); + }, + + //点击tab事件 + tip:function(e) { + var a=e.currentTarget.dataset.ty,th=this;th.data.ismore=1; + this.setData({type:a,goodlist:null}); + this.reloadGoodList(); + }, + + + //---------分享配置-------- + onShareAppMessage: function (e) { + var curPage=this; + var pagePath = curPage.route; //当前页面url + if (pagePath.indexOf('/') != 0) { + pagePath = '/' + pagePath; + } + if(getApp().globalData.user_id){ + + if(pagePath.indexOf("?")>0){ + pagePath+="&first_leader="+getApp().globalData.user_id; + }else{ + pagePath+="?first_leader="+getApp().globalData.user_id; + } + } + + // console.log("11"+pagePath); + return { + title: "组合购", + path:pagePath, + } + }, + + //图片失败,默认图片 + 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/packageB/pages/zuhegou/list/list.json b/packageB/pages/zuhegou/list/list.json new file mode 100644 index 0000000..9e9bfea --- /dev/null +++ b/packageB/pages/zuhegou/list/list.json @@ -0,0 +1,6 @@ +{ + "navigationBarTitleText": "组合列表", + "usingComponents": { + "share_box": "/components/share_box/share_box" + } +} \ No newline at end of file diff --git a/packageB/pages/zuhegou/list/list.wxml b/packageB/pages/zuhegou/list/list.wxml new file mode 100644 index 0000000..df87587 --- /dev/null +++ b/packageB/pages/zuhegou/list/list.wxml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.name}} + + + + + + + 组合数量: {{item.zhbuyqty}} + 活动时间: {{filters.format_time(item.start_time) + '至' + filters.format_time(item.end_time)}} + + + + {{item.zhprice}} + + + + + + + + + + + + + + + + + + 没有相关内容 + + + + + diff --git a/packageB/pages/zuhegou/list/list.wxss b/packageB/pages/zuhegou/list/list.wxss new file mode 100644 index 0000000..3ac1386 --- /dev/null +++ b/packageB/pages/zuhegou/list/list.wxss @@ -0,0 +1,178 @@ + page{ + background: #eee; + color: #333; + } + .body_frame{ + /* width: 100%; + height: 100%; */ + + } +.xc-top-img{ + width: 100%; + height: 333rpx; + margin-top: 5rpx; +} +.kill-list{ + /* height: 807rpx; */ + /* overflow-y: scroll; */ + padding: 10rpx 20rpx; +} +.seckill_list{ +/* margin-top: -10rpx; +left: 2%; */ +} +.seckill{ + width: 95%; +margin: auto; + +} +.kill-time { + text-align: center; + justify-content: space-around; + align-items: center; + height: 101rpx; + border-bottom: 1px solid #ddd; + border-top: 1px solid #ddd; + background-color: #f6f6f6; +} +.kill-time .theader{ + display: flex; margin: 0 auto; align-items: center; + height: 100rpx; + +} +.kill-time .theader .timeac { + font-size: 32rpx; height:100%; width: 50%; + color: #333; background-color: #fff; + +} +/* .kill-time .theader .timeac.left{border-top-left-radius: 86rpx; border-bottom-left-radius: 86rpx;} +.kill-time .theader .timeac.right{border-top-right-radius: 86rpx; border-bottom-right-radius: 86rpx;} */ +.kill-time .theader .timeac.active{color: #c4182e} + +.kill-item { + display: flex; + justify-content: space-between; + background-color: #fff; + padding: 20rpx; + margin-bottom: 20rpx; + border-radius: 10rpx; + /* height: 249rpx; */ + align-items: center; +} + +.kill-pic { + width: 215rpx; + height: 215rpx; +} + +.kill-cont { + width: 465rpx; + margin-left:20rpx; + margin-right: 5rpx; +} + +.goods-name { + /* height: 60rpx; */ + font-size: 27rpx; + color: #555; + line-height: 1.4; + +} + +.goods-num { + padding-top: 10rpx; + display: flex; + justify-content: space-between; + line-height: 42rpx; + font-size: 24rpx; + color: #999; +} + +.goods-num .co-red { + font-size: 30rpx; + font-weight: bold; +} + +.underline { + text-decoration: line-through; + color:#999999; font-size: 20rpx; + margin-left: 10rpx; + line-height: 30rpx; +} + +.kill-btn { + text-align: right; + display: flex; +height: 100%; +align-items: flex-end; +padding-top: 4rpx; + +} + +.kill-btn>navigator { + padding: 0 20rpx; + background: #e23245; + color: #fff; + border-radius: 20rpx; + margin-top: 37px; + +} + +.kill-btn .gray { + background-color: #555; +} + +.no-more { + font-size: 30rpx; + line-height: 2; + text-align: center; + color: #333; +} + +.kill-btn>navigator.huise{background-color: #999;} +.xc-seckill-bottom { + position: fixed; + bottom: 0; + width: 100%; +} +.xc-bottom{ + width: 45rpx; + height: 45rpx; + margin-right: 13rpx; +} +.xc-border-right{ + border-right: 4rpx solid #eee; + +} +.ml10{ +margin-left: 45rpx; +} +.total{ + width:215rpx;height:26rpx;border-radius:20rpx; + background: #ffe3e2; +} +.xc-buttom-money{ + align-items: baseline; + padding-top: 10rpx; +} + +.xc-miaosha{ +width: 68rpx; +height: 40rpx; + +} +.xc-strip-frame{ + width:440rpx;margin-top: 10rpx; +} +.xc-strip-blank{ + width:180rpx; +height: 26rpx; +} +.xc-fill{ +border-radius:20rpx;height:26rpx; +} +.xc-fill-text{ + left:34%; + line-height: 26rpx; + +} \ No newline at end of file