home.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <view class="container">
  3. <!-- 选择发车时间区域 -->
  4. <view class="time">
  5. <view class="time-title">
  6. 选择发车时间 <span>/ 开启校车之旅</span>
  7. </view>
  8. <view class="time-list">
  9. <view :class="currentIndex1 === index?'active':'time-list-item'" v-for="(item,index) in timeList"
  10. :key="index" @click="handleChangeCurrentIndex(index,1,item)">
  11. {{item}}
  12. </view>
  13. </view>
  14. </view>
  15. <!-- 选择预约车辆区域 -->
  16. <view class="bus">
  17. <view class="bus-title">
  18. 选择预约车辆 <span>/ 墨轩湖 - 综合楼</span>
  19. </view>
  20. <view class="bus-list" v-if="busList.length">
  21. <view :class="currentIndex2 === index?'active':'bus-list-item'" v-for="(item,index) in busList"
  22. :key="index" @click="handleChangeCurrentIndex(index,2,item)">
  23. {{item}}
  24. </view>
  25. </view>
  26. <view class="bus-list-nodata" v-else>
  27. <view class="nodata-img">
  28. <img src="../../static/no-bus.png" alt="">
  29. <view class="nodata-info">
  30. 请先选择发车时间
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <!-- 立即预约按钮区域 -->
  36. <view class="btn">
  37. <view class="btn-clock">
  38. <img src="../../static/clock.png">
  39. </view>
  40. <view class="btn-info">
  41. <view class="btn-info-title">
  42. 预约截止时间
  43. </view>
  44. <view class="btn-info-time">
  45. 2023-10-03 15:15:15
  46. </view>
  47. </view>
  48. <view class="btn-button" @click="handleSub">
  49. 立即预约
  50. </view>
  51. </view>
  52. <!-- 预约截止时间区域 -->
  53. <view class="info">
  54. <view class="info-title">
  55. 预约说明
  56. </view>
  57. <view class="info-detail">
  58. 预约成功后请提前5分钟到校车地点,若迟到需重新排队或预约;如有疑问请联系后勤。后勤电话:13689545487
  59. </view>
  60. </view>
  61. </view>
  62. </template>
  63. <script setup>
  64. import {
  65. ref
  66. } from "vue"
  67. import {
  68. onLoad
  69. } from "@dcloudio/uni-app"
  70. onLoad(() => {
  71. })
  72. const currentIndex1 = ref(null)
  73. const currentIndex2 = ref(null)
  74. const currentTime = ref(null)
  75. const currentBus = ref(null)
  76. // 发车时间列表
  77. const timeList = ref([
  78. '2023-10-10 15:15:15', '2023-10-10 16:15:15', '2023-10-10 18:15:15'
  79. ])
  80. // 发车车辆列表
  81. const busList = ref(['车牌尾号:6601(63/63)', '车牌尾号:6661(63/63)', '车牌尾号:6001(63/63)'])
  82. // const busList = ref([])
  83. // 改变选中项回调
  84. const handleChangeCurrentIndex = (index, type, value) => {
  85. if (type === 1) {
  86. currentIndex1.value = index
  87. currentTime.value = value
  88. } else {
  89. currentIndex2.value = index
  90. currentBus.value = value
  91. }
  92. }
  93. // 立即预约按钮回调
  94. const handleSub = () => {
  95. if (!currentTime.value) {
  96. uni.showToast({
  97. title: '请先选择发车时间',
  98. icon: "none"
  99. })
  100. return
  101. }
  102. if (!currentBus.value) {
  103. uni.showToast({
  104. title: '请先选择预约车辆',
  105. icon: "none"
  106. })
  107. return
  108. }
  109. uni.showModal({
  110. title: '提示',
  111. content: '确定预约吗?',
  112. success: (res) => {
  113. if (res.confirm) {
  114. console.log(123);
  115. } else if (res.cancel) {
  116. }
  117. }
  118. });
  119. }
  120. </script>
  121. <style lang="scss" scoped>
  122. .container {
  123. padding: 0 30rpx;
  124. .time {
  125. .time-title {
  126. height: 128rpx;
  127. line-height: 128rpx;
  128. font-size: 30rpx;
  129. font-weight: bold;
  130. span {
  131. font-size: 24rpx;
  132. font-weight: 400;
  133. color: #B3B3B3;
  134. }
  135. }
  136. .time-list {
  137. display: grid;
  138. grid-template-columns: 1fr 1fr;
  139. grid-auto-rows: 100rpx;
  140. grid-gap: 30rpx 20rpx;
  141. .time-list-item {
  142. display: flex;
  143. justify-content: center;
  144. align-items: center;
  145. font-size: 26rpx;
  146. border: 1rpx solid #CCCCCC;
  147. border-radius: 12rpx;
  148. }
  149. .active {
  150. display: flex;
  151. justify-content: center;
  152. align-items: center;
  153. font-size: 26rpx;
  154. border: 1rpx solid #CCCCCC;
  155. border-radius: 12rpx;
  156. color: #fff;
  157. background-image: linear-gradient(#8684FF, #3D50E7);
  158. }
  159. .disable {
  160. background: #E6E6E6;
  161. }
  162. }
  163. }
  164. .bus {
  165. .bus-title {
  166. height: 128rpx;
  167. line-height: 128rpx;
  168. font-size: 30rpx;
  169. font-weight: bold;
  170. span {
  171. font-size: 24rpx;
  172. font-weight: 400;
  173. }
  174. }
  175. .bus-list {
  176. display: flex;
  177. flex-direction: column;
  178. .bus-list-item {
  179. display: flex;
  180. justify-content: center;
  181. align-items: center;
  182. margin-bottom: 30rpx;
  183. height: 100rpx;
  184. font-size: 26rpx;
  185. border: 1rpx solid #CCCCCC;
  186. border-radius: 12rpx;
  187. }
  188. .active {
  189. display: flex;
  190. justify-content: center;
  191. align-items: center;
  192. margin-bottom: 30rpx;
  193. height: 100rpx;
  194. font-size: 26rpx;
  195. border: 1rpx solid #CCCCCC;
  196. border-radius: 12rpx;
  197. color: #fff;
  198. background-image: linear-gradient(#8684FF, #3D50E7);
  199. }
  200. .disable {
  201. background: #E6E6E6;
  202. }
  203. }
  204. .bus-list-nodata {
  205. display: flex;
  206. flex-direction: column;
  207. align-items: center;
  208. color: #B3B3B3;
  209. .nodata-img {
  210. position: relative;
  211. width: 500rpx;
  212. height: 500rpx;
  213. img {
  214. width: 100%;
  215. height: 100%;
  216. }
  217. .nodata-info {
  218. position: absolute;
  219. left: 250rpx;
  220. bottom: 50rpx;
  221. transform: translateX(-50%);
  222. white-space: nowrap;
  223. }
  224. }
  225. }
  226. }
  227. .btn {
  228. position: relative;
  229. display: flex;
  230. margin-top: 50rpx;
  231. padding: 24rpx 30rpx;
  232. box-sizing: border-box;
  233. height: 115rpx;
  234. border-radius: 15rpx;
  235. box-shadow: 0px 0px 12rpx rgba(0, 0, 0, .12);
  236. .btn-clock {
  237. width: 61rpx;
  238. height: 61rpx;
  239. img {
  240. width: 100%;
  241. }
  242. }
  243. .btn-info {
  244. margin-left: 18rpx;
  245. flex: 1;
  246. display: flex;
  247. flex-direction: column;
  248. justify-content: center;
  249. .btn-info-title {
  250. font-size: 28rpx;
  251. color: #5863F1;
  252. }
  253. .btn-info-time {
  254. font-size: 24rpx;
  255. color: #B3B3B3;
  256. }
  257. }
  258. .btn-button {
  259. position: absolute;
  260. right: 0;
  261. top: -7rpx;
  262. width: 257rpx;
  263. height: 130rpx;
  264. line-height: 130rpx;
  265. text-align: center;
  266. font-size: 30rpx;
  267. color: #fff;
  268. background: url(../../static/box.png);
  269. background-size: 100% 100%;
  270. }
  271. }
  272. .info {
  273. margin: 40rpx 0;
  274. .info-title {
  275. height: 41rpx;
  276. font-size: 28rpx;
  277. }
  278. .info-detail {
  279. margin-top: 5rpx;
  280. height: 70rpx;
  281. color: #B3B3B3;
  282. font-size: 24rpx;
  283. }
  284. }
  285. }
  286. </style>