client.js
8.83 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
// pages/tab/output/components/client/client.js
import outputApi from '~/api/outputApi/index'
import { IMG_URL } from '~/utils/constantData'
Component({
/**
* 组件的属性列表
*/
options: {
addGlobalClass: true
},
properties: {},
options: {
styleIsolation: 'shared'
},
/**
* 组件的初始数据
*/
data: {
IMGURL: IMG_URL,
pMerchantId: '',
totalProfit: 0,
pageObj: {
currentPage: 1,
pageSize: 10
},
totalPages: -1,
list: [],
sceneCodeList: ['SC002', 'SC003', 'SC004', 'SC001'],
tabActive: 'store',
// 业务经营汇总
stickyScrollTop: 0,
stickyOffsetTop: 0,
formData: {
// 0:全部-1;1:精品升级SC002;2:售后众筹SC004;3:会员权益/升级SC001
busiIdx: 0,
sceneCode: '-1',
// 时间筛选Idx(全部,精品升级,会员权益)
timeIdx: 0,
// 产品/状态筛选Idx(售后众筹)
proIdx: 0,
statusIdx: 0
},
busiObj: {},
busiTotalList: [],
merchantName4s: '',
crowdOrderObj: {}
},
lifetimes: {
attached() {
wx.$eventbus.on('clientRefresh', res => {
this.getBusinessData()
})
this.getBusinessData()
}
},
/**
* 组件的方法列表
*/
methods: {
getBusinessData() {
this.getBusiStatistics()
},
// 升降序
handleSort() {
this.getBusiStatistics(true)
},
// 吸顶
handleBusiScroll: wx.$util.debounce(function (e) {
this.setData({
stickyScrollTop: e?.detail?.scrollTop
})
}, 50),
resetBusiData() {
this.setData({
busiObj: {},
busiTotalList: [],
crowdOrderObj: {}
})
},
getBusiStatistics(isReset = false, isBusiTab = false) {
let sortTabModule = this.selectComponent('#sortTab')
if (sortTabModule && isBusiTab) {
sortTabModule.resetAllAsc()
}
let sortSearchData = sortTabModule ? sortTabModule.dealParams() : {}
let { subMerchant } = wx.$storage.get()
let params = {
...sortSearchData,
merchantIds: subMerchant,
}
outputApi.getBusiStatistics(params).then(res => {
this.resetBusiData()
if (isReset) {
this.setData({
busiScrollTop: 0
})
}
this.setData({
triggered: false
})
let _list = []
_list = res.merchantList || []
// 0:全部-1;1:精品升级SC002;2:售后众筹SC004;3:会员权益/升级SC001
let _openList = [{
code: 'SC002',
name: 'boutiqueUpgrade',
type: 1,
}, {
code: 'SC004',
name: 'afterSalesCrowdfunding',
type: 0,
}, {
code: 'SC001',
name: 'vdUpgrade',
type: 2,
}, {
code: 'usedCarFlag',
name: 'usedCarTotal',
type: 4,
}]
_list.forEach(item => {
_openList.forEach(k => {
if (k.code === 'usedCarFlag') {
// 二手车特殊处理:根据usedCarFlag值判断是否开通(1:开通,0:未开通)
if (item.usedCarFlag !== 1) item[k.name] = '未开通'
// item[k.name] = item.usedCarFlag === 1 ? '' : '未开通'
} else if (!item.sceneCodes) {
item[k.name] = '未开通'
} else if (item.sceneCodes && !item.sceneCodes.includes(k.code)) {
item[k.name] = '未开通'
}
})
})
this.setData({
merchantName4s: '',
busiObj: res,
totalProfit: res.totalAmount,
busiTotalList: _list,
busiTotalListFirst: _list
})
})
},
// 门店经营汇总-start
getPMerchantInfo() {
let { userInfo } = wx.$storage.get()
this.setData({
pMerchantInfo: userInfo,
pMerchantId: userInfo.subLoginUser.merchantId
})
},
onBindRefresh() {
this.clientRefresh(true)
},
handleBlur(e) {
const merchantName4s = e.detail.value;
const { busiTotalListFirst } = this.data
this.setData({
busiTotalList: busiTotalListFirst.filter(item => item.merchantName4s.includes(merchantName4s))
})
},
clientRefresh(isPull = false) {
this.getPMerchantInfo()
this.setData({
['pageObj.currentPage']: 1,
list: []
})
this.getClientApi(isPull)
},
getClientApi(isPull = false) {
// this.getProfit()
// this.getList()
isPull &&
wx.$api.showToast({
title: '刷新成功',
icon: 'success'
})
if (this.data.pageObj.currentPage == 1) {
this.setData({
scrollTop: 0,
triggered: false
})
}
},
getList() {
let { sceneCodeList } = this.data
outputApi.getCustomerPageList({ merchantId: this.data.pMerchantId, ...this.data.pageObj }).then(res => {
var list = this.data.list
list = list.concat(res.list)
list.forEach((item, index) => {
item.scenePriceList = []
item.sceneList.forEach((k, idx) => {
item['scene' + (idx + 1)] = item.sceneList[idx].flag
let i = sceneCodeList.findIndex(m => m == k.sceneCode)
item.scenePriceList[i] = {
total: item.sceneList[idx].totalMoney || 0
}
})
item.isOpenScene = item.sceneList.map(item => item.flag).some(item => item == true)
})
this.setData({
list: list,
totalPages: res.pages
})
})
},
onReachBottom() {
if (this.data.totalPages != -1 && this.data.pageObj.currentPage == this.data.totalPages) {
return true
}
this.setData({
['pageObj.currentPage']: this.data.pageObj.currentPage + 1
})
this.getClientApi()
},
handleJumpIdx() {
wx.$router.go('pages.index')
},
async handleShare(e) {
let { idx } = e.currentTarget.dataset
var item = {
activityId: this.data.list[idx].activityLastUnSharedInfo.id,
activityName: this.data.list[idx].activityLastUnSharedInfo.activityName
}
wx.$api.showLoading('加载中...')
outputApi
.getPosterUrl({
id: item.activityId
})
.then(res => {
item.posterUrl = res
this.setData({
posterItem: item,
isShowTip: false
})
})
.catch(() => {
wx.$api.showToast('下载海报失败')
})
},
/**长按海报 */
async longtouch(e) {
this.clientRefresh()
let { activityId } = e.detail
const res = await outputApi.reportPosterTrack({
activityId
})
},
handleJump(e) {
let { idx } = e.currentTarget.dataset
var currentItem = this.data.list[idx]
var params = {
merchantId: currentItem.merchantId,
merchantName: currentItem.merchantName,
pMerchantId: this.data.pMerchantId,
pMerchantName: this.data.pMerchantInfo.subLoginUser.merchantName,
isSuper: this.data.pMerchantInfo.isSuper
}
wx.$router.go('/packagesList/packageOutput/pages/summary', params)
}
// 门店经营汇总-end
}
})