| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325 |
- <template>
- <view class="container">
- <!-- 筛选区域 -->
- <Search :typeList="typeList" :timeList="timeList" @handLeConveyData="getConveyData" />
- <!-- 列表区域 -->
- <view class="list" v-for="(item,index) in listData" :key="index">
- <view class="list-title">
- <view>
- {{item.route }}
- </view>
- <view class="list-img" :class="item.state ===1 ? 'mr-30':''">
- <img v-if="item.state===1" src="../../static/success.png">
- <img v-if="item.state===2" src="../../static/pass.png">
- <img v-if="item.state===3" src="../../static/waiting.png">
- <img v-if="item.state===4" src="../../static/cancel.png">
- </view>
- </view>
- <view class="list-info">
- <view class="list-info-item">
- <span>预约号:</span>{{item.row_num}}
- </view>
- <view class="list-info-item">
- <span>下单时间:</span>{{item.yy_time}}
- </view>
- <view class="list-info-item" v-if="item.state===1">
- <span>发车时间:</span>{{item.yy_date}}
- </view>
- <view class="list-info-item" v-if="item.state===1||item.state===2">
- <span>车牌号:</span>{{item.car_number}}
- </view>
- <view class="list-info-item">
- <span>终点站:</span>{{item.route_end}}
- </view>
- <view class="list-info-item" v-if="item.state===1||item.state===2">
- <span>容 量:</span>{{item.contain}}人
- </view>
- <view class="list-info-item2" v-if="item.state===1||item.state===2">
- <span>变更信息:</span>{{item.remark!=''?item.remark:'无'}}
- </view>
- </view>
- <view class="list-button">
- <!-- <view class="list-button-change" v-if="item.state ===1" @click="handleChange">
- 更换车次
- </view> -->
- <view class="list-button-change" v-if="item.state ===1&&item.contain==6" @click="handleOnCar(item.id)">
- 我已上车
- </view>
- <view class="list-button-cancel" v-if="item.state ===1||item.state ===3" @click="handleCancel(item.id)">
- 取消预约
- </view>
- </view>
- </view>
- <!-- 无数据时展示的区域 -->
- <view class="list-nodata" v-if="listData.length ==0">
- <img src="../../static/no-bus.png">
- <view>
- 暂无数据
- </view>
- </view>
- </view>
- </template>
- <script setup>
- import {
- ref
- } from "vue"
- import {
- onLoad,
- onShow,
- onPullDownRefresh
- } from "@dcloudio/uni-app"
- import {
- myRequest
- } from "../../util/api.js"
- import {
- isWeixin
- } from "../../util/isWeixin.js"
- import Search from '../../components/search'
- onLoad(() => {
- if (isWeixin()) {
- card_number.value = uni.getStorageSync('bus_card_number')
- } else {
- uni.redirectTo({
- url: "/pages/404/404?message=请在微信客户端打开链接"
- })
- }
- })
- onShow(() => {
- getMyData()
- })
- onPullDownRefresh(() => {
- getMyData()
- setTimeout(function() {
- uni.stopPullDownRefresh();
- }, 500);
- })
- // 用户card_number
- const card_number = ref('')
- // 筛选条件状态列表
- const typeList = ref(['全部', '预约成功', '已乘车', '候补中', '已取消'])
- // 筛选条件时间列表
- const timeList = ref(['全部', '当天', '本周', '本月'])
- // 预约状态 0:全部 1:预约成功 2:已乘车 3:候补中 4:已取消
- const result_state = ref(0)
- // 时间状态 1:全部 2:当天 3:本周 4:本月
- const date_state = ref(1)
- // 预约记录数据
- // 1代表成功,2代表已乘车,3代表已分配,4代表候补中,5代表已取消
- const listData = ref([])
- // 获取用户预约数据
- const getMyData = async () => {
- listData.value = []
- const res = await myRequest({
- url: '/appqueryUserOrders.action',
- data: {
- result_state: result_state.value,
- date_state: date_state.value,
- card_number: card_number.value,
- }
- })
- // console.log(res);
- listData.value = res.data
- }
- // 更换车次按钮回调
- const handleChange = () => {
- uni.switchTab({
- url: "/pages/home/home"
- })
- }
- // 我已上车按钮回调
- const handleOnCar = (id) => {
- uni.showModal({
- title: '提示',
- content: '确定已经上车吗?',
- success: (res) => {
- if (res.confirm) {
- handleOnCarRequest(id)
- } else if (res.cancel) {}
- }
- });
- }
- // 已上车请求
- const handleOnCarRequest = async (id) => {
- const res = await myRequest({
- url: '/appBoarding.action',
- data: {
- card_number: card_number.value,
- record_id: id
- }
- })
- // console.log(res);
- if (res) {
- uni.showToast({
- title: res.message
- })
- setTimeout(() => {
- getMyData()
- }, 1500)
- }
- }
- // 取消预约按钮回调
- const handleCancel = (id) => {
- uni.showModal({
- title: '提示',
- content: '确定取消预约吗?',
- success: (res) => {
- if (res.confirm) {
- handleCancelRequest(id)
- } else if (res.cancel) {}
- }
- });
- }
- // 取消预约请求
- const handleCancelRequest = async (id) => {
- const res = await myRequest({
- url: '/appcancelOrder.action',
- data: {
- card_number: card_number.value,
- record_id: id
- }
- })
- // console.log(res);
- if (res) {
- uni.showToast({
- title: res.message
- })
- setTimeout(() => {
- getMyData()
- }, 1500)
- }
- }
- // 筛选下拉框确定选择回调
- const getConveyData = (Obj) => {
- // console.log(Obj);
- result_state.value = Obj.typeIndex
- date_state.value = Obj.timeIndex - 0 + 1
- getMyData()
- }
- </script>
- <style lang="scss" scoped>
- .container {
- display: flex;
- flex-direction: column;
- background-color: #F2F2F2;
- .list {
- margin-bottom: 20rpx;
- font-size: 32rpx;
- background-color: #fff;
- .list-title {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 0 30rpx;
- height: 94rpx;
- font-weight: bold;
- font-size: 32rpx;
- border-bottom: 1rpx solid #E6E6E6;
- .list-img {
- width: 121rpx;
- height: 34rpx;
- img {
- // width: 100%;
- height: 100%;
- }
- }
- .mr-30 {
- margin-right: 30rpx;
- }
- }
- .list-info {
- display: flex;
- flex-direction: column;
- justify-content: space-evenly;
- padding: 0 30rpx;
- margin-top: 15rpx;
- .list-info-item,
- .list-info-item2 {
- line-height: 60rpx;
- font-size: 28rpx;
- color: #333333;
- span {
- display: inline-block;
- width: 160rpx;
- text-align-last: justify;
- color: #999999;
- }
- }
- .list-info-item {
- height: 60rpx;
- }
- }
- .list-button {
- display: flex;
- justify-content: flex-end;
- align-items: center;
- font-size: 28rpx;
- text-align: center;
- .list-button-change {
- display: flex;
- justify-content: center;
- align-items: center;
- margin: 17rpx 0 40rpx 0;
- width: 170rpx;
- height: 70rpx;
- color: #fff;
- border-radius: 15rpx;
- background: linear-gradient(#8684FF, #3C50E8);
- }
- .list-button-cancel {
- display: flex;
- justify-content: center;
- align-items: center;
- margin: 17rpx 30rpx 40rpx;
- width: 170rpx;
- height: 70rpx;
- color: #999999;
- border-radius: 15rpx;
- background-color: #E6E6E6;
- }
- }
- }
- .list-nodata {
- margin-top: -20rpx;
- padding-top: 100rpx;
- background-color: #fff;
- text-align: center;
- color: #999999;
- img {
- width: 600rpx;
- }
- }
- }
- </style>
|