my.vue 8.2 KB

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