"use strict";
const common_vendor = require("../../../../common/vendor.js");
const common_js_net_InvoiceApi = require("../../../../common/js/net/InvoiceApi.js");
const ContainerLoading = () => "../../../../components/container-loading.js";
const _sfc_main = {
  components: {
    ContainerLoading
  },
  setup() {
  },
  data() {
    return {
      packageList: [],
      //套餐包使用详情列表
      pageData: {
        page: 1,
        rows: 10,
        packageOrderId: 0
      },
      //检索参数
      loadingState: "loading",
      //加载状态
      listRefreshTrig: false,
      //list刷新状态
      isLoadMore: false,
      //加载更多的状态
      hasMore: "more",
      //是否有更多数据
      msgType: "error",
      msgHint: "",
      id: ""
    };
  },
  onLoad(options) {
    common_vendor.index.setNavigationBarTitle({
      title: "详情"
    });
    common_vendor.index.setNavigationBarColor({
      frontColor: "#000000",
      backgroundColor: "#F0F0F0",
      animation: {
        duration: 500,
        timingFunc: "easeIn"
      }
    });
    const _self = this;
    let id = options.id;
    let orderId = options.oId;
    this.id = id;
    this.pageData.packageOrderId = orderId;
    if (this.id !== void 0 && this.id !== "" && this.pageData.packageOrderId !== void 0 && this.pageData.packageOrderId !== "") {
      this.doRefreshList();
    } else {
      setTimeout(() => {
        _self.doBackPage();
      }, 1e3);
      this.loadingState = "error";
    }
  },
  onPullDownRefresh() {
    this.doRefreshList();
    common_vendor.index.stopPullDownRefresh();
  },
  onReachBottom() {
    this.doLoadMore();
  },
  methods: {
    doBackPage() {
      this.msgHint = "数据有误,请稍后重试";
      this.msgType = "error";
      this.$refs.msg.open();
      setTimeout(() => {
        common_vendor.index.navigateBack();
      }, 1200);
    },
    //刷新列表
    doRefreshList() {
      common_vendor.index.__f__("log", "at pages/mine/mineAccount/minePackageRecordDetail/minePackageRecordDetail.vue:119", "正在刷新...");
      const _self = this;
      _self.listRefreshTrig = true;
      _self.loadingState = "loading";
      _self.hasMore = "more";
      _self.pageData.page = 1;
      _self.isLoadMore = false;
      _self.doGetMinePackageList(true);
    },
    //加载更多
    doLoadMore() {
      const _self = this;
      if (_self.isLoadMore || _self.hasMore == "noMore") {
        return;
      }
      _self.isLoadMore = true;
      _self.pageData.page = ++_self.pageData.page;
      _self.doGetMinePackageList(false);
    },
    //获取我的联系人列表 isRefresh false 加载更多  true 刷新
    doGetMinePackageList(isRefresh) {
      const _self = this;
      _self.packageList = isRefresh ? [] : _self.packageList;
      _self.loadingState = isRefresh ? "loading" : "";
      common_js_net_InvoiceApi.InvoiceApi.doGetMinePackageUseDetail(_self.id, _self.pageData).then((res) => {
        common_vendor.index.__f__("log", "at pages/mine/mineAccount/minePackageRecordDetail/minePackageRecordDetail.vue:146", res);
        common_vendor.index.stopPullDownRefresh();
        var status = "success";
        status = res.rows && res.rows.length > 0 ? "success" : "empty";
        _self.loadingState = isRefresh ? status : "";
        _self.packageList = _self.packageList.concat(res.rows);
        _self.listRefreshTrig = false;
        _self.isLoadMore = false;
        _self.hasMore = _self.packageList.length < res.total ? "more" : "noMore";
      }).catch((err) => {
        common_vendor.index.stopPullDownRefresh();
        _self.loadingState = "error";
        _self.listRefreshTrig = false;
        _self.isLoadMore = false;
        _self.hasMore = "more";
      });
    }
  }
};
if (!Array) {
  const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
  const _component_ContainerLoading = common_vendor.resolveComponent("ContainerLoading");
  const _easycom_uni_popup_message2 = common_vendor.resolveComponent("uni-popup-message");
  const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
  (_easycom_uni_load_more2 + _component_ContainerLoading + _easycom_uni_popup_message2 + _easycom_uni_popup2)();
}
const _easycom_uni_load_more = () => "../../../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
const _easycom_uni_popup_message = () => "../../../../uni_modules/uni-popup/components/uni-popup-message/uni-popup-message.js";
const _easycom_uni_popup = () => "../../../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
if (!Math) {
  (_easycom_uni_load_more + _easycom_uni_popup_message + _easycom_uni_popup)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return {
    a: common_vendor.f($data.packageList, (item, index, i0) => {
      return {
        a: index,
        b: common_vendor.t(item.orderTitle),
        c: common_vendor.t(item.mode == "1" ? "退回" : "使用"),
        d: common_vendor.t(item.description),
        e: common_vendor.t(item.itemCount),
        f: common_vendor.t(item.itemUseCount),
        g: common_vendor.t(item.gmtCreate)
      };
    }),
    b: common_vendor.p({
      status: $data.hasMore
    }),
    c: common_vendor.j({
      "doRefresh": common_vendor.o($options.doRefreshList)
    }),
    d: common_vendor.p({
      loadingVisible: $data.loadingState
    }),
    e: common_vendor.p({
      type: $data.msgType,
      message: $data.msgHint,
      duration: 2e3
    }),
    f: common_vendor.sr("msg", "dc59bd9b-2"),
    g: common_vendor.p({
      type: "message"
    })
  };
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-dc59bd9b"]]);
swan.createPage(MiniProgramPage);
//# sourceMappingURL=../../../../../.sourcemap/mp-baidu/pages/mine/mineAccount/minePackageRecordDetail/minePackageRecordDetail.js.map
