"use strict"; const common_vendor = require("../../common/vendor.js"); const API_api = require("../../API/api.js"); if (!Array) { const _easycom_uni_pagination2 = common_vendor.resolveComponent("uni-pagination"); _easycom_uni_pagination2(); } const _easycom_uni_pagination = () => "../../uni_modules/uni-pagination/components/uni-pagination/uni-pagination.js"; if (!Math) { _easycom_uni_pagination(); } const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({ __name: "orderStateOne", setup(__props) { const currentPage = common_vendor.ref(1); const pageSize = common_vendor.ref(10); const totalItems = common_vendor.ref(0); common_vendor.ref(1); const orderList = common_vendor.ref([]); const getOrder = (page) => { common_vendor.index.request({ url: `${API_api.apiImageUrl}/api/orders/my/page`, method: "POST", data: { current: page, endTime: "", id: "", pageSize: pageSize.value, pickupMethod: "", sortField: "createTime", sortOrder: "dscend", startTime: "", state: 2 }, header: { "Content-Type": "application/json", "cookie": common_vendor.index.getStorageSync("cookie") || "" }, success(res) { if (res.data.code === 0) { const records = res.data.data.records; orderList.value = records; totalItems.value = res.data.data.total; console.log("订单数据:", orderList.value); } }, fail() { console.log("出错啦"); } }); }; const deleteOrder = async (orderId) => { try { const response = await common_vendor.index.request({ url: `${API_api.apiImageUrl}/api/orders/delete`, method: "POST", header: { "Content-Type": "application/json" }, data: JSON.stringify({ id: orderId }) }); if (response.statusCode === 200) { console.log(`成功取消订单:${orderId}`); common_vendor.index.showModal({ title: "提示", content: "删除订单成功", showCancel: false, success: (res) => { if (res.confirm) { getOrder(); } } }); } else { console.error(`无法取消订单:${orderId},错误码:${response.statusCode}`); } } catch (error) { console.error(`发生错误:${error.message}`); } }; const onPageChange = (e) => { currentPage.value = e.current; getOrder(e.current); }; common_vendor.onMounted(() => { getOrder(currentPage.value); }); const orderDetail = (order) => { console.log(order); }; const merchantDetail = (order) => { var _a, _b, _c; console.log((_a = order.businessVO) == null ? void 0 : _a.id); common_vendor.index.setStorageSync("businessItem", (_b = order.businessVO) == null ? void 0 : _b.id); const merchantId = (_c = order.businessVO) == null ? void 0 : _c.id; common_vendor.index.navigateTo({ url: `/pages/merchant/merchant?merchantId=${merchantId}` }); }; return (_ctx, _cache) => { var _a; return { a: common_vendor.f(orderList.value, (order, index, i0) => { var _a2, _b; return common_vendor.e({ a: common_vendor.t((_a2 = order.businessVO) == null ? void 0 : _a2.businessName), b: common_vendor.o(($event) => merchantDetail(order)), c: common_vendor.t(order.id), d: common_vendor.f(1, (sku, k1, i1) => { return { a: common_vendor.f(order.orderDetailsVOList, (item, index2, i2) => { var _a3; return { a: common_vendor.t((_a3 = item.dishesVO) == null ? void 0 : _a3.dishesName), b: common_vendor.t(item.attributeNames) }; }), b: sku }; }), e: (_b = order.businessVO) == null ? void 0 : _b.businessAvatar }, { f: common_vendor.o(() => deleteOrder(order.id)) }, { h: index, i: common_vendor.o(($event) => orderDetail(order)) }); }), b: `/pagesOrder/detail/detail?id=1`, c: common_vendor.t("没有更多数据~"), d: ((_a = _ctx.safeAreaInsets) == null ? void 0 : _a.bottom) + "px", e: common_vendor.o(onPageChange), f: common_vendor.p({ title: "订单列表", ["show-icon"]: true, current: currentPage.value, total: totalItems.value, pageSize: pageSize.value }) }; }; } }); my.createComponent(_sfc_main);