From b5bc85d7f61a4c57b897cedfec4a6c506941d3d3 Mon Sep 17 00:00:00 2001 From: yvan.ni <765199919@qq.com> Date: Sat, 11 Jan 2020 11:01:40 +0800 Subject: [PATCH] 助力活动的数据添加, 帮拆, 帮拆成功页 --- pages/user/assistance/assistance_success.js | 29 +++++++++-------------------- pages/user/assistance/assistance_success.wxml | 30 ++++++++---------------------- pages/user/assistance/friend_assistance.js | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------- pages/user/assistance/friend_assistance.wxml | 11 ++++++----- utils/request.js | 21 +++++++++++++++++++++ 5 files changed, 105 insertions(+), 58 deletions(-) diff --git a/pages/user/assistance/assistance_success.js b/pages/user/assistance/assistance_success.js index 280c870..9603900 100644 --- a/pages/user/assistance/assistance_success.js +++ b/pages/user/assistance/assistance_success.js @@ -8,6 +8,8 @@ Page({ */ data: { iurl: s.imghost, + user:app_d.userInfo, + zl_act:null, //助力活动 }, /** @@ -28,22 +30,22 @@ Page({ * 生命周期函数--监听页面显示 */ onShow: function () { - + this.init(); }, - - // 初始化判断微信余额 - async weixin() { + // ----初始化---- + init:function() { + var user_id = getApp().globalData.user_id; var store_id = os.stoid; - await getApp().request.promiseGet("/api/weshop/marketing/help/act/judge", { + var th=this; + getApp().request.promiseGet("http://172.20.3.102:8022/api/weshop/zl_act", { data: { user_id: user_id, store_id: store_id } }).then(res => { - console.log("是什么东西", res.data.code); - + if(res.data.code==0) th.setData({zl_act:res.data.data}) }) }, @@ -55,19 +57,6 @@ Page({ }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, /** * 页面上拉触底事件的处理函数 diff --git a/pages/user/assistance/assistance_success.wxml b/pages/user/assistance/assistance_success.wxml index 173aabc..40188e9 100644 --- a/pages/user/assistance/assistance_success.wxml +++ b/pages/user/assistance/assistance_success.wxml @@ -1,38 +1,24 @@ - - 你好 - - - 助力成功,自己也差拆一个吧~ + + {{user.nickname}} + 助力成功,自己也差拆一个吧~ - - 活动时间:5月23日-6月15日 - + + 活动时间:{{filter.fm_time(zl_act.beginDate)}}-{{filter.fm_time(zl_act.endDate)}} + 我也要参加 -已有126人领取礼盒 - - +已有{{zl_act.qiang_num}}人领取礼盒 + diff --git a/pages/user/assistance/friend_assistance.js b/pages/user/assistance/friend_assistance.js index 7dab41e..4db0560 100644 --- a/pages/user/assistance/friend_assistance.js +++ b/pages/user/assistance/friend_assistance.js @@ -9,13 +9,34 @@ Page({ data: { iurl: s.imghost, is_show:0,//显示弹框 + user:app_d.userInfo, + zl_act:null, //助力活动 + task_id:0, //助力任务ID + userId:0, //任务用户的ID }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + var th=this; + this.data.task_id=options.options; + this.data.userId=options.userId; + //任务是不是为空 + if(this.data.task_id==0 || this.data.task_id==undefined){ + this.data.task_id= decodeURIComponent(options.scene); + if(this.data.task_id){ + getApp().request.get("http://172.20.3.102:8022/api/weshop/zl_act_user",{ + data:{}, + success:function(res){ + if(res.data.code==0){ + th.data.userId=res.data.data.user_id; + } + } + }) + + } + } }, @@ -25,22 +46,34 @@ Page({ url: '/pages/user/assistance/assistance_success', }) }, - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - + /** * 生命周期函数--监听页面显示 */ onShow: function () { - + this.init(); }, //点击开启礼盒 cklie_button:function(){ - this.setData({ is_show:1}); + var th=this; + var t_user_id=app_d.user_id; + var data={id:this.data.task_id,storeId:os.store_id,userId:this.data.user_id, zlUserId:t_user_id}; + getApp().request.json_post("/api/weshop/marketing/help/help/task/involve/insert", + data, //入参 + function(res){ //成功 + if(res.data.code==0) + this.setData({ is_show:1}); + else{ + getApp().my_warnning(res.data.msg,0,th) + } + }, + function(){//失败 + + } + ) + + + }, //点击关闭礼盒 clike_none:function(){ @@ -86,5 +119,22 @@ Page({ */ onShareAppMessage: function () { - } + }, + + // ----初始化---- + init:function() { + + var user_id = getApp().globalData.user_id; + var store_id = os.stoid; + var th=this; + getApp().request.promiseGet("http://172.20.3.102:8022/api/weshop/zl_act", { + data: { + user_id: user_id, + store_id: store_id + } + }).then(res => { + if(res.data.code==0) th.setData({zl_act:res.data.data}) + }) + + }, }) \ No newline at end of file diff --git a/pages/user/assistance/friend_assistance.wxml b/pages/user/assistance/friend_assistance.wxml index a0301c5..3a1d9fc 100644 --- a/pages/user/assistance/friend_assistance.wxml +++ b/pages/user/assistance/friend_assistance.wxml @@ -1,24 +1,25 @@ + - - 你好 + + {{user.nickname}} 拜托拜托,帮我拆礼盒得好礼~ - + - 活动时间:5月23日-6月15日 + 活动时间:{{filter.fm_time(zl_act.begindate)}}-{{filter.fm_time(zl_act.begindate)}} 帮他拆礼盒 -已有126人领取礼盒 +已有{{zl_act.qiang_num}}人领取礼盒 diff --git a/utils/request.js b/utils/request.js index 35657e9..f477d13 100644 --- a/utils/request.js +++ b/utils/request.js @@ -212,5 +212,26 @@ module.exports = { if(req) req.abort(); },time*1000) } + + /** + * @param {Object} url //url地址 + * @param {Object} data //data入参 + * @param {Object} succ //成功的回调 + * @param {Object} fail //失败的回调 + */ + json_post:function(url,data,succ,fail){ + if(url.indexOf("http")==-1) url=getApp().globalData.setting.url +url; + var str = JSON.stringify(pdata); + wx.request({ + url: url, + data: str, + method: 'POST', + header: { + 'content-type': 'application/json' + },// 设置请求的 header + success: function (res) { succ(res); }, + fail:function(res){fail(res);} + }) + } }; \ No newline at end of file -- libgit2 0.21.4