my.vue
7.7 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
<template>
<view class="app-container">
<up-navbar placeholder :leftIconSize="0" bgColor="transparent" />
<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" 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" 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>
</view>
<view class="line_title">
<text class="left_title">我的待办</text>
<text>去修改车辆信息</text>
</view>
<carCard v-for="carItem in carList" :key="carItem.taskId" tipContent="等待修改" :carInfo="carItem">
<template #header>
<navTop :carNum="carItem.licensePlateNumber" />
</template>
<template #center>
<centerLine :leftContent="carItem.customizeVehicleBrand || carItem.vehicleBrand" fontColor="#999" :rightContent="carItem.customizeVehicleModel || carItem.vehicleModel"></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>
</template>
</carCard>
<up-empty
:show="carList.length == 0"
mode="list"
text="暂无待办事项"
/>
<view class="loginBtn" @click="loginOut">注销信息</view>
</view>
</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 } from '@/api/user.js'
import { queryMyList, disposeUser } from '@/api/work.js'
import useUserStore from '@/store/modules/user.js'
const { userInfo, Logout } = useUserStore()
const carList = ref([])
const myTotal = ref('0')
const queryParams = reactive({
pageNum: 1,
pageSize: 20
})
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}`
})
}
// 微信小程序需要在此注册校验规则
onReady(() => {
userFormRef.value.setRules(rules)
})
const loginOut = () => {
uni.showModal({
title: '提示',
content: '是否要注销信息 \n1、点击注销后工作人员在七个工作日内像你发送短信确认\n 2、注销后将删除你在该平台的所有信息',
success: async (res) => {
if (res.confirm) {
await userCancel()
await Logout()
uni.$u.toast('注销成功')
uni.redirectTo({
url: '/pages/realName/realName'
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
const getMyList = async () => {
const { data } = await queryMyList(queryParams)
carList.value = data.rows
myTotal.value = data.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)
uni.$u.toast('更新成功')
} else {
uni.$u.toast('校验失败')
}
}).catch(() => {
// 处理验证错误
uni.$u.toast('校验失败')
});
}
onShow(() => {
getMyList()
})
</script>
<style lang="scss" scoped>
.app-container{
width: 100%;
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;
.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{
display: flex;
flex-direction: column;
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;
}
}
}
</style>