Commit dd03633d26851aa69e4c273d26da3f9577c988e2
1 parent
a95b4987
企业认证基本判断
Showing
1 changed file
with
0 additions
and
990 deletions
pages/user/assistance/task_assistance.js
1 | -var auth = require("../../../utils/auth.js"), | |
2 | - rq = require("../../../utils/request.js"); | |
3 | -var e = getApp(), | |
4 | - app = e, | |
5 | - i = require("../../../utils/util.js"), | |
6 | - ut = i, | |
7 | - s = e.globalData.setting, | |
8 | - os = s, | |
9 | - app_d = e.globalData; | |
10 | -var regeneratorRuntime = require('../../../utils/runtime.js'); | |
11 | -Page({ | |
12 | - /** | |
13 | - * 页面的初始数据 | |
14 | - */ | |
15 | - data: { | |
16 | - swpie_img: s.imghost +"/miniapp/images/user_index_powder.jpg", | |
17 | - defaultAvatar: s.imghost + "/miniapp/images/no-head.jpg",//助力头像的默认图 | |
18 | - sw_index: 0, //轮播的下标控制 | |
19 | - url: s.url, //接口网址 | |
20 | - iurl: s.imghost, | |
21 | - endDate: "", //活动结束时间 | |
22 | - activity_data: "25:20:59", //活动剩余时间 | |
23 | - task_number: 0, //任务数 | |
24 | - is_task: 0, //历史记录与任务 | |
25 | - aitem: "", //活动的轮播图数据 | |
26 | - switch_head: 0, //0:我的任务,1:记录 | |
27 | - help_id: "", //活动的id canvasHidden: 0, //分享图片是否已经生成 | |
28 | - gid: "", | |
29 | - timer: null, //全局的定时器 | |
30 | - user_task_list: [], //会员列表 | |
31 | - taskid: "", //任务id | |
32 | - usercount: 0, //参与的人数 | |
33 | - dismantle:[], //帮拆记录数据集 | |
34 | - is_user_task: null, //判断是不是领取的任务 | |
35 | - zzjx_id: "", //真正进行的任务id | |
36 | - is_show: 0, //任务的加载更多 | |
37 | - is_bc_show: 0, //帮拆的加载更多 | |
38 | - bc_page: 1, //帮拆的页码 | |
39 | - rw_page: 1, //任务的页码 | |
40 | - block: 0, //阻断助力的我的任务在当前位置多次点击 | |
41 | - is_dismantle:0, //阻断助力的帮拆记录在当前位置多次点击 | |
42 | - is_clik:0,//点击的时候控制划动 | |
43 | - is_dis_list:0,//多个数据的时候 | |
44 | - is_user_list:0,//我的任务点击加载更多的后 | |
45 | - | |
46 | - //*********************************************start钱 | |
47 | - canvasHidden: 0, //分享图片是否已经生成 | |
48 | - is_share: 0, //是否显示画布 | |
49 | - shareImgPath: [], //生成的图片 | |
50 | - screenWidth: "", //用户的屏幕宽度 | |
51 | - gid: "", | |
52 | - images: ["miniapp/images/friendhelp/help.png", "miniapp/images/friendhelp/background.png", "miniapp/images/friendhelp/no_check.png", | |
53 | - "miniapp/images/friendhelp/check.png", "miniapp/images/friendhelp/unfinished.png","miniapp/images/xc_ellipsis.png" | |
54 | - ], //固的分享图片 | |
55 | - | |
56 | - dynamic: null, //已助力的微信头像数组 | |
57 | - head_pic_arr: [], //助力的头像 | |
58 | - share_lb_img: "", //分享的礼包图片 | |
59 | - | |
60 | - is_generate: 0, //是否重复点击拆一拆 | |
61 | - already: 0, //已有几人助力 | |
62 | - lack: 0, //还差几人助力 | |
63 | - zltime: "", //助力时间 | |
64 | - djs: "", //定时器的显示 | |
65 | - //*********************************************end | |
66 | - }, | |
67 | - | |
68 | - /** | |
69 | - * 生命周期函数--监听页面加载 | |
70 | - */ | |
71 | - onLoad: function(options) { | |
72 | - var th = this; | |
73 | - var help_id = options.help_id; | |
74 | - var nav_b = th.selectComponent("#nav_b"); //组件的id | |
75 | - nav_b.set_name("助力", "/pages/user/assistance/assistance"); | |
76 | - th.setData({ | |
77 | - help_id: help_id | |
78 | - }); | |
79 | - //start 钱 | |
80 | - if (options.gid != undefined) { | |
81 | - th.setData({ | |
82 | - gid: options.gid | |
83 | - }) | |
84 | - } | |
85 | - th.close(); | |
86 | - th.syinfo(); | |
87 | - th.imageinfo(); | |
88 | - | |
89 | - }, | |
90 | - | |
91 | - | |
92 | - //选中任务保存 | |
93 | - add_onlicke: function(e) { | |
94 | - var th = this; | |
95 | - var taskid = e.target.dataset.taskid; | |
96 | - var help_id = th.data.help_id; | |
97 | - var user_id = getApp().globalData.user_id; | |
98 | - var stoid = os.stoid | |
99 | - getApp().request.json_post("/api/weshop/marketing/help/help/task/insert", { | |
100 | - helpId: help_id, | |
101 | - userId: user_id, | |
102 | - storeId: stoid, | |
103 | - taskId: taskid | |
104 | - }, | |
105 | - function(res) { | |
106 | - if (res.data.code == 0) { | |
107 | - getApp().my_warnning(res.data.data, 1, th); | |
108 | - //判断是不是领取的任务 | |
109 | - th.get_user_task(); | |
110 | - //会员任务列表 | |
111 | - th.user_task_list(); | |
112 | - } else { | |
113 | - getApp().my_warnning(res.data.msg, 0, th); | |
114 | - } | |
115 | - } | |
116 | - | |
117 | - ) | |
118 | - | |
119 | - }, | |
120 | - | |
121 | - | |
122 | - | |
123 | - /** | |
124 | - * 生命周期函数--监听页面初次渲染完成 | |
125 | - */ | |
126 | - onReady: function() { | |
127 | - | |
128 | - }, | |
129 | - | |
130 | - /** | |
131 | - * 生命周期函数--监听页面显示 | |
132 | - */ | |
133 | - onShow: function() { | |
134 | - this.data.is_timer = 1; | |
135 | - var th = this; | |
136 | - var help_id = th.data.help_id; | |
137 | - var user_id = getApp().globalData.user_id; | |
138 | - | |
139 | - /*-----助力活动(判断)-----*/ | |
140 | - rq.get("/api/weshop/marketing/help/act/judge", { | |
141 | - data: { | |
142 | - userId: user_id, | |
143 | - storeId: os.stoid | |
144 | - }, | |
145 | - success: function(res) { | |
146 | - if (res.data.code == 0) { | |
147 | - var help_data = res.data.data; | |
148 | - th.setData({ | |
149 | - endDate: help_data.endDate, | |
150 | - }); | |
151 | - | |
152 | - //任务时间 设置全局定时器 | |
153 | - th.setData({ | |
154 | - timer: setInterval(function() { | |
155 | - th.countDown(); | |
156 | - }, 1000) | |
157 | - }) | |
158 | - | |
159 | - | |
160 | - } | |
161 | - } | |
162 | - }); | |
163 | - | |
164 | - | |
165 | - /*-----获取助力活动的任务-----*/ | |
166 | - rq.get("/api/weshop/marketing/help/help/task/page", { | |
167 | - data: { | |
168 | - helpId: help_id, | |
169 | - storeId: os.stoid | |
170 | - }, | |
171 | - success: function(su) { | |
172 | - var data = su.data; | |
173 | - if (data.code != 0) { | |
174 | - getApp().my_warnning(data.msg, 0, th); | |
175 | - return false; | |
176 | - } | |
177 | - if (data.code == 0) { | |
178 | - //轮播图的数据 | |
179 | - var data_aissa = data.data.pageData; | |
180 | - //当前时间戳 | |
181 | - var nt = ut.gettimestamp(); | |
182 | - | |
183 | - data_aissa.forEach(function(val, ind) { | |
184 | - | |
185 | - //已开始 | |
186 | - if (val.start_time < nt && val.end_time > nt) data_aissa[ind].status = 0; | |
187 | - //未开始 | |
188 | - else if (val.start_time > nt && val.end_time > nt) data_aissa[ind].status = 1; | |
189 | - //已结束 | |
190 | - else if (val.start_time < nt && val.end_time < nt) data_aissa[ind].status = 2; | |
191 | - }); | |
192 | - var task_number = data_aissa[0].giftQty - data_aissa[0].useGiftQty; | |
193 | - var taskid = data_aissa[0].id; | |
194 | - th.setData({ | |
195 | - aitem: data_aissa, | |
196 | - task_number: task_number, | |
197 | - taskid: taskid | |
198 | - }); | |
199 | - //判断是不是领取的任务 | |
200 | - th.get_user_task(); | |
201 | - | |
202 | - } | |
203 | - | |
204 | - } | |
205 | - }) | |
206 | - | |
207 | - // 分享的 | |
208 | - // setTimeout(function() { | |
209 | - // th.shareFrends(); | |
210 | - // }, 1000) | |
211 | - | |
212 | - //会员任务列表 | |
213 | - this.user_task_list(); | |
214 | - //获取助力活动参与的人数 | |
215 | - this.get_user_task_num(); | |
216 | - | |
217 | - }, | |
218 | - //记录加载更多 | |
219 | - dismantle_record_list:function(){ | |
220 | - this.setData({ is_dismantle:0}); | |
221 | - this.dismantle_record(); | |
222 | - }, | |
223 | - //帮拆记录的 | |
224 | - dismantle_record: function(e) { | |
225 | - //优化 | |
226 | - if (this.data.is_dismantle == 1) { | |
227 | - return false; | |
228 | - } | |
229 | - | |
230 | - var aitem = this.data.aitem; //任务的数据集 | |
231 | - var sw_index = this.data.sw_index; //轮播的下标 | |
232 | - //任务id | |
233 | - var taskid = aitem[sw_index].id; | |
234 | - var th = this; | |
235 | - var index = 1; //获取当前选择的是任务还是活动说明 | |
236 | - var is_task = this.data.is_task; //0任务,1帮拆 | |
237 | - if (is_task == undefined || is_task == null) { | |
238 | - is_task = 1; | |
239 | - } | |
240 | - var switch_head = this.data.switch_head; | |
241 | - if (switch_head == undefined || switch_head == null) { | |
242 | - switch_head = 1; | |
243 | - } | |
244 | - this.setData({ | |
245 | - is_task: 1, | |
246 | - switch_head: 1, | |
247 | - block: 0, | |
248 | - }); | |
249 | - | |
250 | - var bc_page = th.data.bc_page; | |
251 | - rq.get("/api/weshop/marketing/help/help/task/involve/page", { | |
252 | - data: { | |
253 | - page: bc_page, | |
254 | - pageSize: 5, | |
255 | - taskId: taskid, | |
256 | - userId: getApp().globalData.user_id, | |
257 | - storeId: os.stoid | |
258 | - }, | |
259 | - success: function(res) { | |
260 | - if (res.data.code == 0) { | |
261 | - th.setData({is_dismantle: 1}); | |
262 | - var dismantle = res.data.data.pageData[0].zlHelpUser; | |
263 | - if (res.data.data.total > 5) { | |
264 | - var bc_page = th.data.bc_page + 1; | |
265 | - var dismantle_s = th.data.dismantle.concat(dismantle); | |
266 | - th.setData({ | |
267 | - bc_page: bc_page, | |
268 | - is_bc_show: 1, | |
269 | - dismantle: dismantle_s, | |
270 | - is_dis_list:1 | |
271 | - }) | |
272 | - } else { | |
273 | - th.setData({ | |
274 | - dismantle: dismantle, | |
275 | - is_dis_list: 0 | |
276 | - }); | |
277 | - } | |
278 | - var dis_len=th.data.dismantle.length; | |
279 | - if (res.data.data.total == dis_len){ | |
280 | - th.setData({ | |
281 | - is_dis_list: 0, | |
282 | - }) | |
283 | - } | |
284 | - th.setData({ | |
285 | - | |
286 | - is_clik: 0, | |
287 | - }); | |
288 | - } else { | |
289 | - th.setData({ | |
290 | - dismantle: null | |
291 | - }); | |
292 | - } | |
293 | - } | |
294 | - | |
295 | - }) | |
296 | - }, | |
297 | - // 领取礼包 | |
298 | - get_libao: function(e) { | |
299 | - var libao_id = e.currentTarget.dataset.libaoid; //礼包id | |
300 | - var taskid= e.currentTarget.dataset.taskid; | |
301 | - var taskingid = e.currentTarget.dataset.taskingid; | |
302 | - getApp().goto("/pages/user/assistance/giftpacklist?help_id=" + this.data.help_id + "&is_libao=" + 1 + "&taskId=" + taskid + "&id="+taskingid); | |
303 | - }, | |
304 | - //查看礼包id | |
305 | - select_libao: function(e) { | |
306 | - var orderSn = e.currentTarget.dataset.orderSn; | |
307 | - getApp().goto("/pages/user/assistance/giftpacklist?orderSn=" + orderSn); | |
308 | - }, | |
309 | - | |
310 | - //划动的时候监听 | |
311 | - onSli: function(e) { | |
312 | - var arr=[]; | |
313 | - this.setData({ | |
314 | - dismantle: arr | |
315 | - }); | |
316 | - var th = this; | |
317 | - var ind = e.detail.current; | |
318 | - var aitem = this.data.aitem; | |
319 | - var task_number = aitem[ind].giftQty - aitem[ind].useGiftQty; | |
320 | - var task_id = aitem[ind].id; | |
321 | - th.setData({ | |
322 | - sw_index: ind, | |
323 | - task_number: task_number, | |
324 | - taskid: task_id, | |
325 | - is_dismantle: 0, | |
326 | - bc_page:1 | |
327 | - }); | |
328 | - | |
329 | - if (this.data.switch_head == 1&&th.data.is_clik==0) { | |
330 | - //判断有没有帮拆记录 | |
331 | - this.dismantle_record(); | |
332 | - } | |
333 | - //判断是不是领取的任务 | |
334 | - th.get_user_task(); | |
335 | - | |
336 | - }, | |
337 | - //导航球 | |
338 | - close: function() { | |
339 | - var th = this; | |
340 | - var nav_b = th.selectComponent("#nav_b"); //组件的id | |
341 | - nav_b.close_box(); | |
342 | - }, | |
343 | - //我的任务点击加载更多 | |
344 | - task_list:function(){ | |
345 | - this.setData({ block:0}); | |
346 | - this.user_task_list(); | |
347 | - }, | |
348 | - // 获取会员的参与的任务列表 我的任务 | |
349 | - user_task_list: function(e) { | |
350 | - var th = this; | |
351 | - //防止已经当前位置的时候多次点击 | |
352 | - if (th.data.block == 1) { return false; } | |
353 | - var index = 0; | |
354 | - var is_task = this.data.is_task; //0任务,1帮拆 | |
355 | - if (is_task == undefined || is_task == null) { | |
356 | - is_task = 0; | |
357 | - } | |
358 | - var switch_head = this.data.switch_head; | |
359 | - if (switch_head == undefined || switch_head == null) { | |
360 | - switch_head = 0; | |
361 | - } | |
362 | - this.setData({ | |
363 | - is_task: index, | |
364 | - switch_head: index | |
365 | - }); | |
366 | - var help_id = th.data.help_id; | |
367 | - var user_id = getApp().globalData.user_id; | |
368 | - var rw_page = th.data.rw_page; | |
369 | - rq.get("/api/weshop/marketing/help/help/user/page", { | |
370 | - data: { | |
371 | - page: rw_page, | |
372 | - pageSize: 5, | |
373 | - helpId: help_id, | |
374 | - storeId: os.stoid, | |
375 | - userId: user_id | |
376 | - }, | |
377 | - success: function(su) { | |
378 | - th.setData({block:1}); | |
379 | - if (su.data.code == 0) { | |
380 | - if (su.data.data.total > 5) { | |
381 | - var rw_page = th.data.rw_page + 1; | |
382 | - th.setData({ | |
383 | - rw_page: rw_page, | |
384 | - is_show: 1 | |
385 | - }) | |
386 | - | |
387 | - } | |
388 | - | |
389 | - | |
390 | - var user_list = su.data.data.pageData; | |
391 | - // if (user_list == "" || user_list.length == 0 || user_list==null){ | |
392 | - // th.setData({ | |
393 | - // is_user_list: 1 | |
394 | - // }); | |
395 | - // console.log("走哪里1111"); | |
396 | - // }else{} | |
397 | - console.log("走哪里22222222"); | |
398 | - var user_lists=th.data.user_task_list.concat(user_list); | |
399 | - th.setData({ | |
400 | - user_task_list: user_lists | |
401 | - }); | |
402 | - } else { | |
403 | - th.setData({ is_user_list: 1 }); | |
404 | - getApp().my_warnning(su.data.msg, 0, th); | |
405 | - } | |
406 | - } | |
407 | - }) | |
408 | - }, | |
409 | - //判断是否有领取任务 获取正在进行中的任务 | |
410 | - get_user_task: function() { | |
411 | - var user_id = getApp().globalData.user_id; | |
412 | - var th = this; | |
413 | - var aitem = th.data.aitem; | |
414 | - var sw_index = th.data.sw_index; | |
415 | - var taskid = aitem[sw_index].id | |
416 | - rq.get("/api/weshop/marketing/help/help/task/get", { | |
417 | - data: { | |
418 | - storeId: os.stoid, | |
419 | - userId: user_id, | |
420 | - taskId: taskid | |
421 | - }, | |
422 | - success: function(res) { | |
423 | - if (res.data.code == 0) { | |
424 | - var is_usertask = res.data.data; | |
425 | - th.setData({ | |
426 | - is_user_task: is_usertask | |
427 | - }); | |
428 | - } | |
429 | - } | |
430 | - }) | |
431 | - }, | |
432 | - //获取助力活动参与的人数 | |
433 | - get_user_task_num: function() { | |
434 | - var th = this; | |
435 | - var help_id = th.data.help_id; | |
436 | - rq.get("/api/weshop/marketing/help/involve/help/act/people/count", { | |
437 | - data: { | |
438 | - helpId: help_id, | |
439 | - storeId: os.stoid, | |
440 | - }, | |
441 | - success: function(su) { | |
442 | - if (su.data.code == 0) { | |
443 | - var usercount = su.data.data.countAll; | |
444 | - | |
445 | - th.setData({ | |
446 | - usercount: usercount | |
447 | - }); | |
448 | - } | |
449 | - } | |
450 | - }) | |
451 | - | |
452 | - }, | |
453 | - //轮播卡死的重置 | |
454 | - changeGoodsSwip: function(detail) { | |
455 | - if (detail.detail.source == "touch") { | |
456 | - //当页面卡死的时候,current的值会变成0 | |
457 | - if (detail.detail.current == 0) { | |
458 | - //有时候这算是正常情况,所以暂定连续出现3次就是卡了 | |
459 | - let swiperError = this.data.swiperError | |
460 | - swiperError += 1 | |
461 | - this.setData({ | |
462 | - swiperError: swiperError | |
463 | - }) | |
464 | - if (swiperError >= 3) { //在开关被触发3次以上 | |
465 | - this.setData({ | |
466 | - sw_index: this.data.preIndex | |
467 | - }); //,重置current为正确索引 | |
468 | - this.setData({ | |
469 | - swiperError: 0 | |
470 | - }) | |
471 | - } | |
472 | - } else { //正常轮播时,记录正确页码索引 | |
473 | - this.setData({ | |
474 | - preIndex: detail.detail.current | |
475 | - }); | |
476 | - //将开关重置为0 | |
477 | - this.setData({ | |
478 | - swiperError: 0 | |
479 | - }) | |
480 | - } | |
481 | - } | |
482 | - }, | |
483 | - | |
484 | - // 轮播图点击左边 | |
485 | - click_pre: function() { | |
486 | - var arr=[]; | |
487 | - this.setData({ | |
488 | - dismantle:arr | |
489 | - }); | |
490 | - var index = this.data.sw_index; | |
491 | - index--; | |
492 | - if (index < 0) return; | |
493 | - var aitem = this.data.aitem; | |
494 | - var task_number = aitem[index].giftQty - aitem[index].useGiftQty; | |
495 | - var task_id = aitem[index].id; | |
496 | - this.setData({ | |
497 | - sw_index: index, | |
498 | - task_number: task_number, | |
499 | - taskid: task_id, | |
500 | - is_dismantle: 0, | |
501 | - is_clik:1, | |
502 | - bc_page:1 | |
503 | - }) | |
504 | - if (this.data.switch_head == 1) { | |
505 | - //判断有没有帮拆记录 | |
506 | - console.log("往左点////////////////////"); | |
507 | - this.dismantle_record(); | |
508 | - } | |
509 | - if (this.data.switch_head == 0){ | |
510 | - //判断有没有领取任务 | |
511 | - this.get_user_task(); | |
512 | - } | |
513 | - | |
514 | - }, | |
515 | - //轮播图点击右边 | |
516 | - click_next: function() { | |
517 | - var arr=[]; | |
518 | - this.setData({ | |
519 | - is_clik:1, | |
520 | - dismantle: arr | |
521 | - }); | |
522 | - var index = this.data.sw_index; | |
523 | - index++; | |
524 | - if (index >= this.data.aitem.length) return; | |
525 | - var aitem = this.data.aitem; | |
526 | - var task_number = aitem[index].giftQty - aitem[index].useGiftQty; | |
527 | - var task_id = aitem[index].id; | |
528 | - this.setData({ | |
529 | - sw_index: index, | |
530 | - task_number: task_number, | |
531 | - taskid: task_id, | |
532 | - is_dismantle: 0, | |
533 | - bc_page:1, | |
534 | - }) | |
535 | - if (this.data.switch_head == 1) { | |
536 | - this.dismantle_record(); | |
537 | - } | |
538 | - }, | |
539 | - | |
540 | - /** | |
541 | - * 生命周期函数--监听页面隐藏 | |
542 | - */ | |
543 | - onHide: function() { | |
544 | - //--清理定时器-- | |
545 | - clearInterval(this.data.timer); | |
546 | - }, | |
547 | - | |
548 | - /** | |
549 | - * 生命周期函数--监听页面卸载 | |
550 | - */ | |
551 | - onUnload: function() { | |
552 | - | |
553 | - }, | |
554 | - | |
555 | - /** | |
556 | - * 页面相关事件处理函数--监听用户下拉动作 | |
557 | - */ | |
558 | - onPullDownRefresh: function() { | |
559 | - | |
560 | - }, | |
561 | - //----助力任务的时间----- | |
562 | - countDown() { | |
563 | - if (!this.data.is_timer) return false; | |
564 | - var th = this; | |
565 | - // 获取当前时间,同时得到活动结束时间数组 | |
566 | - var newTime = ut.gettimestamp(); | |
567 | - | |
568 | - // 对结束时间进行处理渲染到页面 | |
569 | - | |
570 | - // var o = endTimeList[i]; | |
571 | - var endTime = th.data.endDate; | |
572 | - // if (o.status == 0) endTime = o.start_time | |
573 | - | |
574 | - var obj = null; | |
575 | - // 如果活动未结束,对时间进行处理 | |
576 | - if (endTime - newTime > 0) { | |
577 | - var time = (endTime - newTime); | |
578 | - // 获取天、时、分、秒 | |
579 | - var day = parseInt(time / (60 * 60 * 24)); | |
580 | - var hou = parseInt(time % (60 * 60 * 24) / 3600); | |
581 | - var min = parseInt(time % (60 * 60 * 24) % 3600 / 60); | |
582 | - var sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); | |
583 | - obj = { | |
584 | - day: this.timeFormat(day), | |
585 | - hou: this.timeFormat(hou), | |
586 | - min: this.timeFormat(min), | |
587 | - sec: this.timeFormat(sec) | |
588 | - } | |
589 | - } else { | |
590 | - //活动已结束,全部设置为'00' | |
591 | - obj = { | |
592 | - day: '00', | |
593 | - hou: '00', | |
594 | - min: '00', | |
595 | - sec: '00' | |
596 | - } | |
597 | - } | |
598 | - var txt = "aitem[" + 0 + "].djs"; | |
599 | - th.setData({ | |
600 | - [txt]: obj | |
601 | - }); | |
602 | - }, | |
603 | - //---小于10的格式化函数---- | |
604 | - timeFormat(param) { | |
605 | - return param < 10 ? '0' + param : param; | |
606 | - }, | |
607 | - | |
608 | - /** | |
609 | - * 页面上拉触底事件的处理函数 | |
610 | - */ | |
611 | - onReachBottom: function() { | |
612 | - | |
613 | - }, | |
614 | - | |
615 | - /** | |
616 | - * 用户点击右上角分享 | |
617 | - */ | |
618 | - onShareAppMessage: function() { | |
619 | - | |
620 | - }, | |
621 | - | |
622 | - preview: function() { | |
623 | - var th = this; | |
624 | - var shareImgPath = th.data.shareImgPath; | |
625 | - wx.previewImage({ | |
626 | - url: shareImgPath[0], | |
627 | - urls: shareImgPath | |
628 | - }) | |
629 | - }, | |
630 | - | |
631 | - //关闭分享显示 | |
632 | - close_share: function() { | |
633 | - var th = this; | |
634 | - th.setData({ | |
635 | - is_share: 0 | |
636 | - }) | |
637 | - }, | |
638 | - syinfo: function() { | |
639 | - var th = this; | |
640 | - //获取用户设备信息,屏幕宽度 | |
641 | - wx.getSystemInfo({ | |
642 | - success: res => { | |
643 | - th.setData({ | |
644 | - screenWidth: res.screenWidth | |
645 | - }) | |
646 | - } | |
647 | - }) | |
648 | - }, | |
649 | - | |
650 | - | |
651 | - | |
652 | - //************************ */ | |
653 | - shareFrends: function(e) { | |
654 | - var th = this; | |
655 | - if (th.data.is_generate) return; | |
656 | - th.data.is_generate = 1; | |
657 | - | |
658 | - var scene = 1; | |
659 | - ///二微码 | |
660 | - var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + | |
661 | - os.stoid + "?sceneValue=" + scene + "&pageValue=pages/index/index/index"; | |
662 | - //读取文件成功则OK-- | |
663 | - wx.getImageInfo({ | |
664 | - src: path3, | |
665 | - success: function(res) { | |
666 | - | |
667 | - var ewm_path = res.path; // | |
668 | - //var act_time="2019.06.26 - 2019.07.02"; //活动的时间 | |
669 | - var bg_time = ut.formar_no_full(th.data.dynamic.beginDate); | |
670 | - var end_time = ut.formar_no_full(th.data.dynamic.endDate); | |
671 | - var act_time = bg_time + "-" + end_time; | |
672 | - | |
673 | - | |
674 | - var iurl = th.data.iurl; //图片地址前缀 | |
675 | - const ctx = wx.createCanvasContext('share_id'); //绘图上下文 | |
676 | - var unit = th.data.screenWidth / 750 * 1.35; | |
677 | - var numsize = 20 * unit; //几人助力字体大小 | |
678 | - var head_list_img = th.data.head_pic_arr; | |
679 | - var num = th.data.head_pic_arr.length; //已有几位好友助力 | |
680 | - | |
681 | - var aitem = th.data.aitem; //任务的数据集 | |
682 | - var sw_index = th.data.sw_index; //轮播的下标 | |
683 | - //任务id | |
684 | - var help_num = aitem[sw_index].helpNum; | |
685 | - var q_num = help_num - num; //还差几位好友助力 | |
686 | - var already = num.toString().length + 1; //已有几位好友助力 | |
687 | - var lack = q_num.toString().length + 1; //还差几位好友助力 | |
688 | - | |
689 | - var size = 15 * unit; | |
690 | - var imagesize = 40 * unit; //助力人的图片大小 | |
691 | - var left = 74 * unit; //助力人头像跟左边的距离 | |
692 | - var spacing = 12 * unit; //助力人图片间距 | |
693 | - var images = th.data.images; | |
694 | - ctx.drawImage(images[0], 0, 0, 445 * unit, 700 * unit); //分享的背景图片 | |
695 | - ctx.drawImage(images[1], 37 * unit, 185 * unit, 370 * unit, 377 * unit); //分享的背景图片 | |
696 | - | |
697 | - | |
698 | - ctx.drawImage(th.data.share_lb_img, 90 * unit, 231 * unit, 266 * unit, 160 * unit); //分享的礼包的背景图片 | |
699 | - | |
700 | - ctx.setFillStyle("rgb(221,153,116)"); | |
701 | - ctx.setFontSize(size) | |
702 | - ctx.fillText("已有", 77 * unit, 430 * unit); | |
703 | - ctx.setFillStyle("#FF4746"); | |
704 | - ctx.setFontSize(numsize) | |
705 | - ctx.fillText(num + "位", 108 * unit, 430 * unit); | |
706 | - ctx.setFillStyle("rgb(221,153,116)"); | |
707 | - ctx.setFontSize(size) | |
708 | - ctx.fillText("好友助力,还差", 116 * unit + already * numsize * unit, 430 * unit); | |
709 | - ctx.setFillStyle("#FF4746"); | |
710 | - ctx.setFontSize(numsize); | |
711 | - ctx.fillText(q_num + "位", 223 * unit + already * numsize * unit, 430 * unit); | |
712 | - ctx.setFillStyle("rgb(221,153,116)"); | |
713 | - ctx.setFontSize(size); | |
714 | - ctx.fillText("达成助力", 230 * unit + lack * numsize * unit + already * numsize * unit, 430 * unit); | |
715 | - var c = num / help_num; | |
716 | - ctx.drawImage(images[2], 65 * unit, 445 * unit, 320 * unit, 12 * unit); | |
717 | - ctx.drawImage(images[3], 65 * unit, 445 * unit, 320 * unit * c, 12 * unit); | |
718 | - var head_list_num = 30; | |
719 | - var is_head_list = 0; | |
720 | - | |
721 | - //当需要助力人数小与6个 | |
722 | - if (help_num < 6) { | |
723 | - var pos_arr=ut.get_box_arr(help_num,225.25*unit,505 * unit,spacing,imagesize / 2); | |
724 | - var now_ind=0; | |
725 | - //--判断已助力的人数-- | |
726 | - for (var a = 0; a < head_list_img.length; a++) { | |
727 | - var pos= pos_arr[now_ind]; | |
728 | - ut.draw_circle(ctx,pos.x, pos.y, imagesize / 2,head_list_img[a],'red',unit); | |
729 | - now_ind++; | |
730 | - } | |
731 | - //--显示还差的人数-- | |
732 | - if(help_num-head_list_img.length>0){ | |
733 | - var neednum=help_num-head_list_img.length; | |
734 | - //这个是还未助力的位置 | |
735 | - for (var i = 0; i < neednum; i++) { | |
736 | - var pos= pos_arr[now_ind]; | |
737 | - now_ind++; | |
738 | - // 助力人的头像 | |
739 | - ctx.drawImage(images[4], pos.x-imagesize/2, pos.y-imagesize/2,imagesize, imagesize); //分享的背景图片 | |
740 | - | |
741 | - } | |
742 | - } | |
743 | - | |
744 | - }else if(help_num>7){ | |
745 | - //助力头像数量, 是不是要显示省略图 | |
746 | - var zl_head=0,is_sheng=0; | |
747 | - if(head_list_img.length>=6) { | |
748 | - zl_head=5;is_sheng=1; | |
749 | - }else{ | |
750 | - zl_head=head_list_img.length; | |
751 | - } | |
752 | - | |
753 | - | |
754 | - //判断已助力的人数 | |
755 | - for (var a = 0; a < zl_head; a++) { | |
756 | - //绘制头像 | |
757 | - ut.draw_circle(ctx,left + imagesize / 2, 505 * unit, imagesize / 2,head_list_img[a],'red',unit); | |
758 | - left += imagesize + spacing; | |
759 | - } | |
760 | - | |
761 | - //如果是省略号的话 | |
762 | - if(is_sheng){ | |
763 | - ctx.drawImage(images[5], left , 505 * unit - imagesize / 2, imagesize, imagesize); //头像的省略图片 | |
764 | - }else{ | |
765 | - //这个是还未助力的位置 | |
766 | - for (var i = 0; i < 6-head_list_img.length; i++) { | |
767 | - // 助力人的头像 | |
768 | - ctx.drawImage(images[4], left , 505 * unit - imagesize / 2, imagesize, imagesize); //分享的?号图片 | |
769 | - left += imagesize + spacing; | |
770 | - } | |
771 | - } | |
772 | - }else{ | |
773 | - // 判断已助力的人数 | |
774 | - for (var a = 0; a < head_list_img.length; a++) { | |
775 | - ctx.save(); | |
776 | - ctx.beginPath(); //开始绘制 | |
777 | - ctx.arc(left + imagesize / 2, 505 * unit, imagesize / 2, 0, 2 * Math.PI); | |
778 | - ctx.setLineWidth(4 * unit); | |
779 | - ctx.setStrokeStyle('red'); | |
780 | - ctx.setFillStyle("white"); | |
781 | - ctx.fill(); | |
782 | - ctx.clip(); | |
783 | - ctx.drawImage(head_list_img[a], left , 505 * unit - imagesize / 2, imagesize, imagesize); | |
784 | - ctx.restore(); | |
785 | - left += imagesize + spacing; | |
786 | - } | |
787 | - | |
788 | - if(help_num-head_list_img.lengt>0){ | |
789 | - var neednum=help_num-head_list_img.length; | |
790 | - //这个是还未助力的位置 | |
791 | - for (var i = 0; i < neednum; i++) { | |
792 | - // 助力人的头像 | |
793 | - ctx.drawImage(images[4], left , 505 * unit - imagesize / 2, imagesize, imagesize); //分享的背景图片 | |
794 | - left += imagesize + spacing; | |
795 | - } | |
796 | - } | |
797 | - | |
798 | - } | |
799 | - | |
800 | - ctx.setFillStyle("rgb(255,255,255)"); | |
801 | - ctx.setFontSize(size); | |
802 | - ctx.fillText("优惠乐翻天,精彩就在你身边!", 37 * unit, 595 * unit); | |
803 | - ctx.setFillStyle("rgb(255,255,255)"); | |
804 | - ctx.setFontSize(size); | |
805 | - ctx.fillText(act_time, 37 * unit, 620 * unit); //绘制活动是时间 | |
806 | - ctx.setFillStyle("rgb(255,255,255)"); | |
807 | - ctx.setFontSize(size); | |
808 | - ctx.fillText("长按识别二维码,可帮我助力!", 37 * unit, 660 * unit); | |
809 | - ctx.drawImage(ewm_path, 325 * unit, 585 * unit, 77 * unit, 77 * unit); //分享的背景图片 | |
810 | - ctx.save(); | |
811 | - //读取文件成功则OK-- | |
812 | - // wx.getImageInfo({ | |
813 | - // src: path3, | |
814 | - // success: function (res) { | |
815 | - //把画板内容绘制成图片,并回调 画板图片路径 | |
816 | - ctx.draw(false, function() { | |
817 | - setTimeout(function() { | |
818 | - wx.canvasToTempFilePath({ | |
819 | - x: 0, | |
820 | - y: 0, | |
821 | - width: 300, | |
822 | - height: 500, | |
823 | - destWidth: 400 * 2, | |
824 | - destHeight: 720 * 2, | |
825 | - canvasId: 'share_id', | |
826 | - success: function(res) { | |
827 | - wx.hideLoading(); | |
828 | - var shareImgPath = th.data.shareImgPath; | |
829 | - shareImgPath[0] = res.tempFilePath; | |
830 | - | |
831 | - th.setData({ | |
832 | - shareImgPath: shareImgPath, | |
833 | - canvasHidden: 1, | |
834 | - is_share: 1, | |
835 | - is_generate: 0, | |
836 | - canvasHidden: 1 | |
837 | - }) | |
838 | - if (!res.tempFilePath) { | |
839 | - wx.showModal({ | |
840 | - title: '提示', | |
841 | - content: '图片绘制中,请稍后重试', | |
842 | - showCancel: false | |
843 | - }) | |
844 | - return false; | |
845 | - } | |
846 | - | |
847 | - }, | |
848 | - fail(r) { | |
849 | - | |
850 | - } | |
851 | - }, 500) | |
852 | - }) | |
853 | - }) | |
854 | - } | |
855 | - }) | |
856 | - | |
857 | - | |
858 | - }, | |
859 | - | |
860 | - | |
861 | - preview: function() { | |
862 | - var th = this; | |
863 | - var shareImgPath = th.data.shareImgPath; | |
864 | - wx.previewImage({ | |
865 | - url: shareImgPath[0], | |
866 | - urls: shareImgPath | |
867 | - }) | |
868 | - th.setData({ | |
869 | - is_share: 0 | |
870 | - }) | |
871 | - }, | |
872 | - | |
873 | - //关闭分享显示 | |
874 | - close_share: function() { | |
875 | - var th = this; | |
876 | - wx.hideLoading(); | |
877 | - th.setData({ | |
878 | - is_share: 0 | |
879 | - }) | |
880 | - }, | |
881 | - syinfo: function() { | |
882 | - var th = this; | |
883 | - //获取用户设备信息,屏幕宽度 | |
884 | - wx.getSystemInfo({ | |
885 | - success: res => { | |
886 | - th.setData({ | |
887 | - screenWidth: res.screenWidth | |
888 | - }) | |
889 | - } | |
890 | - }) | |
891 | - }, | |
892 | - | |
893 | - //把固定的图片加载到本地 | |
894 | - imageinfo: async function() { | |
895 | - var th = this; | |
896 | - var images = th.data.images; | |
897 | - var iurl = th.data.iurl; | |
898 | - for (var i in images) { | |
899 | - var img_path = iurl + images[i]; | |
900 | - await getApp().request.promise_downimg(img_path).then(res => { | |
901 | - images[i] = res; | |
902 | - }) | |
903 | - } | |
904 | - | |
905 | - th.data.images = images; | |
906 | - }, | |
907 | - | |
908 | - | |
909 | - //好友猜一猜 | |
910 | - save_share: function(e) { | |
911 | - var th = this; | |
912 | - var aitem = this.data.aitem; //任务的数据集 | |
913 | - var sw_index = this.data.sw_index; //轮播的下标 | |
914 | - var sw_item = aitem[sw_index]; | |
915 | - //任务id | |
916 | - var taskid = sw_item.id; | |
917 | - th.setData({ | |
918 | - is_share: 1 | |
919 | - }) | |
920 | - var url = "/api/weshop/marketing/help/help/task/involve/page"; | |
921 | - getApp().request.promiseGet(url, { | |
922 | - isShowLoading: true, | |
923 | - data: { | |
924 | - storeId: os.stoid, | |
925 | - taskId: taskid, | |
926 | - userId: getApp().globalData.user_id | |
927 | - } | |
928 | - }).then(res => { | |
929 | - if (res.data.code == 0) { | |
930 | - var data = res.data.data.pageData; //帮拆数组 | |
931 | - if (data.length > 0) { | |
932 | - th.data.dynamic = data[0]; | |
933 | - var path = th.data.iurl + sw_item.giftBagUrl; | |
934 | - //先获取礼包分享时的本地路径 | |
935 | - getApp().request.promise_downimg(path).then(res => { | |
936 | - th.data.share_lb_img = res; | |
937 | - //先获取会员的头像 | |
938 | - th.info_head(th.shareFrends); | |
939 | - }); | |
940 | - } | |
941 | - } else { | |
942 | - wx.hideLoading(); | |
943 | - getApp().my_warnning(res.data.msg, 0, th); | |
944 | - } | |
945 | - }) | |
946 | - }, | |
947 | - | |
948 | - //把已助力好友头像下载到本地 | |
949 | - info_head: async function(func) { | |
950 | - var th = this; | |
951 | - var images = th.data.dynamic.zlHelpUser; | |
952 | - var arr = new Array(); | |
953 | - var block = th.data.block; | |
954 | - if (images) { | |
955 | - th.data.head_pic_arr.length = 0; | |
956 | - for (var i in images) { | |
957 | - var img_path = images[i].headPic; | |
958 | - await getApp().request.promise_downimg(img_path).then(res => { | |
959 | - th.data.head_pic_arr.push(res); | |
960 | - }) | |
961 | - } | |
962 | - } | |
963 | - func(); | |
964 | - }, | |
965 | -//立即兑换 | |
966 | - redeem_now: function (e) { | |
967 | - var libao_id = e.currentTarget.dataset.libaoid; | |
968 | - var sw_index=this.data.sw_index; | |
969 | - var aitem=this.data.aitem; | |
970 | - var taskid = aitem[sw_index].id; | |
971 | - var taskingid= e.currentTarget.dataset.taskingid; | |
972 | - getApp().goto("/pages/user/assistance/giftpacklist?help_id=" + this.data.help_id + "&is_libao=" + 1 + "&taskId=" + taskid + "&id="+taskingid); | |
973 | - }, | |
974 | - | |
975 | - | |
976 | - //礼包的详情 轮播图 | |
977 | - libao_details: function(e) { | |
978 | - var th = this; | |
979 | - var help_id = th.data.help_id; //活动id | |
980 | - var taskId = e.currentTarget.dataset.taskid; //任务id | |
981 | - getApp().goto("/pages/user/assistance/giftpacklist?help_id=" + help_id + "&is_libao=" + 0 + "&taskId=" + taskId); | |
982 | - }, | |
983 | - //测试正在进行任务 | |
984 | - test: function (e) { | |
985 | - var taskid = e.currentTarget.dataset.taskid; | |
986 | - var uset_id = this.data.zlisuers_id; | |
987 | - getApp().goto("/pages/user/assistance/friend_assistance?tasking=" + taskid + "&userId=" + uset_id); | |
988 | - }, | |
989 | - | |
990 | -}) | |
991 | 0 | \ No newline at end of file |