颜色滑动选择弹窗

效果预览

滑动选择
滑动选择

引入资源

  • 本弹窗是基于ui框架uview
  • 右上角切到2.X的文档,引入过程此处忽略,根据文档即可

具体实现代码

查看代码
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
<template>
<view class="main">
<view style="width: 100%;">
<button @click="carColorShow = true">出现</button>
</view>
<u-popup :customStyle="{borderRadius: '32rpx 32rpx 0rpx 0rpx'}" :show="carColorShow">
<view class="pop">
<view class="pop_title">颜色选择</view>
<view class="pop_del" @click.stop="carColorShow = false">
<image class="pop_del_img" src="/static/cw/img/addCar_del.png" mode="widthFix"></image>
</view>
<view class="pop_scroll">
<u-scroll-list :indicator="false">
<view class="pop_scroll_main" v-for="(item, index) in colorList" :key="index">
<view class="pop_scroll_main_item" :style="{marginLeft: index === 0 ? '23.1rpx' : ''}">
<view class="pop_scroll_main_item_out" :style="{border: carColorPop === item.name ? '3rpx solid #FF3A3A' : '3rpx solid #FFFFFF'}" @click="selectCarColor(item)">
<view class="pop_scroll_main_item_in" :style="{background: item.background, boxShadow: item.boxShadow}"></view>
</view>
<view class="pop_scroll_main_item_name">{{item.name}}</view>
</view>
</view>
</u-scroll-list>
</view>
<view class="pop_box">
<input class="pop_box_input" placeholder-class="pop_box_placeholder" type="text" @input="carColorInputWatch" v-model="carColorInputPop" :maxlength="6" placeholder="其他颜色" />
</view>
<button class="pop_button" @click="carColorSave">确定</button>
</view>
</u-popup>
</view>
</template>

<script>
export default {
data() {
return {
carColorShow: false,
carColorPop: '',
carColorInputPop: '',
colorList: [
{
background: 'linear-gradient(138deg, #2F2F32 0%, #060C0C 100%)',
boxShadow: '0px 2px 14px 0px rgba(0,0,0,0.3)',
name: '黑色',
},
{
background: 'linear-gradient(137deg, #FBFBFB 0%, #DFDFE3 100%)',
boxShadow: '0px 2px 14px 0px rgba(0,0,0,0.18)',
name: '白色',
},
{
background: 'linear-gradient(137deg, #989898 0%, #5C5C5C 100%)',
boxShadow: '0px 2px 14px 0px rgba(0,0,0,0.3)',
name: '灰色',
},
{
background: 'linear-gradient(145deg, #EFEFEF 0%, #D2D4D6 100%)',
boxShadow: '0px 2px 14px 0px rgba(0,0,0,0.3)',
name: '银色',
},
{
background: 'linear-gradient(317deg, #976F56 0%, #B28972 100%)',
boxShadow: '0px 2px 14px 0px rgba(0,0,0,0.3)',
name: '棕色',
},
{
background: 'linear-gradient(325deg, #C42A2C 0%, #E43333 100%)',
boxShadow: '0px 2px 14px 0px rgba(0,0,0,0.3)',
name: '红色',
},
{
background: 'linear-gradient(328deg, #417BA9 0%, #4188B1 100%)',
boxShadow: '0px 2px 14px 0px rgba(0,0,0,0.3)',
name: '蓝色',
},
{
background: 'linear-gradient(325deg, #F4B434 0%, #FFCF38 100%)',
boxShadow: '0px 2px 14px 0px rgba(0,0,0,0.3)',
name: '黄色',
}
],
}
},
methods: {
selectCarColor(item) {
this.carColorPop = item.name
this.carColorInputPop = ''
uni.vibrateShort({});
},
carColorInputWatch() {
this.carColorPop = ''
},
carColorSave() {
this.carColorShow = false
},
}
}
</script>

<style lang="scss">
/* 解决小程序和app滚动条的问题 */
/* #ifdef MP-WEIXIN || APP-PLUS */
::-webkit-scrollbar {
display: none;
width: 0 !important;
height: 0 !important;
-webkit-appearance: none;
background: transparent;
color: transparent;
}
/* #endif */
.main {
width: 100%;
height: 100%;
}
.pop {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
&_title {
color: #333333; font-size: 32rpx; font-weight: 500; margin-top: 32rpx;
}
&_del {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
top: 43rpx;
right: 35rpx;
width: 40rpx;
height: 40rpx;
&_img {
width: 23rpx;
height: 23rpx;
}
}
&_scroll {
width: 100%;
margin-top: 62rpx;
&_main {
padding-top: 10rpx;
&_item {
display: flex;
flex-direction: column;
align-items: center;
margin-right: 23.1rpx;
&_out {
display: flex;
align-items: center;
justify-content: center;
width: 98rpx;
height: 98rpx;
border-radius: 50%;
}
&_in {
width: 74rpx;
height: 74rpx;
border-radius: 80%;
}
&_name {
margin-top: 8rpx;
color: #333333;
font-size: 22rpx;
}
}
}
}
&_box {
display: flex;
align-items: center;
width: 690rpx;
height: 102rpx;
background-color: #F9F9FA;
margin-top: 60rpx;
border-radius: 24rpx;
&_input {
color: #333333;
font-size: 28rpx;
margin-left: 30rpx;
width: 630rpx;
border-radius: 24rpx;
}
&_placeholder {
color: #B3BABE;
font-size: 28rpx
}
}
&_button {
border-radius: 14rpx;
background-color: #FF3A3A;
margin: 130rpx 0 52rpx 0;
color: #FFFFFF;
font-size: 30rpx;
width: 690rpx;
height: 98rpx;
line-height: 98rpx;
}
}
</style>