This commit is contained in:
yuping
2022-12-13 17:02:07 +08:00
parent de9b83c9e7
commit 19bfce36fe
5 changed files with 151 additions and 91 deletions

4
src/api/ThirdApi.js Normal file
View File

@@ -0,0 +1,4 @@
export const BASE = 'https://u-pre.boe.com'
export const GET_USER_LIST = `/userbasic/user/list post`

View File

@@ -1,6 +1,7 @@
import router from "@/router";
import {reactive, ref, toRefs, watch} from "vue";
import axios from 'axios';
import {getCookie} from "@/api/utils";
export function usePage(_url, param) {
@@ -110,3 +111,38 @@ export async function request(_url, params) {
// router.push({path: '/login'})
})
}
export async function boeRequest(_url, params) {
const s = _url.split(' ')
let url = s[0]
const method = s[1]?.toLowerCase() || 'get'
if (method === 'get') {
let paramsArray = [];
//拼接参数
if (params) {
Object.keys(params).forEach(key => paramsArray.push(key + '=' + params[key]))
if (url.search(/\?/) === -1) {
url += '?' + paramsArray.join('&')
} else {
url += '&' + paramsArray.join('&')
}
}
}
const body = method !== 'get' ? params || {} : {}
return axios({
url,
method,
headers: {
token: getCookie('token'),
...method !== 'get' ? {'Content-Type': 'application/json'} : {}
},
baseURL: '',
...method !== 'get' ? {data: JSON.stringify(body)} : {}
}).then(resp => resp.data).then(response => {
return response
}).catch(e => {
console.log(2222)
console.log(e)
// router.push({path: '/login'})
})
}

View File

