Commit 6731136af6f21671b1017e754f0c288e41bd7a2d

Authored by 后端开发-许程
1 parent 2540a307

助力任务的领取页面

pages/user/assistance/task_assistance.js
... ... @@ -17,21 +17,40 @@ Page({
17 17 sw_index: 0, //轮播的下标控制
18 18 url: s.url, //接口网址
19 19 iurl: s.imghost,
20   - endDate:"",//活动结束时间
  20 + endDate: "", //活动结束时间
21 21 activity_data: "25:20:59", //活动剩余时间
22   - task_number:0, //任务数
  22 + task_number: 0, //任务数
23 23 is_task: 0, //历史记录与任务
24   - aitem: "", //活动的轮播图
  24 + aitem: "", //活动的轮播图数据
25 25 switch_head: 0, //0:我的任务,1:记录
26 26 help_id: "", //活动的id canvasHidden: 0, //分享图片是否已经生成
  27 + is_share: 1, //是否显示画布
  28 + shareImgPath: [], //生成的图片
  29 + screenWidth: "", //用户的屏幕宽度
  30 + gid: "",
  31 + timer: null, //全局的定时器
  32 + user_task_list: null, //会员列表
  33 + taskid: "", //任务id
  34 + usercount: 0, //参与的人数
  35 + dismantle: null, //帮拆记录数据集
  36 + is_shares:111111,//判断是不是要分享的
  37 +
  38 + //*********************************************start钱
  39 + canvasHidden: 0, //分享图片是否已经生成
27 40 is_share: 0, //是否显示画布
28 41 shareImgPath: [], //生成的图片
29 42 screenWidth: "", //用户的屏幕宽度
30 43 gid: "",
31   - timer: null,//全局的定时器
32   - user_task_list:null,//会员列表
33   - taskid:"",//任务id
34   - usercount:0,//参与的人数
  44 + images: ["miniapp/images/friendhelp/help.png", "miniapp/images/friendhelp/background.png", "miniapp/images/friendhelp/no_check.png",
  45 + "miniapp/images/friendhelp/check.png", "miniapp/images/friendhelp/unfinished.png",
  46 + "/public/upload/libao/temp/2019/12-20/51f251f44ea0f67b8efdc5bfa3a434b0.jpg"
  47 + ], //固的分享图片
  48 + dynamic: [], //已助力的微信头像数组
  49 + is_generate: 0, //是否重复点击拆一拆
  50 + already: 0, //已有几人助力
  51 + lack: 0, //还差几人助力
  52 + zltime: "", //助力时间
  53 + //*********************************************end
35 54 },
36 55  
37 56 /**
... ... @@ -43,6 +62,7 @@ Page({
43 62 th.setData({
44 63 help_id: help_id
45 64 });
  65 + //start 钱
46 66 if (options.gid != undefined) {
47 67 th.setData({
48 68 gid: options.gid
... ... @@ -51,81 +71,38 @@ Page({
51 71 th.close();
52 72 th.syinfo();
53 73 // th.imageinfo();
  74 + //end
54 75 },
55   -
56   -
  76 +
  77 +
57 78 //选中任务保存
58   - add_onlicke:function(e){
59   - var th=this;
60   - var taskid=e.target.dataset.taskid;
  79 + add_onlicke: function(e) {
  80 + var th = this;
  81 + var taskid = e.target.dataset.taskid;
61 82 var help_id = th.data.help_id;
62 83 var user_id = getApp().globalData.user_id;
63   - var stoid=os.stoid
64   - getApp().request.json_post("/api/weshop/marketing/help/help/task/insert"
65   - ,{
66   - helpId:help_id,
67   - userId:user_id,
68   - storeId:stoid,
  84 + var stoid = os.stoid
  85 + getApp().request.json_post("/api/weshop/marketing/help/help/task/insert", {
  86 + helpId: help_id,
  87 + userId: user_id,
  88 + storeId: stoid,
69 89 taskId: taskid
70 90 },
71   - function(res) {
72   - if(res.data.code==0){
73   - console.log(res.data.data);
74   - getApp().my_warnning("任务领取成功", 1, th);
75   - }else{
76   - getApp().my_warnning(res.data.msg, 0, th);
77   - }
78   - }
79   -
80   - )
81   -
82   - },
  91 + function(res) {
83 92  
84   - //帮拆记录的
85   - dismantle_record: function(e) {
86   - console.log();
87   - var th = this;
88   - var index =1; //获取当前选择的是任务还是活动说明
89   - var is_task= th.data.is_task; //0任务,1活动说明
90   - console.log(e, "这是标签的", is_task, "这是");
91   -
92   - th.setData({
93   - is_task:1,
94   - switch_head:1
95   - });
96   - rq.get("/api/weshop/marketing/help/help/task/involve/page", {
97   - data: {
98   - userId: user_id,
99   - storeId: os.stoid
100   - },
101   - success: function (res) {}
  93 + if (res.data.code == 0) {
  94 + console.log(res.data.data);
  95 + getApp().my_warnning(res.data.data, 1, th);
  96 + } else {
  97 + getApp().my_warnning(res.data.msg, 0, th);
  98 + }
  99 + }
102 100  
103   - })
  101 + )
104 102  
105   -
106 103 },
107 104  
108 105  
109   - //划动的时候监听
110   - onSli: function(e) {
111   - var th= this;
112   - var ind = e.detail.current;
113   - var aitem = this.data.aitem;
114   -
115   - var task_number = aitem[ind].giftQty - aitem[ind].useGiftQty;
116   - th.setData({
117   - sw_index: ind,
118   - task_number: task_number
119   - })
120   - console.log(th.data.sw_index,"滑动监听", ind);
121   - },
122   - //导航球
123   - close: function() {
124   - var th = this;
125   - var nav_b = th.selectComponent("#nav_b"); //组件的id
126   - nav_b.close_box();
127   - nav_b.set_name("助力", "");
128   - },
129 106  
130 107 /**
131 108 * 生命周期函数--监听页面初次渲染完成
... ... @@ -142,27 +119,27 @@ Page({
142 119 var th = this;
143 120 var help_id = th.data.help_id;
144 121 var user_id = getApp().globalData.user_id;
145   -
  122 +
146 123 /*-----助力活动(判断)-----*/
147 124 rq.get("/api/weshop/marketing/help/act/judge", {
148 125 data: {
149 126 userId: user_id,
150 127 storeId: os.stoid
151 128 },
152   - success: function (res) {
  129 + success: function(res) {
153 130 if (res.data.code == 0) {
154 131  
155 132 var help_data = res.data.data;
156   - console.log( '助力活动(判断)', res.data.data);
  133 + console.log('助力活动(判断)', res.data.data);
157 134 th.setData({
158   - endDate:help_data.endDate,
  135 + endDate: help_data.endDate,
159 136 });
160 137  
161 138 }
162 139 }
163   -
164   -
165   - });
  140 +
  141 +
  142 + });
