my.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <template>
  2. <view class="container">
  3. <!-- 筛选区域 -->
  4. <Search :typeList="typeList" :timeList="timeList" @handLeConveyData="getConveyData" />
  5. <!-- 列表区域 -->
  6. <view class="list" v-for="(item, index) in listData" :key="index">
  7. <view class="list-title">
  8. <view>{{ item.route }}</view>
  9. <view class="list-img" :class="item.state === 1 ? 'mr-30' : ''">
  10. <img v-if="item.state === 1" src="../../static/success.png" />
  11. <img v-if="item.state === 2" src="../../static/pass.png" />
  12. <img v-if="item.state === 3" src="../../static/waiting.png" />
  13. <img v-if="item.state === 4" src="../../static/cancel.png" />
  14. <img v-if="item.state === 5" src="../../static/unAppoint.png" />
  15. </view>
  16. </view>
  17. <view class="list-info">
  18. <view class="list-info-item">
  19. <span>预约号:</span>
  20. {{ item.row_num.toString().padStart(2, '0') }}
  21. </view>
  22. <view :class="['list-info-item', item.state == 1 ? 'highlight' : '']" v-if="item.state !== 3">
  23. <span>车牌号:</span>
  24. {{ item.car_number }}
  25. </view>
  26. <view class="list-info-item" v-if="item.state === 1 || item.state === 2">
  27. <span>容 量:</span>
  28. {{ item.contain }}人
  29. </view>
  30. <view class="list-info-item">
  31. <span>站点:</span>
  32. {{ item.route_end }}
  33. </view>
  34. <view class="list-info-item highlight" v-if="item.state === 1">
  35. <span>发车时间:</span>
  36. {{ item.yy_date }}
  37. </view>
  38. <view class="list-info-item highlight" v-if="item.state === 1">
  39. <span>扫码时间段:</span>
  40. {{ item.sm_time }}
  41. </view>
  42. <view class="list-info-item">
  43. <span>下单时间:</span>
  44. {{ item.yy_time }}
  45. </view>
  46. <view class="list-info-item2" v-if="item.state === 1 || item.state === 2">
  47. <span>变更信息:</span>
  48. {{ item.remark != '' ? item.remark : '无' }}
  49. </view>
  50. </view>
  51. <view class="list-button">
  52. <!-- <view class="list-button-change" v-if="item.state ===1" @click="handleChange">
  53. 更换车次
  54. </view> -->
  55. <view class="list-button-change" v-if="item.state === 1 && item.contain == 6" @click="handleOnCar(item.id)">我已上车</view>
  56. <view class="list-button-cancel" v-if="item.state === 1 || item.state === 3" @click="handleCancel(item.id)">取消预约</view>
  57. </view>
  58. </view>
  59. <!-- 无数据时展示的区域 -->
  60. <view class="list-nodata" v-if="listData.length == 0">
  61. <img src="../../static/no-bus.png" />
  62. <view>暂无数据</view>
  63. </view>
  64. </view>
  65. </template>
  66. <script setup>
  67. import { ref } from 'vue'
  68. import { onLoad, onShow, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
  69. import { myRequest } from '../../util/api.js'
  70. import { isWeixin } from '../../util/isWeixin.js'
  71. import Search from '../../components/search'
  72. onLoad(() => {
  73. if (isWeixin()) {
  74. card_number.value = uni.getStorageSync('bus_card_number')
  75. } else {
  76. uni.redirectTo({
  77. url: '/pages/404/404?message=请在微信客户端打开链接'
  78. })
  79. }
  80. })
  81. onShow(() => {
  82. result_state.value = 0
  83. date_state.value = 1
  84. currentPage.value = 1
  85. listData.value = []
  86. getMyData()
  87. })
  88. // 下拉刷新回调
  89. onPullDownRefresh(() => {
  90. currentPage.value = 1
  91. listData.value = []
  92. getMyData()
  93. setTimeout(function() {
  94. uni.stopPullDownRefresh()
  95. }, 500)
  96. })
  97. // 页面拉到底部触发函数
  98. onReachBottom(() => {
  99. if (listData.value.length < total.value) {
  100. currentPage.value++
  101. getMyData()
  102. } else {
  103. uni.showToast({
  104. title: '没有更多数据了',
  105. icon: 'none'
  106. })
  107. }
  108. })
  109. // 用户card_number
  110. const card_number = ref('')
  111. // 筛选条件状态列表
  112. const typeList = ref([
  113. {
  114. text: '全部',
  115. value: 0
  116. },
  117. {
  118. text: '预约成功',
  119. value: 1
  120. },
  121. {
  122. text: '已乘车',
  123. value: 2
  124. },
  125. {
  126. text: '候补中',
  127. value: 3
  128. },
  129. {
  130. text: '已取消',
  131. value: 4
  132. },
  133. {
  134. text: '已爽约',
  135. value: 5
  136. }
  137. ])
  138. // 筛选条件时间列表
  139. const timeList = ref([
  140. {
  141. text: '全部',
  142. value: 0
  143. },
  144. {
  145. text: '当天',
  146. value: 1
  147. },
  148. {
  149. text: '本周',
  150. value: 2
  151. },
  152. {
  153. text: '本月',
  154. value: 3
  155. }
  156. ])
  157. // 预约状态 0:全部 1:预约成功 2:已乘车 3:候补中 4:已取消 5:已爽约
  158. const result_state = ref(0)
  159. // 时间状态 1:全部 2:当天 3:本周 4:本月
  160. const date_state = ref(1)
  161. // 每页多少条数据
  162. const pageSize = ref(5)
  163. // 当前是第几页
  164. const currentPage = ref(1)
  165. // 总共多少条数据
  166. const total = ref(null)
  167. // 预约记录数据
  168. const listData = ref([])
  169. // 获取用户预约数据
  170. const getMyData = async () => {
  171. const res = await myRequest({
  172. url: '/appqueryUserOrders.action',
  173. data: {
  174. result_state: result_state.value,
  175. date_state: date_state.value,
  176. card_number: card_number.value,
  177. rows: pageSize.value,
  178. page: currentPage.value
  179. }
  180. })
  181. // console.log(res)
  182. total.value = res.data.totalCount
  183. listData.value = [...listData.value, ...res.data.list]
  184. }
  185. // 更换车次按钮回调
  186. const handleChange = () => {
  187. uni.switchTab({
  188. url: '/pages/home/home'
  189. })
  190. }
  191. // 我已上车按钮回调
  192. const handleOnCar = id => {
  193. uni.showModal({
  194. title: '提示',
  195. content: '确定已经上车吗?',
  196. success: res => {
  197. if (res.confirm) {
  198. handleOnCarRequest(id)
  199. } else if (res.cancel) {
  200. }
  201. }
  202. })
  203. }
  204. // 已上车请求
  205. const handleOnCarRequest = async id => {
  206. const res = await myRequest({
  207. url: '/appBoarding.action',
  208. data: {
  209. card_number: card_number.value,
  210. record_id: id
  211. }
  212. })
  213. // console.log(res);
  214. if (res) {
  215. uni.showToast({
  216. title: res.message
  217. })
  218. setTimeout(() => {
  219. currentPage.value = 1
  220. listData.value = []
  221. getMyData()
  222. }, 1500)
  223. }
  224. }
  225. // 取消预约按钮回调
  226. const handleCancel = id => {
  227. uni.showModal({
  228. title: '提示',
  229. content: '确定取消预约吗?',
  230. success: res => {
  231. if (res.confirm) {
  232. handleCancelRequest(id)
  233. } else if (res.cancel) {
  234. }
  235. }
  236. })
  237. }
  238. // 取消预约请求
  239. const handleCancelRequest = async id => {
  240. const res = await myRequest({
  241. url: '/appcancelOrder.action',
  242. data: {
  243. card_number: card_number.value,
  244. record_id: id
  245. }
  246. })
  247. // console.log(res);
  248. if (res) {
  249. uni.showToast({
  250. title: res.message
  251. })
  252. setTimeout(() => {
  253. currentPage.value = 1
  254. listData.value = []
  255. getMyData()
  256. }, 1500)
  257. }
  258. }
  259. // 筛选下拉框确定选择回调
  260. const getConveyData = Obj => {
  261. // console.log(Obj)
  262. result_state.value = Obj.typeIndex
  263. date_state.value = Obj.timeIndex - 0 + 1
  264. currentPage.value = 1
  265. listData.value = []
  266. getMyData()
  267. }
  268. </script>
  269. <style lang="scss" scoped>
  270. .container {
  271. display: flex;
  272. flex-direction: column;
  273. background-color: #f2f2f2;
  274. .list {
  275. margin-bottom: 20rpx;
  276. font-size: 32rpx;
  277. background-color: #fff;
  278. .list-title {
  279. display: flex;
  280. justify-content: space-between;
  281. align-items: center;
  282. padding: 0 30rpx;
  283. height: 94rpx;
  284. font-weight: bold;
  285. font-size: 32rpx;
  286. border-bottom: 1rpx solid #e6e6e6;
  287. .list-img {
  288. width: 121rpx;
  289. height: 34rpx;
  290. img {
  291. // width: 100%;
  292. height: 100%;
  293. }
  294. }
  295. .mr-30 {
  296. margin-right: 30rpx;
  297. }
  298. }
  299. .list-info {
  300. display: flex;
  301. flex-direction: column;
  302. justify-content: space-evenly;
  303. padding: 0 30rpx;
  304. margin-top: 15rpx;
  305. .list-info-item,
  306. .list-info-item2 {
  307. line-height: 60rpx;
  308. font-size: 28rpx;
  309. color: #333333;
  310. span {
  311. display: inline-block;
  312. width: 230rpx;
  313. text-align-last: justify;
  314. color: #999999;
  315. font-size: 28rpx;
  316. }
  317. }
  318. .highlight {
  319. color: #5c60f3;
  320. }
  321. .list-info-item {
  322. height: 60rpx;
  323. }
  324. }
  325. .list-button {
  326. display: flex;
  327. justify-content: flex-end;
  328. align-items: center;
  329. font-size: 28rpx;
  330. text-align: center;
  331. .list-button-change {
  332. display: flex;
  333. justify-content: center;
  334. align-items: center;
  335. margin: 17rpx 0 40rpx 0;
  336. width: 170rpx;
  337. height: 70rpx;
  338. color: #fff;
  339. border-radius: 15rpx;
  340. background: linear-gradient(#8684ff, #3c50e8);
  341. }
  342. .list-button-cancel {
  343. display: flex;
  344. justify-content: center;
  345. align-items: center;
  346. margin: 17rpx 30rpx 40rpx;
  347. width: 170rpx;
  348. height: 70rpx;
  349. color: #fff;
  350. border-radius: 15rpx;
  351. background-color: #ffc400;
  352. }
  353. }
  354. }
  355. .list-nodata {
  356. margin-top: -20rpx;
  357. padding-top: 100rpx;
  358. background-color: #fff;
  359. text-align: center;
  360. color: #999999;
  361. img {
  362. width: 600rpx;
  363. }
  364. }
  365. }
  366. </style>