guoyanqiang 1 month ago
parent
commit
14a8869df9
  1. 10
      src/api/boguApi.js
  2. 272
      src/views/ClubView.vue
  3. 4
      src/views/LiveView.vue

10
src/api/boguApi.js

@ -0,0 +1,10 @@
import service from "./indexApi";
const boguApi = {
selectBogu(queryType){
//查询首页的数据
return service.post('/api/show/getShowList', {queryType: queryType});
}
}
export default boguApi;

272
src/views/ClubView.vue

@ -25,9 +25,9 @@
<!-- 视频列表 --> <!-- 视频列表 -->
<div class="video-list"> <div class="video-list">
<div class="video-card" v-for="(video, index) in videos" :key="index">
<div class="video-card" v-for="(videos, index) in videos" :key="index">
<div class="video-thumbnail" @click="incrementViews(index)"> <div class="video-thumbnail" @click="incrementViews(index)">
<img :src="video.thumbnail" alt="Video Thumbnail" />
<img :src="videos.cover" alt="Video Thumbnail" />
<div class="play-button"> <div class="play-button">
<span class="play-icon"></span> <span class="play-icon"></span>
</div> </div>
@ -45,19 +45,19 @@
<span class="homily-text">HomilyLink</span> <span class="homily-text">HomilyLink</span>
</div> </div>
<div class="stat-item"> <div class="stat-item">
<span class="date">{{ video.date }}</span>
<span class="date">{{ videos.publishTime }}</span>
</div> </div>
<div class="stat-item"> <div class="stat-item">
<img src="../pic/bofang.png" alt="Views" class="views-icon" /> <img src="../pic/bofang.png" alt="Views" class="views-icon" />
<span class="views">{{ video.views }}</span>
<span class="views">{{ videos.viewCount }}</span>
</div> </div>
<div class="stat-item"> <div class="stat-item">
<img src="../pic/bofang.png" alt="Comments" class="comments-icon" @click.stop="toggleComments(index)" /> <img src="../pic/bofang.png" alt="Comments" class="comments-icon" @click.stop="toggleComments(index)" />
<span class="comments">{{ video.comments }}</span>
<span class="comments">{{ videos.commentCount }}</span>
</div> </div>
<div class="stat-item"> <div class="stat-item">
<img src="../pic/dianzan.png" alt="Likes" class="likes-icon" @click.stop="toggleLikes(index)" /> <img src="../pic/dianzan.png" alt="Likes" class="likes-icon" @click.stop="toggleLikes(index)" />
<span class="likes">{{ video.likes }}</span>
<span class="likes">{{ videos.likeCount}}</span>
</div> </div>
</div> </div>
</div> </div>
@ -77,128 +77,156 @@
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref, onMounted } from 'vue';
import axios from 'axios';
//
const API_URL = 'http://192.168.8.235:8000/api/show/getShowList';
//
const fetchShowList = async () => {
try {
// POST
const response = await axios.post(API_URL);
//
console.log('接口返回数据:', response.data);
//
} catch (error) {
//
console.error('接口请求出错:', error);
}
};
const videos = ref([
{
thumbnail: 'src/pic/1.jpg',
title: '第一节《影形结构同现》',
date: '05-26 11:42',
views: 643,
comments: 5,
likes: 3,
isLiked: false,
isCommented: false
},
{
thumbnail: 'src/pic/2.jpg',
title: '第二节《强势结构形态》',
date: '01-11 09:55',
views: 498,
comments: 10,
likes: 12,
isLiked: false,
isCommented: false
},
]);
//
const showModal = ref(false);
const modalTitle = ref('');
const modalContent = ref('');
//
const incrementViews = (index) => {
videos.value[index].views += 1;
saveToLocalStorage();
};
//
const toggleComments = (index) => {
if (videos.value[index].isCommented) {
videos.value[index].comments -= 1;
videos.value[index].isCommented = false;
} else {
videos.value[index].comments += 1;
videos.value[index].isCommented = true;
}
saveToLocalStorage();
};
//
const toggleLikes = (index) => {
if (videos.value[index].isLiked) {
videos.value[index].likes -= 1;
videos.value[index].isLiked = false;
} else {
videos.value[index].likes += 1;
videos.value[index].isLiked = true;
}
saveToLocalStorage();
};
//
const showMore = () => {
modalTitle.value = '查看更多内容';
modalContent.value = '正在加载更多内容...';
showModal.value = true;
};
//
const showMoreTopics = () => {
modalTitle.value = '查看更多专题';
modalContent.value = '正在加载更多专题...';
showModal.value = true;
};
//
const closeModal = () => {
showModal.value = false;
};
//
const saveToLocalStorage = () => {
localStorage.setItem('videos', JSON.stringify(videos.value));
};
//
const loadFromLocalStorage = () => {
const savedVideos = localStorage.getItem('videos');
if (savedVideos) {
videos.value = JSON.parse(savedVideos);
// import { ref, onMounted } from 'vue';
// import axios from 'axios';
// //
// const API_URL = 'http://192.168.8.235:8000/api/show/getShowList';
// //
// const fetchShowList = async () => {
// try {
// // POST
// const response = await axios.post(API_URL);
// //
// console.log(':', response.data);
// //
// } catch (error) {
// //
// console.error(':', error);
// }
// };
// const videos = ref([
// {
// thumbnail: 'src/pic/1.jpg',
// title: '',
// date: '05-26 11:42',
// views: 643,
// comments: 5,
// likes: 3,
// isLiked: false,
// isCommented: false
// },
// {
// thumbnail: 'src/pic/2.jpg',
// title: '',
// date: '01-11 09:55',
// views: 498,
// comments: 10,
// likes: 12,
// isLiked: false,
// isCommented: false
// },
// ]);
// //
// const showModal = ref(false);
// const modalTitle = ref('');
// const modalContent = ref('');
// //
// const incrementViews = (index) => {
// videos.value[index].views += 1;
// saveToLocalStorage();
// };
// //
// const toggleComments = (index) => {
// if (videos.value[index].isCommented) {
// videos.value[index].comments -= 1;
// videos.value[index].isCommented = false;
// } else {
// videos.value[index].comments += 1;
// videos.value[index].isCommented = true;
// }
// saveToLocalStorage();
// };
// //
// const toggleLikes = (index) => {
// if (videos.value[index].isLiked) {
// videos.value[index].likes -= 1;
// videos.value[index].isLiked = false;
// } else {
// videos.value[index].likes += 1;
// videos.value[index].isLiked = true;
// }
// saveToLocalStorage();
// };
// //
// const showMore = () => {
// modalTitle.value = '';
// modalContent.value = '...';
// showModal.value = true;
// };
// //
// const showMoreTopics = () => {
// modalTitle.value = '';
// modalContent.value = '...';
// showModal.value = true;
// };
// //
// const closeModal = () => {
// showModal.value = false;
// };
// //
// const saveToLocalStorage = () => {
// localStorage.setItem('videos', JSON.stringify(videos.value));
// };
// //
// const loadFromLocalStorage = () => {
// const savedVideos = localStorage.getItem('videos');
// if (savedVideos) {
// videos.value = JSON.parse(savedVideos);
// }
// };
// //
// localStorage.removeItem('videos');
// // onMounted
// onMounted(() => {
// fetchShowList();
// loadFromLocalStorage();
// });
import boguApi from '@/api/boguApi';
import { ref } from 'vue';
const videos = ref([]);
function formatTime(queryType) {
boguApi.selectBogu(queryType).then(resp => {
if(resp.data){
videos.value = resp.data.list;
console.log(videos.value);
} }
};
}).catch(error => {
//
console.error('获取视频列表失败:', error);
});
}
//
localStorage.removeItem('videos');
formatTime();
// onMounted
onMounted(() => {
fetchShowList();
loadFromLocalStorage();
});
</script> </script>
<style scoped> <style scoped>
.header-content p { .header-content p {

4
src/views/LiveView.vue

@ -26,8 +26,7 @@
<script setup> <script setup>
import zhiboApi from '@/api/zhiboApi'; import zhiboApi from '@/api/zhiboApi';
import { ref } from 'vue'; import { ref } from 'vue';
const courses = ref([
]);
const courses = ref([]);
function formatTime(queryType) { function formatTime(queryType) {
@ -43,6 +42,7 @@ formatTime();
</script> </script>
<style scoped> <style scoped>
.container { .container {
max-width: 1200px; max-width: 1200px;

Loading…
Cancel
Save