166 143  
167 144  
168 145 /*-----获取助力活动的任务-----*/
... ... @@ -182,9 +159,9 @@ Page({
182 159 var data_aissa = data.data.pageData;
183 160 //当前时间戳
184 161 var nt = ut.gettimestamp();
185   -
  162 +
186 163 data_aissa.forEach(function(val, ind) {
187   -
  164 +
188 165 //已开始
189 166 if (val.start_time < nt && val.end_time > nt) data_aissa[ind].status = 0;
190 167 //未开始
... ... @@ -192,13 +169,13 @@ Page({
192 169 //已结束
193 170 else if (val.start_time < nt && val.end_time < nt) data_aissa[ind].status = 2;
194 171 });
195   - var task_number=data_aissa[0].giftQty - data_aissa[0].useGiftQty;
  172 + var task_number = data_aissa[0].giftQty - data_aissa[0].useGiftQty;
196 173 var taskid = data_aissa[0].id;
197   -
  174 +
198 175 th.setData({
199 176 aitem: data_aissa,
200 177 task_number: task_number,
201   - taskid:taskid
  178 + taskid: taskid
202 179 });
203 180  
204 181  
... ... @@ -211,19 +188,83 @@ Page({
211 188 // th.shareFrends();
212 189 // }, 1000)
213 190 //任务时间 设置全局定时器
214   - th.data.timer = setInterval(function () {
  191 + th.data.timer = setInterval(function() {
215 192 th.countDown();
216   - },1000);
  193 + }, 1000);
217 194 //会员任务列表
218 195 this.user_task_list();
219   - // 获取会员的参与的任务列表 我的任务
  196 + // 获取会员的参与的任务列表 我的任务
220 197 this.get_user_task_num();
  198 +
  199 + },
  200 +
  201 +
  202 +
  203 +
  204 +
  205 +
  206 + //帮拆记录的
  207 + dismantle_record: function(e) {
  208 + var aitem = this.data.aitem; //任务的数据集
  209 + var sw_index = this.data.sw_index; //轮播的下标
  210 + //任务id
  211 + var taskid = aitem[sw_index].id;
  212 + console.log("任务id", taskid);
  213 + var th = this;
  214 + var index = 1; //获取当前选择的是任务还是活动说明
  215 + var is_task = th.data.is_task; //0任务,1帮拆
  216 + console.log("0任务,1帮拆", is_task, );
  217 + th.setData({
  218 + is_task: 1,
  219 + switch_head: 1
  220 + });
  221 + rq.get("/api/weshop/marketing/help/help/task/involve/page", {
  222 + data: {
  223 + taskId: taskid,
  224 + userId: getApp().globalData.user_id,
  225 + storeId: os.stoid
  226 + },
  227 + success: function(res) {
  228 +
  229 + if (res.data.code == 0) {
  230 + var dismantle = res.data.data.pageData;
  231 + th.setData({
  232 + dismantle: dismantle
  233 + });
  234 + }
  235 + }
  236 +
  237 + })
  238 +
  239 +
  240 + },
  241 +
  242 +
  243 + //划动的时候监听
  244 + onSli: function(e) {
  245 + var th = this;
  246 + var ind = e.detail.current;
  247 + var aitem = this.data.aitem;
  248 + var task_number = aitem[ind].giftQty - aitem[ind].useGiftQty;
  249 + console.log("划动的任务总数", task_number, "任务所有的参数", aitem);
  250 + th.setData({
  251 + sw_index: ind,
  252 + task_number: task_number
  253 + });
  254 + console.log("可以领取的的任务数", aitem[ind].giftQty, '已领取的任务数据', aitem[ind].useGiftQty);
  255 + },
  256 + //导航球
  257 + close: function() {
  258 + var th = this;
  259 + var nav_b = th.selectComponent("#nav_b"); //组件的id
  260 + nav_b.close_box();
  261 + nav_b.set_name("助力", "");
221 262 },
222 263 // 获取会员的参与的任务列表 我的任务
223   - user_task_list:function(e){
224   - var th=this;
225   - // var index = e.target.dataset.index; //获取当前选择的是任务还是活动说明
226   - var index =0;
  264 + user_task_list: function(e) {
  265 + var th = this;
  266 +
  267 + var index = 0;
227 268 var is_task = th.data.is_task; //0任务,1活动说明
228 269 var help_id = th.data.help_id;
229 270 var user_id = getApp().globalData.user_id;
... ... @@ -233,49 +274,84 @@ Page({
233 274 storeId: os.stoid,
234 275 userId: user_id
235 276 },
236   - success: function (su) {
  277 + success: function(su) {
237 278 th.setData({
238 279 is_task: index,
239 280 switch_head: index
240 281 });
241 282 if (su.data.code == 0) {
242   - var user_list=su.data.data.pageData;
243   - console.log("会员列表",user_list);
  283 + var user_list = su.data.data.pageData;
  284 + console.log("会员列表", user_list);
244 285 th.setData({
245 286 user_task_list: user_list
246 287 });
247   - }else{
  288 + } else {
248 289 th.setData({
249   - user_task_list:null
  290 + user_task_list: null
250 291 });
251 292 }
252 293 }
253   - })
  294 + })
254 295 },
255 296 //获取助力活动参与的人数
256   - get_user_task_num(){
257   - var th=this;
258   - var help_id=th.data.help_id;
259   - rq.get("/api/weshop/marketing/help/involve/help/act/people/count", {
260   - data: {
261   - helpId: help_id,
262   - storeId: os.stoid,
263   - },
264   - success: function (su) {
265   - console.log(su.data.code, "获取助力活动参与的人数",su.data)
266   - if (su.data.code == 0) {
267   - var usercount=su.data.data.countAll;
268   -
269   - th.setData({ usercount: usercount});
270   - } else {
271   -
272   - }
273   - }
274   - })
275   -
276   - },
  297 + get_user_task_num() {
  298 + var th = this;
  299 + var help_id = th.data.help_id;
  300 + rq.get("/api/weshop/marketing/help/involve/help/act/people/count", {
  301 + data: {
  302 + helpId: help_id,
  303 + storeId: os.stoid,
  304 + },
  305 + success: function(su) {
  306 + console.log(su.data.code, "获取助力活动参与的人数", su.data)
  307 + if (su.data.code == 0) {
  308 + var usercount = su.data.data.countAll;
  309 +
  310 + th.setData({
  311 + usercount: usercount
  312 + });
  313 + } else {
  314 +
  315 + }
  316 + }
  317 + })
  318 +
  319 + },
  320 + //轮播卡死的重置
  321 + changeGoodsSwip: function(detail) {
  322 + if (detail.detail.source == "touch") {
  323 + //当页面卡死的时候,current的值会变成0
  324 + if (detail.detail.current == 0) {
  325 + //有时候这算是正常情况,所以暂定连续出现3次就是卡了
  326 + let swiperError = this.data.swiperError
  327 + swiperError += 1
  328 + this.setData({
  329 + swiperError: swiperError
  330 + })
  331 + if (swiperError >= 3) { //在开关被触发3次以上
  332 + console.error(this.data.swiperError)
  333 + this.setData({
  334 + goodsIndex: this.data.preIndex
  335 + }); //,重置current为正确索引
  336 + this.setData({
  337 + swiperError: 0
  338 + })
  339 + }
  340 + } else { //正常轮播时,记录正确页码索引
  341 + this.setData({
  342 + preIndex: detail.detail.current
  343 + });
  344 + //将开关重置为0
  345 + this.setData({
  346 + swiperError: 0
  347 + })
  348 + }
  349 + }
  350 + },
  351 +
277 352 // 轮播图点击左边
278   - click_pre: function () {
  353 + click_pre: function() {
  354 + console.log("轮播图点击左边");
279 355 var index = this.data.sw_index;
280 356 index--;
281 357 if (index < 0) return;
... ... @@ -288,14 +364,17 @@ Page({
288 364  
289 365 },
290 366 //轮播图点击右边
291   - click_next: function () {
  367 + click_next: function() {
  368 +
292 369 var index = this.data.sw_index;
293 370 index++;
  371 + console.log("轮播图点击右边");
294 372 if (index >= this.data.aitem.length) return;
295 373 var aitem = this.data.aitem;
296 374 var task_number = aitem[index].giftQty - aitem[index].useGiftQty;
297 375 this.setData({
298   - sw_index: index, task_number: task_number
  376 + sw_index: index,
  377 + task_number: task_number
299 378 })
300 379  
301 380 },
... ... @@ -437,13 +516,13 @@ Page({
437 516 if (i == 0) {
438 517 ctx.save();
439 518 ctx.beginPath(); //开始绘制
440   - ctx.arc(left + imagesize / 2, 505 * unit, imagesize/2, 0, 2 * Math.PI);
  519 + ctx.arc(left + imagesize / 2, 505 * unit, imagesize / 2, 0, 2 * Math.PI);
441 520 ctx.setLineWidth(4 * unit);
442 521 ctx.setStrokeStyle('red');
443 522 ctx.setFillStyle("white");
444 523 ctx.fill();
445 524 ctx.clip();
446   - ctx.drawImage(images[6], left, 505 * unit - imagesize/2, imagesize, imagesize);
  525 + ctx.drawImage(images[6], left, 505 * unit - imagesize / 2, imagesize, imagesize);
447 526 ctx.restore(); //恢复之前保存的绘图上下文 恢复之前保存的绘图上下午即状态 还可以继续绘制
448 527 } else {
449 528 // 助力人的头像
... ... @@ -533,103 +612,457 @@ Page({
533 612 }
534 613 })
535 614 },
536   - //分享图
537   - // imageinfo: function() {
538   - // var th = this;
539   - // var images = th.data.images;
540   - // var iurl = th.data.iurl;
541   - // wx.getImageInfo({
542   - // src: iurl + images[0],
543   - // success: function(res) {
544   - // console.log(res + i);
545   - // //res.path是网络图片的本地地址
546   - // images[0] = res.path;
547   - // },
548   - // fail: function(res) {
549   - // console.log(res.toString() + "" + i);
550   - // }
551   - // });
552   - // wx.getImageInfo({
553   - // src: iurl + images[1],
554   - // success: function(res) {
555   - // console.log(res + i);
556   - // //res.path是网络图片的本地地址
557   - // images[1] = res.path;
558   - // },
559   - // fail: function(res) {
560   - // console.log(res.toString() + "" + i);
561   - // }
562   - // });
563   - // wx.getImageInfo({
564   - // src: iurl + images[2],
565   - // success: function(res) {
566   - // console.log(res + i);
567   - // //res.path是网络图片的本地地址
568   - // images[2] = res.path;
569   - // },
570   - // fail: function(res) {
571   - // console.log(res.toString() + "" + i);
572   - // }
573   - // });
574   - // wx.getImageInfo({
575   - // src: iurl + images[3],
576   - // success: function(res) {
577   - // console.log(res + i);
578   - // //res.path是网络图片的本地地址
579   - // images[3] = res.path;
580   - // },
581   - // fail: function(res) {
582   - // console.log(res.toString() + "" + i);
583   - // }
584   - // });
585   - // wx.getImageInfo({
586   - // src: iurl + images[4],
587   - // success: function(res) {
588   - // console.log(res + i);
589   - // //res.path是网络图片的本地地址
590   - // images[4] = res.path;
591   - // },
592   - // fail: function(res) {
593   - // console.log(res.toString() + "" + i);
594   - // }
595   - // });
596   - // wx.getImageInfo({
597   - // src: iurl + images[5],
598   - // success: function(res) {
599   - // console.log(res + i);
600   - // //res.path是网络图片的本地地址
601   - // images[5] = res.path;
602   - // },
603   - // fail: function(res) {
604   - // console.log(res.toString() + "" + i);
605   - // }
606   - // });
607   - // wx.getImageInfo({
608   - // src: iurl + images[6],
609   - // success: function(res) {
610   - // console.log(res + i);
611   - // //res.path是网络图片的本地地址
612   - // images[6] = res.path;
613   - // },
614   - // fail: function(res) {
615   - // console.log(res.toString() + "" + i);
616   - // }
617   - // });
618   -
619   - // wx.getImageInfo({
620   - // src: iurl + images[7],
621   - // success: function(res) {
622   - // console.log(res + i);
623   - // //res.path是网络图片的本地地址
624   - // images[7] = res.path;
625   - // },
626   - // fail: function(res) {
627   - // console.log(res.toString() + "" + i);
628   - // }
629   - // })
630   - // th.setData({
631   - // images: images
632   - // })
633   -
634   - // }
  615 + //钱 分享图
  616 + imageinfo: function() {
  617 + var th = this;
  618 + var images = th.data.images;
  619 + var iurl = th.data.iurl;
  620 + wx.getImageInfo({
  621 + src: iurl + images[0],
  622 + success: function(res) {
  623 + console.log(res + i);
  624 + //res.path是网络图片的本地地址
  625 + images[0] = res.path;
  626 + },
  627 + fail: function(res) {
  628 + console.log(res.toString() + "" + i);
  629 + }
  630 + });
  631 + wx.getImageInfo({
  632 + src: iurl + images[1],
  633 + success: function(res) {
  634 + console.log(res + i);
  635 + //res.path是网络图片的本地地址
  636 + images[1] = res.path;
  637 + },
  638 + fail: function(res) {
  639 + console.log(res.toString() + "" + i);
  640 + }
  641 + });
  642 + wx.getImageInfo({
  643 + src: iurl + images[2],
  644 + success: function(res) {
  645 + console.log(res + i);
  646 + //res.path是网络图片的本地地址
  647 + images[2] = res.path;
  648 + },
  649 + fail: function(res) {
  650 + console.log(res.toString() + "" + i);
  651 + }
  652 + });
  653 + wx.getImageInfo({
  654 + src: iurl + images[3],
  655 + success: function(res) {
  656 + console.log(res + i);
  657 + //res.path是网络图片的本地地址
  658 + images[3] = res.path;
  659 + },
  660 + fail: function(res) {
  661 + console.log(res.toString() + "" + i);
  662 + }
  663 + });
  664 + wx.getImageInfo({
  665 + src: iurl + images[4],
  666 + success: function(res) {
  667 + console.log(res + i);
  668 + //res.path是网络图片的本地地址
  669 + images[4] = res.path;
  670 + },
  671 + fail: function(res) {
  672 + console.log(res.toString() + "" + i);
  673 + }
  674 + });
  675 + wx.getImageInfo({
  676 + src: iurl + images[5],
  677 + success: function(res) {
  678 + console.log(res + i);
  679 + //res.path是网络图片的本地地址
  680 + images[5] = res.path;
  681 + },
  682 + fail: function(res) {
  683 + console.log(res.toString() + "" + i);
  684 + }
  685 + });
  686 + wx.getImageInfo({
  687 + src: iurl + images[6],
  688 + success: function(res) {
  689 + console.log(res + i);
  690 + //res.path是网络图片的本地地址
  691 + images[6] = res.path;
  692 + },
  693 + fail: function(res) {
  694 + console.log(res.toString() + "" + i);
  695 + }
  696 + });
  697 +
  698 + wx.getImageInfo({
  699 + src: iurl + images[7],
  700 + success: function(res) {
  701 + console.log(res + i);
  702 + //res.path是网络图片的本地地址
  703 + images[7] = res.path;
  704 + },
  705 + fail: function(res) {
  706 + console.log(res.toString() + "" + i);
  707 + }
  708 + })
  709 + th.setData({
  710 + images: images
  711 + })
  712 +
  713 + },
  714 + //生成分享图,用于分享给好友帮拆
  715 + demolition: function() {
  716 + var th = this;
  717 +
  718 +
  719 + },
  720 + //************************ */
  721 + shareFrends: function(e) {
  722 + var th = this;
  723 + var is_generate = th.data.is_generate; //是否重复提交拆一拆
  724 + if (is_generate == 0) {
  725 + th.setData({
  726 + is_generate: 1
  727 + })
  728 + var scene = th.data.gid;
  729 + ///二微码
  730 + // var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" +
  731 + // a.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo";
  732 + var iurl = th.data.iurl; //图片地址前缀
  733 + const ctx = wx.createCanvasContext('share_id'); //绘图上下文
  734 + var unit = th.data.screenWidth / 750 * 1.35;
  735 + var numsize = 20 * unit; //几人助力字体大小
  736 + var size = 15 * unit;
  737 + var num = th.data.already; //已有几位好友助力
  738 + var q_num = th.data.lack; //还差几位好友助力
  739 + var already = num.toString().length + 1; //已有几位好友助力
  740 + var lack = q_num.toString().length + 1; //还差几位好友助力
  741 + var imagesize = 40 * unit; //助力人的图片大小
  742 + var left = 74 * unit; //助力人头像跟左边的距离
  743 + var spacing = 12 * unit; //助力人图片间距
  744 + var images = th.data.images;
  745 + ctx.drawImage(images[0], 0, 0, 445 * unit, 700 * unit); //分享的背景图片
  746 + ctx.drawImage(images[1], 37 * unit, 185 * unit, 370 * unit, 377 * unit); //分享的背景图片
  747 + ctx.drawImage(images[5], 90 * unit, 231 * unit, 266 * unit, 160 * unit); //分享的背景图片
  748 + ctx.setFillStyle("rgb(221,153,116)");
  749 + ctx.setFontSize(size)
  750 + ctx.fillText("已有", 77 * unit, 430 * unit);
  751 + ctx.setFillStyle("#FF4746");
  752 + ctx.setFontSize(numsize)
  753 + ctx.fillText(num + "位", 108 * unit, 430 * unit);
  754 + ctx.setFillStyle("rgb(221,153,116)");
  755 + ctx.setFontSize(size)
  756 + ctx.fillText("好友助力,还差", 116 * unit + already * numsize * unit, 430 * unit);
  757 + ctx.setFillStyle("#FF4746");
  758 + ctx.setFontSize(numsize);
  759 + ctx.fillText(q_num + "位", 223 * unit + already * numsize * unit, 430 * unit);
  760 + ctx.setFillStyle("rgb(221,153,116)");
  761 + ctx.setFontSize(size);
  762 + ctx.fillText("达成助力", 230 * unit + lack * numsize * unit + already * numsize * unit, 430 * unit);
  763 + var c = q_num / num;
  764 + ctx.drawImage(images[2], 65 * unit, 445 * unit, 320 * unit, 12 * unit);
  765 + ctx.drawImage(images[3], 65 * unit, 445 * unit, 320 * unit * c, 12 * unit);
  766 + // var dynamic = th.data.dynamic; //助力的微信头像
  767 + // console.log(dynamic[0].headPic + "动态图片显示");
  768 + for (var i = 0; i < 6; i++) {
  769 + if (i < 0) {
  770 + // ctx.beginPath();
  771 + // ctx.arc(left + imagesize / 2, 505 * unit, imagesize / 2, 0, 2 * Math.PI);
  772 + // ctx.setLineWidth(1);
  773 + // ctx.setStrokeStyle('red');
  774 + ctx.save();
  775 + ctx.beginPath(); //开始绘制
  776 + ctx.arc(left + imagesize / 2, 505 * unit, imagesize / 2, 0, 2 * Math.PI);
  777 + ctx.setLineWidth(4 * unit);
  778 + ctx.setStrokeStyle('red');
  779 + ctx.setFillStyle("white");
  780 + ctx.fill();
  781 + ctx.clip();
  782 + ctx.drawImage(dynamic[i].headPic, left, 505 * unit - imagesize / 2, imagesize, imagesize);
  783 + ctx.restore(); //恢复之前保存的绘图上下文 恢复之前保存的绘图上下午即状态 还可以继续绘制
  784 + } else {
  785 + // 助力人的头像
  786 + ctx.drawImage(images[4], left, 505 * unit - imagesize / 2, imagesize, imagesize); //分享的背景图片
  787 +
  788 + }
  789 + left += imagesize + spacing;
  790 + }
  791 + ctx.setFillStyle("rgb(255,255,255)");
  792 + ctx.setFontSize(size);
  793 + ctx.fillText("优惠乐翻天,精彩就在你身边!", 37 * unit, 595 * unit);
  794 + ctx.setFillStyle("rgb(255,255,255)");
  795 + ctx.setFontSize(size);
  796 + ctx.fillText("2019.06.26 - 2019.07.02!", 37 * unit, 620 * unit);
  797 + ctx.setFillStyle("rgb(255,255,255)");
  798 + ctx.setFontSize(size);
  799 + ctx.fillText("长按识别二维码,可帮我助力!", 37 * unit, 660 * unit);
  800 + ctx.drawImage(images[5], 325 * unit, 585 * unit, 77 * unit, 77 * unit); //分享的背景图片
  801 + ctx.save();
  802 + //读取文件成功则OK--
  803 + // wx.getImageInfo({
  804 + // src: path3,
  805 + // success: function (res) {
  806 + //把画板内容绘制成图片,并回调 画板图片路径
  807 + ctx.draw(false, function() {
  808 + setTimeout(function() {
  809 + wx.canvasToTempFilePath({
  810 + x: 0,
  811 + y: 0,
  812 + width: 300,
  813 + height: 500,
  814 + destWidth: 400 * 2,
  815 + destHeight: 720 * 2,
  816 + canvasId: 'share_id',
  817 + success: function(res) {
  818 + wx.hideLoading();
  819 + var shareImgPath = th.data.shareImgPath;
  820 + shareImgPath[0] = res.tempFilePath;
  821 +
  822 + th.setData({
  823 + shareImgPath: shareImgPath,
  824 + canvasHidden: 1,
  825 + is_share: 1,
  826 + is_generate: 0,
  827 + canvasHidden: 1
  828 + })
  829 + if (!res.tempFilePath) {
  830 + wx.showModal({
  831 + title: '提示',
  832 + content: '图片绘制中,请稍后重试',
  833 + showCancel: false
  834 + })
  835 + return false;
  836 + }
  837 +
  838 + },
  839 + fail(r) {
  840 +
  841 + }
  842 + }, 500)
  843 + })
  844 + })
  845 + }
  846 + },
  847 + preview: function() {
  848 + var th = this;
  849 + var shareImgPath = th.data.shareImgPath;
  850 + wx.previewImage({
  851 + url: shareImgPath[0],
  852 + urls: shareImgPath
  853 + })
  854 + th.setData({
  855 + is_share: 0
  856 + })
  857 + },
  858 +
  859 + //关闭分享显示
  860 + close_share: function() {
  861 + var th = this;
  862 + wx.hideLoading();
  863 + th.setData({
  864 + is_share: 0
  865 + })
  866 + },
  867 + syinfo: function() {
  868 + var th = this;
  869 + //获取用户设备信息,屏幕宽度
  870 + wx.getSystemInfo({
  871 + success: res => {
  872 + th.setData({
  873 + screenWidth: res.screenWidth
  874 + })
  875 + }
  876 + })
  877 + },
  878 + //把固定的图片加载到本地
  879 + imageinfo: function() {
  880 + var th = this;
  881 + var images = th.data.images;
  882 + var iurl = th.data.iurl;
  883 + wx.getImageInfo({
  884 + src: iurl + images[0],
  885 + success: function(res) {
  886 + //res.path是网络图片的本地地址
  887 + images[0] = res.path;
  888 + },
  889 + fail: function(res) {
  890 +
  891 + }
  892 + });
  893 + wx.getImageInfo({
  894 + src: iurl + images[1],
  895 + success: function(res) {
  896 + //res.path是网络图片的本地地址
  897 + images[1] = res.path;
  898 + },
  899 + fail: function(res) {
  900 +
  901 + }
  902 + });
  903 + wx.getImageInfo({
  904 + src: iurl + images[2],
  905 + success: function(res) {
  906 + //res.path是网络图片的本地地址
  907 + images[2] = res.path;
  908 + },
  909 + fail: function(res) {
  910 +
  911 + }
  912 + });
  913 + wx.getImageInfo({
  914 + src: iurl + images[3],
  915 + success: function(res) {
  916 +
  917 + //res.path是网络图片的本地地址
  918 + images[3] = res.path;
  919 + },
  920 + fail: function(res) {
  921 +
  922 + }
  923 + });
  924 + wx.getImageInfo({
  925 + src: iurl + images[4],
  926 + success: function(res) {
  927 +
  928 + //res.path是网络图片的本地地址
  929 + images[4] = res.path;
  930 + },
  931 + fail: function(res) {
  932 +
  933 + }
  934 + });
  935 + wx.getImageInfo({
  936 + src: iurl + images[5],
  937 + success: function(res) {
  938 +
  939 + //res.path是网络图片的本地地址
  940 + images[5] = res.path;
  941 + },
  942 + fail: function(res) {
  943 +
  944 + }
  945 + });
  946 + th.setData({
  947 + images: images
  948 + })
  949 +
  950 + },
  951 +//好友猜一猜
  952 + save_share: function (e) {
  953 + var aitem = this.data.aitem; //任务的数据集
  954 + var sw_index = this.data.sw_index; //轮播的下标
  955 + //任务id
  956 + var taskid = aitem[sw_index].id;
  957 + console.log("好友猜一猜的任务id", taskid);
  958 + var th = this;
  959 +
  960 + var url = "/api/weshop/marketing/help/help/task/involve/page";
  961 + getApp().request.promiseGet(url, {
  962 + data: {
  963 + storeId: 1,
  964 + taskId: taskid,
  965 + userId: 1433390
  966 + }
  967 + }).then(res => {
  968 + if (res.data.code == 0) {
  969 + var data = res.data.data.pageData; //帮拆数组
  970 + if (data.length > 0) {
  971 + // th.setData({
  972 + // dynamic: data
  973 + // })
  974 + // th.info_head();
  975 + th.imageinfo();
  976 + setTimeout(function () {
  977 + th.shareFrends();
  978 + }, 500)
  979 + }
  980 + } else {
  981 + wx.hideLoading();
  982 + getApp().my_warnning(res.data.msg, 0, th);
  983 + }
  984 + })
  985 + },
  986 + //把已助力好友头像下载到本地
  987 + info_head: function (e) {
  988 + var th = this;
  989 + var images = th.data.dynamic;
  990 + if (images[0] != null && images[0] != "" && images[0] != undefined) {
  991 + console.log(images[0].headPic + "就将计就计");
  992 + wx.getImageInfo({
  993 + src: images[0].headPic,
  994 + success: function (res) {
  995 + //res.path是网络图片的本地地址
  996 + images[0].headPic = res.path;
  997 + },
  998 + fail: function (res) {
  999 +
  1000 + }
  1001 + });
  1002 + }
  1003 + if (images[1] != null && images[1] != "" && images[1] != undefined) {
  1004 + wx.getImageInfo({
  1005 + src: images[1].headPic,
  1006 + success: function (res) {
  1007 + //res.path是网络图片的本地地址
  1008 + images[1].headPic = res.path;
  1009 + },
  1010 + fail: function (res) {
  1011 +
  1012 + }
  1013 + });
  1014 + }
  1015 + if (images[2] != null && images[2] != "" && images[2] != undefined) {
  1016 + wx.getImageInfo({
  1017 + src: images[2].headPic,
  1018 + success: function (res) {
  1019 + //res.path是网络图片的本地地址
  1020 + images[2].headPic = res.path;
  1021 + },
  1022 + fail: function (res) {
  1023 +
  1024 + }
  1025 + });
  1026 + }
  1027 + if (images[3] != null && images[3] != "" && images[3] != undefined) {
  1028 + wx.getImageInfo({
  1029 + src: images[3].headPic,
  1030 + success: function (res) {
  1031 + //res.path是网络图片的本地地址
  1032 + images[3].headPic = res.path;
  1033 + },
  1034 + fail: function (res) {
  1035 +
  1036 + }
  1037 + });
  1038 + }
  1039 + // if (images[4] != null && images[4] != "" && images[4] != undefined) {
  1040 + // wx.getImageInfo({
  1041 + // src: images[4].headPic,
  1042 + // success: function(res) {
  1043 + // //res.path是网络图片的本地地址
  1044 + // images[4].headPic = res.path;
  1045 + // },
  1046 + // fail: function(res) {
  1047 +
  1048 + // }
  1049 + // });
  1050 + // }
  1051 + // if (images[5] != null && images[5] != "" && images[5] != undefined) {
  1052 + // wx.getImageInfo({
  1053 + // src: images[5].headPic,
  1054 + // success: function (res) {
  1055 + // //res.path是网络图片的本地地址
  1056 + // images[5].headPic = res.path;
  1057 + // },
  1058 + // fail: function (res) {
  1059 +
  1060 + // }
  1061 + // });
  1062 + //}
  1063 + th.setData({
  1064 + dynamic: images
  1065 + })
  1066 + },
  1067 +
635 1068 })
636 1069 \ No newline at end of file
... ...
pages/user/assistance/task_assistance.wxml
  1 +<wxs module="filter" src="../../../utils/filter.wxs"></wxs>
1 2 <view class="top-back" style="background-image: url({{iurl}}/miniapp/images/friendhelp/lumi.png)">
2 3 <!-- 助力活动头部 -->
3 4 <view class="top-frame">
4 5 <view class="top-title white fs36 t-c">
5   - {{sw_index}}
  6 +
6 7 {{aitem[sw_index].helpTaskName}}
7 8 </view>
8 9 <view class="activity-data t-c fs28 white">
... ... @@ -14,7 +15,7 @@
14 15 <view bindtap="click_pre">
15 16 <view class="bg_left xc-left bcolor"></view>
16 17 </view>
17   - <swiper current="{{sw_index}}" style='width:82.7%; height:100%' bindchange='onSli' indicator-dots="{{false}}" autoplay="{{false}}">
  18 + <swiper bindanimationfinish="changeGoodsSwip" current="{{sw_index}}" style='width:82.7%; height:100%' bindchange='onSli' indicator-dots="{{false}}" autoplay="{{false}}">
18 19 <swiper-item wx:for="{{aitem}}" wx:for-item="aitem" wx:for-index="pidx">
19 20 <image class="xc-center-img " src="{{iurl+aitem.giftBagUrl}}"></image>
20 21 </swiper-item>
... ... @@ -24,23 +25,27 @@
24 25 <view class="bg_right xc-right bcolor mt"></view>
25 26 </view>
26 27 </view>
27   - <view class="plan-frame">
  28 + <view class="plan-frame flex ai-center">
28 29 <view class="plan_num rel">
29 30 <view class="is_plam abs"></view>
30 31 </view>
31   - <text class="white fs32">/</text>
  32 + <text class="white fs24">/</text>
32 33  
33 34 </view>
34 35 <view class="task-number fs28 white t-c ">
35 36 今天剩余可领{{task_number}}个任务
36 37 </view>
37 38  
38   - <view class="task_clike fs40 t-c flex-center"data-taskid="{{taskid}}" bindtap="add_onlicke">
  39 + <view wx:if="{{is_shares==null}}" class="task_clike fs40 t-c flex-center"data-taskid="{{taskid}}" bindtap="add_onlicke">
39 40 就选它了
40 41 </view>
  42 + <view wx:if="{{is_shares!=null}}" class="task_clike fs40 t-c flex-center"data-taskid="{{taskid}}" bindtap="save_share">
  43 + 好友拆一拆
  44 + </view>
  45 +
41 46 </view>
42 47 <!-- 底部列表 -->
43   -<view>
  48 +<view style="margin-top:50rpx">
44 49 <!-- 标题 -->
45 50  
46 51 <view class="flex-vertical-between fs28 padding head">
... ... @@ -57,7 +62,7 @@
57 62 <view class="white">
58 63  
59 64 <view class="items" wx:if="{{is_task==0}}">
60   -
  65 +
61 66 <view class="item fs26 flex-vertical-between padding" wx:for="{{user_task_list}}" >
62 67 <view class="flex-center width">
63 68 <view class="ellipsis-1">{{item.helpTaskName}}
... ... @@ -77,12 +82,12 @@
77 82  
78 83  
79 84 <view class="items" wx:if="{{is_task==1}}">
80   - <view class="item fs26 flex flex-vertical-between padding" wx:for="{{}}">
  85 + <view class="item fs26 flex flex-vertical-between padding" wx:for="{{dismantle}}">
81 86 <view class="flex white" style="justify-content: space-around; width: 90%;margin:auto">
82   - <image class="circle user_img" src="https://mshopimg.yolipai.net/public/upload/qyimg/temp/2019/08-14/0697f7277936a3b116a6ebc4f8f5e39a.png"></image>
83   - <view class="ellipsis-1">豪华任务一
  87 + <image class="circle user_img" src="{{iurl+itme.headPic}}"></image>
  88 + <view class="ellipsis-1">{{itme.nickName}}
84 89 </view>
85   - <view class="ellipsis-1">2019-05-12
  90 + <view class="ellipsis-1">{{filter.format_time(itme.beginDate)}}
86 91 </view>
87 92 </view>
88 93  
... ... @@ -111,7 +116,7 @@
111 116 </view>
112 117 <view wx:if="{{is_share}}">
113 118 <!-- 蒙尘 -->
114   - <view wx:if="{{is_share}}" class="dust">
  119 + <view class="dust">
115 120 </view>
116 121 <!-- 画布 -->
117 122 <view class="canvas" style="width:100%;">
... ... @@ -123,6 +128,22 @@
123 128 </view>
124 129 </view>
125 130 </view>
  131 +
  132 +<!--********** 钱巧玲 -->
  133 +<view>
  134 + <!-- 蒙尘 -->
  135 + <view class="dust">
  136 + </view>
  137 + <!-- 画布 -->
  138 + <view class="canvas" style="width:100%;">
  139 + <view class="flex-center">
  140 + <canvas wx:if="{{is_share}}" canvas-id="share_id" style="width:600rpx;height:1000rpx;" bindtap="preview"></canvas>
  141 + </view>
  142 + <view wx:if="{{is_share}}" class="closes flex-center">
  143 + <image class="close" src="{{iurl}}/miniapp/images/plus/Close.png" bindtap="close_share"></image>
  144 + </view>
  145 + </view>
  146 +</view>
126 147 <!-- 引入提示组件 -->
127 148 <warn id="warn"></warn>
128 149 <!-- 制作一个圆球导航 -->
... ...
pages/user/assistance/task_assistance.wxss
... ... @@ -36,12 +36,12 @@ page{
36 36 .task_clike{
37 37 margin: auto;
38 38 width: 60%;
39   - height: 80rpx;
  39 + height: 65rpx;
40 40 border-radius: 50rpx;
41 41 margin-top: 20rpx;
42 42 background: #fbda0e;
43 43 color:#d01119;
44   - line-height: 80rpx;
  44 + line-height: 65rpx;
45 45 letter-spacing: 5rpx;
46 46 box-shadow: 0rpx 7rpx 0rpx 0rpx rgb(245, 119, 6);
47 47 }
... ... @@ -155,18 +155,42 @@ border-color: #fff;
155 155 height: 70rpx;
156 156 }
157 157 .plan-frame{
158   - width: 90%;
  158 + width: 86%;
159 159 margin: auto;
  160 + margin-top: 50rpx;
160 161  
161 162 }
162 163 .plan-frame .plan_num{
163 164 width: 90%;
164 165 background: #ffe7ab;
165 166 border-radius: 20rpx;
166   - height: 32rpx;
  167 + height: 22rpx;
167 168 }
168 169 .is_plam{
169 170 height: 100%;
170 171 top: 0rpx;
171 172 left: 0rpx;
  173 +}
  174 +.dust {
  175 + position: fixed;
  176 + width: 100%;
  177 + height: 100%;
  178 + background-color: red;
  179 + z-index: 10;
  180 +}
  181 +
  182 +.closes {
  183 + margin-top: 20rpx;
  184 +}
  185 +
  186 +.canvas {
  187 + position: fixed;
  188 + z-index: 11;
  189 + width: 100%;
  190 + top:20rpx;
  191 +}
  192 +
  193 +.close {
  194 + width: 70rpx;
  195 + height: 70rpx;
172 196 }
173 197 \ No newline at end of file
... ...