Commit f283ad571df68dce706a45affff4e1aacbd57d65

Authored by taiyuan
1 parent 8a4e9596

组合购列表

packageB/pages/zuhegou/list/g_filter.wxs 0 → 100644
  1 +var g_filters = {
  2 + has_char:function(url,key){
  3 + if(!url) return -1;
  4 + return url.indexOf(key);
  5 + },
  6 + beg_time:function(beg_date){
  7 + var fmt1 = beg_date.substring(0, 19);
  8 + var reg = getRegExp("-", "g");
  9 + var fmt2 = fmt1.replace(reg, '/');
  10 + var t1 = getDate(fmt2);
  11 + var tnow=getDate();
  12 + if(t1<=tnow) return 1;
  13 + return 0;
  14 + },
  15 + end_time:function(end_date){
  16 + var fmt1 = end_date.substring(0, 19);
  17 + var reg = getRegExp("-", "g");
  18 + var fmt2 = fmt1.replace(reg, '/');
  19 + var t1 = getDate(fmt2);
  20 + var tnow=getDate();
  21 + if(t1>=tnow) return 1;
  22 + return 0;
  23 + }
  24 +}
  25 +module.exports = {
  26 + has_char: g_filters.has_char,
  27 + beg_time: g_filters.beg_time,
  28 + end_time: g_filters.end_time,
  29 +}
