"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const pages_mixins_pullRefreshMixin = require("../mixins/pullRefreshMixin.js");
|
|
const _sfc_main = {
|
|
mixins: [pages_mixins_pullRefreshMixin.pullRefreshMixin],
|
|
data() {
|
|
return {
|
|
statusBarHeight: 0,
|
|
navBarContentHeight: 44,
|
|
tabBarHeight: 48,
|
|
navBarHeight: 44,
|
|
navBarRealHeight: 44,
|
|
tabs: [
|
|
{ label: "全部", value: -1 },
|
|
{ label: "已预约", value: 0 },
|
|
{ label: "待质检", value: 1 },
|
|
{ label: "已结款", value: 2 },
|
|
{ label: "已驳回", value: 3 }
|
|
],
|
|
currentTab: 0,
|
|
orderList: [],
|
|
searchMode: false,
|
|
searchText: "",
|
|
historyOrderMode: false,
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
hasMore: true,
|
|
isLoading: false,
|
|
userId: ""
|
|
};
|
|
},
|
|
onLoad(options) {
|
|
const sys = common_vendor.index.getSystemInfoSync();
|
|
this.statusBarHeight = sys.statusBarHeight;
|
|
this.$nextTick(() => {
|
|
common_vendor.index.createSelectorQuery().select(".nav-bar").boundingClientRect((rect) => {
|
|
if (rect) {
|
|
this.navBarRealHeight = rect.height;
|
|
}
|
|
}).exec();
|
|
});
|
|
if (options && options.historyOrder) {
|
|
this.historyOrderMode = true;
|
|
}
|
|
if (options && options.userId) {
|
|
this.userId = options.userId;
|
|
}
|
|
this.fetchOrderList();
|
|
},
|
|
computed: {
|
|
filteredOrders() {
|
|
if (this.searchText) {
|
|
const text = this.searchText.toLowerCase();
|
|
return this.orderList.filter(
|
|
(order) => order.orderNo && order.orderNo.toLowerCase().includes(text) || order.userName && order.userName.toLowerCase().includes(text) || order.phone && order.phone.toLowerCase().includes(text)
|
|
);
|
|
}
|
|
const tabValue = this.tabs[this.currentTab].value;
|
|
if (tabValue === -1)
|
|
return this.orderList;
|
|
if (tabValue === 0) {
|
|
return this.orderList.filter((order) => order.status == 1);
|
|
} else if (tabValue === 1) {
|
|
return this.orderList.filter((order) => order.status == 2);
|
|
} else if (tabValue === 2) {
|
|
return this.orderList.filter((order) => order.status == 3);
|
|
} else if (tabValue === 3) {
|
|
return this.orderList.filter((order) => order.status == 4);
|
|
}
|
|
return this.orderList;
|
|
}
|
|
},
|
|
methods: {
|
|
goBack() {
|
|
common_vendor.index.navigateBack();
|
|
},
|
|
onTabChange(idx) {
|
|
this.currentTab = idx;
|
|
this.pageNum = 1;
|
|
this.hasMore = true;
|
|
this.orderList = [];
|
|
this.fetchOrderList();
|
|
},
|
|
onSearchIconClick() {
|
|
this.searchMode = true;
|
|
this.$nextTick(() => {
|
|
this.$refs.searchInput && this.$refs.searchInput.focus();
|
|
});
|
|
},
|
|
onClearSearch() {
|
|
this.searchText = "";
|
|
},
|
|
onCancelSearch() {
|
|
this.searchText = "";
|
|
this.searchMode = false;
|
|
},
|
|
goToOrderDetail(order) {
|
|
common_vendor.index.navigateTo({
|
|
url: "/pages/manager/order-detail?id=" + order.id
|
|
});
|
|
},
|
|
refreshData() {
|
|
},
|
|
async onRefresh() {
|
|
await this.refreshData && this.refreshData();
|
|
},
|
|
fetchOrderList(isLoadMore = false) {
|
|
if (this.isLoading || !isLoadMore && !this.hasMore)
|
|
return;
|
|
this.isLoading = true;
|
|
const params = {
|
|
pageNum: this.pageNum,
|
|
pageSize: this.pageSize
|
|
};
|
|
if (this.userId) {
|
|
params.userId = this.userId;
|
|
}
|
|
this.$api && this.$api("getOrderList", params, (res) => {
|
|
if (res && res.code === 200 && res.result && res.result.records) {
|
|
const newOrders = res.result.records.map((order) => {
|
|
const statusInfo = this.getOrderStatusInfo(order.status, order.state);
|
|
return {
|
|
id: order.id,
|
|
orderNo: order.ordeNo,
|
|
userName: order.name,
|
|
phone: order.phone,
|
|
appointTime: order.goTime,
|
|
cancelTime: order.state === 3 ? order.updateTime : "",
|
|
qualityTime: order.status === 2 && order.state === 1 ? order.updateTime : "",
|
|
statusText: order.isBy === "Y" ? statusInfo.label : "不包邮",
|
|
statusClass: statusInfo.class,
|
|
statusLabel: statusInfo.label,
|
|
actions: this.getOrderActions(order.status, order.state),
|
|
status: this.getOrderStatus(order.status, order.state)
|
|
};
|
|
});
|
|
if (isLoadMore) {
|
|
this.orderList = [...this.orderList, ...newOrders];
|
|
} else {
|
|
this.orderList = newOrders;
|
|
}
|
|
this.hasMore = newOrders.length === this.pageSize;
|
|
this.pageNum = isLoadMore ? this.pageNum + 1 : 1;
|
|
}
|
|
this.isLoading = false;
|
|
});
|
|
},
|
|
getOrderStatusInfo(status, state) {
|
|
if (status === 1) {
|
|
return { label: "已预约", class: "green" };
|
|
} else if (state === 1) {
|
|
return { label: "待质检", class: "orange" };
|
|
} else if (status === 3) {
|
|
return { label: "已结款", class: "blue" };
|
|
} else if (status === 1 && state === 3) {
|
|
return { label: "已驳回", class: "red" };
|
|
}
|
|
return { label: "未知状态", class: "gray" };
|
|
},
|
|
getOrderStatus(status, state) {
|
|
if (status === 1)
|
|
return 1;
|
|
if (state === 1)
|
|
return 2;
|
|
if (status === 3)
|
|
return 3;
|
|
if (status === 1 && state === 3)
|
|
return 4;
|
|
return -1;
|
|
},
|
|
getOrderActions(status, state) {
|
|
const actions = [];
|
|
if (status === 2 && state === 1) {
|
|
actions.push({ icon: "undo", text: "驳回" });
|
|
actions.push({ icon: "person", text: "审批" });
|
|
}
|
|
return actions;
|
|
},
|
|
onLoadMore() {
|
|
if (this.hasMore && !this.isLoading) {
|
|
this.fetchOrderList(true);
|
|
}
|
|
},
|
|
scanCode() {
|
|
common_vendor.index.scanCode({
|
|
scanType: ["qrCode"],
|
|
success: (res) => {
|
|
common_vendor.index.__f__("log", "at pages/manager/order.vue:330", "扫码结果:", res);
|
|
if (res.result) {
|
|
common_vendor.index.navigateTo({
|
|
url: "/pages/manager/order-detail?id=" + res.result
|
|
});
|
|
}
|
|
},
|
|
fail: (err) => {
|
|
common_vendor.index.__f__("error", "at pages/manager/order.vue:340", "扫码失败:", err);
|
|
common_vendor.index.showToast({
|
|
title: "扫码失败",
|
|
icon: "none"
|
|
});
|
|
}
|
|
});
|
|
}
|
|
},
|
|
onPullDownRefresh() {
|
|
this.pageNum = 1;
|
|
this.hasMore = true;
|
|
this.orderList = [];
|
|
this.fetchOrderList();
|
|
common_vendor.index.stopPullDownRefresh();
|
|
},
|
|
onReachBottom() {
|
|
this.onLoadMore();
|
|
}
|
|
};
|
|
if (!Array) {
|
|
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
|
_easycom_uni_icons2();
|
|
}
|
|
const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
|
|
if (!Math) {
|
|
_easycom_uni_icons();
|
|
}
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
return common_vendor.e({
|
|
a: common_vendor.o($options.goBack),
|
|
b: common_vendor.p({
|
|
type: "left",
|
|
size: "24",
|
|
color: "#222"
|
|
}),
|
|
c: common_vendor.t($data.historyOrderMode ? "历史订单" : "订单管理"),
|
|
d: $data.statusBarHeight + "px",
|
|
e: $data.statusBarHeight + $data.navBarContentHeight + "px",
|
|
f: !$data.historyOrderMode
|
|
}, !$data.historyOrderMode ? {
|
|
g: common_vendor.f($data.tabs, (tab, idx, i0) => {
|
|
return {
|
|
a: common_vendor.t(tab.label),
|
|
b: tab.value,
|
|
c: common_vendor.n({
|
|
active: $data.currentTab === idx
|
|
}),
|
|
d: common_vendor.o(($event) => $options.onTabChange(idx), tab.value)
|
|
};
|
|
}),
|
|
h: $data.tabs.length * 20 + "%",
|
|
i: $data.navBarRealHeight + "px",
|
|
j: $data.tabBarHeight + "px"
|
|
} : {}, {
|
|
k: !$data.historyOrderMode
|
|
}, !$data.historyOrderMode ? common_vendor.e({
|
|
l: !$data.searchMode
|
|
}, !$data.searchMode ? {
|
|
m: common_vendor.o($options.onSearchIconClick),
|
|
n: common_vendor.p({
|
|
type: "search",
|
|
size: "22",
|
|
color: "#999"
|
|
}),
|
|
o: common_vendor.o($options.scanCode),
|
|
p: common_vendor.p({
|
|
type: "scan",
|
|
size: "22",
|
|
color: "#999"
|
|
})
|
|
} : common_vendor.e({
|
|
q: common_vendor.p({
|
|
type: "search",
|
|
size: "22",
|
|
color: "#999"
|
|
}),
|
|
r: $data.searchText,
|
|
s: common_vendor.o(($event) => $data.searchText = $event.detail.value),
|
|
t: $data.searchText
|
|
}, $data.searchText ? {
|
|
v: common_vendor.o($options.onClearSearch),
|
|
w: common_vendor.p({
|
|
type: "close",
|
|
size: "22",
|
|
color: "#ccc"
|
|
})
|
|
} : {}, {
|
|
x: common_vendor.o((...args) => $options.onCancelSearch && $options.onCancelSearch(...args))
|
|
}), {
|
|
y: $data.navBarRealHeight + $data.tabBarHeight + "px"
|
|
}) : {}, {
|
|
z: common_vendor.f($options.filteredOrders, (order, k0, i0) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.t(order.orderNo),
|
|
b: order.statusText === "不包邮"
|
|
}, order.statusText === "不包邮" ? {
|
|
c: common_vendor.t(order.statusText)
|
|
} : {}, {
|
|
d: common_vendor.t(order.userName),
|
|
e: common_vendor.t(order.phone),
|
|
f: order.appointTime
|
|
}, order.appointTime ? {
|
|
g: common_vendor.t(order.appointTime)
|
|
} : {}, {
|
|
h: order.cancelTime
|
|
}, order.cancelTime ? {
|
|
i: common_vendor.t(order.cancelTime)
|
|
} : {}, {
|
|
j: order.qualityTime
|
|
}, order.qualityTime ? {
|
|
k: common_vendor.t(order.qualityTime)
|
|
} : {}, {
|
|
l: common_vendor.t(order.statusLabel),
|
|
m: common_vendor.n(order.statusClass),
|
|
n: order.actions && order.actions.length && !$data.historyOrderMode
|
|
}, order.actions && order.actions.length && !$data.historyOrderMode ? {
|
|
o: common_vendor.f(order.actions, (action, k1, i1) => {
|
|
return {
|
|
a: "33a4a1f0-5-" + i0 + "-" + i1,
|
|
b: common_vendor.p({
|
|
type: action.icon,
|
|
size: "28",
|
|
color: "#666"
|
|
}),
|
|
c: common_vendor.t(action.text),
|
|
d: action.text,
|
|
e: common_vendor.o(($event) => action.text === "审批" ? $options.goToOrderDetail(order) : null, action.text)
|
|
};
|
|
})
|
|
} : {}, {
|
|
p: order.id,
|
|
q: common_vendor.o(($event) => $options.goToOrderDetail(order), order.id)
|
|
});
|
|
}),
|
|
A: $data.navBarRealHeight + ($data.historyOrderMode ? 0 : $data.tabBarHeight + 16 + 40) + "px"
|
|
});
|
|
}
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-33a4a1f0"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/manager/order.js.map
|