+
{{ item.name }}
+ @click="allClick(index, item.fid)">{{ item.name }}

+ @click.stop="starClick(k, i.fid, 'forumFav')">

+ @click.stop="starClick(k, i.fid, 'unforumFav')">
@@ -28,8 +28,16 @@
-
+
+
+
+
+

+
+
+
+
@@ -48,9 +56,11 @@ export default {
data() {
return {
allActive: 0,
- list: [{}],
+ // list: [{}],
+ list: this.$store.state.allForumList,
postCollectionState: false, // 收藏的请求的状态
- fid: 0, // 是否有选中的板块id
+ onefid: 0, // 一级列表的板块id
+ twofid: 0, // 是否有选中的板块id
invitationList: [], // 选中板块帖子的列表
invitationLimit: 10,
invitationPage: 1, //
@@ -60,28 +70,90 @@ export default {
subsectionsname: "",// 子版块名称
},
-
}
},
+ mounted() {
+ console.log("gggkgkgk");
+ this.$store.subscribe((mutation, state) => {
+ if (mutation.type == "setAllForumList") this.list = this.$store.state.allForumList
+ });
+
+ let { onefid, twofid } = this.$route.query
+ if (onefid) this.onefid = onefid
+ if (twofid) this.twofid = twofid
+
+ if (Number(onefid) > 0) this.a()
+
+
+ if (Number(twofid) > 0) this.getInvitationList()
+
+ },
+
methods: {
+ a() {
+ if (this.list.length >= 2) {
+
+ let list = this.list
+ list.forEach((el, index) => {
+ // console.log(this.twofid);
+
+ if (el.fid == this.onefid) this.allActive = index
+
+ if (this.twofid) {
+ el.data.forEach((element, i) => {
+ console.log(element, i);
+ if (element.fid == this.twofid) {
+ this.plate = {
+ stairname: el.name,
+ subsectionsname: element.name,
+ }
+ }
+ })
+
+ }
+
+ })
+
+ console.log(this.onefid, "onefidonefid");
+
+ } else {
+ setTimeout(() => {
+ this.a()
+ }, 500)
+ }
+
+ },
+ // 点击返回选择一级列表页面
backAll() {
- this.fid = 0
+ this.twofid = 0
},
- allClick(index) {
+ allClick(index, fid) {
this.allActive = index
+ const params = new URLSearchParams(window.location.search);
+ params.set('onefid', fid);
+ const newUrl = window.location.pathname + '?' + params.toString();
+ window.history.pushState({}, '', newUrl);
},
// 点击收藏
- starClick(k, fid) {
+ starClick(k, fid, state) {
if (this.postCollectionState) return
+ let url = ""
+ if (state == "forumFav") url = "/api/operation/forumFav"
+ else url = "/api/operation/unforumFav"
this.postCollectionState = true
- this.$http.post("/api/operation/forumFav", {
+ this.$http.post(url, {
fid
}).then(res => {
if (res.code != 200) return
- this.list[this.allActive].data[k]['iscollection'] = 1
+
+ let list = this.$store.state.allForumList
+ list[this.allActive].data[k]['iscollection'] = state == "forumFav" ? 1 : 0
+
+ this.$store.commit('setAllForumList', list)
+
this.$Message.success(res.message)
this.$forceUpdate()
}).finally(() => {
@@ -89,42 +161,20 @@ export default {
})
},
- // 点击取消收藏
- cancelCollection(k, fid) {
- if (this.postCollectionState) return
- this.postCollectionState = true
-
- this.$http.post("/api/operation/unforumFav", {
- fid
- }).then(res => {
- if (res.code != 200) return
- this.list[this.allActive].data[k]['iscollection'] = 0
- this.$Message.success(res.message)
- this.$forceUpdate()
- }).finally(() => {
- this.postCollectionState = false
- })
- },
-
- // 获取全部板块
- getAllForum() {
- this.$http.post("/api/home/allForum").then((res) => {
- if (res.code != 200) return;
- this.list = res.data
- }).catch(err => {
- this.$message.error(err.message)
- });
- },
-
// 点击选中板块 并获取列表
pitchPlate(fid, subsectionsname) {
- this.fid = fid
+ this.twofid = fid
this.plate = {
stairname: this.list[this.allActive].name,
subsectionsname,
}
-
this.getInvitationList()
+
+ const params = new URLSearchParams(window.location.search);
+ params.set('onefid', this.list[this.allActive].fid,);
+ params.set('twofid', this.twofid);
+ const newUrl = window.location.pathname + '?' + params.toString();
+ window.history.pushState({}, '', newUrl);
},
// 获取帖子列表
@@ -132,7 +182,7 @@ export default {
this.$http.post("/api/home/threadList", {
page: this.invitationPage,
limit: this.invitationLimit,
- fid: this.fid
+ fid: this.twofid
}).then(res => {
let data = res.data
this.invitationList = data.data
@@ -149,10 +199,6 @@ export default {
this.getInvitationList()
},
- },
- mounted() {
- this.getAllForum()
-
},
components: {
@@ -164,6 +210,10 @@ export default {
\ No newline at end of file
diff --git a/src/views/search/searchResult/SearchResult.vue b/src/views/search/searchResult/SearchResult.vue
index 7b9037b..e841035 100755
--- a/src/views/search/searchResult/SearchResult.vue
+++ b/src/views/search/searchResult/SearchResult.vue
@@ -75,8 +75,6 @@ export default {
list: [],
searchResultState: false,
loading: null,
- historicalSearch: this.$store.state.historicalSearch, // 历史搜索
-
}
},
components: {
@@ -86,11 +84,8 @@ export default {
mounted() {
this.kw = this.$route.query.kw
this.getSearchResult()
- console.log(this.historicalSearch, "historicalSearch");
- window.addEventListener("visibilitychange", () => {
- console.log("fkjflkdfj");
- })
+
},
watch: {
@@ -98,17 +93,6 @@ export default {
if (val) this.$startupUnderLoading(this)
else this.$closeUnderLoading(this)
},
-
- historicalSearch(val, oldval) {
- console.log("val", val);
- // if (val.length > 10) {
- // this.historicalSearch = val.slice(0, 10)
- // }
- // else this.$store.commit('setHistoricalSearch', this.historicalSearch)
-
- // this.$store.commit('setHistoricalSearch', val)
-
- },
},
methods: {
@@ -122,11 +106,6 @@ export default {
handleSearchResult() {
let kw = this.kw
if (!kw) return
- // console.log(this.historicalSearch.includes(kw), "this.historicalSearch.includes(kw)");
- console.log(this.historicalSearch.unshift(kw));
- // if (!this.historicalSearch.includes(kw)) this.historicalSearch = this.historicalSearch.unshift(kw)
- console.log(this.historicalSearch, "historicalSearch");
-
this.getSearchResult()
},
@@ -137,7 +116,7 @@ export default {
if (this.searchResultState) return
this.searchResultState = true
let kw = this.kw
- this.$http.post("/api/search", {
+ this.$http.get("/api/search", {
keyword: kw,
page: this.page,
limit: this.limit
@@ -152,7 +131,7 @@ export default {
document.body.scrollTop = 0;
this.searchResultState = false
}).finally(() => {
-
+ this.$store.commit('setHistoricalSearch', this.kw)
})
},