0 30 \ No newline at end of file
... ...
packageB/pages/zuhegou/list/list.js 0 → 100644
  1 +var e = getApp(), i = e.request, a = e.globalData.setting,os=a,ut = require("../../../../utils/util.js");
  2 +var regeneratorRuntime = require('../../../../utils/runtime.js');
  3 +
  4 +Page({
  5 + data: {
  6 + url: a.imghost,
  7 + killtime: null,
  8 + currentPage: 1,
  9 + goodlist: null,
  10 + type:1,
  11 + timer:null,
  12 + ismore:1, //是否可以加载更多
  13 + isshow:0,
  14 + ad_data:null,
  15 + max_sw_height:200,
  16 + },
  17 +
  18 + //------初始化加载----------
  19 + onLoad: function(t) {
  20 + // wx.setNavigationBarTitle({ title: "商品秒杀",})
  21 + var first_leader = t.first_leader;
  22 + var type=t.type;
  23 + if(type!=undefined){
  24 + this.setData({type:type});
  25 + }
  26 +
  27 + var th=this;
  28 +
  29 + // console.log("------------");
  30 + console.log(first_leader);
  31 + getApp().getConfig();
  32 +
  33 + if (first_leader) {
  34 + getApp().globalData.first_leader = first_leader;
  35 + //调用接口判断是不是会员
  36 + getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => {
  37 + if (res.data.code == 0) {
  38 + getApp().globalData.guide_id = res.data.data.id;
  39 + }
  40 + })
  41 + }
  42 +
  43 +
  44 + // 广告
  45 + getApp().request.promiseGet("/api/weshop/ad/page?pid=1203&store_id=" + os.stoid, {
  46 + data: {
  47 + enabled: 1
  48 + }
  49 + }).then(res => {
  50 + if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length>0){
  51 + var a = res.data.data.pageData;
  52 + var narr=[];
  53 + for(var i in a){
  54 + var tt = {
  55 + 'ad_code': os.imghost + a[i].ad_code,
  56 + 'media_link': '',
  57 + 'ad_weapplink':a[i].ad_weapplink
  58 + };
  59 + narr.push(tt);
  60 + }
  61 + th.setData({ad_data:narr});
  62 + }
  63 + });
  64 +
  65 + },
  66 +
  67 +
  68 + onShow: function(t) {
  69 + this.data.ismore=1;
  70 + this.data.is_timer=1;
  71 + this.data.currentPage=1;
  72 + var th=this;th.setData({goodlist:null,})
  73 + this.requestSalelist();
  74 + //设置全局定时器
  75 + // th.data.timer=setInterval(function () {
  76 + // th.countDown();
  77 + // },1000);
  78 + },
  79 +
  80 + onHide:function() {
  81 + //--清理定时器--
  82 + // clearInterval(this.timer);
  83 + this.setData({isshow:0});
  84 + },
  85 +
  86 + //---小于10的格式化函数----
  87 + timeFormat(param) {
  88 + return param < 10 ? '0' + param : param;
  89 + },
  90 +
  91 + //----倒计时函数-----
  92 + countDown() {
  93 + if(!this.data.is_timer) return false;
  94 + var th=this;
  95 + // 获取当前时间,同时得到活动结束时间数组
  96 + let newTime =ut.gettimestamp();
  97 + var endTimeList = this.data.goodlist;
  98 + if(endTimeList==null) return null
  99 + // 对结束时间进行处理渲染到页面
  100 + for (var i = 0; i < endTimeList.length;i++){
  101 + var o = endTimeList[i];
  102 + var endTime = o.end_time;
  103 + if(th.data.type==0) endTime = o.start_time;
  104 + let obj = null;
  105 + // 如果活动未结束,对时间进行处理
  106 + if (endTime - newTime > 0){
  107 + let time = (endTime - newTime);
  108 + // 获取天、时、分、秒
  109 + let day = parseInt(time / (60 * 60 * 24));
  110 + let hou = parseInt(time % (60 * 60 * 24) / 3600);
  111 + let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
  112 + let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
  113 + obj = {
  114 + day: this.timeFormat(day), hou: this.timeFormat(hou), min: this.timeFormat(min), sec: this.timeFormat(sec), hide: 1
  115 + }
  116 + }else{
  117 + //活动已结束,全部设置为'00'
  118 + obj = { day: '00', hou: '00', min: '00', sec: '00' }
  119 + }
  120 + var txt ="goodlist["+i+"].djs";
  121 + th.setData({ [txt]: obj});
  122 + }
  123 + },
  124 +
  125 + async requestSalelist() {
  126 + //--没有更多就不调用--
  127 + if(!this.data.ismore) return false;
  128 +
  129 + var e = this,th=e, i = "/api/weshop/prom/zhbuy/page?page=" + e.data.currentPage;
  130 + var plist=null,alllist=th.data.goodlist;
  131 + if(!alllist) alllist=[];
  132 +
  133 + await getApp().request.promiseGet(i,
  134 + {isShowLoading:1,data:{store_id:os.stoid,user_id:getApp().globalData.user_id}}
  135 + ).then(res=>{
  136 + plist=res.data.data.pageData;
  137 + console.log("是什么即将开始",plist);
  138 + });
  139 +
  140 + if(plist.length<=0) {
  141 +
  142 + getApp().showWarning("没有更多数据");
  143 + th.data.ismore=0;
  144 + if(e.data.currentPage==1 && this.data.type==1){
  145 + // setTimeout(function () {
  146 + // th.data.ismore=1;
  147 + // th.setData({type:0});
  148 + // th.requestSalelist();
  149 + // },1000);
  150 + }
  151 + return false;
  152 + }
  153 +
  154 + //--循环读取接口---
  155 + // for(var i=0;i<plist.length;i++) {
  156 + // var prom_id = plist[i].id;
  157 + // await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
  158 + // os.stoid + "/1/" + prom_id, {}
  159 + // ).then(res=>{
  160 + // if(res.data.code==0){
  161 + // plist[i].status=1;
  162 + // if(res.data.data<=0) plist[i].status=3;
  163 + // }
  164 + // })
  165 + // alllist.push(plist[i]);
  166 + // }
  167 + e.data.currentPage++;
  168 + // console.log("秒杀商品列表", alllist);
  169 + th.setData({goodlist:plist,isshow:1});
  170 +
  171 + },
  172 + onPullDownRefresh: function() {
  173 + this.reloadGoodList();
  174 + },
  175 + reloadGoodList: function() {
  176 + this.data.goodlist = null, this.data.currentPage = 1, this.requestSalelist();
  177 + },
  178 +
  179 + onReachBottom: function() {
  180 + this.requestSalelist();
  181 + },
  182 +
  183 + //点击tab事件
  184 + tip:function(e) {
  185 + var a=e.currentTarget.dataset.ty,th=this;th.data.ismore=1;
  186 + this.setData({type:a,goodlist:null});
  187 + this.reloadGoodList();
  188 + },
  189 +
  190 +
  191 + //---------分享配置--------
  192 + onShareAppMessage: function (e) {
  193 + var curPage=this;
  194 + var pagePath = curPage.route; //当前页面url
  195 + if (pagePath.indexOf('/') != 0) {
  196 + pagePath = '/' + pagePath;
  197 + }
  198 + if(getApp().globalData.user_id){
  199 +
  200 + if(pagePath.indexOf("?")>0){
  201 + pagePath+="&first_leader="+getApp().globalData.user_id;
  202 + }else{
  203 + pagePath+="?first_leader="+getApp().globalData.user_id;
  204 + }
  205 + }
  206 +
  207 + // console.log("11"+pagePath);
  208 + return {
  209 + title: "组合购",
  210 + path:pagePath,
  211 + }
  212 + },
  213 +
  214 + //图片失败,默认图片
  215 + bind_bnerr2: function (e) {
  216 + var _errImg = e.target.dataset.errorimg;
  217 + var val = e.target.dataset.val;
  218 + if(val==undefined || val==null || val=='null') {
  219 + var _errObj = {};
  220 + _errObj[_errImg] = "/public/images/default_goods_image_240.gif";
  221 + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
  222 + }
  223 + },
  224 +
  225 + // onShareTimeline() {
  226 + // var store_name=getApp().globalData.config?getApp().globalData.config.store_name:'';
  227 + // if(!store_name)
  228 + // store_name=getApp().globalData.setting.appName;
  229 + // return {
  230 + // title: '秒杀活动-' + store_name,
  231 + // }
  232 + // },
  233 +
  234 + imageLoad:function(e){
  235 + var imgwidth = e.detail.width;
  236 + var imgheight = e.detail.height;
  237 + //宽高比
  238 + var ratio = imgwidth / imgheight;
  239 + //计算的高度值
  240 + var viewHeight = 750 / ratio;
  241 + var hei=this.data.max_sw_height;
  242 +
  243 + if (hei< viewHeight) {
  244 + this.setData({ max_sw_height: viewHeight });
  245 + }
  246 + }
  247 +
  248 +});
