accountList.vue
4.68 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
<template>
<div class="layout">
<div class="title">请选择登录商户号</div>
<div class="box">
<template v-for="(item,index) in accountList">
<div
:key="index"
class="item"
@click="choose(item)"
>
<div class="name">
{{item.merchantName}}
<span class="type text-center">{{merchantEnum[item.accountLevel]}}</span>
</div>
<div class="num">商户编号:{{item.merchantId}}</div>
<div class="icon y-center">
<img src="@/assets/images/icon/arrow.png">
</div>
</div>
</template>
</div>
</div>
</template>
<script type='text/ecmascript-6'>
import { ssoApi } from '@/api'
import store from '@/store'
import { Dialog } from 'vant'
export default {
name: 'accountList',
data () {
return {
accountList: [],
merchantEnum: {
1: '工厂',
2: '省代',
3: '市代',
4: '门店'
},
testView: ''
}
},
mounted () {
this.accountList = this.getLocalStorage('dj_scrm_accountList')
},
// watch: {
// watchFlag: {
// immediate: true,
// handler(newval) {
// this.testView = newval
// }
// }
// },
// computed: {
// watchFlag() {
// return this.$store.state.app.testView
// }
// },
methods: {
choose (e) {
this.showLoading(
'',
() => {
let loginToken = this.getLocalStorage('dj_scrm_loginToken')
let { merchantId, accountName } = e
let loginAccount = accountName
ssoApi
.selectAccount({
loginAccount,
merchantId,
loginToken
})
.then(({ code, data }) => {
this.hideLoading()
this.removeLocalStorage('dj_scrm_loginToken')
if (code == '0') {
if (data) {
if (data.status != 2) {
this.$router.replace({ name: 'common.overdue' })
return
}
let { lastPath } = this.getQuery()
let redirect_uri = this.getLocalStorage('dj_scrm_redirect_uri')
this.setLocalStorage('dj_scrm_userInfo', data)
this.setSessionId(data.sessionId)
let { corpId, agentId } = this.getLocalStorage('dj_scrm_corpId')
store.dispatch('registerHttp', data.sessionId)
this.removeLocalStorage('dj_scrm_redirect_uri')
this.showLoading('登录成功', () => {
this.hideLoading()
if (redirect_uri) {
let [URL, query] = decodeURIComponent(redirect_uri).split('?')
URL = `${URL}?sessionId=${data.sessionId}&corpId=${corpId}`
if(agentId) URL = `${URL}&agentId=${agentId}`
if (query) URL = `${URL}&${query}`
window.location.href = URL
}
else this.$router.replace({ name: lastPath || 'home' })
})
}
} else {
this.hideLoading()
Dialog.alert({
title: '温馨提示',
message: '登录失败,请重试',
confirmButtonColor: '#FF7336',
confirmButtonText: '重试'
}).then(() => {
store.dispatch('navigation')
})
}
})
},
true
)
}
}
}
</script>
<style scoped lang='scss'>
.layout {
padding: 0 16px 32px;
.title {
font-size: 20px;
color: #3a3a3a;
font-weight: 500;
padding: 75px 0 40px;
text-align: center;
}
.item {
padding: 16px 16px 16px 27px;
background: #fafafa;
border-radius: 4px;
margin-bottom: 16px;
position: relative;
.name {
width: 277px;
line-height: 20px;
font-size: 14px;
color: #6b6b6b;
word-break: break-all;
position: relative;
&::after {
position: absolute;
top: 6px;
left: -11px;
width: 6px;
height: 6px;
background: var(--themeColor);
border-radius: 100%;
content: '';
}
.type {
display: inline-flex !important;
width: 34px;
height: 14px;
border: 1px solid var(--themeColor);
border-radius: 4px;
font-size: 10px;
color: #837aff;
vertical-align: middle;
}
}
.num {
font-size: 12px;
color: #666666;
margin-top: 10px;
}
.icon {
right: 16px;
width: 7px;
height: 10px;
}
}
}
</style>