my.vue 8.3 KB

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