monthDetail.js
8.9 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
// pages/cityWide/monthDetail/monthDetail.js
const app = getApp();
var WxParse = require('../../../wxParse/wxParse.js');
Page({
/**
* 页面的初始数据
*/
data: {
activeid: '',
currTab: 0,
// monthStatr: true,
detailCon: '',
detailAddr: '',
imgCourse: [],
isFocus: false,
monthCon: '',
activeStau: 1,
addrestatus:'',
talkpeople: '',
lng:'',
lat:'',
code:false,
codeimg:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options)
let that = this;
let activeid = options.activeid;
that.setData({
activeid: activeid
})
// that.getDetail()
},
// 活动详情接口
getDetail: function(e){
let that = this;
let url = "/api/portal/Activity/detail";
let params = {
token: wx.getStorageSync('token'),
activityId: that.data.activeid
}
var header={
'token': wx.getStorageSync('token'),
}
app.post(url, params,header).then((res) => {
console.log(res)
WxParse.wxParse('article', 'html', res.activity.content, that, 5)
let statu = res.activity.is_save;
let activeType = res.activity.activity_type;
let isJoin = res.activity.is_join;
if (statu == 1){
that.setData({
isFocus: true
})
} else if (statu == 2){
that.setData({
isFocus: false
})
}
//报名人数
console.log(typeof(res.activity.sign))
if (res.activity.sign==null){
res.activity.sign=0
}
// 1是活动 2是微课 1是已报名 2是未报名
if (activeType == 1 && isJoin ==2) {
that.setData({
activeStau:1,
addrestatus:true,
talkpeople:false,
iconshow:true
})
wx.setNavigationBarTitle({
title: '活动详情' //页面切换,更换页面标题
})
} else if (activeType == 2 && isJoin ==2){
that.setData({
activeStau:2,
addrestatus: false,
talkpeople: true,
iconshow:false
})
wx.setNavigationBarTitle({
title: '微课详情' //页面切换,更换页面标题
})
} else if (activeType == 1 && isJoin == 1) {
that.setData({
activeStau: 3,
addrestatus: true,
talkpeople: false,
iconshow: true
})
wx.setNavigationBarTitle({
title: '活动详情' //页面切换,更换页面标题
})
} else if (activeType == 2 && isJoin == 1) {
that.setData({
activeStau: 4,
addrestatus: false,
talkpeople: true,
iconshow: false
})
wx.setNavigationBarTitle({
title: '微课详情' //页面切换,更换页面标题
})
}
that.setData({
detailCon: res.activity,
detailAddr: res.activity.addr,
imgCourse: res.sign,
monthCon: res.mes,
lng: res.activity.latng[0],
lat: res.activity.latng[1],
is_write:res.is_write
})
console.log(that.data.detailCon)
}).catch((errMsg) => {})
},
//链接去地图
gomap() {
console.log(88)
let that = this;
console.log(that.data.lat)
console.log(that.data.lng)
wx.getLocation({//获取当前经纬度
type: 'wgs84', //返回可以用于wx.openLocation的经纬度,官方提示bug: iOS 6.3.30 type 参数不生效,只会返回 wgs84 类型的坐标信息
success: function (res) {
wx.openLocation({//使用微信内置地图查看位置。
latitude: Number(that.data.lat),//要去的纬度-地址
longitude: Number(that.data.lng),//要去的经度-地址
name: that.data.detailCon.addr.addr,
address: that.data.detailCon.addr.addr,
})
}
})
console.log(that.data.lng)
},
// 点击切换
clickTab: function (e) {
var that = this;
if (that.data.currTab === e.target.dataset.current) {
return false;
} else {
that.setData({
currTab: e.target.dataset.current
})
}
},
// 跳转到 活动报名
activityTap:function(){
wx.navigateTo({
url: '../activityName/activityName?activeid=' + this.data.activeid,
})
},
//微课报名
listenlesson(){
let is_write = this.data.is_write;
if(is_write==1){
wx.navigateTo({
url: '../WeChatCulum/WeChatCulum?activeid=' + this.data.activeid,
})
}else{
wx.navigateTo({
url: '../../home/stageofpregnancy/stageofpregnancy',
})
}
},
submit: function (e) {
console.log(e)
console.log(typeof(e.detail.formId));
let that=this;
// let formId = e.detail.formId;
let is_write = that.data.is_write;
if (is_write == 1) {
var url = '/api/portal/Activity/joinCourse';
var params = {
token: wx.getStorageSync('token'),
activityId: this.data.activeid,
formId: e.detail.formId
}
app.post(url, params).then((res) => {
console.log(res);
wx.navigateTo({
url: '../WeChatCulum/WeChatCulum?activeid=' + this.data.activeid,
})
}).catch((err) => {
})
} else {
wx.navigateTo({
url: '../../home/stageofpregnancy/stageofpregnancy',
})
}
},
// 跳转到 报名名单
listTap:function(){
wx.navigateTo({
url: '../nameList/nameList?activeid=' + this.data.activeid,
})
},
// 跳转到 发表点评
markTap:function(){
wx.navigateTo({
url: '../remark/remark?activeid=' + this.data.activeid,
})
},
// 跳转到 微信直播课程
lectureTap: function(){
wx.navigateTo({
url: '../WeChatCulum/WeChatCulum?activeid=' + this.data.activeid,
})
},
// 点击收藏成功
favoriteTab: function (e) {
let that = this;
let isFocus = that.data.isFocus;
let url = "/api/portal/Activity/save";
let params = {
token: wx.getStorageSync('token'),
activityId: that.data.activeid
}
app.post(url, params).then((res) => {
wx.showToast({
title: "收藏成功",
icon: 'success',
duration: 1000
});
that.setData({
isFocus: true
})
}).catch((errMsg) => {})
},
// 取消收藏
cancelCollect: function(e){
let that = this;
let isFocus = that.data.isFocus;
let url = "/api/portal/Activity/saveDel";
let params = {
token: wx.getStorageSync('token'),
activityId: that.data.activeid
}
app.post(url, params).then((res) => {
wx.showToast({
title: "取消收藏",
icon: 'success',
duration: 1000
});
that.setData({
isFocus: false
})
}).catch((errMsg) => { })
},
//微课二维码
seecode(){
let that = this;
that.setData({
code:true
})
var url = '/api/portal/Activity/pic';
var params = {
token: wx.getStorageSync('token'),
activityId: that.data.activeid
}
app.post(url, params).then((res) => {
console.log(res);
that.setData({
codeimg:res.url
})
}).catch((err) => {
})
},
hidecode(){
this.setData({
code:false
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.getDetail()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
let that = this;
let activeid = that.data.activeid;
console.log(activeid)
return {
title: '活动详情分享', // 转发后 所显示的title
// path: '/pages/home/buildtextdetail/buildtextdetail?buildid='+buildid+'&gettoken='+newtoken, // 相对的路径
path:'/pages/index/index?activeid='+activeid +'&status='+5,//微课详情
// path: '/pages/index/index?childrenid',
success: (res) =>{ // 成功后要做的事情
console.log(res)
// console.log(res.shareTickets[0])
// console.log
// wx.getShareInfo({
// shareTicket: res.shareTickets[0],
// success: (res)=> {
// that.setData({
// isShow:true
// })
// console.log(that.setData.isShow)
// },
// fail: function (res) { console.log(res) },
// complete: function (res) { console.log(res) }
// })
},
fail: function (res) {
// 分享失败
console.log(res)
}
}
}
})