companyMy.vue
7.3 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
<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>
<text style="color: #fff;" @click="submit">更新实名信息</text>
</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" 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 class="status">
<view class="statusBtn" :class="{active: userInfo.jobStatus === '0'}" @click="changeStatus('0')">在岗</view>
<view class="statusBtn" :class="{active: userInfo.jobStatus === '1'}" @click="changeStatus('1')">离岗</view>
</view>
</view>
<view class="loginBtn" @click="loginOut">退出登录</view>
</view>
<!-- 底部导航栏 -->
<up-tabbar
:value="useTabbar.employeeCurrent"
activeColor="#3680FE"
inactiveColor="#707070"
>
<up-tabbar-item text="主页" icon="home" :badge="useTabbar.companyTotal" @click="goRouter"></up-tabbar-item>
<up-tabbar-item text="我的" icon="account"></up-tabbar-item>
</up-tabbar>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { updateUserInfo, getPhome } from '@/api/user.js'
import { onReady } from '@dcloudio/uni-app'
import useTabbarStore from '@/store/modules/tabbar.js'
import useUserStore from '@/store/modules/user.js';
const { userInfo, Logout, getUser } = useUserStore()
const useTabbar = useTabbarStore()
const showNotice = ref(true)
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 onGetNumber = (e) => {
if(e.detail.code){
getPhome(e.detail.code).then(res => {
userInfo.phonenumber = res.msg
})
} else {
uni.$u.toast('已取消授权,不能进行操作')
}
}
// 微信小程序需要在此注册校验规则
onReady(() => {
userFormRef.value.setRules(rules)
})
const loginOut = () => {
uni.showModal({
title: '提示',
content: '是否退出登录',
success: async (res) => {
if (res.confirm) {
await Logout()
uni.$u.toast('退出成功')
uni.redirectTo({
url: '/pages/login/login'
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
const goRouter = (index) => {
useTabbar.employeeCurrent = index
uni.redirectTo({
url: '/pages/companyHome/companyHome'
})
}
// 设置在岗状态
const changeStatus = async (status) => {
userInfo.jobStatus = status
await updateUserInfo(userInfo)
await getUser()
uni.$u.toast('更新成功')
}
// 提交方法
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('校验失败')
});
}
</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;
margin-top: 40rpx;
}
}
}
.authBtn{
width: 210rpx;
font-size: 20rpx;
margin-right: 30rpx;
}
.status{
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 20rpx;
.statusBtn{
width: 280rpx;
height: 80rpx;
text-align: center;
line-height: 80rpx;
color: #999;
background: #FFFFFF;
border-radius: 200rpx;
border: 2rpx solid #BBBBBB;
&.active{
color: #fff;
background: #3680FE;
}
}
}
</style>