my.vue
11.2 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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
<template>
<view class="app-container">
<up-navbar placeholder :leftIconSize="0" bgColor="transparent" />
<!-- 人物背景 -->
<view class="bg_1_bx">
<image class="bg_2" src="@/static/commonImage/people.jpg" mode="widthFix"></image>
</view>
<view class="car_list">
<view class="line_title">
<text class="left_title" style="color: #fff;"></text>
<view style="display: flex;align-items: center;">
<u-icon name="checkmark-circle" size="16" color="#fff"></u-icon>
<text style="color: #fff;margin-left: 10rpx;" @click="submit">更新实名信息</text>
</view>
</view>
<view class="user-box">
<up-form :model="userInfo" ref="userFormRef">
<up-form-item prop="nickName">
<up-input v-model="userInfo.nickName" shape="circle" border="none" fontSize="28rpx" color="#bbb" :placeholderStyle="placeholderStyle" :customStyle="customStyle" placeholder="请输入真实姓名">
<template #prefix>
<image style="width: 32rpx;height:32rpx;margin-right: 18rpx;margin-top: 10rpx;" src="@/static/commonImage/user.png" mode="widthFix"></image>
</template>
</up-input>
</up-form-item>
<up-form-item prop="identificationNumber">
<up-input v-model="userInfo.identificationNumber" type="idcard" shape="circle" border="none" fontSize="28rpx" color="#bbb" :placeholderStyle="placeholderStyle" :customStyle="customStyle" placeholder="请输入身份证号">
<template #prefix>
<image style="width: 32rpx;height:32rpx;margin-right: 18rpx;margin-top: 10rpx;" src="@/static/commonImage/IdCard.png" mode="widthFix"></image>
</template>
</up-input>
</up-form-item>
<up-form-item prop="phonenumber">
<up-input v-model="userInfo.phonenumber" disabled shape="circle" border="none" fontSize="28rpx" color="#bbb" :placeholderStyle="placeholderStyle" :customStyle="customStyle" placeholder="请输入手机号码">
<template #prefix>
<image style="width: 32rpx;height:32rpx;margin-right: 18rpx;margin-top: 10rpx;" src="@/static/commonImage/phone.png" mode="widthFix"></image>
</template>
<template #suffix>
<button class="authBtn" open-type="getPhoneNumber" @getphonenumber="onGetNumber">已废弃,重新绑定</button>
</template>
</up-input>
</up-form-item>
</up-form>
</view>
<view class="line_title">
<text class="left_title">我的待办</text>
<text>去修改车辆信息</text>
</view>
<view class="car_box">
<carCard v-for="carItem in carList" :key="carItem.taskId" tipContent="等待修改" :carInfo="carItem">
<template #header>
<navTop :carNum="carItem.licensePlateNumber" />
</template>
<template #center>
<centerLine :leftContent="carItem.frameNumber" fontColor="#999" :rightContent="carItem.engineNumber"></centerLine>
</template>
<template #footer>
<view style="display: flex;gap: 30rpx;">
<view style="color: #3680FE;font-size: 24rpx;" @click="updateCarInfo(carItem.businessKey,carItem.taskId)">修改提交</view>
<view style="color: #3680FE;font-size: 24rpx;" @click="dropEdit(carItem.taskId)">放弃修改</view>
<view style="color: #3680FE;font-size: 24rpx;" @click="lookReason(carItem.processInstanceId)">查看退回原因</view>
</view>
</template>
</carCard>
<up-empty
:show="carList.length == 0"
mode="list"
text="暂无待办事项"
/>
</view>
<view class="loginBtn" @click="singOutShow = true">注销信息</view>
</view>
<!-- 退回原因提示框 -->
<up-popup :show="showReturen" mode="center" :safeAreaInsetBottom="false" round="20" @close="showReturen = false">
<view class="notice">
<view class="notice_title">退回原因</view>
<view class="notice_content">
<up-parse :content="returnReason"></up-parse>
</view>
<view class="btn" @click="showReturen = false">确认</view>
</view>
</up-popup>
<!-- 背景 -->
<view class="bg_bx">
<image class="bgImg" src="@/static/commonImage/bg_bx_2.jpg" mode="widthFix"></image>
</view>
<!-- 用户注销提示框 -->
<up-modal :show="singOutShow" title="注销提示" showCancelButton @confirm="loginOut" @cancel="singOutShow = false">
<view class="signOut">
<text>1、注销帐号是不可恢复的操作,你应自行备份本平台帐号相关的信息和数据。操作之前,请确认与本平台帐号相关的所有服务均已进行妥善处理。</text>
<text>2、注销帐号,你将无法再使用本平台帐号或找回你添加或绑定的任何内容或信息(即使你使用相同的手机号码再次注册并使用本平台)</text>
<text>3、注销后将删除你在该平台的所有信息,本平台不会帮你备份数据,是否确认注销</text>
</view>
</up-modal>
</view>
</template>
<script setup>
import { ref, reactive } from 'vue'
import { onReady, onShow } from '@dcloudio/uni-app'
import carCard from '@/components/carCard.vue';
import centerLine from '@/components/centerLine.vue';
import navTop from '@/components/navTop.vue';
import { updateUserInfo, userCancel, getPhome } from '@/api/user.js'
import { queryMyList, disposeUser, queryDefeatContent } from '@/api/work.js'
import useUserStore from '@/store/modules/user.js'
import storage from '@/utils/storage.js'
const { userInfo, Logout, getUser } = useUserStore()
const carList = ref([])
const singOutShow = ref(false)
const showReturen = ref(false)
const returnReason = ref('') // 退回原因
const myTotal = ref('0')
const queryParams = reactive({
pageNum: 1,
pageSize: 20,
type: 1
})
const customStyle = {
height: '80rpx',
backgroundColor: '#F9F9F9',
paddingLeft: '40rpx'
}
const placeholderStyle = {
color: '#bbb',
fontSize: '28rpx'
}
// 表单引用
const userFormRef = ref(null)
// 校验规则
const rules = {
nickName: [
{ required: true, message: '请输入姓名', trigger: ['blur', 'change'] },
{ min: 2, max: 6, message: '名字应在2到6个字', trigger: ['blur', 'change'] },
{ validator: (rule, value, callback) => {
return uni.$u.test.chinese(value)
},
message: '请输入中文',
// 触发器可以同时用blur和change
trigger: ['change','blur'],
}
],
identificationNumber: [
{ required: true, message: '请输入身份证号', trigger: ['blur', 'change'] },
{ validator: (rule, value, callback) => {
return uni.$u.test.idCard(value)
},
message: '身份证号码不正确',
// 触发器可以同时用blur和change
trigger: ['change','blur'],
}
],
phonenumber: [
{ required: true, message: '请输入手机号', trigger: ['blur', 'change'] },
{ validator: (rule, value, callback) => {
return uni.$u.test.mobile(value)
},
message: '手机号码不正确',
// 触发器可以同时用blur和change
trigger: ['change','blur'],
}
]
}
// 修改车辆信息
const updateCarInfo = (id, taskId) => {
uni.navigateTo({
url: `/pages/carDetail/carDetail?carInfoId=${id}&taskId=${taskId}`
})
}
// 授权获取手机号
const onGetNumber = (e) => {
if(e.detail.code){
getPhome(e.detail.code).then(res => {
userInfo.phonenumber = res.msg
})
} else {
uni.$u.toast('已取消授权,不能进行操作')
}
}
// 查看退回原因
const lookReason = async (processInstanceId) => {
const { data } = await queryDefeatContent({
processInstanceId,
type: 1
});
returnReason.value = data.message
showReturen.value = true
}
// 微信小程序需要在此注册校验规则
onReady(() => {
userFormRef.value.setRules(rules)
})
const loginOut = async () => {
await userCancel()
// 删除缓存中的tokne和userInfo
storage.remove('crgx_token')
storage.remove('crgx_userInfo')
await getUser()
uni.$u.toast('注销成功')
uni.redirectTo({
url: '/pages/realName/realName'
})
}
const getMyList = async () => {
const { data: peopleList } = await queryMyList({
pageNum: 1,
pageSize: 20,
type: 0
})
const { data: buinessList } = await queryMyList(queryParams)
carList.value = [...peopleList.rows, ...buinessList.rows]
myTotal.value = (peopleList.total + buinessList.total).toString()
if(myTotal.value !== '0') {
uni.setTabBarBadge({
index: 1,
text: myTotal.value
})
}else {
uni.removeTabBarBadge({
index: 1
})
}
}
// 放弃修改
const dropEdit = async (taskId) => {
await disposeUser({reregistration:'false'}, taskId)
uni.$u.toast('已放弃修改')
getMyList()
}
// 提交方法
const submit = () => {
userFormRef.value.validate().then(async valid => {
if (valid) {
await updateUserInfo(userInfo)
await getUser()
uni.$u.toast('更新成功')
} else {
uni.$u.toast('校验失败')
}
}).catch(() => {
// 处理验证错误
uni.$u.toast('校验失败')
});
}
onShow(() => {
getMyList()
})
</script>
<style lang="scss" scoped>
.app-container{
position: relative;
width: 100%;
min-height: 100vh;
padding: 0 30rpx;
background: url('http://bxhd.crgx.net/profile/avatar/2024/09/25/bg-index_20240925113012A004.png') no-repeat;
background-size: 100% 100%;
overflow: hidden;
background-attachment: fixed;
.user-box{
width: 690rpx;
padding: 40rpx 44rpx;
background-color: #fff;
z-index: 10;
margin: 0 auto 40rpx;
box-shadow: 0rpx 8rpx 40rpx 0rpx rgba(10,22,44,0.06);
border-radius: 40rpx;
}
// 车辆列表
.car_list{
position: relative;
display: flex;
flex-direction: column;
z-index: 10;
gap: 20rpx;
.line_title{
display: flex;
justify-content: space-between;
font-size: 24rpx;
color: #999;
line-height: 32rpx;
.left_title{
font-size: 32rpx;
line-height: 42rpx;
color: #333;
}
}
.car_data{
padding: 0 30rpx;
background: #FFFFFF;
box-shadow: 0rpx 8rpx 40rpx 0rpx rgba(10,22,44,0.06);
border-radius: 40rpx;
margin-bottom: 60rpx;
.car_item{
padding: 30rpx 0;
border-bottom: 2rpx solid #eee;
&:last-child{
border-bottom: 0;
}
}
}
.loginBtn{
width: 100%;
height: 80rpx;
line-height: 80rpx;
text-align: center;
font-size: 28rpx;
color: #fff;
font-weight: 500;
background: #3680FE;
box-shadow: 0rpx 8rpx 40rpx 0rpx rgba(10,22,44,0.06);
border-radius: 40rpx;
}
}
}
.signOut{
display: flex;
flex-direction: column;
text-indent: 2em;
font-size: 28rpx;
line-height: 32rpx;
color: #333;
}
.authBtn{
width: 210rpx;
font-size: 20rpx;
margin-right: 30rpx;
}
.notice{
position: relative;
width: 690rpx;
height: 600rpx;
background: #FFFFFF;
padding: 40rpx 30rpx 0;
border-radius: 20rpx;
overflow: hidden;
.notice_title{
text-align: center;
font-size: 36rpx;
line-height: 48rpx;
color: #3D3D3D;
margin-bottom: 40rpx;
}
.notice_content{
font-size: 28rpx;
line-height: 38rpx;
height: 375rpx;
color: #999;
overflow-y: scroll;
image{
width: 100%;
}
}
.btn{
position: absolute;
bottom: 0;
left: 0;
width: 100%;
line-height: 100rpx;
text-align: center;
height: 100rpx;
color: #3680FE;
font-size: 28rpx;
background-color: #fff;
border-top: 2rpx solid #eee;
}
}
.bg_bx{
position: fixed;
bottom: 100rpx;
left: 50%;
transform: translateX(-50%);
.bgImg{
width: 400rpx;
}
}
.bg_1_bx{
position: absolute;
left: 30rpx;
top: 90rpx;
.bg_2{
width: 120rpx;
}
}
.car_box{
display: flex;
flex-direction: column;
height: 300rpx;
gap: 20rpx;
overflow-y: scroll;
}
</style>