client.js
3.04 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
// pages/tab/output/components/client/client.js
import outputApi from '~/api/outputApi/index'
import { IMG_URL } from '~/utils/constantData'
Component({
/**
* 组件的属性列表
*/
properties: {
},
options: {
styleIsolation: 'shared'
},
/**
* 组件的初始数据
*/
data: {
IMGURL: IMG_URL,
pMerchantId: '',
totalProfit: 0,
pageObj: {
currentPage: 1,
pageSize: 10
},
totalPages: -1,
list: []
},
lifetimes: {
attached() {
this.getPMerchantInfo()
this.getClientApi()
}
},
/**
* 组件的方法列表
*/
methods: {
getPMerchantInfo() {
let { userInfo } = wx.$storage.get()
this.setData({
pMerchantInfo: userInfo,
pMerchantId: userInfo.subLoginUser.merchantId
})
},
onBindRefresh() {
this.clientRefresh(true)
},
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('刷新成功')
if (this.data.pageObj.currentPage == 1) {
this.setData({
scrollTop: 0,
triggered: false
})
}
},
getProfit() {
outputApi.getMerchantTotal({ merchantId: this.data.pMerchantId }).then(res => {
this.setData({
totalProfit: res
})
})
},
getList() {
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.sceneList.forEach((k, idx) => {
item['scene' + (idx + 1)] = item.sceneList[idx].flag
})
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')
},
handleJump(e) {
let { idx } = e.currentTarget.dataset
var currentItem = this.data.list[idx]
var params = {
merchantId: currentItem.merchantId,
merchantName: currentItem.merchantName,
scene1: currentItem.scene1,
scene2: currentItem.scene2,
scene3: currentItem.scene3,
scene4: currentItem.scene4,
sceneCodeList: currentItem.sceneList.map(item => item.sceneCode),
pMerchantId: this.data.pMerchantId,
pMerchantName: this.data.pMerchantInfo.subLoginUser.merchantName,
isSuper: this.data.pMerchantInfo.isSuper
}
wx.$router.go('packageOutput.summary', params)
}
}
})