{{ item.name }}
@@ -82,9 +81,12 @@ export default {
data() {
return {
allForumList: [], // 所有板块得数据
- favoriteHeadList: [],
+ favoriteHeadList: [{
+ name: "全部",
+ fid: 0
+ }],
// favoriteHeadIdList: [],
- favoriteHeadIdList: this.$parent.favorite,
+ favoriteHeadIdList: this.$store.state.favoriteList,
fid: 0, // 选中的收藏板块
collect: [1],
settingShow: false, //弹窗显示
@@ -106,20 +108,20 @@ export default {
},
watch: {
- "$store.state.homeRequestState": {
- handler(newV, oldV) {
- console.log("newVnewV", newV);
- // if (!newV) return
- // this.$nextTick(() => {
- // this.favoriteHeadIdList = this.$parent.favorite || []
- // this.getAllForumList()
+ // "$store.state.homeRequestState": {
+ // handler(newV, oldV) {
+ // console.log("newVnewV", newV);
+ // if (!newV) return
+ // this.$nextTick(() => {
+ // this.favoriteHeadIdList = this.$parent.favorite || []
+ // this.getAllForumList()
- // if (this.fid) this.handleFavoriteHeadList()
- // })
+ // if (this.fid) this.handleFavoriteHeadList()
+ // })
- },
- immediate: true
- },
+ // },
+ // immediate: true
+ // },
fid: {
handler(newV, oldV) {
@@ -135,8 +137,11 @@ export default {
this.getCollectList()
+ // console.log(this.$store.state.favoriteList, "this.$store.state.favoriteList");
if (this.favoriteHeadIdList.length != 0) this.getAllForumList()
+ console.log("this.favoriteHeadIdList", this.favoriteHeadIdList, this.favoriteHeadList);
+
this.$store.subscribe((mutation, state) => {
if (mutation.type == "setHomeRequestState" && mutation.payload) {
if (!this.$store.state.homeRequestState) return
@@ -153,6 +158,17 @@ export default {
methods: {
// 获取收藏列表数据
getCollectList() {
+ let { homeRequestState, favoriteList } = this.$store.state
+ console.log("homeRequestState", homeRequestState);
+ if (!homeRequestState) {
+ setTimeout(() => {
+ this.getCollectList()
+ }, 300);
+ return
+ }
+
+
+ if (favoriteList.length == 0) return
this.$startupUnderLoading(this)
this.$http.post("/api/home/threadList", {
limit: this.favorite.limit,
diff --git a/src/views/index/index.vue b/src/views/index/index.vue
index eae7c9a..d79b31e 100755
--- a/src/views/index/index.vue
+++ b/src/views/index/index.vue
@@ -57,6 +57,8 @@ export default {
this.$store.commit('setHomeRequestState', true)
this.$store.commit('setFavoriteList', data.favorite)
this.$store.commit('setRecommendList', data.recommend)
+
+ // console.log(this.$store.state.favoriteList,"this.$store.state.favoriteListthis.$store.state.favoriteList ");
})
},
}