Commit 5d70e5b6 by zhangzhen

细节优化

parent 75ba8fc2
......@@ -65,8 +65,11 @@
<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 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>
<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 class="room-name">
......@@ -88,6 +91,7 @@
import {
getDictItem
} from "@/utils/tools.js"
import moment from "@/common/moment";
export default {
data() {
return {
......@@ -138,6 +142,11 @@
cleanStatusEnum:{}
};
},
filters:{
setTime(val){
return moment(val).format("HH:mm")
}
},
onShow() {
this.onGetDicts()
},
......@@ -376,4 +385,16 @@
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>
......@@ -349,7 +349,7 @@
}
return {
id: '',
orderType: 1,
orderType: 1,//订单模式,1:下单;2续单
payWay: 1,
hostUrl: config.hostUrl,
assetsPath: config.assetsPath,
......@@ -443,7 +443,8 @@
duration:0,
days:1
},
days:1
days:1,
addM:false,//初始化加一分钟,之后不加
};
},
filters:{
......@@ -510,7 +511,7 @@
.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.index = 1;
this.modeIndex = 0;
......@@ -553,6 +554,9 @@
hour: index > 0 && index - 24 == 0 ? '次日' : index > 24 ? index - 24 : index
}
})
if(this.orderType === 2){
this.onSetEndTime()
}else{
this.dateIntervalList.forEach((item,index) =>{
if(item.status==1 && this.setStartTime.duration < this.duration && moment(item.endHoldTime).format("mm")<59 ){
this.setStartTime.startTime = moment(item.endHoldTime).format("HH:mm");
......@@ -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")){
this.startTime = this.setStartTime.startTime;
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")){
this.setStartTime.duration = 0;
this.setStartTime.status = false;
......@@ -595,9 +603,14 @@
} else if(item.status === 0 && this.setStartTime.duration == this.duration && this.setStartTime.status){
this.startTime = this.setStartTime.startTime;
this.setStartTime.duration+=1;
if(index>=24){
this.setStartTime.days = 2
this.days = 2;
}
}
if(index >= this.dateIntervalList.length-1){
if(this.orderType == 1){
if(!this.addM){
this.addM = true
// 开始时间加一分钟
let arr = this.startTime.split(":");
let m = Number(arr[1])+1
......@@ -616,7 +629,7 @@
this.onSetEndTime()
}
})
}
})
},
//设置预定结束时间
......@@ -627,7 +640,7 @@
this.endTime = this.startTime.split(":").map((item, k) => {
let num = ''
if (k == 0) {
if ((Number(item) + this.duration) > 23) {
if ((Number(item) + this.duration) >= 24) {
num = Number(item) + this.duration - 24
} else {
num = Number(item) + this.duration
......@@ -645,17 +658,16 @@
} else if (this.orderType === 2) {
this.duration = Number(this.distanceMode2[this.distanceIndex].duration);
}
if (this.orderType === 2 && this.duration < 1) {
let startDateArr = this.startTime.split(":").map(item => Number(item))
// 分钟
let m = startDateArr[1] + 60 * this.duration
if (m >= 60) {
startDateArr[0] += 1
if (startDateArr[0] > 23) {
startDateArr[0] = startDateArr[0] - 23
if (startDateArr[0] >= 24) {
startDateArr[0] = startDateArr[0] - 24
this.setStartTime.days = 2;
this.days = 2
}
startDateArr[1] = m - 60
} else {
......@@ -666,7 +678,7 @@
this.endTime = this.startTime.split(":").map((item, k) => {
let num = ''
if (k == 0) {
if ((Number(item) + this.duration) > 23) {
if ((Number(item) + this.duration) >= 24) {
num = Number(item) + this.duration - 24
} else {
num = Number(item) + this.duration
......@@ -679,7 +691,6 @@
}).join(":")
}
}
this.onGetUseCoupon()
this.onUpdateIntervalList()
},
// 更新时间的选取状态
......@@ -694,19 +705,19 @@
let endM = Number(this.endTime.split(":")[1])
console.log(this.days,start,3333)
// 如果开始时间是第二天
if(this.setStartTime.days >=2 || this.days == 2){
start +=24
}
if (this.orderType ==2 && end < start){
end += 24
}else if(this.orderType ==1 && end <= start) {
end += 24
}
this.dateObj = this.onSetDateTime(this.startTime, this.endTime);
this.onGetUseCoupon()
// 重新将数据还原到元数据
this.intervalList = [
...this.dateIntervalList
......@@ -742,13 +753,12 @@
},
// 获取可用优惠券
onGetUseCoupon() {
let dateObj = this.onSetDateTime(this.startTime, this.endTime);
getUseCoupon({
storeId: this.roomInfo.storeId,
roomId: this.roomInfo.id,
orderMode: this.orderTypeList[this.index].type,
preStartDate: dateObj.startDate,
preEndDate: dateObj.endDate
preStartDate: this.dateObj.startDate,
preEndDate: this.dateObj.endDate
}).then(res => {
if (res.data.code == 200) {
......@@ -763,7 +773,6 @@
})
},
onNavToSelectCoupon() {
let dateObj = this.onSetDateTime(this.startTime, this.endTime);
let that = this;
if (this.useCouponList.length) {
uni.navigateTo({
......@@ -783,8 +792,8 @@
storeId: that.roomInfo.storeId,
roomId: that.roomInfo.id,
orderMode: that.orderTypeList[that.index].type,
preStartDate: dateObj.startDate,
preEndDate: dateObj.endDate,
preStartDate: this.dateObj.startDate,
preEndDate: this.dateObj.endDate,
selectId: that.selectCouponIndex >= 0 ? that.useCouponList[that.selectCouponIndex].id :''
})
}
......@@ -796,15 +805,14 @@
uni.showLoading({
title: "计算价格中..."
})
let dateObj = this.onSetDateTime(this.startTime, this.endTime);
let params = {
storeId: this.roomInfo.storeId,
roomId: this.roomInfo.id,
buyType: this.orderTypeList[this.index].type,
couponId: this.useCouponList.length && this.selectCouponIndex >= 0 ? this.useCouponList[this.selectCouponIndex].id : '',
orderType: this.orderType,
preStartDate: dateObj.startDate,
preEndDate: dateObj.endDate,
preStartDate: this.dateObj.startDate,
preEndDate: this.dateObj.endDate,
orderMode: this.orderTypeList[this.index].type,
}
if (this.index === 1) {
......@@ -840,20 +848,15 @@
let val = this.intervalList.findIndex(item=>item.status === 2)
let len = this.intervalList.filter(item=> item.status ===2).length;
let duration = Number(this.packageMode[this.modeIndex].duration);
let start = Number(this.startTime.split(":")[0])
let startM = Number(this.startTime.split(":")[1])
let h = val;
if(val+duration>=24){
h = val+duration-24
} else{
h = val+duration
}
this.endTime = `${h>=10?h:'0'+h}:${startM>=10?startM:'0'+startM}`;
this.dateObj = this.onSetDateTime(this.startTime, this.endTime);
let showHourUse = false;
this.intervalList = this.intervalList.map((item,index) =>{
let status = item.status;
......@@ -866,7 +869,6 @@
}else{
status = this.dateIntervalList[index].status
}
return {
...item,
status
......@@ -878,7 +880,9 @@
title: "选择时段有重复"
})
}
this.onComputePrice();
// this.onComputePrice();
this.dateObj = this.onSetDateTime(this.startTime, this.endTime);
this.onGetUseCoupon()
},
onDurationChange(i) {
if (i >= this.distanceMode.length - 1) {
......@@ -999,7 +1003,6 @@
uni.showLoading({
title: "下单中..."
})
let dateObj = this.onSetDateTime(this.startTime, this.endTime);
let params = {
storeId: this.roomInfo.storeId,
roomId: this.roomInfo.id,
......@@ -1007,8 +1010,8 @@
buyType: this.orderTypeList[this.index].type,
payType: 1,
couponId: this.useCouponList.length && this.selectCouponIndex >=0 ? this.useCouponList[this.selectCouponIndex].id : '',
preStartDate: dateObj.startDate,
preEndDate: dateObj.endDate,
preStartDate: this.dateObj.startDate,
preEndDate: this.dateObj.endDate,
totalFee: Number(this.roomInfo.price) * this.duration,
payFee: this.computePriceInfo.payFee || 0,
packId: this.index > 0 ? this.packageMode[this.modeIndex].id : ''
......@@ -1130,6 +1133,7 @@
},
// 将时间转换成完整日期
onSetDateTime(startTime, endTime) {
console.log(startTime, endTime,this.days,909090)
let obj = {
startDate: "",
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