... ...
packageB/pages/zuhegou/list/list.json 0 → 100644
  1 +{
  2 + "navigationBarTitleText": "组合列表",
  3 + "usingComponents": {
  4 + "share_box": "/components/share_box/share_box"
  5 + }
  6 +}
0 7 \ No newline at end of file
... ...
packageB/pages/zuhegou/list/list.wxml 0 → 100644
  1 +<wxs module="filters" src="../../../../utils/filter.wxs"></wxs>
  2 +<wxs module="g_filter" src="g_filter.wxs"></wxs>
  3 +<view class=" body_frame">
  4 +
  5 +<block wx:if="{{ad_data}}">
  6 +
  7 + <swiper class="swiper" circular="true" autoplay="true"
  8 + indicator-dots="true" interval="2500"
  9 + style="height:{{max_sw_height}}rpx" >
  10 + <block wx:for="{{ad_data}}">
  11 +
  12 + <navigator url="{{item.ad_weapplink}}" class="s1_gk_a1" wx:if="{{g_filter.has_char(item.ad_weapplink,'plugin')>=0}}">
  13 + <swiper-item>
  14 + <image src="{{item.ad_code}}" style="width: 100%;" bindload="imageLoad" data-index="{{index}}" class="slide-image" mode="widthFix" lazy-load="true"/>
  15 + </swiper-item>
  16 + </navigator>
  17 +
  18 + <view data-url="{{item.ad_weapplink}}" class="s1_gk_a1" bindtap="go_url" wx:else>
  19 + <swiper-item>
  20 + <image src="{{item.ad_code}}" style="width: 100%;" bindload="imageLoad" data-index="{{index}}" class="slide-image" mode="widthFix" lazy-load="true"/>
  21 + </swiper-item>
  22 + </view>
  23 +
  24 + </block>
  25 + </swiper>
  26 +
  27 +
  28 +</block>
  29 +<block wx:else>
  30 + <image class="xc-top-img" src="{{url}}/miniapp/images/seckill_top_img.jpg"></image>
  31 +</block>
  32 +
  33 +
  34 +
  35 +<view class="kill-list">
  36 + <view class="kill-item" wx:for="{{goodlist}}">
  37 + <navigator class="kill-pic rel" url="/packageB/pages/zuhegou/index/index?id={{item.id}}" hover-class="none">
  38 + <!-- <image class="abs xc-miaosha" src="{{url}}/miniapp/images/zms.png"></image> -->
  39 + <image class="wh100" src="{{url+item.img_url}}" data-val="{{item.img_url}}"
  40 + data-errorimg="goodlist[{{index}}].img_url" binderror="bind_bnerr2" lazy-load="true"></image>
  41 + </navigator>
  42 + <view class="kill-cont">
  43 + <navigator class="goods-name ellipsis-2" url="/packageB/pages/zuhegou/index/index?id={{item.id}}" hover-class="none">{{item.name}}</navigator>
  44 +
  45 + <!-- <view class="flex-vertical xc-strip-frame">
  46 + <view class="xc-strip-blank rel">
  47 +
  48 + <view class="flex-vertical rel total">
  49 + <view class="t-c abs xc-fill"style="width:{{type==1?(100-(item.buy_num+item.virtual) /(item.goods_num+item.virtual)*100)>3?(100-(item.buy_num+item.virtual) /(item.goods_num+item.virtual)*100):'3':'100'}}%;background:{{type==1?'#e4374d':'#059de5'}};">
  50 + </view>
  51 + <text class="fs20 white abs xc-fill-text" style="">剩余{{type==1?filters.toFix(100-(item.buy_num+item.virtual)/(item.goods_num+item.virtual)*100,0):'100'}}%</text>
  52 + </view>
  53 +
  54 + </view>
  55 + <view class=" ml10 fs20 " wx:if="{{type==1}}"> 已抢{{item.buy_num+item.virtual}}件</view>
  56 + <view class=" ml10 fs20 " wx:else> 已抢0件</view>
  57 +
  58 + </view> -->
  59 +
  60 +
  61 + <view class="goods-num">
  62 + <view>
  63 + <view>组合数量: {{item.zhbuyqty}}</view>
  64 + <view>活动时间: {{filters.format_time(item.start_time) + '至' + filters.format_time(item.end_time)}}</view>
  65 + <!-- <view class="{{type==1?'xc-wc':'blue_c'}}">
  66 + <text>剩余:</text>
  67 + <text class='tui-conutdown-box'> {{item.djs.day}}</text>天
  68 + <text class='tui-conutdown-box'>{{item.djs.hou}}</text>时
  69 + <text class='tui-conutdown-box'>{{item.djs.min}}</text>分
  70 + <text class='tui-conutdown-box tui-countdown-bg'>{{item.djs.sec}}</text>秒
  71 + </view> -->
  72 + <view class="fs40 flex xc-buttom-money {{type==1?'xc-wc':'blue_c'}}" >
  73 + <view class="fs28" style="line-height: 16px;">¥</view>
  74 + <text>{{item.zhprice}}</text>
  75 + <!-- <span class="underline fs20">零售价¥{{item.market_price}}</span> -->
  76 + </view>
  77 +
  78 + </view>
  79 + <!-- <view class="kill-btn "> -->
  80 + <!-- <navigator style="background-color: #059de5;" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{item.goods_id}}" wx:if="{{type==0}}" >即将开始</navigator> -->
  81 + <!-- <navigator url="/pages/goods/goodsInfo/goodsInfo?goods_id={{item.goods_id}}" wx:if="{{item.status==1 && type==1}}">马上抢</navigator>
  82 + <navigator class="huise"url="/pages/goods/goodsInfo/goodsInfo?goods_id={{item.goods_id}}" wx:if="{{item.status==3 && type==1}}">已抢光</navigator> -->
  83 + <!-- </view> -->
  84 + </view>
  85 + </view>
  86 + </view>
  87 + <!-- <view style="height:120rpx"></view> -->
  88 +</view>
  89 +
  90 +<!-- <view class="kill-time xc-seckill-bottom">
  91 + <view class="theader" >
  92 + <view bindtap='tip' data-ty="1" class="xc-border-right flex-center timeac left {{type==1?'active':''}}">
  93 + <image class="xc-bottom"
  94 + src="{{url}}{{type==1?'/miniapp/images/fire-red.png':'/miniapp/images/fire-black.png'}}"></image>
  95 + 火热进行中</view>
  96 + <view bindtap='tip' data-ty="0" class=" flex-center timeac right {{type==0?'active':''}}">
  97 + <image class="xc-bottom"
  98 + src="{{url}}{{type==0?'/miniapp/images/clock-rad.png':'/miniapp/images/clock-black.png'}}"></image>
  99 + 即将开始</view>
  100 + </view>
  101 +</view> -->
  102 +
  103 +
  104 + <view class="no-more" wx:if="{{goodlist.length==0}}">没有相关内容</view>
  105 +</view>
  106 +
  107 +
  108 +
  109 +<share_box id="share"></share_box>
