修改接口调用

develoop
ww 5 months ago
parent 1017abb695
commit 79505bbd4c
  1. 1
      src/store/modules/type/types.ts
  2. 7
      src/store/modules/user.ts
  3. 3
      src/views/courseResources/index.vue
  4. 4
      src/views/home/components/Class1.vue
  5. 4
      src/views/home/components/Class2.vue
  6. 136
      src/views/home/components/Info.vue
  7. 8
      src/views/home/components/Status.vue
  8. 2
      src/views/home/components/Student1.vue
  9. 2
      src/views/home/components/Student2.vue
  10. 51
      src/views/home/index.vue

@ -7,4 +7,5 @@ export interface LoginStoreType {
routes: string routes: string
phone: string phone: string
userInfo: object userInfo: object
data: object
} }

@ -32,12 +32,13 @@ const useUserStore = defineStore(
avatar: '', // 用户头像 avatar: '', // 用户头像
routes: '', routes: '',
userInfo: {}, // 当前用户相关信息 userInfo: {}, // 当前用户相关信息
data: {},
} }
}, },
actions: { actions: {
// 登录事件 // 登录事件
async userLogin(data: loginType) { async userLogin(data: loginType) {
console.log(data, 'pinia') // console.log(data, 'pinia')
const res: loginResponseType = await userLoginService(data).catch( const res: loginResponseType = await userLoginService(data).catch(
(error) => { (error) => {
ElMessage.error(error.response.data.message) ElMessage.error(error.response.data.message)
@ -94,8 +95,8 @@ const useUserStore = defineStore(
if (result.code === 200) { if (result.code === 200) {
const res = await userIdenService(result.data.id) const res = await userIdenService(result.data.id)
this.userInfo = res.data this.userInfo = res.data
console.log(this.userInfo, 'this.userInfo') // console.log(this.userInfo, 'this.userInfo')
this.data = result.data
console.log(result, '123') console.log(result, '123')
this.userName = result.data.username this.userName = result.data.username
// this.avatar = result.data.checkUser.avatar // this.avatar = result.data.checkUser.avatar

@ -268,11 +268,8 @@ ul {
li { li {
transition: filter 0.3s; /* 添加过渡动画 */ transition: filter 0.3s; /* 添加过渡动画 */
flex: 0 0 20%; flex: 0 0 20%;
<<<<<<< HEAD
=======
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
>>>>>>> f6dea2720fd0ad6ab62f53607d894cd0c406cb6d
margin-bottom: 10px; margin-bottom: 10px;
padding: 10px; padding: 10px;
box-sizing: border-box; box-sizing: border-box;

@ -24,9 +24,9 @@ const courses = [
] ]
</script> </script>
<template> <template>
<div class="info_container" style="width: 214px; height: 326px"> <div class="info_container" style="width: 90%; height: 326px">
<conheader title="已开科目"></conheader> <conheader title="已开科目"></conheader>
<div class="info_content" style="width: 214px; height: 264px"> <div class="info_content" style="width: 100%; height: 264px">
<div class="course-list"> <div class="course-list">
<div <div
v-for="(course, index) in courses" v-for="(course, index) in courses"

@ -24,9 +24,9 @@ const courses = [
] ]
</script> </script>
<template> <template>
<div class="info_container" style="width: 214px; height: 326px"> <div class="info_container" style="width: 90%; height: 326px">
<conheader title="我的科目"></conheader> <conheader title="我的科目"></conheader>
<div class="info_content" style="width: 214px; height: 264px"> <div class="info_content" style="width: 100%; height: 264px">
<div class="course-list"> <div class="course-list">
<div <div
v-for="(course, index) in courses" v-for="(course, index) in courses"

@ -1,7 +1,7 @@
<script setup> <script setup>
import conheader from '@/views/home/components/ConHeader.vue' import conheader from '@/views/home/components/ConHeader.vue'
import { onMounted, ref, computed } from 'vue' import { onMounted, ref, computed } from 'vue'
import { userIdenService, userIdenChangeService } from '@/api/user/user.js' import { userIdenChangeService } from '@/api/user/user.js'
import { Edit } from '@element-plus/icons-vue' import { Edit } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
const props = defineProps({ const props = defineProps({
@ -9,7 +9,7 @@ const props = defineProps({
type: Object, type: Object,
}, },
}) })
const id = props.data.id console.log(props.data, 'info')
const formModel = ref() const formModel = ref()
const loading = ref() const loading = ref()
//true //true
@ -45,81 +45,65 @@ const cancelEdit = () => {
} }
} }
const identInfo = ref() const identInfo = ref()
//
// const getInfo = async (id) => {
// const res = await userIdenService(id)
// identInfo.value = res
// return res
// }
console.log()
onMounted(() => { onMounted(() => {
// getInfo(id) // console.log(props.data, 'res')
// getInfo(id) if (props.data.roleId === 1) {
// .then((res) => { formModel.value = [
// // 访 getData { par: 'name', name: '姓名', content: props.data.name },
// console.log(res.data, '000000') { par: 'sex', name: '性别', content: props.data.sex },
// identInfo.value = res.data { par: 'nationality', name: '民族', content: props.data.nationality },
// // { par: 'profession', name: '专业', content: props.data.profession },
// if (res.data.roleId === 1) { { par: 'education', name: '学历', content: props.data.education },
// formModel.value = [ { par: 'degree', name: '学位', content: props.data.degree },
// { par: 'name', name: '', content: res.data.name }, {
// { par: 'sex', name: '', content: res.data.sex }, par: 'professionalTitle',
// { par: 'nationality', name: '', content: res.data.nationality }, name: '职称',
// { par: 'profession', name: '', content: res.data.profession }, content: props.data.professionalTitle,
// { par: 'education', name: '', content: res.data.education }, },
// { par: 'degree', name: '', content: res.data.degree }, {
// { par: 'emergencyContact',
// par: 'professionalTitle', name: '手机号',
// name: '', content: props.data.emergencyContact,
// content: res.data.professionalTitle, },
// }, {
// { par: 'joinWorkTime',
// par: 'emergencyContact', name: '参加工作时间',
// name: '', content: props.data.joinWorkTime,
// content: res.data.emergencyContact, },
// }, {
// { par: 'politicalStatus',
// par: 'joinWorkTime', name: '政治面貌',
// name: '', content: props.data.politicalStatus,
// content: res.data.joinWorkTime, },
// }, ]
// { } else if (props.data.roleId === 2) {
// par: 'politicalStatus', formModel.value = [
// name: '', { par: 'name', name: '姓名', content: props.data.name },
// content: res.data.politicalStatus, { par: 'sex', name: '性别', content: props.data.sex },
// }, { par: 'nationality', name: '民族', content: props.data.nationality },
// ] { par: 'number', name: '学号', content: props.data.number },
// } else if (res.data.roleId === 2) { { par: 'birthday', name: '生日', content: props.data.birthday },
// formModel.value = [ { par: 'phone', name: '手机号', content: props.data.phone },
// { par: 'name', name: '', content: res.data.name }, { par: 'faculty', name: '院系', content: props.data.faculty },
// { par: 'sex', name: '', content: res.data.sex }, { par: 'major', name: '专业', content: props.data.major },
// { par: 'nationality', name: '', content: res.data.nationality }, { par: 'year_age', name: '入学年份', content: props.data.year_age },
// { par: 'number', name: '', content: res.data.number }, { par: 'class_name', name: '班级', content: props.data.class_name },
// { par: 'birthday', name: '', content: res.data.birthday }, ]
// { par: 'phone', name: '', content: res.data.phone }, }
// { par: 'faculty', name: '', content: res.data.faculty }, // else {
// { par: 'major', name: '', content: res.data.major }, // formModel.value = [
// { par: 'year_age', name: '', content: res.data.year_age }, // { name: '', content: res.data.name },
// { par: 'class_name', name: '', content: res.data.class_name }, // { name: '', content: res.data.id },
// ] // { name: '', content: 9.9 },
// } // { name: '', content: 9.9 },
// // else { // { name: '', content: 9.9 },
// // formModel.value = [ // { name: '', content: 9.9 },
// // { name: '', content: res.data.name }, // { name: '', content: 9.9 },
// // { name: '', content: res.data.id }, // { name: '', content: 9.9 },
// // { name: '', content: 9.9 }, // { name: '', content: 9.9 },
// // { name: '', content: 9.9 }, // ]
// // { name: '', content: 9.9 }, // }
// // { name: '', content: 9.9 }, console.log(formModel.value)
// // { name: '', content: 9.9 },
// // { name: '', content: 9.9 },
// // { name: '', content: 9.9 },
// // ]
// // }
// })
// .catch((error) => {
// console.error(error)
// })
}) })
// 1 // 1
const drawer2 = ref(false) const drawer2 = ref(false)

@ -9,7 +9,8 @@ const props = defineProps({
type: Object, type: Object,
}, },
}) })
// console.log(props.data.icon, 44444) // const data = ref(props.data, 'dsfd')
console.log(props.data, 44444)
const imageUrl = ref('') const imageUrl = ref('')
// //
const form = ref() const form = ref()
@ -61,11 +62,6 @@ const openFileInput = () => {
input.click() input.click()
document.body.removeChild(input) document.body.removeChild(input)
} }
const upload = async (option) => {
const res = await tool.oss.upload(option.file)
imageUrl.value = res.url
console.log(imageUrl.value)
}
// //
const changeInfo = async () => { const changeInfo = async () => {
const userInfo = { const userInfo = {

@ -16,7 +16,7 @@ function confirmClick() {
} }
</script> </script>
<template> <template>
<div class="info_container" style="width: 222px; height: 174px"> <div class="info_container" style="width: 90%; height: 174px">
<conheader title="学生分组" v-model="drawer2"> <conheader title="学生分组" v-model="drawer2">
<div>编辑</div> <div>编辑</div>
<template #drawer> <template #drawer>

@ -16,7 +16,7 @@ function confirmClick() {
} }
</script> </script>
<template> <template>
<div class="info_container" style="width: 222px; height: 174px"> <div class="info_container" style="width: 90%; height: 174px">
<conheader title="已分组别" v-model="drawer2"> <conheader title="已分组别" v-model="drawer2">
<div>编辑</div> <div>编辑</div>
<template #drawer> <template #drawer>

@ -9,39 +9,34 @@ import Class2 from './components/Class2.vue'
import Student2 from './components/Student2.vue' import Student2 from './components/Student2.vue'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import { toRaw } from 'vue'
const userStore = useUserStore() const userStore = useUserStore()
// const info = userStore.getUserInfo()
// userStore.userInfo
// console.log(info)
const username = ref() const username = ref()
const data = ref(null) const data = ref({})
const infoData = ref()
const flag = ref(false) const flag = ref(false)
const role = ref(null) const role = ref(null)
const rightVisible = ref(false) const rightVisible = ref(false)
const getData = async () => { const getData = async () => {
await userStore await userStore.getUserInfo().catch((error) => {
.getUserInfo() console.log(error)
.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, 333333)
})
.catch((error) => {
console.log(error)
})
} }
onMounted(() => { onMounted(() => {
getData() // getData()
username.value = userStore.userName
data.value = userStore.data
infoData.value = userStore.userInfo
// console.log(data.value, '11111')
// console.log(userStore.userInfo, '22222')
// console.log(userStore, 'userStore')
username.value = data.value.username
flag.value = true
role.value = data.value.roles[0]
if (role.value === '老师') {
rightVisible.value = true
} else {
rightVisible.value = false
}
}) })
</script> </script>
<template> <template>
@ -51,7 +46,7 @@ onMounted(() => {
<welcome :username="username"></welcome> <welcome :username="username"></welcome>
</div> </div>
<div class="info" style="width: 100%; height: 368px"> <div class="info" style="width: 100%; height: 368px">
<Info :data="data" v-if="flag"></Info> <Info :data="infoData" v-if="flag"></Info>
</div> </div>
<div class="echarts" style="width: 100%; height: 444px"> <div class="echarts" style="width: 100%; height: 444px">
<echarts></echarts> <echarts></echarts>
@ -59,10 +54,10 @@ onMounted(() => {
</div> </div>
<div v-if="rightVisible" class="right"> <div v-if="rightVisible" class="right">
<status :data="data" v-if="flag"></status> <status :data="data" v-if="flag"></status>
<div class="class" style="width: 278px; height: 388px"> <div class="class" style="width: 100%; height: 388px">
<Class1></Class1> <Class1></Class1>
</div> </div>
<div class="stu" style="width: 278px; height: 236px"> <div class="stu" style="width: 100%; height: 236px">
<Student1></Student1> <Student1></Student1>
</div> </div>
</div> </div>

Loading…
Cancel
Save