zhangxiaoxu123456
2021-12-20 301289e539c417995f95f5cb91fd1f6043bb7cfd
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
139
140
141
142
143
144
145
146
147
<template>
    <view class="u-demo">
        <view class="u-demo-wrap">
            <view class="u-demo-title">演示效果</view>
            <view class="u-demo-area">
                <u-toast ref="uToast"></u-toast>
                <u-tabs v-if="control" bg-color="#fafafa" :bold="bold" :active-color="activeColor" :list="list"
                @change="change" :current="current" :is-scroll="isScroll" :offset="offset"></u-tabs>
            </view>
        </view>
        <view class="u-config-wrap">
            <view class="u-config-title u-border-bottom">
                参数配置
            </view>
            <view class="u-config-item">
                <view class="u-item-title">模式选择</view>
                <u-subsection :current="sectionCurrent" :list="['滚动', '非滚动']" @change="modeChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">标签个数(非滚动模式)</view>
                <u-subsection :list="['2', '3',  '4']" @change="countChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">活动选项字颜色</view>
                <u-subsection mode="button" :list="['primary', 'success', 'error', 'warning']" @change="colorChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">字体加粗</view>
                <u-subsection mode="button" :list="['是', '否']" @change="boldChange"></u-subsection>
            </view>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                list: [],
                data: [{
                    name: '关注',
                    count: 100
                }, {
                    name:  '推荐',
                    count: 7
                }, {
                    name: '电影'
                },{
                    name: '电视剧'
                },{
                    name: '小视频'
                }, {
                    name:  '游戏'
                }, {
                    name: '校园'
                },{
                    name: '影视'
                },{
                    name: '音乐'
                }],
                current: 0,
                sectionCurrent: 0,
                isScroll: true,
                tabCountIndex: 0,
                activeColor: this.$u.color['primary'],
                bold: true,
                control: true,
                offset: [5, -5]
            }
        },
        onLoad() {
            this.list = this.data;
        },
        methods: {
            countChange(index) {
                this.sectionCurrent = 1;
                if(index == 0) {
                    this.list = [];
                    this.list.push(this.data[0]);
                    this.list.push(this.data[1]);
                    this.offset = [5, 60]
                } else if(index == 1) {
                    this.list = [];
                    this.list.push(this.data[0]);
                    this.list.push(this.data[1]);
                    this.list.push(this.data[2]);
                    this.offset = [5, 20]
                } else {
                    this.list = [];
                    this.list.push(this.data[0]);
                    this.list.push(this.data[1]);
                    this.list.push(this.data[2]);
                    this.list.push(this.data[3]);
                    this.offset = [5, 5]
                }
                this.tabCountIndex = index;
                this.isScroll = false;
            },
            change(index) {
                this.current = index;
            },
            modeChange(index) {
                this.control = false;
                this.current = 0;
                if(index == 0) {
                    this.isScroll = true;
                    this.list = this.data;
                    this.offset = [5, -5]
                } else {
                    this.isScroll = false;
                    this.countChange(this.tabCountIndex);
                }
                this.$nextTick(() => {
                    this.control = true;
                })
            },
            colorChange(e) {
                let color = 'primary';
                switch(e) {
                    case 0:
                        color = 'primary';break;
                    case 1:
                        color = 'success';break;
                    case 2:
                        color = 'error';break;
                    case 3:
                        color = 'warning';break;
                }
                this.activeColor = this.$u.color[color];
            },
            boldChange(e) {
                switch(e) {
                    case 0:
                        this.bold = true;break;
                    case 1:
                        this.bold = false;break;
                }
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .u-config-wrap {
 
    }
</style>