... ...
packageB/pages/zuhegou/list/list.wxss 0 → 100644
  1 + page{
  2 + background: #eee;
  3 + color: #333;
  4 + }
  5 + .body_frame{
  6 + /* width: 100%;
  7 + height: 100%; */
  8 +
  9 + }
  10 +.xc-top-img{
  11 + width: 100%;
  12 + height: 333rpx;
  13 + margin-top: 5rpx;
  14 +}
  15 +.kill-list{
  16 + /* height: 807rpx; */
  17 + /* overflow-y: scroll; */
  18 + padding: 10rpx 20rpx;
  19 +}
  20 +.seckill_list{
  21 +/* margin-top: -10rpx;
  22 +left: 2%; */
  23 +}
  24 +.seckill{
  25 + width: 95%;
  26 +margin: auto;
  27 +
  28 +}
  29 +.kill-time {
  30 + text-align: center;
  31 + justify-content: space-around;
  32 + align-items: center;
  33 + height: 101rpx;
  34 + border-bottom: 1px solid #ddd;
  35 + border-top: 1px solid #ddd;
  36 + background-color: #f6f6f6;
  37 +}
  38 +.kill-time .theader{
  39 + display: flex; margin: 0 auto; align-items: center;
  40 + height: 100rpx;
  41 +
  42 +}
  43 +.kill-time .theader .timeac {
  44 + font-size: 32rpx; height:100%; width: 50%;
  45 + color: #333; background-color: #fff;
  46 +
  47 +}
  48 +/* .kill-time .theader .timeac.left{border-top-left-radius: 86rpx; border-bottom-left-radius: 86rpx;}
  49 +.kill-time .theader .timeac.right{border-top-right-radius: 86rpx; border-bottom-right-radius: 86rpx;} */
  50 +.kill-time .theader .timeac.active{color: #c4182e}
  51 +
  52 +.kill-item {
  53 + display: flex;
  54 + justify-content: space-between;
  55 + background-color: #fff;
  56 + padding: 20rpx;
  57 + margin-bottom: 20rpx;
  58 + border-radius: 10rpx;
  59 + /* height: 249rpx; */
  60 + align-items: center;
  61 +}
  62 +
  63 +.kill-pic {
  64 + width: 215rpx;
  65 + height: 215rpx;
  66 +}
  67 +
  68 +.kill-cont {
  69 + width: 465rpx;
  70 + margin-left:20rpx;
  71 + margin-right: 5rpx;
  72 +}
  73 +
  74 +.goods-name {
  75 + /* height: 60rpx; */
  76 + font-size: 27rpx;
  77 + color: #555;
  78 + line-height: 1.4;
  79 +
  80 +}
  81 +
  82 +.goods-num {
  83 + padding-top: 10rpx;
  84 + display: flex;
  85 + justify-content: space-between;
  86 + line-height: 42rpx;
  87 + font-size: 24rpx;
  88 + color: #999;
  89 +}
  90 +
  91 +.goods-num .co-red {
  92 + font-size: 30rpx;
  93 + font-weight: bold;
  94 +}
  95 +
  96 +.underline {
  97 + text-decoration: line-through;
  98 + color:#999999; font-size: 20rpx;
  99 + margin-left: 10rpx;
  100 + line-height: 30rpx;
  101 +}
  102 +
  103 +.kill-btn {
  104 + text-align: right;
  105 + display: flex;
  106 +height: 100%;
  107 +align-items: flex-end;
  108 +padding-top: 4rpx;
  109 +
  110 +}
  111 +
  112 +.kill-btn>navigator {
  113 + padding: 0 20rpx;
  114 + background: #e23245;
  115 + color: #fff;
  116 + border-radius: 20rpx;
  117 + margin-top: 37px;
  118 +
  119 +}
  120 +
  121 +.kill-btn .gray {
  122 + background-color: #555;
  123 +}
  124 +
  125 +.no-more {
  126 + font-size: 30rpx;
  127 + line-height: 2;
  128 + text-align: center;
  129 + color: #333;
  130 +}
  131 +
  132 +.kill-btn>navigator.huise{background-color: #999;}
  133 +.xc-seckill-bottom {
  134 + position: fixed;
  135 + bottom: 0;
  136 + width: 100%;
  137 +}
  138 +.xc-bottom{
  139 + width: 45rpx;
  140 + height: 45rpx;
  141 + margin-right: 13rpx;
  142 +}
  143 +.xc-border-right{
  144 + border-right: 4rpx solid #eee;
  145 +
  146 +}
  147 +.ml10{
  148 +margin-left: 45rpx;
  149 +}
  150 +.total{
  151 + width:215rpx;height:26rpx;border-radius:20rpx;
  152 + background: #ffe3e2;
  153 +}
  154 +.xc-buttom-money{
  155 + align-items: baseline;
  156 + padding-top: 10rpx;
  157 +}
  158 +
  159 +.xc-miaosha{
  160 +width: 68rpx;
  161 +height: 40rpx;
  162 +
  163 +}
  164 +.xc-strip-frame{
  165 + width:440rpx;margin-top: 10rpx;
  166 +}
  167 +.xc-strip-blank{
  168 + width:180rpx;
  169 +height: 26rpx;
  170 +}
  171 +.xc-fill{
  172 +border-radius:20rpx;height:26rpx;
  173 +}
  174 +.xc-fill-text{
  175 + left:34%;
  176 + line-height: 26rpx;
  177 +
  178 +}
0 179 \ No newline at end of file
... ...