my.vue 9.1 KB

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