"use strict";
const common_vendor = require("../../../../common/vendor.js");
const common_js_net_projectApi = require("../../../../common/js/net/projectApi.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
  },
  setup() {
  },
  data() {
    return {
      packageList: [],
      //联系人列表
      loadingState: "loading",
      isLoadMore: false,
      listRefreshTrig: false,
      pageData: {
        page: 1,
        rows: 10
      },
      hasMore: "more",
      msgHint: "",
      msgType: "error",
      msgShow: false,
      urgent: false,
      allPrice: 0,
      materialPrice: 0
    };
  },
  onLoad(options) {
    common_vendor.index.setNavigationBarTitle({
      title: "套餐包"
    });
    common_vendor.index.setNavigationBarColor({
      frontColor: "#000000",
      backgroundColor: "#F0F0F0",
      animation: {
        duration: 500,
        timingFunc: "easeIn"
      }
    });
    this.doGetPrice();
    this.doRefreshList();
  },
  onPullDownRefresh() {
    this.doRefreshList();
    common_vendor.index.stopPullDownRefresh();
  },
  onReachBottom() {
    this.doLoadMore();
  },
  methods: {
    moneyTxt: common_js_conver.moneyTxt,
    //创建
    goCreate(e) {
      const _self = this;
      const item = e.currentTarget.dataset.item;
      if (item.packageTotalSurplusCount > 0) {
        const price = item.packageInfoAppDTO.packageType == "MATERIAL" ? _self.materialPrice : _self.allPrice;
        common_vendor.index.redirectTo({
          url: "/pages/copyright/createProjectInfo/createProjectInfo?type=" + item.packageInfoAppDTO.packageType + "&price=" + price + "&isUrgent=false&pId=" + item.packageInfoId
        });
      } else {
        _self.msgHint = "该套餐包已无剩余次数";
        _self.msgType = "error";
        _self.$refs.msg.open();
      }
    },
    //详情
    goDetail(e) {
      const item = e.currentTarget.dataset.item;
      common_vendor.index.navigateTo({
        url: "/pages/mine/mineAccount/minePackageRecordDetail/minePackageRecordDetail?id=" + item.modifier + "&oId=" + item.packageOrderId
      });
    },
    doGetPrice() {
      common_vendor.index.showLoading({
        title: "加载中..."
      });
      const _self = this;
      common_js_net_projectApi.ProApi.doGetPrice().then((res) => {
        common_vendor.index.hideLoading();
        common_vendor.index.__f__("log", "at pages/mine/mineAccount/minePackageRecord/minePackageRecord.vue:155", res);
        res.projTypes.forEach((el) => {
          if (el.type == "ALL") {
            _self.allPrice = el.price;
          } else if (el.type == "MATERIAL") {
            _self.materialPrice = el.price;
          }
        });
        _self.urgent = res.additional.urgent;
      }).catch((err) => {
        common_vendor.index.hideLoading();
        _self.msgHint = "数据有误,请刷新页面";
        _self.msgType = "error";
        _self.$refs.msg.open();
      });
    },
    //刷新列表
    doRefreshList() {
      common_vendor.index.__f__("log", "at pages/mine/mineAccount/minePackageRecord/minePackageRecord.vue:174", "正在刷新...");
      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_UserApi.UserApi.doGetMinePackageRecord(_self.pageData).then((res) => {
        common_vendor.index.stopPullDownRefresh();
        common_vendor.index.__f__("log", "at pages/mine/mineAccount/minePackageRecord/minePackageRecord.vue:202", res);
        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 common_vendor.e({
        a: index,
        b: common_vendor.t(item.packageName),
        c: common_vendor.t(item.packageInfoAppDTO.packageType == "MATERIAL" ? "写材料" : "全托管"),
        d: $options.moneyTxt(12, 14, item.packageTotalMoney / 100),
        e: item.packageExpireTime != ""
      }, item.packageExpireTime != "" ? {
        f: common_vendor.t(item.packageExpireTime)
      } : {}, {
        g: common_vendor.t(item.packageTotalSurplusCount),
        h: common_vendor.t(item.packageTotalCount),
        i: common_vendor.t(item.gmtCreate),
        j: item,
        k: item
      });
    }),
    b: common_vendor.o((...args) => $options.goCreate && $options.goCreate(...args)),
    c: common_vendor.o((...args) => $options.goDetail && $options.goDetail(...args)),
    d: common_vendor.p({
      status: $data.hasMore
    }),
    e: common_vendor.j({
      "doRefresh": common_vendor.o($options.doRefreshList)
    }),
    f: common_vendor.p({
      loadingVisible: $data.loadingState
    }),
    g: common_vendor.p({
      type: $data.msgType,
      message: $data.msgHint,
      duration: 2e3
    }),
    h: common_vendor.sr("msg", "67d8ce1a-2"),
    i: common_vendor.p({
      type: "message"
    })
  };
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-67d8ce1a"]]);
swan.createPage(MiniProgramPage);
//# sourceMappingURL=../../../../../.sourcemap/mp-baidu/pages/mine/mineAccount/minePackageRecord/minePackageRecord.js.map
