lanan-repair/pages/myReservation/addReservation.vue

602 lines
14 KiB
Vue
Raw Normal View History

2024-09-22 15:07:01 +08:00
<template>
<view class="container">
<VNavigationBar background-color="rgba(0,0,0,0)" title-color="#333" title="提交预约"></VNavigationBar>
<view class="body">
<view class="carInfo">
<view class="cardInfoHeader">
<view class="carInfoLeftTop">
<image class="carInfoLeftTopIcon" src="../../static/icons/order-icon10.png" mode="widthFix">
</image>
车辆信息
</view>
<view class="carInfoRightTop">
2024-09-24 22:42:08 +08:00
<!-- <uni-icons type="compose" color="#0174F6"></uni-icons> -->
<span style="color: #0174F6;" @click="selectCar">选择车辆</span>
2024-09-22 15:07:01 +08:00
</view>
</view>
<view class="cardInfoBody">
<view class="cardInfoBody_content">
<view class="carForm">
2024-09-24 22:42:08 +08:00
<view class="carForm_num">车牌号{{car.licenseNumber}}</view>
<view class="carForm_carName">车辆持有人{{cusInfo.cusName}}</view>
<view class="carForm_carPhone">持有人电话{{cusInfo.phoneNumber}}</view>
2024-09-22 15:07:01 +08:00
</view>
2024-09-25 10:09:50 +08:00
<image class="carImg" src="" mode="aspectFill" :src="config.baseImageUrl + car.logoImg"></image>
2024-09-22 15:07:01 +08:00
</view>
<view class="cardInfoBody_footer">
<view class="nj">
2024-09-24 22:42:08 +08:00
年检时间<text class="date">{{car.insuranceDate || '未获取到'}}</text>
2024-09-22 15:07:01 +08:00
<image class="cardInfoBody_footerIcon" src="../../static/icons/icon2.png" mode="aspectFit">
</image>
</view>
<view class="bx">
2024-09-24 22:42:08 +08:00
保险时间<text class="date">{{car.nextInspectionDate || '未获取到'}}</text>
2024-09-22 15:07:01 +08:00
<image class="cardInfoBody_footerIcon" src="../../static/icons/icon2.png" mode="aspectFit">
</image>
</view>
</view>
</view>
</view>
<view class="baseInfo">
<view class="formItem">
<view class="formItem_content">
<view class="label">姓名</view>
2024-09-24 22:42:08 +08:00
<input class="formItemInput" placeholder="请输入姓名" type="text" v-model="formData.userName" />
2024-09-22 15:07:01 +08:00
</view>
</view>
<view class="formItem">
<view class="formItem_content">
<view class="label">联系电话</view>
2024-09-24 22:42:08 +08:00
<input class="formItemInput" placeholder="请输入联系电话" type="text" v-model="formData.userMobile"/>
2024-09-22 15:07:01 +08:00
</view>
</view>
<view class="formItem">
2024-09-24 22:42:08 +08:00
<!-- <picker mode="selector" :range="['汽车维修']" @change="">
2024-09-22 15:07:01 +08:00
<view class="formItem_content">
<view class="label">预约项目</view>
<input disabled class="formItemInput" placeholder="请选择预约项目" type="text" />
<image class="formItemBtn" src="../../static/icons/homeInfoMore.png" mode="aspectFit">
</image>
</view>
2024-09-24 22:42:08 +08:00
</picker> -->
<view class="formItem_content" @click="selectServer">
<view class="label">预约项目</view>
<input disabled class="formItemInput" placeholder="请选择预约项目" type="text" v-model="service.name" />
<image v-if="!service.name" class="formItemBtn" src="../../static/icons/homeInfoMore.png" mode="aspectFit">
</image>
</view>
2024-09-22 15:07:01 +08:00
</view>
</view>
<view class="dateCard">
<view class="cardTitle">预约时间</view>
<view class="datePicker">
<view v-for="(date, index) in dateList" :key="date.date" class="dateItem"
:class="{active: chooseDate === date.date, disabled: date.disabled}"
@click="chooseDateFun(date)">
<text>{{date.date}}</text>
<text>{{date.title}}</text>
2024-09-24 22:42:08 +08:00
<image v-if="chooseDate === date.date" class="activeIcon"
src="../../static/icons/order-icon11.png" mode="aspectFit"></image>
2024-09-22 15:07:01 +08:00
</view>
</view>
<view class="timerPicker">
<view v-for="(time, index) in timeList" :key="index" class="timeItem"
:class="{active: chooseTime === time.time, disabled: time.disabled}"
@click="chooseTimeFun(time)">
<text>{{time.time}}</text>
2024-09-24 22:42:08 +08:00
<image v-if="chooseTime === time.time" class="activeIcon"
src="../../static/icons/order-icon11.png" mode="aspectFit"></image>
2024-09-22 15:07:01 +08:00
</view>
</view>
</view>
</view>
<view class="footer">
<view class="footerBtn" @click="submit">提交预约</view>
</view>
</view>
</template>
<script>
2024-09-24 22:42:08 +08:00
import request from '../../utils/request';
2024-09-22 15:07:01 +08:00
import VNavigationBar from '@/components/VNavigationBar.vue'
2024-09-25 10:09:50 +08:00
import config from "@/config";
2024-09-27 17:57:20 +08:00
import {getUserInfoRequest} from "@/utils/common.js";
2024-09-28 11:22:55 +08:00
import {getToken,getUserInfo} from '@/utils/auth.js'
2024-09-22 15:07:01 +08:00
export default {
components: {
VNavigationBar,
},
2024-09-25 10:09:50 +08:00
computed: {
config() {
return config
}
},
2024-09-22 15:07:01 +08:00
data() {
return {
2024-09-25 10:22:50 +08:00
// dateList: [{
// date: '06-05',
// title: '周四',
// disabled: true
// }, {
// date: '06-06',
// title: '周四',
// disabled: false
// }, {
// date: '06-07',
// title: '周四',
// disabled: false
// }, {
// date: '06-08',
// title: '周四',
// disabled: false
// }, {
// date: '06-09',
// title: '周四',
// disabled: false
// }, ],
dateList:[],
2024-09-22 15:07:01 +08:00
chooseDate: '06-06',
2024-09-25 10:22:50 +08:00
chooseTime: '11:00',
2024-09-22 15:07:01 +08:00
timeList: [{
2024-09-24 22:42:08 +08:00
time: '09:00',
2024-09-22 15:07:01 +08:00
disabled: false
},
{
2024-09-24 22:42:08 +08:00
time: '11:00',
2024-09-22 15:07:01 +08:00
disabled: false
},
{
2024-09-24 22:42:08 +08:00
time: '14:00',
2024-09-22 15:07:01 +08:00
disabled: false
},
{
2024-09-24 22:42:08 +08:00
time: '15:00',
2024-09-22 15:07:01 +08:00
disabled: false
},
{
2024-09-24 22:42:08 +08:00
time: '16:00',
2024-09-22 15:07:01 +08:00
disabled: false
},
{
2024-09-24 22:42:08 +08:00
time: '17:00',
2024-09-22 15:07:01 +08:00
disabled: false
},
2024-09-24 22:42:08 +08:00
],
carList: [],
car:{},
cusInfo: {},
formData:{
userName: null,
userMobile: null,
projectId: null,
carId: null,
carNo: null,
bookingTime: null,
corpId: null
},
serviceList: [],
service:{},
info: {}
2024-09-22 15:07:01 +08:00
};
},
2024-09-24 22:42:08 +08:00
onLoad(data){
this.info = JSON.parse(decodeURIComponent(data.info))
this.formData.corpId = this.info.id
this.getServer(this.info.id)
},
onShow() {
2024-09-27 17:21:10 +08:00
if(!getToken()){
uni.reLaunch({
url: '/pages/login/login'
})
}else{
console.log("已登录")
this.getUserInfos()
}
2024-09-24 22:42:08 +08:00
this.initCarList()
2024-09-25 10:22:50 +08:00
this.initDateList()
2024-09-24 22:42:08 +08:00
},
2024-09-22 15:07:01 +08:00
methods: {
2024-09-27 17:21:10 +08:00
//获取当前登录用户信息
async getUserInfos() {
console.log("获取用户信息")
2024-09-27 17:57:20 +08:00
getUserInfo()
2024-09-27 17:21:10 +08:00
},
2024-09-25 10:22:50 +08:00
initDateList(){
const daysOfWeek = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
const currentDate = new Date();
const weekDates = [];
// 获取今天是一周中的第几天0表示周日1表示周一以此类推
const todayDayOfWeek = currentDate.getDay();
// 计算本周的第一天(周日)
currentDate.setDate(currentDate.getDate() - todayDayOfWeek);
for (let i = 0; i < 7; i++) {
// 格式化日期为 'MM-DD' 格式
let dateStr = `${currentDate.getMonth() + 1}-${currentDate.getDate()}`;
// 获取当天的标题
let title = daysOfWeek[currentDate.getDay()];
// 当天及之前的日期disabled为true之后的日期disabled为false
let disabled = currentDate < new Date(); // 当前日期小于等于计算日期
// 将日期对象添加到结果数组中
weekDates.push({ date: dateStr, title, disabled });
// 移动到下一天
currentDate.setDate(currentDate.getDate() + 1);
}
// 单独拿出当天的日期信息
this.chooseDate = weekDates.find(day => day.disabled === false).date;
this.dateList = weekDates;
},
2024-09-22 15:07:01 +08:00
chooseTimeFun(time) {
if (time.disabled) {
return
}
this.chooseTime = time.time
},
chooseDateFun(date) {
if (date.disabled) {
return
}
this.chooseDate = date.date
},
submit() {
2024-09-26 10:43:07 +08:00
this.formData.bookingTime = new Date((new Date().getFullYear() + "-" + this.chooseDate + " " + this.chooseTime + ":00")).getTime()
2024-09-24 22:42:08 +08:00
request({
url: "/userClient/repair/booking/update",
method: "post",
data: this.formData
}).then(res => {
uni.redirectTo({
url: '/pages/myReservation/reservationSuccess?info=' + encodeURIComponent(JSON.stringify(this.info))
})
}).catch(() => {})
2024-09-25 10:09:50 +08:00
2024-09-24 22:42:08 +08:00
},
async initCarList() {
const res = await request({
url: "/userClient/base/myCar/get",
method: "get"
2024-09-22 15:07:01 +08:00
})
2024-09-24 22:42:08 +08:00
this.carList = res.data
if(this.carList && this.carList.length > 0){
this.car = this.carList[0]
this.formData.carId = this.car.id
this.formData.carNo = this.car.licenseNumber
this.selectCusInfo(this.car.id)
}
},
// 车辆选择
selectCar() {
const carNos = this.carList.map(item => item.licenseNumber)
uni.showActionSheet({
itemList: carNos,
success: (res) => {
this.car = this.carList[res.tapIndex]
this.formData.carId = this.car.id
this.formData.carNo = this.car.licenseNumber
this.selectCusInfo(this.car.id)
},
fail: (err) => {
console.error('选择框显示失败:', err);
}
});
},
// 反查客户信息
async selectCusInfo(carId){
const res = await request({
url: "/userClient/customer/getByCarId?carId=" + carId,
method: "get"
})
this.cusInfo = res.data
this.formData.userName = this.cusInfo.userName
this.formData.userMobile = this.cusInfo.userMobile
},
// 取服务
async getServer(corpId) {
const res = await request({
url: "/userClient/base/company/get",
method: 'get',
params: {
id: corpId
}
})
this.serviceList = res.data.servicePackages
},
// 选择服务
selectServer(){
const servers = this.serviceList.map(item => item.name)
uni.showActionSheet({
itemList: servers,
success: (res) => {
this.service = this.serviceList[res.tapIndex]
this.formData.projectId = this.service.id
this.info.serviceName = this.service.name
},
fail: (err) => {
console.error('选择框显示失败:', err);
}
});
2024-09-22 15:07:01 +08:00
}
}
}
</script>
<style lang="less" scoped>
.container {
height: 100%;
display: flex;
flex-direction: column;
background: linear-gradient(180deg, #C1DEFF 0%, rgba(193, 222, 255, 0) 100%);
background-size: 100% 500rpx;
background-repeat: no-repeat;
}
.body {
flex: 1;
height: 0;
overflow: auto;
background: linear-gradient(180deg, rgba(193, 222, 255, 0) 0%, #F3F5F7 50%, #F3F5F7 100%);
.carInfo {
margin: 20rpx 32rpx 30rpx;
background: #022B9A;
box-shadow: 0rpx 8rpx 16rpx 0rpx rgba(10, 54, 104, 0.1);
border-radius: 16rpx 16rpx 16rpx 16rpx;
overflow: hidden;
.cardInfoHeader {
display: flex;
align-items: stretch;
}
.carInfoLeftTop {
display: flex;
align-items: center;
column-gap: 10rpx;
padding: 20rpx;
color: #fff;
.carInfoLeftTopIcon {
width: 36rpx;
}
}
.carInfoRightTop {
flex: 1;
width: 0;
background-color: #fff;
text-align: right;
padding-right: 20rpx;
display: flex;
align-items: center;
justify-content: flex-end;
border: 10rpx;
clip-path: polygon(20rpx 0, 100% 0, 100% 0, 100% 100%, 100% 100%, 0 100%, 10rpx 10rpx);
}
.cardInfoBody {
padding: 30rpx;
background-color: #fff;
border-radius: 16rpx 0rpx 0 0;
}
.cardInfoBody_content {
display: flex;
align-items: stretch;
column-gap: 32rpx;
padding-bottom: 20rpx;
border-bottom: 1rpx dashed #858BA0;
.carForm {
padding: 10rpx 0;
display: flex;
flex-direction: column;
justify-content: space-between;
font-weight: 500;
font-size: 28rpx;
color: #858BA0;
flex: 1;
width: 0;
}
.carForm_num {
font-weight: bold;
font-size: 36rpx;
color: #333333;
}
.carImg {
width: 240rpx;
height: 150rpx;
border-radius: 8rpx 8rpx 8rpx 8rpx;
background-color: #efefef;
}
}
.cardInfoBody_footer {
display: flex;
align-items: center;
font-weight: 500;
font-size: 28rpx;
color: #333333;
padding-top: 20rpx;
.nj {
border-right: 1rpx solid #ddd;
margin-right: 20rpx;
}
.nj,
.bx {
flex: 1;
width: 0;
display: flex;
align-items: center;
column-gap: 10rpx;
}
.date {
color: #0174F6;
}
.cardInfoBody_footerIcon {
width: 28rpx;
height: 28rpx;
}
}
}
.baseInfo {
margin: 20rpx 32rpx 30rpx;
background: #FFFFFF;
border-radius: 12rpx 12rpx 12rpx 12rpx;
padding: 0 30rpx;
font-weight: 500;
font-size: 28rpx;
color: #333333;
.formItem {
padding: 40rpx 0;
border-bottom: 1rpx solid #EEEEEE;
&:last-child {
border: none;
}
}
.formItem_content {
display: flex;
align-items: center;
column-gap: 10rpx;
}
.formItemInput {
flex: 1;
width: 0;
text-align: right;
}
.formItemBtn {
width: 24rpx;
height: 24rpx;
}
}
.dateCard {
margin: 20rpx 32rpx 30rpx;
padding: 22rpx 30rpx;
background: #FFFFFF;
border-radius: 16rpx 16rpx 16rpx 16rpx;
.cardTitle {
font-weight: bold;
font-size: 28rpx;
color: #333333;
}
.datePicker {
display: flex;
column-gap: 20rpx;
overflow: auto;
padding: 30rpx 0;
border-bottom: 1rpx solid #EEEEEE;
.dateItem {
padding: 20rpx 40rpx;
border-radius: 8rpx 8rpx 8rpx 8rpx;
border: 1rpx solid rgba(0, 0, 0, 0.1);
font-size: 24rpx;
color: #666666;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
}
.timerPicker {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 20rpx;
padding-top: 30rpx;
2024-09-24 22:42:08 +08:00
2024-09-22 15:07:01 +08:00
.timeItem {
border-radius: 8rpx 8rpx 8rpx 8rpx;
border: 1rpx solid rgba(0, 0, 0, 0.1);
padding: 30rpx 0;
text-align: center;
}
}
.timeItem,
.dateItem {
position: relative;
overflow: hidden;
2024-09-24 22:42:08 +08:00
2024-09-22 15:07:01 +08:00
&.active {
border-radius: 8rpx 8rpx 8rpx 8rpx;
border: 2rpx solid #0174F6;
color: #0174F6;
}
&.disabled {
border-radius: 8rpx 8rpx 8rpx 8rpx;
2024-09-24 22:42:08 +08:00
border: 1rpx solid rgba(0, 0, 0, 0.1);
color: rgba(51, 51, 51, 0.4);
2024-09-22 15:07:01 +08:00
}
2024-09-24 22:42:08 +08:00
2024-09-22 15:07:01 +08:00
.activeIcon {
position: absolute;
right: 0;
top: 0;
width: 36rpx;
height: 24rpx;
}
}
}
}
.footer {
background: #FFFFFF;
padding: 12rpx 0;
padding-bottom: calc(12rpx + env(safe-area-inset-bottom));
.footerBtn {
width: 80%;
margin: 0 auto;
padding: 22rpx 0;
background: #0174F6;
border-radius: 38rpx 38rpx 38rpx 38rpx;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
font-size: 32rpx;
color: #FFFFFF;
}
}
2024-09-25 10:09:50 +08:00
</style>