demo.vue
7.11 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<template>
<div>
<div>
<wuc-tab :tab-list="tabList" :tabCur.sync="TabCur" tab-class="text-center bg-white wuc-tab fixed" :tab-style="CustomBar" select-class="text-blue" @change="tabChange"></wuc-tab>
<div class="cu-bar bg-white solid-bottom" style="margin-top:100upx">
<div class="action">
<text class="cuIcon-titles text-orange"></text>基本使用(tab固定,只支持点击标签切换)
</div>
</div>
<div class="bg-white padding margin text-center text-black">{{tabList[TabCur].name}}</div>
</div>
<div>
<div class="cu-bar bg-white margin-top solid-bottom">
<div class="action">
<text class="cuIcon-titles text-orange"></text>居中选中放大(外部触发切换)
</div>
</div>
<wuc-tab :tab-list="tabList2" :tabCur="TabCur2" @change="tabChange2" tab-class="text-center text-black bg-white" select-class="text-blue text-xl"></wuc-tab>
<swiper :current="TabCur2" class="swiper" duration="300" :circular="true" indicator-color="rgba(255,255,255,0)" indicator-active-color="rgba(255,255,255,0)" @change="swiperChange2">
<swiper-item v-for="(item,index) in tabList2" :key="index">
<div class="bg-white padding margin text-center text-black">{{item.name}}</div>
</swiper-item>
</swiper>
</div>
<div>
<div class="cu-bar bg-white margin-top solid-bottom">
<div class="action">
<text class="cuIcon-titles text-orange"></text>平分
</div>
</div>
<wuc-tab :tab-list="tabList3" textFlex :tabCur.sync="TabCur3" tab-class="text-center text-black bg-white" select-class="text-orange"></wuc-tab>
<swiper :current="TabCur3" class="swiper" duration="300" :circular="true" indicator-color="rgba(255,255,255,0)" indicator-active-color="rgba(255,255,255,0)" @change="swiperChange3">
<swiper-item v-for="(item,index) in tabList3" :key="index">
<div class="bg-white padding margin text-center text-black">{{item.name}}</div>
</swiper-item>
</swiper>
</div>
<div>
<div class="cu-bar bg-white margin-top solid-bottom">
<div class="action">
<text class="cuIcon-titles text-orange"></text>背景
</div>
</div>
<wuc-tab :tab-list="tabList4" :tabCur.sync="TabCur4" tab-class="text-center text-white bg-blue" select-class="text-white"></wuc-tab>
<swiper :current="TabCur4" class="swiper row" duration="300" :circular="true" indicator-color="rgba(255,255,255,0)" indicator-active-color="rgba(255,255,255,0)" @change="swiperChange4">
<swiper-item v-for="(item,index) in tabList4" :key="index">
<div class="bg-white padding margin text-center text-black">{{item.name}}</div>
</swiper-item>
</swiper>
</div>
<div>
<div class="cu-bar bg-white margin-top solid-bottom">
<div class="action">
<text class="cuIcon-titles text-orange"></text>图标
</div>
</div>
<wuc-tab :tab-list="tabList5" :tabCur.sync="TabCur5" tab-class="text-center text-black bg-white" select-class="text-blue" />
<swiper :current="TabCur5" class="swiper" duration="300" :circular="true" indicator-color="rgba(255,255,255,0)" indicator-active-color="rgba(255,255,255,0)" @change="swiperChange5">
<swiper-item v-for="(item,index) in tabList5" :key="index">
<div class="bg-white padding margin text-center text-black">{{item.name}}</div>
</swiper-item>
</swiper>
</div>
</div>
</template>
<script>
import WucTab from '@/components/wuc-tab/wuc-tab.vue';
import { obj2style } from '@/utils/index';
export default {
data() {
return {
tabList: [
{ name: '选项卡一' },
{ name: '选项卡二' },
{ name: '选项卡三' },
{ name: '选项卡四' },
{ name: '选项卡五' },
{ name: '选项卡六' },
{ name: '选项卡七' },
{ name: '选项卡八' }
],
tabList2: [{ name: '精选' }, { name: '订阅' }],
tabList3: [{ name: '精选' }, { name: '订阅' }],
tabList4: [
{ name: '推荐' },
{ name: '热点' },
{ name: '视频' },
{ name: '问答' },
{ name: '社会' },
{ name: '娱乐' },
{ name: '科技' },
{ name: '汽车' }
],
tabList5: [
{ name: '短信', icon: 'cuIcon-comment' },
{ name: '电话', icon: 'cuIcon-dianhua' },
{ name: 'wifi', icon: 'cuIcon-wifi' }
],
TabCur: 0,
TabCur2: 0,
TabCur3: 0,
TabCur4: 0,
TabCur5: 0
};
},
components: { WucTab },
computed: {
CustomBar() {
let style = {};
// #ifdef MP-WEIXIN
const systemInfo = uni.getSystemInfoSync();
let CustomBar =
systemInfo.platform === "android"
? systemInfo.statusBarHeight + 50
: systemInfo.statusBarHeight + 45;
style['top'] = CustomBar + 'px';
// #endif
// #ifdef H5
style['top'] = 0 + 'px';
// #endif
return obj2style(style);
}
},
methods: {
tabChange(index) {
this.TabCur = index;
},
tabChange2(index) {
this.TabCur2 = index;
},
swiperChange2(e) {
let { current } = e.target;
this.TabCur2 = current;
},
swiperChange3(e) {
let { current } = e.target;
this.TabCur3 = current;
},
swiperChange4(e) {
let { current } = e.target;
this.TabCur4 = current;
},
swiperChange5(e) {
this.TabCur5 = e.target.current;
}
},
onReady() {}
};
</script>
<style>
@import "~@/styles/icon.scss";
div,
scroll-view,
swiper {
box-sizing: border-box;
}
div {
font-size: 28upx;
background-color: #f1f1f1;
}
.swiper {
height: 140upx;
}
.cu-bar {
display: flex;
position: relative;
align-items: center;
min-height: 100upx;
justify-content: space-between;
}
.cu-bar .action {
display: flex;
align-items: center;
height: 100%;
justify-content: center;
max-width: 100%;
background-color: #ffffff;
}
.cu-bar .action:first-child {
margin-left: 30upx;
font-size: 30upx;
}
.solid,
.solid-bottom {
position: relative;
}
.solid::after,
.solid-bottom::after{
content: " ";
width: 200%;
height: 200%;
position: absolute;
top: 0;
left: 0;
border-radius: inherit;
transform: scale(0.5);
transform-origin: 0 0;
pointer-events: none;
box-sizing: border-box;
}
.solid::after {
border: 1upx solid rgba(0, 0, 0, 0.1);
}
.solid-bottom::after {
border-bottom: 1upx solid rgba(0, 0, 0, 0.1);
}
.text-orange{
color:#f37b1d
}
.text-black{
color:#333333;
}
.bg-white{
background-color: #ffffff;
}
.padding {
padding: 30upx;
}
.margin {
margin: 30upx;
}
.margin-top {
margin-top: 30upx;
}
.text-center {
text-align: center;
}
</style>