|
@@ -4,6 +4,7 @@
|
|
|
v-if="topicOfConversation.length"
|
|
|
:topicOfConversation="topicOfConversation"
|
|
|
@toRouter="toRouter"
|
|
|
+ :key="routerKey+'/11'"
|
|
|
/>
|
|
|
<router-view class="basePage" :key="routerKey" />
|
|
|
</div>
|
|
@@ -11,6 +12,7 @@
|
|
|
|
|
|
<script>
|
|
|
import { getBase } from "@/api/getList";
|
|
|
+import utils from "../../utils/utils";
|
|
|
|
|
|
import Tabs from "../../components/tabs";
|
|
|
export default {
|
|
@@ -24,59 +26,69 @@ export default {
|
|
|
topicOfConversation: [],
|
|
|
};
|
|
|
},
|
|
|
- created() {
|
|
|
- let season = sessionStorage.getItem("season");
|
|
|
- getBase({
|
|
|
- season
|
|
|
- }).then((res) => {
|
|
|
- this.$store.commit("setTabList", res || []);
|
|
|
- let list = [
|
|
|
- {
|
|
|
- title: "话题对比",
|
|
|
- path: "/contrast",
|
|
|
- id: -1,
|
|
|
- childList: [],
|
|
|
- },
|
|
|
- ];
|
|
|
- if(season == 2) list = [];
|
|
|
- (res || []).map((v) => {
|
|
|
- let childList = (v.child_list || []).map((val, i) => {
|
|
|
- // { title: "子集", path: "/topic", id: i + 1 + "-0", pId: i + 1 }
|
|
|
- return {
|
|
|
- title: val,
|
|
|
- id: i,
|
|
|
- pId: v.topic_id,
|
|
|
- };
|
|
|
- });
|
|
|
-
|
|
|
- list.push({
|
|
|
- title: v.alias_name,
|
|
|
- real_title: v.topic_name,
|
|
|
- path: "/topic",
|
|
|
- id: v.topic_id,
|
|
|
- childList,
|
|
|
- });
|
|
|
- this.topicOfConversation = list;
|
|
|
- });
|
|
|
- if(season == 2 && this.topicOfConversation && this.topicOfConversation.length) {
|
|
|
- this.toRouter(this.topicOfConversation[0], this.topicOfConversation[0].id)
|
|
|
- }else if (season == 1){
|
|
|
- this.toRouter({
|
|
|
- path: "/contrast"
|
|
|
- })
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
+ created() {},
|
|
|
mounted() {},
|
|
|
computed: {
|
|
|
routerKey() {
|
|
|
let date = new Date();
|
|
|
- return this.routerData.path + date.getTime();
|
|
|
+ let season = utils.getUrl("season");
|
|
|
+ let oriSeason = sessionStorage.getItem("season");
|
|
|
+ if(season != oriSeason || !this.topicOfConversation.length){
|
|
|
+ sessionStorage.setItem("season", season || 1);
|
|
|
+ this.init(); // 路由变化时更新tabs
|
|
|
+ }
|
|
|
+ return this.$route.name + date.getTime();
|
|
|
},
|
|
|
},
|
|
|
methods: {
|
|
|
+ init() {
|
|
|
+ let season = sessionStorage.getItem("season");
|
|
|
+ getBase({
|
|
|
+ season,
|
|
|
+ }).then(res => {
|
|
|
+ this.$store.commit("setTabList", res || []);
|
|
|
+ let list = [];
|
|
|
+ if (season == 1)
|
|
|
+ list.push({
|
|
|
+ title: "话题对比",
|
|
|
+ path: "/contrast",
|
|
|
+ id: -1,
|
|
|
+ childList: [],
|
|
|
+ });
|
|
|
+ (res || []).map(v => {
|
|
|
+ let childList = (v.child_list || []).map((val, i) => {
|
|
|
+ return {
|
|
|
+ title: val,
|
|
|
+ id: i,
|
|
|
+ pId: v.topic_id,
|
|
|
+ };
|
|
|
+ });
|
|
|
+
|
|
|
+ list.push({
|
|
|
+ title: v.alias_name,
|
|
|
+ real_title: v.topic_name,
|
|
|
+ path: "/topic",
|
|
|
+ id: v.topic_id,
|
|
|
+ childList,
|
|
|
+ });
|
|
|
+ this.topicOfConversation = list;
|
|
|
+ });
|
|
|
+ if (season == 1 && this.$route.name != "contrast") {
|
|
|
+ this.toRouter(
|
|
|
+ this.topicOfConversation[0],
|
|
|
+ this.topicOfConversation[0].id
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if (season == 2 && this.$route.name != "topic") {
|
|
|
+ this.toRouter(
|
|
|
+ this.topicOfConversation[0],
|
|
|
+ this.topicOfConversation[0].id
|
|
|
+ );
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
toRouter(params, id) {
|
|
|
- console.log(params,id)
|
|
|
+ let season = sessionStorage.getItem("season");
|
|
|
let sonlist =
|
|
|
params.childList && params.childList.length
|
|
|
? JSON.stringify(params.childList || [])
|
|
@@ -88,6 +100,7 @@ export default {
|
|
|
id,
|
|
|
title: params.real_title,
|
|
|
sonlist,
|
|
|
+ season,
|
|
|
},
|
|
|
});
|
|
|
},
|