index.js
5.4 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
import ActivityApi from "~/api/activityApi/index"
import Dialog from '@vant/weapp/dialog/dialog';
Page({
data: {
showFilter: false,
showComfirm: false,
filtterName: '时间',
showTip: true,
// 筛选初始化状态标识
filterInit: true,
customerList: [],
total: 0,
pageNum: 1,
pageSize: 20,
noResult: false,
levelQuery: {
'PC0036': '续保惠享A套餐',
'PC0037': '续保优享B套餐',
'PC0038': '续保乐享C套餐',
'PC0039': '续保尊享D套餐',
}
},
onLoad(options) {
this.setNaviTitle(options.type)
this.setData({
pageType: +options.type
})
if (options.type == 1) {
this.getSendCustomerList()
} else {
this.getListData()
}
},
setNaviTitle(type) {
let _title = type == 1 ? '已赠送客户' : '意向客户'
wx.setNavigationBarTitle({
title: _title
})
},
getFilterResult(e) {
const _obj = e.detail
const { pageType } = this.data
let _setQuery = {
filterQuery: _obj,
pageNum: 1
}
if (pageType == 1) {
delete _obj.status
_setQuery.filtterName = _obj.time.name
}
if (pageType == 0) {
let _isAll = _obj.time.type === 0 && _obj.status.type === 0
_setQuery.filterInit = _isAll
}
this.setData(_setQuery, () => {
if (pageType == 1) {
this.getSendCustomerList(_setQuery)
} else {
this.getListData(_setQuery)
}
})
},
toInt(e) {
this.customerInfo = e.detail.value
},
toSearch() {
const { pageType } = this.data
this.data.pageNum = 1
if (pageType == 1) {
this.getSendCustomerList(this.condition)
} else {
this.getListData(this.condition)
}
},
toShowComfirm(e) {
let { item } = e.currentTarget.dataset
this.setData({
showComfirm: true,
showTip: false,
currentItem: item
})
},
toShowFilter() {
this.setData({
showFilter: true
})
},
onClose() {
this.setData({
showComfirm: false
})
},
onConfirm() {
this.updateStatus()
},
toCall(e) {
let _phone = e.currentTarget.dataset.phone
if (!_phone) return
wx.makePhoneCall({
phoneNumber: _phone
})
},
/**获取列表数据 */
getListData(condition, isScroll) {
let { pageNum, customerList, pageSize } = this.data
let _para = {
pageNum,
pageSize,
}
if (this.customerInfo) {
_para.customerInfo = this.customerInfo
}
if (condition) {
this.condition = condition
const { status, time } = condition.filterQuery
if (time.type) {
_para.recentlyDateFlag = time.type
}
if (status.type) {
_para.followUpFlag = status.type
}
}
if (isScroll) {
Object.assign(_para, this.scrollQuery)
}
this.scrollQuery = { ..._para }
ActivityApi.getFollowCustomer(_para).then(res => {
this.setData({
noResult: pageNum > 1 ? false : res.list.length == 0,
total: res.total,
customerList: pageNum > 1 ? [...customerList, ...res.list] : res.list,
})
})
},
/**更新跟进状态 */
updateStatus() {
const { currentItem } = this.data
let _query = {
id: currentItem.id,
followUpFlag: currentItem.followUpFlag == 1 ? 2 : 1
}
ActivityApi.updateFollowStatus(_query).then(res => {
if (res) {
this.getListData()
wx.$api.showToast('操作成功')
this.onClose()
}
})
},
onReachBottom: function () {
let { pageNum, total, pageSize, pageType } = this.data
// 判断当前页是否是末页
// if (Math.floor(total / pageSize) == pageNum - 1) return
if (pageNum * pageSize >= total) return
this.setData({
pageNum: pageNum + 1
}, () => {
delete this.scrollQuery.pageNum
if (pageType == 1) {
this.getSendCustomerList(null, true)
} else {
this.getListData(null, true)
}
})
},
/** 获取赠送客户列表*/
getSendCustomerList(condition, isScroll) {
let { pageNum, customerList, pageSize } = this.data
let _para = {
pageNum,
pageSize,
}
if (this.customerInfo) {
_para.customerInfo = this.customerInfo
}
if (condition) {
this.condition = condition
const { time } = condition.filterQuery
if (time.type) {
_para.recentlyDateFlag = time.type
}
}
if (isScroll) {
Object.assign(_para, this.scrollQuery)
}
this.scrollQuery = { ..._para }
ActivityApi.getSendFollowList(_para).then(res => {
this.setData({
noResult: pageNum > 1 ? false : res.list.length == 0,
total: res.total,
customerList: pageNum > 1 ? [...customerList, ...res.list] : res.list,
})
})
},
/**导出 */
toExportFile() {
const { pageType } = this.data
wx.$api.showLoading('正在导出...')
const name = pageType == 1 ? 'exportSendFollowList' : 'exportFollowCount'
ActivityApi[name]().then(ress => {
if (ress) {
wx.hideLoading();
this.exportModal(ress)
}
})
},
// 导出弹框
exportModal(url) {
Dialog.confirm({
title: '温馨提示',
message: `导出数据已生成,请复制地址到手机\n浏览器中打开`,
confirmButtonText: "复制链接",
cancelButtonText: "取消",
}).then(() => {
wx.setClipboardData({
data: url,
success() {},
})
}).catch(() => {
})
},
})