104 lines
3.2 KiB
JavaScript
104 lines
3.2 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");
|
|
_easycom_uni_steps2();
|
|
}
|
|
const _easycom_uni_steps = () => "../../uni_modules/uni-steps/components/uni-steps/uni-steps.js";
|
|
if (!Math) {
|
|
_easycom_uni_steps();
|
|
}
|
|
const _sfc_main = {
|
|
__name: "testFive",
|
|
setup(__props) {
|
|
common_vendor.ref(0);
|
|
const orderItem = common_vendor.ref([]);
|
|
common_vendor.onUnload(() => {
|
|
common_vendor.index.reLaunch({
|
|
url: "/pages/index/index"
|
|
});
|
|
});
|
|
const stepsForSelfPickup = common_vendor.reactive([
|
|
{ title: "备餐中" },
|
|
{ title: "已出餐" },
|
|
{ title: "已完成" }
|
|
]);
|
|
const stepsForDelivery = common_vendor.reactive([
|
|
{ title: "备餐中" },
|
|
{ title: "已出餐" },
|
|
{ title: "送餐中" },
|
|
{ title: "已完成" }
|
|
]);
|
|
const calculateActive = (item) => {
|
|
if (item.pickupMethod === 2) {
|
|
if (item.errandState === 4)
|
|
return 3;
|
|
if (item.errandState === 3)
|
|
return 2;
|
|
if (item.orderState === 4)
|
|
return 1;
|
|
return 0;
|
|
} else {
|
|
if (item.orderState === 4)
|
|
return 1;
|
|
if (item.orderState > 4)
|
|
return 2;
|
|
return 0;
|
|
}
|
|
};
|
|
const previewImage = (address) => {
|
|
common_vendor.index.previewImage({
|
|
urls: ["http://" + address],
|
|
current: 0
|
|
});
|
|
};
|
|
const getOrderStatus = () => {
|
|
common_vendor.index.request({
|
|
url: API_api.apiImageUrl + "/api/orders/list/status",
|
|
method: "POST",
|
|
header: {
|
|
"Content-Type": "application/json",
|
|
"cookie": common_vendor.index.getStorageSync("cookie") || ""
|
|
},
|
|
success(res) {
|
|
orderItem.value = res.data.data.map((item) => ({
|
|
...item,
|
|
// 转换数字类型防止类型判断错误
|
|
orderState: Number(item.orderState),
|
|
errandState: Number(item.errandState)
|
|
}));
|
|
}
|
|
});
|
|
};
|
|
common_vendor.onMounted(() => {
|
|
getOrderStatus();
|
|
});
|
|
return (_ctx, _cache) => {
|
|
return {
|
|
a: common_vendor.f(orderItem.value, (item, index, i0) => {
|
|
return common_vendor.e({
|
|
a: item.pickupMethod !== 2 || !item.imageAddress
|
|
}, item.pickupMethod !== 2 || !item.imageAddress ? {
|
|
b: common_vendor.t(item == null ? void 0 : item.id)
|
|
} : {}, {
|
|
c: item.pickupMethod === 2 && item.imageAddress
|
|
}, item.pickupMethod === 2 && item.imageAddress ? {
|
|
d: "http://" + item.imageAddress,
|
|
e: common_vendor.o(($event) => previewImage(item.imageAddress))
|
|
} : {}, {
|
|
f: "2e2c92b9-0-" + i0,
|
|
g: common_vendor.p({
|
|
options: item.pickupMethod === 2 ? stepsForDelivery : stepsForSelfPickup,
|
|
active: calculateActive(item)
|
|
}),
|
|
h: index
|
|
});
|
|
})
|
|
};
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-2e2c92b9"]]);
|
|
my.createPage(MiniProgramPage);
|