| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- <template>
- <div id="history-list">
- <!--搜索结果面包屑-->
- <el-breadcrumb
- v-if="this.$route.path.indexOf('history') > -1"
- class="bread"
- separator-class="el-icon-arrow-right"
- >
- <el-breadcrumb-item :to="{ path: '' }"><a href="/">返回首页</a></el-breadcrumb-item>
- <el-breadcrumb-item>播放历史记录:共<span class="reslut">({{ totalSize }}}</span>条</el-breadcrumb-item>
- </el-breadcrumb>
- <el-row v-if="visitList.length !== 0" class="movie-list">
- <el-col style="text-align: center">
- <el-button
- type="danger"
- icon="el-icon-delete"
- round
- title="一键清空历史"
- @click="removeAll"
- >一键清空历史</el-button>
- </el-col>
- <el-col :md="8">
- <el-timeline :reverse="reverse">
- <el-timeline-item
- v-for="(record, index) in visitList"
- :key="index"
- :timestamp="record.createAt"
- >
- <video-card :video="record"></video-card>
- </el-timeline-item>
- </el-timeline>
- </el-col>
- </el-row>
- <el-row v-else class="not-result">
- <el-col :span="12" :offset="6">
- <img src="@/assets/img/icon/not-history.png">
- <div>无播放历史</div>
- </el-col>
- </el-row>
- <el-row class="movie-list">
- <el-col v-for="(video,index) in videos" :key="index" :md="6" :sm="8" :xs="12">
- <video-card :video="video" date-tit="上次播放:">
- <el-button
- slot="remove"
- class="remove-slot"
- type="danger"
- icon="el-icon-delete"
- circle
- size="small"
- title="移除该历史记录"
- @click.stop="removeHistory(video)"
- />
- </video-card>
- </el-col>
- </el-row>
- </div>
- </template>
- <script>
- import VideoCard from '@/components/card/VideoCard'
- import { getVisitRecord } from "@/api/visit";
- export default {
- name: 'History',
- components: { VideoCard },
- data() {
- return {
- videos: [],
- uid: 11011,
- reverse: false,
- totalSize: 0,
- visitList: []
- }
- },
- created() {
- document.title = '我的历史记录'
- getVisitRecord(1).then(res => {
- if (res.code === 0) {
- this.totalSize = res.data.totalSize
- this.visitList = res.data.list
- }
- })
- },
- methods: {
- // 清除当前历史记录
- removeHistory(video) {
- this.$confirm('确认移除吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- // 确认
- /* deleteHistory(this.uid, video.vid).then(res => {
- // 将要删除的当前video对象移除数组
- // 获取下标
- const index = this.videos.indexOf(video)
- if (index > -1) {
- this.videos.splice(index, 1)
- }
- })*/
- this.$message({
- type: 'success',
- message: '移除成功!'
- })
- }).catch(() => {
- this.$message({
- type: 'info',
- message: '已取消'
- })
- })
- },
- // 清空所有历史记录
- removeAll() {
- // 移除所有收藏
- this.$confirm('确认移除所有播放历史记录吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- const arr = []
- for (const i of this.videos) {
- arr.push(i.vid)
- }
- // const vidStr = arr.join(',')
- // 确认
- /* deleteHistory(this.uid, vidStr).then(res => {
- this.videos = []
- })*/
- this.$message({
- type: 'success',
- message: '移除成功!'
- })
- }).catch(() => {
- this.$message({
- type: 'info',
- message: '已取消'
- })
- })
- }
- }
- }
- </script>
- <style scoped>
- #history-list {
- padding-left: 6%;
- padding-right: 6%;
- padding-top: 30px;
- }
- .bread {
- font-size: 15px;
- }
- .movie-list {
- padding-top: 15px;
- }
- .reslut {
- color: red;
- }
- .not-result {
- padding-top: 100px;
- padding-bottom: 100px;
- text-align: center;
- }
- .remove-slot {
- position: absolute;
- right: 5px;
- bottom: 2px;
- }
- </style>
|