| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427 |
- <template>
- <view class="container">
- <!-- 筛选区域 -->
- <Search :result_state="result_state" :typeList="typeList" :timeList="timeList" @handLeConveyData="getConveyData" />
- <!-- 列表区域 -->
- <view class="list" v-for="(item, index) in listData" :key="index">
- <view class="list-title" :class="item.route === '南昌-靖安' ? 'type' : 'type2'">
- <view>{{ item.route }}</view>
- <view class="list-img" :class="[item.state === 1 ? 'mr-30' : '', { blue: item.route === '南昌-靖安' }]">
- <view v-if="item.state === 1" class="">预约成功</view>
- <view v-if="item.state === 2" class="">已乘车</view>
- <view v-if="item.state === 3" class="">候补中...</view>
- <view v-if="item.state === 4" class="">已取消</view>
- <view v-if="item.state === 5" class="">已爽约</view>
- <view v-if="item.state === 6" class="">爽约已核销</view>
- </view>
- </view>
- <view class="list-info">
- <view class="list-info-item">
- <span>预约号:</span>
- {{ item.row_num.toString().padStart(2, '0') }}
- </view>
- <view :class="['list-info-item', item.state == 1 ? 'highlight' : '']" v-if="item.state !== 3">
- <span>车牌号:</span>
- {{ item.car_number }}
- </view>
- <view class="list-info-item" v-if="item.state === 1 || item.state === 2">
- <span>容 量:</span>
- {{ item.contain }}人
- </view>
- <view class="list-info-item">
- <span>站点:</span>
- {{ item.route_end }}
- </view>
- <view class="list-info-item highlight" v-if="item.state === 1">
- <span>发车时间:</span>
- {{ item.yy_date }}
- </view>
- <view class="list-info-item highlight" v-if="item.state === 1">
- <span>扫码时间段:</span>
- {{ item.sm_time }}
- </view>
- <view class="list-info-item">
- <span>下单时间:</span>
- {{ item.yy_time }}
- </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.is_device == ''" @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, onReachBottom } from '@dcloudio/uni-app'
- import { myRequest } from '@/util/api.js'
- import { isWeixin } from '@/util/isWeixin.js'
- import { filterIdentity } from '@/util/filterIdentity.js'
- import Search from '@/components/search'
- import { decryptDes } from '@/util/des.js'
- onLoad(() => {
- if (isWeixin()) {
- filterIdentity()
- card_number.value = uni.getStorageSync('bus_card_number')
- } else {
- uni.redirectTo({
- url: '/pages/404/404?message=请在微信客户端打开链接'
- })
- }
- })
- onShow(() => {
- result_state.value = 0
- // date_state.value = 1
- currentPage.value = 1
- listData.value = []
- getMyData()
- })
- // 下拉刷新回调
- onPullDownRefresh(() => {
- currentPage.value = 1
- listData.value = []
- getMyData()
- setTimeout(function () {
- uni.stopPullDownRefresh()
- }, 500)
- })
- // 页面拉到底部触发函数
- onReachBottom(() => {
- if (listData.value.length < total.value) {
- currentPage.value++
- getMyData()
- } else {
- uni.showToast({
- title: '没有更多数据了',
- icon: 'none'
- })
- }
- })
- // 用户card_number
- const card_number = ref('')
- // 筛选条件状态列表
- const typeList = ref([
- {
- text: '全部',
- value: 0
- },
- {
- text: '预约成功',
- value: 1
- },
- {
- text: '已乘车',
- value: 2
- },
- {
- text: '候补中',
- value: 3
- },
- {
- text: '已取消',
- value: 4
- },
- {
- text: '已爽约',
- value: 5
- },
- {
- text: '爽约已核销',
- value: 6
- }
- ])
- // 筛选条件时间列表
- const timeList = ref([
- {
- text: '全部',
- value: 0
- },
- {
- text: '当天',
- value: 1
- },
- {
- text: '本周',
- value: 2
- },
- {
- text: '本月',
- value: 3
- }
- ])
- // 预约状态 0:全部 1:预约成功 2:已乘车 3:候补中 4:已取消 5:已爽约
- const result_state = ref(0)
- // 时间状态 1:全部 2:当天 3:本周 4:本月
- const date_state = ref(3)
- // 每页多少条数据
- const pageSize = ref(5)
- // 当前是第几页
- const currentPage = ref(1)
- // 总共多少条数据
- const total = ref(null)
- // 预约记录数据
- const listData = ref([])
- // 获取用户预约数据
- const getMyData = async () => {
- const res = await myRequest({
- url: '/appqueryUserOrders.action',
- data: {
- result_state: result_state.value,
- date_state: date_state.value,
- card_number: card_number.value,
- rows: pageSize.value,
- page: currentPage.value
- }
- })
- // console.log(res)
- const result = JSON.parse(decryptDes(res.data))
- // console.log(result)
- total.value = result.totalCount
- listData.value = [...listData.value, ...result.list]
- }
- // 更换车次按钮回调
- 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(() => {
- currentPage.value = 1
- listData.value = []
- 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(() => {
- currentPage.value = 1
- listData.value = []
- getMyData()
- }, 1500)
- }
- }
- // 筛选下拉框确定选择回调
- const getConveyData = (Obj) => {
- // console.log(Obj)
- result_state.value = Obj.typeIndex
- // date_state.value = Obj.timeIndex - 0 + 1
- currentPage.value = 1
- listData.value = []
- 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 {
- margin-right: 10rpx;
- height: 34rpx;
- font-size: 28rpx;
- font-weight: 400;
- }
- .blue {
- color: #3c50e8;
- }
- .mr-30 {
- margin-right: 30rpx;
- }
- }
- .type {
- color: #000;
- background-color: #ffdb6e;
- }
- .type2 {
- color: #fff;
- background-color: #3c50e8;
- }
- .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: 230rpx;
- text-align-last: justify;
- color: #999999;
- font-size: 28rpx;
- }
- }
- .highlight {
- color: #5c60f3;
- }
- .list-info-item {
- display: flex;
- // 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: #fff;
- border-radius: 15rpx;
- background-color: #ffc400;
- }
- }
- }
- .list-nodata {
- margin-top: -20rpx;
- padding-top: 100rpx;
- background-color: #fff;
- text-align: center;
- color: #999999;
- img {
- width: 600rpx;
- }
- }
- }
- </style>
|