682 lines
16 KiB
Vue
682 lines
16 KiB
Vue
<template>
|
||
<view>
|
||
<view class="container">
|
||
<view class="banner-box"><image src="/static/imgs/banner-b.png" mode=""></image></view>
|
||
<view class="main">
|
||
<view class="tab-box">
|
||
<view class="tab-item" :class="currentTabIndex == 0 ? 'active_tab' : ''" @click="currentTabIndex = 0">洗车预约</view>
|
||
<view class="tab-item" :class="currentTabIndex == 1 ? 'active_tab' : ''" @click="currentTabIndex = 1">预约记录</view>
|
||
</view>
|
||
<!-- 预约表单 -->
|
||
<view class="reservation-box" v-if="currentTabIndex == 0">
|
||
<scroll-view scroll-x="true" class="scroll-view">
|
||
<view class="time-item-box" :class="chooseDateIndex == index ? 'time-active' : ''" v-for="(item, index) in date" :key="index" @click="switchTab(index)">
|
||
<text class="time">{{ item.tiems.substr(5, 10) }}</text>
|
||
<text class="week">{{ item.week }}</text>
|
||
</view>
|
||
</scroll-view>
|
||
|
||
<view class="time-box">
|
||
<view
|
||
class="time-item"
|
||
:class="chooseTimeIndex == index ? 'active' : ''"
|
||
@click="chooseTime(index, item.count)"
|
||
v-for="(item, index) in times"
|
||
:key="index"
|
||
>
|
||
<view class="time-text">{{ item.time }}</view>
|
||
<view class="time-text">
|
||
余
|
||
<text :class="item.count <= 0 ? 'color-666' : ''">{{ item.count }}</text>
|
||
位
|
||
</view>
|
||
<image class="icon" src="/static/imgs/handel.png" mode=""></image>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="form-box">
|
||
<view class="form-item">
|
||
<text class="label">地点</text>
|
||
<view class="ipt-box select">
|
||
<image class="arrow" src="/static/icons/right-arrow.png" mode=""></image>
|
||
<picker class="picker" v-if="places.length > 0" :range="places" @change="changePlace" range-key="name">
|
||
<view>{{ places[placeIndex] }}</view>
|
||
</picker>
|
||
</view>
|
||
</view>
|
||
<view class="form-item">
|
||
<text class="label">车牌号</text>
|
||
<view class="ipt-box">
|
||
<input-autocomplete
|
||
class="AUTO"
|
||
v-model="carId"
|
||
placeholder="请输入车牌号"
|
||
placeholderStyle="font-size:30upx"
|
||
highlightColor="#FF0000"
|
||
:loadData="loadAutocompleteData"
|
||
v-on:selectItem="selectItemD"
|
||
></input-autocomplete>
|
||
<!-- <input type="text" placeholder="请填写车牌号" v-model="carId"> -->
|
||
</view>
|
||
</view>
|
||
<view class="form-item">
|
||
<text class="label">联系人</text>
|
||
<view class="ipt-box"><input type="text" placeholder="请填写预约人姓名" v-model="applyPersonName" /></view>
|
||
</view>
|
||
<view class="form-item">
|
||
<text class="label">联系电话</text>
|
||
<view class="ipt-box"><input type="number" placeholder="请填写预约人手机号" v-model="applyPersonMobile" /></view>
|
||
</view>
|
||
</view>
|
||
<!-- <view class="evaluate">
|
||
<view class="title">用户评价</view>
|
||
<view class="evaluate_item" v-for="(item,index) in commentList" :key="index">
|
||
<view class="user">
|
||
<text class="username input_left">{{item.userName}}</text>
|
||
<text>
|
||
<image v-for="(star,index) in item.level" :key="index" src="../../static/imgs/showstar.png" alt="">
|
||
</text>
|
||
</view>
|
||
<view class="text">{{item.content}}</view>
|
||
</view>
|
||
</view> -->
|
||
</view>
|
||
|
||
<!-- 预约记录列表 -->
|
||
<view v-else>
|
||
<view class="list-box" v-if="reservationList.length > 0">
|
||
<view class="detail" v-for="(item, index) in reservationList" :key="index">
|
||
<view class="detail_header">
|
||
<text class="blueSign"></text>
|
||
<text class="font-tilte">洗车预约</text>
|
||
<!-- <text class="slect_icon"></text> -->
|
||
<text class="font-result">{{ item.status }}</text>
|
||
</view>
|
||
<view class="detail_msg">
|
||
<view class="info-item">
|
||
<text>预约时间:</text>
|
||
<text class="infoSpan">{{ item.timeQ }}</text>
|
||
</view>
|
||
<view class="info-item">
|
||
<text>申请人:</text>
|
||
<text class="infoSpan">{{ item.userName }}</text>
|
||
</view>
|
||
<view class="info-item">
|
||
<text>申请时间:</text>
|
||
<text class="infoSpan">{{ formatDate(item.apply_time, 'dateTime') }}</text>
|
||
</view>
|
||
<view class="info-item">
|
||
<text>联系人:</text>
|
||
<text class="infoSpan">{{ item.concatUserName }}</text>
|
||
</view>
|
||
<view class="info-item">
|
||
<text>申请电话:</text>
|
||
<text class="infoSpan">{{ item.concatPhone }}</text>
|
||
</view>
|
||
<view class="comment-btn" v-if="item.conmentStatus == 0" @click="goEvaluatePage(item.detailId)">评价</view>
|
||
<view class="comment-btn bg-ccc" v-if="item.conmentStatus == 1">已评价</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<content-none v-else :padTop="20"></content-none>
|
||
</view>
|
||
<view v-if="currentTabIndex == 0">
|
||
<view class="occupied"></view>
|
||
<view class="footer-btn"><view class="btn" @click="submit">提交预约</view></view>
|
||
</view>
|
||
<load-more v-if="currentTabIndex == 1" :loadingType="loadingType" :contentText="contentText"></load-more>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import { getDate, alertTip, callbackRequest, getStorage, regPhone, formatDate } from '@/common/util.js';
|
||
import { getAllDept, initWashCar, applyWashCar, getMyWashCarList } from '@/common/api.js';
|
||
import loadMore from '@/components/loadMore.vue';
|
||
import contentNone from '@/components/contentNone.vue';
|
||
import inputAutocomplete from '@/components/input-autocomplete/input-autocomplete.vue';
|
||
export default {
|
||
components: {
|
||
loadMore,
|
||
contentNone,
|
||
inputAutocomplete
|
||
},
|
||
data() {
|
||
return {
|
||
page: 1,
|
||
pageSize: 10,
|
||
loadingType: 0, //0-loading前;1-loading中;2-没有更多了
|
||
contentText: {
|
||
contentdown: '上拉加载更多',
|
||
contentrefresh: '正在加载...',
|
||
contentnomore: '没有更多数据了'
|
||
},
|
||
userId: getStorage('userInfo').id,
|
||
currentTabIndex: 0,
|
||
date: getDate(), //获取近30天日期
|
||
chooseDateIndex: 0, //选中的日期
|
||
times: [
|
||
{ id: '1', time: '08:30-09:15', count: 1 },
|
||
{ id: '2', time: '09:15-10:00', count: 1 },
|
||
{ id: '3', time: '10:00-10:45', count: 1 },
|
||
{ id: '4', time: '10:45-11:30', count: 1 },
|
||
{ id: '5', time: '11:30-12:15', count: 1 },
|
||
{ id: '6', time: '12:15-13:00', count: 1 },
|
||
{ id: '7', time: '13:00-13:45', count: 1 },
|
||
{ id: '8', time: '13:45-14:30', count: 1 },
|
||
{ id: '9', time: '14:30-15:15', count: 1 },
|
||
{ id: '10', time: '15:15-16:00', count: 1 },
|
||
{ id: '11', time: '16:00-16:45', count: 1 },
|
||
{ id: '12', time: '16:45-17:30', count: 1 }
|
||
],
|
||
chooseTimeIndex: null,
|
||
deptList: [], //部门列表
|
||
places: ['科技楼', '后勤中心'],
|
||
placeIndex: 0,
|
||
departmentIndex: 0, //选择的部门下标
|
||
applyPersonName: getStorage('userInfo').username, //申请人姓名
|
||
applyPersonMobile: getStorage('userInfo').telnumber, //申请人手机
|
||
carId: '',
|
||
commentList: [],
|
||
reservationList: [],
|
||
formatDate: formatDate
|
||
};
|
||
},
|
||
onLoad(option) {
|
||
this.currentTabIndex = option.currentTabIndex || 0;
|
||
// 部门
|
||
this.getDepartment();
|
||
if (this.currentTabIndex == 0) {
|
||
this.initData();
|
||
}
|
||
},
|
||
watch: {
|
||
currentTabIndex: function(newVal, oldVal) {
|
||
if (newVal == 1) {
|
||
this.page = 1;
|
||
this.loadingType = 0;
|
||
this.getReservationRecord();
|
||
} else {
|
||
this.initData();
|
||
}
|
||
}
|
||
},
|
||
methods: {
|
||
// 根据输入内容动态加载数据
|
||
loadAutocompleteData(value) {
|
||
console.log('每次输入经过防抖处理以后都会进到这里');
|
||
console.log('此参数就是输入框的值:', value);
|
||
// 【注意】:由于此方法是组件调用进来的,这里的this对象已经不是指向当前页面了
|
||
// 所以无法在这里通过this去取当前页面的数据;
|
||
// 基于同样的原因,也无法通过this去调用当前页的其它方法。
|
||
// 【正确的做法】:在这个方法内写完所有取数据的逻辑,如果需要用输入框的值则取这里的value参数
|
||
//可以通过$root拿到当前页面的引用,从而访问当前页面的数据
|
||
let that = this.$root;
|
||
console.log('访问当前页的数据:', that.places);
|
||
return Promise.resolve(['皖AT0110A', '皖AT0110B', '皖AT0110C']);
|
||
},
|
||
//响应选择事件,接收选中的数据
|
||
selectItemD(data) {
|
||
console.log('收到数据了:', data);
|
||
},
|
||
initData() {
|
||
let params = {
|
||
method: initWashCar,
|
||
data: {
|
||
applyDate: this.date[this.chooseDateIndex].tiems,
|
||
userId: this.userId
|
||
}
|
||
};
|
||
callbackRequest(params).then(res => {
|
||
if (res.data.returnCode == 1) {
|
||
// this.times = res.data.returnData.timeList;
|
||
// 部门列表下拉框 默认显示自己的部门
|
||
var deptId = res.data.returnData.deptId;
|
||
var that = this;
|
||
if (deptId) {
|
||
that.deptList.forEach(function(item, index) {
|
||
if (item.id == deptId) {
|
||
that.departmentIndex = index;
|
||
}
|
||
});
|
||
}
|
||
// 评论
|
||
that.commentList = res.data.returnData.comments;
|
||
}
|
||
});
|
||
},
|
||
//获取部门列表
|
||
getDepartment() {
|
||
let data = {
|
||
method: getAllDept,
|
||
data: {}
|
||
};
|
||
callbackRequest(data).then(res => {
|
||
if (res.data.returnCode == 1) {
|
||
this.deptList = res.data.returnData;
|
||
}
|
||
});
|
||
},
|
||
//获取预约记录列表
|
||
getReservationRecord() {
|
||
let params = {
|
||
method: getMyWashCarList,
|
||
data: {
|
||
pageSize: this.pageSize,
|
||
pageNum: this.page,
|
||
userId: this.userId
|
||
}
|
||
};
|
||
callbackRequest(params).then(res => {
|
||
if (res.data.returnCode == 1) {
|
||
if (this.page == 1) {
|
||
this.reservationList = res.data.returnData;
|
||
} else {
|
||
if (res.data.returnData.length > 0) {
|
||
this.reservationList = [...this.reservationList, ...res.data.returnData];
|
||
this.loadingType = 0;
|
||
} else {
|
||
this.loadingType = 2;
|
||
}
|
||
}
|
||
}
|
||
});
|
||
},
|
||
//选择日期
|
||
switchTab(index) {
|
||
this.chooseDateIndex = index;
|
||
this.initData();
|
||
},
|
||
//选择时间段
|
||
chooseTime(index, num) {
|
||
if (num == 0) {
|
||
alertTip('该时间段已约满,请选择其它时间段');
|
||
this.chooseTimeIndex = null;
|
||
return false;
|
||
} else {
|
||
this.chooseTimeIndex = index;
|
||
}
|
||
},
|
||
changePlace(e) {
|
||
this.placeIndex = e.detail.value;
|
||
},
|
||
//提交预约
|
||
submit() {
|
||
if (this.chooseTimeIndex == null) {
|
||
alertTip('请选择预约时间段');
|
||
return false;
|
||
} else if (!this.applyPersonName) {
|
||
alertTip('请输入预约人姓名');
|
||
return false;
|
||
} else if (!regPhone.test(this.applyPersonMobile)) {
|
||
alertTip('请输入正确的手机号');
|
||
return false;
|
||
}
|
||
let params = {
|
||
method: applyWashCar,
|
||
data: {
|
||
userId: this.userId,
|
||
applyDate: this.date[this.chooseDateIndex].tiems,
|
||
applyTime: this.times[this.chooseTimeIndex].time,
|
||
applyTimeId: this.times[this.chooseTimeIndex].timeId,
|
||
deptId: this.deptList[this.departmentIndex].id,
|
||
deptName: this.deptList[this.departmentIndex].name,
|
||
concatUserName: this.applyPersonName,
|
||
concatPhone: this.applyPersonMobile
|
||
}
|
||
};
|
||
callbackRequest(params).then(res => {
|
||
if (res.data.returnCode == 1) {
|
||
alertTip('预约成功');
|
||
this.page = 1;
|
||
this.loadingType = 0;
|
||
setTimeout(_ => {
|
||
this.applyPersonName = '';
|
||
this.applyPersonMobile = '';
|
||
this.chooseTimeIndex = null;
|
||
this.currentTabIndex = 1;
|
||
}, 2000);
|
||
} else {
|
||
alertTip(res.data.returnMsg);
|
||
}
|
||
});
|
||
},
|
||
//去评价页面
|
||
goEvaluatePage(id) {
|
||
uni.navigateTo({
|
||
url: `/pages/order-form/evaluate?type=5&typeId=${id}`
|
||
});
|
||
}
|
||
},
|
||
onReachBottom() {
|
||
if (this.loadingType !== 0 || this.currentTabIndex != 1) {
|
||
return;
|
||
}
|
||
this.loadingType = 1;
|
||
this.page = this.page + 1;
|
||
this.getReservationRecord();
|
||
}
|
||
};
|
||
</script>
|
||
|
||
<style lang="scss">
|
||
@import '@/static/css/common.scss';
|
||
|
||
.container {
|
||
position: relative;
|
||
overflow: hidden;
|
||
min-height: 100vh;
|
||
background: #f8f8f8;
|
||
|
||
.banner-box {
|
||
width: 100%;
|
||
height: 240upx;
|
||
position: absolute;
|
||
top: 0;
|
||
left: 0;
|
||
|
||
image {
|
||
width: 100%;
|
||
height: 100%;
|
||
}
|
||
}
|
||
|
||
.main {
|
||
margin: 172upx 40upx 0;
|
||
position: relative;
|
||
z-index: 10;
|
||
|
||
.tab-box {
|
||
overflow: hidden;
|
||
border-radius: 10upx 10upx 0 0;
|
||
background: rgba(132, 149, 167, 0.8);
|
||
height: 70upx;
|
||
|
||
.tab-item {
|
||
float: left;
|
||
height: 70upx;
|
||
width: 50%;
|
||
font-size: 30upx;
|
||
color: #e5f6ff;
|
||
text-align: center;
|
||
line-height: 70upx;
|
||
}
|
||
|
||
.active_tab {
|
||
background: #fff;
|
||
color: #333;
|
||
border-radius: 10upx 10upx 0 0;
|
||
font-weight: bold;
|
||
}
|
||
}
|
||
|
||
.reservation-box {
|
||
background: #fff;
|
||
|
||
.time-box {
|
||
overflow: hidden;
|
||
padding-top: 20rpx;
|
||
|
||
.time-item {
|
||
float: left;
|
||
width: 196rpx;
|
||
margin: 0 0rpx 20rpx 20rpx;
|
||
font-size: 26rpx;
|
||
text-align: center;
|
||
line-height: 32rpx;
|
||
padding: 10rpx 0;
|
||
position: relative;
|
||
border: 1px solid #ccc;
|
||
box-sizing: border-box;
|
||
|
||
.time-text {
|
||
color: #666;
|
||
|
||
text {
|
||
padding: 0 6rpx;
|
||
color: #00c277;
|
||
}
|
||
|
||
.color-666 {
|
||
color: #666;
|
||
}
|
||
}
|
||
|
||
.icon {
|
||
position: absolute;
|
||
right: 0;
|
||
bottom: 0;
|
||
width: 36rpx;
|
||
height: 36rpx;
|
||
display: none;
|
||
}
|
||
}
|
||
|
||
.active {
|
||
border: 1px solid #00c277;
|
||
|
||
.icon {
|
||
display: block;
|
||
}
|
||
}
|
||
}
|
||
|
||
.form-box {
|
||
// padding: 20upx 30upx 50upx;
|
||
background: #fff;
|
||
|
||
.form-item {
|
||
overflow: hidden;
|
||
border-bottom: 1px solid #eee;
|
||
padding: 30upx;
|
||
|
||
.label {
|
||
float: left;
|
||
width: 150upx;
|
||
font-size: 28upx;
|
||
color: #333;
|
||
font-weight: bold;
|
||
line-height: 50upx;
|
||
}
|
||
|
||
.ipt-box {
|
||
margin-left: 160upx;
|
||
input {
|
||
width: 100%;
|
||
height: 50upx;
|
||
line-height: 50upx;
|
||
font-size: 26upx;
|
||
color: #666;
|
||
}
|
||
.AUTO {
|
||
width: 100%;
|
||
height: 30upx;
|
||
line-height: 30upx;
|
||
font-size: 26upx;
|
||
color: #666;
|
||
}
|
||
}
|
||
|
||
.select {
|
||
.arrow {
|
||
float: right;
|
||
width: 16upx;
|
||
height: 29upx;
|
||
margin-top: 10upx;
|
||
}
|
||
|
||
.picker {
|
||
height: 50upx;
|
||
line-height: 50upx;
|
||
font-size: 26upx;
|
||
color: #666;
|
||
}
|
||
}
|
||
}
|
||
|
||
.form-item:last-child {
|
||
border-bottom: 0px;
|
||
}
|
||
}
|
||
|
||
/* 评论 */
|
||
.evaluate {
|
||
padding-top: 30upx;
|
||
border-top: 1px solid #eee;
|
||
}
|
||
|
||
.evaluate .title {
|
||
font-size: 28upx;
|
||
color: #333;
|
||
font-weight: bold;
|
||
line-height: 40upx;
|
||
padding: 0 30rpx 30rpx;
|
||
}
|
||
|
||
.evaluate .evaluate_item {
|
||
border-bottom: 1px solid #eeeeee;
|
||
padding: 0 0 30upx 50upx;
|
||
}
|
||
|
||
.evaluate .evaluate_item:last-child {
|
||
border: none;
|
||
}
|
||
|
||
.evaluate .evaluate_item .user {
|
||
padding: 20upx 0;
|
||
}
|
||
|
||
.evaluate .evaluate_item .user .username {
|
||
font-size: 28rpx;
|
||
color: #666;
|
||
display: inline-block;
|
||
vertical-align: top;
|
||
padding-right: 20upx;
|
||
}
|
||
|
||
.evaluate .evaluate_item .user span image {
|
||
width: 40upx;
|
||
height: 40upx;
|
||
margin-right: 5upx;
|
||
}
|
||
|
||
.evaluate .evaluate_item .text {
|
||
font-size: 28upx;
|
||
color: #666;
|
||
line-height: 40upx;
|
||
}
|
||
}
|
||
}
|
||
|
||
.scroll-view {
|
||
padding-top: 30upx;
|
||
white-space: nowrap;
|
||
width: 100%;
|
||
height: 120upx;
|
||
|
||
.time-item-box {
|
||
padding: 0 10upx;
|
||
margin: 0 16upx;
|
||
display: inline-block;
|
||
|
||
.time {
|
||
display: block;
|
||
width: 100%;
|
||
font-size: 28upx;
|
||
color: #666;
|
||
}
|
||
|
||
.week {
|
||
display: block;
|
||
width: 100%;
|
||
font-size: 28upx;
|
||
color: #666;
|
||
}
|
||
}
|
||
|
||
.time-active {
|
||
.time {
|
||
color: #00c277;
|
||
}
|
||
|
||
.week {
|
||
color: #00c277;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
.list-box {
|
||
.detail {
|
||
// margin-top: 10upx;
|
||
margin-bottom: 14upx;
|
||
background: #ffffff;
|
||
border-radius: 4upx;
|
||
}
|
||
|
||
.detail_header {
|
||
padding: 15upx 30upx;
|
||
border-bottom: 1px solid #eee;
|
||
}
|
||
|
||
.detail_header .blueSign {
|
||
height: 30upx;
|
||
width: 10upx;
|
||
background: #00c277;
|
||
display: inline-block;
|
||
margin: 10upx 14upx 0 0;
|
||
}
|
||
|
||
.detail_header .font-tilte {
|
||
display: inline-block;
|
||
font-size: 28upx;
|
||
color: #333;
|
||
line-height: 50upx;
|
||
vertical-align: top;
|
||
}
|
||
|
||
.detail_header .font-result {
|
||
display: inline-block;
|
||
float: right;
|
||
font-size: 26upx;
|
||
color: #00c277;
|
||
line-height: 50upx;
|
||
vertical-align: top;
|
||
}
|
||
|
||
.detail_msg {
|
||
padding: 20upx 30upx;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.detail_msg .info-item {
|
||
margin-bottom: 10upx;
|
||
font-size: 28upx;
|
||
|
||
text {
|
||
display: inline-block;
|
||
width: 140upx;
|
||
}
|
||
|
||
.infoSpan {
|
||
width: auto;
|
||
font-size: 28upx;
|
||
color: #666;
|
||
float: right;
|
||
}
|
||
}
|
||
|
||
.comment-btn {
|
||
float: right;
|
||
font-size: 24upx;
|
||
border-radius: 10upx;
|
||
color: #fff;
|
||
line-height: 50upx;
|
||
text-align: center;
|
||
min-width: 140upx;
|
||
background-color: #00c277;
|
||
}
|
||
}
|
||
</style>
|