inleft
2022-08-24 80476fae71f08bf4408c7509eff254031a4eeac6
commit | author | age
6461f5 1 <template>
eeef9f 2
80476f 3     <a-tabs :defaultActiveKey="activeKey" @change="changeKey"
I 4         :tabBarStyle="{'display': 'flex','justify-content': 'center'}">
5         <a-tab-pane :key="keyType.type_1" tab="片刻">
38a800 6             <videoList v-on="$listeners" :activeKey="activeKey"></videoList>
I 7         </a-tab-pane>
80476f 8         <a-tab-pane :key="keyType.type_2" tab="流影">
I 9             <videoList v-on="$listeners" :activeKey="activeKey"></videoList>
38a800 10         </a-tab-pane>
80476f 11         <a-tab-pane :key="keyType.type_3" tab="谱库">
38a800 12             <photoShow :activeKey="activeKey"></photoShow>
I 13         </a-tab-pane>
14     </a-tabs>
eeef9f 15
6461f5 16 </template>
38a800 17
6461f5 18 <script>
38a800 19     import videoList from "../mini/box14-video.vue"
I 20     import photoShow from "../mini/box18-photoShow.vue"
80476f 21     import myConstant from "../../config/myConstant.js"
38a800 22
6461f5 23     export default {
38a800 24         components: {
I 25             videoList,
80476f 26             photoShow,
38a800 27         },
I 28         created() {
29             this.getActiveKey()
30         },
31         watch: {
32             '$route'(to, from) {
33                 if ("platform" === to.name) {
34                     this.getActiveKey()
35                 }
36             },
6461f5 37         },
I 38         methods: {
38a800 39             getActiveKey() {
80476f 40                 if (this.$route.query.activeKey != "" && this.$route.query.activeKey != undefined) {
38a800 41                     this.activeKey = this.$route.query.activeKey;
80476f 42                 } else {
I 43                     //随机三选一
44                     var random = Math.floor(Math.random() * 10);
45                     this.activeKey = random >= 8 ?
46                         this.keyType.type_3 : (random <= 3 ? this.keyType.type_2 : this.keyType.type_1)
38a800 47                 }
80476f 48                 this.$router.replace({query:{activeKey:this.activeKey}})
38a800 49             },
80476f 50             changeKey(key) {
I 51                 this.activeKey = key
52                 this.$router.replace({query:{activeKey:this.activeKey}})
53             }
38a800 54         },
I 55         data() {
56             return {
80476f 57                 activeKey: "moment",
I 58                 keyType: myConstant.activeKeyType
6461f5 59             }
38a800 60         },
I 61
6461f5 62     }
I 63 </script>
38a800 64
I 65 <style lang="less">
66     .ant-tabs-tab {
67         user-select: none;
68     }
69 </style>