parent
c0ec953709
commit
2e1cef3492
8 changed files with 158 additions and 55 deletions
After Width: | Height: | Size: 4.0 KiB |
@ -1,19 +1,40 @@ |
||||
import { defineStore } from 'pinia' |
||||
const userStore = defineStore('userStore', { |
||||
state() { |
||||
return { |
||||
token: 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ4aWFvMTExMSIsImNyZWF0ZWQiOjE3MjQ2NTQxNjMxMjIsImV4cCI6MTcyNTI1ODk2M30.uIEZhGG6-XGomV0aqpamOn54VxP4ItfM_ip9EgI0ohcYPyEnln6dXBoG8eVBNlbigglIjw5V1N5bHPdIAifeaA', |
||||
import { userGetInfoService } from '@/api/configuration' |
||||
import { ref, reactive } from 'vue' |
||||
const userStore = defineStore('userStore', () => { |
||||
const userInfo = reactive<any>({}) |
||||
const isLogin = ref(false) |
||||
const token = ref('eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ4aWFvMTExMSIsImNyZWF0ZWQiOjE3MjQ2NTQxNjMxMjIsImV4cCI6MTcyNTI1ODk2M30.uIEZhGG6-XGomV0aqpamOn54VxP4ItfM_ip9EgI0ohcYPyEnln6dXBoG8eVBNlbigglIjw5V1N5bHPdIAifeaA') |
||||
|
||||
userGetInfoService(token.value).then(res => { |
||||
// @ts-ignore
|
||||
if (res.code === 200) { |
||||
Object.assign(userInfo, res.data) |
||||
isLogin.value = true |
||||
} |
||||
}, |
||||
actions: { |
||||
async verifyToken(token:string){ |
||||
const res = await verifyTokenApi({token}) |
||||
if(res){ |
||||
this.token = token |
||||
}else{ |
||||
return false |
||||
} |
||||
} |
||||
}, |
||||
}) |
||||
return { |
||||
token, |
||||
userInfo, |
||||
isLogin |
||||
} |
||||
}) |
||||
export default userStore |
||||
// const userStore = defineStore('userStore', {
|
||||
// state() {
|
||||
// return {
|
||||
// token: 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ4aWFvMTExMSIsImNyZWF0ZWQiOjE3MjQ2NTQxNjMxMjIsImV4cCI6MTcyNTI1ODk2M30.uIEZhGG6-XGomV0aqpamOn54VxP4ItfM_ip9EgI0ohcYPyEnln6dXBoG8eVBNlbigglIjw5V1N5bHPdIAifeaA',
|
||||
// }
|
||||
// },
|
||||
// actions: {
|
||||
// async verifyToken(token:string){
|
||||
// const res = await verifyTokenApi({token})
|
||||
// if(res){
|
||||
// this.token = token
|
||||
// }else{
|
||||
// return false
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// })
|
||||
// export default userStore
|
||||
|
@ -0,0 +1,80 @@ |
||||
<script setup lang="ts"> |
||||
import useUserStore from '@/store/module/user'; |
||||
const userStore = useUserStore() |
||||
import { ref, watch } from 'vue'; |
||||
import { userStudentListService } from '@/api/configuration'; |
||||
const loading = ref(false) |
||||
const stuList: any = ref([]) |
||||
const getStuList = async () => { |
||||
loading.value = true |
||||
const res = await userStudentListService(userStore.userInfo.id) |
||||
stuList.value = res.data |
||||
loading.value = false |
||||
} |
||||
|
||||
watch(() => userStore.userInfo.id, () => { |
||||
getStuList() |
||||
}) |
||||
|
||||
import defImg from '@/assets/images/default.png' |
||||
</script> |
||||
|
||||
<template> |
||||
<div class="stu-list"> |
||||
<div class="stu_content" v-loading="loading"> |
||||
<ul> |
||||
<li class="stu-item" v-for="(item, index) in stuList" :key="index"> |
||||
<img :src="item.icon || defImg" class="stu-item-img" /> |
||||
<div class="stu-item-info"> |
||||
<h4 style="font-weight: bold">{{ item.name }}</h4> |
||||
<h4 style="color: #666">{{ item.number }}</h4> |
||||
</div> |
||||
</li> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
</template> |
||||
|
||||
<style lang="scss" scoped> |
||||
.stu_content { |
||||
height: 86%; |
||||
overflow: hidden; |
||||
text-overflow: ellipsis; |
||||
font-family: 'Microsoft YaHei'; |
||||
|
||||
/* background-color: rgb(100, 100, 64); */ |
||||
.stu-item { |
||||
margin-top: 20px; |
||||
/* height: 100%; */ |
||||
/* border-radius: 10px; */ |
||||
/* background-color: #0080ff; */ |
||||
border-bottom: 1px solid #ededed; |
||||
/* border-radius: 10px; */ |
||||
/* box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); */ |
||||
box-shadow: 0 0 1px 0 rgba(0, 0, 0, 0.07); |
||||
display: flex; |
||||
padding: 5px; |
||||
/* margin: 10px; */ |
||||
justify-content: space-between; |
||||
} |
||||
|
||||
.stu-item-img { |
||||
background-color: yellow; |
||||
border-radius: 50%; |
||||
width: 40px; |
||||
height: 40px; |
||||
justify-content: center; |
||||
align-items: center; |
||||
} |
||||
|
||||
.stu-item-info { |
||||
/* margin-left: 15px; */ |
||||
width: 80%; |
||||
height: 40px; |
||||
background-color: #ffffff; |
||||
display: flex; |
||||
flex-direction: column; |
||||
justify-content: space-between; |
||||
} |
||||
} |
||||
</style> |
Loading…
Reference in new issue