176 lines
5.8 KiB
JavaScript
176 lines
5.8 KiB
JavaScript
|
"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: "orderState",
|
||
|
setup(__props) {
|
||
|
const currentPage = common_vendor.ref(1);
|
||
|
const pageSize = common_vendor.ref(10);
|
||
|
const totalPage = 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: "",
|
||
|
sortOrder: "",
|
||
|
startTime: "",
|
||
|
state: 0
|
||
|
},
|
||
|
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();
|
||
|
totalPage.value = Math.ceil(res.data.data.total / pageSize.value);
|
||
|
console.log("订单数据:", orderList.value);
|
||
|
}
|
||
|
},
|
||
|
fail() {
|
||
|
console.log("出错啦");
|
||
|
}
|
||
|
});
|
||
|
};
|
||
|
common_vendor.onMounted(() => {
|
||
|
getOrder(currentPage.value);
|
||
|
});
|
||
|
const onPageChange = (e) => {
|
||
|
currentPage.value = e.current;
|
||
|
getOrder(e.current);
|
||
|
};
|
||
|
const closeOrder = (order) => {
|
||
|
console.log(order);
|
||
|
console.log(order.id);
|
||
|
common_vendor.index.request({
|
||
|
url: API_api.apiImageUrl + "/api/orders/cancel",
|
||
|
method: "POST",
|
||
|
data: {
|
||
|
id: order.id
|
||
|
},
|
||
|
success(res) {
|
||
|
console.log("成功");
|
||
|
console.log(res);
|
||
|
},
|
||
|
fail() {
|
||
|
console.log("失败");
|
||
|
}
|
||
|
});
|
||
|
};
|
||
|
const goToPay = (order) => {
|
||
|
console.log(order);
|
||
|
common_vendor.index.request({
|
||
|
url: API_api.apiImageUrl + "/api/Alipay/payment/create",
|
||
|
method: "GET",
|
||
|
data: {
|
||
|
id: order
|
||
|
},
|
||
|
header: {
|
||
|
"Content-Type": "application/json",
|
||
|
// 确保设置正确的 Content-Type
|
||
|
"cookie": common_vendor.index.getStorageSync("cookie") || ""
|
||
|
},
|
||
|
success: function(result) {
|
||
|
console.log(result);
|
||
|
console.log(result.data.data);
|
||
|
common_vendor.index.setStorageSync("tradeNo", result.data.data);
|
||
|
my.tradePay({
|
||
|
tradeNO: result.data.data,
|
||
|
success: (res) => {
|
||
|
console.log("成功调用");
|
||
|
console.log(res);
|
||
|
console.log(res.resultCode);
|
||
|
if (res.resultCode == 6001) {
|
||
|
console.log("我是6001");
|
||
|
common_vendor.index.setStorageSync("notPay", orderId);
|
||
|
common_vendor.index.navigateTo({
|
||
|
url: "/pages/goToPay/goToPay"
|
||
|
});
|
||
|
} else if (res.resultCode == 9e3) {
|
||
|
common_vendor.index.setStorageSync("orderId", orderId);
|
||
|
common_vendor.index.navigateTo({
|
||
|
url: "/pages/testFive/testFive"
|
||
|
});
|
||
|
}
|
||
|
},
|
||
|
fail: (res) => {
|
||
|
my.alert({
|
||
|
content: JSON.stringify(res)
|
||
|
});
|
||
|
console.log("失败");
|
||
|
console.log(res);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
};
|
||
|
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: common_vendor.o(() => closeOrder(order), index),
|
||
|
g: common_vendor.o(($event) => goToPay(order.id), index)
|
||
|
}, {
|
||
|
i: index
|
||
|
});
|
||
|
}),
|
||
|
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: totalPage.value * pageSize.value
|
||
|
})
|
||
|
};
|
||
|
};
|
||
|
}
|
||
|
});
|
||
|
wx.createComponent(_sfc_main);
|