my.vue 7.1 KB

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