199 lines
6.4 KiB
JavaScript
199 lines
6.4 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const API_api = require("../../API/api.js");
|
|
if (!Array) {
|
|
const _easycom_uni_steps2 = common_vendor.resolveComponent("uni-steps");
|
|
const _easycom_uni_pagination2 = common_vendor.resolveComponent("uni-pagination");
|
|
(_easycom_uni_steps2 + _easycom_uni_pagination2)();
|
|
}
|
|
const _easycom_uni_steps = () => "../../uni_modules/uni-steps/components/uni-steps/uni-steps.js";
|
|
const _easycom_uni_pagination = () => "../../uni_modules/uni-pagination/components/uni-pagination/uni-pagination.js";
|
|
if (!Math) {
|
|
(_easycom_uni_steps + _easycom_uni_pagination)();
|
|
}
|
|
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
|
__name: "orderStateZero",
|
|
setup(__props) {
|
|
const currentPage = common_vendor.ref(1);
|
|
const pageSize = common_vendor.ref(10);
|
|
const totalItems = common_vendor.ref(0);
|
|
const active = common_vendor.ref(1);
|
|
const list1 = common_vendor.reactive([
|
|
{ title: "备餐中" },
|
|
{ title: "已出餐" },
|
|
{ title: "已完成" }
|
|
]);
|
|
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: "",
|
|
sortOrder: "",
|
|
startTime: "",
|
|
state: 1
|
|
},
|
|
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.reverse();
|
|
totalItems.value = res.data.data.total;
|
|
console.log("订单数据:", orderList.value);
|
|
}
|
|
},
|
|
fail() {
|
|
console.log("出错啦");
|
|
}
|
|
});
|
|
};
|
|
const onPageChange = (e) => {
|
|
currentPage.value = e.current;
|
|
getOrder(e.current);
|
|
};
|
|
const deleteOrder = (order) => {
|
|
const orderId = order.id;
|
|
common_vendor.index.request({
|
|
url: `${API_api.apiImageUrl}/api/orders/delete`,
|
|
method: "POST",
|
|
data: {
|
|
id: orderId
|
|
},
|
|
success(res) {
|
|
console.log(res);
|
|
getOrder(currentPage.value);
|
|
},
|
|
fail(Error) {
|
|
console.log(Error);
|
|
}
|
|
});
|
|
};
|
|
common_vendor.onMounted(() => {
|
|
getOrder(currentPage.value);
|
|
});
|
|
const refund = (order) => {
|
|
console.log(order.pickupCode);
|
|
common_vendor.index.setStorageSync("pickupCode", order.pickupCode);
|
|
common_vendor.index.setStorageSync("refundId", order.id);
|
|
common_vendor.index.navigateTo({
|
|
url: "/pages/refund/refund"
|
|
});
|
|
};
|
|
const showButton = common_vendor.ref(true);
|
|
const countdownTime = common_vendor.ref(180);
|
|
let intervalId;
|
|
common_vendor.onMounted(() => {
|
|
intervalId = setInterval(() => {
|
|
if (countdownTime.value > 0) {
|
|
countdownTime.value--;
|
|
} else {
|
|
clearInterval(intervalId);
|
|
showButton.value = false;
|
|
}
|
|
}, 1e3);
|
|
});
|
|
common_vendor.onUnmounted(() => {
|
|
clearInterval(intervalId);
|
|
});
|
|
const tell = (phone) => {
|
|
console.log(phone);
|
|
common_vendor.index.makePhoneCall({
|
|
phoneNumber: phone
|
|
});
|
|
};
|
|
const obtion = (order) => {
|
|
console.log(order.id);
|
|
common_vendor.index.request({
|
|
url: `${API_api.apiImageUrl}/api/orders/update/state/user`,
|
|
method: "POST",
|
|
data: {
|
|
id: order.id
|
|
},
|
|
header: {
|
|
"Content-Type": "application/json",
|
|
"cookie": common_vendor.index.getStorageSync("cookie") || ""
|
|
},
|
|
success(res) {
|
|
console.log(res);
|
|
},
|
|
fail(err) {
|
|
console.log(err);
|
|
}
|
|
});
|
|
};
|
|
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), index),
|
|
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: "686b3eac-0-" + i0
|
|
}, common_vendor.e({
|
|
g: common_vendor.o(() => deleteOrder(order), index),
|
|
h: common_vendor.o(() => obtion(order), index),
|
|
i: common_vendor.o(() => {
|
|
var _a3;
|
|
return tell((_a3 = order.businessVO) == null ? void 0 : _a3.businessPhone);
|
|
}, index),
|
|
j: showButton.value
|
|
}, showButton.value ? {
|
|
k: common_vendor.o(() => refund(order), index)
|
|
} : {}), {
|
|
m: index
|
|
});
|
|
}),
|
|
b: `/pagesOrder/detail/detail?id=1`,
|
|
c: common_vendor.p({
|
|
options: list1,
|
|
active: active.value
|
|
}),
|
|
d: common_vendor.t("没有更多数据~"),
|
|
e: ((_a = _ctx.safeAreaInsets) == null ? void 0 : _a.bottom) + "px",
|
|
f: common_vendor.o(onPageChange),
|
|
g: common_vendor.p({
|
|
title: "订单列表",
|
|
["show-icon"]: true,
|
|
current: currentPage.value,
|
|
total: totalItems.value,
|
|
pageSize: pageSize.value
|
|
})
|
|
};
|
|
};
|
|
}
|
|
});
|
|
wx.createComponent(_sfc_main);
|