Blame view

apps/pages/home/channel/components/scrollNav.vue 1.95 KB
Tao authored
1
<template>
yyq authored
2
  <div class="scroll-nav" v-if="labels.length > 0">
Tao authored
3
    <ScrollNavBar :current="this.list[current].title" :labels="labels" @change="changeHandler">
Tao authored
4
      <span slot-scope="props">
Tao authored
5
        {{props.txt}}
Tao authored
6
        <span :ref="`getindex${props.txt}`" v-show="false">{{props.index}}</span>
Tao authored
7 8
      </span>
    </ScrollNavBar>
Tao authored
9 10 11 12
  </div>
</template>

<script>
Tao authored
13
import { Style, ScrollNavBar } from 'cube-ui';
yyq authored
14
import queryString from 'querystring';
Tao authored
15
Tao authored
16 17 18
export default {
  name: 'slide',
  props: {
Tao authored
19 20 21 22
    list: {
      type: Array,
      default: true
    },
Tao authored
23
    current: {
Tao authored
24 25
      type: Number,
      default: true
huangyCode authored
26
    },
Tao authored
27
  },
Tao authored
28 29 30
  data() {
    return {
      index: 0,
Tao authored
31
      labels: [],
huangyCode authored
32
    };
Tao authored
33 34 35 36 37 38
  },
  components: {
    Style,
    ScrollNavBar
  },
  mounted() {
huangyCode authored
39 40 41
    this.list.map((res) => {
      this.labels.push(res.title);
    });
Tao authored
42
  },
Tao authored
43
  created() {
Tao authored
44
Tao authored
45 46
  },
  methods: {
47
    async changeHandler(cur) {
Tao authored
48
      let index = this.$refs[`getindex${cur}`].innerText;
huangyCode authored
49
      let url = this.list[index].url.split('?');
50
      let params = queryString.parse(url[1]);
huangyCode authored
51
yyq authored
52
      params.isReset = true;
53 54
      this.$parent.$parent.$parent.fetchList && await this.$parent.$parent.$parent.fetchList(params);
      this.$emit('transfer', {index,params});
Tao authored
55
    }
Tao authored
56 57 58 59 60
  }
};
</script>

<style lang="scss" scoped>
yyq authored
61
.scroll-nav {
Tao authored
62
  // padding: 0 24px;
yyq authored
63 64 65 66 67 68 69 70 71 72 73 74
}

/deep/ {
  .cube-scroll-nav-bar {
    background: none;
  }

  .cube-scroll-wrapper {
    text-align: left;
  }

  .cube-scroll-content {
Tao authored
75
    // display: block;
yyq authored
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
  }

  .cube-scroll-nav-bar-item {
    padding: 0 12px;
    line-height: 52px;
    font-size: 15px;
    color: #555;

    > span {
      font-weight: 300;
    }
  }

  .cube-scroll-nav-bar-item_active {
    color: #000;
    font-size: 16px;
    position: relative;

    > span {
      font-weight: 500;
    }

    &:after {
      content: "";
      position: absolute;
      left: 10px;
      right: 10px;
      bottom: 10px;
      height: 3px;
105
      border-radius: 1.5px;
yyq authored
106 107 108
      background-color: #000;
    }
  }
Tao authored
109 110 111
}

</style>