friend_assistance.js
3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
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);
}
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.taskId;
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
}
})
}
return ut.null_promise();
}).then(res => {
if (res && res.data && res.data.code == 0) {
th.setData({
s_num: res.data.data.countAll
});
}
})
}
},
// 跳转到助力成功页
participate_activity: function() {
wx.navigateTo({
url: '/pages/user/assistance/assistance_success?helpid='+this.data.helpId,
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
//点击开启礼盒
cklie_button: function() {
var th = this;
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
};
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);
},
//导航球
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() {
},
})