| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <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"
- placement="top"
- >
- <div>
- <el-button
- type="danger"
- icon="el-icon-delete"
- circle
- size="small"
- title="移除该历史记录"
- @click.stop="removeHistory(record.videoId)"
- />
- <video-card :video="record"></video-card>
- </div>
- </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>
- </div>
- </template>
- <script>
- import VideoCard from '@/components/card/VideoCard'
- import { getVisitRecord } from "@/api/visit";
- export default {
- name: 'History',
- components: { VideoCard },
- data() {
- return {
- reverse: false,
- totalSize: 0,
- nextId: 0,
- nextId1: 0,
- visitList: [],
- }
- },
- created() {
- document.title = '我的历史记录'
- this.getVisitRecordWrapper(this.nextId)
- },
- mounted() {
- window.addEventListener("scroll", this.handleScrollEvent);
- },
- methods: {
- handleScrollEvent() {
- if (document.body.scrollHeight <= window.screen.height + document.documentElement.scrollTop) {
- console.log('滚动条触底, 加载数据')
- if (this.nextId1 !== this.nextId) {
- this.nextId1 = this.nextId
- this.getVisitRecordWrapper(this.nextId)
- }
- }
- },
- getVisitRecordWrapper(nextId) {
- getVisitRecord(nextId).then(res => {
- if (res.code === 0) {
- const resData = res.data
- this.totalSize = resData.totalSize
- this.nextId = resData.nextId
- for (const item of resData.list) {
- this.visitList.push(item)
- }
- }
- })
- },
- // 清除当前历史记录
- removeHistory(videoId) {
- this.$confirm('确认移除吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- console.log('删除 ' + videoId + ' 这条记录')
- // 确认
- /* 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(() => {
- console.log('删除全部记录')
- /*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>
|