-
+
-
-
- 男
- 女
+
+
+ 男
+ 女
-
-
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -179,7 +276,7 @@ const loading = ref(false)
}
.footer {
display: flex;
- justify-content: space-around;
+ justify-content: space-between;
align-items: center;
margin-top: 20px;
}
@@ -230,4 +327,7 @@ span {
margin-left: 65px;
margin-top: -50px;
}
+/* .el-form el-form--default el-form--label-right {
+ height: 500px;
+} */
diff --git a/src/views/home/components/Student1.vue b/src/views/home/components/Student1.vue
index f538d09..f227dd5 100644
--- a/src/views/home/components/Student1.vue
+++ b/src/views/home/components/Student1.vue
@@ -34,7 +34,7 @@ getStuList()
-
{{ item.name }}
+ {{ item.name }}
{{ item.number }}
@@ -95,7 +95,7 @@ getStuList()
}
h4 {
margin-left: 15px;
- font-weight: bold;
+ /* font-weight: bold; */
font-size: 14px;
font-family: Inter, Inter;
/* font-weight: 400; */
diff --git a/src/views/home/components/Welcome.vue b/src/views/home/components/Welcome.vue
index cf0c462..2d1a493 100644
--- a/src/views/home/components/Welcome.vue
+++ b/src/views/home/components/Welcome.vue
@@ -9,7 +9,7 @@ import {
import useUserStore from '@/store/modules/user'
import { useRouter } from 'vue-router'
import { ElMessage, dayjs } from 'element-plus'
-import { Edit } from '@element-plus/icons-vue'
+import { Edit, Back } from '@element-plus/icons-vue'
const props = defineProps({
name: {
type: String,
@@ -34,23 +34,23 @@ const pwdForm = ref({
const dialogFormVisible = ref(false)
//密码
const passFormVisible = ref(false)
-
//dialog
const form = ref({})
const formLabelWidth = '80px'
//打开dialog
-form.value = { ...props.userData, code: '' }
+form.value = { ...props.userData, code: '', newphone: '' }
const openInfo = () => {
dialogFormVisible.value = true
- codeVisible.value = false
+ change.value = true
// console.log(form.value, 'form')
}
const openPass = () => {
passFormVisible.value = true
+ pwdForm.value = {}
}
//校验规则
const checkOldSame = (rule, value, callback) => {
- if (value === props.userData.password) {
+ if (value === pwdForm.value.old_pwd) {
callback(new Error('新密码不能与旧密码相同'))
} else {
callback()
@@ -58,7 +58,14 @@ const checkOldSame = (rule, value, callback) => {
}
const checkNewSame = (rule, value, cb) => {
if (value !== pwdForm.value.new_pwd) {
- cb(new Error('新密码和确认再次输入的新密码不一样!'))
+ cb(new Error('新密码和确认再次输入的新密码不一样'))
+ } else {
+ cb()
+ }
+}
+const checkOldPhone = (rule, value, cb) => {
+ if (value === form.value.phone) {
+ cb(new Error('新手机号与旧手机号相同'))
} else {
cb()
}
@@ -82,6 +89,14 @@ const infoRules = {
trigger: ['change', 'blur'],
},
],
+ newphone: [
+ {
+ pattern: /^1[3-9]\d{9}$/,
+ message: '手机号格式不正确',
+ trigger: ['change', 'blur'],
+ },
+ { validator: checkOldPhone, trigger: 'blur' },
+ ],
}
//密码校验
const rules = {
@@ -119,29 +134,22 @@ const rules = {
const infoRef = ref()
//修改用户信息
const emit = defineEmits(['get-message'])
+const change = ref(true)
//验证码倒计时
const countdown = ref(0)
//修改手机号
-const codeVisible = ref(false)
//切换可见性
+const phoneValue = form.value.phone
const toggleVisibility = () => {
- codeVisible.value = !codeVisible.value
- if (codeVisible.value == true) {
- // 清空输入框
- form.value.phone = ''
- } else {
- // 如果输入框为空,可以设置为某个默认值,比如'sample text'
- form.value.phone = props.userData.phone // 这里可以根据需要自定义默认值
- }
+ // console.log('change')
+ change.value = false
}
-// 切换输入框的值,如果输入框当前有值则设置为空,如果没有值则设置为一个默认值
-const toggleInputValue = () => {}
//验证码
const codecode = ref()
const codeSubmit = async () => {
await infoRef.value.validate()
// console.log('开始发起注册验证码')
- const phoness = form.value.phone
+ const phoness = form.value.newphone
userCodeRegisterService(phoness)
.then((response) => {
codecode.value = response.data
@@ -151,12 +159,52 @@ const codeSubmit = async () => {
console.log(error.message, 'error')
})
}
-
-const changePhone = () => {
- codeVisible.value = true
-}
+// console.log(change.value == true, 'toggleVisibility.value == false')
+// if (toggleVisibility.value == 'false') {
+// console.log('值相等,为 false')
+// } else {
+// console.log('值不相等')
+// }
const changeInfo = async () => {
await infoRef.value.validate()
+ if (change.value === true) {
+ // console.log(form.value.phone, '原手机号')
+ await userChangeService({
+ phone: form.value.phone,
+ id: form.value.id,
+ nickName: form.value.nickName,
+ }).then(() => {
+ ElMessage.success('修改成功')
+ emit('get-message', form.value.nickName)
+ form.value.newphone = ''
+ form.value.code = ''
+ })
+ dialogFormVisible.value = false
+ } else {
+ if (codecode.value === form.value.code) {
+ // console.log(form.value.newphone, '新手机号')
+ // console.log('验证码正确')
+ await userChangeService({
+ phone: form.value.newphone,
+ id: form.value.id,
+ nickName: form.value.nickName,
+ }).then(() => {
+ ElMessage.success('修改成功')
+ form.value.phone = form.value.newphone
+ emit('get-phone', form.value.phone)
+ form.value.newphone = ''
+ form.value.code = ''
+ })
+ dialogFormVisible.value = false
+ } else {
+ ElMessage.error('验证码错误')
+ }
+ }
+}
+//修改密码
+const pwdRef = ref()
+const changePassword = async () => {
+ await pwdRef.value.validate()
await userChangeService({
phone: form.value.phone,
id: form.value.id,
@@ -164,6 +212,8 @@ const changeInfo = async () => {
}).then(() => {
ElMessage.success('修改成功')
emit('get-message', form.value.nickName)
+ form.value.newphone = ''
+ form.value.code = ''
})
dialogFormVisible.value = false
}
@@ -180,11 +230,11 @@ const onSubmit = async () => {
username: props.userData.username,
})
.then(() => {
- ElMessage.success('密码修改成功')
+ ElMessage.success('修改成功')
passFormVisible.value = false
})
.catch((error) => {
- console.log(error, 'error')
+ // console.log(error, 'error')
ElMessage.error(error.response.data.message)
})
pwdForm.value = {}
@@ -209,8 +259,17 @@ const flagVisible = ref(true)
//展示当前日期
const currentDate = new Date()
const formattedDate = ref()
-// const formattedDate = dayjs(currentDate).format('YYYY-MM-DD HH:mm:ss')
-// const timer = ref()
+let currentTime = ref(new Date().toLocaleString())
+
+// 使用 setInterval 每秒更新时间
+let timer1 = setInterval(() => {
+ currentTime.value = new Date().toLocaleString()
+}, 1000)
+
+// 在组件卸载时清除定时器
+onUnmounted(() => {
+ clearInterval(timer1)
+})
//获取验证码
let timer
@@ -233,7 +292,7 @@ onMounted(() => {
daysOnJob.value = Math.floor((currentDate - hireDate) / millisecondsPerDay)
let timer = setInterval(() => {
formattedDate.value = dayjs(currentDate).format('YYYY-MM-DD HH:mm:ss')
- }, 100)
+ }, 1000)
})
onUnmounted(() => {
clearInterval(timer)
@@ -260,14 +319,21 @@ onUnmounted(() => {
修改密码
-