diff --git a/src/api/user/user.js b/src/api/user/user.js index c67d56e..02399b7 100644 --- a/src/api/user/user.js +++ b/src/api/user/user.js @@ -41,8 +41,8 @@ export const userIdenService = (id) => { return request.post('/user/personal/info?id=' + id) } //修改身份信息 -export const userIdenChangeService = (jsonData) => { - return request.post('', jsonData, { +export const userIdenChangeService = (dataToSend) => { + return request.post('/user/update/PersonalInfo', dataToSend, { headers: { 'Content-Type': 'application/json;charset=UTF-8' }, }) } diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 9ff67ca..f4901ac 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -5,7 +5,7 @@ import { reqLogin, getUserInfo } from '@/api/user/index' // 引入登录参数类型 import { loginType, loginResponseType } from '@/api/user/types' // 引入ElementPlus通知插件 -import { ElNotification } from 'element-plus' +import { ElMessage, ElNotification } from 'element-plus' import { getTime } from '@/utils/time' import { LoginStoreType } from '../modules/type/types' // 引入设置token的方法 @@ -15,7 +15,6 @@ import { constantRoute } from '@/router/routers' import permissionStore from './permission' // 引入路由 import { - userRegisterService, userLoginService, userGetInfoService, userPhoneLoginService, @@ -37,10 +36,15 @@ const useUserStore = defineStore( // 登录事件 async userLogin(data: loginType) { console.log(data, 'pinia') - const res: loginResponseType = await userLoginService(data) - this.token = res.data.token as string - console.log(res, '传回的值1') + const res: loginResponseType = await userLoginService(data).catch( + (error) => { + ElMessage.error(error.response.data.message) + console.log(error, 'error') + }, + ) + if (res.code === 200) { + this.token = res.data.token as string SET_TKOEN('TOKEN', this.token) // localStorage.setItem('TOKEN', this.token) ElNotification({ @@ -51,19 +55,20 @@ const useUserStore = defineStore( return 'ok' } else { console.log(res, '33333') - ElNotification({ - // type: 'error', - message: res.message, - }) + // ElNotification({ + // // type: 'error', + // message: res.message, + // }) + ElMessage.error(res.message) return Promise.reject(new Error(res.data.message)) } }, //手机号登录 async userPhoneLogin(data: loginType) { const res: loginResponseType = await userPhoneLoginService(data) - this.token = res.data.token as string //接收返回的token console.log(res, 11111) if (res.code === 200) { + this.token = res.data.token as string //接收返回的token SET_TKOEN('TOKEN', this.token) // localStorage.setItem('TOKEN', this.token) ElNotification({ @@ -75,7 +80,7 @@ const useUserStore = defineStore( } else { ElNotification({ type: 'error', - message: res.data.message, + message: res.message, }) return Promise.reject(new Error(res.data.message)) } diff --git a/src/views/course/CourseObjectives.vue b/src/views/course/CourseObjectives.vue index 87b0412..2a660ac 100644 --- a/src/views/course/CourseObjectives.vue +++ b/src/views/course/CourseObjectives.vue @@ -1,9 +1,121 @@ - - 课程目标 - - - + + + + + | 课程总目标 + + + 通过本课程的学习,使学生进一步了解计算机的工作原理,更好地理解和应用计算机,掌 + 握用计算机处理问题的方法和技能:培养学生分析问题、解决问题的能力以及编制程序实现算 + 法的能力。 + + + + + + | 课程总目标 + + + + + + | 课程分目标 + + + + + + + diff --git a/src/views/group/index.vue b/src/views/group/index.vue index 4fc55f6..6978e96 100644 --- a/src/views/group/index.vue +++ b/src/views/group/index.vue @@ -1,181 +1,6 @@ + - - - - - 智慧物业管理平台 - - - - - - {{ item.text }} - - - - - - - - - - - 获取验证码 - {{ countTime }} - - - 登录 - - - - - - - 重置密码> - 登录 - - - - - + - - - + diff --git a/src/views/home/components/Class.vue b/src/views/home/components/Class1.vue similarity index 100% rename from src/views/home/components/Class.vue rename to src/views/home/components/Class1.vue diff --git a/src/views/home/components/Class2.vue b/src/views/home/components/Class2.vue new file mode 100644 index 0000000..62a7f03 --- /dev/null +++ b/src/views/home/components/Class2.vue @@ -0,0 +1,108 @@ + + + + + + + + + + {{ course.name }} + {{ course.hours }} + + + + + + + diff --git a/src/views/home/components/Info.vue b/src/views/home/components/Info.vue index 5f2de25..e021807 100644 --- a/src/views/home/components/Info.vue +++ b/src/views/home/components/Info.vue @@ -1,26 +1,16 @@ @@ -105,14 +157,14 @@ function confirmClick() { - + @@ -130,6 +182,7 @@ function confirmClick() { v-model="editDialogVisible" title="详细信息" style="width: 800px; text-align: center" + :readonly-field="readonlyField" > @@ -139,7 +192,7 @@ function confirmClick() { - + 取消 保存 diff --git a/src/views/home/components/Status.vue b/src/views/home/components/Status.vue index bde7a7b..aee3a41 100644 --- a/src/views/home/components/Status.vue +++ b/src/views/home/components/Status.vue @@ -2,7 +2,7 @@ import add from '@/assets/images/add.png' // import { Plus } from '@element-plus/icons-vue' import { userChangeService } from '@/api/user/user.js' -import { client, tool } from '@/utils/img' +import { tool } from '@/utils/img' const dialogFormVisible = ref(false) import { ref } from 'vue' const props = defineProps({ @@ -55,25 +55,16 @@ const openFileInput = () => { imageUrl.value = reader.result } reader.readAsDataURL(file) + changeInfo() } } document.body.appendChild(input) input.click() document.body.removeChild(input) } -// const upload = async (option) => { -// console.log(option, 88888) -// const res = await tool.oss.upload(option.file) // console.log(res.url) -// imageUrl.value = res.url -// // imgUrl.value = formModel.value.img -// console.log(imageUrl.value, 1111155) -// } const upload = async (option) => { - // console.log(option) const res = await tool.oss.upload(option.file) - // console.log(res.url) imageUrl.value = res.url - // imgUrl.value = formModel.value.img console.log(imageUrl.value) } //修改用户信息 @@ -106,22 +97,16 @@ const changeInfo = async () => { @click="dialogFormVisible = true" > {{ props.data.username }} - 身份:某某专业教师 - + diff --git a/src/views/home/components/Student.vue b/src/views/home/components/Student1.vue similarity index 100% rename from src/views/home/components/Student.vue rename to src/views/home/components/Student1.vue diff --git a/src/views/home/components/Student2.vue b/src/views/home/components/Student2.vue new file mode 100644 index 0000000..716789c --- /dev/null +++ b/src/views/home/components/Student2.vue @@ -0,0 +1,97 @@ + + + + + 编辑 + + + + 78 + + + + + + + cancel + + confirm + + + + + + + + + {{ item }} + + + + + diff --git a/src/views/home/index.vue b/src/views/home/index.vue index f892985..8f53111 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -3,8 +3,10 @@ import status from '@/views/home/components/Status.vue' import welcome from './components/Welcome.vue' import Info from './components/Info.vue' import echarts from './components/Echarts.vue' -import Class from './components/Class.vue' -import Student from './components/Student.vue' +import Class1 from './components/Class1.vue' +import Student1 from './components/Student1.vue' +import Class2 from './components/Class2.vue' +import Student2 from './components/Student2.vue' import useUserStore from '@/store/modules/user' import { ref, onMounted } from 'vue' import { toRaw } from 'vue' @@ -14,15 +16,29 @@ const userStore = useUserStore() const username = ref() const data = ref(null) const flag = ref(false) +const role = ref(null) +const rightVisible = ref(false) const getData = async () => { - await userStore.getUserInfo().then((response) => { - const res = toRaw(response.result.data) - username.value = res.username - data.value = res - flag.value = true - console.log(data.value, 333333) - }) + await userStore + .getUserInfo() + .then((response) => { + const res = toRaw(response.result.data) + username.value = res.username + data.value = res + flag.value = true + role.value = data.value.roles[0] + if (role.value === '老师') { + rightVisible.value = true + } else { + rightVisible.value = false + } + // console.log(data.value.roles[0], 333333) + }) + .catch((error) => { + console.log(error) + }) } + onMounted(() => { getData() }) @@ -40,13 +56,22 @@ onMounted(() => { - + + + + + + + + + + - + - + diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 42287d5..28911ae 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -20,7 +20,6 @@ v-if="isRegister" > Hello - 账号 手机号 @@ -66,14 +65,7 @@ :prefix-icon="Phone" placeholder="请输入手机号" size="large" - style=" - flex: 1; - /* height: 40px; - line-height: 40px; - border: 1px solid #dcdfe6; - width: 50%; - color: #dcdfe6; */ - " + style="flex: 1" /> @@ -156,8 +148,10 @@ :prefix-icon="Check" size="large" show-repassword + @change="checkPasswordMatch" > + + + + 登录 + + @@ -212,7 +215,7 @@ size="large" class="login-btn" type="primary" - @click="phoneSubmit" + @click="phoneChange" > 注册 @@ -229,26 +232,47 @@ show-password > - - + - 确认 - + + 返回 + + + + + 确认 + + + + + 登录 + + - - - 登录 - - @@ -334,17 +358,6 @@ const rules = { message: '密码长度最小六位最大十五位', trigger: ['change', 'blur'], }, - { - validater: (rule, value, callback) => { - //判断value和password是否一致 - if ((value = formModel.value.password)) { - callback(new Error('两次输入的密码不一致')) - } else { - callback() - } - }, - trigger: ['change', 'blur'], - }, ], phone: [ { required: true, message: '手机号不能为空', trigger: 'blur' }, @@ -361,10 +374,6 @@ const rules = { //验证码倒计时--没搞定 const countdown = ref(0) let timer -const startCountdown = () => { - countdown.value = 60 // 设置倒计时初始值 - timer = setInterval(updateCountdown, 1000) // 每秒更新倒计时 -} const updateCountdown = () => { if (countdown.value > 0) { countdown.value-- @@ -395,12 +404,23 @@ watch(isToggle, () => { code: '', } }) +//确认密码 +const passwordMatchError = ref('') +const checkPasswordMatch = () => { + if (formModel.value.password !== formModel.value.repassword) { + // passwordMatchError.value = '两次输入的密码不一致' + ElMessage('两次输入的密码不一致') + } else { + passwordMatchError.value = '' + } +} //账号注册表单写成json格式 const handleSubmit = async () => { - try { - // 执行注册逻辑 - await form.value.validate() - console.log('开始注册') + // 执行注册逻辑 + await form.value.validate() + console.log('开始注册') + if (formModel.value.password === formModel.value.repassword) { + // 密码校验通过,可以进行注册操作 const dataToSend = { username: formModel.value.username, password: formModel.value.password, @@ -412,14 +432,18 @@ const handleSubmit = async () => { console.log(jsonData) // 发送数据到服务器或其他操作 userRegisterService(jsonData) - // 注册成功后跳转到指定页面 - ElMessage.success('注册成功') - // // 切换到登录 - isRegister.value = true - } catch (error) { - // 处理错误信息 - // 显示错误信息给用户 - ElMessage.error('Oops, this is a error message.') + .then(() => { + // 注册成功后跳转到指定页面 + ElMessage.success('注册成功') + // // 切换到登录 + isRegister.value = true + }) + .catch((error) => { + ElMessage.error(error.response.data.message) + }) + } else { + // 密码校验不通过 + passwordMatchError.value = '两次输入的密码不一致' } } // const userGetInfoService @@ -429,89 +453,90 @@ const codeSubmit = async () => { await form.value.validate() console.log('开始发起注册验证码') const phoness = formModel.value.phone - // const jsonData = JSON.stringify(dataToSend) - // console.log(phoness) - // 发送手机号到服务器或其他操作 - const res = userCodeRegisterService(phoness) - console.log(res) - userCodeRegisterService(phoness).then((response) => { - codecode.value = response.data - console.log(codecode.value) - }) + userCodeRegisterService(phoness) + .then((response) => { + codecode.value = response.data + console.log(codecode.value) + }) + .catch((error) => { + console.log(error.message, 'error') + }) } //手机号注册 +const phoneChange = () => { + console.log('开始手机号注册') + isinfo.value = false +} +//注册中的返回 +const phoneReturn = () => { + isinfo.value = true +} const phoneSubmit = async () => { await form.value.validate() - console.log('开始手机号注册') - try { - // 执行注册逻辑 - if (formModel.value.code == codecode.value) { - isinfo.value = false - const dataToSend = { - phone: formModel.value.phone, - password: formModel.value.password, - } - const jsonData = JSON.stringify(dataToSend) - // 发送手机号到服务器或其他操作 - await userPhoneRegisterService(jsonData) - console.log(jsonData) - // 注册成功后跳转到指定页面 - isinfo.value = false + // 执行注册逻辑 + if (formModel.value.code == codecode.value) { + isinfo.value = false + const dataToSend = { + phone: formModel.value.phone, + password: formModel.value.password, } - } catch (error) { - // 处理错误信息 - // 显示错误信息给用户 - ElMessage.error('注册失败返回错误信息') + const jsonData = JSON.stringify(dataToSend) + // 发送手机号到服务器或其他操作 + userPhoneRegisterService(jsonData) + .then(() => { + // 注册成功后跳转到指定页面 + ElMessage.success('注册成功') + // // 切换到登录 + isRegister.value = true + }) + .catch((error) => { + ElMessage.error(error.response.data.message) + }) } } - //账号登录接口 const login = async () => { // 等待校验通过 await form.value.validate() + isBtnLoading.value = true try { - isBtnLoading.value = true - await userStore.userLogin(formModel.value) - isBtnLoading.value = false - $router.push('/home') - if ($route.query.redirect) { - $router.push($route.query.redirect as string) - } else { - $router.push('/') - } + await userStore.userLogin(formModel.value).then(() => { + isBtnLoading.value = false + $router.push('/home') + if ($route.query.redirect) { + $router.push($route.query.redirect as string) + } else { + $router.push('/') + } + }) } catch (error) { isBtnLoading.value = false - console.log(error, '111111') } } //手机号登录 -// const log = ref() const phoneLogin = async () => { // 等待校验通过 await form.value.validate() - try { - isBtnLoading.value = true - if (formModel.value.code == codecode.value) { - const phones = formModel.value.phone - // console.log(dataToSend) - userStore.userPhoneLogin(phones) - // console.log(res) - // .then((response) => { - // log.value = response.data - // console.log(log.value) - // }) - // await userStore.userPhoneLogin(dataToSend) - } - isBtnLoading.value = false - $router.push('/home') - if ($route.query.redirect) { - $router.push($route.query.redirect as string) - } else { - $router.push('/') - } - } catch (error) { - isBtnLoading.value = false + isBtnLoading.value = true + if (formModel.value.code == codecode.value) { + const phones = formModel.value.phone + // console.log(dataToSend) + userStore + .userPhoneLogin(phones) + .then(() => { + isBtnLoading.value = false + $router.push('/home') + if ($route.query.redirect) { + $router.push($route.query.redirect as string) + } else { + $router.push('/') + } + }) + .catch((error) => { + isBtnLoading.value = false + ElMessage.error(error.response.data.message) + }) } } const keyDown = (e: any) => { diff --git a/src/views/message/index.vue b/src/views/message/index.vue index 6d4c443..4ce7196 100644 --- a/src/views/message/index.vue +++ b/src/views/message/index.vue @@ -1,107 +1,5 @@ - - Open Drawer - - - - - - - Edit - - - - - - - - - - - - - - - - - - Cancel - Save - - - - + 消息 - + diff --git a/src/views/portal/courseHomepage.vue b/src/views/portal/courseHomepage.vue index 65390e1..127d483 100644 --- a/src/views/portal/courseHomepage.vue +++ b/src/views/portal/courseHomepage.vue @@ -1,173 +1,7 @@ - - - - - - - Hello - 同学! - - - - - - - - - 登录 - - - - - - - + - + - + diff --git a/src/views/student/index.vue b/src/views/student/index.vue index 4516860..74c4ecc 100644 --- a/src/views/student/index.vue +++ b/src/views/student/index.vue @@ -1,536 +1,30 @@ - - - - - - - - - Hello - - - 账号 - 手机号 - - - - - - - - - - - - - - - - - - - - {{ countdown }} 秒 - - - 发送验证码 - - - - - - 登录 - - - - - 注册 → - - - - - - Hello - - 账号 - 手机号 - - - - - - - - - - - - - - - - - - - - - - - {{ countdown }} 秒 - - - - 发送验证码 - - - - - - - - 注册 - - - - - 登录 → - - - - - - + + + - - -
| 课程总目标
| 课程分目标
获取验证码
{{ countTime }}
{{ course.name }}
{{ course.hours }}
{{ countdown }} 秒