operatingShow.js
8.52 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
// tabOperating/pages/operatingShow/operatingShow.js
import api from '../../api.js'
import { getYQInfo } from '~/store/index'
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
statusBarHeight: app.globalData.statusBarHeight + 43,
tableHeaderList: [
{
name: '日期',
propName: 'dataDateStr'
},
{
name: '营业额',
propName: 'orderMoneyTotal'
},
{
name: '工单量',
// propName: 'toShopTotal'
// propName: 'totalUpgrade'
propName: 'upgradeTotal'
},
{
name: '转化率',
propName: 'upgradeRate'
}
],
tableList: [],
// tableList: {
// totalOrderMoney: 0,
// totalAdd: 0,
// totalUpgrade: 0,
// totalUpgradeRate: null,
// list: []
// },
currentPage: 1,
pageSize: 20,
pages: 1,
dateObj: {
beginDateStr: ''
},
showPicker: false
},
showStorePicker() {
let { merchantRange } = this.data
merchantRange.length > 1 &&
this.setData({
showPicker: true
})
},
getStoreList(e) {
console.log(e)
let { value } = e.detail
getYQInfo(this.data.userInfo)
.then(result => {
// console.log(result)
let { merchantRange } = result
if (value) {
merchantRange = merchantRange.filter(item => item.merchantName.includes(value))
}
this.setData({
merchantRange
})
})
.catch(err => {})
},
navbarReady(e) {
let navBarHeight = e.detail.height
this.setData({
navBarHeight
})
},
jump() {
// console.log('back')
// let { refresh } = this.data
// wx.$router.back()
wx.$router.back()
// if (refresh) {
// wx.$router.reLaunch('tabOperating.index')
// } else {
// }
},
changePicker(e) {
let { value } = e.detail
let { merchantId } = this.data.merchantRange[value]
// 修改对应下标显示
app.globalData.yqdInfo.subIndex = value
let obj = {}
if (merchantId) obj.merchantId = merchantId
wx.$util.showLoading('加载中...')
api.swtichSubLoginInfo(obj).then(res => {
// console.log(res)
let { code, data, message } = res
wx.hideLoading()
if (code == 0) {
wx.$util.setUserInfo(data)
this.init(data)
// this.refresh()
this.initTime()
this.getAccumulateList()
this.getAccumulateCount()
} else {
this.showToast(message)
}
})
// this.setData({
// refresh: true
// })
this.tapPicker()
},
// 切换园区
tapPicker() {
this.setData({
moveArrow: !this.data.moveArrow
})
},
// 切换日历
tapCalendar() {
console.log(this.data.whiteArrow)
this.setData({
whiteArrow: !this.data.whiteArrow
})
},
init(userInfo) {
// app.
getYQInfo(userInfo)
.then(result => {
console.log(result)
this.setData({
...result
})
})
.catch(err => {})
// return
// if (!userInfo.isSuper && userInfo.merchantType && userInfo.userType == 2) {
// this.setData({
// merchantRange: [
// {
// merchantName: userInfo.merchantName
// }
// ],
// subIndex: 0
// })
// return
// }
// let all = {
// merchantName: '全部'
// }
// api.getYQList().then(res => {
// console.log(res)
// let { code, data } = res
// if (code == 0) {
// let subIndex = 0
// let arr = []
// if (data.length > 1) {
// if (userInfo.merchantId != userInfo.subLoginUser.merchantId) {
// data.map((e, index) => {
// if (e.merchantId == userInfo.subLoginUser.merchantId) subIndex = index + 1
// })
// }
// arr = [all, ...data]
// } else {
// arr = [
// {
// merchantName: userInfo.merchantName
// }
// ]
// }
// this.setData({
// merchantRange: arr,
// subIndex
// })
// }
// })
// this.getAccumulateList()
},
// 获取选中天数
rangeSelect(e) {
console.log(e.detail)
// let { date } = e.detail
// this.setTimeList(date)
let { date, type } = e.detail
let { dateObj } = this.data
// let dateObj
// let dateObj = {
// beginDateStr: date.start,
// endDateStr: date.end
// }
// dateObj.pointUnit = type ? 2 : 1
// 按月份
dateObj = Object.assign(dateObj, date)
// return
if (type) {
let [year, month] = date.end.split('-')
let day = this.getLastDay(year, month)
dateObj.beginDateStr = date.start + '-01'
dateObj.endDateStr = date.end + '-' + day
dateObj.pointUnit = 2
dateObj.type = 'month'
// }
} else {
// 按日期
dateObj.beginDateStr = date.start
dateObj.endDateStr = date.end
dateObj.pointUnit = 1
dateObj.type = 'day'
}
this.setData({
dateObj,
currentPage: 1
})
this.getAccumulateList()
this.getAccumulateCount()
},
getLastDay(year, month) {
var new_year = year //取当前的年份
var new_month = month++ //取下一个月的第一天,方便计算(最后一天不固定)
if (month > 12) {
new_month -= 12 //月份减
new_year++ //年份增
}
var new_date = new Date(new_year, new_month, 1) //取当年当月中的第一天
return new Date(new_date.getTime() - 1000 * 60 * 60 * 24).getDate() //获取当月最后一天日期
},
initTime() {
let today = new Date().format('yyyy-MM-dd')
let NewYearDay = new Date().format('yyyy')
console.log(NewYearDay)
this.setData({
dateObj: {
beginDateStr: NewYearDay + '-01-01',
endDateStr: today,
today: today,
pointUnit: 1, // 1日,2月,默认日
type: 'year',
label: NewYearDay
}
})
},
scrollonReachBottom() {
console.log('scrollonReachBottom')
let { pages, currentPage } = this.data
// 判断当前页是否是末页
if (pages == currentPage) return wx.$util.showToast('列表已到底')
this.setData({
currentPage: currentPage + 1
})
this.getAccumulateList()
},
restPageNum() {
console.log('restPageNum')
this.setData({
currentPage: 1
})
this.getAccumulateList()
},
getAccumulateCount() {
let {
dateObj: { beginDateStr, endDateStr }
} = this.data
let params = {
beginDateStr,
endDateStr
}
api
.accumulateCount(params)
.then(result => {
console.log(result)
let { code, data } = result
if (code == 0) {
this.setData({
tableObj: data
})
}
})
.catch(err => {
console.log(err)
})
},
getAccumulateList() {
// console.log('getAccumulateList')
// wx.$util.showLoading()
wx.$util.showLoading('加载中...')
let {
dateObj: { beginDateStr, endDateStr, pointUnit },
currentPage,
pageSize,
tableList
} = this.data
// let params = JSON.parse(JSON.stringify(dateObj))
let params = {
beginDateStr,
endDateStr,
pointUnit,
currentPage,
pageSize
}
api
.accumulatePage(params)
.then(result => {
wx.hideLoading()
console.log(result)
let { code, data } = result
if (code == '0') {
this.setData({
tableList: currentPage == 1 ? data.list : [...tableList, ...data.list],
// tableObj:data,
triggered: false,
pages: data.pages
})
}
})
.catch(err => {
console.log(err)
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.initTime()
this.getAccumulateList()
this.getAccumulateCount()
this.setData({
flag: true
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {}
})