home.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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">{{item.ci_time}}</view>
  40. <view class="top_info">
  41. <view class="info_box">{{getRouteParts(item.route_end).prefix}}</view>
  42. <view class="info_box top">{{getRouteParts(item.route_end).suffix}}</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. const getRouteParts = (str) => {
  102. if (str && typeof str === 'string') {
  103. const parts = str.split('→');
  104. return {
  105. prefix: parts[0] || '', // 箭头前的文字
  106. suffix: parts[1] || '' // 箭头后的文字
  107. };
  108. }
  109. return { prefix: '', suffix: '' };
  110. };
  111. // 获取预约时间段数据
  112. async function getOrderConfig() {
  113. const res = await myRequest({
  114. url: '/appqueryConfig.action'
  115. })
  116. // console.log(res)
  117. yy_end.value = res.data.data.yy_end || 0
  118. }
  119. // 根据路线查询所有车次
  120. async function getBusList(route) {
  121. const res = await myRequest({
  122. url: '/tAppqueryCarNums.action',
  123. data: {
  124. date: currentTime.value,
  125. route: route || currentPath.value,
  126. mobile: userInfo.mobile
  127. }
  128. })
  129. // console.log(res)
  130. busList.value = res.data.data || []
  131. }
  132. // 获取所有的发车路线
  133. async function getPathList() {
  134. const res = await myRequest({
  135. url: '/appqueryRoute.action'
  136. })
  137. // console.log(res)
  138. pathList.value = res.data.data || []
  139. if (pathList.value.length) {
  140. currentPath.value = pathList.value[0]?.route
  141. getBusList(currentPath.value)
  142. }
  143. }
  144. onMounted(() => {
  145. const bus_date = uni.getStorageSync('bus_date')
  146. if (bus_date) {
  147. currentTime.value = bus_date
  148. } else {
  149. currentTime.value = dayjs(Date.now()).format('YYYY-MM-DD')
  150. }
  151. paddingTop.value = uni.getMenuButtonBoundingClientRect().top
  152. getOrderConfig()
  153. getPathList()
  154. })
  155. onLoad(() => {
  156. // uni.removeStorageSync('bus_date')
  157. })
  158. // 选择路线回调
  159. function handleChangeCurrentIndex(index, item) {
  160. currentIndex.value = index
  161. currentPath.value = item.route
  162. getBusList(currentPath.value)
  163. }
  164. // 点击跳转选择日期
  165. function chooseDate() {
  166. uni.navigateTo({
  167. url: '/pages/date/date'
  168. })
  169. }
  170. // 点击每一个车辆的回调
  171. function handleClickItem(item) {
  172. const info = encodeURIComponent(JSON.stringify(item),'l')
  173. uni.navigateTo({
  174. url: `/pages/chooseCar/chooseCar?info=${info}`
  175. })
  176. }
  177. // 点击拨打电话回调
  178. function handlePhone(phoneNumber) {
  179. uni.makePhoneCall({
  180. phoneNumber
  181. })
  182. }
  183. const handleClose = () => {
  184. show.value = false
  185. }
  186. </script>
  187. <style lang="scss" scoped>
  188. .container {
  189. position: relative;
  190. height: 100%;
  191. .banner {
  192. width: 100%;
  193. height: 680rpx;
  194. }
  195. .title {
  196. position: absolute;
  197. left: 314rpx;
  198. font-size: 40rpx;
  199. color: #001713;
  200. }
  201. .people {
  202. position: absolute;
  203. top: 274rpx;
  204. right: 18rpx;
  205. width: 234rpx;
  206. height: 298rpx;
  207. }
  208. .path {
  209. display: flex;
  210. margin: -266rpx auto 0;
  211. width: 706rpx;
  212. height: 410rpx;
  213. background: url(@/static/images/home/box.png);
  214. background-size: 100% 100%;
  215. .path_box {
  216. margin-top: 48rpx;
  217. margin-left: 50rpx;
  218. color: #707070;
  219. font-size: 24rpx;
  220. .box_time {
  221. display: flex;
  222. align-items: center;
  223. margin-top: 12rpx;
  224. margin-bottom: 14rpx;
  225. height: 64rpx;
  226. color: #001713;
  227. font-size: 28rpx;
  228. font-weight: bold;
  229. border-bottom: 2rpx solid #ebecf1;
  230. .time {
  231. margin: 0 56rpx 0 10rpx;
  232. }
  233. .novalue {
  234. color: #707070;
  235. }
  236. }
  237. .box_line {
  238. display: flex;
  239. align-items: center;
  240. height: 76rpx;
  241. font-size: 28rpx;
  242. }
  243. .active {
  244. color: #001713;
  245. font-weight: bold;
  246. transform: scale(1.08);
  247. }
  248. }
  249. }
  250. .car {
  251. margin: auto;
  252. width: 700rpx;
  253. color: #001713;
  254. font-size: 24rpx;
  255. .car_list {
  256. margin-top: 20rpx;
  257. .car_box {
  258. box-sizing: border-box;
  259. padding: 34rpx 34rpx 0;
  260. margin-bottom: 20rpx;
  261. width: 100%;
  262. height: 222rpx;
  263. background: url(@/static/images/home/car-box.png);
  264. background-size: 100% 100%;
  265. .box_top {
  266. display: flex;
  267. align-items: center;
  268. height: 110rpx;
  269. .top_time {
  270. margin-top: -30rpx;
  271. margin-right: 76rpx;
  272. font-size: 44rpx;
  273. }
  274. .top_info {
  275. height: 100%;
  276. font-size: 28rpx;
  277. .info_box {
  278. width: 320rpx;
  279. overflow: hidden;
  280. text-overflow: ellipsis;
  281. white-space: nowrap;
  282. }
  283. .top {
  284. margin-top: 14rpx;
  285. }
  286. }
  287. .top_msg {
  288. // margin-left: 8rpx;
  289. height: 100%;
  290. color: #f86818;
  291. .msg_price {
  292. margin-top: -15rpx;
  293. font-size: 28rpx;
  294. .text {
  295. font-size: 48rpx;
  296. }
  297. }
  298. .msg_num {
  299. margin-top: 8rpx;
  300. }
  301. }
  302. }
  303. .box_bottom {
  304. display: flex;
  305. align-items: center;
  306. height: 58rpx;
  307. color: #f86818;
  308. .bottom_box {
  309. margin-right: 65rpx;
  310. }
  311. }
  312. }
  313. }
  314. }
  315. .box_info {
  316. padding: 30rpx 30rpx 40rpx;
  317. .info_title {
  318. height: 41rpx;
  319. font-size: 28rpx;
  320. color: #666666;
  321. }
  322. .info_detail {
  323. margin-top: 5rpx;
  324. color: #999999;
  325. font-size: 24rpx;
  326. }
  327. }
  328. }
  329. </style>