|
@@ -1,6 +1,5 @@
|
|
|
"use strict";
|
|
|
const common_vendor = require("../../common/vendor.js");
|
|
|
-const common_assets = require("../../common/assets.js");
|
|
|
const _sfc_main = {
|
|
|
props: {
|
|
|
isQuantum: {
|
|
@@ -10,7 +9,7 @@ const _sfc_main = {
|
|
|
isMultiple: {
|
|
|
//是否多选
|
|
|
type: Boolean,
|
|
|
- default: true
|
|
|
+ default: false
|
|
|
},
|
|
|
isSection: {
|
|
|
//预约时间段
|
|
@@ -19,6 +18,10 @@ const _sfc_main = {
|
|
|
},
|
|
|
disableText: {
|
|
|
//禁用显示的文本
|
|
|
+ type: String,
|
|
|
+ default: "已预约"
|
|
|
+ },
|
|
|
+ disableSumText: {
|
|
|
type: String,
|
|
|
default: "已约满"
|
|
|
},
|
|
@@ -35,12 +38,12 @@ const _sfc_main = {
|
|
|
selectedTabColor: {
|
|
|
// 日期栏选中的颜色
|
|
|
type: String,
|
|
|
- default: "#FB4B5C"
|
|
|
+ default: "#51bf81"
|
|
|
},
|
|
|
selectedItemColor: {
|
|
|
// 时间选中的颜色
|
|
|
type: String,
|
|
|
- default: "#FB4B5C"
|
|
|
+ default: "#51bf81"
|
|
|
},
|
|
|
beginTime: {
|
|
|
type: String,
|
|
@@ -99,7 +102,7 @@ const _sfc_main = {
|
|
|
"teacher_name": "张老师",
|
|
|
"teacher_desc": "擅长舞蹈",
|
|
|
"course_name": "拳击初级课",
|
|
|
- "course_image": "http://kailin.com/uploads/images/1/img.jpg",
|
|
|
+ "course_image": "../../static/logo2.jpg",
|
|
|
"course_desc": "拳击讲解",
|
|
|
"address": "一方天地"
|
|
|
}
|
|
@@ -119,14 +122,28 @@ const _sfc_main = {
|
|
|
"teacher_name": "王老师",
|
|
|
"teacher_desc": "从业20年,资深老教室",
|
|
|
"course_name": "拳击初级课",
|
|
|
- "course_image": "http://kailin.com/uploads/images/1/img.jpg",
|
|
|
+ "course_image": "../../static/logo2.jpg",
|
|
|
"course_desc": "拳击讲解",
|
|
|
"address": "一方天地"
|
|
|
}
|
|
|
}
|
|
|
],
|
|
|
+ course_number: 30,
|
|
|
+ reservation_number: 0,
|
|
|
+ teacher_desc: "",
|
|
|
+ course_name: "",
|
|
|
+ course_image: "",
|
|
|
start_time: 1731823931,
|
|
|
+ //开始时间戳
|
|
|
end_time: 1731324931,
|
|
|
+ //结束时间戳
|
|
|
+ orders_product_id: 0,
|
|
|
+ //商品id
|
|
|
+ course_id: 0,
|
|
|
+ //课程id
|
|
|
+ schedule_id: 0,
|
|
|
+ //排课id
|
|
|
+ teacherActive: -1,
|
|
|
orderDateTime: "暂无选择",
|
|
|
// 选中时间
|
|
|
orderTimeArr: {},
|
|
@@ -147,26 +164,109 @@ const _sfc_main = {
|
|
|
//选择的日期
|
|
|
timeQuanBegin: "",
|
|
|
//时间段开始时间
|
|
|
- timeQuanEnd: "",
|
|
|
+ timeQuanEnd: ""
|
|
|
//时间段结束时间
|
|
|
- isTime: [],
|
|
|
+ // isTime:[],
|
|
|
// teacherList: ['王老师', '崔老师','王老师', '崔老师'],
|
|
|
// days: ['周一', '周二', '周三', '周四', '周五'],
|
|
|
- //商品Id
|
|
|
- orders_product_id: 0
|
|
|
};
|
|
|
},
|
|
|
created(props) {
|
|
|
this.selectDate = this.nowDate = this.currentTime().date;
|
|
|
this.initOnload();
|
|
|
},
|
|
|
+ onLoad(e) {
|
|
|
+ let { orders_product_id, course_id } = e;
|
|
|
+ this.orders_product_id = orders_product_id;
|
|
|
+ this.course_id = course_id;
|
|
|
+ },
|
|
|
+ onShow() {
|
|
|
+ this.defaultTeacherDesc();
|
|
|
+ if (this.orders_product_id > 0 && this.course_id > 0) {
|
|
|
+ this.$http.request("api/course/get_schedule_list", { orders_product_id: this.orders_product_id, course_id: this.course_id }, "post").then((res) => {
|
|
|
+ if (res.code === "success") {
|
|
|
+ this.data = res.data;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ //老师选择事件
|
|
|
+ selectTeacher(index, item) {
|
|
|
+ if (this.teacherActive == index)
|
|
|
+ return;
|
|
|
+ this.teacherActive = index;
|
|
|
+ if (!this.isMultiple) {
|
|
|
+ this.orderDateTime = "暂无选择";
|
|
|
+ }
|
|
|
+ if (this.data.length > 0) {
|
|
|
+ if (this.teacherActive == index) {
|
|
|
+ this.course_number = this.data[index]["list"].course_number;
|
|
|
+ this.reservation_number = this.data[index]["list"].reservation_number;
|
|
|
+ this.teacher_desc = this.data[index]["list"].teacher_desc;
|
|
|
+ this.course_name = this.data[index]["list"].course_name;
|
|
|
+ this.course_image = this.data[index]["list"].course_image;
|
|
|
+ this.start_time = this.data[index]["list"].start_time;
|
|
|
+ this.schedule_id = this.data[index]["list"].id;
|
|
|
+ this.initOnload();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //默认选项
|
|
|
+ defaultTeacherDesc() {
|
|
|
+ if (this.data.length > 0) {
|
|
|
+ this.course_number = this.data[0]["list"].course_number;
|
|
|
+ this.reservation_number = this.data[0]["list"].reservation_number;
|
|
|
+ this.teacher_desc = this.data[0]["list"].teacher_desc;
|
|
|
+ this.course_name = this.data[0]["list"].course_name;
|
|
|
+ this.course_image = this.data[0]["list"].course_image;
|
|
|
+ this.teacherActive = 0;
|
|
|
+ this.start_time = this.data[0]["list"].start_time;
|
|
|
+ this.schedule_id = this.data[0]["list"].id;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //预约课程事件
|
|
|
+ reservationPopup() {
|
|
|
+ if (this.schedule_id === 0) {
|
|
|
+ common_vendor.index.showToast({
|
|
|
+ title: "请选择老师",
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.orderDateTime === "暂无选择") {
|
|
|
+ common_vendor.index.showToast({
|
|
|
+ title: "请选择预约时间",
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$http.request("api/course/get_schedule_list", { course_id: this.course_id, orders_product_id: this.orders_product_id }, "post").then((res) => {
|
|
|
+ if (res.code === "success") {
|
|
|
+ if (this.reservation_number < this.course_number) {
|
|
|
+ this.reservation_number++;
|
|
|
+ }
|
|
|
+ this.handleSubmit();
|
|
|
+ this.initOnload();
|
|
|
+ this.$refs.outcomePopup.open("center");
|
|
|
+ } else {
|
|
|
+ common_vendor.index.showToast({
|
|
|
+ title: `${res.msg}`,
|
|
|
+ icon: "error"
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ outcomeButton() {
|
|
|
+ this.orderDateTime = "暂无选择";
|
|
|
+ this.$refs.outcomePopup.close();
|
|
|
+ },
|
|
|
initOnload() {
|
|
|
this.dateArr = this.initData();
|
|
|
this.timeArr = this.initTime(this.beginTime, this.endTime, this.timeInterval, this.isQuantum);
|
|
|
this.timeQuanBegin = this.timeQuanEnd = "";
|
|
|
console.log(this.orderTimeArr);
|
|
|
- let isFullTime = true;
|
|
|
this.timeArr.forEach((item, index) => {
|
|
|
if (this.isQuantum) {
|
|
|
const cur_be_time = `${this.selectDate} ${item.begin}:00`;
|
|
@@ -188,6 +288,9 @@ const _sfc_main = {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
+ if (this.reservation_number === this.course_number) {
|
|
|
+ item.disableSum = true;
|
|
|
+ }
|
|
|
this.appointTime.forEach((t) => {
|
|
|
let [date, time] = t.split(" ");
|
|
|
if (date == this.selectDate && item.time == time) {
|
|
@@ -201,29 +304,23 @@ const _sfc_main = {
|
|
|
item.disable = true;
|
|
|
}
|
|
|
}
|
|
|
- if (!item.disable) {
|
|
|
- isFullTime = false;
|
|
|
- }
|
|
|
+ if (!item.disable)
|
|
|
+ ;
|
|
|
this.isSection && (item.isInclude = false);
|
|
|
if (this.isMultiple && (this.orderTimeArr[this.selectDate] || []).includes(item.time)) {
|
|
|
item.isActive = true;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- this.orderDateTime = isFullTime ? "暂无选择" : this.selectDate;
|
|
|
this.timeActive = -1;
|
|
|
- for (let i = 0, len = this.timeArr.length; i < len; i++) {
|
|
|
- if (!this.timeArr[i].disable) {
|
|
|
- this.orderDateTime = `${this.selectDate} ${this.timeArr[i].time}`;
|
|
|
- this.timeActive = i;
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
},
|
|
|
// 日期选择事件
|
|
|
selectDateEvent(index, item) {
|
|
|
this.dateActive = index;
|
|
|
this.selectDate = item.date;
|
|
|
+ if (!this.isMultiple) {
|
|
|
+ this.orderDateTime = "暂无选择";
|
|
|
+ }
|
|
|
this.initOnload();
|
|
|
},
|
|
|
// 时间选择事件
|
|
@@ -233,6 +330,8 @@ const _sfc_main = {
|
|
|
}
|
|
|
if (item.disable)
|
|
|
return;
|
|
|
+ if (item.disableSum)
|
|
|
+ return;
|
|
|
if (this.isMultiple) {
|
|
|
item.isActive = !item.isActive;
|
|
|
this.timeArr = this.timeArr.slice();
|
|
@@ -241,6 +340,7 @@ const _sfc_main = {
|
|
|
return prev;
|
|
|
}, []);
|
|
|
} else {
|
|
|
+ console.log("hhh");
|
|
|
this.timeActive = index;
|
|
|
this.orderDateTime = `${this.selectDate} ${item.time}`;
|
|
|
}
|
|
@@ -313,16 +413,6 @@ const _sfc_main = {
|
|
|
]);
|
|
|
},
|
|
|
handleSubmit() {
|
|
|
- if (this.isSection) {
|
|
|
- this.handleChange();
|
|
|
- this.$emit("change", {
|
|
|
- beginTime: `${this.selectDate} ${this.timeQuanBegin}`,
|
|
|
- endTime: `${this.selectDate} ${this.timeQuanEnd}`
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
- console.log("我执行拉?");
|
|
|
- console.log(this.orderTimeArr);
|
|
|
if (this.isMultiple) {
|
|
|
if (this.isQuantum) {
|
|
|
this.$emit("change", this.orderTimeArr);
|
|
@@ -335,8 +425,8 @@ const _sfc_main = {
|
|
|
});
|
|
|
}
|
|
|
this.$emit("change", time);
|
|
|
- this.isTime = time;
|
|
|
} else {
|
|
|
+ this.appointTime.push(this.orderDateTime);
|
|
|
this.$emit("change", this.orderDateTime);
|
|
|
}
|
|
|
},
|
|
@@ -372,7 +462,7 @@ const _sfc_main = {
|
|
|
const days = ["日", "一", "二", "三", "四", "五", "六"];
|
|
|
return {
|
|
|
allDate: `${year}/${this.strFormat(month)}/${this.strFormat(date)}`,
|
|
|
- date: `${this.strFormat(date)}`,
|
|
|
+ date: `${this.strFormat(year)}-${this.strFormat(month)}-${this.strFormat(date)}`,
|
|
|
//返回的日期 07-01
|
|
|
day: `周${days[day]}`,
|
|
|
//返回的礼拜天数 星期一
|
|
@@ -380,18 +470,17 @@ const _sfc_main = {
|
|
|
//返回的时钟 08:00
|
|
|
};
|
|
|
},
|
|
|
- //获取最近5天的日期和礼拜天数
|
|
|
+ //获取最近7天的日期和礼拜天数
|
|
|
initData() {
|
|
|
const time = [];
|
|
|
- const date = /* @__PURE__ */ new Date();
|
|
|
- const now = date.getTime();
|
|
|
+ const now = this.start_time * 1e3;
|
|
|
let timeStr = 3600 * 24 * 1e3;
|
|
|
let obj = {
|
|
|
0: "今天"
|
|
|
// 1: "明天",
|
|
|
// 2: "后天"
|
|
|
};
|
|
|
- for (let i = 0; i < 5; i++) {
|
|
|
+ for (let i = 0; i < 7; i++) {
|
|
|
time.push({
|
|
|
date: this.timeStamp(now + timeStr * i).date,
|
|
|
//保存日期
|
|
@@ -413,7 +502,6 @@ const _sfc_main = {
|
|
|
const timeStr = 3600 * 1e3 * timeInterval;
|
|
|
const sum = (endTimeStamp - startTimeStamp) / timeStr;
|
|
|
const count = sum % 2 == 0 ? sum : sum - 1;
|
|
|
- let num = 0;
|
|
|
for (let i = startTimeStamp; i <= endTimeStamp; i = i + timeStr) {
|
|
|
if (isQuantum) {
|
|
|
num++;
|
|
@@ -425,6 +513,8 @@ const _sfc_main = {
|
|
|
} else {
|
|
|
time.push({
|
|
|
time: this.timeStamp(i).hour,
|
|
|
+ sum: `${this.reservation_number}/${this.course_number}`,
|
|
|
+ disableSum: false,
|
|
|
disable: false
|
|
|
});
|
|
|
}
|
|
@@ -432,16 +522,6 @@ const _sfc_main = {
|
|
|
return time;
|
|
|
}
|
|
|
return time;
|
|
|
- },
|
|
|
- reservationPopup() {
|
|
|
- this.handleSubmit();
|
|
|
- this.$refs.outcomePopup.open("center");
|
|
|
- },
|
|
|
- // outcomePopup(){
|
|
|
- // this.$refs.outcomePopup.open("center")
|
|
|
- // },
|
|
|
- outcomeButton() {
|
|
|
- this.$refs.outcomePopup.close();
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -455,42 +535,48 @@ if (!Math) {
|
|
|
}
|
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
return {
|
|
|
- a: common_assets._imports_0$2,
|
|
|
- b: common_vendor.f($data.data, (item, index, i0) => {
|
|
|
+ a: common_vendor.t($data.course_name),
|
|
|
+ b: common_vendor.t($data.teacher_desc),
|
|
|
+ c: $data.course_image,
|
|
|
+ d: common_vendor.f($data.data, (item, index, i0) => {
|
|
|
return {
|
|
|
a: common_vendor.t(item.teacher_name),
|
|
|
- b: index
|
|
|
+ b: index,
|
|
|
+ c: common_vendor.o(($event) => $options.selectTeacher(index, item), index),
|
|
|
+ d: common_vendor.n(index === $data.teacherActive ? "active" : "")
|
|
|
};
|
|
|
}),
|
|
|
- c: common_vendor.f($data.dateArr, (item, index, i0) => {
|
|
|
+ e: common_vendor.f($data.dateArr, (item, index, i0) => {
|
|
|
return {
|
|
|
a: common_vendor.t(item.week),
|
|
|
b: common_vendor.t(item.date),
|
|
|
c: index,
|
|
|
d: common_vendor.o(($event) => $options.selectDateEvent(index, item), index),
|
|
|
- e: index == $data.dateActive ? $props.selectedTabColor : "#333"
|
|
|
+ e: index == $data.dateActive ? 1 : "",
|
|
|
+ f: index == $data.dateActive ? $props.selectedTabColor : "#333"
|
|
|
};
|
|
|
}),
|
|
|
- d: common_vendor.f($data.timeArr, (item, _index, i0) => {
|
|
|
+ f: common_vendor.f($data.timeArr, (item, _index, i0) => {
|
|
|
return {
|
|
|
a: common_vendor.t(item.disable ? $props.disableText : $props.undisableText),
|
|
|
b: common_vendor.t(item.time),
|
|
|
- c: _index,
|
|
|
- d: item.disable ? 1 : "",
|
|
|
- e: ($props.isMultiple ? item.isActive : _index == $data.timeActive) ? 1 : "",
|
|
|
- f: $props.isMultiple ? item.isActive ? $props.selectedItemColor : "#333" : _index == $data.timeActive ? $props.selectedItemColor : "#333",
|
|
|
- g: common_vendor.o(($event) => $options.selectTimeEvent(_index, item), _index)
|
|
|
- };
|
|
|
- }),
|
|
|
- e: common_vendor.f($data.isTime, (item, index, i0) => {
|
|
|
- return {
|
|
|
- a: common_vendor.t(item),
|
|
|
- b: index
|
|
|
+ c: common_vendor.t(item.sum),
|
|
|
+ d: _index,
|
|
|
+ e: item.disable ? 1 : "",
|
|
|
+ f: ($props.isMultiple ? item.isActive : _index == $data.timeActive) ? 1 : "",
|
|
|
+ g: $props.isMultiple ? item.isActive ? "#fff" : "#333" : _index == $data.timeActive ? "#fff" : "#333",
|
|
|
+ h: $props.isMultiple ? item.isActive ? $props.selectedItemColor : "" : _index == $data.timeActive ? $props.selectedItemColor : "",
|
|
|
+ i: common_vendor.o(($event) => $options.selectTimeEvent(_index, item), _index)
|
|
|
};
|
|
|
}),
|
|
|
- f: common_vendor.o(($event) => $options.outcomeButton()),
|
|
|
- g: common_vendor.sr("outcomePopup", "46f39ab6-0"),
|
|
|
- h: common_vendor.o(($event) => $options.reservationPopup())
|
|
|
+ g: common_vendor.t($data.orderDateTime),
|
|
|
+ h: common_vendor.o(($event) => $options.reservationPopup()),
|
|
|
+ i: common_vendor.t($data.orderDateTime),
|
|
|
+ j: common_vendor.o(($event) => $options.outcomeButton()),
|
|
|
+ k: common_vendor.sr("outcomePopup", "46f39ab6-0"),
|
|
|
+ l: common_vendor.p({
|
|
|
+ ["is-mask-click"]: false
|
|
|
+ })
|
|
|
};
|
|
|
}
|
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|