Skip to content

Commit

Permalink
fix:bug修复 多次出现登陆提示
Browse files Browse the repository at this point in the history
  • Loading branch information
Personxy committed Feb 21, 2022
1 parent d87ff13 commit cb01093
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 41 deletions.
12 changes: 9 additions & 3 deletions src/components/xymusic/video/videopage/videcategory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

<script>
import { mapGetters } from "vuex";
import { bus } from "../../../../plugins/bus";
// import { bus } from "../../../../plugins/bus";
export default {
data () {
return {
Expand Down Expand Up @@ -132,21 +132,27 @@ export default {
},
//传递查询参数
sendmessage (id) {
bus.$emit("catid", id);
this.$emit("sendcatid", id);
},
// 点击外部关闭面板
close: function (e) {
if (this.$el.contains(e.target)) return;
this.panel = false;
},
},
created () {
mounted () {
this.getlistcat();
this.gethotcat();
},
computed: {
...mapGetters(["cookie"]),
},
watch: {
cookie () {
// console.log(1);
this.gethotcat();
}
},
directives: {
// 自定义指令 能够在组件外部控制弹窗关闭
// https://www.cnblogs.com/yangzhou33/p/10023410.html
Expand Down
85 changes: 49 additions & 36 deletions src/components/xymusic/video/videopage/videolist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

<script>
import { mapGetters } from "vuex";
import { bus } from "../../../../plugins/bus";
export default {
data () {
return {
Expand All @@ -66,16 +66,37 @@ export default {
hasmore: true,
};
},
props: {
catId: String
},
methods: {
// 获取所有视频列表
async getallvideolist () {
const { data } = await this.$http
this.$http
.get("/video/timeline/all", {
params: {
// cookie: this.cookie,
offset: this.offset,
timeStamp: Date.now(),
},
}).then(({ data }) => {
// console.log(data);
this.offset = this.offset + 8;
if (data.hasmore == false) return (this.hasmore = false);
this.catlist.push.apply(this.catlist, data.datas);
// 清除重复
this.catlist = this.catlist.filter((element, index, arr) => {
return (
arr.findIndex((el) => el.data.vid == element.data.vid) === index
);
});
// console.log(this.catlist);
// 至少获取30条数据
if (this.catlist.length < 30)
{
this.getallvideolist();
}
})
.catch((err) => {
if (
Expand All @@ -91,35 +112,15 @@ export default {
this.$store.commit("changeloginbar", true);
}
});
// console.log(data);
if (data.datas)
{
// console.log(data);
this.offset = this.offset + 8;
if (data.hasmore == false) return (this.hasmore = false);
this.catlist.push.apply(this.catlist, data.datas);
// 清除重复
this.catlist = this.catlist.filter((element, index, arr) => {
return (
arr.findIndex((el) => el.data.vid == element.data.vid) === index
);
});
// console.log(this.catlist);
// 至少获取30条数据
if (this.catlist.length < 30)
{
this.getallvideolist();
}
}
},
// 根据分类id获取视频列表
async getvideolist () {
if (this.catid === "全部视频")
{
this.getallvideolist();
} else
{
if (this.catid === "")
Expand Down Expand Up @@ -190,24 +191,36 @@ export default {
this.getallvideolist();
},
mounted () {
bus.$off("catid");
bus.$on("catid", (data) => {
this.catid = data;
this.offset = 0;
this.catlist = [];
this.hasmore = true;
this.getvideolist();
});
},
// mounted () {
// // bus.$off("catid");
// this.getallvideolist();
// bus.$on("catid", (data) => {
// this.catid = data;
// this.offset = 0;
// this.catlist = [];
// this.hasmore = true;
// this.getvideolist();
// });
// },
// beforeDestroy () {
// bus.$off('catid')
// },
watch: {
cookie () {
this.getallvideolist();
},
catId () {
this.catid = this.catId;
this.offset = 0;
this.catlist = [];
this.hasmore = true;
this.getvideolist();
}
},
beforeDestroy () {
bus.$off("catid");
},
// beforeDestroy () {
// bus.$off("catid");
// },
computed: {
...mapGetters(["cookie"]),
},
Expand Down
14 changes: 12 additions & 2 deletions src/views/video/videopage/videopage.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="videopage">
<videocategory />
<videolist />
<videocategory @sendcatid="getcatid" />
<videolist :catId="catid" />
</div>
</template>

Expand All @@ -13,6 +13,16 @@ export default {
videocategory,
videolist,
},
data () {
return {
catid: ''
}
},
methods: {
getcatid (data) {
this.catid = data
}
}
};
</script>

Expand Down

2 comments on commit cb01093

@vercel
Copy link

@vercel vercel bot commented on cb01093 Feb 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

xy-music – ./

xy-music-personxy.vercel.app
xy-music-git-master-personxy.vercel.app
xy-music.vercel.app

@vercel
Copy link

@vercel vercel bot commented on cb01093 Feb 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

xy-music1 – ./

yangyangmusic.vercel.app
xy-music1-git-master-personxy.vercel.app
xy-music1-personxy.vercel.app

Please sign in to comment.