|
|
- "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 {
- tabs: [
- { name: "全部", count: 0 },
- { name: "进行中", count: 0 },
- { name: "已完成", count: 0 }
- ],
- currentTab: 0,
- orderList: [],
- // 当前显示的订单列表
- loading: false,
- page: 1,
- pageSize: 10,
- hasMore: true
- };
- },
- created() {
- this.fetchOrderList();
- },
- methods: {
- async fetchOrderList(isLoadMore = false) {
- this.loading = true;
- let statusArr = [];
- if (this.currentTab === 1)
- statusArr = [0, 1, 2];
- else if (this.currentTab === 2)
- statusArr = [3];
- else
- statusArr = [];
- let allOrders = [];
- if (statusArr.length === 0) {
- await new Promise((resolve) => {
- this.$api("getOrderListPage", { pageSize: this.pageSize, current: this.page }, (res) => {
- if (res && res.code === 200 && res.result && Array.isArray(res.result.records)) {
- allOrders = res.result.records;
- if (isLoadMore) {
- this.orderList = this.orderList.concat(allOrders);
- } else {
- this.orderList = allOrders;
- }
- this.hasMore = allOrders.length === this.pageSize;
- }
- resolve();
- });
- });
- } else {
- for (let status of statusArr) {
- await new Promise((resolve) => {
- this.$api("getOrderListPage", { status, pageSize: this.pageSize, current: this.page }, (res) => {
- if (res && res.code === 200 && res.result && Array.isArray(res.result.records)) {
- allOrders = allOrders.concat(res.result.records);
- }
- resolve();
- });
- });
- }
- const map = {};
- allOrders = allOrders.filter((item) => {
- if (map[item.id])
- return false;
- map[item.id] = 1;
- return true;
- });
- if (isLoadMore) {
- this.orderList = this.orderList.concat(allOrders);
- } else {
- this.orderList = allOrders;
- }
- this.hasMore = allOrders.length === this.pageSize;
- }
- this.loading = false;
- },
- switchTab(index) {
- if (this.currentTab === index)
- return;
- this.currentTab = index;
- this.page = 1;
- this.hasMore = true;
- this.orderList = [];
- this.fetchOrderList();
- },
- getOrderStatusText(order) {
- const { status, state } = order;
- if (state == 3)
- return "已取消";
- if (status == 0)
- return "【在线预约】";
- if (status == 1 && state == 0)
- return "【待取件】快递员正在赶来";
- if (status == 1 && state == 1)
- return "【已取件】快递员正在送至质检";
- if (status == 2 && state == 1)
- return "【质检中】质检员正在质检";
- if (status == 3 && state == 1)
- return "【待结款】待平台确认结款项";
- if (status == 3 && state == 2)
- return "【已结款】平台已结款至账户";
- return "";
- },
- async onRefresh() {
- await new Promise((resolve) => setTimeout(resolve, 1e3));
- common_vendor.index.stopPullRefresh();
- },
- goBack() {
- common_vendor.index.navigateBack();
- },
- showMore() {
- },
- onShare() {
- },
- viewAll() {
- this.switchTab(0);
- },
- // 加载更多
- loadMore() {
- if (this.loading || !this.hasMore)
- return;
- this.page++;
- this.fetchOrderList(true);
- },
- goToDetail(order) {
- common_vendor.index.navigateTo({
- url: `/pages/subcomponent/detail?id=${order.id}`
- });
- }
- }
- };
- if (!Array) {
- const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
- const _component_uni_loading = common_vendor.resolveComponent("uni-loading");
- (_easycom_uni_icons2 + _component_uni_loading)();
- }
- 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.p({
- type: "left",
- size: "20"
- }),
- b: common_vendor.o((...args) => $options.goBack && $options.goBack(...args)),
- c: common_vendor.f($data.tabs, (tab, index, i0) => {
- return common_vendor.e({
- a: common_vendor.t(tab.name),
- b: tab.count > 0
- }, tab.count > 0 ? {
- c: common_vendor.t(tab.count)
- } : {}, {
- d: index,
- e: $data.currentTab === index ? 1 : "",
- f: common_vendor.o(($event) => $options.switchTab(index), index)
- });
- }),
- d: common_vendor.f($data.orderList, (order, k0, i0) => {
- return {
- a: common_vendor.t(order.ordeNo || order.id),
- b: order.image || "/static/回收/衣物.png",
- c: common_vendor.t(order.num || order.count || 1),
- d: common_vendor.t(order.onePrice || order.priceRange || 0),
- e: common_vendor.t(order.price || order.estimatePrice),
- f: order.statusIcon || "/static/my/【待取件】快递员正在赶来.png",
- g: common_vendor.t($options.getOrderStatusText(order)),
- h: common_vendor.t(order.goTime || order.statusTime),
- i: order.id,
- j: common_vendor.o(($event) => $options.goToDetail(order), order.id)
- };
- }),
- e: $data.loading
- }, $data.loading ? {
- f: common_vendor.p({
- color: "#ffac07",
- size: 40
- })
- } : !$data.hasMore && $data.orderList.length ? {} : {}, {
- g: !$data.hasMore && $data.orderList.length,
- h: common_vendor.o((...args) => $options.loadMore && $options.loadMore(...args))
- });
- }
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-e4b66be1"]]);
- wx.createPage(MiniProgramPage);
- //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/subcomponent/order.js.map
|