clue.js
8.91 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
// packagesList/mineDetail/pages/clue.js
import { IMG_URL } from '~/utils/constantData.js'
import { unreadApi, pageApi, tagApi } from '~/api/index.js'
const IMAGES = Object.freeze({
arrow: `${IMG_URL}/index/point.png`,
actArrow: `${IMG_URL}/index/actArrow.png`
})
Page({
/**
* 页面的初始数据
*/
data: {
IMAGES,
IMG_URL,
disLikeRecordFlag: true,
typeList: [
{
0: '无电话',
1: '有电话',
2: '联系电话',
selectIndex: 2,
key: 'hasPhone'
},
{
0: '非意向客户',
1: '是意向客户',
2: '意向客户',
selectIndex: 2,
key: 'starTag'
},
{
0: '来自访客',
1: '来自门店',
2: '线索来源',
selectIndex: 2,
key: 'clueSource'
},
{
2: '重置',
selectIndex: 2
}
],
levelTagObj: {
1: {
label: '初步了解'
},
2: {
label: '深入了解',
class: 'tag-red'
},
3: {
label: '签约成交',
class: 'tag-blue'
}
},
clueList: [],
// 看线索部分
unreadClueCount: 0,
cluePageSize: 1000,
clueCurrentPage: 1,
disLikeFlag: true,
clueParams: {} //看线索参数
},
//点击收藏
showToast: function (e) {
wx.$storage.set('disLikeRecordFlag', false)
let disLikeRecordFlag = wx.$storage.get('disLikeRecordFlag')
this.setData({
disLikeFlag: false,
disLikeRecordFlag
})
let { type, item } = e.currentTarget.dataset
// console.log('type,item: ', type, item)
let tipObj = {}
if (item.starTag == 1) {
tipObj = {
type: 'fail',
title: '取消标记为意向客户'
}
} else {
tipObj = {
type: 'success',
title: '成功标记为意向客户'
}
}
this.data.prompt.showToast({
type: tipObj.type,
title: tipObj.title,
duration: 1000,
compelete: function () {
// console.log("toast框隐藏之后,会调用该函数");
//例如:跳转页面wx.navigateTo({ url: 'xxx' });
}
})
//切换收藏标记
let index = e.currentTarget.dataset.outidx
let completeStatus = `clueList[${index}].like`
this.setData({
[completeStatus]: !this.data.clueList[index].like
})
//发请求
let { sessionId } = wx.$storage.get()
let params = {
clueId: item.clueId,
sessionId
}
this.getTagApi(params)
},
//看线索重置
resetCluelist() {
let { typeList } = this.data
typeList.forEach(item => {
item.selectIndex = 2
})
this.setData({
typeList,
clueParams: {}
})
//重置数据
this.clearclueData()
this.getPageApi()
},
filterTypeFn(e) {
let { typeList } = this.data
let index = e.currentTarget.dataset.index
// 重置筛选
if (index == 3) {
return this.resetCluelist()
}
let itemList = Object.values(typeList[index]).slice(0, 2)
itemList.push('全部')
let _this = this
wx.pro.showActionSheet({
itemList,
success(res) {
//重置数据
_this.clearclueData()
// 选中全部
let selectIndex = res.tapIndex
// console.log('selectIndex: ', selectIndex);
typeList[index].selectIndex = selectIndex
let params = typeList.reduce((obj, item, index) => {
// console.log(' item: ', item)
if (item['key']) {
let itemIndx = item.selectIndex
// key: 'clueSource'
if (item['key'] == 'clueSource') {
// itemIndx += 1
obj[item['key']] = itemIndx == 2 ? '' : itemIndx + 1
} else {
obj[item['key']] = itemIndx == 2 ? '' : itemIndx
}
}
return obj
}, {})
// console.log(params)
// 清空数据
_this.setData({ typeList, clueParams: params })
_this.getPageApi(params)
},
fail(res) {
// console.log(res.errMsg)
}
})
},
//重置数据
clearclueData() {
this.setData({
clueList: [],
clueCurrentPage: 1
// hasPhone: '',
// starTag: '',
// clueSource: '',
})
},
// 打电话
phoneCallFn(e) {
let { phone } = e.currentTarget.dataset
wx.$api.phoneCall(phone)
},
// 复制号码
setCopyDataFn(e) {
let { phone } = e.currentTarget.dataset
wx.$api.setCopyData(phone)
},
getClueInit(param) {
this.getUnreadApi(param)
this.getPageApi(param)
},
//未读消息
async getUnreadApi(param) {
let { code, data } = await unreadApi(param)
if (code == 0) {
this.setData({
unreadClueCount: data.unreadClueCount
})
}
},
//获取浏览线索数据列表
async getPageApi(param) {
let { cluePageSize, clueCurrentPage, clueList } = this.data
let params = {
pageSize: cluePageSize,
currentPage: clueCurrentPage,
...param
}
let { code, data } = await pageApi(params)
if (code == 0) {
let arr = data.list.map(item => {
if (item.visitList && item.visitList.length > 5) {
item.getMoreFlag = true
}
return item
})
//添加分页数据
// let concatArr = []
// if(arr.length > 0) {
// concatArr = clueList.concat(arr)
// }
this.setData({
clueList: arr
})
let arrinx = arr.findIndex(e => e.clueType == 1 && e.starTag == 0)
this.setData({
disLikeFlagIdx: arrinx,
triggered: false
})
}
},
//喜欢收藏功能
async getTagApi(param) {
let { clueParams } = this.data
let res = await tagApi(param)
if (res.code == 0) {
let clueListPamas = {
...param,
...clueParams
}
this.getPageApi(clueListPamas)
}
},
// 上拉刷新
scrolltolowerFn() {
let { clueCurrentPage, clueParams } = this.data
let params = {
...clueParams,
clueCurrentPage: clueCurrentPage++
}
this.setData({
clueCurrentPage
})
this.getPageApi(params)
},
// 下拉刷新
refreshList() {
// console.log('onPullDownRefresh: ');
let { clueParams } = this.data
this.getClueInit(clueParams)
// this.resetCluelist()
// this.onLoad()
wx.pro.showToast({
title: '刷新成功',
icon: 'success',
duration: 1500
})
},
gotoApply(e) {
let { type, item } = e.currentTarget.dataset
// let { } = e.currentTarget.dataset
// console.log(item)
// return
if (type == 'active') {
let { userInfo } = wx.$storage.get()
let pMerchantName = userInfo.subLoginUser.merchantName
let pMerchantId = userInfo.subLoginUser.merchantId
// let sceneActive
// switch (this.data.actNum) {
// case 0:
// sceneActive = 1
// break
// case 1:
// sceneActive = 2
// break
// case 2:
// sceneActive = 3
// break
// case 3:
// sceneActive = 4
// break
// }
// let pMerchantId = userInfo.subLoginUser.merchantId
// console.log("type,item: ", type, item);
const params = {
merchantInfo: {
pMerchantId,
pMerchantName,
merchantId: item.visitList[0].merchantId,
merchantName: item.visitList[0].merchantName
},
// sceneActive,
clueId: item.clueId
// sceneCodeList: ['SC001', 'SC002','SC003','SC004']
}
//申请活动
// wx.$router.go("packageOutput.openBusiness", params);
wx.$router.go('packagesList.openBusiness', params)
} else {
//申请门店
// let { type, item } = e.currentTarget.dataset
wx.$router.go('packagesList.apply', item?.clueId || '')
}
// wx.$router.go('apply',1235)
},
getMore(e) {
// console.log("显示更多数据");
let index = e.currentTarget.dataset.outidx
// console.log("index: ", index);
let completeStatus = `clueList[${index}].getMoreFlag`
this.setData({
[completeStatus]: !this.data.clueList[index].getMoreFlag
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// 看线索
this.getClueInit()
this.data.prompt = this.selectComponent('#toast')
let disLikeRecordFlag = wx.$storage.get('disLikeRecordFlag')
this.setData({
disLikeRecordFlag
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})