Commit 5d70e5b6 by zhangzhen

细节优化

parent 75ba8fc2
...@@ -65,8 +65,11 @@ ...@@ -65,8 +65,11 @@
<view class="room-box"> <view class="room-box">
<view v-for="(val,k) in item.roolList" :key='k' class="room-item" :class="{marginLeft: k%4 == 0, marginRight: k%4 == 3}" @tap='onNavSearch(val)'> <view v-for="(val,k) in item.roolList" :key='k' class="room-item" :class="{marginLeft: k%4 == 0, marginRight: k%4 == 3}" @tap='onNavSearch(val)'>
<view class="room-stauts"> <view class="room-stauts">
<text :style="{color: colorEnum[val.colorStatus] }">{{statusEnum[val.colorStatus]}}</text> <text :style="{color: colorEnum[val.colorStatus]}">{{statusEnum[val.colorStatus]}}</text>
<image class="img" :src="assetsPath+'/avatar_no.png'" mode="widthFix"></image> <image class="img" :src="assetsPath+'/avatar_no.png'" mode="widthFix"></image>
<view class="end-time-box">
<text v-if="val.recordsTime && val.status==1" :style="{color: colorEnum[val.colorStatus] }">{{val.recordsTime|setTime}} 结束</text>
</view>
</view> </view>
<view class="room-name"> <view class="room-name">
...@@ -88,6 +91,7 @@ ...@@ -88,6 +91,7 @@
import { import {
getDictItem getDictItem
} from "@/utils/tools.js" } from "@/utils/tools.js"
import moment from "@/common/moment";
export default { export default {
data() { data() {
return { return {
...@@ -138,6 +142,11 @@ ...@@ -138,6 +142,11 @@
cleanStatusEnum:{} cleanStatusEnum:{}
}; };
}, },
filters:{
setTime(val){
return moment(val).format("HH:mm")
}
},
onShow() { onShow() {
this.onGetDicts() this.onGetDicts()
}, },
...@@ -376,4 +385,16 @@ ...@@ -376,4 +385,16 @@
margin-right: 0; margin-right: 0;
} }
} }
.end-time-box{
display: flex;
width: 100%;
justify-content: center;
align-items: center;
height: 32upx;
text{
margin: 0 !important;
padding: 0;
font-size: 24upx;
}
}
</style> </style>
...@@ -349,7 +349,7 @@ ...@@ -349,7 +349,7 @@
} }
return { return {
id: '', id: '',
orderType: 1, orderType: 1,//订单模式,1:下单;2续单
payWay: 1, payWay: 1,
hostUrl: config.hostUrl, hostUrl: config.hostUrl,
assetsPath: config.assetsPath, assetsPath: config.assetsPath,
...@@ -443,7 +443,8 @@ ...@@ -443,7 +443,8 @@
duration:0, duration:0,
days:1 days:1
}, },
days:1 days:1,
addM:false,//初始化加一分钟,之后不加
}; };
}, },
filters:{ filters:{
...@@ -510,7 +511,7 @@ ...@@ -510,7 +511,7 @@
.split(",").map(val => this.hostUrl + val) : [] .split(",").map(val => this.hostUrl + val) : []
} }
// 判断房间有没有绑定套餐 // 判断房间有没有绑定套餐
if (this.orderType == 1 && this.roomInfo.packList && this.roomInfo.packList.length) { if (this.roomInfo.packList && this.roomInfo.packList.length) {
this.packageMode = this.roomInfo.packList this.packageMode = this.roomInfo.packList
this.index = 1; this.index = 1;
this.modeIndex = 0; this.modeIndex = 0;
...@@ -553,6 +554,9 @@ ...@@ -553,6 +554,9 @@
hour: index > 0 && index - 24 == 0 ? '次日' : index > 24 ? index - 24 : index hour: index > 0 && index - 24 == 0 ? '次日' : index > 24 ? index - 24 : index
} }
}) })
if(this.orderType === 2){
this.onSetEndTime()
}else{
this.dateIntervalList.forEach((item,index) =>{ this.dateIntervalList.forEach((item,index) =>{
if(item.status==1 && this.setStartTime.duration < this.duration && moment(item.endHoldTime).format("mm")<59 ){ if(item.status==1 && this.setStartTime.duration < this.duration && moment(item.endHoldTime).format("mm")<59 ){
this.setStartTime.startTime = moment(item.endHoldTime).format("HH:mm"); this.setStartTime.startTime = moment(item.endHoldTime).format("HH:mm");
...@@ -578,6 +582,10 @@ ...@@ -578,6 +582,10 @@
}else if(item.status==1 && this.setStartTime.status && this.setStartTime.duration === this.duration && moment(this.setStartTime.startTime).format("mm") < moment(item.startHoldTime).format("mm")){ }else if(item.status==1 && this.setStartTime.status && this.setStartTime.duration === this.duration && moment(this.setStartTime.startTime).format("mm") < moment(item.startHoldTime).format("mm")){
this.startTime = this.setStartTime.startTime; this.startTime = this.setStartTime.startTime;
this.setStartTime.duration+=1; this.setStartTime.duration+=1;
if(index>=24){
this.setStartTime.days = 2
this.days = 2;
}
}else if(item.status==1 && this.setStartTime.status && this.setStartTime.duration === this.duration && moment(this.setStartTime.startTime).format("mm") >= moment(item.startHoldTime).format("mm")){ }else if(item.status==1 && this.setStartTime.status && this.setStartTime.duration === this.duration && moment(this.setStartTime.startTime).format("mm") >= moment(item.startHoldTime).format("mm")){
this.setStartTime.duration = 0; this.setStartTime.duration = 0;
this.setStartTime.status = false; this.setStartTime.status = false;
...@@ -595,9 +603,14 @@ ...@@ -595,9 +603,14 @@
} else if(item.status === 0 && this.setStartTime.duration == this.duration && this.setStartTime.status){ } else if(item.status === 0 && this.setStartTime.duration == this.duration && this.setStartTime.status){
this.startTime = this.setStartTime.startTime; this.startTime = this.setStartTime.startTime;
this.setStartTime.duration+=1; this.setStartTime.duration+=1;
if(index>=24){
this.setStartTime.days = 2
this.days = 2;
}
} }
if(index >= this.dateIntervalList.length-1){ if(index >= this.dateIntervalList.length-1){
if(this.orderType == 1){ if(!this.addM){
this.addM = true
// 开始时间加一分钟 // 开始时间加一分钟
let arr = this.startTime.split(":"); let arr = this.startTime.split(":");
let m = Number(arr[1])+1 let m = Number(arr[1])+1
...@@ -616,7 +629,7 @@ ...@@ -616,7 +629,7 @@
this.onSetEndTime() this.onSetEndTime()
} }
}) })
}
}) })
}, },
//设置预定结束时间 //设置预定结束时间
...@@ -627,7 +640,7 @@ ...@@ -627,7 +640,7 @@
this.endTime = this.startTime.split(":").map((item, k) => { this.endTime = this.startTime.split(":").map((item, k) => {
let num = '' let num = ''
if (k == 0) { if (k == 0) {
if ((Number(item) + this.duration) > 23) { if ((Number(item) + this.duration) >= 24) {
num = Number(item) + this.duration - 24 num = Number(item) + this.duration - 24
} else { } else {
num = Number(item) + this.duration num = Number(item) + this.duration
...@@ -645,17 +658,16 @@ ...@@ -645,17 +658,16 @@
} else if (this.orderType === 2) { } else if (this.orderType === 2) {
this.duration = Number(this.distanceMode2[this.distanceIndex].duration); this.duration = Number(this.distanceMode2[this.distanceIndex].duration);
} }
if (this.orderType === 2 && this.duration < 1) { if (this.orderType === 2 && this.duration < 1) {
let startDateArr = this.startTime.split(":").map(item => Number(item)) let startDateArr = this.startTime.split(":").map(item => Number(item))
// 分钟 // 分钟
let m = startDateArr[1] + 60 * this.duration let m = startDateArr[1] + 60 * this.duration
if (m >= 60) { if (m >= 60) {
startDateArr[0] += 1 startDateArr[0] += 1
if (startDateArr[0] > 23) { if (startDateArr[0] >= 24) {
startDateArr[0] = startDateArr[0] - 23 startDateArr[0] = startDateArr[0] - 24
this.setStartTime.days = 2;
this.days = 2
} }
startDateArr[1] = m - 60 startDateArr[1] = m - 60
} else { } else {
...@@ -666,7 +678,7 @@ ...@@ -666,7 +678,7 @@
this.endTime = this.startTime.split(":").map((item, k) => { this.endTime = this.startTime.split(":").map((item, k) => {
let num = '' let num = ''
if (k == 0) { if (k == 0) {
if ((Number(item) + this.duration) > 23) { if ((Number(item) + this.duration) >= 24) {
num = Number(item) + this.duration - 24 num = Number(item) + this.duration - 24
} else { } else {
num = Number(item) + this.duration num = Number(item) + this.duration
...@@ -679,7 +691,6 @@ ...@@ -679,7 +691,6 @@
}).join(":") }).join(":")
} }
} }
this.onGetUseCoupon()
this.onUpdateIntervalList() this.onUpdateIntervalList()
}, },
// 更新时间的选取状态 // 更新时间的选取状态
...@@ -694,19 +705,19 @@ ...@@ -694,19 +705,19 @@
let endM = Number(this.endTime.split(":")[1]) let endM = Number(this.endTime.split(":")[1])
console.log(this.days,start,3333)
// 如果开始时间是第二天 // 如果开始时间是第二天
if(this.setStartTime.days >=2 || this.days == 2){ if(this.setStartTime.days >=2 || this.days == 2){
start +=24 start +=24
} }
if (this.orderType ==2 && end < start){ if (this.orderType ==2 && end < start){
end += 24 end += 24
}else if(this.orderType ==1 && end <= start) { }else if(this.orderType ==1 && end <= start) {
end += 24 end += 24
} }
this.dateObj = this.onSetDateTime(this.startTime, this.endTime); this.dateObj = this.onSetDateTime(this.startTime, this.endTime);
this.onGetUseCoupon()
// 重新将数据还原到元数据 // 重新将数据还原到元数据
this.intervalList = [ this.intervalList = [
...this.dateIntervalList ...this.dateIntervalList
...@@ -742,13 +753,12 @@ ...@@ -742,13 +753,12 @@
}, },
// 获取可用优惠券 // 获取可用优惠券
onGetUseCoupon() { onGetUseCoupon() {
let dateObj = this.onSetDateTime(this.startTime, this.endTime);
getUseCoupon({ getUseCoupon({
storeId: this.roomInfo.storeId, storeId: this.roomInfo.storeId,
roomId: this.roomInfo.id, roomId: this.roomInfo.id,
orderMode: this.orderTypeList[this.index].type, orderMode: this.orderTypeList[this.index].type,
preStartDate: dateObj.startDate, preStartDate: this.dateObj.startDate,
preEndDate: dateObj.endDate preEndDate: this.dateObj.endDate
}).then(res => { }).then(res => {
if (res.data.code == 200) { if (res.data.code == 200) {
...@@ -763,7 +773,6 @@ ...@@ -763,7 +773,6 @@
}) })
}, },
onNavToSelectCoupon() { onNavToSelectCoupon() {
let dateObj = this.onSetDateTime(this.startTime, this.endTime);
let that = this; let that = this;
if (this.useCouponList.length) { if (this.useCouponList.length) {
uni.navigateTo({ uni.navigateTo({
...@@ -783,8 +792,8 @@ ...@@ -783,8 +792,8 @@
storeId: that.roomInfo.storeId, storeId: that.roomInfo.storeId,
roomId: that.roomInfo.id, roomId: that.roomInfo.id,
orderMode: that.orderTypeList[that.index].type, orderMode: that.orderTypeList[that.index].type,
preStartDate: dateObj.startDate, preStartDate: this.dateObj.startDate,
preEndDate: dateObj.endDate, preEndDate: this.dateObj.endDate,
selectId: that.selectCouponIndex >= 0 ? that.useCouponList[that.selectCouponIndex].id :'' selectId: that.selectCouponIndex >= 0 ? that.useCouponList[that.selectCouponIndex].id :''
}) })
} }
...@@ -796,15 +805,14 @@ ...@@ -796,15 +805,14 @@
uni.showLoading({ uni.showLoading({
title: "计算价格中..." title: "计算价格中..."
}) })
let dateObj = this.onSetDateTime(this.startTime, this.endTime);
let params = { let params = {
storeId: this.roomInfo.storeId, storeId: this.roomInfo.storeId,
roomId: this.roomInfo.id, roomId: this.roomInfo.id,
buyType: this.orderTypeList[this.index].type, buyType: this.orderTypeList[this.index].type,
couponId: this.useCouponList.length && this.selectCouponIndex >= 0 ? this.useCouponList[this.selectCouponIndex].id : '', couponId: this.useCouponList.length && this.selectCouponIndex >= 0 ? this.useCouponList[this.selectCouponIndex].id : '',
orderType: this.orderType, orderType: this.orderType,
preStartDate: dateObj.startDate, preStartDate: this.dateObj.startDate,
preEndDate: dateObj.endDate, preEndDate: this.dateObj.endDate,
orderMode: this.orderTypeList[this.index].type, orderMode: this.orderTypeList[this.index].type,
} }
if (this.index === 1) { if (this.index === 1) {
...@@ -840,20 +848,15 @@ ...@@ -840,20 +848,15 @@
let val = this.intervalList.findIndex(item=>item.status === 2) let val = this.intervalList.findIndex(item=>item.status === 2)
let len = this.intervalList.filter(item=> item.status ===2).length; let len = this.intervalList.filter(item=> item.status ===2).length;
let duration = Number(this.packageMode[this.modeIndex].duration); let duration = Number(this.packageMode[this.modeIndex].duration);
let start = Number(this.startTime.split(":")[0]) let start = Number(this.startTime.split(":")[0])
let startM = Number(this.startTime.split(":")[1]) let startM = Number(this.startTime.split(":")[1])
let h = val; let h = val;
if(val+duration>=24){ if(val+duration>=24){
h = val+duration-24 h = val+duration-24
} else{ } else{
h = val+duration h = val+duration
} }
this.endTime = `${h>=10?h:'0'+h}:${startM>=10?startM:'0'+startM}`; this.endTime = `${h>=10?h:'0'+h}:${startM>=10?startM:'0'+startM}`;
this.dateObj = this.onSetDateTime(this.startTime, this.endTime);
let showHourUse = false; let showHourUse = false;
this.intervalList = this.intervalList.map((item,index) =>{ this.intervalList = this.intervalList.map((item,index) =>{
let status = item.status; let status = item.status;
...@@ -866,7 +869,6 @@ ...@@ -866,7 +869,6 @@
}else{ }else{
status = this.dateIntervalList[index].status status = this.dateIntervalList[index].status
} }
return { return {
...item, ...item,
status status
...@@ -878,7 +880,9 @@ ...@@ -878,7 +880,9 @@
title: "选择时段有重复" title: "选择时段有重复"
}) })
} }
this.onComputePrice(); // this.onComputePrice();
this.dateObj = this.onSetDateTime(this.startTime, this.endTime);
this.onGetUseCoupon()
}, },
onDurationChange(i) { onDurationChange(i) {
if (i >= this.distanceMode.length - 1) { if (i >= this.distanceMode.length - 1) {
...@@ -999,7 +1003,6 @@ ...@@ -999,7 +1003,6 @@
uni.showLoading({ uni.showLoading({
title: "下单中..." title: "下单中..."
}) })
let dateObj = this.onSetDateTime(this.startTime, this.endTime);
let params = { let params = {
storeId: this.roomInfo.storeId, storeId: this.roomInfo.storeId,
roomId: this.roomInfo.id, roomId: this.roomInfo.id,
...@@ -1007,8 +1010,8 @@ ...@@ -1007,8 +1010,8 @@
buyType: this.orderTypeList[this.index].type, buyType: this.orderTypeList[this.index].type,
payType: 1, payType: 1,
couponId: this.useCouponList.length && this.selectCouponIndex >=0 ? this.useCouponList[this.selectCouponIndex].id : '', couponId: this.useCouponList.length && this.selectCouponIndex >=0 ? this.useCouponList[this.selectCouponIndex].id : '',
preStartDate: dateObj.startDate, preStartDate: this.dateObj.startDate,
preEndDate: dateObj.endDate, preEndDate: this.dateObj.endDate,
totalFee: Number(this.roomInfo.price) * this.duration, totalFee: Number(this.roomInfo.price) * this.duration,
payFee: this.computePriceInfo.payFee || 0, payFee: this.computePriceInfo.payFee || 0,
packId: this.index > 0 ? this.packageMode[this.modeIndex].id : '' packId: this.index > 0 ? this.packageMode[this.modeIndex].id : ''
...@@ -1130,6 +1133,7 @@ ...@@ -1130,6 +1133,7 @@
}, },
// 将时间转换成完整日期 // 将时间转换成完整日期
onSetDateTime(startTime, endTime) { onSetDateTime(startTime, endTime) {
console.log(startTime, endTime,this.days,909090)
let obj = { let obj = {
startDate: "", startDate: "",
endDate: '' endDate: ''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment