appointment_system/miniprogram/unpackage/dist/dev/mp-weixin/pages/appointment/airfare-info-entry-page.js
2025-12-19 00:37:31 +08:00

485 lines
17 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";
const common_vendor = require("../../common/vendor.js");
const modules_api_AppServer = require("../../modules/api/AppServer.js");
const common_assets = require("../../common/assets.js");
const appServer = new modules_api_AppServer.AppServer();
const _sfc_main = {
data() {
return {
serviceId: "",
// 服务ID从页面参数获取
serviceTitle: "",
// 服务标题
userName: "",
userWechat: "",
userPhone: "",
userWhats: "",
remark: "",
departureDate: "",
returnDate: "",
departureCity: "",
arrivalCity: "",
luggageCount: "",
adultCount: 0,
childCount: 0,
infantCount: 0,
calendarType: "departure",
tripType: "single",
tripTypeIndex: 0,
submitting: false,
// 提交状态
tripTypeColumns: [
[
{
label: "单程",
value: "single"
},
{
label: "往返",
value: "round"
}
]
],
cabinType: "economy",
cabinTypeIndex: 0,
cabinTypeColumns: [
[
{
label: "经济舱",
value: "economy"
},
{
label: "超级经济舱",
value: "premium_economy"
},
{
label: "商务舱",
value: "business"
}
]
],
flashingField: "",
selectedDialCode: "86",
showCalendar: false,
showTripPicker: false,
showCabinPicker: false,
minDate: "",
maxDate: ""
};
},
computed: {
tripTypeText() {
const item = this.tripTypeColumns[0].find((t) => t.value === this.tripType);
return item ? item.label : "单程";
},
cabinTypeText() {
const item = this.cabinTypeColumns[0].find((t) => t.value === this.cabinType);
return item ? item.label : "经济舱";
}
},
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`;
},
openDepartureCalendar() {
common_vendor.index.__f__("log", "at pages/appointment/airfare-info-entry-page.vue:332", "打开出发日期选择器");
this.calendarType = "departure";
this.initDateRange();
this.$nextTick(() => {
this.showCalendar = true;
});
},
openReturnCalendar() {
common_vendor.index.__f__("log", "at pages/appointment/airfare-info-entry-page.vue:340", "打开返程日期选择器");
this.calendarType = "return";
if (this.departureDate) {
this.minDate = this.departureDate;
} else {
this.initDateRange();
}
this.$nextTick(() => {
this.showCalendar = true;
});
},
closeCalendar() {
this.showCalendar = false;
this.initDateRange();
},
onCalendarConfirm(dates) {
common_vendor.index.__f__("log", "at pages/appointment/airfare-info-entry-page.vue:357", "日历确认:", dates);
if (dates && dates.length > 0) {
if (this.calendarType === "departure") {
this.departureDate = dates[0];
if (this.returnDate && this.returnDate < dates[0]) {
this.returnDate = "";
}
} else {
this.returnDate = dates[0];
}
}
this.showCalendar = false;
this.initDateRange();
},
onTripTypeConfirm(e) {
const selected = e.value[0];
this.tripType = selected.value;
this.tripTypeIndex = this.tripTypeColumns[0].findIndex((t) => t.value === selected.value);
this.showTripPicker = false;
},
onCabinTypeConfirm(e) {
const selected = e.value[0];
this.cabinType = selected.value;
this.cabinTypeIndex = this.cabinTypeColumns[0].findIndex((t) => t.value === selected.value);
this.showCabinPicker = 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: "departureDate",
selector: "#fieldDepartureDate",
check: () => !this.departureDate,
message: "请选择出发日期"
},
{
field: "returnDate",
selector: "#fieldReturnDate",
check: () => this.tripType === "round" && !this.returnDate,
message: "请选择返程日期"
},
{
field: "departureCity",
selector: "#fieldDepartureCity",
check: () => !this.departureCity.trim(),
message: "请输入出发城市"
},
{
field: "arrivalCity",
selector: "#fieldArrivalCity",
check: () => !this.arrivalCity.trim(),
message: "请输入到达城市"
},
{
field: "personCount",
selector: "#fieldPersonCount",
check: () => this.adultCount === 0 && this.childCount === 0 && this.infantCount === 0,
message: "请至少选择一位乘客"
},
{
field: "luggageCount",
selector: "#fieldLuggageCount",
check: () => !this.luggageCount || this.luggageCount === "",
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: "travel",
// 机票属于出行类型
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,
// 机票专用字段
tripType: this.tripType,
departureDate: this.departureDate,
returnDate: this.tripType === "round" ? this.returnDate : null,
departureCity: this.departureCity.trim(),
arrivalCity: this.arrivalCity.trim(),
adultCount: this.adultCount,
childCount: this.childCount,
infantCount: this.infantCount,
cabinType: this.cabinType,
luggageCount: parseInt(this.luggageCount) || 0
};
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();
common_vendor.index.__f__("error", "at pages/appointment/airfare-info-entry-page.vue:515", "提交预约失败:", 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
});
},
increaseCount(type) {
if (type === "adult") {
this.adultCount++;
} else if (type === "child") {
this.childCount++;
} else if (type === "infant") {
this.infantCount++;
}
},
decreaseCount(type) {
if (type === "adult" && this.adultCount > 0) {
this.adultCount--;
} else if (type === "child" && this.childCount > 0) {
this.childCount--;
} else if (type === "infant" && this.infantCount > 0) {
this.infantCount--;
}
}
}
};
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_picker2 = common_vendor.resolveComponent("up-picker");
const _easycom_up_calendar2 = common_vendor.resolveComponent("up-calendar");
(_easycom_up_input2 + _easycom_aure_country_picker2 + _easycom_up_picker2 + _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_picker = () => "../../node-modules/uview-plus/components/u-picker/u-picker.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_picker + _easycom_up_calendar)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: common_assets._imports_0,
b: common_vendor.o((...args) => $options.back && $options.back(...args)),
c: common_vendor.t(_ctx.$t("infoEntry.title")),
d: common_vendor.t(_ctx.$t("infoEntry.personalInfo")),
e: common_vendor.t(_ctx.$t("infoEntry.realName")),
f: common_vendor.o(($event) => $data.userName = $event),
g: common_vendor.p({
placeholder: _ctx.$t("infoEntry.realNamePlaceholder"),
border: "surround",
modelValue: $data.userName
}),
h: $data.flashingField === "userName" ? 1 : "",
i: common_vendor.t(_ctx.$t("infoEntry.wechat")),
j: common_vendor.t(_ctx.$t("infoEntry.contactMethod")),
k: common_vendor.o(($event) => $data.userWechat = $event),
l: common_vendor.p({
placeholder: _ctx.$t("infoEntry.wechatPlaceholder"),
border: "surround",
modelValue: $data.userWechat
}),
m: $data.flashingField === "contact" ? 1 : "",
n: common_vendor.t(_ctx.$t("infoEntry.phone")),
o: common_vendor.t(_ctx.$t("infoEntry.contactMethod")),
p: common_vendor.o(($event) => $data.selectedDialCode = $event),
q: 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
}),
r: common_vendor.o(($event) => $data.userPhone = $event),
s: common_vendor.p({
placeholder: _ctx.$t("infoEntry.phonePlaceholder"),
border: "surround",
modelValue: $data.userPhone
}),
t: $data.flashingField === "contact" ? 1 : "",
v: common_vendor.t(_ctx.$t("infoEntry.whatsapp")),
w: common_vendor.t(_ctx.$t("infoEntry.contactMethod")),
x: common_vendor.o(($event) => $data.userWhats = $event),
y: common_vendor.p({
placeholder: _ctx.$t("infoEntry.whatsappPlaceholder"),
border: "surround",
modelValue: $data.userWhats
}),
z: $data.flashingField === "contact" ? 1 : "",
A: common_vendor.t(_ctx.$t("infoEntry.remark")),
B: common_vendor.o(($event) => $data.remark = $event),
C: common_vendor.p({
placeholder: _ctx.$t("infoEntry.remarkPlaceholder"),
border: "surround",
modelValue: $data.remark
}),
D: common_vendor.t(_ctx.$t("infoEntry.serviceInfo")),
E: common_vendor.t($options.tripTypeText),
F: common_assets._imports_2$1,
G: common_vendor.o(($event) => $data.showTripPicker = true),
H: common_vendor.t(_ctx.$t("infoEntry.departureDate")),
I: common_vendor.t($data.departureDate || _ctx.$t("infoEntry.departureDatePlaceholder")),
J: !$data.departureDate ? 1 : "",
K: common_assets._imports_1,
L: common_vendor.o((...args) => $options.openDepartureCalendar && $options.openDepartureCalendar(...args)),
M: $data.flashingField === "departureDate" ? 1 : "",
N: $data.tripType === "round"
}, $data.tripType === "round" ? {
O: common_vendor.t($data.returnDate || "请选择返程日期"),
P: !$data.returnDate ? 1 : "",
Q: common_assets._imports_1,
R: common_vendor.o((...args) => $options.openReturnCalendar && $options.openReturnCalendar(...args)),
S: $data.flashingField === "returnDate" ? 1 : ""
} : {}, {
T: $data.tripType === "round"
}, $data.tripType === "round" ? {} : {}, {
U: common_vendor.o(($event) => $data.departureCity = $event),
V: common_vendor.p({
placeholder: "请输入出发城市",
border: "surround",
modelValue: $data.departureCity
}),
W: $data.flashingField === "departureCity" ? 1 : "",
X: common_vendor.o(($event) => $data.arrivalCity = $event),
Y: common_vendor.p({
placeholder: "请输入到达城市",
border: "surround",
modelValue: $data.arrivalCity
}),
Z: $data.flashingField === "arrivalCity" ? 1 : "",
aa: common_vendor.o(($event) => $options.decreaseCount("adult")),
ab: common_vendor.t($data.adultCount),
ac: common_vendor.o(($event) => $options.increaseCount("adult")),
ad: common_vendor.o(($event) => $options.decreaseCount("child")),
ae: common_vendor.t($data.childCount),
af: common_vendor.o(($event) => $options.increaseCount("child")),
ag: common_vendor.o(($event) => $options.decreaseCount("infant")),
ah: common_vendor.t($data.infantCount),
ai: common_vendor.o(($event) => $options.increaseCount("infant")),
aj: $data.flashingField === "personCount" ? 1 : "",
ak: common_vendor.t($options.cabinTypeText),
al: common_assets._imports_2$1,
am: common_vendor.o(($event) => $data.showCabinPicker = true),
an: common_vendor.o(($event) => $data.luggageCount = $event),
ao: common_vendor.p({
placeholder: "请输入行李件数",
border: "surround",
type: "number",
modelValue: $data.luggageCount
}),
ap: $data.flashingField === "luggageCount" ? 1 : "",
aq: common_vendor.t(_ctx.$t("common.submit")),
ar: common_vendor.o(($event) => $options.checkData()),
as: common_vendor.o($options.onTripTypeConfirm),
at: common_vendor.o(($event) => $data.showTripPicker = false),
av: common_vendor.o(($event) => $data.showTripPicker = false),
aw: common_vendor.p({
show: $data.showTripPicker,
columns: $data.tripTypeColumns,
defaultIndex: [$data.tripTypeIndex],
keyName: "label"
}),
ax: common_vendor.o($options.onCabinTypeConfirm),
ay: common_vendor.o(($event) => $data.showCabinPicker = false),
az: common_vendor.o(($event) => $data.showCabinPicker = false),
aA: common_vendor.p({
show: $data.showCabinPicker,
columns: $data.cabinTypeColumns,
defaultIndex: [$data.cabinTypeIndex],
keyName: "label"
}),
aB: common_vendor.o($options.onCalendarConfirm),
aC: common_vendor.o($options.closeCalendar),
aD: 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]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/appointment/airfare-info-entry-page.js.map