| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714 |
- <template>
- <view class="container">
- <!-- 头部时间信息区域 -->
- <view class="header-time">
- <view class="today" @click="handleChangeTime">
- {{dateType=='明天'?'今天':''}}
- </view>
- <view class="time-info">
- {{currentMonth}}月{{currentDay}}日
- <span>{{dateType}}</span>
- {{currentWeek}}
- </view>
- <view class="tomorrow" @click="handleChangeTime">
- {{dateType=='今天'?'明天':''}}
- </view>
- </view>
- <!-- 头部路线信息区域 -->
- <view class="header-path">
- <view class="path-title">
- 请选择路线
- </view>
- <view class="path-list" v-if="pathList.length">
- <view :class="currentIndex1 === index?'active path-item':'path-item'" v-for="(item,index) in pathList"
- :key="index" @click="handleChangeCurrentIndex(1,index,item)">
- {{item.route}}
- </view>
- </view>
- <view class="path-list-nodata" v-else>
- 暂无数据
- </view>
- </view>
- <!-- 车辆列表区域 -->
- <view class="carList">
- <view class="carList-title">
- 请选择车辆
- </view>
- <view :class="[currentIndex2 === index?'active ':'',item.can_order==0?'unactive':'','carList-item']"
- v-for="(item,index) in busList" :key="index" @click="handleChangeCurrentIndex(2,index,item)">
- <view class="item-time">
- {{item.ci_time}}
- </view>
- <view class="item-info">
- <view class="item-info-place">
- {{item.route_end}}
- </view>
- <view class="item-info-detail">
- 车牌:{{item.car_number}}
- <span>容量:{{item.boarde_num+'/'+item.contain}}</span>
- </view>
- </view>
- </view>
- <!-- 没有数据时展示的区域 -->
- <view class="carList-nodata" v-if="busList.length==0">
- <img src="../../static/no-bus.png">
- <view class="nodata-info">
- 暂无数据
- </view>
- </view>
- </view>
- <!-- 立即预约按钮区域 -->
- <view class="btn-box" v-if="busList.length">
- <view class="btn">
- <view class="btn-clock">
- <img src="../../static/clock.png">
- </view>
- <view class="btn-info" v-if="status">
- <view class="btn-info-title">
- 开始预约时间段
- </view>
- <view>
- {{yy_duration}}
- </view>
- </view>
- <view class="btn-info" v-else>
- <view class="btn-info-title2">
- 候补截止时间
- </view>
- <view class="btn-info-time">
- {{hh_end}}
- </view>
- </view>
- <view class="btn-button" @click="handleSub">
- <!-- {{status?'立即预约':'候补预约'}} -->
- {{status?'立即预约':dateType=='今天'?'候补预约':'立即预约'}}
- </view>
- </view>
- </view>
- <!-- 温馨提示区域 -->
- <view class="box-info">
- <view class="info-title">
- 温馨提示
- </view>
- <view class="info-detail">
- 预约截止时间为发车前{{yy_end}}分钟,如当月爽约{{black_count}}次,账号会被锁定,锁定后联系车队长解锁。车队长联系方式:<span
- @click="handlePhone(13576937506)">13576937506</span>,候补功能仅当日开放。
- </view>
- </view>
- </view>
- </template>
- <script setup>
- import {
- ref,
- computed,
- watch
- } from "vue"
- import {
- onLoad,
- onPullDownRefresh,
- onShow
- } from "@dcloudio/uni-app"
- import {
- myRequest
- } from "../../util/api.js"
- import {
- isWeixin
- } from "../../util/isWeixin.js"
- onLoad(() => {
- if (isWeixin()) {
- card_number.value = uni.getStorageSync('bus_card_number')
- getUserInfo()
- } else {
- uni.redirectTo({
- url: "/pages/404/404?message=请在微信客户端打开链接"
- })
- }
- })
- onShow(() => {
- getTimeFormat()
- getPathList()
- getOrderConfig()
- currentIndex1.value = 0
- currentIndex2.value = null
- currentBusId.value = null
- busList.value = []
- setTimeout(() => {
- currentPath.value = pathList.value[0].route
- getBusList(pathList.value[0].route)
- }, 200)
- })
- // 页面下拉触发刷新回调
- onPullDownRefresh(() => {
- getUserInfo()
- getTimeFormat()
- getPathList()
- getOrderConfig()
- currentIndex1.value = 0
- currentIndex2.value = null
- currentBusId.value = null
- busList.value = []
- setTimeout(function() {
- currentPath.value = pathList.value[0].route
- getBusList(pathList.value[0].route)
- uni.stopPullDownRefresh();
- }, 500);
- })
- // 用户card_number
- const card_number = ref('')
- // 判断是今天还是明天
- const dateType = ref("今天")
- // 当前月份
- const currentMonth = ref("")
- // 当前日期
- const currentDay = ref("")
- // 当前星期
- const currentWeek = ref("")
- // 发车路线列表
- const pathList = ref([])
- // 发车路线当前选中项
- const currentIndex1 = ref(0)
- // 当前发车路线
- const currentPath = ref(null)
- // 发车车辆列表
- const busList = ref([])
- // 预约车辆当前选中项
- const currentIndex2 = ref(null)
- // 当前预约车辆ID
- const currentBusId = ref(null)
- // 开始预约时间段
- const yy_duration = ref("")
- // 预约截止时间
- const yy_end = ref("")
- // 候补截止时间
- const hh_end = ref("")
- // 爽约次数
- const black_count = ref("")
- // 候补预约状态 true表示预约 false表示候补
- const status = ref(true)
- // 监听车辆列表更改候补预约状态
- watch(
- () => busList.value,
- (newValue) => {
- status.value = newValue.some(item =>
- item.can_order == 1
- )
- })
- // 获取用户信息
- const getUserInfo = async () => {
- const res = await myRequest({
- url: '/appget_user.action',
- data: {
- card_number: card_number.value,
- }
- })
- // console.log(res);
- uni.setStorageSync("bus-userInfo", JSON.stringify(res.data))
- if (res.data && res.data.user_zz !== '教师') {
- uni.reLaunch({
- url: "/pages/record/record"
- })
- }
- }
- // 获取所有的发车路线
- const getPathList = async () => {
- const res = await myRequest({
- url: '/appqueryRoute.action',
- })
- // console.log(res);
- pathList.value = res.data
- }
- // 根据路线查询所有车次
- const getBusList = async (route) => {
- busList.value = []
- // 处理时间参数
- let date = new Date()
- let year = date.getFullYear()
- const res = await myRequest({
- url: '/appqueryCarNums.action',
- data: {
- date: `${year}-${currentMonth.value}-${currentDay.value}`,
- route: route || currentPath.value
- }
- })
- // console.log(res);
- busList.value = res.data || []
- }
- // 获取预约时间段数据
- const getOrderConfig = async () => {
- const res = await myRequest({
- url: '/appqueryConfig.action',
- })
- // console.log(res);
- yy_duration.value = res.data.yy_duration
- yy_end.value = res.data.yy_end
- hh_end.value = res.data.hh_end
- black_count.value = res.data.black_count
- }
- // 立即预约按钮回调
- const handleSub = () => {
- if (status.value) {
- if (!currentPath.value) {
- uni.showToast({
- title: '请选择路线',
- icon: "none"
- })
- return
- }
- if (!currentBusId.value) {
- uni.showToast({
- title: '请选择车辆',
- icon: "none"
- })
- return
- }
- uni.showModal({
- title: '提示',
- content: '确定预约吗?',
- success: (res) => {
- if (res.confirm) {
- handleSubscribe()
- } else if (res.cancel) {
- }
- }
- });
- } else {
- if (dateType.value == '明天') {
- uni.showToast({
- title: '候补功能仅当日开放',
- icon: "none"
- })
- return
- }
- if (!currentPath.value) {
- uni.showToast({
- title: '请选择路线',
- icon: "none"
- })
- return
- }
- if (pathList.value[currentIndex1.value].is_repair == 0) {
- uni.showToast({
- title: '当前路线不可候补',
- icon: "none"
- })
- return
- }
- uni.showModal({
- title: '提示',
- content: '确定候补预约吗?',
- success: (res) => {
- if (res.confirm) {
- handleStandby()
- } else if (res.cancel) {}
- }
- });
- }
- }
- // 预约请求
- const handleSubscribe = async () => {
- // 处理时间参数
- let date = new Date()
- let year = date.getFullYear()
- const res = await myRequest({
- url: '/appmakeAppointment.action',
- data: {
- date: `${year}-${currentMonth.value}-${currentDay.value}`,
- card_number: card_number.value,
- id: currentBusId.value,
- yyEnd: yy_end.value,
- }
- })
- // console.log(res);
- if (res) {
- uni.showToast({
- title: res.message
- })
- currentIndex1.value = null
- currentIndex2.value = null
- currentPath.value = null
- currentBusId.value = null
- busList.value = []
- uni.switchTab({
- url: "/pages/my/my"
- })
- }
- }
- // 候补预约请求
- const handleStandby = async () => {
- const res = await myRequest({
- url: '/appwait_appointment.action',
- data: {
- route: currentPath.value,
- card_number: card_number.value,
- hh_end: hh_end.value
- }
- })
- // console.log(res);
- if (res) {
- uni.showToast({
- title: res.message
- })
- currentIndex1.value = null
- currentIndex2.value = null
- currentPath.value = null
- currentBusId.value = null
- uni.switchTab({
- url: "/pages/my/my"
- })
- }
- }
- // 改变选中项回调
- const handleChangeCurrentIndex = (type, index, item) => {
- if (type === 1) {
- currentIndex2.value = null
- currentBusId.value = null
- currentIndex1.value = index
- currentPath.value = item.route
- getBusList()
- } else {
- // 如果车辆不能预约则不进行任何操作
- if (item.can_order == 0) {
- } else {
- currentIndex2.value = index
- currentBusId.value = item.id
- }
- }
- }
- // 切换日期回调
- const handleChangeTime = () => {
- if (dateType.value == "今天") {
- dateType.value = "明天"
- getTimeFormat(1)
- } else {
- dateType.value = "今天"
- getTimeFormat()
- }
- // currentIndex1.value = null
- // currentPath.value = null
- // currentIndex2.value = null
- // currentBusId.value = null
- // busList.value = []
- currentIndex1.value = 0
- currentPath.value = pathList.value[0].route
- currentIndex2.value = null
- currentBusId.value = null
- busList.value = []
- getBusList()
- }
- // 获取格式化时间 日期 和 星期
- const getTimeFormat = (dayType) => {
- let date = new Date()
- if (dayType) {
- let targetday = date.getTime() + 1000 * 60 * 60 * 24
- date.setTime(targetday)
- }
- let month = (date.getMonth() + 1 + '').padStart(2, "0")
- let day = (date.getDate() + '').padStart(2, "0")
- let week = date.getDay()
- let weekArr = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
- currentMonth.value = month
- currentDay.value = day
- currentWeek.value = weekArr[week]
- }
- // 点击电话回调
- const handlePhone = (phone) => {
- uni.makePhoneCall({
- phoneNumber: phone
- });
- }
- </script>
- <style lang="scss" scoped>
- .container {
- background-color: #EBECED;
- .header-time {
- display: flex;
- align-items: center;
- padding: 0 30rpx;
- height: 118rpx;
- background-color: #fff;
- .today,
- .tomorrow {
- width: 72rpx;
- font-size: 24rpx;
- color: #999999;
- }
- .time-info {
- flex: 1;
- display: flex;
- justify-content: center;
- align-items: center;
- font-size: 34rpx;
- span {
- margin: 0 15rpx;
- font-size: 24rpx;
- color: #3D51E8;
- }
- }
- }
- .header-path {
- margin-top: 20rpx;
- padding: 0 30rpx;
- background-color: #fff;
- .path-title {
- line-height: 95rpx;
- font-size: 34rpx;
- font-weight: bold;
- }
- .path-list {
- display: flex;
- justify-content: space-between;
- flex-wrap: wrap;
- .path-item {
- margin-bottom: 20rpx;
- padding: 0 8rpx;
- min-width: 45%;
- line-height: 96rpx;
- text-align: center;
- font-size: 27rpx;
- border-radius: 14rpx;
- background-color: #EBEBEB;
- }
- .active {
- color: #fff;
- background-color: #5C60F3;
- .item-info {
- .item-info-detail {
- color: #fff;
- }
- }
- }
- .unactive {
- color: #A6A6A6;
- .item-info {
- .item-info-detail {
- color: #A6A6A6;
- }
- }
- }
- }
- .path-list-nodata {
- text-align: center;
- color: #999999;
- padding-bottom: 20rpx;
- }
- }
- .carList {
- margin-top: 20rpx;
- padding-bottom: 30rpx;
- min-height: 508rpx;
- background-color: #fff;
- .carList-title {
- padding-left: 30rpx;
- line-height: 95rpx;
- font-size: 34rpx;
- font-weight: bold;
- }
- .carList-item {
- display: flex;
- align-items: center;
- box-sizing: border-box;
- padding: 37rpx 30rpx 32rpx;
- height: 163rpx;
- .item-time {
- position: relative;
- width: 128rpx;
- font-weight: bold;
- }
- .item-time::after {
- content: "";
- height: 77rpx;
- position: absolute;
- top: -15rpx;
- right: 0;
- border-right: 1px solid #A6A6A6;
- }
- .item-info {
- display: flex;
- flex-direction: column;
- justify-content: space-around;
- margin-left: 50rpx;
- height: 100%;
- .item-info-place {
- font-weight: bold;
- }
- .item-info-detail {
- color: #999999;
- font-size: 26rpx;
- span {
- margin-left: 20rpx;
- }
- }
- }
- }
- .active {
- color: #fff;
- background-color: #5C60F3;
- .item-info {
- .item-info-detail {
- color: #fff;
- }
- }
- }
- .unactive {
- color: #A6A6A6;
- .item-info {
- .item-info-detail {
- color: #A6A6A6;
- }
- }
- }
- .carList-nodata {
- padding: 0 30rpx;
- text-align: center;
- img {
- height: 508rpx;
- }
- .nodata-info {
- padding-bottom: 10rpx;
- color: #999999;
- }
- }
- }
- .btn-box {
- padding: 0 30rpx;
- background-color: #fff;
- .btn {
- position: relative;
- display: flex;
- align-items: center;
- width: 690rpx;
- height: 95rpx;
- border-radius: 15rpx;
- box-shadow: 0px 0px 12rpx rgba(0, 0, 0, .12);
- .btn-clock {
- margin-left: 30rpx;
- width: 61rpx;
- height: 61rpx;
- img {
- width: 100%;
- }
- }
- .btn-info {
- margin-left: 18rpx;
- flex: 1;
- display: flex;
- flex-direction: column;
- justify-content: center;
- font-size: 24rpx;
- color: #5863F1;
- .btn-info-title {
- margin-bottom: 8rpx;
- }
- .btn-info-title2 {
- font-size: 28rpx;
- margin-bottom: 8rpx;
- }
- .btn-info-time {
- color: #B3B3B3;
- }
- }
- .btn-button {
- position: absolute;
- right: 0;
- top: -7rpx;
- width: 257rpx;
- height: 113rpx;
- line-height: 113rpx;
- text-align: center;
- font-size: 30rpx;
- color: #fff;
- background: url(../../static/box.png);
- background-size: 100% 100%;
- }
- }
- }
- .box-info {
- padding: 30rpx 30rpx 40rpx;
- background-color: #fff;
- .info-title {
- height: 41rpx;
- font-size: 28rpx;
- color: #666666;
- }
- .info-detail {
- margin-top: 5rpx;
- color: #999999;
- font-size: 24rpx;
- }
- }
- }
- </style>
|