home.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <view class="container">
  3. <image class="banner" src="@/static/images/home/banner.png" mode="aspectFill" />
  4. <view class="title" :style="{ top: `${paddingTop * 2}rpx` }">校车预约</view>
  5. <image class="people" src="@/static/images/home/people.png" mode="aspectFill" />
  6. <!-- 选择时间路线区域 -->
  7. <view class="path">
  8. <view class="path_box">
  9. <view>选择日期</view>
  10. <view class="box_time" @click="chooseDate">
  11. <wd-icon name="warning" color="#707070" size="10" />
  12. <view class="time" :class="currentTime ? '' : 'novalue'">
  13. <!-- 2025-8月-14日 星期五 -->
  14. {{ currentTime ? currentTime : '请选择日期' }}
  15. </view>
  16. <wd-icon name="calendar" color="#707070" size="26" />
  17. </view>
  18. <view>选择路线</view>
  19. <view
  20. v-for="(item, index) in pathList"
  21. :key="index"
  22. class="box_line"
  23. :class="currentIndex === index ? 'active' : ''"
  24. @click="handleChangeCurrentIndex(index, item)"
  25. >
  26. <image v-if="index % 2 === 1" style="width: 28rpx; height: 28rpx; margin-right: 20rpx" src="@/static/images/home/address.png" mode="aspectFill" />
  27. <image v-else style="width: 28rpx; height: 28rpx; margin-right: 20rpx" src="@/static/images/home/address2.png" mode="aspectFill" />
  28. {{ item.route }}
  29. </view>
  30. </view>
  31. </view>
  32. <!-- 选择车辆区域 -->
  33. <view class="car">
  34. 选择车辆
  35. <view class="car_list">
  36. <!-- 每一个车辆区域 -->
  37. <view v-for="(item, index) in busList" :key="index" class="car_box" @click="handleClickItem(item)">
  38. <view class="box_top">
  39. <view class="top_time">14:50</view>
  40. <view class="top_info">
  41. <view class="info_box">南昌交通学院墨轩湖校区</view>
  42. <view class="info_box top">南昌火车站</view>
  43. </view>
  44. <view class="top_msg">
  45. <view class="msg_price">
  46. ¥
  47. <text class="text">{{ item.price }}</text>
  48. </view>
  49. <view class="msg_num">剩余{{ item.contain - item.boarde_num }}座</view>
  50. </view>
  51. </view>
  52. <view class="box_bottom">
  53. <view class="bottom_box">6点30分起售</view>
  54. <view class="bottom_box">车牌:{{ item.car_number }}</view>
  55. <view class="bottom_box">容量:{{ item.contain }}座</view>
  56. </view>
  57. </view>
  58. </view>
  59. <view v-if="!busList.length">
  60. <wd-status-tip image="content" tip="暂无数据" />
  61. </view>
  62. </view>
  63. <!-- 温馨提示区域 -->
  64. <view class="box_info">
  65. <view class="info_title">温馨提示</view>
  66. <view class="info_detail">
  67. 预约截止时间为发车前{{ yy_end }}分钟,车队长联系方式:
  68. <span @click="handlePhone('13576937506')">13576937506</span>
  69. ,技术支持联系方式:
  70. <span @click="handlePhone(`0791 - 82293574`)">0791-82293574</span>
  71. ,候补功能仅当日开放。
  72. </view>
  73. </view>
  74. </view>
  75. <!-- 授权手机号 -->
  76. <AuthorizePopup :show="show" @close="handleClose" />
  77. </template>
  78. <script setup>
  79. import { onLoad } from '@dcloudio/uni-app'
  80. import { onMounted, ref } from 'vue'
  81. import { myRequest } from '@/utils/api.ts'
  82. import dayjs from 'dayjs'
  83. const show = ref(false)
  84. // 胶囊按钮距离页面顶部的距离
  85. const paddingTop = ref(0)
  86. // 用户信息
  87. const userInfo = uni.getStorageSync('carUserInfo')
  88. // 当前日期
  89. const currentTime = ref('')
  90. // 发车路线列表
  91. const pathList = ref([])
  92. // 当前发车路线
  93. const currentPath = ref(null)
  94. // 当前路线
  95. const currentIndex = ref(0)
  96. // 发车车辆列表
  97. const busList = ref([])
  98. // 预约截止时间
  99. const yy_end = ref(0)
  100. // 获取预约时间段数据
  101. async function getOrderConfig() {
  102. const res = await myRequest({
  103. url: '/appqueryConfig.action'
  104. })
  105. // console.log(res)
  106. yy_end.value = res.data.data.yy_end || 0
  107. }
  108. // 根据路线查询所有车次
  109. async function getBusList(route) {
  110. const res = await myRequest({
  111. url: '/tAppqueryCarNums.action',
  112. data: {
  113. date: currentTime.value,
  114. route: route || currentPath.value,
  115. mobile: userInfo?.phone || ''
  116. }
  117. })
  118. // console.log(res)
  119. busList.value = res.data.data || []
  120. }
  121. // 获取所有的发车路线
  122. async function getPathList() {
  123. const res = await myRequest({
  124. url: '/appqueryRoute.action'
  125. })
  126. // console.log(res)
  127. pathList.value = res.data.data || []
  128. if (pathList.value.length) {
  129. currentPath.value = pathList.value[0]?.route
  130. getBusList(currentPath.value)
  131. }
  132. }
  133. onMounted(() => {
  134. const bus_date = uni.getStorageSync('bus_date')
  135. if (bus_date) {
  136. currentTime.value = bus_date
  137. } else {
  138. currentTime.value = dayjs(Date.now()).format('YYYY-MM-DD')
  139. }
  140. paddingTop.value = uni.getMenuButtonBoundingClientRect().top
  141. getOrderConfig()
  142. getPathList()
  143. })
  144. onLoad(() => {
  145. // uni.removeStorageSync('bus_date')
  146. })
  147. // 选择路线回调
  148. function handleChangeCurrentIndex(index, item) {
  149. currentIndex.value = index
  150. currentPath.value = item.route
  151. getBusList(currentPath.value)
  152. }
  153. // 点击跳转选择日期
  154. function chooseDate() {
  155. uni.navigateTo({
  156. url: '/pages/date/date'
  157. })
  158. }
  159. // 点击每一个车辆的回调
  160. function handleClickItem(item) {
  161. const info = encodeURIComponent(JSON.stringify(item))
  162. uni.navigateTo({
  163. url: `/pages/chooseCar/chooseCar?info=${info}`
  164. })
  165. }
  166. // 点击拨打电话回调
  167. function handlePhone(phoneNumber) {
  168. uni.makePhoneCall({
  169. phoneNumber
  170. })
  171. }
  172. const handleClose = () => {
  173. show.value = false
  174. }
  175. </script>
  176. <style lang="scss" scoped>
  177. .container {
  178. position: relative;
  179. height: 100%;
  180. .banner {
  181. width: 100%;
  182. height: 680rpx;
  183. }
  184. .title {
  185. position: absolute;
  186. left: 314rpx;
  187. font-size: 40rpx;
  188. color: #001713;
  189. }
  190. .people {
  191. position: absolute;
  192. top: 274rpx;
  193. right: 18rpx;
  194. width: 234rpx;
  195. height: 298rpx;
  196. }
  197. .path {
  198. display: flex;
  199. margin: -266rpx auto 0;
  200. width: 706rpx;
  201. height: 410rpx;
  202. background: url(@/static/images/home/box.png);
  203. background-size: 100% 100%;
  204. .path_box {
  205. margin-top: 48rpx;
  206. margin-left: 50rpx;
  207. color: #707070;
  208. font-size: 24rpx;
  209. .box_time {
  210. display: flex;
  211. align-items: center;
  212. margin-top: 12rpx;
  213. margin-bottom: 14rpx;
  214. height: 64rpx;
  215. color: #001713;
  216. font-size: 28rpx;
  217. font-weight: bold;
  218. border-bottom: 2rpx solid #ebecf1;
  219. .time {
  220. margin: 0 56rpx 0 10rpx;
  221. }
  222. .novalue {
  223. color: #707070;
  224. }
  225. }
  226. .box_line {
  227. display: flex;
  228. align-items: center;
  229. height: 76rpx;
  230. font-size: 28rpx;
  231. }
  232. .active {
  233. color: #001713;
  234. font-weight: bold;
  235. transform: scale(1.08);
  236. }
  237. }
  238. }
  239. .car {
  240. margin: auto;
  241. width: 700rpx;
  242. color: #001713;
  243. font-size: 24rpx;
  244. .car_list {
  245. margin-top: 20rpx;
  246. .car_box {
  247. box-sizing: border-box;
  248. padding: 34rpx 34rpx 0;
  249. margin-bottom: 20rpx;
  250. width: 100%;
  251. height: 222rpx;
  252. background: url(@/static/images/home/car-box.png);
  253. background-size: 100% 100%;
  254. .box_top {
  255. display: flex;
  256. align-items: center;
  257. height: 110rpx;
  258. .top_time {
  259. margin-top: -30rpx;
  260. margin-right: 76rpx;
  261. font-size: 44rpx;
  262. }
  263. .top_info {
  264. height: 100%;
  265. font-size: 28rpx;
  266. .info_box {
  267. width: 320rpx;
  268. overflow: hidden;
  269. text-overflow: ellipsis;
  270. white-space: nowrap;
  271. }
  272. .top {
  273. margin-top: 14rpx;
  274. }
  275. }
  276. .top_msg {
  277. margin-left: 8rpx;
  278. height: 100%;
  279. color: #f86818;
  280. .msg_price {
  281. margin-top: -15rpx;
  282. font-size: 28rpx;
  283. .text {
  284. font-size: 48rpx;
  285. }
  286. }
  287. .msg_num {
  288. margin-top: 8rpx;
  289. }
  290. }
  291. }
  292. .box_bottom {
  293. display: flex;
  294. align-items: center;
  295. height: 58rpx;
  296. color: #f86818;
  297. .bottom_box {
  298. margin-right: 65rpx;
  299. }
  300. }
  301. }
  302. }
  303. }
  304. .box_info {
  305. padding: 30rpx 30rpx 40rpx;
  306. .info_title {
  307. height: 41rpx;
  308. font-size: 28rpx;
  309. color: #666666;
  310. }
  311. .info_detail {
  312. margin-top: 5rpx;
  313. color: #999999;
  314. font-size: 24rpx;
  315. }
  316. }
  317. }
  318. </style>