169 lines
6.3 KiB
JavaScript
169 lines
6.3 KiB
JavaScript
|
"use strict";
|
||
|
const common_vendor = require("../common/vendor.js");
|
||
|
const api_request = require("../api/request.js");
|
||
|
const _sfc_main = {
|
||
|
__name: "syy",
|
||
|
setup(__props) {
|
||
|
const Status = common_vendor.ref({
|
||
|
orderStatus: "全部",
|
||
|
orders: [],
|
||
|
displayedOrders: []
|
||
|
});
|
||
|
common_vendor.ref(0);
|
||
|
const isSelected = (tab) => Status.value.orderStatus === tab;
|
||
|
const searchKeyword = common_vendor.ref("");
|
||
|
common_vendor.onMounted(async () => {
|
||
|
await Getorder();
|
||
|
if (Status.value.orderStatus === "全部") {
|
||
|
Status.value.displayedOrders = Status.value.orders;
|
||
|
} else {
|
||
|
Status.value.displayedOrders = Status.value.orders.filter((order) => {
|
||
|
switch (Status.value.orderStatus) {
|
||
|
case "待支付":
|
||
|
return order.orderStatus === "待支付";
|
||
|
case "待发货":
|
||
|
return order.orderStatus === "待发货";
|
||
|
case "已发货":
|
||
|
return order.orderStatus === "已发货";
|
||
|
case "已退款":
|
||
|
return order.orderStatus === "已退款";
|
||
|
default:
|
||
|
return false;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
const userInfo = common_vendor.wx$1.getStorageSync("userInfo");
|
||
|
const Getorder = async () => {
|
||
|
const res = await common_vendor.index.request({
|
||
|
url: api_request.baseUrl + "/order/list",
|
||
|
method: "POST",
|
||
|
header: {
|
||
|
cookie: common_vendor.wx$1.getStorageSync("cookie")
|
||
|
},
|
||
|
data: {
|
||
|
id: userInfo.id
|
||
|
}
|
||
|
});
|
||
|
if (res.data.code === 1) {
|
||
|
Status.value.orders = res.data.data;
|
||
|
} else {
|
||
|
console.log("没拿到用户数据");
|
||
|
}
|
||
|
};
|
||
|
const zt = common_vendor.ref({
|
||
|
tab: ""
|
||
|
});
|
||
|
common_vendor.onLoad((options) => {
|
||
|
if (options.tab) {
|
||
|
zt.value.tab = JSON.parse(options.tab);
|
||
|
changeTab(zt.value.tab);
|
||
|
}
|
||
|
});
|
||
|
const changeTab = (tab) => {
|
||
|
if (tab === "全部") {
|
||
|
Status.value.displayedOrders = Status.value.orders;
|
||
|
Status.value.orderStatus = "全部";
|
||
|
} else {
|
||
|
Status.value.displayedOrders = Status.value.orders.filter((order) => {
|
||
|
switch (tab) {
|
||
|
case "待支付":
|
||
|
return order.orderStatus === "待支付";
|
||
|
case "待发货":
|
||
|
return order.orderStatus === "待发货";
|
||
|
case "已发货":
|
||
|
return order.orderStatus === "已发货";
|
||
|
case "已退款":
|
||
|
return order.orderStatus === "已退款";
|
||
|
default:
|
||
|
return false;
|
||
|
}
|
||
|
});
|
||
|
Status.value.orderStatus = tab;
|
||
|
}
|
||
|
};
|
||
|
const handleSearch = () => {
|
||
|
if (searchKeyword.value.trim() === "") {
|
||
|
if (Status.value.orderStatus === "全部") {
|
||
|
Status.value.displayedOrders = Status.value.orders;
|
||
|
} else {
|
||
|
Status.value.displayedOrders = Status.value.orders.filter((order) => {
|
||
|
switch (Status.value.orderStatus) {
|
||
|
case "待支付":
|
||
|
return order.orderStatus === "待支付";
|
||
|
case "待发货":
|
||
|
return order.orderStatus === "待发货";
|
||
|
case "已发货":
|
||
|
return order.orderStatus === "已发货";
|
||
|
case "已退款":
|
||
|
return order.orderStatus === "已退款";
|
||
|
default:
|
||
|
return false;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
const keyword = searchKeyword.value.toLowerCase();
|
||
|
Status.value.displayedOrders = Status.value.orders.filter((order) => {
|
||
|
return order.orderItemList.some((item) => {
|
||
|
return item.goodSnapshot.name.toLowerCase().includes(keyword);
|
||
|
});
|
||
|
});
|
||
|
};
|
||
|
const goToText = (index) => {
|
||
|
common_vendor.index.navigateTo({
|
||
|
url: "../../../pages/mine/OrderDetails/OrderDetails?info=" + JSON.stringify(Status.value.displayedOrders[index])
|
||
|
});
|
||
|
};
|
||
|
return (_ctx, _cache) => {
|
||
|
return {
|
||
|
a: common_vendor.o([($event) => searchKeyword.value = $event.detail.value, handleSearch]),
|
||
|
b: searchKeyword.value,
|
||
|
c: _ctx.orderStatus === "全部" ? 1 : "",
|
||
|
d: isSelected("全部") ? 1 : "",
|
||
|
e: common_vendor.o(($event) => changeTab("全部")),
|
||
|
f: _ctx.orderStatus === "待支付" ? 1 : "",
|
||
|
g: isSelected("待支付") ? 1 : "",
|
||
|
h: common_vendor.o(($event) => changeTab("待支付")),
|
||
|
i: _ctx.orderStatus === "待发货" ? 1 : "",
|
||
|
j: isSelected("待发货") ? 1 : "",
|
||
|
k: common_vendor.o(($event) => changeTab("待发货")),
|
||
|
l: _ctx.orderStatus === "已发货" ? 1 : "",
|
||
|
m: isSelected("已发货") ? 1 : "",
|
||
|
n: common_vendor.o(($event) => changeTab("已发货")),
|
||
|
o: _ctx.orderStatus === "已退款" ? 1 : "",
|
||
|
p: isSelected("已退款") ? 1 : "",
|
||
|
q: common_vendor.o(($event) => changeTab("已退款")),
|
||
|
r: common_vendor.f(Status.value.displayedOrders, (order, index, i0) => {
|
||
|
return common_vendor.e({
|
||
|
a: common_vendor.t(order.orderNumber),
|
||
|
b: common_vendor.f(order.orderItemList, (item, k1, i1) => {
|
||
|
return {
|
||
|
a: item.goodSnapshot.goodImg,
|
||
|
b: common_vendor.t(item.goodSnapshot.name),
|
||
|
c: common_vendor.t(item.goodSnapshot.type),
|
||
|
d: common_vendor.t(item.goodSnapshot.price),
|
||
|
e: item.id
|
||
|
};
|
||
|
}),
|
||
|
c: order.orderStatus === "待支付"
|
||
|
}, order.orderStatus === "待支付" ? {} : {}, {
|
||
|
d: order.orderStatus === "待发货"
|
||
|
}, order.orderStatus === "待发货" ? {} : {}, {
|
||
|
e: order.orderStatus === "已发货"
|
||
|
}, order.orderStatus === "已发货" ? {} : {}, {
|
||
|
f: order.orderStatus === "已退款"
|
||
|
}, order.orderStatus === "已退款" ? {} : {}, {
|
||
|
g: common_vendor.t(order.totalAmount),
|
||
|
h: order.id,
|
||
|
i: common_vendor.o(($event) => goToText(index), order.id)
|
||
|
});
|
||
|
})
|
||
|
};
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-6c52591e"], ["__file", "D:/微信小程序/课设整合/匠承非遗小程序端/jiangchengfeiyi-xiaochengxu/pages/syy.vue"]]);
|
||
|
wx.createPage(MiniProgramPage);
|