"use strict";
const common_vendor = require("../../../../common/vendor.js");
const common_js_net_InvoiceApi = require("../../../../common/js/net/InvoiceApi.js");
const common_js_conver = require("../../../../common/js/conver.js");
const ContainerLoading = () => "../../../../components/container-loading.js";
const _sfc_main = {
  components: {
    ContainerLoading
  },
  setup() {
  },
  data() {
    return {
      keywords: "",
      pageData: {
        page: 1,
        rows: 10,
        keywords: ""
      },
      msgShow: false,
      msgHint: "",
      msgType: "error",
      loadingState: "loading",
      listRefreshTrig: false,
      isLoadMore: false,
      hasMore: "more",
      recordList: [],
      //开票记录
      needRefresh: false
    };
  },
  onLoad(options) {
    common_vendor.index.setNavigationBarTitle({
      title: "发票管理"
    });
    common_vendor.index.setNavigationBarColor({
      frontColor: "#000000",
      backgroundColor: "#F0F0F0",
      animation: {
        duration: 500,
        timingFunc: "easeIn"
      }
    });
    this.doRefreshList();
  },
  methods: {
    invoiceStatus: common_js_conver.invoiceStatus,
    invoiceStatusColor: common_js_conver.invoiceStatusColor,
    moneyTxt: common_js_conver.moneyTxt,
    inputKeywords(e) {
      this.keywords = e.detail.value;
    },
    doSearchKeyWord() {
      this.doRefreshList();
    },
    clearSearch() {
      this.keywords = "";
      this.doRefreshList();
    },
    //开票信息
    openInvoiceInfo() {
      common_vendor.index.navigateTo({
        url: "/pages/mine/mineAccount/invoiceInfo/invoiceInfo"
      });
    },
    //去修改
    doUpdate(e) {
      const item = e.currentTarget.dataset.value;
      const params = JSON.stringify(item);
      common_vendor.index.navigateTo({
        url: "/pages/mine/mineAccount/mineMakeInvoice/mineMakeInvoice?bean=" + params
      });
    },
    openDetail(e) {
      const item = e.currentTarget.dataset.value;
      const params = JSON.stringify(item);
      common_vendor.index.navigateTo({
        url: "/pages/mine/mineAccount/invoiceDetail/invoiceDetail?bean=" + params
      });
    },
    //取消开票
    cancelRecord(e) {
      const item = e.currentTarget.dataset.value;
      const _self = this;
      common_vendor.index.showModal({
        title: "警告",
        content: "请问您是否真的想要取消此次开票操作?",
        success: (res) => {
          if (res.confirm) {
            _self.doCancelInvoiceRecord(item);
          }
        }
      });
    },
    //取消开票
    doCancelInvoiceRecord(item) {
      const _self = this;
      common_vendor.index.showLoading({
        title: "取消中..."
      });
      common_js_net_InvoiceApi.InvoiceApi.doCancelInvoiceRecord(item.invoiceRechargeId).then((res) => {
        common_vendor.index.hideLoading();
        common_vendor.index.__f__("log", "at pages/mine/mineAccount/mineInvoiceManage/mineInvoiceManage.vue:171", res);
        _self.msgHint = "取消成功";
        _self.msgType = "success";
        _self.$refs.msg.open();
        _self.doRefreshList();
      }).catch((err) => {
        common_vendor.index.hideLoading();
        _self.msgHint = err.msg ? err.msg : "取消出错了,请稍后重试";
        _self.msgType = "error";
        _self.$refs.msg.open();
      });
    },
    //去开票
    openMake() {
      common_vendor.index.navigateTo({
        url: "/pages/mine/mineAccount/minePayOrder/minePayOrder"
      });
    },
    doRefreshList() {
      common_vendor.index.__f__("log", "at pages/mine/mineAccount/mineInvoiceManage/mineInvoiceManage.vue:191", "正在刷新...");
      const _self = this;
      _self.loadingState = "loading";
      _self.hasMore = "more";
      _self.pageData.page = 1;
      _self.pageData.keywords = _self.keywords;
      _self.doGetInvoiceRecordList(true);
    },
    doLoadMore() {
      const _self = this;
      if (_self.isLoadMore || _self.hasMore == "noMore") {
        return;
      }
      _self.hasMore = "loading";
      _self.pageData.page = ++_self.pageData.page;
      _self.pageData.keywords = _self.keywords;
      _self.doGetInvoiceRecordList(false);
    },
    doGetInvoiceRecordList(isRefresh) {
      const _self = this;
      _self.recordList = isRefresh ? [] : _self.recordList;
      _self.loadingState = isRefresh ? "loading" : "";
      common_js_net_InvoiceApi.InvoiceApi.doGetInvoiceRecordList(_self.pageData).then((res) => {
        common_vendor.index.__f__("log", "at pages/mine/mineAccount/mineInvoiceManage/mineInvoiceManage.vue:216", res);
        var status = "success";
        status = res.rows && res.rows.length > 0 ? "success" : "empty";
        _self.loadingState = isRefresh ? status : "";
        _self.recordList = _self.recordList.concat(res.rows);
        _self.hasMore = _self.recordList.length < res.total ? "more" : "noMore";
        _self.isLoadMore = false;
      }).catch((err) => {
        _self.loadingState = "error";
        _self.hasMore = "more";
        _self.isLoadMore = false;
      });
    }
  },
  onPullDownRefresh() {
    this.doRefreshList();
    common_vendor.index.stopPullDownRefresh();
  }
};
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 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.o((...args) => $options.openInvoiceInfo && $options.openInvoiceInfo(...args)),
    g: common_vendor.f($data.recordList, (item, index, i0) => {
      return common_vendor.e({
        a: common_vendor.t($options.invoiceStatus(item.invoiceStatus)),
        b: common_vendor.n($options.invoiceStatusColor(item.invoiceStatus)),
        c: common_vendor.t(item.invoiceName),
        d: item,
        e: item.invoiceStatus == "-1" || item.invoiceStatus == "0"
      }, item.invoiceStatus == "-1" || item.invoiceStatus == "0" ? {
        f: common_vendor.o((...args) => $options.doUpdate && $options.doUpdate(...args)),
        g: item
      } : {}, {
        h: item.invoiceStatus == "1"
      }, item.invoiceStatus == "1" ? {
        i: common_vendor.o((...args) => $options.cancelRecord && $options.cancelRecord(...args)),
        j: item
      } : {}, {
        k: common_vendor.t(item.invoiceNumber),
        l: item,
        m: common_vendor.t(item.gmtCreate),
        n: $options.moneyTxt(10, 14, item.invoiceRechargeMoney),
        o: item,
        p: index
      });
    }),
    h: common_vendor.o((...args) => $options.openDetail && $options.openDetail(...args)),
    i: common_vendor.o((...args) => $options.openDetail && $options.openDetail(...args)),
    j: common_vendor.o((...args) => $options.openDetail && $options.openDetail(...args)),
    k: common_vendor.p({
      status: $data.hasMore
    }),
    l: common_vendor.o((...args) => $options.doLoadMore && $options.doLoadMore(...args)),
    m: common_vendor.o($options.doRefreshList),
    n: common_vendor.p({
      loadingVisible: $data.loadingState
    }),
    o: common_vendor.o((...args) => $options.openMake && $options.openMake(...args)),
    p: common_vendor.p({
      type: $data.msgType,
      message: $data.msgHint,
      duration: 2e3
    }),
    q: common_vendor.sr("msg", "d48a47ca-2"),
    r: common_vendor.p({
      type: "message"
    })
  });
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-d48a47ca"]]);
tt.createPage(MiniProgramPage);
//# sourceMappingURL=../../../../../.sourcemap/mp-toutiao/pages/mine/mineAccount/mineInvoiceManage/mineInvoiceManage.js.map
