"use strict";
const common_vendor = require("../../../../common/vendor.js");
const common_js_net_UserApi = require("../../../../common/js/net/UserApi.js");
const common_js_conver = require("../../../../common/js/conver.js");
const ContainerLoading = () => "../../../../components/container-loading.js";
const _sfc_main = {
  components: {
    ContainerLoading
  },
  data() {
    return {
      orderList: [],
      //订单列表
      pageData: {
        page: 1,
        rows: 10,
        keywords: ""
      },
      //检索参数
      loadingState: "loading",
      //加载状态
      listRefreshTrig: false,
      //list刷新状态
      isLoadMore: false,
      //加载更多的状态
      hasMore: true,
      //是否有更多数据
      keywords: "",
      //搜索关键字
      loadMore: "more"
      //加载更多 more loading noMore
    };
  },
  onLoad(options) {
    common_vendor.index.setNavigationBarTitle({
      title: "我的订单"
    });
    common_vendor.index.setNavigationBarColor({
      frontColor: "#000000",
      // 必写项，字体颜色仅支持#ffffff和#000000
      backgroundColor: "#F0F0F0",
      // 传递的颜色值，仅支持十六进制颜色
      animation: {
        // 可选项
        duration: 500,
        timingFunc: "linear"
      }
    });
    this.doRefreshList();
  },
  onPullDownRefresh() {
    this.doRefreshList();
    common_vendor.index.stopPullDownRefresh();
  },
  methods: {
    orderStatus: common_js_conver.orderStatus,
    proType: common_js_conver.proType,
    //监听搜索输入框
    inputKeywords(e) {
      this.keywords = e.detail.value;
    },
    //清除搜索内容
    clearSearch() {
      const _self = this;
      _self.keywords = "";
      _self.doRefreshList();
    },
    //发起搜索
    doSearchKeyWord() {
      const _self = this;
      _self.doRefreshList();
    },
    //获取我的订单列表 isRefresh false 加载更多  true 刷新
    doGetMineOrderList(isRefresh) {
      const _self = this;
      _self.orderList = isRefresh ? [] : _self.orderList;
      _self.loadingState = isRefresh ? "loading" : "";
      common_js_net_UserApi.UserApi.doGetMineOrder(_self.pageData).then((res) => {
        common_vendor.index.__f__("log", "at pages/mine/mineAccount/mineOrder/mineOrder.vue:129", res);
        var status = "success";
        status = res.rows && res.rows.length > 0 ? "success" : "empty";
        _self.loadingState = isRefresh ? status : "";
        _self.orderList = _self.orderList.concat(res.rows);
        _self.listRefreshTrig = false;
        _self.isLoadMore = false;
        _self.hasMore = _self.orderList.length < res.total ? "more" : "noMore";
        _self.loadMore = _self.hasMore ? "more" : "noMore";
      }).catch((err) => {
        _self.loadingState = "error";
        _self.listRefreshTrig = false;
        _self.isLoadMore = false;
        _self.hasMore = "more";
        _self.loadMore = "more";
      });
    },
    //刷新列表
    doRefreshList() {
      common_vendor.index.__f__("log", "at pages/mine/mineAccount/mineOrder/mineOrder.vue:149", "正在刷新...");
      const _self = this;
      _self.listRefreshTrig = true;
      _self.loadingState = "loading";
      _self.hasMore = true;
      _self.loadMore = "more";
      _self.pageData.page = 1;
      _self.pageData.keywords = _self.keywords;
      _self.isLoadMore = false;
      _self.doGetMineOrderList(true);
    },
    //加载更多
    doLoadMore() {
      const _self = this;
      if (_self.isLoadMore || _self.hasMore == "noMore") {
        return;
      }
      _self.isLoadMore = true;
      _self.hasMore = "loading";
      _self.pageData.page = ++_self.pageData.page;
      _self.pageData.keywords = _self.keywords;
      _self.doGetMineOrderList(false);
    }
  }
};
if (!Array) {
  const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
  const _component_ContainerLoading = common_vendor.resolveComponent("ContainerLoading");
  (_easycom_uni_load_more2 + _component_ContainerLoading)();
}
const _easycom_uni_load_more = () => "../../../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
if (!Math) {
  _easycom_uni_load_more();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: $data.keywords,
    b: common_vendor.o((...args) => $options.inputKeywords && $options.inputKeywords(...args)),
    c: common_vendor.o((...args) => $options.doSearchKeyWord && $options.doSearchKeyWord(...args)),
    d: $data.keywords != ""
  }, $data.keywords != "" ? {
    e: common_vendor.o((...args) => $options.clearSearch && $options.clearSearch(...args))
  } : {}, {
    f: common_vendor.f($data.orderList, (item, index, i0) => {
      return {
        a: common_vendor.t(item.orderNo),
        b: common_vendor.t($options.orderStatus(item.orderStatus)),
        c: common_vendor.f(item.orderDetails, (detail, dIndex, i1) => {
          return {
            a: common_vendor.t(detail.productName),
            b: common_vendor.t($options.proType(detail.productType)),
            c: common_vendor.t(detail.quantity),
            d: common_vendor.t(detail.unitPrice / 100),
            e: common_vendor.t(detail.notes),
            f: common_vendor.t(detail.productDescription),
            g: dIndex
          };
        }),
        d: common_vendor.t(item.totalAmount / 100),
        e: index
      };
    }),
    g: common_vendor.p({
      status: $data.hasMore
    }),
    h: common_vendor.o((...args) => $options.doLoadMore && $options.doLoadMore(...args)),
    i: common_vendor.o($options.doRefreshList),
    j: common_vendor.p({
      loadingVisible: $data.loadingState
    })
  });
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
tt.createPage(MiniProgramPage);
//# sourceMappingURL=../../../../../.sourcemap/mp-toutiao/pages/mine/mineAccount/mineOrder/mineOrder.js.map
