aboutBalls.vue
7.0 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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<template>
<view class="about_balls">
<!-- 选项卡片 -->
<view class="select_card">
<view class="title">运动项目</view>
<view style="width: 100%;overflow-x: scroll;">
<view class="ball_list" :style="{transform: `translateX(${transformWidth}rpx)`}" @touchmove="transformWidth = 0">
<view class="ball_item" v-for="(item, index) in imageList" :key="index" @click="ballToggle(index)">
<view
class="iconfont item_icon"
:class="[item.iconName]"
:style="{color: ballActive == index ? ThemeColor.PrimaryColor : '#999'}"
></view>
<text :class="{ ballname: ballActive === index }">{{ item.title }}</text>
</view>
</view>
</view>
<view class="title">选择场馆</view>
<!-- 选择场馆 -->
<view class="select_arena" @click="show = true">
<text>{{ arenaName }}</text>
<u-icon name="arrow-right" color="#999"></u-icon>
</view>
<view class="title">项目时间</view>
<!-- 时间范围 -->
<view class="time_list">
<view class="startTime" @click="selectTime('start')">{{ startTime }}</view>
<view class="line"></view>
<view class="endTime" @click="selectTime('end')">{{ endTime }}</view>
</view>
</view>
<!-- 运动人数 -->
<view class="sport_number">
<view class="title">运动人数</view>
<text>8 人</text>
</view>
<!-- 去人约球 -->
<view class="footer">
<MyButton title="发起约球" @comfirn="goRouter" />
</view>
<!-- 场馆选择 -->
<u-picker :show="show" title="选择场馆" :confirmColor="ThemeColor.PrimaryColor" :columns="columns" :closeOnClickOverlay="true" @cancel="show = false" @close="show = false" @confirm="confirm"></u-picker>
<!-- 时间选择 -->
<u-datetime-picker
ref="datetimePicker"
:show="showDate"
v-model="dateValue"
title="选择约球时间"
mode="datetime"
:formatter="formatter"
@cancel="showDate = false"
@confirm="confirmTime"
/>
</view>
</template>
<script>
import MyButton from '@/components/myButton.vue'
import ThemeColor from '@/utils/themeColor'
export default {
components: { MyButton },
data() {
return {
ThemeColor,
transformWidth: 0, // 移动的距离
totalWidth: 0, // 移动的总长度
bollListWidth: 0, // 导航盒子的宽度
ballActive: 0, // 动态球类索引
show: false, // 显示场馆列表
showDate: false, // 时间选择列表
dateValue: '', // 选择的时间值
startTime: '开始时间', // 开始时间
endTime: '结束时间', // 结束时间
timeMode: '', // 时间状态
arenaName: '请选择场馆',
columns: [
['彩虹体育馆', '飞人网球场', 'L2T体育馆']
],
// 球类列表
imageList: [
{ title: '羽毛球', iconName: 'icon-yumaoqiu1' },
{ title: '足球', iconName: 'icon-zuqiu' },
{ title: '篮球', iconName: 'icon-lanqiu' },
{ title: '排球', iconName: 'icon-paiqiu' },
{ title: '乒乓球', iconName: 'icon-pingpangqiu' },
{ title: '网球', iconName: 'icon-wangqiu1' },
{ title: '排球', iconName: 'icon-paiqiu' },
{ title: '台球', iconName: 'icon-taiqiu' },
{ title: '高尔夫球', iconName: 'icon-gaoerfu2' },
{ title: '棒球', iconName: 'icon-bangqiu' }
]
}
},
onReady() {
// 微信小程序需要用此写法
this.$refs.datetimePicker.setFormatter(this.formatter)
},
mounted() {
let _this = this
this.totalWidth = this.imageList.length * 100
const query = uni.createSelectorQuery().in(this);
query.select(".ball_list").boundingClientRect(res => {
_this.bollListWidth = res.width * 2
}).exec();
},
methods: {
// 确认选择场馆
confirm({value}){
this.show = false
this.arenaName = value
},
// 时间过滤器
formatter(type, value) {
let timeObj = {
year: `${value}年`,
month: `${value}月`,
day: `${value}日`,
hour: `${value}时`,
minute: `${value}分`,
}
return timeObj[type]
},
// 选择时间
selectTime(value){
this.timeMode = value
this.showDate = true
},
// 选择时间的值
confirmTime({value}){
if(this.timeMode === 'start') {
this.startTime = uni.$u.timeFormat(value, 'yyyy-mm-dd hh:MM')
} else {
this.endTime = uni.$u.timeFormat(value, 'yyyy-mm-dd hh:MM')
}
this.showDate = false
},
// 切换球类
ballToggle(index){
this.ballActive = index
if(index < 3) {
this.transformWidth = 0
} else {
let moveWidth = (index - 2) * 100
let maxMove = this.totalWidth - this.bollListWidth
this.transformWidth = moveWidth > maxMove ? - maxMove : - moveWidth
}
},
// 前往订单详情
goRouter(){
uni.navigateTo({
url: '/pages/comfirmOrder/comfirmOrder'
})
}
}
}
</script>
<style lang="scss" scoped>
.title{
position: relative;
font-weight: 500;
font-size: 28rpx;
line-height: 36rpx;
color: #333;
margin-left: 20rpx;
&::before{
content: '';
position: absolute;
left: -20rpx;
top: 50%;
transform: translateY(-50%);
width: 8rpx;
height: 8rpx;
background-color: $uni-color-primary;
border-radius: 50%;
}
}
.about_balls{
padding: 24rpx 30rpx 0;
background-color: #F6F6F6;
min-height: 100vh;
box-sizing: border-box;
.select_card{
height: 548rpx;
background: #FFFFFF;
box-sizing: border-box;
padding: 24rpx;
border-radius: 12rpx 12rpx 12rpx 12rpx;
.ball_list{
display: flex;
align-items: center;
margin: 34rpx 0;
width: 100%;
transition: all 0.5s linear;
.ball_item{
display: flex;
flex-direction: column;
align-items: center;
gap: 10rpx;
font-size: 24rpx;
flex-shrink: 0;
width: 100rpx;
color: #999;
line-height: 28rpx;
.item_icon{
font-size: 38rpx;
transition: all 0.5s ease;
}
.ballname{
color: $uni-color-primary;
font-weight: 500;
}
.ball_icon{
width: 48rpx;
height: 48rpx;
margin-bottom: 16rpx;
}
}
}
// 选择场馆
.select_arena{
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 32rpx;
height: 68rpx;
background: #F6F6F6;
border-radius: 68rpx;
color: #333;
font-size: 24rpx;
margin: 24rpx 0 36rpx 0;
}
// 选择时间
.time_list {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 22rpx;
.startTime, .endTime{
width: 256rpx;
height: 56rpx;
background: #F6F6F6;
border-radius: 68rpx;
font-size: 24rpx;
color: #333;
text-align: center;
line-height: 56rpx;
}
.line{
width: 44rpx;
height: 0rpx;
border: 2rpx solid rgba(225,225,225,0.7);
}
}
}
// 人数
.sport_number{
display: flex;
align-items: center;
justify-content: space-between;
padding: 24rpx;
height: 88rpx;
box-sizing: border-box;
background: #FFFFFF;
border-radius: 12rpx 12rpx 12rpx 12rpx;
margin-top: 24rpx;
}
// 确认约球
.footer{
position: fixed;
width: 100%;
box-sizing: border-box;
bottom: env(safe-area-inset-bottom);
left: 0;
padding: 0 30rpx;
}
}
</style>