diff --git a/pages/user/assistance/task_assistance.js b/pages/user/assistance/task_assistance.js index e0852a8..5181a71 100644 --- a/pages/user/assistance/task_assistance.js +++ b/pages/user/assistance/task_assistance.js @@ -17,9 +17,9 @@ Page({ sw_index: 0, //轮播的下标控制 url: s.url, //接口网址 iurl: s.imghost, - is_task: 0, //判断标题名是任务1还是2 + endDate:"",//活动结束时间 activity_data: "25:20:59", //活动剩余时间 - task_number: 12, //任务数 + task_number:0, //任务数 is_task: 0, //历史记录与任务 aitem: "", //活动的轮播图 switch_head: 0, //0:我的任务,1:记录 @@ -28,9 +28,10 @@ Page({ shareImgPath: [], //生成的图片 screenWidth: "", //用户的屏幕宽度 gid: "", - images: ["miniapp/images/friendhelp/help.png", "miniapp/images/friendhelp/background.png", "miniapp/images/friendhelp/gift.png", "miniapp/images/friendhelp/no_check.png", - "miniapp/images/friendhelp/check.png", "miniapp/images/friendhelp/check.png", "miniapp/images/friendhelp/unfinished.png", "miniapp/images/friendhelp/gift.png" - ] + timer: null,//全局的定时器 + user_task_list:null,//会员列表 + taskid:"",//任务id + usercount:0,//参与的人数 }, /** @@ -38,7 +39,6 @@ Page({ */ onLoad: function(options) { var help_id = options.help_id; - console.log("是什么鬼", help_id); var th = this; th.setData({ help_id: help_id @@ -50,57 +50,74 @@ Page({ } th.close(); th.syinfo(); - th.imageinfo(); + // th.imageinfo(); }, - // 轮播图点击左边 - click_pre: function() { - var index = this.data.sw_index; - index--; - if (index < 0) return; - this.setData({ - sw_index: index - }) + + + //选中任务保存 + add_onlicke:function(e){ + var th=this; + var taskid=e.target.dataset.taskid; + var help_id = th.data.help_id; + var user_id = getApp().globalData.user_id; + var stoid=os.stoid + getApp().request.json_post("/api/weshop/marketing/help/help/task/insert" + ,{ + helpId:help_id, + userId:user_id, + storeId:stoid, + taskId: taskid + }, + function(res) { + if(res.data.code==0){ + console.log(res.data.data); + getApp().my_warnning("任务领取成功", 1, th); + }else{ + getApp().my_warnning(res.data.msg, 0, th); + } + } + + ) }, - //轮播图点击右边 - click_next: function() { - var index = this.data.sw_index; - index++; - if (index >= this.data.aitem.length) return; - this.setData({ - sw_index: index - }) - }, - //任务领取 - onlicke: function() { + //帮拆记录的 + dismantle_record: function(e) { + console.log(); var th = this; - th.shareFrends(); - th.setData({ - is_share:1 - }) - getApp().my_warnning("任务领取成功", 1, th); - }, - - //我的任务和帮拆记录的替换 - switch_head: function(e) { - var th = this; - var index = e.currentTarget.dataset.index; //获取当前选择的是任务还是活动说明 - var switch_head = th.data.switch_head; //0任务,1活动说明 - if (index != switch_head) { + var index =1; //获取当前选择的是任务还是活动说明 + var is_task= th.data.is_task; //0任务,1活动说明 + console.log(e, "这是标签的", is_task, "这是"); + th.setData({ - switch_head: index, - is_task: index + is_task:1, + switch_head:1 + }); + rq.get("/api/weshop/marketing/help/help/task/involve/page", { + data: { + userId: user_id, + storeId: os.stoid + }, + success: function (res) {} + }) - } + + }, + + //划动的时候监听 onSli: function(e) { - + var th= this; var ind = e.detail.current; - this.setData({ - sw_index: ind + var aitem = this.data.aitem; + + var task_number = aitem[ind].giftQty - aitem[ind].useGiftQty; + th.setData({ + sw_index: ind, + task_number: task_number }) + console.log(th.data.sw_index,"滑动监听", ind); }, //导航球 close: function() { @@ -121,18 +138,41 @@ Page({ * 生命周期函数--监听页面显示 */ onShow: function() { + this.data.is_timer = 1; var th = this; var help_id = th.data.help_id; - /*-----统计-----*/ + var user_id = getApp().globalData.user_id; + + /*-----助力活动(判断)-----*/ + rq.get("/api/weshop/marketing/help/act/judge", { + data: { + userId: user_id, + storeId: os.stoid + }, + success: function (res) { + if (res.data.code == 0) { + + var help_data = res.data.data; + console.log( '助力活动(判断)', res.data.data); + th.setData({ + endDate:help_data.endDate, + }); + + } + } + + + }); + + + /*-----获取助力活动的任务-----*/ rq.get("/api/weshop/marketing/help/help/task/page", { data: { helpId: help_id, storeId: os.stoid }, success: function(su) { - var data = su.data; - console.log('waitlist5555555555' + data.code); if (data.code != 0) { getApp().my_warnning(data.msg, 0, th); return false; @@ -142,21 +182,23 @@ Page({ var data_aissa = data.data.pageData; //当前时间戳 var nt = ut.gettimestamp(); - + data_aissa.forEach(function(val, ind) { - console.log(nt, "当前时间", "结束时间", val.end_time, "开始时间"); + //已开始 if (val.start_time < nt && val.end_time > nt) data_aissa[ind].status = 0; //未开始 else if (val.start_time > nt && val.end_time > nt) data_aissa[ind].status = 1; //已结束 - else if (val.start_time < nt && val.end_time < nt) data_aissa[ind].status = 2; - }); - + var task_number=data_aissa[0].giftQty - data_aissa[0].useGiftQty; + var taskid = data_aissa[0].id; + th.setData({ - aitem: data_aissa + aitem: data_aissa, + task_number: task_number, + taskid:taskid }); @@ -164,58 +206,97 @@ Page({ } }) - setTimeout(function() { - th.shareFrends(); - }, 1000) - + // 分享的 + // setTimeout(function() { + // th.shareFrends(); + // }, 1000) + //任务时间 设置全局定时器 + th.data.timer = setInterval(function () { + th.countDown(); + },1000); + //会员任务列表 + this.user_task_list(); + // 获取会员的参与的任务列表 我的任务 + this.get_user_task_num(); }, - //----助力任务----- - countDown() { - if (!this.data.is_timer) return false; - var th = this; - // 获取当前时间,同时得到活动结束时间数组 - var newTime = ut.gettimestamp(); - var List = this.data.aitem; - for (var j = 0; j < List.length; j++) { - var endTimeList = List[j]; - // 对结束时间进行处理渲染到页面 - for (var i = 0; i < endTimeList.length; i++) { - var o = endTimeList[i]; - var endTime = o.end_time - if (o.status == 0) endTime = o.start_time - - var obj = null; - // 如果活动未结束,对时间进行处理 - if (endTime - newTime > 0) { - var time = (endTime - newTime); - // 获取天、时、分、秒 - var day = parseInt(time / (60 * 60 * 24)); - var hou = parseInt(time % (60 * 60 * 24) / 3600); - var min = parseInt(time % (60 * 60 * 24) % 3600 / 60); - var sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); - obj = { - day: this.timeFormat(day), - hou: this.timeFormat(hou), - min: this.timeFormat(min), - sec: this.timeFormat(sec) - } - } else { - //活动已结束,全部设置为'00' - obj = { - day: '00', - hou: '00', - min: '00', - sec: '00' - } - } - var txt = "aitem[" + j + "][" + i + "].djs"; + // 获取会员的参与的任务列表 我的任务 + user_task_list:function(e){ + var th=this; + // var index = e.target.dataset.index; //获取当前选择的是任务还是活动说明 + var index =0; + var is_task = th.data.is_task; //0任务,1活动说明 + var help_id = th.data.help_id; + var user_id = getApp().globalData.user_id; + rq.get("/api/weshop/marketing/help/help/user/page", { + data: { + helpId: help_id, + storeId: os.stoid, + userId: user_id + }, + success: function (su) { th.setData({ - [txt]: obj + is_task: index, + switch_head: index }); + if (su.data.code == 0) { + var user_list=su.data.data.pageData; + console.log("会员列表",user_list); + th.setData({ + user_task_list: user_list + }); + }else{ + th.setData({ + user_task_list:null + }); + } } + }) + }, + //获取助力活动参与的人数 + get_user_task_num(){ + var th=this; + var help_id=th.data.help_id; + rq.get("/api/weshop/marketing/help/involve/help/act/people/count", { + data: { + helpId: help_id, + storeId: os.stoid, + }, + success: function (su) { + console.log(su.data.code, "获取助力活动参与的人数",su.data) + if (su.data.code == 0) { + var usercount=su.data.data.countAll; + + th.setData({ usercount: usercount}); + } else { + + } + } + }) + + }, + // 轮播图点击左边 + click_pre: function () { + var index = this.data.sw_index; + index--; + if (index < 0) return; + var aitem = this.data.aitem; + var task_number = aitem[index].giftQty - aitem[index].useGiftQty; + this.setData({ + sw_index: index, + task_number: task_number + }) - } - setTimeout(th.countDown, 1000); + }, + //轮播图点击右边 + click_next: function () { + var index = this.data.sw_index; + index++; + if (index >= this.data.aitem.length) return; + var aitem = this.data.aitem; + var task_number = aitem[index].giftQty - aitem[index].useGiftQty; + this.setData({ + sw_index: index, task_number: task_number + }) }, @@ -223,7 +304,9 @@ Page({ * 生命周期函数--监听页面隐藏 */ onHide: function() { - + //--清理定时器-- + console.log("清理定时器"); + clearInterval(this.timer); }, /** @@ -239,6 +322,63 @@ Page({ onPullDownRefresh: function() { }, + //----助力任务的时间----- + countDown() { + if (!this.data.is_timer) return false; + var th = this; + // 获取当前时间,同时得到活动结束时间数组 + var newTime = ut.gettimestamp(); + var List = this.data.aitem; + for (var j = 0; j < List.length; j++) { + var o = List[j]; + + // 对结束时间进行处理渲染到页面 + + // var o = endTimeList[i]; + var endTime = o.endDate + + // if (o.status == 0) endTime = o.start_time + + var obj = null; + // 如果活动未结束,对时间进行处理 + if (endTime - newTime > 0) { + + var time = (endTime - newTime); + // 获取天、时、分、秒 + var day = parseInt(time / (60 * 60 * 24)); + var hou = parseInt(time % (60 * 60 * 24) / 3600); + var min = parseInt(time % (60 * 60 * 24) % 3600 / 60); + var sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); + obj = { + day: this.timeFormat(day), + hou: this.timeFormat(hou), + min: this.timeFormat(min), + sec: this.timeFormat(sec) + } + } else { + + //活动已结束,全部设置为'00' + obj = { + day: '00', + hou: '00', + min: '00', + sec: '00' + } + } + var txt = "aitem[" + j + "]djs"; + th.setData({ + [txt]: obj + }); + + + } + setTimeout(th.countDown, 1000); + + }, + //---小于10的格式化函数---- + timeFormat(param) { + return param < 10 ? '0' + param : param; + }, /** * 页面上拉触底事件的处理函数 @@ -393,102 +533,103 @@ Page({ } }) }, - imageinfo: function() { - var th = this; - var images = th.data.images; - var iurl = th.data.iurl; - wx.getImageInfo({ - src: iurl + images[0], - success: function(res) { - console.log(res + i); - //res.path是网络图片的本地地址 - images[0] = res.path; - }, - fail: function(res) { - console.log(res.toString() + "" + i); - } - }); - wx.getImageInfo({ - src: iurl + images[1], - success: function(res) { - console.log(res + i); - //res.path是网络图片的本地地址 - images[1] = res.path; - }, - fail: function(res) { - console.log(res.toString() + "" + i); - } - }); - wx.getImageInfo({ - src: iurl + images[2], - success: function(res) { - console.log(res + i); - //res.path是网络图片的本地地址 - images[2] = res.path; - }, - fail: function(res) { - console.log(res.toString() + "" + i); - } - }); - wx.getImageInfo({ - src: iurl + images[3], - success: function(res) { - console.log(res + i); - //res.path是网络图片的本地地址 - images[3] = res.path; - }, - fail: function(res) { - console.log(res.toString() + "" + i); - } - }); - wx.getImageInfo({ - src: iurl + images[4], - success: function(res) { - console.log(res + i); - //res.path是网络图片的本地地址 - images[4] = res.path; - }, - fail: function(res) { - console.log(res.toString() + "" + i); - } - }); - wx.getImageInfo({ - src: iurl + images[5], - success: function(res) { - console.log(res + i); - //res.path是网络图片的本地地址 - images[5] = res.path; - }, - fail: function(res) { - console.log(res.toString() + "" + i); - } - }); - wx.getImageInfo({ - src: iurl + images[6], - success: function(res) { - console.log(res + i); - //res.path是网络图片的本地地址 - images[6] = res.path; - }, - fail: function(res) { - console.log(res.toString() + "" + i); - } - }); - - wx.getImageInfo({ - src: iurl + images[7], - success: function(res) { - console.log(res + i); - //res.path是网络图片的本地地址 - images[7] = res.path; - }, - fail: function(res) { - console.log(res.toString() + "" + i); - } - }) - th.setData({ - images: images - }) - - } + //分享图 + // imageinfo: function() { + // var th = this; + // var images = th.data.images; + // var iurl = th.data.iurl; + // wx.getImageInfo({ + // src: iurl + images[0], + // success: function(res) { + // console.log(res + i); + // //res.path是网络图片的本地地址 + // images[0] = res.path; + // }, + // fail: function(res) { + // console.log(res.toString() + "" + i); + // } + // }); + // wx.getImageInfo({ + // src: iurl + images[1], + // success: function(res) { + // console.log(res + i); + // //res.path是网络图片的本地地址 + // images[1] = res.path; + // }, + // fail: function(res) { + // console.log(res.toString() + "" + i); + // } + // }); + // wx.getImageInfo({ + // src: iurl + images[2], + // success: function(res) { + // console.log(res + i); + // //res.path是网络图片的本地地址 + // images[2] = res.path; + // }, + // fail: function(res) { + // console.log(res.toString() + "" + i); + // } + // }); + // wx.getImageInfo({ + // src: iurl + images[3], + // success: function(res) { + // console.log(res + i); + // //res.path是网络图片的本地地址 + // images[3] = res.path; + // }, + // fail: function(res) { + // console.log(res.toString() + "" + i); + // } + // }); + // wx.getImageInfo({ + // src: iurl + images[4], + // success: function(res) { + // console.log(res + i); + // //res.path是网络图片的本地地址 + // images[4] = res.path; + // }, + // fail: function(res) { + // console.log(res.toString() + "" + i); + // } + // }); + // wx.getImageInfo({ + // src: iurl + images[5], + // success: function(res) { + // console.log(res + i); + // //res.path是网络图片的本地地址 + // images[5] = res.path; + // }, + // fail: function(res) { + // console.log(res.toString() + "" + i); + // } + // }); + // wx.getImageInfo({ + // src: iurl + images[6], + // success: function(res) { + // console.log(res + i); + // //res.path是网络图片的本地地址 + // images[6] = res.path; + // }, + // fail: function(res) { + // console.log(res.toString() + "" + i); + // } + // }); + + // wx.getImageInfo({ + // src: iurl + images[7], + // success: function(res) { + // console.log(res + i); + // //res.path是网络图片的本地地址 + // images[7] = res.path; + // }, + // fail: function(res) { + // console.log(res.toString() + "" + i); + // } + // }) + // th.setData({ + // images: images + // }) + + // } }) \ No newline at end of file diff --git a/pages/user/assistance/task_assistance.wxml b/pages/user/assistance/task_assistance.wxml index b3a8a35..bed33b8 100644 --- a/pages/user/assistance/task_assistance.wxml +++ b/pages/user/assistance/task_assistance.wxml @@ -2,10 +2,11 @@ - {{aitem[sw_index].tite_name}} + {{sw_index}} + {{aitem[sw_index].helpTaskName}} - 活动剩余时间: {{activity_data}} + 活动剩余时间: {{aitem[0].djs.day}}:{{aitem[0].djs.hou}}:{{aitem[0].djs.min}}:{{aitem[0].djs.sec}} @@ -14,25 +15,27 @@ - - - - + - - + + + + + / + + 今天剩余可领{{task_number}}个任务 - + 就选它了 @@ -41,26 +44,30 @@ - + 我的任务 - + 帮拆记录 + - + + - 豪华任务一 + {{item.helpTaskName}} - - 进行中 + + {{item.zlHelpNum}}/{{item.helpNum}} + 查看详情 + 领取礼包 @@ -70,9 +77,7 @@ - - - + 豪华任务一 @@ -84,30 +89,23 @@ - - + + 暂无任务记录 - - - 已有 - 126 - 人领取了任务 - - - - + + 点击加载更多 已有 - 126 + {{usercount}} 人领取了任务 diff --git a/pages/user/assistance/task_assistance.wxss b/pages/user/assistance/task_assistance.wxss index 61968ed..101fae3 100644 --- a/pages/user/assistance/task_assistance.wxss +++ b/pages/user/assistance/task_assistance.wxss @@ -154,3 +154,19 @@ border-color: #fff; width: 70rpx; height: 70rpx; } +.plan-frame{ + width: 90%; + margin: auto; + +} +.plan-frame .plan_num{ + width: 90%; + background: #ffe7ab; + border-radius: 20rpx; + height: 32rpx; +} +.is_plam{ + height: 100%; + top: 0rpx; + left: 0rpx; +} \ No newline at end of file