16 changed files with 883 additions and 303 deletions
-
100vueHomilyLink/package-lock.json
-
1vueHomilyLink/package.json
-
22vueHomilyLink/src/api/ChannelApi.js
-
23vueHomilyLink/src/api/ClubApi.js
-
15vueHomilyLink/src/api/LiveApi.js
-
16vueHomilyLink/src/api/index.js
-
BINvueHomilyLink/src/assets/live.jpg
-
4vueHomilyLink/src/assets/main.css
-
2vueHomilyLink/src/components/Nav.vue
-
2vueHomilyLink/src/router/index.js
-
451vueHomilyLink/src/views/ChannelView.vue
-
296vueHomilyLink/src/views/LiveView.vue
-
81vueHomilyLink/src/views/club/BoguView.vue
-
81vueHomilyLink/src/views/club/MuminView.vue
-
81vueHomilyLink/src/views/club/shenQiang.vue
-
11vueHomilyLink/vite.config.js
@ -0,0 +1,22 @@ |
|||||
|
import service from "."; |
||||
|
|
||||
|
const ChannelApi = { |
||||
|
//获取频道列表
|
||||
|
getchannels(){ |
||||
|
return service.get('/list'); |
||||
|
}, |
||||
|
//获取shows列表
|
||||
|
getShows(Id,UserId,FlagType){ |
||||
|
return service.post('/channel',{Id,UserId,FlagType}); |
||||
|
}, |
||||
|
//订阅状态
|
||||
|
subscribe(Id,UserId){ |
||||
|
return service.post('/subscription',{Id,UserId}) |
||||
|
}, |
||||
|
//取消订阅
|
||||
|
unSubscribe(Id,UserId){ |
||||
|
return service.delete('/subscription',{Id,UserId}) |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
export default ChannelApi; |
@ -0,0 +1,23 @@ |
|||||
|
import service from "."; |
||||
|
|
||||
|
const ClubApi = { |
||||
|
getClub(id){ |
||||
|
return service.get( |
||||
|
'/clubpage/get-club',{ |
||||
|
params: { |
||||
|
id: id |
||||
|
} |
||||
|
} |
||||
|
); |
||||
|
}, |
||||
|
getShows(id){ |
||||
|
return service.get( |
||||
|
'/clubpage/get-club-shows',{ |
||||
|
params: { |
||||
|
id: id |
||||
|
} |
||||
|
} |
||||
|
) |
||||
|
} |
||||
|
} |
||||
|
export default ClubApi; |
@ -0,0 +1,15 @@ |
|||||
|
import service from "."; |
||||
|
const liveApi = { |
||||
|
//获取直播列表
|
||||
|
getLiveList() { |
||||
|
return service.get('/live'); |
||||
|
}, |
||||
|
//预约
|
||||
|
addReservation(id,userId){ |
||||
|
return service.post('/reservation',{id,userId}); |
||||
|
}, |
||||
|
//取消预约
|
||||
|
cancelReservation(id,userId){ |
||||
|
return service.delete('/reservation',{id,userId}); |
||||
|
} |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
import axios from "axios"; |
||||
|
|
||||
|
const service = axios.create({ |
||||
|
// baseURL: 'http://192.168.8.191:8080',
|
||||
|
// baseURL: 'http://localhost:8080',
|
||||
|
baseURL: '/api', |
||||
|
}); |
||||
|
// http://192.168.8.191:8080
|
||||
|
|
||||
|
//Axios的响应拦截器..
|
||||
|
service.interceptors.response.use(resp => { |
||||
|
return resp.data; |
||||
|
}, error => { |
||||
|
return Promise.reject(error); |
||||
|
}); |
||||
|
export default service; |
After Width: 310 | Height: 200 | Size: 39 KiB |
@ -1,9 +1,7 @@ |
|||||
@import './base.css'; |
|
||||
|
|
||||
html,body{ |
html,body{ |
||||
margin:0px; |
margin:0px; |
||||
height: 100%; |
height: 100%; |
||||
} |
} |
||||
#app{ |
#app{ |
||||
height: 100%; |
height: 100%; |
||||
} |
|
||||
|
} |
@ -1,10 +1,300 @@ |
|||||
|
<template> |
||||
|
<!-- 卡片 --> |
||||
|
<div class="card-container"> |
||||
|
<div v-for="(live, index) in liveList" :key="index" class="card"> |
||||
|
<div class="cover-image" :class="{ 'no-overlay': !live.status == 1 }" style="position:relative;"> |
||||
|
<img :src=live.cover alt="节目1"> |
||||
|
<div v-if="live.status == 1" class="overlay">即将开播</div> |
||||
|
<div v-if="live.status == 1" class="start-time">{{ getDateDay(live.startTime) }} {{ live.startTime.slice(11, 16) }}开播</div> |
||||
|
</div> |
||||
|
<div class="card-content"> |
||||
|
<div class="card-title">{{ live.liveName }}</div> |
||||
|
<div class="card-actions"> |
||||
|
<!-- 用户头像 --> |
||||
|
<img :src=live.user.avatar alt="节目1" class="user-avatar"> |
||||
|
<!-- 用户昵称,与头像同行显示 --> |
||||
|
<div class="card-info">{{ live.user.userName }}</div> |
||||
|
<!-- 预约按钮,如果预约过了,按钮变灰色,文字变灰色,按钮文字为“已预约” --> |
||||
|
<a v-if="live.reservation == 0" href="#" class="card-button" |
||||
|
@click="booking(live.id, live.user.userId)">预约</a> |
||||
|
<a v-else href="#" class="card-button" style="background-color: #ccc;">已预约</a> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
|
||||
<script setup> |
<script setup> |
||||
|
import { ref } from 'vue'; |
||||
|
/* |
||||
|
模拟后端数据 |
||||
|
*/ |
||||
|
const liveList = ref([]); |
||||
|
|
||||
|
|
||||
|
//获取直播列表 |
||||
|
function getLive() { |
||||
|
liveList.value = [ |
||||
|
{ |
||||
|
id: 1, |
||||
|
cover: "src/assets/live.jpg", |
||||
|
user: { |
||||
|
userId: 1, |
||||
|
userName: "冷辉老师", |
||||
|
avatar: "src/assets/live.jpg" |
||||
|
}, |
||||
|
liveName: "猎庄之顶级波段", |
||||
|
startTime: "2024-12-01 09:55", |
||||
|
reservation: 1, //0表示未预约,1表示已预约 |
||||
|
status: 1 //0表示未开播,1表示已开播 |
||||
|
}, |
||||
|
{ |
||||
|
id: 2, |
||||
|
cover: "src/assets/live.jpg", |
||||
|
user: { |
||||
|
userId: 2, |
||||
|
userName: "冷辉老师", |
||||
|
avatar: "src/assets/live.jpg" |
||||
|
}, |
||||
|
liveName: "猎庄之顶级波段", |
||||
|
startTime: "2024-12-01 09:55", |
||||
|
reservation: 1, //0表示未预约,1表示已预约 |
||||
|
status: 1 |
||||
|
}, |
||||
|
{ |
||||
|
id: 3, |
||||
|
cover: "src/assets/live.jpg", |
||||
|
user: { |
||||
|
userId: 3, |
||||
|
userName: "冷辉老师", |
||||
|
avatar: "src/assets/live.jpg" |
||||
|
}, |
||||
|
liveName: "猎庄之顶级波段", |
||||
|
startTime: "2024-11-30 12:55", |
||||
|
reservation: 1, //0表示未预约,1表示已预约 |
||||
|
status: 1 |
||||
|
}, |
||||
|
{ |
||||
|
id: 4, |
||||
|
cover: "src/assets/live.jpg", |
||||
|
user: { |
||||
|
userId: 4, |
||||
|
userName: "冷辉老师", |
||||
|
avatar: "src/assets/live.jpg" |
||||
|
}, |
||||
|
liveName: "猎庄之顶级波段", |
||||
|
startTime: "2024-12-30 12:55", |
||||
|
reservation: 0, //0表示未预约,1表示已预约 |
||||
|
status: 1 |
||||
|
}, |
||||
|
{ |
||||
|
id: 5, |
||||
|
cover: "src/assets/live.jpg", |
||||
|
user: { |
||||
|
userId: 5, |
||||
|
userName: "冷辉老师", |
||||
|
avatar: "src/assets/live.jpg" |
||||
|
}, |
||||
|
liveName: "猎庄之顶级波段", |
||||
|
startTime: "2024-12-30 12:55", |
||||
|
reservation: 0, //0表示未预约,1表示已预约 |
||||
|
status: 1, |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
getLive(); |
||||
|
|
||||
|
// 判断开播日期与当前时间的关系(今天、明天、其他) |
||||
|
function getDateDay(startTime) { |
||||
|
const now = new Date(); |
||||
|
const start = new Date(startTime); |
||||
|
const oneDay = 24 * 60 * 60 * 1000; // 一天的毫秒数 |
||||
|
if (now.toDateString() == start.toDateString()) { |
||||
|
return "今天"; |
||||
|
} else if (now.getTime() + oneDay >= start.getTime()) { |
||||
|
return "明天"; |
||||
|
} else { |
||||
|
return startTime.slice(5, 10); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// //获取用户信息 |
||||
|
// const userInfo = ref([]); |
||||
|
// function getUserInfo() { |
||||
|
// userInfo.value = { |
||||
|
// userId: 1, |
||||
|
// userName: "冷辉老师", |
||||
|
// avatar: "src/assets/live.jpg", |
||||
|
// //预约信息 |
||||
|
// reservationList: [1,2,3] |
||||
|
// } |
||||
|
// } |
||||
|
// getUserInfo(); |
||||
|
|
||||
|
// console.log(userInfo.value); |
||||
|
|
||||
|
// /* 判断预约状态 */ |
||||
|
// function isBooking(liveId) { |
||||
|
// for (let i = 0; i < userInfo.value.reservationList.length; i++) { |
||||
|
// if (userInfo.value.reservationList[i] == liveId) { |
||||
|
// return true; |
||||
|
// } |
||||
|
// } |
||||
|
// return false; |
||||
|
// } |
||||
|
|
||||
|
|
||||
|
|
||||
|
/*点击预约按钮以后显示预约成功的提示,并将按钮变为不可点击状态,且将按钮的文字改为“已预约”,并将按钮的背景颜色改为灰色*/ |
||||
|
function booking(liveId, userId) { |
||||
|
alert("预约成功!"); |
||||
|
} |
||||
|
|
||||
</script> |
</script> |
||||
|
|
||||
<template> |
|
||||
直播 |
|
||||
</template> |
|
||||
|
|
||||
<style scoped> |
<style scoped> |
||||
|
.card-container { |
||||
|
/*居中显示*/ |
||||
|
margin-left: auto; |
||||
|
margin-right: auto; |
||||
|
/*宽度*/ |
||||
|
width: 916px; |
||||
|
font-family: Arial, sans-serif; |
||||
|
padding: 0; |
||||
|
flex-wrap: wrap; |
||||
|
/*超出自动换行*/ |
||||
|
background-color: #f4f4f4; |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
} |
||||
|
|
||||
|
.card { |
||||
|
background-color: #fff; |
||||
|
border-radius: 8px; |
||||
|
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); |
||||
|
margin: 10px; |
||||
|
overflow: hidden; |
||||
|
border: #666; |
||||
|
height: 190px; |
||||
|
width: 209px; |
||||
|
} |
||||
|
|
||||
|
.card .cover-image img { |
||||
|
width: 100%; |
||||
|
height: 100%; |
||||
|
/*图片占满整个卡片*/ |
||||
|
object-fit: cover; |
||||
|
border-radius: 8px; |
||||
|
} |
||||
|
|
||||
|
.cover-image { |
||||
|
position: relative; |
||||
|
height: 120px; |
||||
|
width: 208px; |
||||
|
border-radius: 8px; |
||||
|
} |
||||
|
|
||||
|
/*即将开播图层*/ |
||||
|
.overlay { |
||||
|
position: absolute; |
||||
|
z-index: 2; |
||||
|
text-align: center; |
||||
|
top: 30%; |
||||
|
left: 50%; |
||||
|
transform: translate(-50%, -50%); |
||||
|
color: #fff; |
||||
|
font-size: 18px; |
||||
|
} |
||||
|
|
||||
|
/*开播时间*/ |
||||
|
.start-time { |
||||
|
position: absolute; |
||||
|
z-index: 2; |
||||
|
text-align: center; |
||||
|
top: 60%; |
||||
|
left: 50%; |
||||
|
transform: translate(-50%, -50%); |
||||
|
color: #ffffffaf; |
||||
|
font-size: 15px; |
||||
|
width: 120px; |
||||
|
} |
||||
|
|
||||
|
.cover-image::before { |
||||
|
content: " "; |
||||
|
position: absolute; |
||||
|
top: 0; |
||||
|
left: 0; |
||||
|
width: 207px; |
||||
|
height: 120px; |
||||
|
/*最后一个参数是半透明度,可以透过调整0-1的数值,调整到满意的透明度*/ |
||||
|
background-color: rgba(0, 0, 0, 0.3); |
||||
|
border-radius: 8px; |
||||
|
} |
||||
|
|
||||
|
/*用于隐藏样式*/ |
||||
|
.cover-image.no-overlay::before { |
||||
|
display: none; |
||||
|
} |
||||
|
|
||||
|
.card-content { |
||||
|
padding: 8px; |
||||
|
} |
||||
|
|
||||
|
.card-title { |
||||
|
font-size: 13px; |
||||
|
font-weight: bold; |
||||
|
margin-bottom: 5px; |
||||
|
white-space: nowrap; |
||||
|
overflow: hidden; |
||||
|
text-overflow: ellipsis; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
.card-info { |
||||
|
font-size: 14px; |
||||
|
color: #666; |
||||
|
} |
||||
|
|
||||
|
.card-button { |
||||
|
display: inline-block; |
||||
|
padding: 5px 5px; |
||||
|
background-color: #eb8b31; |
||||
|
color: #fff; |
||||
|
text-decoration: none; |
||||
|
border-radius: 20px; |
||||
|
font-size: small; |
||||
|
width: 50px; |
||||
|
text-align: center; |
||||
|
margin-left: auto; |
||||
|
} |
||||
|
|
||||
|
.card-actions { |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
/* 垂直居中对齐 */ |
||||
|
justify-content: space-between; |
||||
|
/* 按钮右对齐 */ |
||||
|
} |
||||
|
|
||||
|
.user-avatar { |
||||
|
border-radius: 50%; |
||||
|
width: 20px; |
||||
|
height: 20px; |
||||
|
} |
||||
|
|
||||
|
.card-info { |
||||
|
margin-left: 5px; |
||||
|
/* 昵称与头像之间的间距 */ |
||||
|
margin-top: 0; |
||||
|
/* 移除顶部外边距 */ |
||||
|
/*超长以后将内容省略显示*/ |
||||
|
white-space: nowrap; |
||||
|
overflow: hidden; |
||||
|
text-overflow: ellipsis; |
||||
|
|
||||
|
width: 90px; |
||||
|
font-size: 12px; |
||||
|
} |
||||
</style> |
</style> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue