297 lines
10 KiB
JavaScript
297 lines
10 KiB
JavaScript
"use strict";
|
||
const common_vendor = require("../../common/vendor.js");
|
||
const modules_api_AppServer = require("../../modules/api/AppServer.js");
|
||
require("../../modules/Config.js");
|
||
const appServer = new modules_api_AppServer.AppServer();
|
||
const _sfc_main = {
|
||
data() {
|
||
return {
|
||
serviceId: "",
|
||
serviceTitle: "",
|
||
userName: "",
|
||
userWechat: "",
|
||
userPhone: "",
|
||
userWhats: "",
|
||
remark: "",
|
||
reservationDate: "",
|
||
itinerary: "",
|
||
specialAssistanceReason: "",
|
||
submitting: false,
|
||
flashingField: "",
|
||
selectedDialCode: "86",
|
||
showCalendar: false,
|
||
minDate: "",
|
||
maxDate: ""
|
||
};
|
||
},
|
||
onLoad(options) {
|
||
this.initDateRange();
|
||
if (options.id) {
|
||
this.serviceId = options.id;
|
||
}
|
||
if (options.title) {
|
||
this.serviceTitle = decodeURIComponent(options.title);
|
||
}
|
||
},
|
||
methods: {
|
||
initDateRange() {
|
||
const now = /* @__PURE__ */ new Date();
|
||
const year = now.getFullYear();
|
||
const month = String(now.getMonth() + 1).padStart(2, "0");
|
||
const day = String(now.getDate()).padStart(2, "0");
|
||
this.minDate = `${year}-${month}-${day}`;
|
||
this.maxDate = `${year + 2}-12-31`;
|
||
},
|
||
openCalendar() {
|
||
this.initDateRange();
|
||
this.$nextTick(() => {
|
||
this.showCalendar = true;
|
||
});
|
||
},
|
||
closeCalendar() {
|
||
this.showCalendar = false;
|
||
},
|
||
onCalendarConfirm(dates) {
|
||
if (dates && dates.length > 0) {
|
||
this.reservationDate = dates[0];
|
||
}
|
||
this.showCalendar = false;
|
||
},
|
||
checkData() {
|
||
const validations = [
|
||
{
|
||
field: "userName",
|
||
selector: "#fieldUserName",
|
||
check: () => !this.userName.trim(),
|
||
message: "请输入真实姓名"
|
||
},
|
||
{
|
||
field: "contact",
|
||
selector: "#fieldContact",
|
||
check: () => !this.userWechat.trim() && !this.userPhone.trim() && !this.userWhats.trim(),
|
||
message: "请至少填写一种联系方式(微信号/手机号/WhatsApp)"
|
||
},
|
||
{
|
||
field: "reservationDate",
|
||
selector: "#fieldReservationDate",
|
||
check: () => !this.reservationDate,
|
||
message: "请选择预约日期"
|
||
},
|
||
{
|
||
field: "itinerary",
|
||
selector: "#fieldItinerary",
|
||
check: () => !this.itinerary.trim(),
|
||
message: "请输入行程信息"
|
||
},
|
||
{
|
||
field: "specialAssistanceReason",
|
||
selector: "#fieldSpecialAssistanceReason",
|
||
check: () => !this.specialAssistanceReason.trim(),
|
||
message: "请输入特殊协助原因"
|
||
}
|
||
];
|
||
for (const validation of validations) {
|
||
if (validation.check()) {
|
||
common_vendor.index.showToast({
|
||
title: validation.message,
|
||
icon: "none"
|
||
});
|
||
this.scrollToElement(validation.selector);
|
||
this.flashingField = validation.field;
|
||
setTimeout(() => {
|
||
this.flashingField = "";
|
||
}, 1500);
|
||
return;
|
||
}
|
||
}
|
||
this.submitAppointment();
|
||
},
|
||
async submitAppointment() {
|
||
var _a;
|
||
if (this.submitting)
|
||
return;
|
||
this.submitting = true;
|
||
common_vendor.index.showLoading({
|
||
title: "提交中...",
|
||
mask: true
|
||
});
|
||
try {
|
||
const appointmentData = {
|
||
hotServiceId: parseInt(this.serviceId) || null,
|
||
serviceType: "special_needs",
|
||
realName: this.userName.trim(),
|
||
wechatId: this.userWechat.trim() || null,
|
||
phone: this.userPhone.trim() || null,
|
||
phoneCountryCode: this.userPhone.trim() ? this.selectedDialCode : null,
|
||
whatsapp: this.userWhats.trim() || null,
|
||
notes: this.remark.trim() || null,
|
||
appointmentDate: this.reservationDate,
|
||
itinerary: this.itinerary.trim(),
|
||
specialAssistanceReason: this.specialAssistanceReason.trim()
|
||
};
|
||
const result = await appServer.CreateAppointment(appointmentData);
|
||
common_vendor.index.hideLoading();
|
||
if (result.success || result.code === 0) {
|
||
common_vendor.index.showToast({
|
||
title: "预约提交成功",
|
||
icon: "success"
|
||
});
|
||
setTimeout(() => {
|
||
common_vendor.index.navigateBack({
|
||
delta: 1
|
||
});
|
||
}, 1500);
|
||
} else {
|
||
common_vendor.index.showToast({
|
||
title: ((_a = result.error) == null ? void 0 : _a.message) || "提交失败,请重试",
|
||
icon: "none"
|
||
});
|
||
}
|
||
} catch (error) {
|
||
common_vendor.index.hideLoading();
|
||
console.error("提交预约失败:", error);
|
||
common_vendor.index.showToast({
|
||
title: "网络错误,请重试",
|
||
icon: "none"
|
||
});
|
||
} finally {
|
||
this.submitting = false;
|
||
}
|
||
},
|
||
scrollToElement(selector) {
|
||
const systemInfo = common_vendor.index.getSystemInfoSync();
|
||
const screenHeight = systemInfo.windowHeight;
|
||
const query = common_vendor.index.createSelectorQuery().in(this);
|
||
query.select(selector).boundingClientRect();
|
||
query.selectViewport().scrollOffset();
|
||
query.exec((res) => {
|
||
if (res[0] && res[1]) {
|
||
const rect = res[0];
|
||
const scrollInfo = res[1];
|
||
const targetScrollTop = scrollInfo.scrollTop + rect.top - screenHeight / 2 + rect.height / 2;
|
||
common_vendor.index.pageScrollTo({
|
||
scrollTop: Math.max(0, targetScrollTop),
|
||
duration: 300
|
||
});
|
||
}
|
||
});
|
||
},
|
||
back() {
|
||
common_vendor.index.navigateBack({
|
||
delta: 1
|
||
});
|
||
}
|
||
}
|
||
};
|
||
if (!Array) {
|
||
const _easycom_up_input2 = common_vendor.resolveComponent("up-input");
|
||
const _easycom_aure_country_picker2 = common_vendor.resolveComponent("aure-country-picker");
|
||
const _easycom_up_textarea2 = common_vendor.resolveComponent("up-textarea");
|
||
const _easycom_up_calendar2 = common_vendor.resolveComponent("up-calendar");
|
||
(_easycom_up_input2 + _easycom_aure_country_picker2 + _easycom_up_textarea2 + _easycom_up_calendar2)();
|
||
}
|
||
const _easycom_up_input = () => "../../node-modules/uview-plus/components/u-input/u-input.js";
|
||
const _easycom_aure_country_picker = () => "../../uni_modules/aure-country-picker/components/aure-country-picker/aure-country-picker.js";
|
||
const _easycom_up_textarea = () => "../../node-modules/uview-plus/components/u-textarea/u-textarea.js";
|
||
const _easycom_up_calendar = () => "../../node-modules/uview-plus/components/u-calendar/u-calendar.js";
|
||
if (!Math) {
|
||
(_easycom_up_input + _easycom_aure_country_picker + _easycom_up_textarea + _easycom_up_calendar)();
|
||
}
|
||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||
return {
|
||
a: common_vendor.o((...args) => $options.back && $options.back(...args)),
|
||
b: common_vendor.t(_ctx.$t("infoEntry.title")),
|
||
c: common_vendor.t(_ctx.$t("infoEntry.personalInfo")),
|
||
d: common_vendor.t(_ctx.$t("infoEntry.realName")),
|
||
e: common_vendor.o(($event) => $data.userName = $event),
|
||
f: common_vendor.p({
|
||
placeholder: _ctx.$t("infoEntry.realNamePlaceholder"),
|
||
border: "surround",
|
||
modelValue: $data.userName
|
||
}),
|
||
g: $data.flashingField === "userName" ? 1 : "",
|
||
h: common_vendor.t(_ctx.$t("infoEntry.wechat")),
|
||
i: common_vendor.t(_ctx.$t("infoEntry.contactMethod")),
|
||
j: common_vendor.o(($event) => $data.userWechat = $event),
|
||
k: common_vendor.p({
|
||
placeholder: _ctx.$t("infoEntry.wechatPlaceholder"),
|
||
border: "surround",
|
||
modelValue: $data.userWechat
|
||
}),
|
||
l: $data.flashingField === "contact" ? 1 : "",
|
||
m: common_vendor.t(_ctx.$t("infoEntry.phone")),
|
||
n: common_vendor.t(_ctx.$t("infoEntry.contactMethod")),
|
||
o: common_vendor.o(($event) => $data.selectedDialCode = $event),
|
||
p: common_vendor.p({
|
||
title: _ctx.$t("infoEntry.selectCountry"),
|
||
height: "70%",
|
||
width: "60vw",
|
||
duration: 350,
|
||
position: "bottom",
|
||
round: true,
|
||
radius: "24rpx",
|
||
["mask-closable"]: true,
|
||
modelValue: $data.selectedDialCode
|
||
}),
|
||
q: common_vendor.o(($event) => $data.userPhone = $event),
|
||
r: common_vendor.p({
|
||
placeholder: _ctx.$t("infoEntry.phonePlaceholder"),
|
||
border: "surround",
|
||
modelValue: $data.userPhone
|
||
}),
|
||
s: $data.flashingField === "contact" ? 1 : "",
|
||
t: common_vendor.t(_ctx.$t("infoEntry.whatsapp")),
|
||
v: common_vendor.t(_ctx.$t("infoEntry.contactMethod")),
|
||
w: common_vendor.o(($event) => $data.userWhats = $event),
|
||
x: common_vendor.p({
|
||
placeholder: _ctx.$t("infoEntry.whatsappPlaceholder"),
|
||
border: "surround",
|
||
modelValue: $data.userWhats
|
||
}),
|
||
y: $data.flashingField === "contact" ? 1 : "",
|
||
z: common_vendor.t(_ctx.$t("infoEntry.remark")),
|
||
A: common_vendor.o(($event) => $data.remark = $event),
|
||
B: common_vendor.p({
|
||
placeholder: _ctx.$t("infoEntry.remarkPlaceholder"),
|
||
border: "surround",
|
||
modelValue: $data.remark
|
||
}),
|
||
C: common_vendor.t(_ctx.$t("infoEntry.serviceInfo")),
|
||
D: common_vendor.t($data.reservationDate || "请选择预约日期"),
|
||
E: !$data.reservationDate ? 1 : "",
|
||
F: common_vendor.o((...args) => $options.openCalendar && $options.openCalendar(...args)),
|
||
G: $data.flashingField === "reservationDate" ? 1 : "",
|
||
H: common_vendor.o(($event) => $data.itinerary = $event),
|
||
I: common_vendor.p({
|
||
placeholder: "请输入行程信息(如:北京-上海)",
|
||
border: "surround",
|
||
modelValue: $data.itinerary
|
||
}),
|
||
J: $data.flashingField === "itinerary" ? 1 : "",
|
||
K: common_vendor.o(($event) => $data.specialAssistanceReason = $event),
|
||
L: common_vendor.p({
|
||
placeholder: "请详细描述需要特殊协助的原因",
|
||
maxlength: 1e3,
|
||
count: true,
|
||
height: "200",
|
||
border: "surround",
|
||
modelValue: $data.specialAssistanceReason
|
||
}),
|
||
M: $data.flashingField === "specialAssistanceReason" ? 1 : "",
|
||
N: common_vendor.t(_ctx.$t("common.submit")),
|
||
O: common_vendor.o(($event) => $options.checkData()),
|
||
P: common_vendor.o($options.onCalendarConfirm),
|
||
Q: common_vendor.o($options.closeCalendar),
|
||
R: common_vendor.p({
|
||
show: $data.showCalendar,
|
||
mode: "single",
|
||
minDate: $data.minDate,
|
||
maxDate: $data.maxDate,
|
||
confirmText: _ctx.$t("common.confirm"),
|
||
color: "#57C9DD"
|
||
})
|
||
};
|
||
}
|
||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "F:/gitCode/uniapp/appointment_system/miniprogram/src/pages/appointment/special-needs-page.vue"]]);
|
||
wx.createPage(MiniProgramPage);
|