Blame view

pages/extUI/swiper-dot/swiper-dot.nvue 6.05 KB
4b045f7c   刘淇   江阴初始化项目
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
  <template>
  	<view class="content">
  		<uni-swiper-dot class="uni-swiper-dot-box" @clickItem=clickItem :info="info" :current="current" :mode="mode"
  			:dots-styles="dotsStyles" field="content">
  			<swiper class="swiper-box" @change="change" :current="swiperDotIndex">
  				<swiper-item v-for="(item, index) in 3" :key="index">
  					<view class="swiper-item" :class="'swiper-item' + index">
  						<text style="color: #fff; font-size: 32px;">{{index+1}}</text>
  					</view>
  				</swiper-item>
  			</swiper>
  		</uni-swiper-dot>
  		<uni-section title="模式选择" type="line">
  			<view class="example-body">
  				<view :class="{ active: modeIndex === 0 }" class="example-body-item" @click="selectMode('default', 0)">
  					<text class="example-body-item-text">default</text></view>
  				<view :class="{ active: modeIndex === 1 }" class="example-body-item" @click="selectMode('dot', 1)"><text
  						class="example-body-item-text">dot</text></view>
  				<view :class="{ active: modeIndex === 2 }" class="example-body-item" @click="selectMode('round', 2)">
  					<text class="example-body-item-text">round</text></view>
  				<view :class="{ active: modeIndex === 3 }" class="example-body-item" @click="selectMode('nav', 3)"><text
  						class="example-body-item-text">nav</text></view>
  				<view :class="{ active: modeIndex === 4 }" class="example-body-item" @click="selectMode('indexes', 4)">
  					<text class="example-body-item-text">indexes</text></view>
  			</view>
  		</uni-section>
  
  		<uni-section title="颜色样式选择" type="line">
  			<view class="example-body">
  				<template v-if="mode !== 'nav'">
  					<view v-for="(item, index) in dotStyle" :class="{ active: styleIndex === index }" :key="index"
  						class="example-body-item" @click="selectStyle(index)">
  						<view :style="{ 'background-color': item.selectedBackgroundColor, border: item.selectedBorder }"
  							class="example-body-dots" />
  						<view :style="{ 'background-color': item.backgroundColor, border: item.border }"
  							class="example-body-dots" />
  						<view :style="{ 'background-color': item.backgroundColor, border: item.border }"
  							class="example-body-dots" />
  					</view>
  				</template>
  				<template v-if="mode === 'nav'">
  					<view v-for="(item, index) in dotStyle" :class="{ active: styleIndex === index }" :key="index"
  						:style="{ 'background-color': item.selectedBackgroundColor }" class="example-body-item"
  						@click="selectStyle(index)">
  						<text class="example-body-item-text" :style="{ color: item.color }">内容</text>
  					</view>
  				</template>
  			</view>
  		</uni-section>
  
  	</view>
  </template>
  
  <script>
  	export default {
  		components: {},
  		data() {
  			return {
  				info: [{
  						colorClass: 'uni-bg-red',
  						url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
  						content: '内容 A'
  					},
  					{
  						colorClass: 'uni-bg-green',
  						url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
  						content: '内容 B'
  					},
  					{
  						colorClass: 'uni-bg-blue',
  						url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
  						content: '内容 C'
  					}
  				],
  				dotStyle: [{
  						backgroundColor: 'rgba(0, 0, 0, .3)',
  						border: '1px rgba(0, 0, 0, .3) solid',
  						color: '#fff',
  						selectedBackgroundColor: 'rgba(0, 0, 0, .9)',
  						selectedBorder: '1px rgba(0, 0, 0, .9) solid'
  					},
  					{
  						backgroundColor: 'rgba(255, 90, 95,0.3)',
  						border: '1px rgba(255, 90, 95,0.3) solid',
  						color: '#fff',
  						selectedBackgroundColor: 'rgba(255, 90, 95,0.9)',
  						selectedBorder: '1px rgba(255, 90, 95,0.9) solid'
  					},
  					{
  						backgroundColor: 'rgba(83, 200, 249,0.3)',
  						border: '1px rgba(83, 200, 249,0.3) solid',
  						color: '#fff',
  						selectedBackgroundColor: 'rgba(83, 200, 249,0.9)',
  						selectedBorder: '1px rgba(83, 200, 249,0.9) solid'
  					}
  				],
  				modeIndex: -1,
  				styleIndex: -1,
  				current: 0,
  				mode: 'default',
  				dotsStyles: {},
  				swiperDotIndex: 0
  			}
  		},
  		onLoad() {},
  		methods: {
  			change(e) {
  				this.current = e.detail.current
  			},
  			selectStyle(index) {
  				this.dotsStyles = this.dotStyle[index]
  				this.styleIndex = index
  			},
  			selectMode(mode, index) {
  				this.mode = mode
  				this.modeIndex = index
  				this.styleIndex = -1
  				this.dotsStyles = this.dotStyle[0]
  			},
  			clickItem(e) {
  				this.swiperDotIndex = e
  			},
  			onBanner(index) {
  				console.log(22222, index);
  			}
  		}
  	}
  </script>
  
  <style lang="scss">
  	.swiper-box {
  		height: 200px;
  	}
  
  	.swiper-item {
  		/* #ifndef APP-NVUE */
  		display: flex;
  		/* #endif */
  		flex-direction: column;
  		justify-content: center;
  		align-items: center;
  		height: 200px;
  		color: #fff;
  	}
  
  	.swiper-item0 {
  		background-color: #cee1fd;
  	}
  
  	.swiper-item1 {
  		background-color: #b2cef7;
  	}
  
  	.swiper-item2 {
  		background-color: #cee1fd;
  	}
  
  	.image {
  		width: 750rpx;
  	}
  
  	/* #ifndef APP-NVUE */
  	::v-deep .image img {
  		-webkit-user-drag: none;
  		-khtml-user-drag: none;
  		-moz-user-drag: none;
  		-o-user-drag: none;
  		user-drag: none;
  	}
  
  	/* #endif */
  
  	@media screen and (min-width: 500px) {
  		.uni-swiper-dot-box {
  			width: 400px;
  			margin: 0 auto;
  			margin-top: 8px;
  		}
  
  		.image {
  			width: 100%;
  		}
  	}
  
  	.uni-bg-red {
  		background-color: #ff5a5f;
  	}
  
  	.uni-bg-green {
  		background-color: #09bb07;
  	}
  
  	.uni-bg-blue {
  		background-color: #007aff;
  	}
  
  	.example-body {
  		/* #ifndef APP-NVUE */
  		display: flex;
  		/* #endif */
  		flex-direction: row;
  		padding: 20rpx;
  	}
  
  	.example-body-item {
  
  		flex-direction: row;
  		justify-content: center;
  		align-items: center;
  		margin: 15rpx;
  		padding: 15rpx;
  		height: 60rpx;
  		/* #ifndef APP-NVUE */
  		display: flex;
  		padding: 0 15rpx;
  		/* #endif */
  		flex: 1;
  		border-color: #e5e5e5;
  		border-style: solid;
  		border-width: 1px;
  		border-radius: 5px;
  	}
  
  	.example-body-item-text {
  		font-size: 28rpx;
  		color: #333;
  	}
  
  	.example-body-dots {
  		width: 16rpx;
  		height: 16rpx;
  		border-radius: 50px;
  		background-color: #333333;
  		margin-left: 10rpx;
  	}
  
  	.active {
  		border-style: solid;
  		border-color: #007aff;
  		border-width: 1px;
  	}
  </style>