diff --git a/src/views/index/allSections/AllSections.vue b/src/views/index/allSections/AllSections.vue index f9a36de..92a5ca9 100755 --- a/src/views/index/allSections/AllSections.vue +++ b/src/views/index/allSections/AllSections.vue @@ -84,7 +84,7 @@ export default { if (twofid) this.twofid = twofid if (invitationPage) this.invitationPage = Number(invitationPage) - if (Number(onefid) > 0) this.a() + if (Number(onefid) > 0) this.handQuery() if (Number(twofid) > 0) this.getInvitationList() @@ -92,18 +92,15 @@ export default { }, methods: { - a() { + // 处理 query 的参数 + handQuery() { 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, @@ -116,11 +113,9 @@ export default { }) - console.log(this.onefid, "onefidonefid"); - } else { setTimeout(() => { - this.a() + this.handQuery() }, 500) } @@ -132,10 +127,7 @@ export default { 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); + this.$updateURLSearchParams({ onefid: fid }) }, // 点击收藏 diff --git a/src/views/index/recommend/Recommend.vue b/src/views/index/recommend/Recommend.vue index 6082377..3a9f322 100755 --- a/src/views/index/recommend/Recommend.vue +++ b/src/views/index/recommend/Recommend.vue @@ -2,11 +2,12 @@ <div class="recommend"> <!-- 热门版块 --> <div class="hot-box"> - <div class="hot-label" :class="{ 'active': hotActive == index }" v-for="(item, index) in list" :key="index" - @click="hotLabelClick(index)">{{ item.label }}</div> + <div class="hot-label" :class="{ 'active': hotActive == index }" v-for="(item, index) in hotList" :key="index" + @click="hotLabelClick(index, item.fid)">{{ item.name }}</div> </div> <!-- 路径 --> - <plate-navigation stairname="香港澳门台湾" subsectionsname="SAT、AP考试、海外本科申…"></plate-navigation> + <plate-navigation v-if="fid != 0" :stairname="plate.subsectionsname" + :subsectionsname="plate.subsectionsname"></plate-navigation> <section> <template v-if="list.length == 0"> <index-list></index-list> @@ -26,28 +27,33 @@ export default { data() { return { hotActive: -1,//热门版块活跃点击 - list: [ - { - label: "香港留学" - }, - { - label: "香港留学" - }, - { - label: "香港留学" - }, - { - label: "香港留学" - } - ] + hotList: [], + list: [], + fid: 0, // 板块id + plate: { + stairname: "",// 一级版块名称 + subsectionsname: "",// 子版块名称 + }, + } + }, + + watch: { + "$parent.recommend": { + handler(newV, oldV) { + console.log(newV); + this.hotList = newV + }, + immediate: true } }, mounted() { - console.log(this.$parent); + console.log(this.$parent.recommend); }, methods: { - hotLabelClick(index) { + hotLabelClick(index, fid) { + console.log(fid); + this.fid = fid this.hotActive = index } }, diff --git a/src/views/search/searchResult/SearchResult.vue b/src/views/search/searchResult/SearchResult.vue index 1a2fa80..cb390a0 100755 --- a/src/views/search/searchResult/SearchResult.vue +++ b/src/views/search/searchResult/SearchResult.vue @@ -108,9 +108,11 @@ export default { let kw = this.kw if (!kw) return this.page = 1 - this.getSearchResult() - this.$updateURLSearchParams({ kw: this.kw, page: this.page }) + this.$router.push({ path: `/searchResult`, query: { kw: this.kw, page: this.page } }) + + // this.getSearchResult() + // this.$updateURLSearchParams({ kw: this.kw, page: this.page }) }, // 获取搜索结果数据