Blame view

ceres-uniapp-master/components/basics/categoryList.vue 1.76 KB
3f535f30   杨鑫   '初始'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
  <template>
    <view class="tabs-nav-warp">
      <scroll-view class="tabs-nav" scroll-x="true">
        <view class="ul">
          <view class="li" :class="{'on':activeTab===0}" @click="tabChange(0)">首页</view>
          <view class="li" :class="{'on':activeTab===index+1}" v-for="(item,index) in categoryList" :key="index" @click="tabChange(index+1,item.classifyId)">
            {{item.classifyName}}
          </view>
        </view>
      </scroll-view>
    </view>
  </template>
  
  <script>
  const NET = require('@/utils/request')
  const API = require('@/config/api')
  export default {
    name: "categoryList",
    data () {
      return {
        activeTab: 0,
        categoryList: []
      }
    },
    mounted () {
      this.getCategoryData();
    },
    methods:{
      tabChange (index, id) {
        this.activeTab = index
        this.$emit('tabChange', index, id)
      },
      getCategoryData(){
        uni.showLoading({
          title:'加载中...'
        })
        NET.request(API.FindCategoryListByDepth, {
        }, 'GET').then(res => {
          this.categoryList = res.data
          uni.hideLoading()
        }).catch(res => {
          uni.hideLoading()
        })
      }
    }
  
  }
  </script>
  
  <style lang="scss" scoped>
  .tabs-nav-warp{
    margin-top: 20rpx;
    padding:0 30rpx;
    .tabs-nav{
      .ul{
        display: flex;
        .li{
          flex: 1 0 auto;
          margin-left: 36rpx;
          font-size: 30rpx;
          color: #999999;
          position: relative;
          padding-bottom: 18rpx;
          &:first-child{
            margin-left: 0;
          }
          &.on{
            &:after{
              content: '';
              width: 100%;
              height: 4rpx;
              background: #39be7a;
              position: absolute;
              left: 0;
              bottom: 0;
            }
            font-weight:bold;
          }
        }
      }
    }
  }
  
  </style>