Blame view

src/components/Wuc-tab/Wuc-tab.vue 2.75 KB
e7121c710   BigBoss   detail update
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
  <template>
    <scroll-view class="wuc-tab" :class="tabClass" :style="tabStyle" scroll-with-animation scroll-x :scroll-left="scrollLeft">
      <div v-if="!textFlex" class="wuc-tab-wrap">
        <div class="wuc-tab-item" :class="[index === tabCur ? selectClass + ' cur':'']" v-for="(item,index) in tabList" :key="index" :id="index" @tap="tabSelect(index,$event)">
          <text :class="item.icon"></text>
          <span>{{item.name}}</span>
        </div>
      </div>
  
      <div class="flex text-center" v-if="textFlex">
        <div class="wuc-tab-item flex-sub" :class="index === tabCur ? selectClass + ' cur':''" v-for="(item,index) in tabList" :key="index" :id="index" @tap="tabSelect(index,$event)">
          <text :class="item.icon"></text>
          <span>{{item.name}}</span>
        </div>
      </div>
    </scroll-view>
  </template>
  <script>
  export default {
      name: 'Wuc-tab',
      data() {
          return {};
      },
      props: {
          tabList: {
              type: Array,
              default() {
                  return [];
              }
          },
          tabCur: {
              type: Number,
              default() {
                  return 0;
              }
          },
          tabClass: {
              type: String,
              default() {
                  return '';
              }
          },
          tabStyle: {
              type: String,
              default() {
                  return '';
              }
          },
          textFlex: {
              type: Boolean,
              default() {
                  return false;
              }
          },
          selectClass: {
              type: String,
              default() {
                  return 'text-blue';
              }
          }
      },
      methods: {
          tabSelect(index, e) {
              if (this.currentTab === index) return false;
              this.$emit('update:tabCur', index);
              this.$emit('change', index);
          }
      },
      computed: {
          scrollLeft() {
              return (this.tabCur - 1) * 60;
          }
      }
  };
  </script>
  <style>
  div,
  scroll-view,
  swiper {
  	box-sizing: border-box;
  }
  .wuc-tab {
      white-space: nowrap;
  	margin-bottom: 24rpx;
  }
  .wuc-tab-wrap{
  	display: flex;
  	justify-content: space-between;
  }
  .wuc-tab-item {
      height: 48rpx;
      display: inline-block;
      line-height: 48rpx;
      font-size: 14px;
      color: #333333;
  }
  
  .wuc-tab-item.cur {
      border-bottom: 4rpx solid #FF6B4A;
  }
  
  .wuc-tab.fixed {
  	position: fixed;
  	width: 100%;
  	top: 0;
  	z-index: 1024;
  	box-shadow: 0 1upx 6upx rgba(0, 0, 0, 0.1);
  }
  
  .flex {
      display: flex;
  }
  .text-center {
      text-align: center;
  }
  .flex-sub {
      flex: 1;
  }
  .text-blue{
    color:#333333;
  }
  .text-white{
    color:#ffffff;
  }
  .bg-white{
      background-color: #ffffff;
  }
  .bg-blue{
      background-color: #333333;
  }
  .text-orange{
    color: #f37b1d
  }
  
  .text-xl {
  	font-size: 36upx;
  }
  </style>