"use strict";
const common_vendor = require("../../../common/vendor.js");
const sheep_index = require("../../../sheep/index.js");
const sheep_hooks_useGoods = require("../../../sheep/hooks/useGoods.js");
const sheep_api_trade_afterSale = require("../../../sheep/api/trade/afterSale.js");
require("../../../sheep/api/index.js");
require("../../../sheep/api/distri/score.js");
require("../../../sheep/request/index.js");
require("../../../sheep/config/index.js");
require("../../../sheep/store/index.js");
require("../../../sheep/store/app.js");
require("../../../sheep/api/promotion/diy.js");
require("../../../sheep/platform/index.js");
require("../../../sheep/platform/provider/wechat/index.js");
require("../../../sheep/platform/provider/wechat/miniProgram.js");
require("../../../sheep/api/member/auth.js");
require("../../../sheep/api/member/social.js");
require("../../../sheep/api/member/user.js");
require("../../../sheep/platform/provider/apple/index.js");
require("../../../sheep/platform/share.js");
require("../../../sheep/router/index.js");
require("../../../sheep/hooks/useModal.js");
require("../../../sheep/helper/index.js");
require("../../../sheep/helper/test.js");
require("../../../sheep/helper/digit.js");
require("../../../sheep/api/member/signin.js");
require("../../../sheep/helper/throttle.js");
require("../../../sheep/url/index.js");
require("../../../sheep/platform/pay.js");
require("../../../sheep/api/pay/order.js");
require("../../../sheep/store/user.js");
require("../../../sheep/store/cart.js");
require("../../../sheep/api/trade/cart.js");
require("../../../sheep/api/pay/wallet.js");
require("../../../sheep/api/trade/order.js");
require("../../../sheep/api/promotion/coupon.js");
require("../../../sheep/store/sys.js");
require("../../../sheep/store/modal.js");
require("../../../sheep/api/distri/share.js");
require("../../../sheep/api/distri/team.js");
require("../../../sheep/api/infra/file.js");
require("../../../sheep/api/member/address.js");
require("../../../sheep/api/member/point.js");
require("../../../sheep/api/migration/app.js");
require("../../../sheep/api/migration/chat.js");
require("../../../sheep/api/migration/index.js");
require("../../../sheep/api/migration/third.js");
require("../../../sheep/api/pay/channel.js");
require("../../../sheep/api/product/category.js");
require("../../../sheep/api/product/comment.js");
require("../../../sheep/api/product/favorite.js");
require("../../../sheep/api/product/history.js");
require("../../../sheep/api/product/spu.js");
require("../../../sheep/api/promotion/activity.js");
require("../../../sheep/api/promotion/article.js");
require("../../../sheep/api/promotion/bargain.js");
require("../../../sheep/api/promotion/combination.js");
require("../../../sheep/api/promotion/rewardActivity.js");
require("../../../sheep/api/promotion/seckill.js");
require("../../../sheep/api/system/area.js");
require("../../../sheep/api/system/voice.js");
require("../../../sheep/api/trade/brokerage.js");
require("../../../sheep/api/trade/config.js");
require("../../../sheep/api/trade/delivery.js");
require("../../../sheep/config/zIndex.js");
require("../../../sheep/util/index.js");
if (!Array) {
  const _easycom_su_tabs2 = common_vendor.resolveComponent("su-tabs");
  const _easycom_su_sticky2 = common_vendor.resolveComponent("su-sticky");
  const _easycom_s_empty2 = common_vendor.resolveComponent("s-empty");
  const _easycom_s_goods_item2 = common_vendor.resolveComponent("s-goods-item");
  const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
  const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  (_easycom_su_tabs2 + _easycom_su_sticky2 + _easycom_s_empty2 + _easycom_s_goods_item2 + _easycom_uni_load_more2 + _easycom_s_layout2)();
}
const _easycom_su_tabs = () => "../../../sheep/ui/su-tabs/su-tabs.js";
const _easycom_su_sticky = () => "../../../sheep/ui/su-sticky/su-sticky.js";
const _easycom_s_empty = () => "../../../sheep/components/s-empty/s-empty.js";
const _easycom_s_goods_item = () => "../../../sheep/components/s-goods-item/s-goods-item.js";
const _easycom_uni_load_more = () => "../../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
const _easycom_s_layout = () => "../../../sheep/components/s-layout/s-layout.js";
if (!Math) {
  (_easycom_su_tabs + _easycom_su_sticky + _easycom_s_empty + _easycom_s_goods_item + _easycom_uni_load_more + _easycom_s_layout)();
}
const _sfc_main = {
  __name: "list",
  setup(__props) {
    const paginationNull = {
      list: [],
      total: 0,
      pageNo: 1,
      pageSize: 10
    };
    const state = common_vendor.reactive({
      currentTab: 0,
      showApply: false,
      pagination: {
        list: [],
        total: 0,
        pageNo: 1,
        pageSize: 10
      },
      loadStatus: ""
    });
    const tabMaps = [
      {
        name: "全部",
        value: "all"
      }
      // {
      //   name: '申请中',
      //   value: 'nooper',
      // },
      // {
      //   name: '处理中',
      //   value: 'ing',
      // },
      // {
      //   name: '已完成',
      //   value: 'completed',
      // },
      // {
      //   name: '已拒绝',
      //   value: 'refuse',
      // },
    ];
    function onTabsChange(e) {
      state.pagination = paginationNull;
      state.currentTab = e.index;
      getOrderList();
    }
    async function getOrderList() {
      state.loadStatus = "loading";
      let { data, code } = await sheep_api_trade_afterSale.AfterSaleApi.getAfterSalePage({
        // type: tabMaps[state.currentTab].value,
        pageNo: state.pagination.pageNo,
        pageSize: state.pagination.pageSize
      });
      if (code !== 0) {
        return;
      }
      data.list.forEach((order) => sheep_hooks_useGoods.handleAfterSaleButtons(order));
      state.pagination.list = common_vendor._.concat(state.pagination.list, data.list);
      state.pagination.total = data.total;
      state.loadStatus = state.pagination.list.length < state.pagination.total ? "more" : "noMore";
    }
    function onApply(orderId) {
      common_vendor.index.showModal({
        title: "提示",
        content: "确定要取消此申请吗？",
        success: async function(res) {
          if (!res.confirm) {
            return;
          }
          const { code } = await sheep_api_trade_afterSale.AfterSaleApi.cancelAfterSale(orderId);
          if (code === 0) {
            state.pagination = paginationNull;
            await getOrderList();
          }
        }
      });
    }
    common_vendor.onLoad(async (options) => {
      if (options.type) {
        state.currentTab = options.type;
      }
      await getOrderList();
    });
    function loadMore() {
      if (state.loadStatus === "noMore") {
        return;
      }
      state.pagination.pageNo++;
      getOrderList();
    }
    common_vendor.onReachBottom(() => {
      loadMore();
    });
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.o(onTabsChange),
        b: common_vendor.p({
          list: tabMaps,
          scrollable: false,
          current: state.currentTab
        }),
        c: common_vendor.p({
          bgColor: "#fff"
        }),
        d: state.pagination.total === 0
      }, state.pagination.total === 0 ? {
        e: common_vendor.p({
          icon: "/static/data-empty.png",
          text: "暂无数据"
        })
      } : {}, {
        f: state.pagination.total > 0
      }, state.pagination.total > 0 ? {
        g: common_vendor.f(state.pagination.list, (order, k0, i0) => {
          return common_vendor.e({
            a: common_vendor.t(order.no),
            b: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.formatAfterSaleStatus)(order)),
            c: "c5e81116-4-" + i0 + ",c5e81116-0",
            d: common_vendor.p({
              img: order.picUrl,
              title: order.spuName,
              skuText: order.properties.map((property) => property.valueName).join(" "),
              price: order.refundPrice
            }),
            e: common_vendor.t(order.way === 10 ? "仅退款" : "退款退货"),
            f: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.formatAfterSaleStatusDescription)(order)),
            g: order == null ? void 0 : order.buttons.includes("cancel")
          }, (order == null ? void 0 : order.buttons.includes("cancel")) ? {
            h: common_vendor.o(($event) => onApply(order.id), order.id)
          } : {}, {
            i: order.id,
            j: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/order/aftersale/detail", {
              id: order.id
            }), order.id)
          });
        })
      } : {}, {
        h: state.pagination.total > 0
      }, state.pagination.total > 0 ? {
        i: common_vendor.o(loadMore),
        j: common_vendor.p({
          status: state.loadStatus,
          ["content-text"]: {
            contentdown: "上拉加载更多"
          }
        })
      } : {}, {
        k: common_vendor.p({
          title: "售后列表"
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-c5e81116"], ["__file", "D:/zx/mall-front-app/pages/order/aftersale/list.vue"]]);
wx.createPage(MiniProgramPage);
