order.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <view class="container">
  3. <!-- 标题区域 -->
  4. <view class="title" :style="{ top: `${paddingTop * 2}rpx` }">我的出行</view>
  5. <wd-tabs v-model="tabIndex" auto-line-width custom-class="custom_class_tab" @click="handleChange">
  6. <block v-for="tab in tabs" :key="tab">
  7. <wd-tab :title="`${tab}`" :name="tab">
  8. <scroll-view scroll-y class="content" @scrolltolower="scrolltolower">
  9. <!-- 每一个订单区域 -->
  10. <view v-for="item in listData" :key="item.id" class="order_box">
  11. <view class="box_top">
  12. <view class="top_left">
  13. <image class="left_img" src="@/static/images/mine/riding.png" mode="aspectFill" />
  14. 墨轩出行
  15. </view>
  16. <view class="top_status red">待支付</view>
  17. </view>
  18. <view class="box_center">
  19. <image class="center_img" src="@/static/images/home/line.png" mode="aspectFill" />
  20. <view class="center_text">
  21. <view class="text_start">南昌交通学院墨轩湖校区</view>
  22. <view class="text_end">南昌火车站</view>
  23. </view>
  24. <view class="center_price">
  25. ¥
  26. <text class="text">{{ item.payAmount }}</text>
  27. </view>
  28. </view>
  29. <view class="box_bottom">
  30. <view class="bottom_time">出行时间:{{ item.ciDate }}</view>
  31. <view class="bottom_btns">
  32. <view class="btn_item" @click="handleDetail">查看详情</view>
  33. <view class="btn_item pay">立即支付</view>
  34. </view>
  35. </view>
  36. </view>
  37. <view v-if="!listData.length" style="padding-top: 100rpx">
  38. <wd-status-tip image="content" tip="暂无数据" />
  39. </view>
  40. </scroll-view>
  41. </wd-tab>
  42. </block>
  43. </wd-tabs>
  44. </view>
  45. </template>
  46. <script setup>
  47. import { onMounted, ref } from 'vue'
  48. import { myRequest } from '@/utils/api.ts'
  49. import debounce from 'lodash/debounce'
  50. // 用户信息
  51. const userInfo = uni.getStorageSync('carUserInfo')
  52. // 胶囊按钮距离页面顶部的距离
  53. const paddingTop = ref(0)
  54. const tabIndex = ref(0)
  55. // 预约状态 0:全部 1:预约成功 2:已乘车 3:候补中 4:已取消 5:已爽约
  56. const result_state = ref(0)
  57. // 时间状态 1:全部 2:当天 3:本周 4:本月
  58. const date_state = ref(1)
  59. // 每页多少条数据
  60. const pageSize = ref(6)
  61. // 当前是第几页
  62. const currentPage = ref(1)
  63. // 总共多少条数据
  64. const total = ref(0)
  65. // 预约记录数据
  66. const listData = ref([])
  67. const tabs = ref(['全部', '未乘车', '已乘车', '已取消', '待支付'])
  68. // 获取用户预约数据
  69. async function getMyData() {
  70. const res = await myRequest({
  71. url: '/tAppqueryUserOrders.action',
  72. data: {
  73. result_state: result_state.value,
  74. date_state: date_state.value,
  75. mobile: userInfo?.phone || '18320846714',
  76. rows: pageSize.value,
  77. page: currentPage.value
  78. }
  79. })
  80. // console.log(res)
  81. const result = JSON.parse(res.data.data)
  82. console.log(result)
  83. total.value = result.totalCount
  84. // 处理数据
  85. result.list.forEach((ele) => {
  86. // 如果是待支付状态,算出剩余支付时间
  87. if (ele.state === 1 && ele.payState === 0) {
  88. const temLockTime = 5
  89. // 兼容ios部分系统转换时间格式
  90. const createTime = ele.createTime.slice(0, 19).replace(/-/g, '/')
  91. ele.countDownTime = new Date(createTime).getTime() + temLockTime * 60 * 1000 - new Date().getTime()
  92. }
  93. })
  94. listData.value = [...listData.value, ...result.list]
  95. }
  96. onMounted(() => {
  97. console.log(userInfo)
  98. paddingTop.value = uni.getMenuButtonBoundingClientRect().top
  99. console.log(paddingTop.value)
  100. getMyData()
  101. })
  102. // 页面拉到底部触发函数
  103. function scrolltolower() {
  104. if (listData.value.length < total.value) {
  105. currentPage.value++
  106. getMyData()
  107. } else {
  108. uni.showToast({
  109. title: '没有更多数据了',
  110. icon: 'none'
  111. })
  112. }
  113. }
  114. function handleChange(e) {
  115. console.log(e)
  116. result_state.value = e.index
  117. listData.value = []
  118. currentPage.value = 1
  119. total.value = 0
  120. getMyData()
  121. }
  122. function handleDetail() {
  123. uni.navigateTo({
  124. url: '/subPackages/car/bus/orderDetail/orderDetail'
  125. })
  126. }
  127. </script>
  128. <style lang="scss" scoped>
  129. .container {
  130. position: relative;
  131. display: flex;
  132. box-sizing: border-box;
  133. padding-top: 162rpx;
  134. height: 100%;
  135. color: #001713;
  136. background-color: #fff;
  137. overflow: hidden;
  138. .title {
  139. position: absolute;
  140. left: 314rpx;
  141. font-size: 40rpx;
  142. }
  143. .content {
  144. box-sizing: border-box;
  145. padding: 30rpx;
  146. height: calc(100vh - 246rpx);
  147. color: #001713;
  148. overflow-y: auto;
  149. .order_box {
  150. margin-bottom: 20rpx;
  151. box-sizing: border-box;
  152. padding: 40rpx 20rpx;
  153. box-shadow: 0px 3px 6px #ccc;
  154. .box_top {
  155. display: flex;
  156. align-items: center;
  157. justify-content: space-between;
  158. font-size: 28rpx;
  159. color: #ff8205;
  160. .top_left {
  161. display: flex;
  162. align-items: center;
  163. .left_img {
  164. margin-right: 12rpx;
  165. width: 32rpx;
  166. height: 32rpx;
  167. }
  168. }
  169. .top_status {
  170. font-size: 32rpx;
  171. }
  172. .red {
  173. color: #dc2626;
  174. }
  175. .gray {
  176. color: #707070;
  177. }
  178. }
  179. .box_center {
  180. display: flex;
  181. align-items: center;
  182. margin-top: 40rpx;
  183. font-weight: bold;
  184. .center_img {
  185. width: 14rpx;
  186. height: 88rpx;
  187. }
  188. .center_text {
  189. margin-left: 16rpx;
  190. .text_start {
  191. margin-top: -8rpx;
  192. width: 480rpx;
  193. text-overflow: ellipsis;
  194. white-space: nowrap;
  195. overflow: hidden;
  196. }
  197. .text_end {
  198. margin-top: 30rpx;
  199. width: 480rpx;
  200. text-overflow: ellipsis;
  201. white-space: nowrap;
  202. overflow: hidden;
  203. }
  204. }
  205. .center_price {
  206. margin-left: auto;
  207. font-size: 24rpx;
  208. color: #dc2626;
  209. .text {
  210. font-size: 36rpx;
  211. }
  212. }
  213. }
  214. .box_bottom {
  215. display: flex;
  216. align-items: flex-end;
  217. justify-content: space-between;
  218. margin-top: 8rpx;
  219. font-size: 24rpx;
  220. color: #aba6a6;
  221. .bottom_btns {
  222. display: flex;
  223. align-items: center;
  224. .btn_item {
  225. display: flex;
  226. align-items: center;
  227. justify-content: center;
  228. padding: 0 15rpx;
  229. margin-left: 10rpx;
  230. height: 50rpx;
  231. font-size: 24rpx;
  232. border-radius: 32rpx;
  233. border: 2rpx solid #aba6a6;
  234. }
  235. .pay {
  236. color: #ff8205;
  237. border: 2rpx solid #ff8205;
  238. }
  239. .cancel {
  240. color: #fff;
  241. background-color: #ff8205;
  242. }
  243. }
  244. }
  245. }
  246. }
  247. }
  248. </style>