"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()); }); }; 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"); 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; 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); } }); 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 }); 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.codeStr); } } else { utils_commUtils.toast("扫码失败"); } }); const orderPay = () => __async(this, null, function* () { try { const res = yield logic_pay.payOrder(props.id); if (res.code == 200) { yield loadOrderDetails(); 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) { yield loadOrderDetails(); utils_commUtils.toast("取消成功"); common_vendor.index.$emit("refresh"); } else { utils_commUtils.toast(res.message); } }); const toOrderDetail = () => { common_vendor.index.navigateTo({ url: `/modules/pet/order/order-detail?id=${props.id}` }); }; 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) { yield loadOrderDetails(); 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({ a: common_vendor.unref(utils_commUtils.imgUrl)(__props.serviceInfo.url), b: __props.serviceInfo && __props.serviceInfo.serviceName }, __props.serviceInfo && __props.serviceInfo.serviceName ? { c: common_vendor.t(__props.serviceInfo.serviceName) } : {}, { 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) } : {}, { j: !__props.isPay && !__props.isTake }, !__props.isPay && !__props.isTake ? { k: common_vendor.o(orderPay) } : {}, { 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) } : {}, { n: __props.isTake }, __props.isTake ? { o: common_vendor.o(confirm) } : {}, { p: __props.isTake && __props.state.includes("已接单") }, __props.isTake && __props.state.includes("已接单") ? { q: common_vendor.o(scan) } : {}); }; } }; const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-745b4889"]]); wx.createComponent(Component);