home.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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. import {
  71. myRequest
  72. } from "../../util/api.js"
  73. onLoad(() => {
  74. wxcode.value = uni.getStorageSync('wxcode')
  75. alert(wxcode.value)
  76. getUserInfo()
  77. })
  78. const wxcode = ref('')
  79. const currentIndex1 = ref(null)
  80. const currentIndex2 = ref(null)
  81. const currentTime = ref(null)
  82. const currentBus = ref(null)
  83. // 发车时间列表
  84. const timeList = ref([
  85. '2023-10-10 15:15:15', '2023-10-10 16:15:15', '2023-10-10 18:15:15'
  86. ])
  87. // 发车车辆列表
  88. const busList = ref(['车牌尾号:6601(63/63)', '车牌尾号:6661(63/63)', '车牌尾号:6001(63/63)'])
  89. // const busList = ref([])
  90. const getUserInfo = async () => {
  91. const res = await myRequest({
  92. url: '/carBook/useropenid.action',
  93. method: 'post',
  94. data: {
  95. wxcode: wxcode.value
  96. }
  97. })
  98. alert(JSON.stringify(res))
  99. console.log(res);
  100. }
  101. // 改变选中项回调
  102. const handleChangeCurrentIndex = (index, type, value) => {
  103. if (type === 1) {
  104. currentIndex1.value = index
  105. currentTime.value = value
  106. } else {
  107. currentIndex2.value = index
  108. currentBus.value = value
  109. }
  110. }
  111. // 立即预约按钮回调
  112. const handleSub = () => {
  113. if (!currentTime.value) {
  114. uni.showToast({
  115. title: '请先选择发车时间',
  116. icon: "none"
  117. })
  118. return
  119. }
  120. if (!currentBus.value) {
  121. uni.showToast({
  122. title: '请先选择预约车辆',
  123. icon: "none"
  124. })
  125. return
  126. }
  127. uni.showModal({
  128. title: '提示',
  129. content: '确定预约吗?',
  130. success: (res) => {
  131. if (res.confirm) {
  132. console.log(123);
  133. } else if (res.cancel) {
  134. }
  135. }
  136. });
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .container {
  141. padding: 0 30rpx;
  142. .time {
  143. .time-title {
  144. height: 128rpx;
  145. line-height: 128rpx;
  146. font-size: 30rpx;
  147. font-weight: bold;
  148. span {
  149. font-size: 24rpx;
  150. font-weight: 400;
  151. color: #B3B3B3;
  152. }
  153. }
  154. .time-list {
  155. display: grid;
  156. grid-template-columns: 1fr 1fr;
  157. grid-auto-rows: 100rpx;
  158. grid-gap: 30rpx 20rpx;
  159. .time-list-item {
  160. display: flex;
  161. justify-content: center;
  162. align-items: center;
  163. font-size: 26rpx;
  164. border: 1rpx solid #CCCCCC;
  165. border-radius: 12rpx;
  166. }
  167. .active {
  168. display: flex;
  169. justify-content: center;
  170. align-items: center;
  171. font-size: 26rpx;
  172. border: 1rpx solid #CCCCCC;
  173. border-radius: 12rpx;
  174. color: #fff;
  175. background-image: linear-gradient(#8684FF, #3D50E7);
  176. }
  177. .disable {
  178. background: #E6E6E6;
  179. }
  180. }
  181. }
  182. .bus {
  183. .bus-title {
  184. height: 128rpx;
  185. line-height: 128rpx;
  186. font-size: 30rpx;
  187. font-weight: bold;
  188. span {
  189. font-size: 24rpx;
  190. font-weight: 400;
  191. }
  192. }
  193. .bus-list {
  194. display: flex;
  195. flex-direction: column;
  196. .bus-list-item {
  197. display: flex;
  198. justify-content: center;
  199. align-items: center;
  200. margin-bottom: 30rpx;
  201. height: 100rpx;
  202. font-size: 26rpx;
  203. border: 1rpx solid #CCCCCC;
  204. border-radius: 12rpx;
  205. }
  206. .active {
  207. display: flex;
  208. justify-content: center;
  209. align-items: center;
  210. margin-bottom: 30rpx;
  211. height: 100rpx;
  212. font-size: 26rpx;
  213. border: 1rpx solid #CCCCCC;
  214. border-radius: 12rpx;
  215. color: #fff;
  216. background-image: linear-gradient(#8684FF, #3D50E7);
  217. }
  218. .disable {
  219. background: #E6E6E6;
  220. }
  221. }
  222. .bus-list-nodata {
  223. display: flex;
  224. flex-direction: column;
  225. align-items: center;
  226. color: #B3B3B3;
  227. .nodata-img {
  228. position: relative;
  229. width: 500rpx;
  230. height: 500rpx;
  231. img {
  232. width: 100%;
  233. height: 100%;
  234. }
  235. .nodata-info {
  236. position: absolute;
  237. left: 250rpx;
  238. bottom: 50rpx;
  239. transform: translateX(-50%);
  240. white-space: nowrap;
  241. }
  242. }
  243. }
  244. }
  245. .btn {
  246. position: relative;
  247. display: flex;
  248. margin-top: 50rpx;
  249. padding: 24rpx 30rpx;
  250. box-sizing: border-box;
  251. height: 115rpx;
  252. border-radius: 15rpx;
  253. box-shadow: 0px 0px 12rpx rgba(0, 0, 0, .12);
  254. .btn-clock {
  255. width: 61rpx;
  256. height: 61rpx;
  257. img {
  258. width: 100%;
  259. }
  260. }
  261. .btn-info {
  262. margin-left: 18rpx;
  263. flex: 1;
  264. display: flex;
  265. flex-direction: column;
  266. justify-content: center;
  267. .btn-info-title {
  268. font-size: 28rpx;
  269. color: #5863F1;
  270. }
  271. .btn-info-time {
  272. font-size: 24rpx;
  273. color: #B3B3B3;
  274. }
  275. }
  276. .btn-button {
  277. position: absolute;
  278. right: 0;
  279. top: -7rpx;
  280. width: 257rpx;
  281. height: 130rpx;
  282. line-height: 130rpx;
  283. text-align: center;
  284. font-size: 30rpx;
  285. color: #fff;
  286. background: url(../../static/box.png);
  287. background-size: 100% 100%;
  288. }
  289. }
  290. .info {
  291. margin: 40rpx 0;
  292. .info-title {
  293. height: 41rpx;
  294. font-size: 28rpx;
  295. }
  296. .info-detail {
  297. margin-top: 5rpx;
  298. height: 70rpx;
  299. color: #B3B3B3;
  300. font-size: 24rpx;
  301. }
  302. }
  303. }
  304. </style>