my.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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 == ''" @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. listData.value = [...listData.value, ...result.list]
  194. }
  195. // 更换车次按钮回调
  196. const handleChange = () => {
  197. uni.switchTab({
  198. url: '/pages/home/home'
  199. })
  200. }
  201. // 我已上车按钮回调
  202. const handleOnCar = (id) => {
  203. uni.showModal({
  204. title: '提示',
  205. content: '确定已经上车吗?',
  206. success: (res) => {
  207. if (res.confirm) {
  208. handleOnCarRequest(id)
  209. } else if (res.cancel) {
  210. }
  211. }
  212. })
  213. }
  214. // 已上车请求
  215. const handleOnCarRequest = async (id) => {
  216. const res = await myRequest({
  217. url: '/appBoarding.action',
  218. data: {
  219. card_number: card_number.value,
  220. record_id: id
  221. }
  222. })
  223. // console.log(res);
  224. if (res) {
  225. uni.showToast({
  226. title: res.message
  227. })
  228. setTimeout(() => {
  229. currentPage.value = 1
  230. listData.value = []
  231. getMyData()
  232. }, 1500)
  233. }
  234. }
  235. // 取消预约按钮回调
  236. const handleCancel = (id) => {
  237. uni.showModal({
  238. title: '提示',
  239. content: '确定取消预约吗?',
  240. success: (res) => {
  241. if (res.confirm) {
  242. handleCancelRequest(id)
  243. } else if (res.cancel) {
  244. }
  245. }
  246. })
  247. }
  248. // 取消预约请求
  249. const handleCancelRequest = async (id) => {
  250. const res = await myRequest({
  251. url: '/appcancelOrder.action',
  252. data: {
  253. card_number: card_number.value,
  254. record_id: id
  255. }
  256. })
  257. // console.log(res);
  258. if (res) {
  259. uni.showToast({
  260. title: res.message
  261. })
  262. setTimeout(() => {
  263. currentPage.value = 1
  264. listData.value = []
  265. getMyData()
  266. }, 1500)
  267. }
  268. }
  269. // 筛选下拉框确定选择回调
  270. const getConveyData = (Obj) => {
  271. // console.log(Obj)
  272. result_state.value = Obj.typeIndex
  273. // date_state.value = Obj.timeIndex - 0 + 1
  274. currentPage.value = 1
  275. listData.value = []
  276. getMyData()
  277. }
  278. </script>
  279. <style lang="scss" scoped>
  280. .container {
  281. display: flex;
  282. flex-direction: column;
  283. background-color: #f2f2f2;
  284. .list {
  285. margin-bottom: 20rpx;
  286. font-size: 32rpx;
  287. background-color: #fff;
  288. .list-title {
  289. display: flex;
  290. justify-content: space-between;
  291. align-items: center;
  292. padding: 0 30rpx;
  293. height: 94rpx;
  294. font-weight: bold;
  295. font-size: 32rpx;
  296. border-bottom: 1rpx solid #e6e6e6;
  297. .list-img {
  298. margin-right: 10rpx;
  299. height: 34rpx;
  300. font-size: 28rpx;
  301. font-weight: 400;
  302. }
  303. .blue {
  304. color: #3c50e8;
  305. }
  306. .mr-30 {
  307. margin-right: 30rpx;
  308. }
  309. }
  310. .type {
  311. color: #000;
  312. background-color: #ffdb6e;
  313. }
  314. .type2 {
  315. color: #fff;
  316. background-color: #3c50e8;
  317. }
  318. .list-info {
  319. display: flex;
  320. flex-direction: column;
  321. justify-content: space-evenly;
  322. padding: 0 30rpx;
  323. margin-top: 15rpx;
  324. .list-info-item,
  325. .list-info-item2 {
  326. line-height: 60rpx;
  327. font-size: 28rpx;
  328. color: #333333;
  329. span {
  330. display: inline-block;
  331. width: 230rpx;
  332. text-align-last: justify;
  333. color: #999999;
  334. font-size: 28rpx;
  335. }
  336. }
  337. .highlight {
  338. color: #5c60f3;
  339. }
  340. .list-info-item {
  341. display: flex;
  342. // height: 60rpx;
  343. }
  344. }
  345. .list-button {
  346. display: flex;
  347. justify-content: flex-end;
  348. align-items: center;
  349. font-size: 28rpx;
  350. text-align: center;
  351. .list-button-change {
  352. display: flex;
  353. justify-content: center;
  354. align-items: center;
  355. margin: 17rpx 0 40rpx 0;
  356. width: 170rpx;
  357. height: 70rpx;
  358. color: #fff;
  359. border-radius: 15rpx;
  360. background: linear-gradient(#8684ff, #3c50e8);
  361. }
  362. .list-button-cancel {
  363. display: flex;
  364. justify-content: center;
  365. align-items: center;
  366. margin: 17rpx 30rpx 40rpx;
  367. width: 170rpx;
  368. height: 70rpx;
  369. color: #fff;
  370. border-radius: 15rpx;
  371. background-color: #ffc400;
  372. }
  373. }
  374. }
  375. .list-nodata {
  376. margin-top: -20rpx;
  377. padding-top: 100rpx;
  378. background-color: #fff;
  379. text-align: center;
  380. color: #999999;
  381. img {
  382. width: 600rpx;
  383. }
  384. }
  385. }
  386. </style>