parkEnter.vue
6.51 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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<template>
<div class="park-enter-container">
<!-- 欢迎语模块 -->
<div class="welcome-box">欢迎光临</div>
<!-- 虚拟车牌展示模块 -->
<div class="virtual-plate-box">{{ virtualPlate }}</div>
<!-- 截屏提示模块 -->
<div class="tips-red">请截屏保存虚拟车牌</div>
<!-- 服务说明模块 -->
<div class="service-desc">
<!-- 出场方法 -->
<div class="desc-item">
<i class="icon-car">🚗</i>
<div class="desc-content">
<p class="title">出场方法</p>
<p class="text">出口扫码缴费即可出场</p>
</div>
</div>
<!-- 注意事项 -->
<div class="desc-item">
<i class="icon-warning">!</i>
<div class="desc-content">
<p class="title">注意事项</p>
<p class="text">1.进出场、缴费扫码时,请保持使用同一部手机中同一扫码工具(微信、支付宝)</p>
<p class="text">2.受充电桩功能限制,虚拟车牌不支持充电减免。(充电桩不支持虚拟车牌绑定)</p>
</div>
</div>
</div>
<!-- 确定入场按钮 -->
<!-- <div class="okBtn" @click="onHandle">确定入场</div> -->
</div>
</template>
<script>
// 导入接口(根据实际项目路径调整)
import { noCarQRcodeInOutPark } from '@/api/parkEnter/parkEnter'
export default {
name: 'parkEnter',
data() {
return {
// 页面请求参数
query: {},
// 虚拟车牌(实际项目中建议从接口获取,此处先写死示例)
virtualPlate: '',
// 入场图片地址(可从接口返回)
enterImgUrl: ''
}
},
created() {
// 初始化获取URL请求参数
this.initQueryParams()
// 可选:初始化获取虚拟车牌
this.getVirtualPlate()
},
methods: {
/**
* 初始化获取URL请求参数
*/
initQueryParams() {
try {
this.query = this.$utils.getQueryString(window.location)
console.log('入场请求参数:', this.query)
} catch (e) {
console.error('获取请求参数失败:', e)
this.query = {}
}
},
/**
* 获取虚拟车牌(对接后端接口示例)
*/
async getVirtualPlate() {
try {
// 此处替换为实际获取虚拟车牌的接口
const requestParams = {
...this.query,
app_id: 1,
salt: 2,
deviceInfo: 3,
sign_type: 'md5',
sign: 4,
token: '666',
// carNumber: this.virtualPlate, // 传虚拟车牌(替代原手机号)
terminalSource: "7" // 1:任你听 3:微信公共号 4:云平台 7:H5
}
const res = await noCarQRcodeInOutPark(requestParams)
console.log(res);
this.virtualPlate = res.data.plateno
localStorage.setItem('virtualCarPlate', res.data.plateno)
this.$msgbox('提示', '进场信息已录入,请您进场!')
console.log('虚拟车牌已获取')
} catch (e) {
console.error('获取虚拟车牌失败:', e)
this.$msgbox('提示', '获取虚拟车牌失败,请重试')
}
},
/**
* 确定入场按钮点击事件
*/
async onHandle() {
// 1. 校验请求参数
if (Object.keys(this.query).length === 0) {
this.$msgbox('提示', '没有接收到请求参数')
return
}
// 2. 组装接口请求参数
const requestParams = {
...this.query,
app_id: 1,
salt: 2,
deviceInfo: 3,
sign_type: 'md5',
sign: 4,
token: '666',
carNumber: this.virtualPlate, // 传虚拟车牌(替代原手机号)
terminalSource: "7" // 1:任你听 3:微信公共号 4:云平台 7:H5
}
try {
// 3. 调用入场接口
const res = await noCarQRcodeInOutPark(requestParams)
if (res.code === 0) {
this.$msgbox('提示', '进场信息已录入,请您进场!')
} else {
this.$msgbox('提示', res.message || '入场失败,请重试')
}
} catch (e) {
console.error('入场接口调用失败:', e)
this.$msgbox('提示', '网络异常,请稍后重试')
}
}
}
}
</script>
<style scoped lang="scss">
// 全局容器样式
.park-enter-container {
width: 100%;
max-width: 500px; // 适配移动端,限制最大宽度
margin: 0 auto;
padding: 20px 15px;
box-sizing: border-box;
background-color: #fff;
}
// 欢迎语盒子样式
.welcome-box {
width: 100%;
padding: 15px 0;
text-align: center;
font-size: 18px;
color: #f97316; // 橙色字体
border: 1px solid #e5e7eb;
border-radius: 2px;
margin-bottom: 20px;
}
// 虚拟车牌盒子样式
.virtual-plate-box {
width: 100%;
height: 80px;
line-height: 80px;
text-align: center;
font-size: 32px;
font-weight: bold;
color: #ffffff;
background: linear-gradient(180deg, #3885D9 0%, #4194EF 100%);
border-radius: 4px;
margin-bottom: 15px;
letter-spacing: 2px; // 增加字符间距,更像车牌
}
// 红色提示样式
.tips-red {
text-align: center;
color: #ef4444;
font-size: 16px;
padding: 10px 0;
border: 1px dashed #ef4444;
border-radius: 2px;
margin-bottom: 25px;
}
// 服务说明容器样式
.service-desc {
margin-bottom: 50px;
// 说明项样式
.desc-item {
display: flex;
align-items: flex-start;
margin-bottom: 25px;
// 图标样式
i {
font-size: 24px;
margin-right: 15px;
margin-top: 2px;
font-style: normal; // 清除默认斜体
}
// 车辆图标
.icon-car {
color: #3885D9;
}
// 警告图标
.icon-warning {
display: inline-block;
width: 24px;
height: 24px;
line-height: 24px;
text-align: center;
background: #f59e0b;
color: #fff;
border-radius: 50%;
font-weight: bold;
}
// 说明内容样式
.desc-content {
flex: 1;
.title {
font-size: 16px;
color: #000;
margin-bottom: 5px;
font-weight: 500;
}
.text {
font-size: 14px;
color: #ef4444;
line-height: 1.5;
}
}
}
}
// 确定入场按钮样式
.okBtn {
background: linear-gradient(180deg, #3885D9 0%, #4194EF 100%);
width: 60%;
margin: 0 auto;
height: 48px;
line-height: 48px;
text-align: center;
border-radius: 5px;
color: #ffffff;
font-size: 18px;
cursor: pointer;
&:hover {
opacity: 0.9;
}
&:active {
opacity: 0.8;
}
}
</style>