Commit aa4ffa027de7c652566deaac741ea2b5837f81ef

Authored by taiyuan
1 parent 648500eb

大转盘修改

packageB/pages/luckactivity/luckinfo/luckinfo.js
  1 +var util = require("../../../../utils/util.js");
1 2 var WxParse = require('../../../../utils/wxParse/wxParse.js');
2 3 const app = getApp();
3 4 let imghost = app.globalData.setting.imghost;
4 5 let self = null;
  6 +let imgDraw = {
  7 + "width": "554px",
  8 + "height": "899px",
  9 + "background": "http://jmh.xinda100.cn/public/images/share_bg.png",
  10 + "views": [
  11 + { //0.头像
  12 + "type": "image",
  13 + "url": "",
  14 + "css": {
  15 + "background": "white",
  16 + "width": "80px",
  17 + "height": "80px",
  18 + "top": "24px",
  19 + "left": "40px",
  20 + "borderRadius": "80px",
  21 + }
  22 + },
  23 + { //1.昵称
  24 + "type": "text",
  25 + "text": "",
  26 + "css": {
  27 + "color": "#000000",
  28 + "width": "400px",
  29 + "top": "25px",
  30 + "left": "140px",
  31 + "fontSize": "26px",
  32 + "maxLines": "1",
  33 + }
  34 + },
  35 + { //2.强烈推荐
  36 + "type": "text",
  37 + "text": "强烈推荐",
  38 + "css": {
  39 + "color": "#fff",
  40 + "background": "#FF6768",
  41 + "width": "110px",
  42 + "height": "26px",
  43 + "lineHeight": "26px",
  44 + "top": "70px",
  45 + "left": "140px",
  46 + "borderRadius": "10px",
  47 + "fontSize": "18px",
  48 + "textAlign": "center"
  49 +
  50 + }
  51 + },
  52 + { //3.分享标题
  53 + "type": "text",
  54 + "text": "",
  55 + "css": {
  56 + "color": "red",
  57 + "width": "554px",
  58 + "padding": "20px",
  59 + "left": "20px",
  60 + "top": "140px",
  61 + "fontSize": "28px",
  62 + "textAlign": "center",
  63 + "maxLines": "1",
  64 + "fontWeight": "bold",
  65 + }
  66 + },
  67 + { //4.分享内容
  68 + "type": "text",
  69 + "text": "分享内容分享内容分享内容分享内容分享内容分享内容分享内容分享内容分享内容",
  70 + "css": {
  71 + "color": "#000000",
  72 + "width": "554px",
  73 + "padding": "20px",
  74 + "left": "20px",
  75 + "top": "190px",
  76 + "fontSize": "26px",
  77 + "textAlign": "center",
  78 + "maxLines": "1",
  79 + }
  80 + },
  81 + { //5.分享图片
  82 + "type": "image",
  83 + "url": "",
  84 + "css": {
  85 + "width": "554px",
  86 + "height": "350px",
  87 + "top": "240px",
  88 + "mode": "scaleToFill",
  89 + }
  90 + },
  91 + { //6
  92 + "type": "image",
  93 + "url": "/images/share/s_gou.png",
  94 + "css": {
  95 + "width": "30px",
  96 + "height": "30px",
  97 + "top": "620px",
  98 + "left": "18px",
  99 + "rotate": "0",
  100 + "borderRadius": "30px",
  101 + }
  102 + },
  103 + { //7
  104 + "type": "text",
  105 + "text": "正品保障",
  106 + "css": {
  107 + "color": "red",
  108 + "width": "110px",
  109 + "top": "620px",
  110 + "left": "52px",
  111 + "fontSize": "22px",
  112 + }
  113 + },
  114 + { //8
  115 + "type": "image",
  116 + "url": "/images/share/s_gou.png",
  117 + "css": {
  118 + "width": "30px",
  119 + "height": "30px",
  120 + "top": "620px",
  121 + "left": "208px",
  122 + "borderRadius": "30px",
  123 + }
  124 + },
  125 + { //9
  126 + "type": "text",
  127 + "text": "纯实体店",
  128 + "css": {
  129 + "color": "red",
  130 + "width": "129px",
  131 + "top": "620px",
  132 + "left": "243px",
  133 + "fontSize": "22px",
  134 + }
  135 + },
  136 + { //10
  137 + "type": "image",
  138 + "url": "/images/share/s_gou.png",
  139 + "css": {
  140 + "width": "30px",
  141 + "height": "30px",
  142 + "top": "620px",
  143 + "left": "410px",
  144 + "borderRadius": "30px",
  145 + }
  146 + },
  147 + { //11
  148 + "type": "text",
  149 + "text": "官方验证",
  150 + "css": {
  151 + "color": "red",
  152 + "width": "121px",
  153 + "top": "620px",
  154 + "left": "450px",
  155 + "fontSize": "22px",
  156 + }
  157 + },
  158 + { //12.横线
  159 + "type": "rect",
  160 + "css": {
  161 + "background": "#f0f0f0",
  162 + "width": "554px",
  163 + "height": "1px",
  164 + "top": "676px",
  165 + "left": "0px",
  166 + }
  167 + },
  168 + { //13
  169 + "type": "text",
  170 + "text": "特惠活动时间仅限",
  171 + "css": {
  172 + "color": "#000000",
  173 + "width": "245px",
  174 + "top": "730px",
  175 + "left": "28px",
  176 + "fontSize": "24px",
  177 + "textAlign": "left"
  178 + }
  179 + },
  180 + { //14.时间
  181 + "type": "text",
  182 + "text": "",
  183 + "css": {
  184 + "width": "377px",
  185 + "top": "770px",
  186 + "left": "28px",
  187 + "fontSize": "24px",
  188 + }
  189 + },
  190 + { //15
  191 + "type": "text",
  192 + "text": "长按识别小程序码有惊喜哦!",
  193 + "css": {
  194 + "color": "#7c7c7c",
  195 + "width": "348px",
  196 + "top": "810px",
  197 + "left": "27px",
  198 + "fontSize": "24px",
  199 + }
  200 + },
  201 +
  202 + { //16.码
  203 + "type": "image",
  204 + "url": "",
  205 + "css": {
  206 + "width": "150px",
  207 + "height": "150px",
  208 + "top": "705px",
  209 + "left": "380px",
  210 + "mode": "scaleToFill"
  211 + }
  212 + },
  213 +
  214 + ]
  215 + };
  216 +
