Commit ddba3710 by zhangzhen

细节优化

parent 6b17151f
......@@ -534,7 +534,6 @@
dateList.push(obj)
}
this.dateList = dateList;
console.log(this.dateList,909090)
},
onSetSelectTime(){
if(this.dateIndex === 0){
......@@ -634,38 +633,12 @@
}
})
// 今天可连续选择的时段
let selectNum = 0;
let t = -1;
// let startInex = this.dateIntervalList.findIndex(item => item.status === 0)
this.dateIntervalList.forEach((val,i)=>{
if(selectNum>this.duration){
return
} else if(val.status === 0 || (val.status ==1 && Number(moment(val.endHoldTime).format('mm'))<20)){
selectNum+=1
if(t<0){
t = i
}
}else{
selectNum = 0
t = -1
}
})
if( selectNum <= this.duration || (selectNum >= this.duration && t>=24)){
if(this.dateIndex>=this.dateList.length-1){
this.onInitDateList()
}else{
this.dateIndex+=1;
}
this.onGetSortDistance();
return;
}
if(this.orderType === 2){
this.onSetEndTime()
}else{
this.onCheckDate();
return
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");
......@@ -716,9 +689,7 @@
this.setStartTime.duration+=1;
}
if(index >= this.dateIntervalList.length-1){
console.log(this.addM,"是否加一分钟")
if(!this.addM && this.dateIntervalList[0].status){
console.log(this.startTime,909090)
this.addM = true
// 开始时间加一分钟
let arr = this.startTime.split(":");
......@@ -865,7 +836,7 @@
preStartDate: this.dateObj.startDate,
preEndDate: this.dateObj.endDate,
orderType: this.orderType,
packageId:this.packageMode[this.modeIndex].id
packageId: this.index>0? this.packageMode[this.modeIndex].id:''
}).then(res => {
if (res.data.code == 200) {
if (res.data && res.data.data.length) {
......@@ -1057,42 +1028,63 @@
day: this.dateList[k].readDate,
orderType:this.orderType
}).then(res=>{
let n = 0
// 今天可连续选择的时段
let selectNum = 0;
//预定节点
let t = -1;
res.data.data.forEach((item,k)=>{
if(n<=this.duration && (item.status===0||(item.status ==1 && Number(moment(item.endHoldTime).format('mm'))<29))){
n += 1
if(t<0){
t = k
}
}else{
if(n<this.duration){
n=0
//预定开始时间
let startDate = '';
let ms = 0;
let endDate = ""
// 查询有无可预定的时段
let todaySelectStatus = false;
res.data.data.forEach((val,i)=>{
if(val.status ==1 && moment(val.endHoldTime).format('mm')<59 && selectNum == 0){
startDate = moment(val.endHoldTime).format("YYYY-MM-DD HH:mm:ss")
selectNum += 1
t = i
} else if(val.status ==1 && selectNum > 0 ){
let start = new Date(startDate).getTime()
let end = new Date(val.startHoldTime).getTime()
if(end-start >this.duration*60*60*1000){
todaySelectStatus = true;
} else {
startDate = ''
selectNum = 0
endDate = ""
t = -1
}
} else if(selectNum == 0 && !val.status){
startDate = val.timeHour+":00:00";
selectNum+=1
t = i
}else if(selectNum>0 && !val.status){
// 计算时长
let start = new Date(startDate).getTime()
endDate = endDate? moment(endDate).add(1,'h').format("YYYY-MM-DD HH:mm:ss") : moment(startDate).add(1,'h').format("YYYY-MM-DD HH:mm:ss")
let end = new Date(endDate).getTime()
if(end-start > this.duration*60*60*1000){
todaySelectStatus = true;
} else {
selectNum+=1
}
}
})
if(n <= this.duration || (n >= this.duration && t>=24)){
if((todaySelectStatus && t >=24) || !todaySelectStatus ){
uni.showToast({
icon:"none",
title:"当前日期无可预约时段"
})
return
return;
}
this.dateIndex = k
this.selectCouponIndex = -1
this.setStartTime = {
status:false,
startTime:'',
startDate:'',
duration:0,
days:1
}
this.days = 1;
this.addM = false;
this.onGetSortDistance()
})
},
// 开始选择时间
......@@ -1217,24 +1209,20 @@
this.$refs.confirmPop.open();
},
onOrder(){
this.onOrderCreate()
// wx.requestSubscribeMessage({
// tmplIds: [
// 'oTc000e4NHkoc7v9OLBZiwM6Q6SFzguemrx6d0iuVS8',
// 'K8fbcKVq46w9o7Ekpesn74RThj_Yw6hFNwA-A5L3XA0',
// 'HB2_moQRQrXC2cKw6zE08NU3AQO9Ggj3aAOg0lIgecg'
// ],
// success: (res) => {
// // uni.setStorageSync("orderUseMessage", true);
// // this.$refs.confirmPop.open();
// // this.onOrderCreate()
// },
// complete: (res) => {
// }
// })
wx.requestSubscribeMessage({
tmplIds: [
'HB2_moQRQrXC2cKw6zE08FF8UZJ5ue1h_qXZhvOkacc',
'UkvsRnZkZB_w3MqXPbRhi4jEk8ML4N9PWT3rnd3Bhxg',
'K8fbcKVq46w9o7Ekpesn70wK3mYjXqdSfFUth4AufqU'
],
success: (res) => {
uni.setStorageSync("orderUseMessage", true);
},
complete: (res) => {
// this.$refs.confirmPop.open();
this.onOrderCreate();
}
})
},
onOrderCreate() {
this.onCancle();
......@@ -1284,7 +1272,6 @@
})
},
"fail": (resp) => {
console.log(resp,"支付失败")
// 取消支付或支付失败
uni.showToast({
title: "取消支付"
......@@ -1466,6 +1453,82 @@
obj.endDate = `${moment(obj.startDate).format("YYYY-MM-DD")} ${endTime}:00`
}
return obj;
},
onCheckDate(){
// 今天可连续选择的时段
let selectNum = 0;
//预定节点
let t = -1;
//预定开始时间
let startDate = '';
let ms = 0;
let endDate = ""
// 查询有无可预定的时段
let todaySelectStatus = false;
this.dateIntervalList.forEach((val,i)=>{
if(val.status ==1 && moment(val.endHoldTime).format('mm')<59 && selectNum == 0){
startDate = moment(val.endHoldTime).format("YYYY-MM-DD HH:mm:ss")
selectNum += 1
t = i
} else if(val.status ==1 && selectNum > 0 ){
let start = new Date(startDate).getTime()
let end = new Date(val.startHoldTime).getTime()
if(end-start >this.duration*60*60*1000){
todaySelectStatus = true;
} else {
startDate = ''
selectNum = 0
endDate = ""
t = -1
}
} else if(selectNum == 0 && !val.status){
startDate =val.timeHour+":00:00";
selectNum+=1
t = i
}else if(selectNum>0 && !val.status){
// 计算时长
let start = new Date(startDate).getTime()
endDate = endDate? moment(endDate).add(1,'h').format("YYYY-MM-DD HH:mm:ss") : moment(startDate).add(1,'h').format("YYYY-MM-DD HH:mm:ss")
let end = new Date(endDate).getTime()
if(end-start > this.duration*60*60*1000){
todaySelectStatus = true;
} else {
selectNum+=1
}
}
})
if((todaySelectStatus && t >=24) || !todaySelectStatus ){
if(this.dateIndex>=this.dateList.length-1){
this.onInitDateList()
}else{
this.dateIndex+=1;
}
this.onGetSortDistance();
return;
}else{
let startDateTime= "";
if(!this.addM && t != 0 ){
this.addM = true
startDateTime = moment(startDate).add(1,"m").format("YYYY-MM-DD");
this.startTime = moment(startDate).add(1,"m").format("HH:mm");
} else{
startDateTime = moment(startDate).format("YYYY-MM-DD");
this.startTime = moment(startDate).format("HH:mm");
}
let i = this.dateList.findIndex(item => item.readDate === startDateTime)
if(this.dateIndex !== i && this.dateIndex>=0){
this.dateIndex = i;
this.onGetSortDistance();
return;
}
this.onSetEndTime()
}
}
}
}
......
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