@@ -1,3 +1,7 @@
import {watch, ref} from "vue";
import {boeRequest} from "@/api/request";
import {BASE, GET_USER_LIST} from "@/api/ThirdApi";
export function useImage(src) {
return new URL(`../assets/image/${src}`, import.meta.url).href
}
@@ -11,3 +15,13 @@ export function setCookie(name, value, perpetual) {
export function getCookie(name) {
return document.cookie?.split(";").find(e => e.includes(name)).replace(`${name}=`, '') || ''
}
export function useUserInfoAvatar(id) {
const avatar = ref(import.meta.env.DEV ? `${BASE}/upload` : '')
watch(id, () => {
id.value && boeRequest(GET_USER_LIST, {id: id.value}).then(res => {
avatar.value = avatar.value + res.result.userInfoList[0].avatar
})
})
return avatar
}

View File

@@ -182,7 +182,7 @@
class="teacheritem"
:style="{'border-bottom': '1px solid rgba(56, 125, 247, 0.2)'}"
>
<img class="peopleimg" :src="data.userInfoBo?.peopleimg"/>
<img class="peopleimg" :src="userAvatar"/>
<div style="margin-left: 17px">
<div class="teacherName">
<div style="margin-right: 5px">{{ data.userInfoBo?.userName }}</div>
@@ -213,7 +213,7 @@
<div class="progress">
<div style="width: 291px">
<el-progress
:percentage="data.totalChapterCnt"
:percentage="parseInt(data.currentChapterCnt/data.totalChapterCnt * 100)"
:show-text="false"
:stroke-width="8"
:color="
@@ -224,7 +224,7 @@
3:'rgba(59, 94, 251, 1)',
4:'rgba(57, 219, 183, 1)',
5:'rgba(57, 219, 183, 1)'
}[parseInt(data.totalChapterCnt/20)]
}[parseInt(data.currentChapterCnt/data.totalChapterCnt)]
"
/>
</div>
@@ -242,10 +242,10 @@
3:'rgba(59, 94, 251, 1)',
4:'rgba(57, 219, 183, 1)',
5:'rgba(57, 219, 183, 1)'
}[parseInt(data.totalChapterCnt/20)]
}[parseInt(data.currentChapterCnt/data.totalChapterCnt)]
}"
>
{{ data.totalChapterCnt }}%
{{ parseInt(data.currentChapterCnt / data.totalChapterCnt * 100) }}%
</div>
</div>
</div>
@@ -256,7 +256,7 @@
<div class="progress">
<div style="width: 291px">
<el-progress
:percentage="data.currentChapterCnt"
:percentage="parseInt(data.currentReqCnt/data.totalReqCnt * 100)"
:show-text="false"
:stroke-width="8"
:color="
@@ -267,7 +267,7 @@
3:'rgba(59, 94, 251, 1)',
4:'rgba(57, 219, 183, 1)',
5:'rgba(57, 219, 183, 1)'
}[parseInt(data.currentChapterCnt/20)]
}[parseInt(data.currentReqCnt/data.totalReqCnt)]
"
/>
</div>
@@ -287,10 +287,10 @@
3:'rgba(59, 94, 251, 1)',
4:'rgba(57, 219, 183, 1)',
5:'rgba(57, 219, 183, 1)'
}[parseInt(data.currentChapterCnt/20)]
}[parseInt(data.currentReqCnt/data.totalReqCnt)]
}"
>
{{ data.currentChapterCnt }}%
{{ parseInt(data.currentReqCnt / data.totalReqCnt * 100) }}%
</div>
</div>
</div>
@@ -305,7 +305,7 @@
</template>
<script setup>
import {reactive, ref} from "vue";
import {computed, reactive, ref, watch} from "vue";
import word from '@/assets/image/file/word.png'
import ppt from '@/assets/image/file/ppt.png'
import pdf from '@/assets/image/file/pdf.png'
@@ -315,14 +315,17 @@ import medal1 from '@/assets/image/medal/medal1.png'
import medal2 from '@/assets/image/medal/medal2.png'
import medal3 from '@/assets/image/medal/medal3.png'
import img from '@/assets/image/uploadimg.png'
import {useRequest} from "@/api/request";
import {boeRequest, useRequest} from "@/api/request";
import {ROUTER_PROCESS} from "@/api/api";
import {useRoute, useRouter} from "vue-router";
import {ElMessage} from 'element-plus'
import {useUserInfoAvatar} from "@/api/utils";
const {query: {routerId}} = useRoute()
const router = useRouter()
const {data} = useRequest(ROUTER_PROCESS, {routerId})
const userAvatar = useUserInfoAvatar(computed(() => data.value?.userInfoBo?.userId))
const state = reactive({
course: [
{

View File

@@ -35,60 +35,63 @@ export default defineConfig(({ command }) =>
{find: '@', replacement: path.resolve(__dirname, 'src')}
]
},
// server: {
// proxy: {
// '/file/upload': {
// target: 'http://111.231.196.214:30001',
// changeOrigin: true,
// },
// '/stu': {
// target: url,
// changeOrigin: true,
// },
// '/queryVoteSubmitDetailById': {
// target: url,
// changeOrigin: true,
// },
// '/work': {
// target: url,
// changeOrigin: true,
// },
// '/discuss': {
// target: url,
// changeOrigin: true,
// },
// '/discussSubmit': {
// target: url,
// changeOrigin: true,
// },
// '/comment': {
// target: url,
// changeOrigin: true,
// },
// '/vote': {
// target: url,
// changeOrigin: true,
// },
// '/admin': {
// target: url,
// changeOrigin: true,
// }, '/activity': {
// target: url,
// changeOrigin: true,
// }, '/liveBroadcast': {
// target: url,
// changeOrigin: true,
// }, '/examination': {
// target: url,
// changeOrigin: true,
// }, '/assessment': {
// target: url,
// changeOrigin: true,
// },'/workSubmit': {
// target: url,
// changeOrigin: true,
// },
// }
// }
server: {
proxy: {
'/file/upload': {
target: 'http://111.231.196.214:30001',
changeOrigin: true,
},
'/stu': {
target: url,
changeOrigin: true,
},
'/queryVoteSubmitDetailById': {
target: url,
changeOrigin: true,
},
'/work': {
target: url,
changeOrigin: true,
},
'/discuss': {
target: url,
changeOrigin: true,
},
'/discussSubmit': {
target: url,
changeOrigin: true,
},
'/comment': {
target: url,
changeOrigin: true,
},
'/vote': {
target: url,
changeOrigin: true,
},
'/admin': {
target: url,
changeOrigin: true,
}, '/activity': {
target: url,
changeOrigin: true,
}, '/liveBroadcast': {
target: url,
changeOrigin: true,
}, '/examination': {
target: url,
changeOrigin: true,
}, '/assessment': {
target: url,
changeOrigin: true,
}, '/workSubmit': {
target: url,
changeOrigin: true,
}, '/userbasic': {
target: 'https://u-pre.boe.com',
changeOrigin: true,
},
}
}
})
)