5 217  
6 218 Page({
7 219 data: {
  220 + imgDraw: imgDraw,
8 221 start: false,
9 222 list: null,
10 223 isLoading: false, // 检测是否已经发送请求,防止重复发送请求
... ... @@ -12,6 +225,8 @@ Page({
12 225 pageNum: 1, // 当前页数
13 226 imghost: imghost,
14 227 num: 3,
  228 + canStart: false,
  229 +
15 230  
16 231 prizes: [],
17 232 defaultConfig: {
... ... @@ -63,6 +278,7 @@ Page({
63 278 // });
64 279 // console.log('imghost+++++', imghost);
65 280 self = this;
  281 + let first_leader = null;
66 282 this.data.options = options;
67 283 // this.setData({
68 284 // options,
... ... @@ -72,28 +288,58 @@ Page({
72 288 wx.setNavigationBarTitle({
73 289 title: options.title,
74 290 });
  291 +
  292 +
75 293 app.isLogin().then(function(data) {//进入页面前已经授权登录成功
76 294 self.setData({
77 295 userInfo: data,
78   - // imghost,
79 296 });
80 297 });
  298 +
  299 +
  300 +
  301 + //从分享的跳转过来
  302 + if (options.id == undefined || options.id == null || options.id == '') {
  303 + var scene = decodeURIComponent(options.scene);
  304 + scene = scene.split('_');
  305 + first_leader = scene[0];
  306 + this.data.options.id = scene[1];
  307 + };
  308 +
  309 + if(first_leader) {
  310 + console.log("log---", first_leader);
  311 + app.globalData.first_leader = first_leader;
  312 + //调用接口判断是不是会员
  313 + app.request.promiseGet("/api/weshop/shoppingGuide/get/" + app.globalData.setting.stoid +"/" + first_leader,{}).then(res=>{
  314 + if(res.data.code==0){
  315 + app.globalData.guide_id = res.data.data.id;
  316 + }
  317 + })
  318 + };
  319 +
  320 +
  321 +
  322 +
  323 +
81 324 },
82 325  
83 326 onShow() {
  327 + console.log('show~~`');
84 328 if(app.globalData.userInfo) {
85 329 if(!this.data.isLogin) {
86   -
87 330 this.setData({
88 331 userInfo: app.globalData.userInfo,
89 332 isLogin: true,
  333 + 'imgDraw.views[0].url': app.globalData.userInfo.head_pic,//头像
  334 + 'imgDraw.views[1].text': app.globalData.userInfo.nickname,//昵称
90 335 });
91   -
92 336 // console.log('imghost', this.data.imghost);
93 337 let user_id = app.globalData.userInfo.user_id;
94 338 let store_id = app.globalData.setting.stoid;
95 339 let id = this.data.options.id;
96 340 let url = `/api/weshop/marketing/marketingLuckForm/getLuckInfo/${store_id}/${id}/${user_id}`;
  341 +
  342 +
97 343  
98 344  
99 345 app.request.get(url, {
... ... @@ -116,31 +362,32 @@ Page({
116 362  
117 363  
118 364 if(luckInfo && luckInfo.template_type != null && luckInfo.template_type == 1) { //获取模板
119   - let url = `/api/weshop/marketing/marketingLuckTemplate/get/${store_id}/${luckInfo.template_id}`;
  365 + let url = `/api/weshop/marketing/marketingLuckTemplate/get/0/${luckInfo.template_id}`;
120 366 app.request.get(url, {
121 367 success: function(res) {
122   - // console.log('prizes//////', res.data.data);
123   - self.setData({
124   - template: res.data.data,
125   - bannerUrl: imghost + ((res.data.data&&res.data.data.bannerUrl) ? res.data.data.bannerUrl:'miniapp/images/luckDraw/bg.png?v=2'), //背景图
126   - 'blocks[0].imgs[0].src': imghost + ((res.data.data&&res.data.data.wheelBaseUrl) ? res.data.data.wheelBaseUrl:'miniapp/images/luckDraw/weel.png?v=2'), //转盘
127   - 'buttons[0].imgs[0].src': imghost + ((res.data.data&&res.data.data.wheelPointerUrl) ? res.data.data.wheelPointerUrl:'miniapp/images/luckDraw/pointer.png?v=2'), //指针
128   - });
  368 + // if(res.data.code == 0) {
  369 + self.setData({
  370 + template: res.data.data,
  371 + bannerUrl: imghost + ((res.data.data&&res.data.data.bannerUrl) ? res.data.data.bannerUrl:'miniapp/images/luckDraw/bg.png?v=2'), //背景图
  372 + 'blocks[0].imgs[0].src': imghost + ((res.data.data&&res.data.data.wheelBaseUrl) ? res.data.data.wheelBaseUrl:'miniapp/images/luckDraw/weel.png?v=2'), //转盘
  373 + 'buttons[0].imgs[0].src': imghost + ((res.data.data&&res.data.data.wheelPointerUrl) ? res.data.data.wheelPointerUrl:'miniapp/images/luckDraw/pointer.png?v=2'), //指针
  374 + 'imgDraw.views[3].text': (res.data.data&&res.data.data.title) ? res.data.data.tilte : self.data.luckInfo.act_name,//分享标题
  375 + 'imgDraw.views[4].text': (res.data.data&&res.data.data.share_content) ? res.data.data.share_content : '快来一起抽奖吧,精美奖品等着你!',//分享标题
  376 + 'imgDraw.views[5].url': imghost + ((res.data.data&&res.data.data.share_image) ? res.data.data.share_image:self.data.luckInfo.imageurl),//分享图片
  377 + 'imgDraw.views[14].text': util.formar_no_full(self.data.luckInfo.begindate) + ' 至 ' + util.formar_no_full(self.data.luckInfo.enddate),//活动时间
  378 + });
  379 + // };
  380 +
129 381 },
130 382 });
131 383 } else {
132   - // wx.hideLoading();
  384 +
133 385 if(luckInfo && luckInfo.store_bannerUrl) {
134 386 self.setData({
135 387 bannerUrl: imghost + luckInfo.store_bannerUrl,
136 388 });
137 389 };
138 390  
139   - // self.setData({
140   - // showMask2: false,
141   - // hiddenCanvas: false,
142   - // });
143   -
144 391 };
145 392  
146 393  
... ... @@ -149,7 +396,6 @@ Page({
149 396 title: self.data.luckInfo.msgInfo,
150 397 icon: 'none',
151 398 });
152   - // return;
153 399 };
154 400  
155 401 },
... ... @@ -211,6 +457,24 @@ Page({
211 457 },
212 458 });
213 459  
  460 + let mainUrl = app.globalData.setting.url;
  461 + // let stoid = app.globalData.setting.stoid;
  462 + let cj_id = this.data.options.id;
  463 + // let user_id = app.globalData.userInfo.user_id;
  464 +
  465 + wx.getImageInfo({
  466 + src: `${mainUrl}/api/wx/open/app/user/getWeAppEwm/${store_id}?sceneValue=${user_id}_${cj_id}&pageValue=packageB/pages/luckactivity/luckinfo/luckinfo`,
  467 + success (res) {
  468 + if(res.data.code != -1) {
  469 + self.setData({
  470 + 'imgDraw.views[16].url': res.path,
  471 + });
  472 + };
  473 +
  474 + }
  475 + });
  476 +
  477 +
214 478 };
215 479 };
216 480 },
... ... @@ -234,7 +498,7 @@ Page({
234 498 if(length == 1) {
235 499 [0,2,4,6].map(function(item, index) {
236 500 prizes[item] = {
237   - id: award[0].id,
  501 + id: award[0].record_id,
238 502 lbtype: award[0].lbtype,
239 503 fonts: [{ text: award[0].luck_goods_name + ' x' + award[0].num, top: '18%', wordWrap:false, fontColor: 'transparent'}],
240 504 imgs: [
... ... @@ -258,7 +522,7 @@ Page({
258 522 if(length == 2) {
259 523 [0,4].map(function(item, index) {
260 524 prizes[item] = {
261   - id: award[0].id,
  525 + id: award[0].record_id,
262 526 lbtype: award[0].lbtype,
263 527 fonts: [{ text: award[0].luck_goods_name + ' x' + award[0].num, top: '18%', wordWrap:false, fontColor: 'transparent'}],
264 528 imgs: [
... ... @@ -274,7 +538,7 @@ Page({
274 538  
275 539 [2,6].map(function(item, index) {
276 540 prizes[item] = {
277   - id: award[1].id,
  541 + id: award[1].record_id,
278 542 lbtype: award[1].lbtype,
279 543 fonts: [{ text: award[1].luck_goods_name + ' x' + award[1].num, top: '18%', wordWrap:false, fontColor: 'transparent'}],
280 544 imgs: [
... ... @@ -298,7 +562,7 @@ Page({
298 562 if(length == 3) {
299 563 [0,4].map(function(item, index) {
300 564 prizes[item] = {
301   - id: award[0].id,
  565 + id: award[0].record_id,
302 566 lbtype: award[0].lbtype,
303 567 fonts: [{ text: award[0].luck_goods_name + ' x' + award[0].num, top: '18%', wordWrap:false, fontColor: 'transparent'}],
304 568 imgs: [
... ... @@ -314,7 +578,7 @@ Page({
314 578  
315 579 [1,5].map(function(item, index) {
316 580 prizes[item] = {
317   - id: award[1].id,
  581 + id: award[1].record_id,
318 582 lbtype: award[1].lbtype,
319 583 fonts: [{ text: award[1].luck_goods_name + ' x' + award[1].num, top: '18%', wordWrap:false, fontColor: 'transparent'}],
320 584 imgs: [
... ... @@ -330,7 +594,7 @@ Page({
330 594  
331 595 [2,6].map(function(item, index) {
332 596 prizes[item] = {
333   - id: award[2].id,
  597 + id: award[2].record_id,
334 598 lbtype: award[2].lbtype,
335 599 fonts: [{ text: award[2].luck_goods_name + ' x' + award[2].num, top: '18%', wordWrap:false, fontColor: 'transparent'}],
336 600 imgs: [
... ... @@ -355,7 +619,7 @@ Page({
355 619 if(length == 4) {
356 620 [0,2,4,6].map(function(item, index) {
357 621 prizes[item] = {
358   - id: award[index].id,
  622 + id: award[index].record_id,
359 623 lbtype: award[index].lbtype,
360 624 fonts: [{ text: award[index].luck_goods_name + ' x' + award[index].num, top: '18%', wordWrap:false, fontColor: 'transparent'}],
361 625 imgs: [
... ... @@ -379,7 +643,7 @@ Page({
379 643 if(length == 5) {
380 644 [0,2,3,5,6].map(function(item, index) {
381 645 prizes[item] = {
382   - id: award[index].id,
  646 + id: award[index].record_id,
383 647 lbtype: award[index].lbtype,
384 648 fonts: [{ text: award[index].luck_goods_name + ' x' + award[index].num, top: '18%', wordWrap:false, fontColor: 'transparent'}],
385 649 imgs: [
... ... @@ -403,7 +667,7 @@ Page({
403 667 if(length == 6) {
404 668 prizes = award.map(function(item, index) {
405 669 return {
406   - id: item.id,
  670 + id: item.record_id,
407 671 lbtype: item.lbtype,
408 672 fonts: [{ text: item.luck_goods_name + ' x' + item.num, top: '18%', wordWrap:false, fontColor: 'transparent'}],
409 673 imgs: [
... ... @@ -503,146 +767,183 @@ Page({
503 767 return;
504 768 };
505 769  
506   -
507   - if(this.data.luckInfo.user_LuckNumDay > 0 || this.data.luckInfo.vip_act_num == 0) {
508   - // console.log('start choujiang');
509   - // let start = false;
510   - if(!this.data.start) {
511   - this.data.start = true;
512   - // 获取抽奖组件实例
513   - const $lucky = this.selectComponent('#myLucky');
514   - // 调用play方法开始旋转
515   - $lucky.play();
  770 + // 获取积分
  771 + app.request.promisePost('/api/weshop/marketing/marketingLuckForm/startLuckIntegral', {
  772 + isShowLoading: false,
  773 + data: {
  774 + storeId: app.globalData.setting.stoid,
  775 + userId: app.globalData.userInfo.user_id,
  776 + LuckId: this.data.options.id,
  777 + },
  778 + })
  779 + .then(function(res) {
  780 + if(res.data.code == -1) {
  781 + //积分不足,弹出提示
  782 + self.data.luckInfo.msgInfo = res.data.msg
  783 + wx.showToast({
  784 + title: res.data.msg,
  785 + icon: 'none',
  786 + });
  787 + return;
  788 + };
  789 +
  790 + if(res.data.code == 0) {
516 791  
517   - // 获取抽奖结果
518   - app.request.post('/api/weshop/marketing/marketingLuckForm/startLuck', {
519   - isShowLoading: false,
520   - data: {
521   - storeId: app.globalData.setting.stoid,
522   - userId: app.globalData.userInfo.user_id,
523   - LuckId: this.data.options.id,
524   - },
525   - success: function(res) {
  792 + if(self.data.luckInfo.user_LuckNumDay > 0 || self.data.luckInfo.vip_act_num == 0) {
  793 + console.log('start choujiang');
  794 + // let start = false;
  795 + if(!self.data.start) {
  796 + self.data.start = true;
  797 + // 获取抽奖组件实例
  798 + const $lucky = self.selectComponent('#myLucky');
  799 + // 调用play方法开始旋转
  800 + $lucky.play();
526 801  
527   - if(res.data.code == 0) {
528   - console.log('开始摇奖', res.data.data);
529   - if(self.data.luckInfo.vip_act_num != 0) {
530   - self.setData({
531   - 'luckInfo.user_LuckNumDay': self.data.luckInfo.user_LuckNumDay - 1,
532   - // isActive: true,
533   - });
534   - };
535   -
536   - self.setData({
537   - // 'luckInfo.user_LuckNumDay': self.data.luckInfo.user_LuckNumDay - 1,
538   - isActive: true,
539   - wow: res.data.data,
540   - });
541   - // console.log('请求成功', res.data.data);
542   - let luckyId = res.data.data.id;
543   - let indexArr = self.luckyIndex(self.data.prizes, luckyId);
544   - // console.log('抽奖奖品id', luckyId);
545   - // console.log('奖品列表', self.data.prizes);
546   - // console.log('奖品对应的索引数组', indexArr);
547   - let random = Math.random() * indexArr.length >> 0;
548   - // console.log('random', random);
549   - let index = indexArr[random];
550   - setTimeout(() => {
551   - $lucky.stop(index);
552   - self.data.start = false;
553   - }, 3000);
554   -
555   -
556   - //获取兑奖记录
557   - // app.request.get('/api/weshop/marketing/marketingLuckRecord/page', {
558   - // isShowLoading: false,
559   - // data: {
560   - // store_id: app.globalData.setting.stoid,
561   - // user_id: app.globalData.userInfo.user_id,
562   - // luck_formid: self.data.options.id,
563   - // luck_state: 1
564   - // },
565   - // success: function(res) {
566   - // if(res.data.code == 0) {
567   - // // console.log('res===>', res.data.data.pageData);
568   - // self.setData({
569   - // record: res.data.data.pageData,
570   - // });
571   - // };
572   - // },
573   - // });
574   -
575   -
576   - } else {
577   - let thxIndexArr = self.data.thxIndexArr;
578   - const random = Math.random() * thxIndexArr.length >> 0;
579   - const index = thxIndexArr[random];
580   - // console.log('谢谢参与数组', thxIndexArr);
581   - // console.log('请求出错产生谢谢参与的随机数', index);
582   - setTimeout(() => {
583   - $lucky.stop(index);
584   - self.data.start = false;
585   - }, 3000);
586   -
587   -
  802 + // 获取抽奖结果
  803 + app.request.post('/api/weshop/marketing/marketingLuckForm/startLuck', {
  804 + isShowLoading: false,
  805 + data: {
  806 + storeId: app.globalData.setting.stoid,
  807 + userId: app.globalData.userInfo.user_id,
  808 + LuckId: self.data.options.id,
  809 + },
  810 + success: function(res) {
  811 +
  812 + if(res.data.code == 0) {
  813 + console.log('开始摇奖', res.data.data);
  814 + if(self.data.luckInfo.vip_act_num != 0) {
  815 + self.setData({
  816 + 'luckInfo.user_LuckNumDay': self.data.luckInfo.user_LuckNumDay - 1,
  817 + // isActive: true,
  818 + });
  819 + };
  820 +
  821 + self.setData({
  822 + // 'luckInfo.user_LuckNumDay': self.data.luckInfo.user_LuckNumDay - 1,
  823 + isActive: true,
  824 + wow: res.data.data,
  825 + });
  826 + // console.log('请求成功', res.data.data);
  827 + let luckyId = res.data.data.id;
  828 + let indexArr = self.luckyIndex(self.data.prizes, luckyId);
  829 + // console.log('抽奖奖品id', luckyId);
  830 + // console.log('奖品列表', self.data.prizes);
  831 + // console.log('奖品对应的索引数组', indexArr);
  832 + let random = Math.random() * indexArr.length >> 0;
  833 + // console.log('random', random);
  834 + let index = indexArr[random];
  835 + setTimeout(() => {
  836 + $lucky.stop(index);
  837 + self.data.start = false;
  838 + }, 3000);
  839 +
  840 +
  841 + //获取兑奖记录
  842 + // app.request.get('/api/weshop/marketing/marketingLuckRecord/page', {
  843 + // isShowLoading: false,
  844 + // data: {
  845 + // store_id: app.globalData.setting.stoid,
  846 + // user_id: app.globalData.userInfo.user_id,
  847 + // luck_formid: self.data.options.id,
  848 + // luck_state: 1
  849 + // },
  850 + // success: function(res) {
  851 + // if(res.data.code == 0) {
  852 + // // console.log('res===>', res.data.data.pageData);
  853 + // self.setData({
  854 + // record: res.data.data.pageData,
  855 + // });
  856 + // };
  857 + // },
  858 + // });
  859 +
  860 +
  861 + } else {
  862 + let thxIndexArr = self.data.thxIndexArr;
  863 + const random = Math.random() * thxIndexArr.length >> 0;
  864 + const index = thxIndexArr[random];
  865 + // console.log('谢谢参与数组', thxIndexArr);
  866 + // console.log('请求出错产生谢谢参与的随机数', index);
  867 + setTimeout(() => {
  868 + $lucky.stop(index);
  869 + self.data.start = false;
  870 + }, 3000);
  871 +
  872 +
  873 +
  874 +
  875 + if(res.data.code == -1) {
  876 + wx.showToast({
  877 + title: res.data.msg,
  878 + icon: 'none',
  879 + });
  880 + self.data.luckInfo.msgInfo = res.data.msg;
  881 + return;
  882 + // self.data.start = true;
  883 + };
  884 +
  885 +
  886 + if(res.data.code == -2 && self.data.luckInfo.vip_act_num != 0) {
  887 + self.setData({
  888 + 'luckInfo.user_LuckNumDay': self.data.luckInfo.user_LuckNumDay - 1,
  889 + });
  890 + };
  891 +
  892 +
  893 + };
  894 +
588 895  
  896 + },
589 897  
590   - if(res.data.code == -1) {
  898 + fail: function(res) {
  899 + // console.log('出错');
591 900 wx.showToast({
592   - title: res.data.msg,
593   - icon: 'none',
  901 + title: '数据请求失败',
  902 + icon: 'error',
594 903 });
595   - self.data.luckInfo.msgInfo = res.data.msg;
596   - return;
597   - // self.data.start = true;
598   - };
599   - // console.log('请求出错');
600   - if(res.data.code == -2 && self.data.luckInfo.vip_act_num != 0) {
601   - self.setData({
602   - 'luckInfo.user_LuckNumDay': self.data.luckInfo.user_LuckNumDay - 1,
603   - });
604   - };
605   -
  904 + let thxIndexArr = self.data.thxIndexArr;
  905 + const random = Math.random() * thxIndexArr.length >> 0;
  906 + const index = thxIndexArr[random];
  907 + setTimeout(() => {
  908 + $lucky.stop(index);
  909 + self.data.start = false;
  910 + }, 3000);
  911 + },
606 912  
607 913  
608 914  
609   - };
610   - },
611   -
612   - fail: function(res) {
613   - // console.log('出错');
614   - wx.showToast({
615   - title: '数据请求失败',
616   - icon: 'error',
617 915 });
618   - let thxIndexArr = self.data.thxIndexArr;
619   - const random = Math.random() * thxIndexArr.length >> 0;
620   - const index = thxIndexArr[random];
621   - setTimeout(() => {
622   - $lucky.stop(index);
623   - self.data.start = false;
624   - }, 3000);
625   - },
  916 +
  917 + }
626 918  
627   - });
  919 +
  920 + } else {
  921 + wx.showToast({
  922 + title: '你今天的抽奖次数已用完啦!~',
  923 + icon: 'none',
  924 + });
  925 + };
628 926  
629   - }
630   -
631   -
632   - } else {
633   - wx.showToast({
634   - title: '你今天的抽奖次数已用完啦!~',
635   - icon: 'none',
636   - });
637   - };
  927 + };
  928 + });
  929 +
  930 +
  931 +
  932 +
  933 +
638 934  
639 935 },
640 936 end (event) {
641 937 // 中奖奖品详情
642   - console.log('00000000~',event.detail.lbtype);
  938 + console.log('抽奖结果:',event.detail);
643 939 let no_luck_urltype = this.data.luckInfo.no_luck_urltype;
644   - let lbtype;
  940 + let lbtype = null;
  941 + let good_id = null;
645 942 let resultTitle = event.detail.fonts[0].text.replace('\n','');
  943 + if(event.detail.id) {
  944 + console.log('~~~~~~----++++++',event.detail.id);
  945 + good_id = event.detail.id;
  946 + };
646 947 if(event.detail.lbtype == 5) {
647 948 lbtype = 5;
648 949 } else {
... ... @@ -656,6 +957,7 @@ Page({
656 957 resultTitle,
657 958 showPopup: false,
658 959 currentLbtype: lbtype,
  960 + good_id,
659 961 });
660 962  
661 963  
... ... @@ -691,7 +993,7 @@ Page({
691 993 });
692 994 };
693 995 } else if((self.data.luckInfo.give_type == 2)) {
694   - if(self.data.luckInfo.give_integral > 0) {
  996 + if(self.data.luckInfo.give_growth > 0) {
695 997 wx.showToast({
696 998 title: `获得游戏奖励成长值${self.data.luckInfo.give_growth}`,
697 999 icon: 'none',
... ... @@ -708,7 +1010,7 @@ Page({
708 1010 });
709 1011 };
710 1012 } else if((self.data.luckInfo.give_type == 2)) {
711   - if(self.data.luckInfo.give_integral > 0) {
  1013 + if(self.data.luckInfo.give_growth > 0) {
712 1014 wx.showToast({
713 1015 title: `获得游戏奖励成长值${self.data.luckInfo.give_growth}`,
714 1016 icon: 'none',
... ... @@ -887,20 +1189,30 @@ Page({
887 1189 },
888 1190  
889 1191 showQr(e) {
  1192 + let id = null;
890 1193 let store_id = app.globalData.setting.stoid;
891   - let id = e.currentTarget.dataset.id;
  1194 + if(e && e.currentTarget.dataset.id) {
  1195 + id = e.currentTarget.dataset.id;
  1196 + } else {
  1197 + id = this.data.good_id;
  1198 + };
892 1199 let url = `/api/weshop/marketing/marketingLuckList/updateGoodsVerifyCode/${store_id}/${id}`;
  1200 + console.log('good_id', id, url);
893 1201 app.request.put(url, {
894 1202 success: function(res) {
895 1203 if(res.data.code == 0) {
896 1204 let data = res.data.data;
897   - console.log('data!!!!', data);
898 1205 let barcode = self.selectComponent("#qrcode");
899 1206 barcode.open({val: data});
900 1207 self.setData({
901 1208 hiddenCanvas: true,
902 1209 showPopup: false,
903 1210 });
  1211 + } else {
  1212 + wx.showToast({
  1213 + title: res.data.msg,
  1214 + icon: 'none',
  1215 + });
904 1216 };
905 1217 },
906 1218  
... ... @@ -917,7 +1229,32 @@ Page({
917 1229 clickReceive() {
918 1230 this.setData({
919 1231 showResult: false,
  1232 + showMask: false,
  1233 + });
  1234 + this.showQr();
  1235 + },
  1236 +
  1237 + showPoster() {
  1238 + this.setData({
  1239 + hiddenCanvas: true,
  1240 + showMask: true,
  1241 + showPoster: true,
  1242 + });
  1243 + },
  1244 +
  1245 + closePoster() {
  1246 + this.setData({
  1247 + showMask: false,
  1248 + showPoster: false,
  1249 + hiddenCanvas: false,
  1250 + });
  1251 + },
  1252 +
  1253 +
  1254 +
  1255 + onImgOK(e) {
  1256 + this.setData({
  1257 + myimg: e.detail.path,
920 1258 });
921   - this.showPopup();
922 1259 },
923 1260 })
924 1261 \ No newline at end of file
... ...
packageB/pages/luckactivity/luckinfo/luckinfo.json
... ... @@ -2,7 +2,8 @@
2 2 "usingComponents": {
3 3 "lucky-wheel":"/packageB/miniprogram_npm/mini-luck-draw/lucky-wheel/index",
4 4 "qrcode": "/components/my-qrcode/my-qrcode",
5   - "nodata": "/components/nodata/nodata"
  5 + "nodata": "/components/nodata/nodata",
  6 + "painter": "/packageB/components/painter/painter"
6 7 },
7 8 "enablePullDownRefresh": false,
8 9 "navigationBarTitleText": "幸运大转盘"
... ...
packageB/pages/luckactivity/luckinfo/luckinfo.wxml
1 1 <wxs module="filter" src="../../../../utils/filter.wxs"></wxs>
2 2 <wxs module="tool" src="./tool.wxs"></wxs>
3   -<view class="luck-container" style="background: {{template.colorCode ? template.colorCode:'#da104b'}} url({{bannerUrl ? bannerUrl:(imghost + 'miniapp/images/luckDraw/bg.png?v=2')}}) no-repeat;">
  3 +<view class="luck-container {{template ? '':'on'}}" style="background: {{template.colorCode ? template.colorCode:'#f0f0f0'}} url({{bannerUrl ? bannerUrl:(imghost + 'miniapp/images/luckDraw/bg.png?v=2')}}) no-repeat;">
4 4 <!-- 中奖人员 -->
5 5 <view class="swiper-container" wx:if="{{nameList && nameList.length != 0}}">
6 6 <swiper class="swiper" autoplay="true" circular="true" vertical="true" interval="3000">
... ... @@ -35,17 +35,17 @@
35 35 hiddenCanvas="{{hiddenCanvas}}"
36 36 />
37 37 </view>
38   - <view class="fs28 white t-c pdt10" wx:if="{{luckInfo.vip_act_num == 0}}">今天你有 <text class="fs50 c-yellow">不限次</text> 抽奖机会</view>
39   - <view class="fs28 white t-c pdt10" wx:else>今天你还有 <text class="fs50 c-yellow">{{filter.show_default(luckInfo.user_LuckNumDay, '0')}}</text> 次抽奖机会</view>
  38 + <view class="weel-txt fs28 white t-c pdt10" wx:if="{{luckInfo.vip_act_num == 0}}">今天你有 <text class="fs50 c-yellow cs">不限次</text> 抽奖机会</view>
  39 + <view class="weel-txt fs28 white t-c pdt10" wx:else>今天你还有 <text class="fs50 c-yellow">{{filter.show_default(luckInfo.user_LuckNumDay, '0')}}</text> 次抽奖机会</view>
40 40 <view class="tip-to-down expand-transition">
41 41 <text></text>
42 42 <text></text>
43 43 </view>
44 44 </view>
45 45 <!-- 奖品展示 -->
46   - <view wx:if="{{award}}">
  46 + <view wx:if="{{award && award.length != 0}}">
47 47 <view class="badge-container"><image src="{{imghost + 'miniapp/images/luckDraw/badge.png'}}" class="badge prizes" lazy-load></image></view>
48   - <view class="list br12 bg-white">
  48 + <view class="panel list br12 bg-white">
49 49 <view class="list-item" wx:for="{{award}}">
50 50 <view class="img-container">
51 51 <image wx:if="{{item.luck_goods_img}}" src="{{imghost + item.luck_goods_img}}" class="img" mode="aspectFit"></image>
... ... @@ -64,19 +64,19 @@
64 64 <!-- 活动展示 -->
65 65 <view>
66 66 <view class="badge-container"><image src="{{imghost + 'miniapp/images/luckDraw/badge.png'}}" class="badge activity" lazy-load></image></view>
67   - <view class="bg-white br12 pd20 fs28">
  67 + <view class="panel bg-white br12 pd20 fs28">
68 68 <!-- {{luckInfo.remark}} -->
69 69 <import src="../../../../utils/wxParse/wxParse.wxml"/>
70 70 <!-- <template is="wxParse" data="{{wxParseData:content.nodes}}"/> -->
71 71 <!-- 时间 -->
72   - <view class="bdb">
  72 + <view class="bdt">
73 73 <!-- <view class=""> -->
74 74 <view class="txt-red">活动时间:</view>
75 75 <view class="fs28 pdv20">{{filter.format_time(luckInfo.begindate, 1) + ' 至 ' + filter.format_time(luckInfo.enddate, 1)}}</view>
76 76 <!-- </view> -->
77 77 </view>
78 78 <!-- 规则 -->
79   - <view class="bdb" wx:if="{{luckInfo.remark}}">
  79 + <view class="bdt" wx:if="{{luckInfo.remark}}">
80 80 <view class="txt-red pdt20">活动说明:</view>
81 81 <view class="fs28 pdv20"><template is="wxParse" data="{{wxParseData:content.nodes}}"/></view>
82 82 </view>
... ... @@ -116,14 +116,14 @@
116 116 </view>
117 117 </view> -->
118 118 <!-- 技术支持 -->
119   - <view class="t-c">
  119 + <view class="logo-container t-c">
120 120 <!-- <view class="pdt20 fs26 text-underline">帮美店免费开通这个玩法</view> -->
121 121 <view class="flex ai_c fs24 jc-center pdv20 white"><image src="{{imghost + 'miniapp/images/luckDraw/logo.png'}}" class="logo" lazy-load></image>提供技术支持</view>
122 122 </view>
123 123 </view>
124 124  
125 125 <!-- 分享按钮 -->
126   -<!-- <view class="circle-container zhuanfa" bindtap=""><text class="iconfont icon-zhuanfa1"></text></view> -->
  126 +<view class="circle-container zhuanfa" bindtap="showPoster"><text class="iconfont icon-zhuanfa1"></text></view>
127 127  
128 128 <!-- 悬浮按钮 -->
129 129 <view class="circle-container gift {{((record && record.length != 0) || isActive) ? 'active':''}}" bindtap="showPopup"><text class="iconfont icon-liwu"></text></view>
... ... @@ -140,10 +140,10 @@
140 140 <view class="ellipsis-2 fs28">{{item.luck_name}}</view>
141 141 <view class="pdt20">
142 142 <view class="fs26 xc-black3">价值:<text class="rmb">{{item.luck_goods_price}}</text></view>
143   - <view class="flex ai_c jc_fe fs26 xc-black3 ">
  143 + <view class="flex ai_c {{item.luck_type == 5 ? 'jc_sb':'jc_fe'}} fs26 xc-black3 ">
144 144 <!-- <view style="visibility: {{item.luck_type == 5 ? 'visible':'hidden'}};">兑换状态:{{item.state == 0 ? '未兑换':'已兑换'}}</view> -->
145 145 <!-- <view style="">兑换状态:{{item.state == 0 ? '未兑换':'已兑换'}}</view> -->
146   - <!-- <view class="fs24 c-a">中奖时间:{{filter.format_time(item.luck_time, 1)}}</view> -->
  146 + <view class="fs24 c-a" wx:if="{{item.luck_type == 5}}">兑换截止时间:{{filter.show_default(item.changeDate, '不限')}}</view>
147 147 <view class="btn" bindtap="{{item.luck_type == 5 ? (item.state == 0 ? 'showQr':''):'goto'}}" data-type="{{item.luck_type}}" data-id="{{item.id}}" data-ordersn="{{item.order_sn}}" data-buyreceiveid="{{item.buyreceive_id}}">{{item.luck_type == 5 ? (item.state == 1 ? '已兑换':'兑换'):'查看'}}</view>
148 148 </view>
149 149 </view>
... ... @@ -187,9 +187,18 @@
187 187 </view>
188 188  
189 189  
  190 +<!-- 海报 -->
  191 + <view class="poster-container" wx:if="{{showPoster}}">
  192 + <view class="t-r pdb20 white2"><text class="iconfont icon-close fs40" bindtap="closePoster"></text></view>
  193 + <image src="{{myimg}}" class="poster" show-menu-by-longpress></image>
  194 + <view class="pdt10 fs26 white2"><text class="iconfont icon-zhiwen"></text> 长按图片保存至相册</view>
  195 + </view>
  196 +
  197 +
190 198 <!-- 遮罩层 -->
191 199 <view class="mask" wx:if="{{showMask}}"></view>
192   -<!-- 进场遮罩层 -->
193   -<view class="mask2" wx:if="{{showMask2}}"></view>
194 200  
195   -<qrcode id="qrcode" bind:close="closeQr"></qrcode>
196 201 \ No newline at end of file
  202 +<qrcode id="qrcode" bind:close="closeQr"></qrcode>
  203 +
  204 +
  205 +<painter style="position: absolute; top: -9999rpx;" palette="{{imgDraw}}" bind:imgOK="onImgOK" />
197 206 \ No newline at end of file
... ...
packageB/pages/luckactivity/luckinfo/luckinfo.wxss
... ... @@ -13,7 +13,7 @@ page,
13 13  
14 14 .luck-container {
15 15 background-size: 100% auto !important;
16   - padding: 50% 20rpx 0;
  16 + padding: 42% 20rpx 0;
17 17 }
18 18  
19 19 .weel-container {
... ... @@ -320,9 +320,7 @@ page,
320 320 color: #ff2d4b;
321 321 }
322 322  
323   -.bdb {
324   - border-bottom: 2rpx solid #ebedf0;
325   -}
  323 +
326 324  
327 325 .c-yellow {
328 326 color: yellow;
... ... @@ -336,7 +334,7 @@ page,
336 334 width: 100%;
337 335 height: 100%;
338 336 top: 0;
339   - background-color: rgba(0,0,0,.5);
  337 + background-color: rgba(0,0,0,.7);
340 338 z-index: 1;
341 339 }
342 340  
... ... @@ -437,3 +435,50 @@ page,
437 435 padding: 0 10rpx;
438 436 }
439 437  
  438 +.bdt ~ .bdt {
  439 + border-top: 2rpx solid #ebedf0;
  440 +}
  441 +
  442 +.poster-container {
  443 + text-align: center;
  444 + color: white;
  445 + position: fixed;
  446 + top: 50%;
  447 + left: 50%;
  448 + transform: translate(-50%, -50%);
  449 + z-index: 9;
  450 +}
  451 +
  452 +.poster {
  453 + width: 554rpx;
  454 + height: 899rpx;
  455 + /* border-radius: 16rpx; */
  456 + margin: 0 auto;
  457 + /* background-color: pink; */
  458 +}
  459 +
  460 +
  461 +.luck-container.on .weel-txt {
  462 + color: black;
  463 +}
  464 +
  465 +.luck-container.on .badge,
  466 +.luck-container.on .logo-container,
  467 +.luck-container.on .tip-to-down {
  468 + -webkit-filter: brightness(60%);
  469 + filter: brightness(60%);
  470 +}
  471 +
  472 +.luck-container.on .panel {
  473 + box-shadow: 0 16rpx 24rpx #e7e9eb;
  474 +}
  475 +
  476 +.luck-container.on .cs {
  477 + color: #ff5000;
  478 +}
  479 +
  480 +
  481 +
  482 +
  483 +
  484 +
... ...