AccountList.vue
6.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
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
<template>
<view
class="box"
:key="selectedUuid"
v-if="flag"
>
<template v-if="loginUserInfoList.length">
<template v-for="(item,index) in loginUserInfoList">
<view
:key="index"
:class="['items', `${item.active ? 'active' : ''}` ]"
@click="chooseAccount(item)"
>
<view class="right">
<view :class="['midle', midle(item)]">
{{item.isSuper==true?'超管':item.userType==1?'商户':(item.loginRole == 3 ? '督导' : item.loginRole == 4 ? '驻店' : '员工')}}
</view>
</view>
<view class="left">
<view class="name">
{{item.merchantName}}
</view>
<view class="shop_no">
商户号:{{item.merchantId}}
</view>
</view>
</view>
</template>
</template>
<template v-else>
<view class="list-not">
暂无内容
</view>
</template>
</view>
</template>
<script type='text/ecmascript-6'>
import { loginMixin } from '@/mixin/index'
export default {
mixins: [loginMixin],
name: '',
data () {
return {
copyLoginUserInfoList: [],
loginRole: {
1: '超管',
2: '商户号',
3: '区域督导',
4: '驻店负责人'
},
selectedUuid: '',
requestFlag: false,
loginUserInfoList: [],
flag: false
}
},
mounted () {
this.getListSelectAccount()
},
methods: {
getListSelectAccount () {
uni.showLoading()
uni.$api.userApi.getListSelectAccount().then(res => {
uni.hideLoading()
let { code, data, message } = res
if (code == 21) uni.reLaunch({
url: "/pages/common/login",
})
else {
if (code == 0) {
let { loginUserInfoList, sessionId } = data
uni.$storage.set('sessionId', sessionId);
this.loginUserInfoList = loginUserInfoList
this.copyLoginUserInfoList = loginUserInfoList
} else uni.showToast({
title: message,
icon: 'none',
});
this.flag = true
}
})
},
chooseAccount (item) {
let { loginUserInfoList } = this
loginUserInfoList.map(i => {
i.active = false
if (i.uuid == item?.uuid) i.active = true
return i
})
this.loginUserInfoList = loginUserInfoList
this.selectedUuid = item.uuid
this.choiceAccountLogin()
},
async choiceAccountLogin () {
let { loginUserInfoList } = this,
id = null
loginUserInfoList.map(e => {
if (e.active) id = e.uuid
})
if (!id) {
uni.showToast({
title: '请选择账号',
icon: 'none',
});
return
}
// 清空4s店数据
// app.globalData.storeListRange = []
this.selectAccountLogin(id)
},
selectAccountLogin (id) {
if (this.requestFlag) return
this.requestFlag = true
uni.showLoading()
uni.$api.userApi.selectAccountLogin({ id }).then(res => {
uni.hideLoading()
this.requestFlag = false
let { data, message } = res,
[userInfo] = data.loginUserInfoList
if (data && userInfo) this.get4SStoreList(userInfo)
else uni.showToast({
title: message,
icon: 'none',
})
})
},
// 搜索过滤
searchEvent (searchValue) {
let { copyLoginUserInfoList, selectedUuid } = this
copyLoginUserInfoList.map(val => {
val.active = false
if (val.uuid == selectedUuid) val.active = true
return val
})
let filterArr = copyLoginUserInfoList.filter(val => val.merchantName.includes(searchValue) || val.merchantId == searchValue) || []
this.loginUserInfoList = filterArr
if (!searchValue) this.loginUserInfoList = copyLoginUserInfoList
},
midle (item) {
return item.isSuper == true ? 'midle_1' : item.userType == 1 ? 'midle_2' : (item.loginRole == 3 ? 'midle_3' : item.loginRole == 4 ? 'midle_4' : 'midle_5')
},
}
}
</script>
<style scoped lang='scss'>
.box {
display: flex;
align-items: center;
flex-wrap: wrap;
padding: 0 48rpx;
gap: 48rpx;
.items {
width: calc(50% - 24rpx);
height: 160rpx;
background: #ffffff;
border-radius: 16rpx;
padding: 32rpx;
display: flex;
align-items: center;
box-sizing: border-box;
border: 4rpx solid transparent;
.left {
width: 65%;
display: flex;
flex-flow: column;
justify-content: center;
.name {
font-weight: 500;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 32rpx;
color: #181a1f;
}
.shop_no {
font-weight: 400;
font-size: 28rpx;
margin-top: 12rpx;
color: #999ea8;
}
}
.right {
flex-shrink: 0;
display: flex;
align-items: center;
.midle {
font-size: 28rpx;
font-weight: 700;
width: 96rpx;
height: 96rpx;
border-radius: 8rpx;
margin-right: 28rpx;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.midle_1 {
color: #f24724;
background-color: #f247241a;
}
.midle_2 {
color: #ff9d0a;
/* border: var(--fontSize2) solid #FF9D0A; */
background-color: #ff9d0a1a;
}
.midle_3 {
color: #347bff;
/* border: var(--fontSize2) solid #347BFF; */
background-color: #347bff1a;
}
.midle_4 {
color: #35c376;
/* border: var(--fontSize2) solid #35C376; */
background-color: #35c3761a;
}
.midle_5 {
color: #35c376;
/* border: var(--fontSize2) solid #35C376; */
background-color: #35c3761a;
}
.icon {
width: 40rpx;
height: 40rpx;
}
}
}
.active {
border: 4rpx solid #347bff;
}
.list-not {
font-size: 28rpx;
color: #999999;
margin: auto;
}
}
</style>