Commit dd053a03f1c790374e57a8bd9555fd1ff2833a43
1 parent
51c3bb3b
抢红包
Showing
9 changed files
with
979 additions
and
2 deletions
packageA/pages/hongBao/hongBao.js
0 → 100644
1 | +// packageA//pages/hongBao/hongBao.js | |
2 | +const app = getApp(); | |
3 | +let self = null; | |
4 | + | |
5 | +let ut = require("../../../utils/util.js") | |
6 | + | |
7 | +Page({ | |
8 | + | |
9 | + /** | |
10 | + * 页面的初始数据 | |
11 | + */ | |
12 | + data: { | |
13 | + url: app.globalData.setting.imghost, | |
14 | + qiangHongBao: false, | |
15 | + time: null, | |
16 | + | |
17 | + // hongBaoData: null, //保存抢红包活动的相关时间等信息 | |
18 | + isStart: 0, //记录抢红包活动是否开始 | |
19 | + result: null, //保存抢红包的结果 | |
20 | + }, | |
21 | + | |
22 | + /** | |
23 | + * 生命周期函数--监听页面加载 | |
24 | + */ | |
25 | + onLoad: function (options) { | |
26 | + console.log('onload'); | |
27 | + self = this; | |
28 | + | |
29 | + this.isLogin() | |
30 | + .then(function(data) { | |
31 | + | |
32 | + self.requestData('/api/weshop/redmoney/redConfig/get/'+app.globalData.setting.stoid, {}) | |
33 | + .then(function(data) { | |
34 | + self.data.hongBaoData = data.data.data; | |
35 | + self.countDown(); | |
36 | + self.setData({ | |
37 | + storeName: app.globalData.config.store_name | |
38 | + }); | |
39 | + }); | |
40 | + | |
41 | + }); | |
42 | + }, | |
43 | + | |
44 | + // 判断是否授权登录 | |
45 | + isLogin() { | |
46 | + return new Promise((resolve, reject) => { | |
47 | + let user_info = app.globalData.userInfo; | |
48 | + if(user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
49 | + wx.navigateTo({ | |
50 | + url: '/pages/togoin/togoin', | |
51 | + }) | |
52 | + } else { | |
53 | + resolve(); | |
54 | + }; | |
55 | + }); | |
56 | + }, | |
57 | + | |
58 | + /** | |
59 | + * 生命周期函数--监听页面初次渲染完成 | |
60 | + */ | |
61 | + onReady: function () { | |
62 | + console.log('onready'); | |
63 | + | |
64 | + | |
65 | + }, | |
66 | + | |
67 | + /** | |
68 | + * 生命周期函数--监听页面显示 | |
69 | + */ | |
70 | + onShow: function () { | |
71 | + console.log('onshow'); | |
72 | + | |
73 | + | |
74 | + | |
75 | + | |
76 | + }, | |
77 | + | |
78 | + /** | |
79 | + * 生命周期函数--监听页面隐藏 | |
80 | + */ | |
81 | + onHide: function () { | |
82 | + console.log('onhide'); | |
83 | + }, | |
84 | + | |
85 | + /** | |
86 | + * 生命周期函数--监听页面卸载 | |
87 | + */ | |
88 | + onUnload: function () { | |
89 | + | |
90 | + }, | |
91 | + | |
92 | + /** | |
93 | + * 页面相关事件处理函数--监听用户下拉动作 | |
94 | + */ | |
95 | + onPullDownRefresh: function () { | |
96 | + | |
97 | + }, | |
98 | + | |
99 | + /** | |
100 | + * 页面上拉触底事件的处理函数 | |
101 | + */ | |
102 | + onReachBottom: function () { | |
103 | + | |
104 | + }, | |
105 | + | |
106 | + /** | |
107 | + * 用户点击右上角分享 | |
108 | + */ | |
109 | + onShareAppMessage: function () { | |
110 | + | |
111 | + }, | |
112 | + | |
113 | + // 请求数据 | |
114 | + requestData(url, data) { | |
115 | + return new Promise((resolve, reject) => { | |
116 | + app.request.promiseGet(url, {data: data}) | |
117 | + .then(res => { | |
118 | + if(res.data.code == 0) { | |
119 | + console.log('resolve', res); | |
120 | + resolve(res); | |
121 | + } else { | |
122 | + reject(res); | |
123 | + }; | |
124 | + }) | |
125 | + }); | |
126 | + }, | |
127 | + | |
128 | + //秒杀倒计时 | |
129 | + //---小于10的格式化函数---- | |
130 | + timeFormat(param) { | |
131 | + return param < 10 ? '0' + param : param; | |
132 | + }, | |
133 | + | |
134 | + handleTime(time) { | |
135 | + var day = parseInt(time / (60 * 60 * 24)); | |
136 | + var hou = parseInt(time % (60 * 60 * 24) / 3600); | |
137 | + var min = parseInt(time % (60 * 60 * 24) % 3600 / 60); | |
138 | + var sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); | |
139 | + return { | |
140 | + day: this.timeFormat(day), | |
141 | + hou: this.timeFormat(hou), | |
142 | + min: this.timeFormat(min), | |
143 | + sec: this.timeFormat(sec), | |
144 | + }; | |
145 | + }, | |
146 | + | |
147 | + //----秒杀倒计时函数----- | |
148 | + countDown() { | |
149 | + // if (!this.data.is_timer) return false; | |
150 | + var time; | |
151 | + // 获取当前时间,同时得到活动结束时间数组 | |
152 | + var newTime = ut.gettimestamp(); | |
153 | + // var List = this.data.saleGoods; | |
154 | + // for (var j = 0; j < List.length; j++) { | |
155 | + // var endTimeList = List[j]; | |
156 | + // 对结束时间进行处理渲染到页面 | |
157 | + // for (var i = 0; i < endTimeList.length; i++) { | |
158 | + // var o = endTimeList[i]; | |
159 | + var startTime = this.data.hongBaoData.start_time; | |
160 | + // var startTime = 1600; | |
161 | + var endTime = this.data.hongBaoData.end_time; | |
162 | + // if (o.status == 0) endTime = o.start_time | |
163 | + var obj = null; | |
164 | + | |
165 | + if(startTime - newTime > 0) { //活动还没开始 | |
166 | + this.setData({ | |
167 | + isStart: 0, | |
168 | + }); | |
169 | + time = startTime - newTime; | |
170 | + // var day = parseInt(time / (60 * 60 * 24)); | |
171 | + // var hou = parseInt(time % (60 * 60 * 24) / 3600); | |
172 | + // var min = parseInt(time % (60 * 60 * 24) % 3600 / 60); | |
173 | + // var sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); | |
174 | + // obj = { | |
175 | + // day: this.timeFormat(day), | |
176 | + // hou: this.timeFormat(hou), | |
177 | + // min: this.timeFormat(min), | |
178 | + // sec: this.timeFormat(sec), | |
179 | + // }; | |
180 | + | |
181 | + obj = this.handleTime(time); | |
182 | + } | |
183 | + // 如果活动未结束,对时间进行处理 | |
184 | + if (endTime - newTime > 0) { //活动还没结束 | |
185 | + this.setData({ | |
186 | + isStart: 1, | |
187 | + }); | |
188 | + time = endTime - newTime; | |
189 | + // 获取天、时、分、秒 | |
190 | + // var day = parseInt(time / (60 * 60 * 24)); | |
191 | + // var hou = parseInt(time % (60 * 60 * 24) / 3600); | |
192 | + // var min = parseInt(time % (60 * 60 * 24) % 3600 / 60); | |
193 | + // var sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); | |
194 | + // obj = { | |
195 | + // day: this.timeFormat(day), | |
196 | + // hou: this.timeFormat(hou), | |
197 | + // min: this.timeFormat(min), | |
198 | + // sec: this.timeFormat(sec), | |
199 | + // }; | |
200 | + | |
201 | + obj = this.handleTime(time); | |
202 | + | |
203 | + } else { //活动已经结束 | |
204 | + //活动已结束,全部设置为'00' | |
205 | + this.setData({ | |
206 | + isStart: 2, | |
207 | + }); | |
208 | + obj = { | |
209 | + day: '00', | |
210 | + hou: '00', | |
211 | + min: '00', | |
212 | + sec: '00' | |
213 | + } | |
214 | + } | |
215 | + // var txt = "saleGoods[" + j + "][" + i + "].djs"; | |
216 | + self.setData({ | |
217 | + time: obj, | |
218 | + }); | |
219 | + // } | |
220 | + | |
221 | + // } | |
222 | + setTimeout(self.countDown, 1000); | |
223 | + }, | |
224 | + | |
225 | + qiangHongBao() { | |
226 | + app.request.promisePost('/api/weshop/redmoney/redRecord/saveRecord', { | |
227 | + data: { | |
228 | + store_id: app.globalData.setting.stoid, | |
229 | + user_id: app.globalData.user_id, | |
230 | + redid: this.data.hongBaoData.id, | |
231 | + } | |
232 | + }) | |
233 | + .then(res => { | |
234 | + if(res.data.code == 0){ | |
235 | + // wx.hideLoading(); | |
236 | + // wx.showToast({ | |
237 | + // title: '领取成功', | |
238 | + // icon: 'success', | |
239 | + // duration: 2000 | |
240 | + // }); | |
241 | + console.log('请求提交成功',res.data); | |
242 | + // if(callback) { | |
243 | + // callback(res.data.data); | |
244 | + // } | |
245 | + } else if(res.data.code === -1) { | |
246 | + // wx.hideLoading(); | |
247 | + // wx.showToast({ | |
248 | + // title: '领取失败:' + res.data.msg, | |
249 | + // icon: 'none', | |
250 | + // duration: 2000 | |
251 | + // }); | |
252 | + // self.setData({ | |
253 | + // result: res.data | |
254 | + // }); | |
255 | + | |
256 | + }; | |
257 | + self.setData({ | |
258 | + result: res.data, | |
259 | + qiangHongBao: true, | |
260 | + }); | |
261 | + }) | |
262 | + | |
263 | + }, | |
264 | + | |
265 | + receive() { | |
266 | + // app.postData('/api/wemd/stafftask/saveGuideTaskListGive', { | |
267 | + // store_id: app.globalData.userInfo.store_id, | |
268 | + // StaffId: _this.data.StaffId, | |
269 | + // Id: _this.data.details.Id, | |
270 | + // TaskType: _this.data.details.TaskType, | |
271 | + // }); | |
272 | + | |
273 | + // postData(url, data, callback) { | |
274 | + wx.showLoading({ | |
275 | + title: '奖励领取中' | |
276 | + }); | |
277 | + app.request.promisePost('/api/wemd/stafftask/saveGuideTaskListGive', { | |
278 | + data: { | |
279 | + store_id: app.globalData.userInfo.store_id, | |
280 | + StaffId: _this.data.StaffId, | |
281 | + Id: _this.data.details.Id, | |
282 | + TaskType: _this.data.details.TaskType, | |
283 | + } | |
284 | + }) | |
285 | + .then(res => { | |
286 | + if(res.data.code == 0){ | |
287 | + wx.hideLoading(); | |
288 | + wx.showToast({ | |
289 | + title: '领取成功', | |
290 | + icon: 'success', | |
291 | + duration: 2000 | |
292 | + }); | |
293 | + // console.log('请求提交成功',res.data.data); | |
294 | + // if(callback) { | |
295 | + // callback(res.data.data); | |
296 | + // } | |
297 | + } else if(res.data.code === -1) { | |
298 | + wx.hideLoading(); | |
299 | + wx.showToast({ | |
300 | + title: '领取失败:' + res.data.msg, | |
301 | + icon: 'none', | |
302 | + duration: 2000 | |
303 | + }); | |
304 | + }; | |
305 | + }) | |
306 | + // }, | |
307 | + }, | |
308 | + | |
309 | + | |
310 | + closePopup() { | |
311 | + this.setData({ | |
312 | + qiangHongBao: false, | |
313 | + }); | |
314 | + }, | |
315 | + | |
316 | + | |
317 | + gotoDetails() { | |
318 | + app.goto('/packageA/pages/hongBaoDetails/hongBaoDetails?redid=' + this.data.hongBaoData.id); | |
319 | + }, | |
320 | + | |
321 | + | |
322 | +}) | |
0 | 323 | \ No newline at end of file | ... | ... |
packageA/pages/hongBao/hongBao.json
0 → 100644
packageA/pages/hongBao/hongBao.wxml
0 → 100644
1 | +<!--packageA//pages/hongBao/hongBao.wxml--> | |
2 | +<view class="hongBao-container"> | |
3 | + <view class="white fs26">由{{storeName}}发起抢红包</view> | |
4 | + <view class="btn-container"> | |
5 | + <image src="{{url + 'miniapp/images/redmoney/redbag_btn.png'}}" class="btn" mode="aspectFit" bindtap="qiangHongBao"></image> | |
6 | + </view> | |
7 | + <view class="countdown-container"> | |
8 | + <view class="countdown-txt">{{isStart == 0 ? '距离活动开始还有':(isStart == 1 ? '距离活动结束还有':'活动已经结束')}}</view> | |
9 | + <view class="countdown"> | |
10 | + <view class="countdown-item">{{time.day}}天</view> | |
11 | + <view class="countdown-item">{{time.hou}}时</view> | |
12 | + <view class="countdown-item">{{time.min}}分</view> | |
13 | + <view class="countdown-item">{{time.sec}}秒</view> | |
14 | + </view> | |
15 | + </view> | |
16 | +</view> | |
17 | + | |
18 | +<!-- 弹窗 --> | |
19 | +<view class="popup-container" wx:if="{{qiangHongBao}}" bindtap="closePopup"> | |
20 | + <view class="popup"> | |
21 | + <block wx:if="{{result.code == 0}}"> | |
22 | + <image src="{{url + 'miniapp/images/redmoney/hbtit.png'}}" mode="aspectFit"></image> | |
23 | + <view class="amount-container"> | |
24 | + <view class="amount">¥{{result.data.redmoney}}</view> | |
25 | + <view class="btn-receive" catchtap="gotoDetails" data-redid="{{hongBaoData.id}}"> | |
26 | + <image src="{{url + 'miniapp/images/redmoney/srhb.png'}}" class="btn-img"></image> | |
27 | + </view> | |
28 | + </view> | |
29 | + </block> | |
30 | + | |
31 | + <block wx:if="{{result.code == -1}}"> | |
32 | + <image src="{{url + 'miniapp/images/redmoney/hbtit2.png'}}" mode="aspectFit"></image> | |
33 | + <!-- <view class="none">来晚了,红包已抢空~</view> --> | |
34 | + <view class="none">{{result.msg}}</view> | |
35 | + <view class="see" catchtap="gotoDetails" data-redid="{{hongBaoData.id}}">看看大家的手气 ></view> | |
36 | + </block> | |
37 | + </view> | |
38 | +</view> | |
39 | + | |
40 | +<!-- 弹窗 --> | |
41 | +<!-- <view class="popup-container"> | |
42 | + <view class="popup"> | |
43 | + <image src="{{url + 'miniapp/images/redmoney/hbtit2.png'}}" mode="aspectFit"></image> | |
44 | + <view class="none">来晚了,红包已抢空~</view> | |
45 | + <view class="see">看看大家的手气 ></view> | |
46 | + </view> | |
47 | +</view> --> | ... | ... |
packageA/pages/hongBao/hongBao.wxss
0 → 100644
1 | +/* packageA//pages/hongBao/hongBao.wxss */ | |
2 | +page { | |
3 | + background: url('https://mshopimg.yolipai.net/miniapp/images/redmoney/hongbao_bg.jpg') center top; | |
4 | + background-size: 100% auto; | |
5 | +} | |
6 | + | |
7 | +.hongBao-container { | |
8 | + padding: 20rpx; | |
9 | +} | |
10 | + | |
11 | +.btn-container { | |
12 | + padding-top: 60rpx; | |
13 | + padding-bottom: 60rpx; | |
14 | + -webkit-animation: free_download 600ms linear alternate infinite; | |
15 | + animation: free_download 600ms linear alternate infinite; | |
16 | +} | |
17 | + | |
18 | +@-webkit-keyframes free_download{ | |
19 | + 0% {-webkit-transform:scale(0.9);} | |
20 | + 100% {-webkit-transform:scale(1.1);} | |
21 | +} | |
22 | + | |
23 | +@keyframes free_download{ | |
24 | + 0% {transform:scale(0.9);} | |
25 | + 100% {transform:scale(1.1);} | |
26 | +} | |
27 | + | |
28 | +.countdown-container { | |
29 | + position: fixed; | |
30 | + left: 0; | |
31 | + bottom: 0; | |
32 | + width: 100%; | |
33 | + height: 688rpx; | |
34 | + background: url('https://mshopimg.yolipai.net/miniapp/images/redmoney/indexbot.png') no-repeat left bottom; | |
35 | + background-size: 100% auto; | |
36 | + text-align: center; | |
37 | +} | |
38 | + | |
39 | +.countdown { | |
40 | + display: flex; | |
41 | + justify-content: space-around; | |
42 | + padding: 200rpx 160rpx 0; | |
43 | +} | |
44 | + | |
45 | +.countdown-item { | |
46 | + background: url('https://mshopimg.yolipai.net/miniapp/images/redmoney/timebox.png') no-repeat; | |
47 | + background-size: 100% 100%; | |
48 | + width: 90rpx; | |
49 | + height: 100rpx; | |
50 | + line-height: 120rpx; | |
51 | + color: white; | |
52 | +} | |
53 | + | |
54 | +.btn { | |
55 | + width: 100%; | |
56 | + height: 400rpx; | |
57 | +} | |
58 | + | |
59 | +.countdown-txt { | |
60 | + color: #ff6768; | |
61 | + text-align: center; | |
62 | + padding-top: 120rpx; | |
63 | + font-size: 36rpx; | |
64 | + font-weight: bold; | |
65 | +} | |
66 | + | |
67 | +.popup-container { | |
68 | + position: fixed; | |
69 | + width: 100%; | |
70 | + height: 100%; | |
71 | + top: 0; | |
72 | + background-color: rgba(0,0,0,.7); | |
73 | +} | |
74 | + | |
75 | +.popup { | |
76 | + position: relative; | |
77 | + top: 50%; | |
78 | + left: 50%; | |
79 | + transform: translate(-50%, -50%); | |
80 | + text-align: center; | |
81 | +} | |
82 | + | |
83 | + | |
84 | +.btn-img { | |
85 | + width: 200rpx; | |
86 | + height: 50rpx; | |
87 | +} | |
88 | + | |
89 | +.amount-container { | |
90 | + position: absolute; | |
91 | + left: 50%; | |
92 | + top: 50%; | |
93 | + transform: translateX(-55%); | |
94 | +} | |
95 | + | |
96 | +.amount { | |
97 | + color: #fff005; | |
98 | + font-size: 68rpx; | |
99 | + text-align: center; | |
100 | + padding-top: 10rpx; | |
101 | + padding-bottom: 20rpx; | |
102 | +} | |
103 | + | |
104 | + | |
105 | + | |
106 | +.none, | |
107 | +.see { | |
108 | + position: absolute; | |
109 | + font-size: 26rpx; | |
110 | + color: white; | |
111 | + left: 50%; | |
112 | + transform: translateX(-60%); | |
113 | +} | |
114 | + | |
115 | +.none { | |
116 | + font-size: 20rpx; | |
117 | + top: 36%; | |
118 | + margin-left: 55rpx; | |
119 | +} | |
120 | + | |
121 | +.see { | |
122 | + top: 82%; | |
123 | + left: 50%; | |
124 | + transform: translateX(-58%); | |
125 | +} | |
126 | + | |
127 | +.late { | |
128 | + font-size: 38; | |
129 | + color: #fff005; | |
130 | + padding-top: 40rpx; | |
131 | +} | |
0 | 132 | \ No newline at end of file | ... | ... |
packageA/pages/hongBaoDetails/hongBaoDetails.js
0 → 100644
1 | +// packageA//pages/hongBao/hongBao.js | |
2 | +const app = getApp(); | |
3 | +let reqData = {}; | |
4 | +let _this = null; | |
5 | + | |
6 | +Page({ | |
7 | + | |
8 | + /** | |
9 | + * 页面的初始数据 | |
10 | + */ | |
11 | + data: { | |
12 | + url: app.globalData.setting.imghost, | |
13 | + list: null, | |
14 | + isLoading: false, // 检测是否已经发送请求,防止重复发送请求 | |
15 | + noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据 | |
16 | + pageNum: 1, // 当前页数 | |
17 | + }, | |
18 | + | |
19 | + /** | |
20 | + * 生命周期函数--监听页面加载 | |
21 | + */ | |
22 | + onLoad: function (options) { | |
23 | + _this = this; | |
24 | + console.log('options', options); | |
25 | + this.data.options = options; | |
26 | + reqData.url = '/api/weshop/redmoney/redRecord/page', | |
27 | + reqData.data = { | |
28 | + store_id: app.globalData.setting.stoid, | |
29 | + redid: this.data.options.redid, | |
30 | + }; | |
31 | + reqData.data2 = { | |
32 | + store_id: app.globalData.setting.stoid, | |
33 | + user_id: app.globalData.user_id, | |
34 | + redid: this.data.options.redid, | |
35 | + pageSize: 1, | |
36 | + page: 1, | |
37 | + }; | |
38 | + this.getData(true, reqData.url, reqData.data); | |
39 | + this.requestData(reqData.url, reqData.data2) | |
40 | + .then(function(data) { | |
41 | + _this.setData({ | |
42 | + myRed: data.data.data.pageData[0] | |
43 | + }); | |
44 | + // console.log('123', data.data.data.pageData[0]); | |
45 | + }); | |
46 | + }, | |
47 | + | |
48 | + /** | |
49 | + * 生命周期函数--监听页面初次渲染完成 | |
50 | + */ | |
51 | + onReady: function () { | |
52 | + | |
53 | + }, | |
54 | + | |
55 | + /** | |
56 | + * 生命周期函数--监听页面显示 | |
57 | + */ | |
58 | + onShow: function () { | |
59 | + | |
60 | + }, | |
61 | + | |
62 | + /** | |
63 | + * 生命周期函数--监听页面隐藏 | |
64 | + */ | |
65 | + onHide: function () { | |
66 | + | |
67 | + }, | |
68 | + | |
69 | + /** | |
70 | + * 生命周期函数--监听页面卸载 | |
71 | + */ | |
72 | + onUnload: function () { | |
73 | + | |
74 | + }, | |
75 | + | |
76 | + /** | |
77 | + * 页面相关事件处理函数--监听用户下拉动作 | |
78 | + */ | |
79 | + onPullDownRefresh: function () { | |
80 | + | |
81 | + }, | |
82 | + | |
83 | + /** | |
84 | + * 页面上拉触底事件的处理函数 | |
85 | + */ | |
86 | + onReachBottom: function () { | |
87 | + this.scrollToLower(reqData.url, reqData.data); | |
88 | + }, | |
89 | + | |
90 | + /** | |
91 | + * 用户点击右上角分享 | |
92 | + */ | |
93 | + onShareAppMessage: function () { | |
94 | + | |
95 | + }, | |
96 | + | |
97 | + // 请求数据 | |
98 | + requestData(url, data) { | |
99 | + return new Promise((resolve, reject) => { | |
100 | + app.request.promiseGet(url, {data: data}) | |
101 | + .then(res => { | |
102 | + if(res.data.code == 0) { | |
103 | + console.log('resolve', res); | |
104 | + resolve(res); | |
105 | + } else { | |
106 | + reject(res); | |
107 | + }; | |
108 | + }) | |
109 | + }); | |
110 | + }, | |
111 | + | |
112 | + | |
113 | + | |
114 | + // 上拉加载请求数据 | |
115 | + getData: function(isInit, url, data) { | |
116 | + wx.showLoading({ | |
117 | + title: '加载中', | |
118 | + }) | |
119 | + this.requestData(url, data) | |
120 | + .then(function(res) { | |
121 | + wx.hideLoading(); | |
122 | + console.log('res--->', res); | |
123 | + _this.setData({ | |
124 | + isLoading: false | |
125 | + }); | |
126 | + | |
127 | + if(isInit) {// 第一次加载 | |
128 | + _this.setData({ | |
129 | + list: res.data.data | |
130 | + }); | |
131 | + } else { | |
132 | + | |
133 | + _this.setData({ | |
134 | + 'list.pageData': _this.data.list.pageData.concat(res.data.data.pageData) | |
135 | + }); | |
136 | + }; | |
137 | + | |
138 | + if((res.data.data.pageData.length == 0) || (res.data.data.pageSize * res.data.data.page >= res.data.data.total)) { | |
139 | + _this.setData({ | |
140 | + noMore: true | |
141 | + }); | |
142 | + }; | |
143 | + | |
144 | + }) | |
145 | + .catch(function(reason) { | |
146 | + wx.hideLoading(); | |
147 | + wx.showToast({ | |
148 | + title: reason.data.msg, | |
149 | + icon: 'none', | |
150 | + duration: 2000 | |
151 | + }) | |
152 | + _this.setData({ | |
153 | + 'list.pageData': [] | |
154 | + }); | |
155 | + }); | |
156 | + }, | |
157 | + | |
158 | + | |
159 | + // 上拉加载 | |
160 | + scrollToLower(url, requestData, callback) { | |
161 | + // 页面数据 | |
162 | + // let pageData = this.data.list.pageData; | |
163 | + // 数据总量 | |
164 | + let total = this.data.list.total; | |
165 | + // 单页最大数据量 | |
166 | + let pageSize = this.data.list.pageSize; | |
167 | + // 如果数据总量不为0且小于或等于单页最大数据量,说明数据已全部加载,显示‘没有更多了’ | |
168 | + if((total != 0)&&(total <= pageSize)) { | |
169 | + this.setData({ | |
170 | + noMore: true | |
171 | + }); | |
172 | + }; | |
173 | + | |
174 | + if(!this.data.isLoading && !this.data.noMore) { | |
175 | + this.setData({ | |
176 | + isLoading: true, | |
177 | + pageNum: this.data.pageNum + 1 | |
178 | + }); | |
179 | + requestData.page = this.data.pageNum; | |
180 | + this.getData(false, url, requestData); | |
181 | + }; | |
182 | + }, | |
183 | + | |
184 | + | |
185 | + | |
186 | +}) | |
0 | 187 | \ No newline at end of file | ... | ... |
packageA/pages/hongBaoDetails/hongBaoDetails.json
0 → 100644
packageA/pages/hongBaoDetails/hongBaoDetails.wxml
0 → 100644
1 | +<!--packageA//pages/hongBao/hongBao.wxml--> | |
2 | +<wxs module="filter" src="../../../utils/filter.wxs"></wxs> | |
3 | +<view class="hongBao-container"> | |
4 | + <!-- <view class="white fs26">由美得得美妆商城发起抢红包</view> --> | |
5 | + <view class="btn-container"> | |
6 | + <image src="{{url + 'miniapp/images/redmoney/redbag_pro.png'}}" class="btn" mode="aspectFit"></image> | |
7 | + <view class="amount">¥{{filter.show_default(myRed.redmoney, '0.00')}}</view> | |
8 | + </view> | |
9 | + <view class="list-container"> | |
10 | + <!-- <view class="countdown-txt">获奖名单</view> --> | |
11 | + <image src="{{url + 'miniapp/images/redmoney/listit.png'}}" class="list-img" mode=""></image> | |
12 | + <view class="list"> | |
13 | + <view class="list-item" wx:for="{{list.pageData}}"> | |
14 | + <view class="flex ai-center"> | |
15 | + <view class="avatar-container"> | |
16 | + <image src="{{item.userimg}}" class="avatar"></image> | |
17 | + </view> | |
18 | + <view> | |
19 | + <view>{{item.vipname}}</view> | |
20 | + <view class="xc-ash fs24 pdt20">{{filter.format_time(item.addtime, 1)}}</view> | |
21 | + </view> | |
22 | + </view> | |
23 | + <view class="co-red">¥{{item.redmoney}}</view> | |
24 | + </view> | |
25 | + <nodata nodataContainer="txt-center" wx:if="{{list.pageData.length == 0}}"></nodata> | |
26 | + <!-- <view class="list-item"> | |
27 | + <view class="flex ai-center"> | |
28 | + <view class="avatar-container"> | |
29 | + <image src="../../images/wx2.png" class="avatar"></image> | |
30 | + </view> | |
31 | + <view> | |
32 | + <view>good</view> | |
33 | + <view class="xc-ash fs24 pdt20">2020-12-12 18:00:00</view> | |
34 | + </view> | |
35 | + </view> | |
36 | + <view class="co-red">¥100.00</view> | |
37 | + </view> --> | |
38 | + <!-- <view class="countdown-item">50天</view> | |
39 | + <view class="countdown-item">9时</view> | |
40 | + <view class="countdown-item">23分</view> | |
41 | + <view class="countdown-item">43秒</view> --> | |
42 | + </view> | |
43 | + </view> | |
44 | + <view class="nodata" hidden="{{!noMore}}" wx:if="{{list.pageData.length !== 0}}">- 没有更多了 -</view> | |
45 | + <!-- <view class="no-more txt-center" hidden="{{!noMore}}" wx:if="{{list.pageData.length !== 0}}">- 没有更多了 -</view> --> | |
46 | +</view> | |
47 | + | |
48 | +<!-- 弹窗 --> | |
49 | +<!-- <view class="popup-container"> | |
50 | + <view class="popup"> | |
51 | + <image src="{{url + 'miniapp/images/redmoney/hbtit.png'}}" mode="aspectFit"></image> | |
52 | + <view class="amount-container"> | |
53 | + <view class="amount">0.53</view> | |
54 | + <view class="btn-receive"> | |
55 | + <image src="{{url + 'miniapp/images/redmoney/srhb.png'}}" class="btn-img"></image> | |
56 | + </view> | |
57 | + </view> | |
58 | + </view> | |
59 | +</view> --> | |
60 | + | |
61 | +<!-- 弹窗 --> | |
62 | +<!-- <view class="popup-container"> | |
63 | + <view class="popup"> | |
64 | + <image src="{{url + 'miniapp/images/redmoney/hbtit2.png'}}" mode="aspectFit"></image> | |
65 | + <view class="none">来晚了,红包已抢空~</view> | |
66 | + <view class="see">看看大家的手气 ></view> | |
67 | + </view> | |
68 | +</view> --> | ... | ... |
packageA/pages/hongBaoDetails/hongBaoDetails.wxss
0 → 100644
1 | +/* packageA//pages/hongBao/hongBao.wxss */ | |
2 | +page { | |
3 | + background: url('https://mshopimg.yolipai.net/miniapp/images/redmoney/hongbao_bg.jpg') center top; | |
4 | + background-size: 100% auto; | |
5 | +} | |
6 | + | |
7 | +.hongBao-container { | |
8 | + padding: 20rpx; | |
9 | +} | |
10 | + | |
11 | +.btn-container { | |
12 | + padding-top: 60rpx; | |
13 | + /* padding-bottom: 60rpx; */ | |
14 | + /* transform:scale(1.2); */ | |
15 | + position: relative; | |
16 | + /* -webkit-animation: free_download 600ms linear alternate infinite; | |
17 | + animation: free_download 600ms linear alternate infinite; */ | |
18 | +} | |
19 | + | |
20 | +/* @-webkit-keyframes free_download{ | |
21 | + 0% {-webkit-transform:scale(0.9);} | |
22 | + 100% {-webkit-transform:scale(1.1);} | |
23 | +} | |
24 | + | |
25 | +@keyframes free_download{ | |
26 | + 0% {transform:scale(0.9);} | |
27 | + 100% {transform:scale(1.1);} | |
28 | +} */ | |
29 | + | |
30 | +.countdown-container { | |
31 | + /* position: fixed; | |
32 | + left: 0; | |
33 | + bottom: 0; | |
34 | + width: 100%; | |
35 | + height: 688rpx; | |
36 | + background: url('https://mshopimg.yolipai.net/miniapp/images/redmoney/indexbot.png') no-repeat left bottom; | |
37 | + background-size: 100% auto; | |
38 | + text-align: center; */ | |
39 | +} | |
40 | + | |
41 | +.countdown { | |
42 | + /* display: flex; | |
43 | + justify-content: space-around; | |
44 | + padding: 200rpx 160rpx 0; */ | |
45 | +} | |
46 | + | |
47 | +.countdown-item { | |
48 | + /* background: url('https://mshopimg.yolipai.net/miniapp/images/redmoney/timebox.png') no-repeat; | |
49 | + background-size: 100% 100%; | |
50 | + width: 90rpx; | |
51 | + height: 100rpx; | |
52 | + line-height: 120rpx; | |
53 | + color: white; */ | |
54 | +} | |
55 | + | |
56 | +.btn { | |
57 | + width: 100%; | |
58 | + height: 400rpx; | |
59 | + transform: scale(1.1); | |
60 | +} | |
61 | + | |
62 | +.countdown-txt { | |
63 | + /* color: #ff6768; | |
64 | + text-align: center; | |
65 | + padding-top: 120rpx; | |
66 | + font-size: 36rpx; | |
67 | + font-weight: bold; */ | |
68 | +} | |
69 | + | |
70 | +.popup-container { | |
71 | + position: fixed; | |
72 | + width: 100%; | |
73 | + height: 100%; | |
74 | + top: 0; | |
75 | + background-color: rgba(0,0,0,.7); | |
76 | +} | |
77 | + | |
78 | +.popup { | |
79 | + position: relative; | |
80 | + top: 50%; | |
81 | + left: 50%; | |
82 | + transform: translate(-50%, -50%); | |
83 | + text-align: center; | |
84 | +} | |
85 | + | |
86 | + | |
87 | +.btn-img { | |
88 | + /* width: 200rpx; | |
89 | + height: 50rpx; */ | |
90 | +} | |
91 | + | |
92 | +.amount-container { | |
93 | + /* position: absolute; | |
94 | + left: 50%; | |
95 | + top: 50%; | |
96 | + transform: translateX(-55%); */ | |
97 | +} | |
98 | + | |
99 | +.amount { | |
100 | + color: #fff005; | |
101 | + font-size: 60rpx; | |
102 | + text-align: center; | |
103 | + position: absolute; | |
104 | + left: 49%; | |
105 | + top: 50%; | |
106 | + transform: translate(-50%); | |
107 | + padding-top: 30rpx; | |
108 | + /* padding-top: 10rpx; | |
109 | + padding-bottom: 20rpx; */ | |
110 | +} | |
111 | + | |
112 | + | |
113 | + | |
114 | +/* .none, | |
115 | +.see { | |
116 | + position: absolute; | |
117 | + font-size: 26rpx; | |
118 | + color: white; | |
119 | + left: 50%; | |
120 | + transform: translateX(-60%); | |
121 | +} | |
122 | + | |
123 | +.none { | |
124 | + font-size: 20rpx; | |
125 | + top: 36%; | |
126 | + margin-left: 55rpx; | |
127 | +} | |
128 | + | |
129 | +.see { | |
130 | + top: 82%; | |
131 | + left: 50%; | |
132 | + transform: translateX(-58%); | |
133 | +} */ | |
134 | + | |
135 | + | |
136 | +/* .list-container { | |
137 | + /* background: url('https://mshopimg.yolipai.net/miniapp/images/redmoney/timebox.png') no-repeat; | |
138 | +} */ | |
139 | + | |
140 | +.list-container { | |
141 | + border-radius: 12rpx; | |
142 | + overflow: hidden; | |
143 | +} | |
144 | + | |
145 | +.list { | |
146 | + /* position: relative; */ | |
147 | + margin-top: -8rpx; | |
148 | +} | |
149 | + | |
150 | +.list-img { | |
151 | + width: 100%; | |
152 | + height: 326rpx; | |
153 | +} | |
154 | + | |
155 | +.list-item { | |
156 | + display: flex; | |
157 | + justify-content: space-between; | |
158 | + align-items: center; | |
159 | + background-color: white; | |
160 | + padding: 30rpx 20rpx; | |
161 | + border-bottom: 2rpx solid #f8f8f8; | |
162 | +} | |
163 | + | |
164 | +.list-item:last-child { | |
165 | + border-bottom: none; | |
166 | +} | |
167 | + | |
168 | +.avatar-container { | |
169 | + width: 100rpx; | |
170 | + height: 100rpx; | |
171 | + border-radius: 50%; | |
172 | + overflow: hidden; | |
173 | + margin-right: 20rpx; | |
174 | +} | |
175 | + | |
176 | +.avatar { | |
177 | + display: block; | |
178 | + width: 100%; | |
179 | + height: 100%; | |
180 | +} | |
181 | + | |
182 | +.nodata { | |
183 | + color: white; | |
184 | + font-size: 24rpx; | |
185 | + text-align: center; | |
186 | + padding-top: 20rpx; | |
187 | +} | ... | ... |
utils/filter.wxs
... | ... | @@ -29,7 +29,7 @@ var filters = { |
29 | 29 | var fm = [d.getFullYear(), d.getMonth() + 1, d.getDate()].join('-'); |
30 | 30 | var md = (d.getMonth() + 1) + '月' + d.getDate() + '日'; |
31 | 31 | if (isFull == 1) |
32 | - fm = fm + ' ' + [d.getHours(), d.getMinutes(), d.getSeconds()].join(':'); | |
32 | + fm = fm + ' ' + [appendZero(d.getHours()), appendZero(d.getMinutes()), appendZero(d.getSeconds())].join(':'); | |
33 | 33 | if (isFull == 2) { |
34 | 34 | fm = md + ' ' + [appendZero(d.getHours()), appendZero(d.getMinutes())].join(':'); |
35 | 35 | } |
... | ... | @@ -55,7 +55,30 @@ var filters = { |
55 | 55 | return spec + "/" + color; |
56 | 56 | } |
57 | 57 | } |
58 | - } | |
58 | + }, | |
59 | + | |
60 | + | |
61 | + show_default: function (value, placeholder, multiple) { | |
62 | + if(typeof value === 'number') { | |
63 | + if(isNaN(value) || value === 0) { | |
64 | + return placeholder || '0'; | |
65 | + } else { | |
66 | + if(multiple) { | |
67 | + return value / multiple; | |
68 | + } else { | |
69 | + return value; | |
70 | + } | |
71 | + }; | |
72 | + } else if(value === '' || value === undefined || value === null) { | |
73 | + return placeholder || '-'; | |
74 | + } else { | |
75 | + return value; | |
76 | + } | |
77 | + }, | |
78 | + | |
79 | + | |
80 | + | |
81 | + | |
59 | 82 | }; |
60 | 83 | |
61 | 84 | module.exports = { |
... | ... | @@ -65,4 +88,5 @@ module.exports = { |
65 | 88 | format_time: filters.format_time, |
66 | 89 | pInt: filters.pInt, |
67 | 90 | show_gui_ge: filters.show_gui_ge, |
91 | + show_default: filters.show_default, | |
68 | 92 | } |
69 | 93 | \ No newline at end of file | ... | ... |