153 lines
5.2 KiB
JavaScript
153 lines
5.2 KiB
JavaScript
"use strict";
|
|
const pages_goToPay_utils = require("./utils.js");
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const _sfc_main = {
|
|
name: "distributionBox",
|
|
props: {
|
|
getTime: String
|
|
// 接收父组件传来的初始值
|
|
},
|
|
data() {
|
|
return {
|
|
sendTime: "",
|
|
sRightDate: "",
|
|
sLDate: "",
|
|
jmhDay: [],
|
|
timeList: [
|
|
{ disabled: false, time: "10:00-12:00", id: 1 },
|
|
{ disabled: false, time: "12:00-14:00", id: 2 },
|
|
{ disabled: false, time: "14:00-16:00", id: 3 },
|
|
{ disabled: false, time: "16:00-18:00", id: 4 },
|
|
{ disabled: false, time: "18:00-20:00", id: 5 }
|
|
]
|
|
};
|
|
},
|
|
mounted() {
|
|
this.getNextDay();
|
|
},
|
|
methods: {
|
|
close() {
|
|
this.$refs.popup.close();
|
|
},
|
|
getWeekDate(day) {
|
|
const weeks = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
|
|
return weeks[day];
|
|
},
|
|
getNextDay() {
|
|
const day = this.getWeekDate((/* @__PURE__ */ new Date()).getDay());
|
|
const isDay = pages_goToPay_utils.getDate().fullDate;
|
|
const nextDay = this.getWeekDate(new Date((/* @__PURE__ */ new Date()).getTime() + 24 * 60 * 60 * 1e3).getDay());
|
|
const nDate = pages_goToPay_utils.getDate(new Date((/* @__PURE__ */ new Date()).getTime() + 24 * 60 * 60 * 1e3)).fullDate;
|
|
const HDay = this.getWeekDate(new Date((/* @__PURE__ */ new Date()).getTime() + 48 * 60 * 60 * 1e3).getDay());
|
|
const hDate = pages_goToPay_utils.getDate(new Date((/* @__PURE__ */ new Date()).getTime() + 48 * 60 * 60 * 1e3)).fullDate;
|
|
const d1 = hDate.substr(hDate.indexOf("-") + 1);
|
|
this.sLDate = isDay;
|
|
this.selectLDate(1);
|
|
this.jmhDay = [
|
|
{ name: day, id: 1, formatDate: isDay, desc: "今天" },
|
|
{ name: nextDay, id: 2, formatDate: nDate, desc: "明天" },
|
|
{ name: HDay, id: 3, formatDate: hDate, desc: d1.substr(0, d1.indexOf("-")) + "月" + d1.substr(d1.indexOf("-") + 1) + "日" }
|
|
];
|
|
},
|
|
showBox() {
|
|
this.$refs.popup.open();
|
|
},
|
|
selectRDate(item) {
|
|
if (item.disabled) {
|
|
return;
|
|
}
|
|
this.sRightDate = item.time;
|
|
this.sendTime = `${this.sLDate} ${item.time}`;
|
|
this.$emit("update:getTime", this.sendTime);
|
|
this.$emit("timeSelected", this.sendTime);
|
|
this.$refs.popup.close();
|
|
},
|
|
selectLDate(val) {
|
|
if (val !== 1) {
|
|
this.sLDate = val.formatDate;
|
|
}
|
|
let t = [
|
|
{ disabled: false, time: "10:00-12:00", id: 1 },
|
|
{ disabled: false, time: "12:00-14:00", id: 2 },
|
|
{ disabled: false, time: "14:00-16:00", id: 3 },
|
|
{ disabled: false, time: "16:00-18:00", id: 4 },
|
|
{ disabled: false, time: "18:00-20:00", id: 5 }
|
|
];
|
|
if (val.desc === "今天" || val === 1) {
|
|
const currentHour = (/* @__PURE__ */ new Date()).getHours();
|
|
if (currentHour <= 10) {
|
|
this.timeList = t;
|
|
} else if (currentHour <= 12) {
|
|
t[0].disabled = true;
|
|
this.timeList = t;
|
|
} else if (currentHour <= 14) {
|
|
t[0].disabled = true;
|
|
t[1].disabled = true;
|
|
this.timeList = t;
|
|
} else if (currentHour <= 16) {
|
|
t[0].disabled = true;
|
|
t[1].disabled = true;
|
|
t[2].disabled = true;
|
|
this.timeList = t;
|
|
} else if (currentHour <= 18) {
|
|
t[0].disabled = true;
|
|
t[1].disabled = true;
|
|
t[2].disabled = true;
|
|
t[3].disabled = true;
|
|
this.timeList = t;
|
|
} else if (currentHour <= 20) {
|
|
t[0].disabled = true;
|
|
t[1].disabled = true;
|
|
t[2].disabled = true;
|
|
t[3].disabled = true;
|
|
t[4].disabled = true;
|
|
this.timeList = t;
|
|
}
|
|
} else {
|
|
this.timeList = t;
|
|
}
|
|
this.sRightDate = "";
|
|
}
|
|
}
|
|
};
|
|
if (!Array) {
|
|
const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
|
|
_easycom_uni_popup2();
|
|
}
|
|
const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
|
|
if (!Math) {
|
|
_easycom_uni_popup();
|
|
}
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
return common_vendor.e({
|
|
a: common_vendor.f($data.jmhDay, (item, index, i0) => {
|
|
return {
|
|
a: common_vendor.t(item.desc),
|
|
b: common_vendor.t(item.name),
|
|
c: common_vendor.o(($event) => $options.selectLDate(item), index),
|
|
d: common_vendor.n($data.sLDate === item.formatDate ? "ed" : ""),
|
|
e: index
|
|
};
|
|
}),
|
|
b: common_vendor.f($data.timeList, (item, index, i0) => {
|
|
return {
|
|
a: common_vendor.t(item.time),
|
|
b: common_vendor.t(item.disabled ? " (超出配送时间)" : ""),
|
|
c: common_vendor.o(($event) => $options.selectRDate(item), index),
|
|
d: common_vendor.n($data.sRightDate === item.time ? "ed" : ""),
|
|
e: common_vendor.n(item.disabled ? "disabled" : ""),
|
|
f: index
|
|
};
|
|
}),
|
|
c: $data.timeList.length < 1
|
|
}, $data.timeList.length < 1 ? {} : {}, {
|
|
d: common_vendor.o(($event) => $options.close()),
|
|
e: common_vendor.sr("popup", "1d253218-0"),
|
|
f: common_vendor.p({
|
|
type: "bottom"
|
|
})
|
|
});
|
|
}
|
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-1d253218"]]);
|
|
wx.createComponent(Component);
|