"use strict";
const common_vendor = require("../../../common/vendor.js");
const request_api = require("../../../request/api.js");
const utils_util = require("../../../utils/util.js");
const common_assets = require("../../../common/assets.js");
const _sfc_main = {
  data() {
    return {
      navH: common_vendor.inject("navHeight"),
      followList: [],
      page: 1,
      loadAll: false,
      getRateStr: utils_util.getRateStr,
      getRateUpOrDown: utils_util.getRateUpOrDown,
      getLocaleTime: utils_util.getLocaleTime
    };
  },
  onLoad() {
    this.getFollowCollectListData();
  },
  onPullDownRefresh() {
    this.page = 1;
    this.getFollowCollectListData();
  },
  onReachBottom() {
    if (!this.loadAll) {
      this.page++;
      this.getFollowCollectListData();
    }
  },
  methods: {
    /**
     * 点击相关股票
     * @param {Object} code
     */
    clickLookRelatedStockItem(id, code) {
      common_vendor.index.navigateTo({
        url: "/pages/index/stockDetails/stockDetails?type=1&code=" + code + "&id=" + id
      });
    },
    /**
     * 点击关注事件
     * @param {Object} id
     */
    clickFollowEvent(id, index) {
      request_api.followEvent(id).then((res) => {
        common_vendor.index.showToast({
          title: res.message,
          icon: "none"
        });
        this.followList.splice(index, 1);
      }).catch((error) => {
      });
    },
    /**
     * 查看事件详情
     */
    clickEventItem(id) {
      common_vendor.index.navigateTo({
        url: "/pages/index/eventDetails/eventDetails?id=" + id
      });
    },
    /**
     * 获取关注收藏列表数据
     */
    getFollowCollectListData() {
      let param = { page: this.page, type: "follows" };
      request_api.userActivityList(param).then((res) => {
        if (res.code == 200) {
          if (res.data.current_page == 1) {
            this.followList = res.data.activities;
          } else
            this.followList = this.followList.concat(res.data.activities);
          if (res.data.current_page == res.data.pages) {
            this.loadAll = true;
          }
        } else
          common_vendor.index.showToast({
            title: res.message,
            icon: "none"
          });
      }).catch((error) => {
      });
    }
  }
};
if (!Array) {
  const _easycom_navBar2 = common_vendor.resolveComponent("navBar");
  _easycom_navBar2();
}
const _easycom_navBar = () => "../../../components/navBar/navBar.js";
if (!Math) {
  _easycom_navBar();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return {
    a: common_vendor.p({
      leftText: "关注收藏"
    }),
    b: common_assets._imports_0,
    c: common_vendor.f($data.followList, (item, index, i0) => {
      return common_vendor.e({
        a: common_vendor.t(item.importance),
        b: common_vendor.n("level " + item.importance),
        c: common_vendor.t(item.event_title),
        d: common_vendor.t(item.event_description),
        e: $data.getRateUpOrDown(item.related_avg_chg)
      }, $data.getRateUpOrDown(item.related_avg_chg) ? {
        f: common_assets._imports_1$1
      } : {
        g: common_assets._imports_2$1
      }, {
        h: common_vendor.t($data.getRateStr(item.related_avg_chg)),
        i: common_vendor.n("rateItem " + ($data.getRateUpOrDown(item.related_avg_chg) ? "down" : "up")),
        j: $data.getRateUpOrDown(item.related_max_chg)
      }, $data.getRateUpOrDown(item.related_max_chg) ? {
        k: common_assets._imports_1$1
      } : {
        l: common_assets._imports_2$1
      }, {
        m: common_vendor.t($data.getRateStr(item.related_max_chg)),
        n: common_vendor.n("rateItem " + ($data.getRateUpOrDown(item.related_max_chg) ? "down" : "up")),
        o: $data.getRateUpOrDown(item.related_week_chg)
      }, $data.getRateUpOrDown(item.related_week_chg) ? {
        p: common_assets._imports_1$1
      } : {
        q: common_assets._imports_2$1
      }, {
        r: common_vendor.t($data.getRateStr(item.related_week_chg)),
        s: common_vendor.n("rateItem " + ($data.getRateUpOrDown(item.related_week_chg) ? "down" : "up")),
        t: common_vendor.f(item.related_stocks, (sitem, sindex, i1) => {
          return {
            a: common_vendor.t(sitem.stock_name),
            b: common_vendor.t(($data.getRateUpOrDown(sitem.daily_change) ? "" : "+") + sitem.daily_change),
            c: sindex,
            d: common_vendor.o(($event) => $options.clickLookRelatedStockItem(item.event_id, sitem.stock_code), sindex)
          };
        }),
        v: common_vendor.t($data.getLocaleTime(item.created_at)),
        w: common_vendor.t(item.view_count),
        x: common_vendor.t(item.comment_count),
        y: common_vendor.t(item.follower_count),
        z: common_vendor.o(($event) => $options.clickFollowEvent(item.event_id, index), index),
        A: common_vendor.o(($event) => $options.clickEventItem(item.event_id), index),
        B: index
      });
    }),
    d: common_assets._imports_3$1,
    e: common_assets._imports_4,
    f: common_assets._imports_5$3,
    g: common_vendor.s("top:" + $data.navH + "px;")
  };
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/mine/followCollect/followCollect.js.map
