Commit fb571d795c46f3cc7709d6b25cf85724d717ac4b
Merge branch 'dev' of http://git.vipzhuang.cn/wxd/MShopWeApp into dev
Showing
11 changed files
with
711 additions
and
100 deletions
packageB/miniprogram_npm/mini-luck-draw/lucky-wheel/index.js
... | ... | @@ -181,6 +181,7 @@ var _utils = __webpack_require__(1); |
181 | 181 | |
182 | 182 | Component({ |
183 | 183 | properties: { |
184 | + hiddenCanvas: { type: Boolean, value: false}, | |
184 | 185 | width: { type: String, value: '600rpx' }, |
185 | 186 | height: { type: String, value: '600rpx' }, |
186 | 187 | blocks: { type: Array, value: [] }, | ... | ... |
packageB/miniprogram_npm/mini-luck-draw/lucky-wheel/index.wxml
packageB/miniprogram_npm/mini-luck-draw/lucky-wheel/index.wxss
packageB/pages/luckactivity/index/index.js
... | ... | @@ -213,7 +213,8 @@ Page({ |
213 | 213 | // url = e.currentTarget.dataset.url; |
214 | 214 | // } |
215 | 215 | let id = e.currentTarget.dataset.id; |
216 | - let url = `/packageB/pages/luckactivity/luckinfo/luckinfo?id=${id}`; | |
216 | + let title = e.currentTarget.dataset.title; | |
217 | + let url = `/packageB/pages/luckactivity/luckinfo/luckinfo?id=${id}&title=${title}`; | |
217 | 218 | app.goto(url); |
218 | 219 | }, |
219 | 220 | ... | ... |
packageB/pages/luckactivity/index/index.wxml
... | ... | @@ -19,8 +19,8 @@ |
19 | 19 | </view> |
20 | 20 | <!-- 按钮 --> |
21 | 21 | <view class="btn-container"> |
22 | - <view bindtap="goto" data-id="{{item.id}}" class="btn red" wx:if="{{currentIndex == 0}}">立即参与</view> | |
23 | - <view bindtap="goto" data-id="{{item.id}}" class="btn red" wx:else>去兑换</view> | |
22 | + <view bindtap="goto" data-id="{{item.id}}" data-title="{{item.act_name}}" class="btn red" wx:if="{{currentIndex == 0}}">立即参与</view> | |
23 | + <view bindtap="goto" data-id="{{item.id}}" data-title="{{item.act_name}}" class="btn red" wx:else>去兑换</view> | |
24 | 24 | </view> |
25 | 25 | </view> |
26 | 26 | </view> | ... | ... |
packageB/pages/luckactivity/index/index.wxss
packageB/pages/luckactivity/luckinfo/luckinfo.js
... | ... | @@ -3,6 +3,12 @@ let self = null; |
3 | 3 | |
4 | 4 | Page({ |
5 | 5 | data: { |
6 | + start: false, | |
7 | + list: null, | |
8 | + isLoading: false, // 检测是否已经发送请求,防止重复发送请求 | |
9 | + noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据 | |
10 | + pageNum: 1, // 当前页数 | |
11 | + | |
6 | 12 | prizes: [ |
7 | 13 | { fonts: [{ text: '积分', top: '18%', wordWrap:false, fontColor: 'transparent'}], |
8 | 14 | imgs: [ |
... | ... | @@ -97,8 +103,8 @@ Page({ |
97 | 103 | // } |
98 | 104 | { |
99 | 105 | radius: '60rpx', |
100 | - background: 'black', | |
101 | - pointer: true, | |
106 | + // background: 'black', | |
107 | + // pointer: true, | |
102 | 108 | imgs: [{ |
103 | 109 | src: 'http://201442.image.myqcloud.com/201442/0/b29290ec-aeb3-40e9-9444-8f15fd9acda3/original', |
104 | 110 | width: '188rpx', |
... | ... | @@ -110,12 +116,15 @@ Page({ |
110 | 116 | }, |
111 | 117 | |
112 | 118 | onLoad(options) { |
113 | - console.log('options', options); | |
114 | 119 | self = this; |
115 | 120 | this.data.options = options; |
121 | + wx.setNavigationBarTitle({ | |
122 | + title: options.title, | |
123 | + }); | |
116 | 124 | app.isLogin().then(function(data) {//进入页面前已经授权登录成功 |
117 | 125 | self.setData({ |
118 | 126 | userInfo: data, |
127 | + imghost: app.globalData.setting.imghost, | |
119 | 128 | }); |
120 | 129 | }); |
121 | 130 | }, |
... | ... | @@ -124,44 +133,55 @@ Page({ |
124 | 133 | if(app.globalData.userInfo) { |
125 | 134 | if(!this.data.isLogin) { |
126 | 135 | |
127 | - console.log('gl', app.globalData); | |
128 | - | |
129 | 136 | this.setData({ |
130 | 137 | userInfo: app.globalData.userInfo, |
131 | 138 | imghost: app.globalData.setting.imghost, |
132 | 139 | isLogin: true, |
133 | 140 | }); |
134 | 141 | |
142 | + console.log('imghost', this.data.imghost); | |
135 | 143 | let user_id = app.globalData.userInfo.user_id; |
136 | 144 | let store_id = app.globalData.setting.stoid; |
137 | 145 | let id = this.data.options.id; |
138 | 146 | let url = `/api/weshop/marketing/marketingLuckForm/getLuckInfo/${store_id}/${id}/${user_id}`; |
139 | - console.log('url', url); | |
147 | + | |
148 | + | |
140 | 149 | app.request.get(url, { |
141 | 150 | success: function(res) { |
142 | - // self.setData({ | |
143 | - // details: res.data.data | |
144 | - // }); | |
145 | - console.log('res****', res.data.data); | |
146 | - // let basic = res.data.data; | |
147 | - | |
148 | - // self.setData({ | |
149 | - // basic, | |
150 | - // }); | |
151 | + if(res.data.code == 0) { | |
152 | + self.setData({ | |
153 | + luckInfo: res.data.data, | |
154 | + }); | |
155 | + } else { | |
156 | + wx.showToast({ | |
157 | + title: res.data.msg, | |
158 | + icon: 'none', | |
159 | + }); | |
160 | + self.data.msg = res.data.msg; | |
161 | + }; | |
151 | 162 | |
152 | - // if(basic.template_type == 1) { //获取模板 | |
153 | - // let url = `/api/weshop/marketing/marketingLuckTemplate/get/${store_id}/${basic.template_id}`; | |
154 | - // app.request.get(url, { | |
155 | - | |
156 | - // success: function(res) { | |
157 | - // // console.log('prizes//////', res.data.data); | |
158 | - // // self.setData({ | |
159 | - // // prizes: res.data.data.pageData | |
160 | - // // }); | |
161 | - // }, | |
162 | - | |
163 | - // }); | |
164 | - // }; | |
163 | + console.log('luckInfo', res.data.data); | |
164 | + let luckInfo = res.data.data; | |
165 | + let imghost = self.data.imghost; | |
166 | + if(luckInfo.template_type == 1) { //获取模板 | |
167 | + let url = `/api/weshop/marketing/marketingLuckTemplate/get/${store_id}/${luckInfo.template_id}`; | |
168 | + app.request.get(url, { | |
169 | + success: function(res) { | |
170 | + console.log('prizes//////', res.data.data); | |
171 | + self.setData({ | |
172 | + template: res.data.data, | |
173 | + bannerUrl: imghost + res.data.data.bannerUrl, //背景图 | |
174 | + 'blocks[0].imgs[0].src': imghost + res.data.data.wheelBaseUrl, //转盘 | |
175 | + 'buttons[0].imgs[0].src': imghost + res.data.data.wheelPointerUrl, //指针 | |
176 | + }); | |
177 | + }, | |
178 | + }); | |
179 | + } else { | |
180 | + self.setData({ | |
181 | + bannerUrl: imghost + luckInfo.store_bannerUrl, | |
182 | + }); | |
183 | + }; | |
184 | + | |
165 | 185 | }, |
166 | 186 | }); |
167 | 187 | |
... | ... | @@ -172,10 +192,14 @@ Page({ |
172 | 192 | luck_formid: id, |
173 | 193 | }, |
174 | 194 | success: function(res) { |
175 | - // console.log('res//////', res.data.data.pageData); | |
195 | + | |
196 | + let award = res.data.data.pageData; | |
176 | 197 | self.setData({ |
177 | - prizes: res.data.data.pageData | |
198 | + award, | |
178 | 199 | }); |
200 | + console.log('award', award); | |
201 | + self.prizeLayout(award); | |
202 | + | |
179 | 203 | }, |
180 | 204 | |
181 | 205 | }); |
... | ... | @@ -183,33 +207,552 @@ Page({ |
183 | 207 | }; |
184 | 208 | }, |
185 | 209 | |
210 | + // 设置转盘奖品布局 | |
211 | + prizeLayout(award) { | |
212 | + let prizes = []; | |
213 | + let length = award.length; | |
214 | + let thx = {fonts: [{ text: '谢谢\n参与', top: '18%', wordWrap:false, fontColor: 'rgba(0,0,0,.5)'}]}; | |
215 | + | |
216 | + if(length == 1) { | |
217 | + [0,2,4,6].map(function(item, index) { | |
218 | + prizes[item] = { | |
219 | + id: award[0].id, | |
220 | + fonts: [{ text: award[0].luck_goods_name + ' x' + award[0].num, top: '18%', wordWrap:false, fontColor: 'transparent'}], | |
221 | + imgs: [ | |
222 | + { | |
223 | + src: self.prizeSrc(award[0].lbtype), | |
224 | + width: '135rpx', | |
225 | + height: '107rpx', | |
226 | + top: '12%', | |
227 | + } | |
228 | + ], | |
229 | + }; | |
230 | + }); | |
231 | + | |
232 | + [1,3,5,7].map(function(item, index) { | |
233 | + prizes[item] = thx; | |
234 | + }); | |
235 | + | |
236 | + this.data.thxIndexArr = [1,3,5,7]; | |
237 | + }; | |
238 | + | |
239 | + if(length == 2) { | |
240 | + [0,4].map(function(item, index) { | |
241 | + prizes[item] = { | |
242 | + id: award[0].id, | |
243 | + fonts: [{ text: award[0].luck_goods_name + ' x' + award[0].num, top: '18%', wordWrap:false, fontColor: 'transparent'}], | |
244 | + imgs: [ | |
245 | + { | |
246 | + src: self.prizeSrc(award[0].lbtype), | |
247 | + width: '135rpx', | |
248 | + height: '107rpx', | |
249 | + top: '12%', | |
250 | + } | |
251 | + ], | |
252 | + }; | |
253 | + }); | |
254 | + | |
255 | + [2,6].map(function(item, index) { | |
256 | + prizes[item] = { | |
257 | + id: award[1].id, | |
258 | + fonts: [{ text: award[1].luck_goods_name + ' x' + award[1].num, top: '18%', wordWrap:false, fontColor: 'transparent'}], | |
259 | + imgs: [ | |
260 | + { | |
261 | + src: self.prizeSrc(award[1].lbtype), | |
262 | + width: '135rpx', | |
263 | + height: '107rpx', | |
264 | + top: '12%', | |
265 | + } | |
266 | + ], | |
267 | + }; | |
268 | + }); | |
269 | + | |
270 | + [1,3,5,7].map(function(item, index) { | |
271 | + prizes[item] = thx; | |
272 | + }); | |
273 | + this.data.thxIndexArr = [1,3,5,7]; | |
274 | + }; | |
275 | + | |
276 | + | |
277 | + if(length == 3) { | |
278 | + [0,4].map(function(item, index) { | |
279 | + prizes[item] = { | |
280 | + id: award[0].id, | |
281 | + fonts: [{ text: award[0].luck_goods_name + ' x' + award[0].num, top: '18%', wordWrap:false, fontColor: 'transparent'}], | |
282 | + imgs: [ | |
283 | + { | |
284 | + src: self.prizeSrc(award[0].lbtype), | |
285 | + width: '135rpx', | |
286 | + height: '107rpx', | |
287 | + top: '12%', | |
288 | + } | |
289 | + ], | |
290 | + }; | |
291 | + }); | |
292 | + | |
293 | + [1,5].map(function(item, index) { | |
294 | + prizes[item] = { | |
295 | + id: award[1].id, | |
296 | + fonts: [{ text: award[1].luck_goods_name + ' x' + award[1].num, top: '18%', wordWrap:false, fontColor: 'transparent'}], | |
297 | + imgs: [ | |
298 | + { | |
299 | + src: self.prizeSrc(award[1].lbtype), | |
300 | + width: '135rpx', | |
301 | + height: '107rpx', | |
302 | + top: '12%', | |
303 | + } | |
304 | + ], | |
305 | + }; | |
306 | + }); | |
307 | + | |
308 | + [2,6].map(function(item, index) { | |
309 | + prizes[item] = { | |
310 | + id: award[2].id, | |
311 | + fonts: [{ text: award[2].luck_goods_name + ' x' + award[2].num, top: '18%', wordWrap:false, fontColor: 'transparent'}], | |
312 | + imgs: [ | |
313 | + { | |
314 | + src: self.prizeSrc(award[2].lbtype), | |
315 | + width: '135rpx', | |
316 | + height: '107rpx', | |
317 | + top: '12%', | |
318 | + } | |
319 | + ], | |
320 | + }; | |
321 | + }); | |
322 | + | |
323 | + [3,7].map(function(item, index) { | |
324 | + prizes[item] = thx; | |
325 | + }); | |
326 | + | |
327 | + this.data.thxIndexArr = [3,7]; | |
328 | + }; | |
329 | + | |
330 | + | |
331 | + if(length == 4) { | |
332 | + [0,2,4,6].map(function(item, index) { | |
333 | + prizes[item] = { | |
334 | + id: award[index].id, | |
335 | + fonts: [{ text: award[index].luck_goods_name + ' x' + award[index].num, top: '18%', wordWrap:false, fontColor: 'transparent'}], | |
336 | + imgs: [ | |
337 | + { | |
338 | + src: self.prizeSrc(award[index].lbtype), | |
339 | + width: '135rpx', | |
340 | + height: '107rpx', | |
341 | + top: '12%', | |
342 | + } | |
343 | + ], | |
344 | + }; | |
345 | + }); | |
346 | + | |
347 | + [1,3,5,7].map(function(item, index) { | |
348 | + prizes[item] = thx; | |
349 | + }); | |
350 | + | |
351 | + this.data.thxIndexArr = [1,3,5,7]; | |
352 | + }; | |
353 | + | |
354 | + if(length == 5) { | |
355 | + [0,2,3,5,6].map(function(item, index) { | |
356 | + prizes[item] = { | |
357 | + id: award[index].id, | |
358 | + fonts: [{ text: award[index].luck_goods_name + ' x' + award[index].num, top: '18%', wordWrap:false, fontColor: 'transparent'}], | |
359 | + imgs: [ | |
360 | + { | |
361 | + src: self.prizeSrc(award[index].lbtype), | |
362 | + width: '135rpx', | |
363 | + height: '107rpx', | |
364 | + top: '12%', | |
365 | + } | |
366 | + ], | |
367 | + }; | |
368 | + }); | |
369 | + | |
370 | + [1,4,7].map(function(item, index) { | |
371 | + prizes[item] = thx; | |
372 | + }); | |
373 | + | |
374 | + this.data.thxIndexArr = [1,4,7]; | |
375 | + }; | |
376 | + | |
377 | + if(length == 6) { | |
378 | + prizes = award.map(function(item, index) { | |
379 | + return { | |
380 | + id: item.id, | |
381 | + fonts: [{ text: item.luck_goods_name + ' x' + item.num, top: '18%', wordWrap:false, fontColor: 'transparent'}], | |
382 | + imgs: [ | |
383 | + { | |
384 | + src: self.prizeSrc(item.lbtype), | |
385 | + width: '135rpx', | |
386 | + height: '107rpx', | |
387 | + top: '12%', | |
388 | + } | |
389 | + ], | |
390 | + }; | |
391 | + }); | |
392 | + | |
393 | + prizes.push(thx); | |
394 | + prizes.splice(3, 0, thx); | |
395 | + | |
396 | + this.data.thxIndexArr = [3,7]; | |
397 | + }; | |
398 | + | |
399 | + console.log('prizes', prizes); | |
400 | + | |
401 | + this.setData({ | |
402 | + prizes, | |
403 | + }); | |
404 | + }, | |
405 | + | |
406 | + // 根据lbtype指定奖品类别图标 | |
407 | + prizeSrc(lbtype) { | |
408 | + let src = ''; | |
409 | + let imghost = this.data.imghost; | |
410 | + switch(lbtype) { | |
411 | + case 1: { //积分 | |
412 | + src = imghost + 'miniapp/images/luckDraw/jf.png'; | |
413 | + break; | |
414 | + }; | |
415 | + case 2: { //成长值 | |
416 | + src = imghost + 'miniapp/images/luckDraw/czz.png'; | |
417 | + break; | |
418 | + }; | |
419 | + case 3: { //优惠券 | |
420 | + src = imghost + 'miniapp/images/luckDraw/yhq.png'; | |
421 | + break; | |
422 | + }; | |
423 | + case 4: { //服务项目 | |
424 | + src = imghost + 'miniapp/images/luckDraw/fw.png'; | |
425 | + break; | |
426 | + }; | |
427 | + case 5: { //赠品 | |
428 | + src = imghost + 'miniapp/images/luckDraw/zp.png'; | |
429 | + break; | |
430 | + }; | |
431 | + case 6: { //礼包 | |
432 | + src = imghost + 'miniapp/images/luckDraw/lb.png'; | |
433 | + break; | |
434 | + }; | |
435 | + }; | |
436 | + return src; | |
437 | + }, | |
438 | + | |
439 | + // 获取抽奖结果匹配对应奖品在奖品列表里的所有索引号 | |
440 | + luckyIndex(arr, target) { | |
441 | + var results=[], | |
442 | + len = arr.length, | |
443 | + pos = 0; | |
444 | + while(pos < len){ | |
445 | + // pos = arr[pos].indexOf(target, pos); | |
446 | + if(arr[pos].id == target) { | |
447 | + results.push(pos);//找到就存储索引 | |
448 | + | |
449 | + }; | |
450 | + pos+=1;//并从下个位置开始搜索 | |
451 | + // if(pos === -1){//未找到就退出循环完成搜索 | |
452 | + // break; | |
453 | + // }; | |
454 | + | |
455 | + } | |
456 | + // console.log('当前奖品列表', this.data.prizes); | |
457 | + // console.log('中奖结果在当前奖品列表中的索引', results); | |
458 | + | |
459 | + return results; | |
460 | + }, | |
461 | + | |
186 | 462 | start () { |
187 | - // 获取抽奖组件实例 | |
188 | - const $lucky = this.selectComponent('#myLucky') | |
189 | - // 调用play方法开始旋转 | |
190 | - $lucky.play() | |
191 | - // 用定时器模拟请求接口 | |
192 | - setTimeout(() => { | |
193 | - // 3s 后得到中奖索引 | |
194 | - const index = Math.random() * 6 >> 0 | |
195 | - // 调用stop方法然后缓慢停止 | |
196 | - $lucky.stop(index) | |
197 | - }, 3000) | |
463 | + if(!this.data.luckInfo) { | |
464 | + wx.showToast({ | |
465 | + title: this.data.msg, | |
466 | + icon: 'none', | |
467 | + }); | |
468 | + return; | |
469 | + }; | |
470 | + | |
471 | + if(this.data.luckInfo.user_LuckNumDay != 0) { | |
472 | + // console.log('start choujiang'); | |
473 | + // let start = false; | |
474 | + if(!this.data.start) { | |
475 | + this.data.start = true; | |
476 | + // 获取抽奖组件实例 | |
477 | + const $lucky = this.selectComponent('#myLucky'); | |
478 | + // 调用play方法开始旋转 | |
479 | + $lucky.play(); | |
480 | + | |
481 | + // 获取抽奖结果 | |
482 | + app.request.post('/api/weshop/marketing/marketingLuckForm/startLuck', { | |
483 | + isShowLoading: false, | |
484 | + data: { | |
485 | + storeId: app.globalData.setting.stoid, | |
486 | + userId: app.globalData.userInfo.user_id, | |
487 | + LuckId: this.data.options.id, | |
488 | + }, | |
489 | + success: function(res) { | |
490 | + | |
491 | + // console.log('开始摇奖', res.data.data.id, res.data.data); | |
492 | + if(res.data.code == 0) { | |
493 | + self.setData({ | |
494 | + 'luckInfo.user_LuckNumDay': self.data.luckInfo.user_LuckNumDay - 1 | |
495 | + }); | |
496 | + // console.log('请求成功', res.data.data); | |
497 | + let luckyId = res.data.data.id; | |
498 | + let indexArr = self.luckyIndex(self.data.prizes, luckyId); | |
499 | + // console.log('抽奖奖品id', luckyId); | |
500 | + // console.log('奖品列表', self.data.prizes); | |
501 | + // console.log('奖品对应的索引数组', indexArr); | |
502 | + let random = Math.random() * indexArr.length >> 0; | |
503 | + // console.log('random', random); | |
504 | + let index = indexArr[random]; | |
505 | + setTimeout(() => { | |
506 | + $lucky.stop(index); | |
507 | + self.data.start = false; | |
508 | + }, 3000); | |
509 | + | |
510 | + | |
511 | + } else { | |
512 | + console.log('请求出错'); | |
513 | + let thxIndexArr = self.data.thxIndexArr; | |
514 | + const random = Math.random() * thxIndexArr.length >> 0; | |
515 | + const index = thxIndexArr[random]; | |
516 | + // console.log('谢谢参与数组', thxIndexArr); | |
517 | + // console.log('请求出错产生谢谢参与的随机数', index); | |
518 | + setTimeout(() => { | |
519 | + $lucky.stop(index); | |
520 | + self.data.start = false; | |
521 | + }, 3000); | |
522 | + }; | |
523 | + }, | |
524 | + | |
525 | + fail: function() { | |
526 | + | |
527 | + console.log('出错'); | |
528 | + let thxIndexArr = self.data.thxIndexArr; | |
529 | + const random = Math.random() * thxIndexArr.length >> 0; | |
530 | + const index = thxIndexArr[random]; | |
531 | + setTimeout(() => { | |
532 | + $lucky.stop(index); | |
533 | + self.data.start = false; | |
534 | + }, 3000); | |
535 | + }, | |
536 | + | |
537 | + }); | |
538 | + | |
539 | + } | |
540 | + | |
541 | + | |
542 | + } else { | |
543 | + wx.showToast({ | |
544 | + title: '你今天的抽奖次数已用完啦!~', | |
545 | + icon: 'none', | |
546 | + }); | |
547 | + }; | |
548 | + | |
198 | 549 | }, |
199 | 550 | end (event) { |
200 | 551 | // 中奖奖品详情 |
201 | - console.log(event.detail) | |
552 | + // console.log('zjiangla~~',event.detail.fonts[0].text.replace('\n','')); | |
553 | + let resultTitle = event.detail.fonts[0].text.replace('\n',''); | |
554 | + this.setData({ | |
555 | + hiddenCanvas: true, | |
556 | + showResult: true, | |
557 | + showMask: true, | |
558 | + resultTitle, | |
559 | + }); | |
202 | 560 | }, |
203 | 561 | |
204 | 562 | showPopup() { |
205 | 563 | this.setData({ |
206 | - showPopup: true, | |
564 | + list: null, | |
565 | + pageNum: 1, | |
566 | + noMore: false, | |
567 | + }); | |
568 | + this.getData(true, '/api/weshop/marketing/marketingLuckRecord/page', { | |
569 | + store_id: app.globalData.setting.stoid, | |
570 | + user_id: app.globalData.userInfo.user_id, | |
571 | + luck_formid: this.data.options.id, | |
572 | + luck_state: 1, | |
573 | + pageSize: 50, | |
574 | + }).then(function(res) { | |
575 | + self.setData({ | |
576 | + showPopup: true, | |
577 | + showMask: true, | |
578 | + hiddenCanvas: true, | |
579 | + // record: self.data.list.pageData, | |
580 | + }); | |
207 | 581 | }); |
582 | + // app.request.get('/api/weshop/marketing/marketingLuckRecord/page', { | |
583 | + // // isShowLoading: false, | |
584 | + // data: { | |
585 | + // store_id: app.globalData.setting.stoid, | |
586 | + // user_id: app.globalData.userInfo.user_id, | |
587 | + // luck_formid: this.data.options.id, | |
588 | + // luck_state: 1 | |
589 | + // }, | |
590 | + // success: function(res) { | |
591 | + // // console.log('中奖记录', res.data.data); | |
592 | + // if(res.data.code == 0) { | |
593 | + // self.setData({ | |
594 | + // showPopup: true, | |
595 | + // showMask: true, | |
596 | + // hiddenCanvas: true, | |
597 | + // record: self.data.list.pageData, | |
598 | + // }); | |
599 | + | |
600 | + | |
601 | + // }; | |
602 | + // }, | |
603 | + | |
604 | + // }); | |
605 | + | |
208 | 606 | }, |
209 | 607 | |
210 | 608 | closePopup() { |
211 | 609 | this.setData({ |
212 | 610 | showPopup: false, |
611 | + showMask: false, | |
612 | + hiddenCanvas: false, | |
613 | + }); | |
614 | + }, | |
615 | + | |
616 | + closeResult() { | |
617 | + this.setData({ | |
618 | + showResult: false, | |
619 | + showMask: false, | |
620 | + hiddenCanvas: false, | |
621 | + }); | |
622 | + }, | |
623 | + | |
624 | + loadmore() { | |
625 | + this.scrollToLower('/api/weshop/marketing/marketingLuckRecord/page', { | |
626 | + store_id: app.globalData.setting.stoid, | |
627 | + user_id: app.globalData.userInfo.user_id, | |
628 | + luck_formid: this.data.options.id, | |
629 | + luck_state: 1, | |
630 | + pageSize: 50, | |
631 | + }); | |
632 | + }, | |
633 | + | |
634 | + | |
635 | + /** | |
636 | + * 请求数据 | |
637 | + */ | |
638 | + getData: function(isInit, url, data) { | |
639 | + let p = app.request.promiseGet(url, { | |
640 | + data: data, | |
641 | + isShowLoading: true, | |
642 | + }) | |
643 | + .then(function(res) { | |
644 | + if(res.data.code == 0) { | |
645 | + | |
646 | + self.setData({ | |
647 | + isLoading: false | |
648 | + }); | |
649 | + | |
650 | + if(isInit) {// 第一次加载 | |
651 | + self.setData({ | |
652 | + list: res.data.data | |
653 | + }); | |
654 | + } else { | |
655 | + self.setData({ | |
656 | + 'list.pageData': self.data.list.pageData.concat(res.data.data.pageData) | |
657 | + }); | |
658 | + }; | |
659 | + | |
660 | + if((res.data.data.pageData.length == 0) || (res.data.data.pageSize * res.data.data.page >= res.data.data.total)) { | |
661 | + self.setData({ | |
662 | + noMore: true | |
663 | + }); | |
664 | + }; | |
665 | + | |
666 | + } else { | |
667 | + self.setData({ | |
668 | + 'list.pageData': [] | |
669 | + }); | |
670 | + }; | |
671 | + | |
672 | + }); | |
673 | + | |
674 | + return p; | |
675 | + }, | |
676 | + | |
677 | + | |
678 | + /** | |
679 | + * 上拉加载 | |
680 | + */ | |
681 | + scrollToLower(url, requestData) { | |
682 | + // 数据总量 | |
683 | + let total = this.data.list.total; | |
684 | + // 单页最大数据量 | |
685 | + let pageSize = this.data.list.pageSize; | |
686 | + // 如果数据总量不为0且小于或等于单页最大数据量,说明数据已全部加载,显示‘没有更多了’ | |
687 | + if((total != 0)&&(total <= pageSize)) { | |
688 | + this.setData({ | |
689 | + noMore: true | |
690 | + }); | |
691 | + }; | |
692 | + | |
693 | + if(!this.data.isLoading && !this.data.noMore) { | |
694 | + this.setData({ | |
695 | + isLoading: true, | |
696 | + pageNum: this.data.pageNum + 1 | |
697 | + }); | |
698 | + requestData.page = this.data.pageNum; | |
699 | + this.getData(false, url, requestData); | |
700 | + }; | |
701 | + }, | |
702 | + | |
703 | + | |
704 | + goto(e) { | |
705 | + let url = ''; | |
706 | + let type = e.currentTarget.dataset.type; | |
707 | + switch(type) { | |
708 | + case 1: { | |
709 | + url = '/pages/user/integral/integral'; | |
710 | + break; | |
711 | + }; | |
712 | + case 2: { | |
713 | + url = '/pages/user/grow_value/grow_value'; | |
714 | + break; | |
715 | + }; | |
716 | + case 3: { | |
717 | + url = '/pages/user/coupons/coupons'; | |
718 | + break; | |
719 | + }; | |
720 | + case 4: { | |
721 | + url = '/pages/user/my_service/i_service'; | |
722 | + break; | |
723 | + }; | |
724 | + case 6: { | |
725 | + url = '/packageA/pages/myGift/myGift'; | |
726 | + break; | |
727 | + }; | |
728 | + }; | |
729 | + app.goto(url); | |
730 | + }, | |
731 | + | |
732 | + showQr(e) { | |
733 | + let store_id = app.globalData.setting.stoid; | |
734 | + let id = e.currentTarget.dataset.id; | |
735 | + let url = `/api/weshop/marketing/marketingLuckList/updateGoodsVerifyCode/${store_id}/${id}`; | |
736 | + app.request.put(url, { | |
737 | + success: function(res) { | |
738 | + if(res.data.code == 0) { | |
739 | + let data = res.data.data; | |
740 | + let barcode = self.selectComponent("#qrcode"); | |
741 | + barcode.open({val: data}); | |
742 | + self.setData({ | |
743 | + hiddenCanvas: true, | |
744 | + showPopup: false, | |
745 | + }); | |
746 | + }; | |
747 | + }, | |
748 | + | |
749 | + }); | |
750 | + }, | |
751 | + | |
752 | + closeCode() { | |
753 | + this.setData({ | |
754 | + hiddenCanvas: false, | |
755 | + showMask: false, | |
213 | 756 | }); |
214 | 757 | }, |
215 | 758 | }) |
216 | 759 | \ No newline at end of file | ... | ... |
packageB/pages/luckactivity/luckinfo/luckinfo.json
1 | 1 | { |
2 | 2 | "usingComponents": { |
3 | - "lucky-wheel":"/packageB/miniprogram_npm/mini-luck-draw/lucky-wheel/index" | |
3 | + "lucky-wheel":"/packageB/miniprogram_npm/mini-luck-draw/lucky-wheel/index", | |
4 | + "qrcode": "/components/qr_code/qr_code", | |
5 | + "nodata": "/components/nodata/nodata" | |
4 | 6 | }, |
5 | 7 | "enablePullDownRefresh": false, |
6 | 8 | "navigationBarTitleText": "幸运大转盘" | ... | ... |
packageB/pages/luckactivity/luckinfo/luckinfo.wxml
1 | -<view class="luck-container" style="background: url('http://201442.image.myqcloud.com/201442/0/d7d0fc88-7e87-478e-a1a1-496198001521/original') no-repeat;"> | |
1 | +<wxs module="filter" src="../../../../utils/filter.wxs"></wxs> | |
2 | +<wxs module="tool" src="./tool.wxs"></wxs> | |
3 | +<view class="luck-container" style="background: {{template.colorCode}} url({{bannerUrl}}) no-repeat;"> | |
4 | +<!-- <view class="luck-container" style="background: url({{ bannerUrl}}) no-repeat;"> --> | |
2 | 5 | <!-- 大转盘 --> |
3 | 6 | <view class="weel-container"> |
4 | - <!-- <lucky-wheel | |
5 | - class="myLucky" | |
6 | - id="myLucky" | |
7 | - width="700rpx" | |
8 | - height="700rpx" | |
9 | - blocks="{{blocks}}" | |
10 | - prizes="{{prizes}}" | |
11 | - buttons="{{buttons}}" | |
12 | - defaultConfig="{{defaultConfig}}" | |
13 | - defaultStyle="{{defaultStyle}}" | |
14 | - bindstart="start" | |
15 | - bindend="end" | |
16 | - /> --> | |
17 | - <view class="fs28 white t-c pdv20">今天你还有 <text class="fs50 c-yellow">3</text> 次抽奖机会</view> | |
7 | + <view> | |
8 | + <lucky-wheel | |
9 | + class="myLucky" | |
10 | + id="myLucky" | |
11 | + width="700rpx" | |
12 | + height="700rpx" | |
13 | + blocks="{{blocks}}" | |
14 | + prizes="{{prizes}}" | |
15 | + buttons="{{buttons}}" | |
16 | + defaultConfig="{{defaultConfig}}" | |
17 | + defaultStyle="{{defaultStyle}}" | |
18 | + bindstart="start" | |
19 | + bindend="end" | |
20 | + hiddenCanvas="{{hiddenCanvas}}" | |
21 | + /> | |
22 | + </view> | |
23 | + | |
24 | + <view class="fs28 white t-c pdt10">今天你还有 <text class="fs50 c-yellow">{{filter.show_default(luckInfo.user_LuckNumDay, '0')}}</text> 次抽奖机会</view> | |
18 | 25 | <view class="tip-to-down expand-transition"> |
19 | 26 | <text></text> |
20 | 27 | <text></text> |
21 | 28 | </view> |
22 | 29 | </view> |
23 | 30 | <!-- 奖品展示 --> |
24 | - <view wx:if="{{prizes.length != 0}}"> | |
25 | - <view class="badge-container"><image src="../../../images/luckDraw/badge.png" class="badge prizes"></image></view> | |
31 | + <view> | |
32 | + <view class="badge-container"><image src="{{imghost + 'miniapp/images/luckDraw/badge.png'}}" class="badge prizes"></image></view> | |
26 | 33 | <view class="list br12 bg-white"> |
27 | - <view class="list-item" wx:for="{{prizes}}"> | |
34 | + <view class="list-item" wx:for="{{award}}"> | |
28 | 35 | <view class="img-container"> |
29 | 36 | <image wx:if="{{item.luck_goods_img}}" src="{{item.luck_goods_img}}" class="img" mode="aspectFit"></image> |
30 | - <image wx:else src="{{imghost + 'miniapp/images/default_g_img.gif'}}" class="img" mode="aspectFit"></image> | |
37 | + <image wx:else src="{{imghost + tool.showDefaultImg(item.lbtype)}}" class="img" mode="aspectFit"></image> | |
31 | 38 | </view> |
32 | 39 | <view class="item-r"> |
33 | - <view class="fs26">{{item.luck_goods_name}}</view> | |
34 | - <view class="flex jc_sb fs24 c9"> | |
40 | + <view class="fs28">{{item.luck_goods_name}}</view> | |
41 | + <view class="flex jc_sb fs26 c9"> | |
35 | 42 | <view>价值:<text class="rmb">{{item.luck_goods_price}}</text></view> |
36 | 43 | <view>数量:{{item.luck_goods_qty}}</view> |
37 | 44 | </view> |
... | ... | @@ -41,7 +48,7 @@ |
41 | 48 | </view> |
42 | 49 | <!-- 活动展示 --> |
43 | 50 | <view wx:if="{{basic.remark}}"> |
44 | - <view class="badge-container"><image src="../../../images/luckDraw/badge.png" class="badge activity"></image></view> | |
51 | + <view class="badge-container"><image src="{{imghost + 'miniapp/images/luckDraw/badge.png'}}" class="badge activity"></image></view> | |
45 | 52 | <view class="bg-white br12 pd20"> |
46 | 53 | {{basic.remark}} |
47 | 54 | <!-- 时间 --> |
... | ... | @@ -98,49 +105,61 @@ |
98 | 105 | <!-- 技术支持 --> |
99 | 106 | <view class="t-c"> |
100 | 107 | <!-- <view class="pdt20 fs26 text-underline">帮美店免费开通这个玩法</view> --> |
101 | - <view class="flex ai_c fs24 jc-center pdv20"><image src="../../../images/luckDraw/logo.png" class="logo"></image>提供技术支持</view> | |
108 | + <view class="flex ai_c fs24 jc-center pdv20 white"><image src="{{imghost + 'miniapp/images/luckDraw/logo.png'}}" class="logo"></image>提供技术支持</view> | |
102 | 109 | </view> |
103 | 110 | </view> |
104 | 111 | |
105 | 112 | <!-- 悬浮按钮 --> |
106 | -<view class="gift-container active" bindtap="showPopup"><text class="iconfont icon-liwu"></text></view> | |
113 | +<view class="gift-container" bindtap="showPopup"><text class="iconfont icon-liwu"></text></view> | |
107 | 114 | |
108 | 115 | <!-- 弹窗 --> |
109 | 116 | <view class="popup-container" wx:if="{{showPopup}}"> |
110 | - <view class="popup-list"> | |
111 | - <view class="popup-item"> | |
112 | - <view class="img-container"><image src="../../../images/luckDraw/badge.png" class="img"></image></view> | |
113 | - <view class="flex fdc"> | |
114 | - <view class="ellipsis-2">我是标题我是标题我是标题我是标题我是标题我是标题我是标题我是标题我是标题我是标题我是标题</view> | |
117 | + <scroll-view class="popup-list" scroll-y bindscrolltolower="loadmore"> | |
118 | + <view class="popup-item" wx:for="{{list.pageData}}"> | |
119 | + <view class="img-container"> | |
120 | + <image wx:if="{{item.luck_goods_img}}" src="{{item.luck_goods_img}}" class="img" mode="aspectFit"></image> | |
121 | + <image wx:else src="{{imghost + tool.showDefaultImg(item.luck_type)}}" class="img" mode="aspectFit"></image> | |
122 | + </view> | |
123 | + <view class="flex fdc f1"> | |
124 | + <view class="ellipsis-2">{{item.luck_name}}</view> | |
115 | 125 | <view class="pdt20"> |
116 | - <view class="fs26 xc-black3">价值:<text class="rmb">1800</text></view> | |
117 | - <view class="flex ai_c jc_sb fs26 xc-black3"> | |
118 | - <view>兑换状态:未兑换</view> | |
119 | - <view class="btn">兑换</view> | |
126 | + <view class="fs26 xc-black3">价值:<text class="rmb">{{item.luck_goods_price}}</text></view> | |
127 | + <view class="flex ai_c jc_sb fs26 xc-black3 "> | |
128 | + <view style="visibility: {{item.luck_type == 5 ? 'visible':'hidden'}};">兑换状态:{{item.state == 0 ? '未兑换':'已兑换'}}</view> | |
129 | + <view class="btn" bindtap="{{item.luck_type == 5 ? (item.state == 0 ? 'showQr':''):'goto'}}" data-type="{{item.luck_type}}" data-id="{{item.id}}">{{((item.luck_type == 5)&&(item.state == 1)) ? '已兑换':'兑换'}}</view> | |
120 | 130 | </view> |
121 | 131 | </view> |
122 | 132 | </view> |
123 | 133 | </view> |
124 | - </view> | |
134 | + <nodata nodataContainer="t-c" wx:if="{{list.pageData.length == 0}}"></nodata> | |
135 | + <view class="noMore" hidden="{{!noMore}}" wx:if="{{list.pageData.length !== 0}}">—— 已经到底了 ——</view> | |
136 | + </scroll-view> | |
125 | 137 | <view class="close-container" bindtap="closePopup"><text class="iconfont icon-close"></text></view> |
126 | 138 | </view> |
127 | 139 | |
128 | 140 | |
129 | -<view class="popup-container2"> | |
130 | - <view class="t-r"><text class="iconfont icon-close white"></text></view> | |
141 | +<view class="popup-container2" wx:if="{{showResult}}"> | |
142 | + <view class="t-r"><text class="iconfont icon-close white" bindtap="closeResult"></text></view> | |
131 | 143 | <view class="popup"> |
132 | 144 | <view class="t-c"> |
133 | - <view class="bold c-tb">恭喜你获得</view> | |
134 | - <view class="pdt10">奖品名称</view> | |
135 | - </view> | |
136 | - <view class="img-container2"><image src="../../../images/luckDraw/gift.png" class="img"></image></view> | |
137 | - <view class="flex jc-center mgt30 mgb20"> | |
138 | - <view class="btn btn2">立即领取</view> | |
145 | + <block wx:if="{{resultTitle == '谢谢参与'}}"> | |
146 | + <view class="bold c-tb">{{resultTitle}}</view> | |
147 | + </block> | |
148 | + <block wx:else> | |
149 | + <view class="bold c-tb">恭喜你获得</view> | |
150 | + <view class="pdt10">{{resultTitle}} </view> | |
151 | + </block> | |
139 | 152 | </view> |
140 | - <view class="note">注:未领取就关闭弹窗视为主动放弃奖品。</view> | |
153 | + <view class="img-container2"><image src="{{imghost + 'miniapp/images/luckDraw/gift.png'}}" class="img"></image></view> | |
154 | + <!-- <view class="flex jc-center mgt30 mgb20"> | |
155 | + <view class="btn btn2" bindtap="closeResult">再抽一次</view> | |
156 | + </view> --> | |
157 | + <!-- <view class="note">注:未领取就关闭弹窗视为主动放弃奖品。</view> --> | |
141 | 158 | </view> |
142 | 159 | </view> |
143 | 160 | |
144 | 161 | |
145 | 162 | <!-- 遮罩层 --> |
146 | -<view class="mask" wx:if="{{showPopup}}"></view> | |
147 | 163 | \ No newline at end of file |
164 | +<view class="mask" wx:if="{{showMask}}"></view> | |
165 | + | |
166 | +<qrcode id="qrcode" bindtap="closeCode"></qrcode> | |
148 | 167 | \ No newline at end of file | ... | ... |
packageB/pages/luckactivity/luckinfo/luckinfo.wxss
1 | 1 | /* packageB//pages/luckactivity/index/index.wxss */ |
2 | 2 | |
3 | 3 | page { |
4 | - background-color: rgb(129, 2, 253); | |
4 | + /* background-color: rgb(129, 2, 253); */ | |
5 | 5 | } |
6 | 6 | |
7 | 7 | page, |
... | ... | @@ -68,7 +68,7 @@ page, |
68 | 68 | width: 140rpx; |
69 | 69 | height: 140rpx; |
70 | 70 | margin-right: 20rpx; |
71 | - background-color: gray; | |
71 | + /* background-color: gray; */ | |
72 | 72 | } |
73 | 73 | |
74 | 74 | .img { |
... | ... | @@ -227,11 +227,12 @@ page, |
227 | 227 | z-index: 1; |
228 | 228 | padding: 0 20rpx; |
229 | 229 | box-sizing: border-box; |
230 | + z-index: 998; | |
230 | 231 | } |
231 | 232 | |
232 | 233 | .popup-container .img-container { |
233 | - width: 200rpx; | |
234 | - height: 200rpx; | |
234 | + width: 140rpx; | |
235 | + height: 140rpx; | |
235 | 236 | flex-shrink: 0; |
236 | 237 | } |
237 | 238 | |
... | ... | @@ -326,22 +327,22 @@ page, |
326 | 327 | height: 100%; |
327 | 328 | top: 0; |
328 | 329 | background-color: rgba(0,0,0,.5); |
329 | - /* z-index: 999; */ | |
330 | + z-index: 1; | |
330 | 331 | } |
331 | 332 | |
332 | 333 | |
333 | 334 | .popup-container2 { |
334 | - display: none; | |
335 | 335 | position: fixed; |
336 | 336 | top: 50%; |
337 | 337 | left: 50%; |
338 | 338 | transform: translate(-50%, -50%); |
339 | + z-index: 999; | |
339 | 340 | } |
340 | 341 | |
341 | 342 | .popup { |
342 | 343 | background-color: white; |
343 | 344 | border-radius: 12rpx; |
344 | - padding: 20rpx 40rpx; | |
345 | + padding: 40rpx; | |
345 | 346 | margin-top: 20rpx; |
346 | 347 | } |
347 | 348 | |
... | ... | @@ -363,4 +364,11 @@ page, |
363 | 364 | |
364 | 365 | .c-tb { |
365 | 366 | color: #ff6200; |
367 | +} | |
368 | + | |
369 | +.noMore { | |
370 | + padding: 20rpx; | |
371 | + color: #bbb; | |
372 | + text-align: center; | |
373 | + font-size: 22rpx; | |
366 | 374 | } |
367 | 375 | \ No newline at end of file | ... | ... |
packageB/pages/luckactivity/luckinfo/tool.wxs
0 → 100644
1 | +var tools = { | |
2 | + showDefaultImg: function(type) { | |
3 | + var src = ''; | |
4 | + switch(type) { | |
5 | + case 1: { //积分 | |
6 | + src = 'miniapp/images/luckDraw/jf.png'; | |
7 | + break; | |
8 | + }; | |
9 | + case 2: { //成长值 | |
10 | + src = 'miniapp/images/luckDraw/czz.png'; | |
11 | + break; | |
12 | + }; | |
13 | + case 3: { //优惠券 | |
14 | + src = 'miniapp/images/luckDraw/yhq.png'; | |
15 | + break; | |
16 | + }; | |
17 | + case 4: { //服务项目 | |
18 | + src = 'miniapp/images/luckDraw/fw.png'; | |
19 | + break; | |
20 | + }; | |
21 | + case 5: { //赠品 | |
22 | + src = 'miniapp/images/luckDraw/zp.png'; | |
23 | + break; | |
24 | + }; | |
25 | + case 6: { //礼包 | |
26 | + src = 'miniapp/images/luckDraw/lb.png'; | |
27 | + break; | |
28 | + }; | |
29 | + }; | |
30 | + return src; | |
31 | + }, | |
32 | +}; | |
33 | + | |
34 | +module.exports = { | |
35 | + showDefaultImg: tools.showDefaultImg, | |
36 | +} | |
0 | 37 | \ No newline at end of file | ... | ... |