MerchantList.vue
6.13 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
<template>
<view
class="box"
:key="selectMerchantId"
>
<template v-if="flag">
<template v-if="loginUserInfoList.length">
<template v-for="(item, index) in loginUserInfoList">
<view
:key="index"
:class="['items', { active: item.active }]"
@click="chooseAccount(item)"
>
<view class="right">
<view class="sprite-icon icon-store"></view>
</view>
<view class="left">
<view class="text_box">
<view class="name">{{ item.merchantName }}</view>
<view class="text_no">商户号:{{ item.merchantId }}</view>
</view>
</view>
</view>
</template>
</template>
<template v-else>
<no-data />
</template>
</template>
</view>
</template>
<script type="text/ecmascript-6">
import NoData from './NoData.vue'
export default {
name: 'MerchantList',
data () {
return {
loginUserInfoList: [],
copyLoginUserInfoList: [],
showSelect: false,
flag: false,
userInfo: {},
selectMerchantId: ''
}
},
components: {
NoData
},
methods: {
init (userInfo) {
uni.$logger.info(`进入选择4s店页面!`)
this.userInfo = userInfo
this.getMerchantList()
// this.getSceneArr()
},
async getSceneArr (merchantId = '') {
return new Promise(async resolve => {
let { userInfo } = this,
openSceneArr = []
// 获取4s店关联场景数据
const result = await uni.$api.userApi.getYqMerchantSceneConfigAPI({
yqMerchantId: userInfo?.subLoginUser?.merchantId,
merchantId
})
result.map(val => {
if (val.sceneOpenFlag == 0) openSceneArr.push(val.scene)
})
resolve(openSceneArr)
})
},
getMerchantList () {
this.loginUserInfoList = []
this.copyLoginUserInfoList = []
this.flag = false
uni.showLoading({
mask: true
})
let { userInfo } = this
let params = {
merchantId: userInfo?.isSuper ? '' : userInfo?.merchantId,
staffUUID: userInfo?.isSuper ? '' : userInfo?.uuid
}
uni.$api.userApi.getSceneMerchantRefStoreList(params).then(result => {
uni.hideLoading()
this.loginUserInfoList = result
this.copyLoginUserInfoList = result
this.flag = true
if (result && result.length == 1) this.chooseAccount(result[0])
}).catch(err => {
uni.hideLoading()
})
},
async chooseAccount (item) {
uni.$logger.info(`选择4s店${item.merchantName}!`)
uni.showLoading({
mask: true
})
let { loginUserInfoList } = this
let listArr = loginUserInfoList
listArr.map(i => {
i.active = false
if (i.merchantId == item?.merchantId) {
i.active = true
}
return i
})
let openSceneArr = await this.getSceneArr(item.merchantId)
this.loginUserInfoList = listArr
this.selectMerchantId = item.merchantId
this.jumpPage(item, openSceneArr)
},
async jumpPage (item, openSceneArr) {
let { merchantName: shopMerchantName, merchantId: shopMerchantId } = item,
{ userInfo } = this
const usedCarSceneType = 7
if (!openSceneArr?.length && !userInfo?.isSuper) {
uni.hideLoading()
uni.showToast({
title: '暂无开通业务,请联系总部管理员',
icon: 'none'
})
return
}
if (userInfo.isSuper) openSceneArr = [1, 0, usedCarSceneType] //超管默认开通全部场景
userInfo = {
...userInfo,
openSceneArr,
shopMerchantName,
shopMerchantId,
default4SStoreInfo: {
merchantId: shopMerchantId,
merchantName: shopMerchantName
},
default4SStoreInfo_crowdFunding: {
merchantId: shopMerchantId,
merchantName: shopMerchantName
},
default4SStoreInfo_newCarConversion: {
merchantId: shopMerchantId,
merchantName: shopMerchantName
}
}
if (openSceneArr.length == 1 && openSceneArr[0] == usedCarSceneType) {
const data = await uni.$api.userApi.selectMerchantScene({
merchantId: userInfo.shopMerchantId,
merchantName: userInfo.shopMerchantName,
sceneType: usedCarSceneType
})
uni.$logger.local.info(`商户只有二手车场景时自动跳转进入二手车首页!`)
if (data) userInfo.loginRoleOnSelectMerchant = data?.loginRoleOnSelectMerchant
userInfo.sceneType = usedCarSceneType
uni.$storage.set('userInfo', userInfo)
uni.reLaunch({
url: '/pages/usedCar/index'
})
return
}
this.$emit('chooseMerchant', userInfo)
uni.hideLoading()
},
searchEvent (searchValue) {
let { copyLoginUserInfoList, selectMerchantId } = this
copyLoginUserInfoList.map(val => {
val.active = false
if (val.merchantId == selectMerchantId) 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
},
}
}
</script>
<style scoped lang="scss">
.box {
display: flex;
align-items: center;
flex-wrap: wrap;
padding: 0 toRpx(48);
gap: toRpx(48);
.items {
width: calc(50% - #{toRpx(24)});
height: toRpx(160);
background: #ffffff;
border-radius: toRpx(16);
padding: toRpx(32);
display: flex;
align-items: center;
box-sizing: border-box;
border: toRpx(4) solid transparent;
.right {
margin-right: toRpx(28);
flex-shrink: 0;
}
.left {
flex: 1;
.name {
font-weight: 500;
font-size: toRpx(32);
color: #181a1f;
margin-bottom: toRpx(12);
}
.text_no {
font-size: toRpx(28);
color: #999ea8;
}
}
}
.active {
border: toRpx(4) solid #347bff;
}
}
</style>