| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <template>
- <el-row class="movie-list">
- <el-col :md="12">
- <el-row style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
- <el-card class="box-card">
- <div slot="header" class="clearfix">
- <el-row>
- <span v-html="audio.title" />
- </el-row>
- </div>
- <div class="text item">
- <el-row>
- <audio-player
- ref="audioPlayer"
- :show-prev-button="false"
- :show-next-button="false"
- :show-playback-rate="false"
- :audio-list="audioList.map(elm => elm.url)"
- :before-play="handleBeforePlay"
- theme-color="#87CEFA"
- />
- </el-row>
- <el-divider v-if="audio.description !== undefined && audio.description !== null"/>
- <el-row>
- <span v-html="audio.description" />
- </el-row>
- <el-divider/>
- <el-row>
- 发布于 <span v-html="audio.pubDate" />
- </el-row>
- <el-divider/>
- <el-row>
- <span>
- <span>
- <i :class=collectedIcon @click="collectItem"/>
- </span>
- </span>
- </el-row>
- </div>
- </el-card>
- </el-row>
- </el-col>
- <el-col :md="6">
- <user-avatar-card :userAvatar="user" />
- </el-col>
- </el-row>
- </template>
- <script>
- import UserAvatarCard from '@/components/card/UserAvatarCard'
- import { getAudio } from "@/api/audio";
- import {getUserInfo} from "@/api/user";
- export default {
- name: 'AudioPage',
- components: { UserAvatarCard },
- filters: {
- ellipsis(value) {
- if (!value) return ''
- const max = 20
- if (value.length > max) {
- return value.slice(0, max) + '...'
- }
- return value
- }
- },
- data() {
- return {
- currentAudioName: '',
- audio: null,
- audioList: [],
- user: null,
- collected: false,
- collectedIcon: 'el-icon-star-off'
- }
- },
- created() {
- const audioId = this.$route.params.audioId
- getAudio(audioId).then(res => {
- if (res.code === 0) {
- this.audio = res.data
- this.audioList = [
- { name: this.audio.title, url: this.audio.audioUrl }
- ]
- document.title = '音频 - ' + this.audio.title
- } else {
- }
- getUserInfo(10001).then(res => {
- if (res.code === 0) {
- this.user = res.data
- }
- })
- })
- },
- methods: {
- // 播放前做的事
- handleBeforePlay(next) {
- // 这里可以做一些事情...
- this.currentAudioName = this.audioList[this.$refs.audioPlayer.currentPlayIndex].name
- // 开始播放
- next()
- },
- handlePlaySpecify() {
- this.$refs.audioPlayer.currentPlayIndex = 1
- this.$nextTick(() => {
- this.$refs.audioPlayer.play()
- this.title = this.audioList[
- this.$refs.audioPlayer.currentPlayIndex
- ].name
- })
- },
- collectItem() {
- if (this.collected) {
- console.log('取消收藏音频')
- this.collected = false
- this.collectedIcon = 'el-icon-star-off'
- } else {
- console.log('收藏音频')
- this.collected = true
- this.collectedIcon = 'el-icon-star-on'
- }
- }
- }
- }
- </script>
- <style scoped>
- .movie-list {
- padding-top: 15px;
- padding-left: 6%;
- padding-right: 6%;
- }
- /*处于手机屏幕时*/
- @media screen and (max-width: 768px) {
- .movie-list {
- padding-top: 8px;
- padding-left: 0.5%;
- padding-right: 0.5%;
- }
- }
- .clearfix:before,
- .clearfix:after {
- display: table;
- content: "";
- }
- .clearfix:after {
- clear: both;
- }
- </style>
|