...
|
...
|
@@ -3,27 +3,15 @@ let utils = require("../../utils/util.js") |
|
|
let method = require("../../utils/reuqest.js")
|
|
|
const app = getApp()
|
|
|
Component({
|
|
|
/**
|
|
|
* 组件的属性列表
|
|
|
*/
|
|
|
|
|
|
/**
|
|
|
* 组件的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
list:[], //时间数组
|
|
|
deliveryTime: "",
|
|
|
selfData: [], //自提日期
|
|
|
showDelivery: false,
|
|
|
deliveryTimeList: [{
|
|
|
day: "",
|
|
|
timeList: ""
|
|
|
}],
|
|
|
list: [], //自提时间数组
|
|
|
nowDay: 0,
|
|
|
selectTime: '',
|
|
|
selectTime: '', //自提时间
|
|
|
selectTimeIndex: '',
|
|
|
selectDay: 0,
|
|
|
timeLists: ''
|
|
|
},
|
|
|
pageLifetimes: {
|
|
|
show: function () {
|
...
|
...
|
@@ -42,36 +30,35 @@ Component({ |
|
|
lifetimes: {
|
|
|
created() {
|
|
|
let _this = this;
|
|
|
if(_this.data.nowDay==0){
|
|
|
if (_this.data.nowDay == 0) {
|
|
|
method.getRequest("/myUser/period/" + '1', data => {
|
|
|
//let list=this
|
|
|
if (data.statusCode == 0) {
|
|
|
_this.setData({
|
|
|
list:data.data
|
|
|
list: data.data
|
|
|
})
|
|
|
}
|
|
|
console.log(_this.data.nowDay,'now')
|
|
|
console.log(_this.data.nowDay, 'now')
|
|
|
console.log(_this.data.deliveryTimeList, 'list')
|
|
|
})
|
|
|
}else{
|
|
|
} else {
|
|
|
method.getRequest("/myUser/period/" + '2', data => {
|
|
|
//let list=this
|
|
|
if (data.statusCode == 0) {
|
|
|
_this.setData({
|
|
|
list:data.data
|
|
|
list: data.data
|
|
|
})
|
|
|
}
|
|
|
console.log(_this.data.nowDay,'now')
|
|
|
console.log(_this.data.nowDay, 'now')
|
|
|
console.log(_this.data.deliveryTimeList, 'list')
|
|
|
})
|
|
|
}
|
|
|
|
|
|
|
|
|
},
|
|
|
attached() {
|
|
|
console.log("在组件实例进入页面节点树时执行")
|
|
|
},
|
|
|
ready() {
|
|
|
|
|
|
|
|
|
console.log("在组件在视图层布局完成后执行")
|
|
|
},
|
|
|
moved() {
|
...
|
...
|
@@ -83,60 +70,43 @@ Component({ |
|
|
error() {
|
|
|
console.log("每当组件方法抛出错误时执行")
|
|
|
},
|
|
|
/*组件所在页面的生命周期 */
|
|
|
pageLifetimes: {
|
|
|
show: function () {
|
|
|
// 页面被展示
|
|
|
console.log("页面被展示")
|
|
|
},
|
|
|
hide: function () {
|
|
|
// 页面被隐藏
|
|
|
console.log("页面被隐藏")
|
|
|
},
|
|
|
resize: function (size) {
|
|
|
// 页面尺寸变化
|
|
|
console.log("页面尺寸变化")
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
getnowDay(e) {
|
|
|
this.setData({
|
|
|
nowDay: e.currentTarget.dataset.index
|
|
|
})
|
|
|
console.log(this.data.nowDay,'nowday')
|
|
|
console.log(this.data.nowDay, 'nowday')
|
|
|
let _this = this;
|
|
|
if(_this.data.nowDay==0){
|
|
|
if (_this.data.nowDay == 0) {
|
|
|
method.getRequest("/myUser/period/" + '1', data => {
|
|
|
//let list=this
|
|
|
if (data.statusCode == 0) {
|
|
|
_this.setData({
|
|
|
list:data.data
|
|
|
list: data.data
|
|
|
})
|
|
|
}
|
|
|
console.log(_this.data.nowDay,'now')
|
|
|
console.log(_this.data.nowDay, 'now')
|
|
|
console.log(_this.data.deliveryTimeList, 'list')
|
|
|
})
|
|
|
}else{
|
|
|
} else {
|
|
|
method.getRequest("/myUser/period/" + '2', data => {
|
|
|
//let list=this
|
|
|
if (data.statusCode == 0) {
|
|
|
_this.setData({
|
|
|
list:data.data
|
|
|
list: data.data
|
|
|
})
|
|
|
}
|
|
|
console.log(_this.data.nowDay,'now')
|
|
|
console.log(_this.data.nowDay, 'now')
|
|
|
console.log(_this.data.deliveryTimeList, 'list')
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
clickTime(e) {
|
|
|
let selfData = this.data.selfData[this.data.nowDay]
|
|
|
let id= e.currentTarget.dataset.id;
|
|
|
let index= e.currentTarget.dataset.index;
|
|
|
let id = e.currentTarget.dataset.id;
|
|
|
let index = e.currentTarget.dataset.index;
|
|
|
let _this = this;
|
|
|
// let selectTime = this.data.deliveryTimeList[this.data.nowDay].timeList[index]
|
|
|
let deliveryTime = selfData.year + '-' + selfData.month + '-' + selfData.day + ' '
|
|
|
let deliveryTime = selfData.year + '-' + selfData.month + '-' + selfData.day + ' '
|
|
|
let nowDay = this.data.nowDay
|
|
|
this.setData({
|
|
|
selectTimeIndex: index,
|
...
|
...
|
@@ -144,15 +114,16 @@ Component({ |
|
|
deliveryTime: deliveryTime,
|
|
|
selectDay: nowDay
|
|
|
})
|
|
|
// this.triggerEvent('selectTime', {
|
|
|
// deliveryTime: this.data.deliveryTime
|
|
|
// })
|
|
|
this.data.list.map((item,index)=>{
|
|
|
if(item.id === id){
|
|
|
this.data.list.map((item, index) => {
|
|
|
if (item.id === id) {
|
|
|
let times = item.start + '-' + item.end
|
|
|
_this.triggerEvent('selectTime',{time : times,flag : false,timeId:item.id,deliveryTime:this.data. deliveryTime})
|
|
|
//_this.triggerEvent('showTime',false)
|
|
|
wx.setStorageSync('selecClick',true)
|
|
|
_this.triggerEvent('selectTime', {
|
|
|
time: times,
|
|
|
flag: false,
|
|
|
timeId: item.id,
|
|
|
deliveryTime: this.data.deliveryTime
|
|
|
})
|
|
|
wx.setStorageSync('selecClick', true)
|
|
|
}
|
|
|
})
|
|
|
},
|
...
|
...
|
@@ -166,63 +137,62 @@ Component({ |
|
|
})
|
|
|
//获取时间段
|
|
|
let timeDate = new Date(date.getTime());
|
|
|
let todayList = getTimeList(timeDate.getHours(), 1);
|
|
|
deliveryTimeList.push({
|
|
|
timeList: todayList
|
|
|
});
|
|
|
let nextDayList = getTimeList(9, 0);
|
|
|
for (let i = 1; i < 5; i++) {
|
|
|
deliveryTimeList.push({
|
|
|
timeList: nextDayList
|
|
|
});
|
|
|
}
|
|
|
this.triggerEvent('selectTime', {
|
|
|
deliveryTime: this.data.deliveryTime
|
|
|
})
|
|
|
this.setData({
|
|
|
deliveryTimeList: []
|
|
|
})
|
|
|
this.setData({
|
|
|
deliveryTimeList: deliveryTimeList
|
|
|
})
|
|
|
// let todayList = getTimeList(timeDate.getHours(), 1);
|
|
|
// deliveryTimeList.push({
|
|
|
// timeList: todayList
|
|
|
// });
|
|
|
// let nextDayList = getTimeList(9, 0);
|
|
|
// for (let i = 1; i < 5; i++) {
|
|
|
// deliveryTimeList.push({
|
|
|
// timeList: nextDayList
|
|
|
// });
|
|
|
// }
|
|
|
// this.triggerEvent('selectTime', {
|
|
|
// deliveryTime: this.data.deliveryTime
|
|
|
// })
|
|
|
// this.setData({
|
|
|
// deliveryTimeList: []
|
|
|
// })
|
|
|
// this.setData({
|
|
|
// deliveryTimeList: deliveryTimeList
|
|
|
// })
|
|
|
//获取时间段
|
|
|
// today 1 是今天 0 不是今天
|
|
|
function getTimeList(hour, today) {
|
|
|
|
|
|
let timeList = [];
|
|
|
// let startTime = hour <= 9 ? 9 : hour;
|
|
|
// for (let i = 0; i < 8; i++) {
|
|
|
// if (((hour <= 9) && (startTime + 2 * i >21)) || ((hour > 9) && (startTime + 2 * i >= 21))) {
|
|
|
// break;
|
|
|
// } else {
|
|
|
// if (hour <= 9) {
|
|
|
// timeList.push(
|
|
|
// startTime + 2 * i + ":00" + "-" + (startTime + 2 * (i + 1)) + ":00"
|
|
|
// );
|
|
|
// } else {
|
|
|
// if (startTime % 2 === 0) {
|
|
|
// timeList.push(
|
|
|
// startTime + 2 * i + 1 + ":00" + "-" + (startTime + 2 * i + 3) + ":00"
|
|
|
// );
|
|
|
// } else {
|
|
|
// console.log(i,'i')
|
|
|
// timeList.push(
|
|
|
// startTime + 2 * i +2 + ":00" + "-" + (startTime + 2 * i + 4) + ":00"
|
|
|
// );
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
method.getRequest("/myUser/period/" + '1', data => {
|
|
|
if (data.statusCode == 0) {
|
|
|
that.setData({
|
|
|
deliveryTimeList: data.data
|
|
|
})
|
|
|
timeList = data.data
|
|
|
}
|
|
|
console.log(timeList, 'list')
|
|
|
})
|
|
|
return timeList;
|
|
|
}
|
|
|
// function getTimeList(hour, today) {
|
|
|
// let timeList = [];
|
|
|
// // let startTime = hour <= 9 ? 9 : hour;
|
|
|
// // for (let i = 0; i < 8; i++) {
|
|
|
// // if (((hour <= 9) && (startTime + 2 * i >21)) || ((hour > 9) && (startTime + 2 * i >= 21))) {
|
|
|
// // break;
|
|
|
// // } else {
|
|
|
// // if (hour <= 9) {
|
|
|
// // timeList.push(
|
|
|
// // startTime + 2 * i + ":00" + "-" + (startTime + 2 * (i + 1)) + ":00"
|
|
|
// // );
|
|
|
// // } else {
|
|
|
// // if (startTime % 2 === 0) {
|
|
|
// // timeList.push(
|
|
|
// // startTime + 2 * i + 1 + ":00" + "-" + (startTime + 2 * i + 3) + ":00"
|
|
|
// // );
|
|
|
// // } else {
|
|
|
// // console.log(i,'i')
|
|
|
// // timeList.push(
|
|
|
// // startTime + 2 * i +2 + ":00" + "-" + (startTime + 2 * i + 4) + ":00"
|
|
|
// // );
|
|
|
// // }
|
|
|
// // }
|
|
|
// // }
|
|
|
// // }
|
|
|
// method.getRequest("/myUser/period/" + '1', data => {
|
|
|
// if (data.statusCode == 0) {
|
|
|
// that.setData({
|
|
|
// deliveryTimeList: data.data
|
|
|
// })
|
|
|
// timeList = data.data
|
|
|
// }
|
|
|
// })
|
|
|
// return timeList;
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|