Commit 5cae7c58 by zhangzhen

细节优化

parent 10559ee4
...@@ -112,44 +112,27 @@ ...@@ -112,44 +112,27 @@
onGetOrderByAvailable(i){ onGetOrderByAvailable(i){
getOrderByAvailable().then(res=>{ getOrderByAvailable().then(res=>{
if(res.data.code === 200){ if(res.data.code === 200){
if(res.data.data&&res.data.data.length===1){ if(res.data.data&&res.data.data.length){
this.orderInfo = res.data.data[0]; let arr = res.data.data.filter(item => item.status);
if(i === 3){ if(arr.length && arr.length ==1){
if(this.orderInfo.status ==1){ this.orderInfo = arr[0];
// 去续单 if( i==3 ){
// 续单
uni.navigateTo({ uni.navigateTo({
url:`/pages/order/order?roomId=${this.orderInfo.roomId}&orderNo=${this.orderInfo.orderNo}` url:`/pages/order/order?orderNo=${this.orderInfo.orderNo}`
}) })
}else{ } else{
uni.showToast({ // 开门
icon:"none",
title:"无使用中的订单,无法续单哦!"
})
}
}else{
// 去开门
this.onOpenDoor() this.onOpenDoor()
} }
} else if(arr.length && arr.length >1){
}else if(res.data.data&&res.data.data.length > 1){ uni.switchTab({
url:"/pages/orderRecord/orderRecord?index=2"
let list = res.data.data.filter(item=> item.status ==1)
if(list.length ===1){
this.orderInfo = list[0];
if(i === 3){
// 去续单
uni.navigateTo({
url:`/pages/order/order?roomId=${this.orderInfo.roomId}&orderNo=${this.orderInfo.orderNo}`
}) })
}else{
// 去开门
this.onOpenDoor()
}
}else{ }else{
uni.switchTab({ uni.showToast({
url:"/pages/orderRecord/orderRecord" icon:"none",
title:"暂无可用的订单,请先下单预约哦!"
}) })
} }
}else{ }else{
......
...@@ -349,7 +349,7 @@ ...@@ -349,7 +349,7 @@
</uni-popup> </uni-popup>
<uni-popup ref="popupDialog" type="dialog"> <uni-popup ref="popupDialog" type="dialog">
<uni-popup-dialog type="warn" mode="base" title="提示" content="所选套餐可使用时长不足,请点击确定表示接受" :duration="2000" :before-close="true" @close="onCancleTip" @confirm="onPackageCheck"></uni-popup-dialog> <uni-popup-dialog type="warn" mode="base" title="提示" :content=" warnTip || packageMode[modeIndex2].name + '时长不足,是否接受预定?'" :duration="2000" :before-close="true" @close="onCancleTip" @confirm="onPackageCheck"></uni-popup-dialog>
</uni-popup> </uni-popup>
</view> </view>
</template> </template>
...@@ -509,7 +509,8 @@ ...@@ -509,7 +509,8 @@
}, },
allDayUseStatus: false, // 当日无可预约时段,true 无法预约,false 可预约 allDayUseStatus: false, // 当日无可预约时段,true 无法预约,false 可预约
tipContent: "当前条件下无可预约的时段,请手动选择合适的空闲时段", tipContent: "当前条件下无可预约的时段,请手动选择合适的空闲时段",
tipErrMsg: '' tipErrMsg: '',
warnTip:''
}; };
}, },
...@@ -569,7 +570,13 @@ ...@@ -569,7 +570,13 @@
onChangePackage(index){ onChangePackage(index){
if(this.modeIndex == index || this.allDayUseStatus) return; if(this.modeIndex == index || this.allDayUseStatus) return;
let startDateTime = this.orderType ==2? this.orderInfo.endDate: '' let startDateTime = ''
if(this.orderType ==2){
startDateTime = this.orderInfo.endDate
if(this.orderInfo.status ==2){
startDateTime = moment().format("YYYY-MM-DD HH:mm:00")
}
}
this.modeIndex = index this.modeIndex = index
this.modeIndex2 = -1 this.modeIndex2 = -1
...@@ -600,7 +607,7 @@ ...@@ -600,7 +607,7 @@
let startDate = moment(moment().format(startStr)).format("YYYY-MM-DD HH:00:00"); let startDate = moment(moment().format(startStr)).format("YYYY-MM-DD HH:00:00");
let endStr = `${this.dateList[this.dateIndex].readDate} ${valData.packaEndPeriod}:00:00` let endStr = `${this.dateList[this.dateIndex].readDate} ${valData.packaEndPeriod}:00:00`
let endDate = moment(moment().format(endStr)).format("YYYY-MM-DD HH:00:00"); let endDate = moment(moment().format(endStr)).format("YYYY-MM-DD HH:00:00");
console.log(startDate,endDate,6666)
// 如果是续单,则订单的结束时间必须在套餐的开始时间和结束时间内,否则无法续对应的套餐 // 如果是续单,则订单的结束时间必须在套餐的开始时间和结束时间内,否则无法续对应的套餐
if(this.orderType == 2){ if(this.orderType == 2){
if(!(moment(this.orderInfo.endDate).valueOf() >= moment(startDate).valueOf() && moment(this.orderInfo.endDate).valueOf() <= moment(endDate).valueOf())){ if(!(moment(this.orderInfo.endDate).valueOf() >= moment(startDate).valueOf() && moment(this.orderInfo.endDate).valueOf() <= moment(endDate).valueOf())){
...@@ -621,7 +628,7 @@ ...@@ -621,7 +628,7 @@
let originTime = moment(endDate).valueOf() - moment(startDate).valueOf() let originTime = moment(endDate).valueOf() - moment(startDate).valueOf()
// 实际时间 // 实际时间
let actualTime = moment(dateTimeObj.tempEndDate).valueOf() - moment(dateTimeObj.tempStartDate).valueOf() let actualTime = moment(dateTimeObj.tempEndDate).valueOf() - moment(dateTimeObj.tempStartDate).valueOf()
if( actualTime < originTime*0.6 || this.onCheckPackUse(startDate,endDate)){ if( actualTime < originTime - 4*60*60*1000 || this.onCheckPackUse(startDate,endDate,4)){
// console.log("实际时长小于原时长的60%则选择明天的时间"); // console.log("实际时长小于原时长的60%则选择明天的时间");
// 加一天时间重新计算 // 加一天时间重新计算
if(this.dateIndex != 0){ if(this.dateIndex != 0){
...@@ -635,7 +642,7 @@ ...@@ -635,7 +642,7 @@
dateTimeObj = this.onComputeStartDateAndEndDate(startDate,endDate); dateTimeObj = this.onComputeStartDateAndEndDate(startDate,endDate);
// 实际时间 // 实际时间
actualTime = moment(dateTimeObj.tempEndDate).valueOf() - moment(dateTimeObj.tempStartDate).valueOf() actualTime = moment(dateTimeObj.tempEndDate).valueOf() - moment(dateTimeObj.tempStartDate).valueOf()
if( actualTime < originTime*0.6 || this.onCheckPackUse(startDate,endDate)){ if( actualTime < originTime - 4*60*60*1000 || this.onCheckPackUse(startDate,endDate,4)){
useStatus = false; useStatus = false;
return return
} }
...@@ -645,12 +652,12 @@ ...@@ -645,12 +652,12 @@
// 如果此套餐的结束时间在12点后,则为闲时套餐,仅查看今日日否有合适的套餐 // 如果此套餐的结束时间在12点后,则为闲时套餐,仅查看今日日否有合适的套餐
// console.log("闲时套餐") // console.log("闲时套餐")
dateTimeObj = this.onComputeStartDateAndEndDate(startDate,endDate); dateTimeObj = this.onComputeStartDateAndEndDate(startDate,endDate);
console.log(dateTimeObj,"dateTimeObj")
// 原时间 // 原时间
let originTime = moment(endDate).valueOf() - moment(startDate).valueOf() let originTime = moment(endDate).valueOf() - moment(startDate).valueOf()
// 实际时间 // 实际时间
let actualTime = moment(dateTimeObj.tempEndDate).valueOf() - moment(dateTimeObj.tempStartDate).valueOf() let actualTime = moment(dateTimeObj.tempEndDate).valueOf() - moment(dateTimeObj.tempStartDate).valueOf()
if( actualTime< originTime*0.6 || this.onCheckPackUse(startDate,endDate)){ if( actualTime < originTime*0.6 || this.onCheckPackUse(startDate,endDate)){
useStatus = false; useStatus = false;
return return
} }
...@@ -675,15 +682,14 @@ ...@@ -675,15 +682,14 @@
if(moment(endDate).valueOf() < moment(pointDateForm).valueOf()){ if(moment(endDate).valueOf() < moment(pointDateForm).valueOf()){
// console.log("通宵套餐") // console.log("通宵套餐")
dateTimeObj = this.onComputeStartDateAndEndDate(startDate,endDate); dateTimeObj = this.onComputeStartDateAndEndDate(startDate,endDate);
console.log(dateTimeObj,"通宵套餐")
// 实际时长小于原时长的50%则选择明天的时间
// 原时间 // 原时间
let originTime = moment(endDate).valueOf() - moment(startDate).valueOf() let originTime = moment(endDate).valueOf() - moment(startDate).valueOf()
// 实际时间 // 实际时间
let actualTime = moment(dateTimeObj.tempEndDate).valueOf() - moment(dateTimeObj.tempStartDate).valueOf() let actualTime = moment(dateTimeObj.tempEndDate).valueOf() - moment(dateTimeObj.tempStartDate).valueOf()
// 原时长是9个小时,减去4个小时, 低于5个小时,则时长不足
if( actualTime< originTime*0.6){ if( actualTime< originTime - 4*60*60*1000 || this.onCheckPackUse(startDate,endDate,4)){
// console.log("实际时长小于原时长的60%则选择明天的时间"); // console.log("实际时长小于原时长的60%则选择明天的时间");
// 加一天时间重新计算 // 加一天时间重新计算
...@@ -694,17 +700,20 @@ ...@@ -694,17 +700,20 @@
}) })
return return
} }
dateTimeObj = this.onComputeStartDateAndEndDate(moment(startDate).add(1,"d").format("YYYY-MM-DD HH:00:00"),moment(endDate).add(1,"d").format("YYYY-MM-DD HH:00:00"));
startDate = moment(startDate).add(1,"d").format("YYYY-MM-DD HH:00:00");
endDate = moment(endDate).add(1,"d").format("YYYY-MM-DD HH:00:00");
dateTimeObj = this.onComputeStartDateAndEndDate(startDate,endDate);
// 实际时间 // 实际时间
actualTime = moment(dateTimeObj.tempEndDate).valueOf() - moment(dateTimeObj.tempStartDate).valueOf() actualTime = moment(dateTimeObj.tempEndDate).valueOf() - moment(dateTimeObj.tempStartDate).valueOf()
if( actualTime < originTime*0.6){ if( actualTime < originTime - 4*60*60*1000 || this.onCheckPackUse(startDate,endDate,4)){
uni.showToast({ uni.showToast({
icon:"none", icon:"none",
title:'可使用时长不足,请选择其他日期' title:'可使用时长不足,请选择其他日期'
}) })
return return
}else if(actualTime < originTime*0.8 && actualTime >= originTime*0.6){ }else if(actualTime < originTime - 3*60*60*1000 && actualTime >= originTime - 4*60*60*1000){
this.tempDateObj = { this.tempDateObj = {
startDate: dateTimeObj.tempStartDate, startDate: dateTimeObj.tempStartDate,
...@@ -712,11 +721,10 @@ ...@@ -712,11 +721,10 @@
duration: actualTime/60000, duration: actualTime/60000,
durationType:2 durationType:2
} }
this.warnTip = '通宵套餐,不足4小时,是否预定?'
this.$refs.popupDialog.open(); this.$refs.popupDialog.open();
return return
}else{ }else{
this.modeIndex = -1 this.modeIndex = -1
this.modeIndex2 = index this.modeIndex2 = index
let duration = (moment(dateTimeObj.tempEndDate).valueOf()-moment(dateTimeObj.tempStartDate).valueOf())/1000/60; let duration = (moment(dateTimeObj.tempEndDate).valueOf()-moment(dateTimeObj.tempStartDate).valueOf())/1000/60;
...@@ -729,14 +737,14 @@ ...@@ -729,14 +737,14 @@
}); });
} }
} else if( actualTime < originTime*0.8 && actualTime >= originTime*0.6){ } else if( actualTime < originTime - 3*60*60*1000 && actualTime >= originTime - 4*60*60*1000){
this.tempDateObj = { this.tempDateObj = {
startDate: dateTimeObj.tempStartDate, startDate: dateTimeObj.tempStartDate,
endDate: dateTimeObj.tempEndDate, endDate: dateTimeObj.tempEndDate,
duration: actualTime/60000, duration: actualTime/60000,
durationType:2 durationType:2
} }
this.warnTip = '通宵套餐,不足4小时,是否预定?'
this.$refs.popupDialog.open(); this.$refs.popupDialog.open();
return return
...@@ -763,7 +771,7 @@ ...@@ -763,7 +771,7 @@
let originTime = moment(endDate).valueOf() - moment(startDate).valueOf() let originTime = moment(endDate).valueOf() - moment(startDate).valueOf()
// 实际时间 // 实际时间
let actualTime = moment(dateTimeObj.tempEndDate).valueOf() - moment(dateTimeObj.tempStartDate).valueOf() let actualTime = moment(dateTimeObj.tempEndDate).valueOf() - moment(dateTimeObj.tempStartDate).valueOf()
if( actualTime< originTime*0.6){ if( actualTime< originTime*0.6 || this.onCheckPackUse(startDate,endDate)){
uni.showToast({ uni.showToast({
icon:"none", icon:"none",
title:'可使用时长不足,请选择其他日期' title:'可使用时长不足,请选择其他日期'
...@@ -809,33 +817,27 @@ ...@@ -809,33 +817,27 @@
let end = moment(moment(item.timeHour).format("YYYY-MM-DD HH:59:59")).valueOf() let end = moment(moment(item.timeHour).format("YYYY-MM-DD HH:59:59")).valueOf()
if( start < moment(endDate).valueOf() && start >= moment(startDate).valueOf()){ if( start < moment(endDate).valueOf() && start >= moment(startDate).valueOf()){
if(item.status ==1 && tempStartDate && start > moment(tempStartDate).valueOf() && endNeedChange){ if(tempStartDate && !startNeedChange){
if(item.status ==0 && endNeedChange){
endNeedChange = true;
tempEndDate = moment(item.timeHour+':59:00').add(1,"m").format("YYYY-MM-DD HH:mm:00")
} else if(item.status ==1 && endNeedChange){
endNeedChange = false; endNeedChange = false;
tempEndDate = moment(item.startHoldTime).format("YYYY-MM-DD HH:mm:00") tempEndDate = moment(item.startHoldTime).format("YYYY-MM-DD HH:mm:00")
} }
}else{
if(item.status ==0 && tempStartDate && start > moment(tempStartDate).valueOf() && endNeedChange){ if(item.status == 0 && startNeedChange){
endNeedChange = true; tempStartDate = moment(item.timeHour).format("YYYY-MM-DD HH:00:00")
tempEndDate = moment(item.timeHour+':59:59').add(1,"m").format("YYYY-MM-DD HH:mm:00")
}
// 当前小时仅部分占用
if(item.status ==1 && !this.onCheckHourUse(item.startHoldTime,item.endHoldTime) && startNeedChange){
startNeedChange = false; startNeedChange = false;
tempStartDate = moment(moment(item.endHoldTime).format("YYYY-MM-DD HH:mm:00")).add(1,"m").format("YYYY-MM-DD HH:mm:00") }else if(item.status ==1 && this.onCheckHourUse(item.startHoldTime,item.endHoldTime) && startNeedChange){
}
if(item.status ==1 && this.onCheckHourUse(item.startHoldTime,item.endHoldTime) && startNeedChange){
startNeedChange = true; startNeedChange = true;
tempStartDate = moment(moment(item.endHoldTime).format("YYYY-MM-DD HH:mm:00")).format("YYYY-MM-DD HH:mm:00") tempStartDate = moment(moment(item.endHoldTime).format("YYYY-MM-DD HH:mm:00")).format("YYYY-MM-DD HH:mm:00")
} tempEndDate = moment(moment(item.endHoldTime).format("YYYY-MM-DD HH:mm:00")).add(1,'m').format("YYYY-MM-DD HH:mm:00")
}else if(item.status ==1 && !this.onCheckHourUse(item.startHoldTime,item.endHoldTime) && startNeedChange){
if(item.status == 0 && startNeedChange){
tempStartDate = moment(item.timeHour).format("YYYY-MM-DD HH:00:00")
startNeedChange = false; startNeedChange = false;
tempStartDate = moment(moment(item.endHoldTime).format("YYYY-MM-DD HH:mm:00")).add(1,"m").format("YYYY-MM-DD HH:mm:00")
}
} }
} }
}) })
...@@ -1053,8 +1055,15 @@ ...@@ -1053,8 +1055,15 @@
} }
}) })
let startDateTime = ''
if(this.orderType ==2){
startDateTime = this.orderInfo.endDate
if(this.orderInfo.status ==2){
startDateTime = moment().format("YYYY-MM-DD HH:mm:00")
}
}
this.formatAllData = this.onTransiteForDate({ this.formatAllData = this.onTransiteForDate({
startDateTime:this.orderType ==2 && this.orderInfo.status == 1? this.orderInfo.endDate : '' , startDateTime,
list: JSON.parse(JSON.stringify(this.dateIntervalList)), list: JSON.parse(JSON.stringify(this.dateIntervalList)),
duration: this.roomLabelList[this.modeIndex].labelDuration duration: this.roomLabelList[this.modeIndex].labelDuration
}); });
...@@ -1652,8 +1661,8 @@ ...@@ -1652,8 +1661,8 @@
let timeStamp = moment(endDate).valueOf()-moment(startDate).valueOf(); let timeStamp = moment(endDate).valueOf()-moment(startDate).valueOf();
return timeStamp >= 3599000 return timeStamp >= 3599000
}, },
//检查套餐后半段60%的时间内是否有被占用,有被占用,则无法预定 //检查套餐后半段60%的时间内是否有被占用,有被占用,则无法预定,d为小时
onCheckPackUse(startDate,endDate) { onCheckPackUse(startDate,endDate,d = 0) {
let useStatus = false; let useStatus = false;
...@@ -1662,7 +1671,12 @@ ...@@ -1662,7 +1671,12 @@
let timeStamp = moment(endDate).valueOf()-moment(startDate).valueOf(); let timeStamp = moment(endDate).valueOf()-moment(startDate).valueOf();
if(d){
startStemp = startStemp + d*3600*1000;
}else{
startStemp = startStemp + timeStamp*0.4; startStemp = startStemp + timeStamp*0.4;
}
this.dateIntervalList.forEach(item=>{ this.dateIntervalList.forEach(item=>{
......
...@@ -182,7 +182,10 @@ import NoLogin from "@/components/noLogin/noLogin" ...@@ -182,7 +182,10 @@ import NoLogin from "@/components/noLogin/noLogin"
listBlankImage:config.assetsPath+'/no_data_icon.png', listBlankImage:config.assetsPath+'/no_data_icon.png',
}; };
}, },
onLoad() { onLoad(option) {
if(option.index){
this.statusIndex = option.index
}
// 隐藏原生的tabbar // 隐藏原生的tabbar
uni.hideTabBar(); uni.hideTabBar();
}, },
......
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
<view class="part"> <view class="part">
<button class="cu-btn block round line-pink lg" open-type="share">分享好友</button> <button class="cu-btn block round line-pink lg" open-type="share">分享好友</button>
</view> </view>
<view v-if="continStatus || orderInfo.status ==1" class="part"> <view v-if=" continStatus || orderInfo.status ==1 " class="part">
<button class="cu-btn block round bg-mauve lg" @tap="onCheckLogin">房间续单</button> <button class="cu-btn block round bg-mauve lg" @tap="onCheckLogin">房间续单</button>
</view> </view>
</view> </view>
......
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