personalCenter.js
12.5 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
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
// pages/personalCenter/personalCenter.js
var app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
tab_state: false,
withdraw_state: false,
currentTab: 0,
user_type: '',
page: 1,
user_info: [],
temp_UserType: '',
paylist: [],
popularize: [],
sharetext: '',
listmessages: [],
status: '',
},
charge() {
wx.redirectTo({
url: '/pages/start/start',
})
},
//点击切换
tabCharge(e) {
var that = this;
if (this.data.currentTab === e.target.dataset.current) {
return false;
} else {
that.setData({
currentTab: e.target.dataset.current
})
}
},
//展开收起
tabExpand(e) {
var index = e.currentTarget.dataset.index
var indexs = e.currentTarget.dataset.index
var paylist = this.data.paylist
paylist[index].tab_state = !(paylist[index].tab_state)
this.setData({
paylist: paylist
})
},
//展开收起
tabExpand2(e) {
var indexs = e.currentTarget.dataset.indexs
var listmessages = this.data.listmessages
listmessages[indexs].tab_state = !(listmessages[indexs].tab_state)
this.setData({
listmessages: listmessages,
})
},
//我要提现
withdraw() {
this.setData({
withdraw_state: true
})
},
//提现金额
setTbNum(e) {
let TbNum = e.detail.value;
this.setData({
TbNum: TbNum,
// maskstatu: true
})
},
//确认提现
confirmWithdrawal() {
var that = this
var popularize = that.data.popularize
var num = parseInt(popularize.tb) //1000
var balance = parseInt(popularize.balance) //我的TB
var TbNum = parseInt(that.data.TbNum) //输入TB
console.log('TbNum', TbNum)
if (TbNum == '' || TbNum == 'Nan') {
wx.showToast({
title: '请输入提现金额',
icon: 'none',
duration: 2000,
})
} else {
let url = 'popularize/withdraw';
let param = {
UserId: app.globalData.UserId,
TbNum: that.data.TbNum
}
app.post(url, param).then((res) => {
console.log(res)
if (res.data.data.type == 1) {
wx.showToast({
title: '正在人工审核',
icon: 'success',
duration: 2000,
mask: true,
})
} else if (res.data.data.type == -1) {
wx.showToast({
title: 'T币数值错误',
icon: 'none',
duration: 2000,
})
} else if (res.data.data.type == -2) {
wx.showToast({
title: '提现次数超出',
icon: 'none',
duration: 2000,
})
} else if (res.data.data.type == -3) {
wx.showToast({
title: '提现失败',
icon: 'none',
duration: 2000,
})
} else if (res.data.data.type == -4) {
wx.showToast({
title: '数据写入错误',
icon: 'none',
duration: 2000,
})
} else if (res.data.data.type == -5) {
wx.showToast({
title: '余额不足',
icon: 'none',
duration: 2000,
})
} else if (res.data.data.type == -6) {
wx.showToast({
title: '后台暂未设定合法格式',
icon: 'none',
duration: 2000,
})
}
setTimeout(function() {
that.getPersonanCenter()
}, 2000)
that.setData({
withdraw_state: false
})
})
}
// wx.showToast({
// title: '提交成功,请等待后台审核',
// success: function() {
// setTimeout(function() {
// that.setData({
// withdraw_state: false
// })
// }, 2000)
// }
// })
},
//修改个人资料
editInfo() {
wx.navigateTo({
url: '../index/editProfile/editProfile',
})
},
//T币交易记录
TB() {
if (app.globalData.UserType == 4) {
wx.showToast({
title: '暂无权限',
icon: 'none'
})
} else {
wx.navigateTo({
url: '../index/TB/TB',
})
}
},
//会员充值
vipCharge() {
if (app.globalData.UserType == 4) {
wx.showToast({
title: '暂无权限',
icon: 'none'
})
} else {
wx.navigateTo({
url: '../index/VipRecharge/VipRecharge',
})
}
},
//报告浏览记录
reportList() {
wx.navigateTo({
url: '../index/browseRecord/browseRecord',
})
},
//文章浏览记录
articlList() {
wx.navigateTo({
url: '../index/articleBrowseRecord/articleBrowseRecord',
})
},
//建议预设
suggest() {
wx.navigateTo({
url: '../index/Suggest/Suggest',
})
},
//方案预设
project() {
wx.navigateTo({
url: '../index/Program/Program',
})
},
//分享赚T币
share() {
if (app.globalData.UserType == 4) {
wx.showToast({
title: '暂无权限',
icon: 'none'
})
} else {
wx.navigateTo({
url: '../index/share/share',
})
}
},
//下载专属二维码
twoCode(e) {
let imgurl = e.currentTarget.dataset.imgurl
console.log(e)
if (app.globalData.UserType == 4 && app.globalData.user_index != 4) {
wx.showToast({
title: '暂无权限',
icon: 'none'
})
} else {
// wx.navigateTo({
// url: '../index/twoCode/twoCode',
// })
wx.navigateTo({
url: '/pages/index/twoCode/twoCode?imgurl=' + imgurl,
})
}
},
//邀请名单
inviteList() {
if (app.globalData.UserType == 4) {
wx.showToast({
title: '暂无权限',
icon: 'none'
})
} else {
wx.navigateTo({
url: '../index/inviteList/inviteList',
})
}
},
//7天到期提醒
remind() {
wx.navigateTo({
url: '../index/smartRemind/smartRemind',
})
},
//////////// 客户个人中心 ////////////////
//保单列表
policyList() {
wx.navigateTo({
url: '../index/policyList/policyList',
})
},
//体检报告
medicalReport() {
wx.navigateTo({
url: '../index/reportList2/reportList2',
})
},
//顾问认证
register() {
wx.navigateTo({
url: '../index/register/register',
})
},
//顾问信息
consultantInfo() {
wx.navigateTo({
url: '/pages/index/consultantList/consultantList',
})
},
////////// 推广员个人中心 ////////////////
//关闭弹窗
cancleMask() {
this.setData({
withdraw_state: false
})
},
// 个人中心页面接口调取
getPersonanCenter() {
let url = 'pubilc/user'
let params = {
UserId: app.globalData.UserId,
UserType: app.globalData.UserType,
Page: this.data.page
}
app.post(url, params).then((res) => {
console.log(res)
var paylist = res.data.data.paylog
for (var i in paylist) {
paylist[i].tab_state = false
}
if (res.data.code == 200) {
this.setData({
user_info: res.data.data.user, //用户基本数据
counselor: res.data.data.counselor, //顾问数据
popularize: res.data.data.popularize, //推广数据
paylist: paylist
})
}
}).catch((erro) => {
console.log(erro)
})
},
//分享页面接口
getShareData() {
let that = this;
let url = 'popularize/share';
app.post(url, {
UserId: app.globalData.UserId
}).then((res) => {
if (res.data.code == 200) {
var listmessages = res.data.data.listmessages;
for (var i in listmessages) {
listmessages[i].tab_state = false
}
that.setData({
sharetext: res.data.data.sharetext,
listmessages: listmessages,
status: res.data.data.status
})
}
}).catch((errMsg) => {
console.log(errMsg)
})
},
// 跳转二维码页
sharecode(e) {
let imgurl = e.currentTarget.dataset.imgurl
console.log(e.currentTarget.dataset.imgurl)
wx.navigateTo({
url: '/pages/index/twoCode/twoCode?imgurl=' + imgurl,
})
},
//输入的分享文字
shareText(e) {
this.setData({
sharetext: e.detail.value,
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
var that = this
that.setData({
user_type: app.globalData.UserType
})
console.log('user-type', that.data.user_type)
if (app.globalData.UserType === 2 && app.globalData.UserType === app.globalData.user_index) {
wx.setNavigationBarTitle({
title: '客户个人中心'
})
} else if (app.globalData.UserType === 2) {
wx.setNavigationBarTitle({
title: '客户个人中心'
})
} else if (app.globalData.UserType === 3 && app.globalData.UserType === app.globalData.user_index || app.globalData.temp_UserType == app.globalData.user_index) {
wx.setNavigationBarTitle({
title: '顾问个人中心'
})
that.setData({
temp_UserType: 3
})
} else if (app.globalData.UserType === 4 && app.globalData.UserType === app.globalData.user_index) {
wx.setNavigationBarTitle({
title: '传播大使个人中心'
})
}
that.getPersonanCenter()
that.getShareData();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
var that = this
that.setData({
user_type: app.globalData.UserType
})
console.log('user-type', that.data.user_type)
if (app.globalData.UserType === 2 && app.globalData.UserType === app.globalData.user_index) {
console.log(app.globalData.UserType, app.globalData.user_index)
wx.setNavigationBarTitle({
title: '客户个人中心'
})
} else if (app.globalData.UserType === 3 && app.globalData.UserType === app.globalData.user_index || app.globalData.temp_UserType == app.globalData.user_index) {
console.log(app.globalData.UserType, app.globalData.user_index)
wx.setNavigationBarTitle({
title: '顾问个人中心'
})
that.setData({
temp_UserType: 3
})
} else if (app.globalData.UserType === 4 && app.globalData.UserType === app.globalData.user_index) {
console.log(app.globalData.UserType, app.globalData.user_index)
wx.setNavigationBarTitle({
title: '传播大使个人中心'
})
}
that.getPersonanCenter()
this.getShareData()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function(options) {
var sharetext = options.target.dataset.sharetext
// 设置菜单中的转发按钮触发转发事件时的转发内容
var shareObj = {
title: "保险顾问专用客户和保单管理工具,诚邀使用!",
// 默认是小程序的名称(可以写slogan等)
path: '/pages/start/start?status =' + options.target.dataset.status + '&sharetext=' + sharetext,
// 默认是当前页面,必须是以‘/’开头的完整路径
imageUrl: '/images/bg.jpg',
//自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
success: function(res) {
// 转发成功之后的回调
if (res.errMsg == 'shareAppMessage:ok') {}
},
fail: function() {
// 转发失败之后的回调
if (res.errMsg == 'shareAppMessage:fail cancel') {
// 用户取消转发
} else if (res.errMsg == 'shareAppMessage:fail') {
// 转发失败,其中 detail message 为详细失败信息
}
},
complete: function() {
// 转发结束之后的回调(转发成不成功都会执行)
}
} // 来自页面内的按钮的转发
// if (options.from == 'button') {
// var sharetext = options.target.dataset.sharetext
// // 此处可以修改 shareObj 中的内容
// shareObj.path = '/pages/start/start?status=' + options.target.dataset.status + '&sharetext=' + sharetext
// shareObj.imgUrl= '/images/bg.jpg'
// } // 返回shareObj
return shareObj;
}
})