Commit 5cae7c58 by zhangzhen

细节优化

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