Explorar el Código

论坛数据加载问题

canghailong hace 7 meses
padre
commit
df9f4864f1

+ 2 - 2
src/views/forum/addForum.vue

@@ -104,9 +104,9 @@
 			errorCorrection()
 		}
 	}
-	setTimeout(() => {
+	onMounted(() => {
 		getData()
-	}, 0)
+	})
 	// 关闭抽屉
 	const onClose = () => {
 		formRef.value.resetFields()

+ 4 - 1
src/views/forum/detail.vue

@@ -125,7 +125,10 @@
 		moreType.value = true
 		getDetail()
 	}
-	getDetail()
+	
+	onMounted(() => {
+		getDetail()
+	})
 </script>
 
 <style scoped>

+ 4 - 8
src/views/forum/index.vue

@@ -193,7 +193,7 @@
 			})
 		})
 	}
-	getTypeList()
+	
 
 	const exType = ref(false)
 	const tableData = ref([])
@@ -232,7 +232,7 @@
 		current: 1,
 		size: 10
 	})
-	loadData(pagination.value)
+	
 	// 切换应用标签查询菜单列表
 	const moduleClock = (value, t) => {
 		exType.value = false
@@ -260,13 +260,7 @@
 	const handleScroll = () => {
 		const tableContainer = window.document.querySelector('.main-content-wrapper')
 		const scrollPosition = tableContainer.scrollTop
-		const isTop = scrollPosition === 0
 		const isBottom = tableContainer.scrollHeight - scrollPosition - 20 < tableContainer.clientHeight
-		if (isTop) {
-			// pagination.value.current = 1
-			// loadData(pagination.value);
-			console.log('重新加载')
-		}
 		if (isBottom) {
 			if (tableTotal.value > pagination.value.current * pagination.value.size) {
 				pagination.value.current += 1
@@ -281,6 +275,8 @@
 
 	// 添加scroll监听
 	onMounted(() => {
+		getTypeList()
+		loadData(pagination.value)
 		nextTick(() => {
 			if (table.value) {
 				const tableContainer = window.document.querySelector('.main-content-wrapper')

+ 9 - 5
src/views/student/classCentre/index.vue

@@ -162,7 +162,6 @@
 			videoRef.value.src = classTimeData.value.filter((r) => r.funcType == 1)[0]?.url
 		})
 	}
-	getClassData()
 
 	const tabsActiveKey = ref('1')
 	const noteRef = ref()
@@ -195,9 +194,7 @@
 			timeStamp1.value = initialtime.value
 		}
 	}
-	nextTick(() => {
-		videoStart()
-	})
+
 	const timeUpdate = (e) => {
 		//获取当前播放时间 durationinitialtime
 		if (timeStamp1.value != parseInt(e.target.currentTime)) {
@@ -305,7 +302,7 @@
 			currentTimenew.value = parseFloat(data.endTime) / 1000
 		})
 	}
-	getVideoTime()
+
 	// 毫秒转换时分秒
 	function msToHMS(ms) {
 		if (typeof ms !== 'number' || isNaN(ms)) return '00:00:00'
@@ -379,6 +376,13 @@
 			}
 		})
 	})
+	onMounted(() => {
+		getClassData()
+		getVideoTime()
+		nextTick(() => {
+			videoStart()
+		})
+	})
 </script>
 <style scoped lang="less">
 	.classTitle {

+ 16 - 2
src/views/student/classCollect/index.vue

@@ -3,7 +3,7 @@
 		<a-list item-layout="vertical" size="large" :pagination="pagination" :data-source="listData">
 			<template #renderItem="{ item }">
 				<a-list-item key="item.title">
-					<a-list-item-meta>
+					<a-list-item-meta @click="jump(item)" style="cursor: pointer;">
 						<template #title>{{ item.courseName }}</template>
 						<template #description>
 							<div v-html="item.courseDesc"></div>
@@ -22,6 +22,8 @@
 </template>
 <script setup>
 	import classCentre from '@/api/student/classCentre'
+	import { useRoute, useRouter } from 'vue-router'
+	const router = useRouter()
 	const listData = ref([])
 	const pagination = ref({
 		current: 1,
@@ -31,7 +33,8 @@
 		pageSize: 10
 	})
 	const getList = (current) => {
-		classCentre.classCollectList({
+		classCentre
+			.classCollectList({
 				current: current ? current : pagination.value.current,
 				size: pagination.value.pageSize
 			})
@@ -40,6 +43,17 @@
 			})
 	}
 	getList()
+	const jump = (t) => {
+		router.push({
+			path: '/student/classCentre',
+			query: {
+				id: t.courseId
+			}
+		})
+	}
+	onMounted(() => {
+		getList()
+	})
 </script>
 <style scoped>
 	.index-message-list {

+ 3 - 1
src/views/student/classNotice/index.vue

@@ -32,7 +32,9 @@
 				listData.value = data.records
 			})
 	}
-	getList()
+	onMounted(() => {
+		getList()
+	})
 </script>
 <style scoped>
 	.index-message-list {