var auth = require("../../../utils/auth.js"), rq = require("../../../utils/request.js"); var e = getApp(), app = e, s = e.globalData.setting, os = s, app_d = e.globalData; var regeneratorRuntime = require('../../../utils/runtime.js'); var ut = require("../../../utils/util.js"); Page({ /** * 页面的初始数据 */ data: { iurl: s.imghost, is_show: 0, //显示弹框 user: app_d.userInfo, zl_act: null, //助力活动 tasking: 0, //助力任务ID userId: 0, //任务用户的ID s_num: 0, //分享的人数 taskId:0, //活动从表ID helpId:0, }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { var th = this; var nav_b = th.selectComponent("#nav_b"); //组件的id nav_b.set_name("助力", "/pages/user/assistance/assistance"); if (options.tasking) this.data.tasking = options.tasking; if (options.userId) this.data.userId = options.userId; //任务是不是为空 if (this.data.tasking == 0 || this.data.tasking == undefined) { this.data.tasking = decodeURIComponent(options.scene); } }, // 跳转到助力首页,我也要参加 participate_activity: function() { wx.navigateTo({ url: '/pages/user/assistance/assistance', }) }, /** * 生命周期函数--监听页面显示 */ onShow: function() { //--先判断会员状态-- var user_info = getApp().globalData.userInfo; if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { getApp().goto('/pages/togoin/togoin'); return false; } var th=this; if (!th.data.user) th.setData({ user: getApp().globalData.userInfo}); if (this.data.tasking != null && this.data.tasking != 'undefined' && this.data.tasking != "" && this.data.tasking != 0) { getApp().request.promiseGet("/api/weshop/marketing/help/help/tasking/get", { data: { taskingId: th.data.tasking, storeId: os.stoid } }).then(res => { if (res.data.code == 0) { th.data.userId = res.data.data.userId; th.data.taskId = res.data.data.helpTaskId; th.data.helpId=res.data.data.helpFormId; //获取活动的时间 return getApp().request.promiseGet("/api/weshop/marketing/help/help/act/get", { data: { helpId: res.data.data.helpFormId, storeId: os.stoid } }) } return ut.null_promise(); }).then(res => { if (res.data.code == 0) { th.setData({ zl_act: res.data.data }) //获取活动的参与的人数 return getApp().request.promiseGet("/api/weshop/marketing/help/involve/help/act/people/count", { data: { helpId: res.data.data.id, storeId: os.stoid, taskId:th.data.taskId, } }) } return ut.null_promise(); }).then(res => { if (res && res.data && res.data.code == 0) { th.setData({ s_num: res.data.data.countAll }); } }) } }, //点击开启礼盒 cklie_button: function() { var th = this; //--先判断会员状态-- var user_info = getApp().globalData.userInfo; if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { wx.navigateTo({ url: '/pages/togoin/togoin', }) return false; } var t_user_id = app_d.user_id; var data = { id: this.data.tasking, storeId: os.stoid, userId: this.data.userId, zlUserId: t_user_id, isWeappUser:1, //是不是小程序的入口,不需要判断 }; console.log(data); getApp().request.json_post("/api/weshop/marketing/help/help/task/involve/insert", data, //入参 function(res) { //成功 if (res.data.code == 0) th.setData({ is_show: 1 }); else { getApp().my_warnning(res.data.msg, 0, th) } }, function() { //失败 } ) }, //点击关闭礼盒 clike_none: function() { this.setData({is_show: 0}); getApp().goto("/pages/user/assistance/assistance_success?helpid="+this.data.helpId+"&taskId="+this.data.taskId); }, //导航球 close: function() { var th = this; var nav_b = th.selectComponent("#nav_b"); //组件的id nav_b.close_box(); nav_b.set_name("助力", "/pages/user/assistance/assistance"); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { }, })