4 Commits

Author SHA1 Message Date
宋杰 75aefb050f 主页、电子书完成 11 months ago
guoyanqiang 46068b90b7 Merge branch 'guoyanqiang' into dev 11 months ago
guoyanqiang 14a8869df9 haha 11 months ago
guoyanqiang c94de16b83 4.16 11 months ago
  1. 10
      src/api/boguApi.js
  2. 7
      src/api/bookApi.js
  3. 10
      src/api/zhiboApi.js
  4. 77
      src/views/BookView.vue
  5. 260
      src/views/ClubView.vue
  6. 37
      src/views/HomeView.vue
  7. 151
      src/views/LiveView.vue
  8. 27
      vite.config.js

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;

7
src/api/bookApi.js

@ -0,0 +1,7 @@
import service from "./indexApi";
const bookApi = {
getBookList() {
return service.post("/api/ebooks/getEbookList");
},
}
export default bookApi;

10
src/api/zhiboApi.js

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

77
src/views/BookView.vue

@ -1,11 +1,12 @@
<template> <template>
<div class="book-list"> <div class="book-list">
<div v-for="book in books" :key="book.title" class="book-item">
<img :src="book.cover" :alt="book.title">
<div class="book-info">
<div v-for="book in books" :key="book.id" class="book-item">
<img :src="book.cover">
<!-- <img :src="book.cover" :alt="book.title"> -->
<div class="book-info" >
<h3>{{ book.title }}</h3> <h3>{{ book.title }}</h3>
<p>{{ book.description }}</p> <p>{{ book.description }}</p>
<p>阅读次数{{ book.reads }}</p>
<p>阅读次数{{ book.viewCount }}</p>
</div> </div>
<button @click="handleReadBook(book.title)">立即阅读</button> <button @click="handleReadBook(book.title)">立即阅读</button>
</div> </div>
@ -57,34 +58,45 @@ export default {
}; };
</script> --> </script> -->
<script setup> <script setup>
import bookApi from '@/api/bookApi';
import { ref } from 'vue'; import { ref } from 'vue';
const books = ref([
{
title: "发财线秘籍",
description: "发财线经济(阅读时间截止为2024年6月30日)",
reads: 2490,
cover: "src/assets/发财线.png"
},
{
title: "解套宝典",
description: "解套宝典(阅读截止时间为2024年12月31日)",
reads: 1057,
cover: "src/assets/解套.png"
},
{
title: "十年200倍——上册",
description: "十年200倍——上册(阅读截止时间为2024年12月31日)",
reads: 1073,
cover: "src/assets/十年上.png"
},
{
title: "十年200倍——下册",
description: "十年200倍——下册(阅读截止时间为2024年12月31日)",
reads: 1018,
cover: "src/assets/十年下.png"
}
]);
const books = ref([]);
//
function getBooks() {
bookApi.getBookList().then(resp => {
books.value = resp.data.list;
console.log(books.value);
} );
}
getBooks();
// const books = ref([
// {
// title: "线",
// description: "线2024630",
// reads: 2490,
// cover: "src/assets/线.png"
// },
// {
// title: "",
// description: "20241231",
// reads: 1057,
// cover: "src/assets/.png"
// },
// {
// title: "200",
// description: "20020241231",
// reads: 1073,
// cover: "src/assets/.png"
// },
// {
// title: "200",
// description: "20020241231",
// reads: 1018,
// cover: "src/assets/.png"
// }
// ]);
const handleReadBook = (title) => { const handleReadBook = (title) => {
alert(`您点击了《${title}`); alert(`您点击了《${title}`);
@ -92,6 +104,10 @@ const handleReadBook = (title) => {
</script> </script>
<style> <style>
.book-item:hover{
transform: scale(1.01);
}
body { body {
font-family: Arial, sans-serif; font-family: Arial, sans-serif;
background-color: #f4f4f4; background-color: #f4f4f4;
@ -102,7 +118,6 @@ body {
.book-list { .book-list {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 20px;
} }
.book-item { .book-item {

260
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,108 +77,156 @@
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref, onMounted } from 'vue';
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(() => {
loadFromLocalStorage();
});
// 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);
});
}
formatTime();
</script> </script>
<style scoped> <style scoped>
.header-content p { .header-content p {
@ -401,4 +449,4 @@ onMounted(() => {
font-size: 24px; font-size: 24px;
cursor: pointer; cursor: pointer;
} }
</style>
</style>

37
src/views/HomeView.vue

@ -5,7 +5,7 @@
<div class="section-title">推荐</div> <div class="section-title">推荐</div>
<el-row :gutter="20" class="recommend-videos" style="margin-right: -25px;"> <el-row :gutter="20" class="recommend-videos" style="margin-right: -25px;">
<el-col :span="24" v-for="video in video" :key="video.id"> <el-col :span="24" v-for="video in video" :key="video.id">
<el-card class="video-card" @click="incrementViews(scope.row.id)">
<el-card class="video-card">
<div class="video-content"> <div class="video-content">
<img :src="video.cover" alt="视频缩略图" class="video-thumbnail" /> <img :src="video.cover" alt="视频缩略图" class="video-thumbnail" />
<div class="video-info"> <div class="video-info">
@ -15,18 +15,12 @@
<img class="icon" :src="video.publisherAvatar" /> <img class="icon" :src="video.publisherAvatar" />
<span> {{ video.publisherName }} {{ video.publishTime }}</span> <span> {{ video.publisherName }} {{ video.publishTime }}</span>
<div class="video-stats"> <div class="video-stats">
<el-icon>
<View />
</el-icon>
<el-button type="text">{{ video.videoDuration }}</el-button>
<!-- <div type="text" style="color: black;" >{{ video.videoDuration }}</div> -->
<el-icon>
<ChatDotSquare />
</el-icon>
<el-button type="text">{{ video.likeCount }}</el-button>
<el-icon><View /></el-icon>
<el-button type="text" style="color: black;">{{ video.videoDuration }}</el-button>
<el-icon><ChatDotSquare /></el-icon>
<el-button type="text" style="color: black;">{{ video.likeCount }}</el-button>
<img src="../pic/like.png" class="like"> <img src="../pic/like.png" class="like">
<el-button type="text">{{ video.commentCount }}</el-button>
<el-button type="text" style="color: black;">{{ video.commentCount }}</el-button>
</div> </div>
</div> </div>
</div> </div>
@ -49,8 +43,8 @@
<el-icon class="my-icon"> <el-icon class="my-icon">
<View /> <View />
</el-icon> </el-icon>
<el-button type="text">{{ video.viewCount }}</el-button>
<el-button type="text">{{ video.publishTime }}</el-button>
<el-button type="text" style="color: black;">{{ video.viewCount }}</el-button>
<el-button type="text" style="color: black;">{{ video.publishTime }}</el-button>
<!-- <el-button type="text">{{ video.comments }}</el-button> --> <!-- <el-button type="text">{{ video.comments }}</el-button> -->
</div> </div>
</div> </div>
@ -287,7 +281,7 @@ span {
.video-title1 { .video-title1 {
font-size: 20px; font-size: 20px;
font-weight: bold;
font-weight: 600;
margin-bottom: 10px; margin-bottom: 10px;
text-align: left; text-align: left;
line-height: normal; line-height: normal;
@ -295,7 +289,7 @@ span {
.video-title2 { .video-title2 {
font-size: 18px; font-size: 18px;
font-weight: 540;
font-weight: 600;
margin-bottom: 10px; margin-bottom: 10px;
text-align: left; text-align: left;
line-height: normal; line-height: normal;
@ -309,13 +303,22 @@ span {
/* padding-top: 20px; */ /* padding-top: 20px; */
} }
.video-meta1 span{
display: flex;
align-items: center;
font-size: 14px;
color: #666;
/* padding-top: 20px; */
font-weight: 600;
}
.video-meta2 { .video-meta2 {
display: flex; display: flex;
align-items: center; align-items: center;
font-size: 14px; font-size: 14px;
color: #666; color: #666;
padding-top: 40px;
padding-top: 20px;
} }

151
src/views/LiveView.vue

@ -3,17 +3,17 @@
<div class="course-grid"> <div class="course-grid">
<div v-for="course in courses" :key="course.id" class="course-card"> <div v-for="course in courses" :key="course.id" class="course-card">
<div class="course-image"> <div class="course-image">
<img :src="course.image" alt="课程图片">
<img :src="course.cover" alt="课程图片">
<div class="live-badge">即将开播</div> <div class="live-badge">即将开播</div>
<div class="live-time">{{ course.time }}</div>
<div class="live-time">{{ course.startTime }}</div>
</div> </div>
<div class="course-info"> <div class="course-info">
<div class="course-title">{{ course.title }}</div> <div class="course-title">{{ course.title }}</div>
<div class="course-footer"> <div class="course-footer">
<div class="course-tag"> <div class="course-tag">
<img :src="course.avatar" alt="讲师头像">
<img :src="course.cover" alt="讲师头像">
<!-- <img src="../pic/images/1.png" alt="讲师头像"> --> <!-- <img src="../pic/images/1.png" alt="讲师头像"> -->
{{ course.teacher }}
{{ course.publisherName }}
</div> </div>
<button class="book-btn" :class="{ active: course.booked }" @click="toggleBook(course.id)">预约</button> <button class="book-btn" :class="{ active: course.booked }" @click="toggleBook(course.id)">预约</button>
</div> </div>
@ -23,143 +23,26 @@
</div> </div>
</template> </template>
<script>
<script setup>
import zhiboApi from '@/api/zhiboApi';
import { ref } from 'vue'; import { ref } from 'vue';
const courses = ref([]);
export default {
name: 'LiveCourses',
setup() {
const courses = ref([
{
id: 1,
title: '猎庄之顶级波段我公司不...',
teacher: '猎庄之顶级波段',
time: '明天09:55开播',
image: 'src/pic/images/1.png',
avatar: 'src/pic/images/link.jpg',
booked: false
},
{
id: 2,
title: '如何提前把握大盘和个股...',
teacher: '多空识庄短线寻...',
time: '明天10:00开播',
image: 'src/pic/images/2.png',
avatar: 'src/pic/images/link.jpg',
booked: false
},
{
id: 3,
title: '【粤语】AI铁皮训练-Tom...',
teacher: '【粤语】AI铁皮...',
time: '明天11:30开播',
image: 'src/pic/images/3.png',
avatar: 'src/pic/images/link.jpg',
booked: false
},
{
id: 4,
title: '构建有效的价值投资体系...',
teacher: '构建有效的价值...',
time: '明天20:30开播',
image: 'src/pic/images/4.png',
avatar: 'src/pic/images/link.jpg',
booked: false
},
{
id: 5,
title: '猎庄之顶级波段我公司不...',
teacher: '猎庄之顶级波段',
time: '明天09:55开播',
image: 'src/pic/images/5.png',
avatar: 'src/pic/images/link.jpg',
booked: false
},
{
id: 6,
title: '如何提前把握大盘和个股...',
teacher: '多空识庄短线寻...',
time: '明天10:00开播',
image: 'src/pic/images/6.png',
avatar: 'src/pic/images/link.jpg',
booked: false
},
{
id: 7,
title: '【粤语】AI铁皮训练-Tom...',
teacher: '【粤语】AI铁皮...',
time: '明天11:30开播',
image: 'src/pic/images/7.png',
avatar: 'src/pic/images/link.jpg',
booked: false
},
{
id: 8,
title: '构建有效的价值投资体系...',
teacher: '构建有效的价值...',
time: '明天20:30开播',
image: 'src/pic/images/8.png',
avatar: 'src/pic/images/link.jpg',
booked: false
}
]);
const toggleBook = async (id) => {
const courseIndex = courses.value.findIndex(course => course.id === id);
if (courseIndex !== -1) {
const course = courses.value[courseIndex];
try {
if (!course.booked) {
// - POST
const response = await fetch(`https://your-backend-api.com/bookings/${id}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
courseId: id
})
});
if (!response.ok) {
throw new Error('预约失败');
}
//
course.booked = true;
alert(`您已成功预约课程:${course.title}`);
} else {
// - DELETE
const response = await fetch(`https://your-backend-api.com/bookings/${id}`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
}
});
if (!response.ok) {
throw new Error('取消预约失败');
}
function formatTime(queryType) {
zhiboApi.selectZhibo(queryType).then(resp => {
if(resp.data){
courses.value = resp.data.list;
console.log(courses.value);
}
})
}
//
course.booked = false;
alert(`您已取消预约课程:${course.title}`);
}
} catch (error) {
console.error('预约请求失败:', error);
alert('预约请求失败,请稍后再试');
}
}
};
formatTime();
return {
courses,
toggleBook
};
}
};
</script> </script>
<style scoped> <style scoped>
.container { .container {
max-width: 1200px; max-width: 1200px;

27
vite.config.js

@ -1,18 +1,25 @@
import { fileURLToPath, URL } from 'node:url'
import { fileURLToPath, URL } from 'node:url';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueDevTools from 'vite-plugin-vue-devtools';
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
// https://vite.dev/config/
export default defineConfig({ export default defineConfig({
server: {
proxy: {
'/api': {
target: 'http://192.168.8.235:8000', // 后端服务器地址
changeOrigin: true, // 改变请求源
rewrite: (path) => path.replace(/^\/api/, '') // 重写路径,去掉 /api
}
}
},
plugins: [ plugins: [
vue(), vue(),
vueDevTools(),
vueDevTools()
], ],
resolve: { resolve: {
alias: { alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)) '@': fileURLToPath(new URL('./src', import.meta.url))
},
},
})
}
}
});
Loading…
Cancel
Save