aboutBalls.vue
6.6 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
<template>
<view class="about_balls">
<!-- 选项卡片 -->
<view class="select_card">
<view class="title">运动项目</view>
<view class="ball_list">
<view class="ball_item" v-for="(item, index) in imageList" :key="index" @click="ballActive = index">
<image class="ball_icon" v-show="ballActive !== index" :src="item.activeIcon" mode="widthFix"></image>
<image class="ball_icon" v-show="ballActive === index" :src="item.icon" mode="widthFix"></image>
<text :class="{ ballname: ballActive === index }">{{ item.title }}</text>
</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="#FFA100" :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 badminton from '@/static/images/sport/badminton.png'
import badminton1 from '@/static/images/sport/badminton-1.png'
import basketball from '@/static/images/sport/basketball.png'
import basketball1 from '@/static/images/sport/basketball-1.png'
import football from '@/static/images/sport/football.png'
import football1 from '@/static/images/sport/football-1.png'
import frisbee from '@/static/images/sport/frisbee.png'
import frisbee1 from '@/static/images/sport/frisbee-1.png'
import tableTennis from '@/static/images/sport/table-tennis.png'
import tableTennis1 from '@/static/images/sport/table-tennis-1.png'
import tennis from '@/static/images/sport/tennis.png'
import tennis1 from '@/static/images/sport/tennis-1.png'
import MyButton from '@/components/myButton.vue'
export default {
components: { MyButton },
data() {
return {
ballActive: 0, // 动态球类索引
show: false, // 显示场馆列表
showDate: false, // 时间选择列表
dateValue: '', // 选择的时间值
startTime: '开始时间', // 开始时间
endTime: '结束时间', // 结束时间
timeMode: '', // 时间状态
arenaName: '',
columns: [
['彩虹体育馆', '飞人网球场', 'L2T体育馆']
],
// 球类列表
imageList: [
{ title: '羽毛球', icon: badminton, activeIcon: badminton1 },
{ title: '足球', icon: football, activeIcon: football1 },
{ title: '网球', icon: tennis, activeIcon: tennis1 },
{ title: '飞盘', icon: frisbee, activeIcon: frisbee1 },
{ title: '篮球', icon: basketball, activeIcon: basketball1 },
{ title: '乒乓球', icon: tableTennis, activeIcon: tableTennis1 }
]
}
},
onReady() {
// 微信小程序需要用此写法
this.$refs.datetimePicker.setFormatter(this.formatter)
},
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
},
// 前往订单详情
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: #FFA100;
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;
justify-content: space-around;
margin: 34rpx 0;
.ball_item{
display: flex;
flex-direction: column;
align-items: center;
font-size: 24rpx;
color: #999;
line-height: 28rpx;
.ballname{
color: #FFA100;
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;
height: 112rpx;
width: 100%;
box-sizing: border-box;
bottom: 0;
left: 0;
background-color: #fff;
padding: 16rpx 30rpx;
}
}
</style>