my.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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>
  9. {{item.route }}
  10. </view>
  11. <view class="list-img" :class="item.state ===1 ? 'mr-30':''">
  12. <img v-if="item.state===1" src="../../static/success.png">
  13. <img v-if="item.state===2" src="../../static/pass.png">
  14. <img v-if="item.state===3" src="../../static/waiting.png">
  15. <img v-if="item.state===4" src="../../static/cancel.png">
  16. </view>
  17. </view>
  18. <view class="list-info">
  19. <view class="list-info-item">
  20. <span>预约号:</span>{{item.row_num}}
  21. </view>
  22. <view class="list-info-item">
  23. <span>下单时间:</span>{{item.yy_time}}
  24. </view>
  25. <view class="list-info-item" v-if="item.state===1">
  26. <span>发车时间:</span>{{item.yy_date}}
  27. </view>
  28. <view class="list-info-item" v-if="item.state===1||item.state===2">
  29. <span>车牌号:</span>{{item.car_number}}
  30. </view>
  31. <view class="list-info-item">
  32. <span>终点站:</span>{{item.route_end}}
  33. </view>
  34. <view class="list-info-item" v-if="item.state===1||item.state===2">
  35. <span>容 量:</span>{{item.contain}}人
  36. </view>
  37. <view class="list-info-item2" v-if="item.state===1||item.state===2">
  38. <span>变更信息:</span>{{item.remark!=''?item.remark:'无'}}
  39. </view>
  40. </view>
  41. <view class="list-button">
  42. <!-- <view class="list-button-change" v-if="item.state ===1" @click="handleChange">
  43. 更换车次
  44. </view> -->
  45. <view class="list-button-change" v-if="item.state ===1&&item.contain==6" @click="handleOnCar(item.id)">
  46. 我已上车
  47. </view>
  48. <view class="list-button-cancel" v-if="item.state ===1||item.state ===3" @click="handleCancel(item.id)">
  49. 取消预约
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 无数据时展示的区域 -->
  54. <view class="list-nodata" v-if="listData.length ==0">
  55. <img src="../../static/no-bus.png">
  56. <view>
  57. 暂无数据
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script setup>
  63. import {
  64. ref
  65. } from "vue"
  66. import {
  67. onLoad,
  68. onShow,
  69. onPullDownRefresh
  70. } from "@dcloudio/uni-app"
  71. import {
  72. myRequest
  73. } from "../../util/api.js"
  74. import {
  75. isWeixin
  76. } from "../../util/isWeixin.js"
  77. import Search from '../../components/search'
  78. onLoad(() => {
  79. if (isWeixin()) {
  80. card_number.value = uni.getStorageSync('bus_card_number')
  81. } else {
  82. uni.redirectTo({
  83. url: "/pages/404/404?message=请在微信客户端打开链接"
  84. })
  85. }
  86. })
  87. onShow(() => {
  88. getMyData()
  89. })
  90. onPullDownRefresh(() => {
  91. getMyData()
  92. setTimeout(function() {
  93. uni.stopPullDownRefresh();
  94. }, 500);
  95. })
  96. // 用户card_number
  97. const card_number = ref('')
  98. // 筛选条件状态列表
  99. const typeList = ref(['全部', '预约成功', '已乘车', '候补中', '已取消'])
  100. // 筛选条件时间列表
  101. const timeList = ref(['全部', '当天', '本周', '本月'])
  102. // 预约状态 0:全部 1:预约成功 2:已乘车 3:候补中 4:已取消
  103. const result_state = ref(0)
  104. // 时间状态 1:全部 2:当天 3:本周 4:本月
  105. const date_state = ref(1)
  106. // 预约记录数据
  107. // 1代表成功,2代表已乘车,3代表已分配,4代表候补中,5代表已取消
  108. const listData = ref([])
  109. // 获取用户预约数据
  110. const getMyData = async () => {
  111. listData.value = []
  112. const res = await myRequest({
  113. url: '/appqueryUserOrders.action',
  114. data: {
  115. result_state: result_state.value,
  116. date_state: date_state.value,
  117. card_number: card_number.value,
  118. }
  119. })
  120. // console.log(res);
  121. listData.value = res.data
  122. }
  123. // 更换车次按钮回调
  124. const handleChange = () => {
  125. uni.switchTab({
  126. url: "/pages/home/home"
  127. })
  128. }
  129. // 我已上车按钮回调
  130. const handleOnCar = (id) => {
  131. uni.showModal({
  132. title: '提示',
  133. content: '确定已经上车吗?',
  134. success: (res) => {
  135. if (res.confirm) {
  136. handleOnCarRequest(id)
  137. } else if (res.cancel) {}
  138. }
  139. });
  140. }
  141. // 已上车请求
  142. const handleOnCarRequest = async (id) => {
  143. const res = await myRequest({
  144. url: '/appBoarding.action',
  145. data: {
  146. card_number: card_number.value,
  147. record_id: id
  148. }
  149. })
  150. // console.log(res);
  151. if (res) {
  152. uni.showToast({
  153. title: res.message
  154. })
  155. setTimeout(() => {
  156. getMyData()
  157. }, 1500)
  158. }
  159. }
  160. // 取消预约按钮回调
  161. const handleCancel = (id) => {
  162. uni.showModal({
  163. title: '提示',
  164. content: '确定取消预约吗?',
  165. success: (res) => {
  166. if (res.confirm) {
  167. handleCancelRequest(id)
  168. } else if (res.cancel) {}
  169. }
  170. });
  171. }
  172. // 取消预约请求
  173. const handleCancelRequest = async (id) => {
  174. const res = await myRequest({
  175. url: '/appcancelOrder.action',
  176. data: {
  177. card_number: card_number.value,
  178. record_id: id
  179. }
  180. })
  181. // console.log(res);
  182. if (res) {
  183. uni.showToast({
  184. title: res.message
  185. })
  186. setTimeout(() => {
  187. getMyData()
  188. }, 1500)
  189. }
  190. }
  191. // 筛选下拉框确定选择回调
  192. const getConveyData = (Obj) => {
  193. // console.log(Obj);
  194. result_state.value = Obj.typeIndex
  195. date_state.value = Obj.timeIndex - 0 + 1
  196. getMyData()
  197. }
  198. </script>
  199. <style lang="scss" scoped>
  200. .container {
  201. display: flex;
  202. flex-direction: column;
  203. background-color: #F2F2F2;
  204. .list {
  205. margin-bottom: 20rpx;
  206. font-size: 32rpx;
  207. background-color: #fff;
  208. .list-title {
  209. display: flex;
  210. justify-content: space-between;
  211. align-items: center;
  212. padding: 0 30rpx;
  213. height: 94rpx;
  214. font-weight: bold;
  215. font-size: 32rpx;
  216. border-bottom: 1rpx solid #E6E6E6;
  217. .list-img {
  218. width: 121rpx;
  219. height: 34rpx;
  220. img {
  221. // width: 100%;
  222. height: 100%;
  223. }
  224. }
  225. .mr-30 {
  226. margin-right: 30rpx;
  227. }
  228. }
  229. .list-info {
  230. display: flex;
  231. flex-direction: column;
  232. justify-content: space-evenly;
  233. padding: 0 30rpx;
  234. margin-top: 15rpx;
  235. .list-info-item,
  236. .list-info-item2 {
  237. line-height: 60rpx;
  238. font-size: 28rpx;
  239. color: #333333;
  240. span {
  241. display: inline-block;
  242. width: 160rpx;
  243. text-align-last: justify;
  244. color: #999999;
  245. }
  246. }
  247. .list-info-item {
  248. height: 60rpx;
  249. }
  250. }
  251. .list-button {
  252. display: flex;
  253. justify-content: flex-end;
  254. align-items: center;
  255. font-size: 28rpx;
  256. text-align: center;
  257. .list-button-change {
  258. display: flex;
  259. justify-content: center;
  260. align-items: center;
  261. margin: 17rpx 0 40rpx 0;
  262. width: 170rpx;
  263. height: 70rpx;
  264. color: #fff;
  265. border-radius: 15rpx;
  266. background: linear-gradient(#8684FF, #3C50E8);
  267. }
  268. .list-button-cancel {
  269. display: flex;
  270. justify-content: center;
  271. align-items: center;
  272. margin: 17rpx 30rpx 40rpx;
  273. width: 170rpx;
  274. height: 70rpx;
  275. color: #999999;
  276. border-radius: 15rpx;
  277. background-color: #E6E6E6;
  278. }
  279. }
  280. }
  281. .list-nodata {
  282. margin-top: -20rpx;
  283. padding-top: 100rpx;
  284. background-color: #fff;
  285. text-align: center;
  286. color: #999999;
  287. img {
  288. width: 600rpx;
  289. }
  290. }
  291. }
  292. </style>