diff --git a/pages/user/assistance/assistance.js b/pages/user/assistance/assistance.js
index 8d29625..df28cf6 100644
--- a/pages/user/assistance/assistance.js
+++ b/pages/user/assistance/assistance.js
@@ -6,7 +6,7 @@ var t = getApp(),
ut = i,
s = require("../../../utils/common.js");
var regeneratorRuntime = require('../../../utils/runtime.js');
-var oo = t.globalData.setting;
+var oo = t.globalData.setting,os=oo, ut= require("../../../utils/util.js");
Page({
/**
@@ -24,6 +24,7 @@ Page({
is_show_more: 0, //是否加载更多
help_id:"",//助力活动的id
timer:"",//任务列表的定时器
+ s_num:"",//多少人已经领取任务
},
@@ -50,29 +51,36 @@ Page({
},
// 助力活动
- async assistance() {
+ assistance() {
var th=this;
var user_id = getApp().globalData.user_id;
var store_id = os.stoid;
- await getApp().request.promiseGet("/api/weshop/marketing/help/act/judge", {
+ getApp().request.promiseGet("/api/weshop/marketing/help/act/judge", {
data: {
storeId: store_id,
userId: user_id
}
}).then(res => {
if (res.data.code == 0) {
-
+
var help_data=res.data.data;
console.log(help_data.id,'数据', res.data.data);
- th.setData({
- zl_act:help_data,
- help_id:help_data.id
- });
+ th.setData({ zl_act:help_data, help_id:help_data.id });
+ return getApp().request.promiseGet("/api/weshop/marketing/help/involve/help/act/people/count", {
+ data: {
+ helpId: help_data.id, storeId: store_id
+ }
+ })
}
- })
-
+ return ut.null_promise();
+ }).then(res=>{
+ if(res.data.code==0)
+ th.setData({s_num:res.data.data.countAll})
+ })
+
+
},
//--点击获取用户任务列表--会员的任务列表
diff --git a/pages/user/assistance/assistance.wxml b/pages/user/assistance/assistance.wxml
index 2fce9ba..eb5cf9b 100644
--- a/pages/user/assistance/assistance.wxml
+++ b/pages/user/assistance/assistance.wxml
@@ -76,10 +76,10 @@
暂无任务记录
-
+
已有
- {{zl_act.countAll}}
+ {{s_num}}
人领取了任务
diff --git a/pages/user/assistance/assistance_success.js b/pages/user/assistance/assistance_success.js
index 9603900..bec86b9 100644
--- a/pages/user/assistance/assistance_success.js
+++ b/pages/user/assistance/assistance_success.js
@@ -1,6 +1,7 @@
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({
/**
@@ -10,6 +11,7 @@ Page({
iurl: s.imghost,
user:app_d.userInfo,
zl_act:null, //助力活动
+ s_num:0, //分享的人数
},
/**
@@ -18,42 +20,44 @@ Page({
onLoad: function (options) {
},
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
/**
* 生命周期函数--监听页面显示
*/
- onShow: function () {
- this.init();
+ onShow: function (e) {
+ var helpid=e.helpid;
+ this.init(helpid);
},
// ----初始化----
- init:function() {
-
+ init:function(helpid) {
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", {
+
+ //链式调用接口,先获取活动,在获取参与活动的人数
+ getApp().request.promiseGet("/api/weshop/marketing/help/help/user/page", {
data: {
- user_id: user_id,
- store_id: store_id
+ userId: app_d.user_id,
+ storeId: os.store_id,
+ helpId: helpid
}
}).then(res => {
- if(res.data.code==0) th.setData({zl_act:res.data.data})
- })
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
+ 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: {
+ storeId: os.store_id,
+ helpId: helpid
+ }
+ })
+ }
+ return ut.null_promise();
+
+ }).then(res=>{
+ if(res.data.code==0){
+ th.setData({s_num:res.data.data.countAll});
+ }
+ })
},
@@ -65,10 +69,4 @@ Page({
},
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
- }
})
\ No newline at end of file
diff --git a/pages/user/assistance/assistance_success.wxml b/pages/user/assistance/assistance_success.wxml
index 40188e9..678c94e 100644
--- a/pages/user/assistance/assistance_success.wxml
+++ b/pages/user/assistance/assistance_success.wxml
@@ -17,7 +17,7 @@
我也要参加
-已有{{zl_act.qiang_num}}人领取礼盒
+已有{{s_num}}人领取礼盒
diff --git a/pages/user/assistance/friend_assistance.js b/pages/user/assistance/friend_assistance.js
index 8d8d194..7588929 100644
--- a/pages/user/assistance/friend_assistance.js
+++ b/pages/user/assistance/friend_assistance.js
@@ -1,141 +1,150 @@
-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 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, //助力活动
+ task_id: 0, //助力任务ID
+ userId: 0, //任务用户的ID
+ s_num: 0, //分享的人数
+ },
- /**
- * 页面的初始数据
- */
- 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;
+ if (options.task_id) this.data.task_id = options.task_id;
+ if (options.userId) 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 != null && this.data.task_id != 'undefined' && this.data.task_id != "" && this.data.task_id !=
+ 0) {
+ getApp().request.promiseGet("/api/weshop/marketing/help/help/tasking/get", {
+ data: {
+ id: th.data.task_id,
+ storeId: os.stoid
+ }
+ }).then(res => {
+ if (res.data.code == 0) {
+ th.data.userId = res.data.data.user_id;
+ //获取活动的时间
+ return getApp().request.promiseGet("/api/weshop/marketing/help/help/act/get", {
+ data: {
+ id: th.data.task_id,
+ 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
+ }
+ })
+ }
+ return ut.null_promise();
+ }).then(res => {
+ if (res.data.code == 0) {
+ th.setData({
+ s_num: res.data.data.countAll
+ });
+ }
+ })
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- var th=this;
- if(options.task_id) this.data.task_id=options.task_id;
- if(options.userId) 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!=null && this.data.task_id!='undefined' && this.data.task_id!="" && this.data.task_id!=0){
- 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;
- }
- }
- })
-
- }
- }
- },
+ }
+ }
+ },
- // 跳转到助力成功页
- participate_activity:function(){
- wx.navigateTo({
- url: '/pages/user/assistance/assistance_success',
- })
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.init();
- },
- //点击开启礼盒
- cklie_button:function(){
- var th=this;
- var t_user_id=app_d.user_id;
- var data={id:this.data.task_id,storeId:os.stoid,userId:this.data.user_id, zlUserId:t_user_id};
- console.log(data);
- 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(){
- this.setData({ is_show:0});
- },
- //导航球
- close: function () {
- var th = this;
- var nav_b = th.selectComponent("#nav_b"); //组件的id
- nav_b.close_box();
- nav_b.set_name("助力", "");
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
+ // 跳转到助力成功页
+ participate_activity: function() {
+ wx.navigateTo({
+ url: '/pages/user/assistance/assistance_success',
+ })
+ },
- },
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow: function() {
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
+ },
+ //点击开启礼盒
+ cklie_button: function() {
+ var th = this;
+ var t_user_id = app_d.user_id;
+ var data = {
+ id: this.data.task_id,
+ storeId: os.stoid,
+ userId: this.data.user_id,
+ zlUserId: t_user_id
+ };
+ console.log(data);
+ 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() { //失败
- },
+ }
+ )
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
+ },
+ //点击关闭礼盒
+ clike_none: function() {
+ this.setData({
+ is_show: 0
+ });
+ },
+ //导航球
+ close: function() {
+ var th = this;
+ var nav_b = th.selectComponent("#nav_b"); //组件的id
+ nav_b.close_box();
+ nav_b.set_name("助力", "");
+ },
- },
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom: function() {
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
+ },
- },
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage: function() {
- /**
- * 用户点击右上角分享
- */
- 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/index/index.js b/pages/user/index/index.js
index 8568ec1..b89522e 100644
--- a/pages/user/index/index.js
+++ b/pages/user/index/index.js
@@ -51,14 +51,15 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
- this.birthday();
- this.is_assistance();
+ this.birthday();
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
+
+ this.is_assistance();
var stoid = app_d.setting.stoid;
var s = this,th=s,need_money=0,cur_g_num=0;
@@ -128,10 +129,12 @@ Page({
await getApp().request.promiseGet("/api/weshop/users/grade/aftervipinfo/get",{
data:{ storeId:os.stoid,userId:app_d.user_id }
}).then(res=>{
- gid=res.data.data.GradeId;
- var cz_val = res.data.data.GradeSum;
- cz_vals=parseInt(cz_val);
- GradeName=res.data.data.GradeName;
+ if (res.data.code == 0 && res.data.data){
+ gid=res.data.data.GradeId;
+ var cz_val = res.data.data.GradeSum;
+ cz_vals=parseInt(cz_val);
+ GradeName=res.data.data.GradeName;
+ }
//th.setData({ cz_val: cz_vals, GradeName: res.data.data.GradeName, is_init: is_init, gradeId: gid});
})
var obj = { cz_val: cz_vals, GradeName:GradeName, is_init: is_init, gradeId: gid };
diff --git a/utils/util.js b/utils/util.js
index 5de0a30..d99accd 100644
--- a/utils/util.js
+++ b/utils/util.js
@@ -1,4 +1,3 @@
-
function isString(str) {
return (typeof str == 'string') && str.constructor == String;
}
@@ -309,6 +308,11 @@ function draw_randon_rect(ctx,x,y,r,w,h){
}
+
+function null_promise(){
+ var promise=new Promise(function(resolve, reject){ var ob={code:-1,data:null}; resolve(ob); }); return promise;
+}
+
module.exports = {
formatTime: function(e, r) {
var t = e ? new Date(1e3 * e) : new Date(), n = t.getFullYear(), o = t.getMonth() + 1, a = t.getDate(), u = t.getHours(), i = t.getMinutes(), f = t.getSeconds(), s = function(e) {