Commit a84115ad682498b2b8ebf34627076e3d02310c1a

Authored by taiyuan
2 parents 33e4c9d2 c39ab084

Merge branch 'dev' of http://git.vipzhuang.cn/wxd/MShopWeApp into dev

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