output.js
5.46 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
// pages/tab/output/output.js
import USERAPI from '~/api/usersApi/index'
import util from '~/utils/util'
import {
IMG_URL
} from '~/utils/constantData'
import {
getMockData
} from '~/api/api'
import {
wyMerchantId
} from '~/utils/request/environment'
Page({
/**
* 页面的初始数据
*/
data: {
IMG_URL,
isShow: true,
navStyle: 'background-color: rgba(0,0,0,0);',
loginType: 0,
agree: true,
tabIndx: 0,
// tabList: ['我的客户', '我的门店', '我的员工'],
tabList: ['我的客户', '我的员工'],
popupShow: false,
subIndex: -1,
merchantList: [{
merchantId: 0,
merchantName: 'string',
show: true
},
{
merchantId: 1,
merchantName: 'test',
show: true
}
],
isShowService: false,
},
// 切换园区
tapPicker() {
let {
isSuper
} = this.data
isSuper &&
this.setData({
moveArrow: !this.data.moveArrow,
popupShow: !this.data.popupShow
})
},
navbarReady(e) {
let {
height,
statusBarHeight
} = e.detail
this.setData({
tabBarStyle: height / 2 + statusBarHeight
})
// console.log(e)
},
changeTabIndx(e) {
this.setData({
tabIndx: e.detail
})
},
init() {
this.setUserInfo()
this.getMerchantRange()
// this.getMockInfo()
},
setUserInfo() {
let {
userInfo
} = wx.$storage.get()
// console.log(userInfo)
this.setData({
userInfo,
isSuper: userInfo.isSuper
})
},
async getMockInfo() {
let {
serviceMerchatList
} = await getMockData() || {
serviceMerchatList: []
}
this.setData({
isShowService: serviceMerchatList.includes(this.data.userInfo.merchantId + '')
})
},
getMerchantRange(e) {
// 重新刷新
// let { detail } = e || null
// console.log(detail)
if (e) {
this.setUserInfo()
let clientModule = this.selectComponent('#client')
// let merchantModule = this.selectComponent('#merchant')
clientModule.getClientApi && clientModule.clientRefresh()
clientModule.getBusinessData && clientModule.getBusinessData()
// merchantModule.init && merchantModule.init()
}
let {
isSuper,
userInfo
} = this.data
// 判断是超管才需要切换账号
if (isSuper) {
USERAPI.adminSelectLogin()
.then(result => {
// console.log(result)
let {
merchantList: merchantRange
} = result
// console.log(merchantRange)
let subIndex = -1
merchantRange.forEach((item, index) => {
item.show = true
if (item.merchantId == userInfo.subLoginUser.merchantId) {
subIndex = index
item.act = true
}
})
this.setData({
merchantRange,
subIndex
})
})
.catch(err => {})
} else {
let merchantRange = [{
merchantId: userInfo.subLoginUser.merchantId,
merchantName: userInfo.subLoginUser.merchantName
}]
this.setData({
merchantRange,
subIndex: 0
})
}
},
onRoute(options) {
if (!options || wx.$util.isEmptyObj(options)) return
let {
page = 'client', refresh = true
} = options
if (page == 'client' && refresh) {
let clientModule = this.selectComponent('#client')
clientModule.getClientApi && clientModule.clientRefresh()
clientModule.getBusinessData && clientModule.getBusinessData()
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
if (wyMerchantId.includes(+wx.$storage.get().userInfo.merchantId)) {
this.setData({
isWy: true
})
this.getTabBar().setData({
active: 2,
isShow:false
})
}
const {
merchantId,
type,
merchantName,
usedCarFlag
} = options
if (merchantId) {
wx.navigateTo({
url: `/packagesList/outDetail/index?merchantId=${merchantId}&type=${type}&merchantName=${merchantName}&usedCarFlag=${usedCarFlag}`,
})
this.setData({
isShow: false
}, () => {
setTimeout(() => {
this.setData({
isShow: true
})
}, 1000)
})
}
this.init()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
// console.log(getTextWidth('随后获取dom元素的clientWidth 随后获取dom元素的clientWidth随后获取dom元素的clientWidth随后获取dom元素的clientWidth', '12px'))
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
let title = '看产值'
if (typeof this.getTabBar === 'function') {
this.getTabBar((tabBar) => {
const list = util.deepClone(tabBar.data.initList)
if (wyMerchantId.includes(+wx.$storage.get().userInfo.merchantId)) {
list.splice(1, 1);
title = wx.$storage.get().userInfo.merchantName
}
tabBar.setData({
active: 0,list
})
})
}
this.setData({title})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {}
})