2024-09-19 07:20:14 +08:00
|
|
|
"use strict";
|
|
|
|
var __async = (__this, __arguments, generator) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
var fulfilled = (value) => {
|
|
|
|
try {
|
|
|
|
step(generator.next(value));
|
|
|
|
} catch (e) {
|
|
|
|
reject(e);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
var rejected = (value) => {
|
|
|
|
try {
|
|
|
|
step(generator.throw(value));
|
|
|
|
} catch (e) {
|
|
|
|
reject(e);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
|
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
|
|
});
|
|
|
|
};
|
2024-10-01 09:15:35 +08:00
|
|
|
const common_vendor = require("../../../../common/vendor.js");
|
|
|
|
const logic_pay = require("../../../../logic/pay.js");
|
|
|
|
const utils_commUtils = require("../../../../utils/commUtils.js");
|
|
|
|
const utils_http = require("../../../../utils/http.js");
|
2024-09-19 07:20:14 +08:00
|
|
|
const _sfc_main = {
|
|
|
|
__name: "OrderItem",
|
|
|
|
props: {
|
|
|
|
id: String,
|
|
|
|
userId: String,
|
|
|
|
reservationTime: String,
|
|
|
|
serviceHours: String,
|
|
|
|
personalServiceId: String,
|
|
|
|
personalServiceUserId: String,
|
|
|
|
price: Number,
|
|
|
|
isPay: Boolean,
|
|
|
|
feedback: String,
|
|
|
|
star: Number,
|
|
|
|
state: String,
|
|
|
|
paymentMethod: String,
|
|
|
|
qrcode: String,
|
|
|
|
createTime: String,
|
|
|
|
updateTime: String,
|
|
|
|
address: Object,
|
|
|
|
pet: Object,
|
|
|
|
user: Object,
|
|
|
|
psUser: Object,
|
|
|
|
serviceInfo: Object,
|
|
|
|
isTake: false
|
|
|
|
},
|
|
|
|
setup(__props) {
|
|
|
|
const props = __props;
|
2024-10-01 09:15:35 +08:00
|
|
|
const orderData = common_vendor.ref({});
|
|
|
|
const loadOrderDetails = () => __async(this, null, function* () {
|
|
|
|
try {
|
|
|
|
const response = yield utils_http.httpGet(`/order/info/${props.id()}`);
|
|
|
|
if (response.code === 200) {
|
|
|
|
orderData.value = response.data;
|
|
|
|
orderData.value.id = data.id || props.id;
|
|
|
|
orderData.value.userId = data.userId || props.userId;
|
|
|
|
orderData.value.reservationTime = data.reservationTime || props.reservationTime;
|
|
|
|
orderData.value.serviceHours = data.serviceHours || props.serviceHours;
|
|
|
|
orderData.value.personalServiceId = data.personalServiceId || props.personalServiceId;
|
|
|
|
orderData.value.personalServiceUserId = data.personalServiceUserId || props.personalServiceUserId;
|
|
|
|
orderData.value.price = data.price || props.price;
|
|
|
|
orderData.value.isPay = data.isPay || props.isPay;
|
|
|
|
orderData.value.feedback = data.feedback || props.feedback;
|
|
|
|
orderData.value.star = data.star || props.star;
|
|
|
|
orderData.value.state = data.state || props.state;
|
|
|
|
orderData.value.paymentMethod = data.paymentMethod || props.paymentMethod;
|
|
|
|
orderData.value.qrcode = data.qrcode || props.qrcode;
|
|
|
|
orderData.value.createTime = data.createTime || props.createTime;
|
|
|
|
orderData.value.updateTime = data.updateTime || props.updateTime;
|
|
|
|
orderData.value.address = data.address || props.address;
|
|
|
|
orderData.value.pet = data.pet || props.pet;
|
|
|
|
orderData.value.user = data.user || props.user;
|
|
|
|
orderData.value.psUser = data.psUser || props.psUser;
|
|
|
|
orderData.value.serviceInfo = data.serviceInfo || props.serviceInfo;
|
|
|
|
} else {
|
|
|
|
console.log("获取订单信息失败", response);
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
console.log("请求失败,请稍后再试", error);
|
|
|
|
}
|
|
|
|
});
|
2024-09-19 07:20:14 +08:00
|
|
|
const shopRemark = common_vendor.ref("");
|
|
|
|
const scan = () => __async(this, null, function* () {
|
|
|
|
const scan2 = yield utils_commUtils.scanCodeAsync();
|
|
|
|
if (scan2.result) {
|
|
|
|
try {
|
|
|
|
const res = yield utils_http.httpPost("/order/scan/" + props.id, {}, { qrcode: scan2.result });
|
2024-10-01 09:15:35 +08:00
|
|
|
if (res.code === 200) {
|
2024-09-19 07:20:14 +08:00
|
|
|
utils_commUtils.toast("支付成功");
|
|
|
|
common_vendor.index.$emit("refresh");
|
|
|
|
} else {
|
|
|
|
utils_commUtils.toast(res.message);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
utils_commUtils.toast(e.data.codeStr);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
utils_commUtils.toast("扫码失败");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
const orderPay = () => __async(this, null, function* () {
|
|
|
|
try {
|
|
|
|
const res = yield logic_pay.payOrder(props.id);
|
|
|
|
if (res.code == 200) {
|
2024-10-01 09:15:35 +08:00
|
|
|
yield loadOrderDetails();
|
2024-09-19 07:20:14 +08:00
|
|
|
utils_commUtils.toast("支付成功");
|
|
|
|
} else {
|
|
|
|
utils_commUtils.toast(res.message);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
utils_commUtils.toast(e.data.codeStr);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
const cancel = () => __async(this, null, function* () {
|
|
|
|
const res = yield utils_http.httpPost("/order/cancel/" + props.id);
|
|
|
|
if (res.code == 200) {
|
2024-10-01 09:15:35 +08:00
|
|
|
yield loadOrderDetails();
|
2024-09-19 07:20:14 +08:00
|
|
|
utils_commUtils.toast("取消成功");
|
|
|
|
common_vendor.index.$emit("refresh");
|
|
|
|
} else {
|
|
|
|
utils_commUtils.toast(res.message);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
const toOrderDetail = () => {
|
|
|
|
common_vendor.index.navigateTo({
|
2024-10-01 09:15:35 +08:00
|
|
|
url: `/modules/pet/order/order-detail?id=${props.id}`
|
2024-09-19 07:20:14 +08:00
|
|
|
});
|
|
|
|
};
|
|
|
|
const bookingCancel = () => __async(this, null, function* () {
|
|
|
|
try {
|
|
|
|
const res = yield utils_commUtils.showModalAsync({
|
|
|
|
title: "取消订单",
|
|
|
|
content: "",
|
|
|
|
editable: true,
|
|
|
|
placeholderText: "请输入取消原因!"
|
|
|
|
});
|
|
|
|
if (res.confirm) {
|
|
|
|
shopRemark.value = res.content;
|
|
|
|
const response = yield utils_http.httpPost(
|
|
|
|
"/order/bookingCancel/" + props.id,
|
|
|
|
{},
|
|
|
|
{ shopRemark: shopRemark.value }
|
|
|
|
);
|
|
|
|
if (response.code == 200) {
|
2024-10-01 09:15:35 +08:00
|
|
|
yield loadOrderDetails();
|
2024-09-19 07:20:14 +08:00
|
|
|
utils_commUtils.toast("取消订单成功!");
|
|
|
|
common_vendor.index.$emit("refresh");
|
|
|
|
} else {
|
|
|
|
utils_commUtils.toast(response.message);
|
|
|
|
}
|
|
|
|
} else if (res.cancel) {
|
|
|
|
utils_commUtils.toast("取消操作已取消");
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
utils_commUtils.toast("请求失败,请稍后再试");
|
|
|
|
console.error(e);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
const confirm = () => __async(this, null, function* () {
|
|
|
|
try {
|
|
|
|
const res = yield utils_http.httpPost("/order/confirm/" + props.id);
|
|
|
|
if (res.code == 200) {
|
|
|
|
utils_commUtils.toast("确认订单成功!");
|
|
|
|
common_vendor.index.$emit("refresh");
|
|
|
|
} else {
|
|
|
|
utils_commUtils.toast(res.message);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
utils_commUtils.toast(e.data.message);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return (_ctx, _cache) => {
|
|
|
|
return common_vendor.e({
|
2024-10-01 09:15:35 +08:00
|
|
|
a: common_vendor.unref(utils_commUtils.imgUrl)(__props.serviceInfo.url),
|
|
|
|
b: __props.serviceInfo && __props.serviceInfo.serviceName
|
2024-09-19 07:20:14 +08:00
|
|
|
}, __props.serviceInfo && __props.serviceInfo.serviceName ? {
|
2024-10-01 09:15:35 +08:00
|
|
|
c: common_vendor.t(__props.serviceInfo.serviceName)
|
2024-09-19 07:20:14 +08:00
|
|
|
} : {}, {
|
2024-10-01 09:15:35 +08:00
|
|
|
d: common_vendor.t(__props.state),
|
|
|
|
e: common_vendor.t(__props.serviceInfo.description),
|
|
|
|
f: common_vendor.t(__props.price),
|
|
|
|
g: common_vendor.o(toOrderDetail),
|
|
|
|
h: !__props.isTake && common_vendor.unref(utils_commUtils.isCancelOrder)(__props.state)
|
|
|
|
}, !__props.isTake && common_vendor.unref(utils_commUtils.isCancelOrder)(__props.state) ? {
|
|
|
|
i: common_vendor.o(cancel)
|
2024-09-19 07:20:14 +08:00
|
|
|
} : {}, {
|
2024-10-01 09:15:35 +08:00
|
|
|
j: !__props.isPay && !__props.isTake
|
|
|
|
}, !__props.isPay && !__props.isTake ? {
|
|
|
|
k: common_vendor.o(orderPay)
|
2024-09-19 07:20:14 +08:00
|
|
|
} : {}, {
|
2024-10-01 09:15:35 +08:00
|
|
|
l: __props.isTake && common_vendor.unref(utils_commUtils.isTakeCancelOrder)(__props.state)
|
|
|
|
}, __props.isTake && common_vendor.unref(utils_commUtils.isTakeCancelOrder)(__props.state) ? {
|
|
|
|
m: common_vendor.o(bookingCancel)
|
2024-09-19 07:20:14 +08:00
|
|
|
} : {}, {
|
2024-10-01 09:15:35 +08:00
|
|
|
n: __props.isTake
|
2024-09-19 07:20:14 +08:00
|
|
|
}, __props.isTake ? {
|
2024-10-01 09:15:35 +08:00
|
|
|
o: common_vendor.o(confirm)
|
2024-09-19 07:20:14 +08:00
|
|
|
} : {}, {
|
2024-10-01 09:15:35 +08:00
|
|
|
p: __props.isTake && __props.state.includes("已接单")
|
|
|
|
}, __props.isTake && __props.state.includes("已接单") ? {
|
|
|
|
q: common_vendor.o(scan)
|
2024-09-19 07:20:14 +08:00
|
|
|
} : {});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
2024-10-01 09:15:35 +08:00
|
|
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-745b4889"]]);
|
2024-09-19 07:20:14 +08:00
|
|
|
wx.createComponent(Component);
|