inleft
2022-08-29 1b6f1e454fff0187d4d30dcf0d5819d4f57f1787
commit | author | age
6461f5 1 <template>
c6793e 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)
c6793e 47                         
I 48                     this.$router.replace({query:{activeKey:this.activeKey}})
38a800 49                 }
I 50             },
80476f 51             changeKey(key) {
I 52                 this.activeKey = key
53                 this.$router.replace({query:{activeKey:this.activeKey}})
54             }
38a800 55         },
I 56         data() {
57             return {
80476f 58                 activeKey: "moment",
I 59                 keyType: myConstant.activeKeyType
6461f5 60             }
38a800 61         },
I 62
6461f5 63     }
I 64 </script>
38a800 65
I 66 <style lang="less">
67     .ant-tabs-tab {
68         user-select: none;
69     }
70 </style>