|
...
|
...
|
@@ -14,12 +14,12 @@ Component({ |
|
|
|
attached(){
|
|
|
|
},
|
|
|
|
observers: {
|
|
|
|
'date'(newdate){
|
|
|
|
'date': async function(newdate) {
|
|
|
|
console.log('section',this.data.date,newdate,this.data.section)
|
|
|
|
//今天日期
|
|
|
|
if(newdate){
|
|
|
|
let today=util.unixtoTime(new Date()/1000,'YYYY-MM-DD');
|
|
|
|
this.getsectionlist();
|
|
|
|
await this.getsectionlist();
|
|
|
|
if(today==newdate){
|
|
|
|
this.markoversection();
|
|
|
|
}else{
|
|
...
|
...
|
@@ -57,30 +57,62 @@ Component({ |
|
|
|
},
|
|
|
|
methods:{
|
|
|
|
getsectionlist(){
|
|
|
|
let section={'morning':'早餐','noon':'午餐','night':'晚餐','midnight':'夜宵'};
|
|
|
|
let sectionlist=[];
|
|
|
|
for(let key in this.data.seller.daily){
|
|
|
|
if(this.data.seller.daily[key]!=""){
|
|
|
|
sectionlist.push({
|
|
|
|
section:key,
|
|
|
|
sectiondur:this.data.seller.daily[key],
|
|
|
|
showmark:section[key],
|
|
|
|
overdate:false,
|
|
|
|
isselected:false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
sectionlist:sectionlist
|
|
|
|
})
|
|
|
|
console.log(sectionlist)
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
App.Seller.getMealSectionByDay({
|
|
|
|
sellerid: this.data.seller.id,
|
|
|
|
day: this.data.date,
|
|
|
|
}).then(res => {
|
|
|
|
let data = res.data;
|
|
|
|
let lunchDinnerList = [];
|
|
|
|
if (data.length <= 3 && !data[0].ddate_solt) {
|
|
|
|
data.forEach(i => {
|
|
|
|
if (i.mname == '早餐') {
|
|
|
|
lunchDinnerList.push({
|
|
|
|
mname: "早餐",
|
|
|
|
mdate: i.mdate,
|
|
|
|
ddate_solt: 1,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if (i.mname == '午餐') {
|
|
|
|
lunchDinnerList.push({
|
|
|
|
mname: "午餐",
|
|
|
|
mdate: i.mdate,
|
|
|
|
ddate_solt: 2,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if (i.mname == '晚餐') {
|
|
|
|
lunchDinnerList.push({
|
|
|
|
mname: "晚餐",
|
|
|
|
mdate: i.mdate,
|
|
|
|
ddate_solt: 3,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
lunchDinnerList = data;
|
|
|
|
}
|
|
|
|
lunchDinnerList.forEach((item,index)=>{
|
|
|
|
item.sectiondur = item.mdate;
|
|
|
|
item.showmark = item.mname;
|
|
|
|
item.section = 'ket'+index
|
|
|
|
item.overdate = false;
|
|
|
|
item.isselected = false;
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
sectionlist:lunchDinnerList
|
|
|
|
})
|
|
|
|
resolve();
|
|
|
|
}).catch(res => {
|
|
|
|
console.log(res, '获取多时段失败');
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
markoversection(){
|
|
|
|
let sectionlist=this.data.sectionlist;
|
|
|
|
//今天日期
|
|
|
|
let today=util.unixtoTime(new Date()/1000,'YYYY-MM-DD');
|
|
|
|
let curtimestamp=Math.ceil(new Date()/1000);
|
|
|
|
let interval=[],flag=false;
|
|
|
|
let interval=[],flag=false;
|
|
|
|
sectionlist.forEach((v,i)=>{
|
|
|
|
let sectionarr=v.sectiondur.split('-');
|
|
|
|
if(curtimestamp>Number(util.timetouUnix(today+' '+sectionarr[1]+':00'))){
|
|
...
|
...
|
@@ -128,11 +160,10 @@ Component({ |
|
|
|
selectsection(e){
|
|
|
|
let _target=e.currentTarget.dataset;
|
|
|
|
this.changesectionstyle(_target.section);
|
|
|
|
this.tellsection(_target.section,'click',_target.index);
|
|
|
|
console.log(_target.index);
|
|
|
|
this.tellsection(_target.section,'click',_target.index,_target.ddate_solt);
|
|
|
|
},
|
|
|
|
//通知时段
|
|
|
|
tellsection(selectsection,action,index){
|
|
|
|
tellsection(selectsection,action,index,ddate_solt){
|
|
|
|
console.log(index);
|
|
|
|
//2019-12-13修改
|
|
|
|
// let today=util.unixtoTime(new Date()/1000,'YYYY-MM-DD');
|
|
...
|
...
|
@@ -142,7 +173,8 @@ Component({ |
|
|
|
let endtimestamp=Number(util.timetouUnix(this.data.date+' '+sectionarr[1]+':00'));
|
|
|
|
let obj={
|
|
|
|
section:selectsection,
|
|
|
|
action:action
|
|
|
|
action:action,
|
|
|
|
ddate_solt,
|
|
|
|
}
|
|
|
|
console.log(curtimestamp,starttimestamp)
|
|
|
|
if(curtimestamp<starttimestamp){
|
...
|
...
|
|