import { defineComponent, reactive, ref, resolveComponent, mergeProps, useSSRContext } from "vue";
import { useStore } from "vuex";
import { useRouter, useRoute } from "vue-router";
import { _ as _sfc_main$1 } from "./banner-Bjm1R_JU.js";
import { _ as _sfc_main$2 } from "./pagination-CaTX_3XH.js";
import { ssrRenderAttrs, ssrRenderComponent, ssrRenderStyle, ssrRenderList, ssrRenderClass, ssrInterpolate } from "vue/server-renderer";
import { _ as _export_sfc } from "../entry-server.js";
import "element-plus";
import "axios";
import "vue3-lazy";
const _sfc_main = defineComponent({
  setup() {
    const store = useStore();
    const router = useRouter();
    useRoute();
    reactive({});
    let paramsData = reactive({
      params: {
        categoryid: 0,
        pageNum: 1,
        pageSize: 10,
        order: "sortindex",
        acitve: true
      },
      index: "",
      sub: 0
    });
    let oldCategoryId = ref(store.state.columnTypes[0].id);
    function facilityClick(item) {
      if (item.id != oldCategoryId.value) {
        paramsData = {
          params: {
            categoryid: item.id,
            pageNum: 1,
            pageSize: 10,
            order: "sortindex",
            acitve: true
          },
          index: store.state.currentPagePath,
          sub: store.state.sub
        };
        oldCategoryId.value = item.id;
        store.dispatch("getPageData", paramsData);
      }
    }
    function details(item) {
      let params = {
        path: `/news_Read`,
        query: {
          categoryid: item.categoryid,
          id: item.id,
          isUrlId: 1
        }
      };
      store.commit("setRoute", params);
      router.push(params);
    }
    function handleCurrentChange(val) {
      paramsData.params.pageNum = val;
      store.dispatch("getPageData", paramsData);
    }
    return { store, facilityClick, handleCurrentChange, details };
  },
  components: {
    banner: _sfc_main$1,
    pagination: _sfc_main$2
  },
  asyncData({ store, route }) {
    let params = reactive(route.value);
    return store.dispatch("getMenuList").then(() => {
      var _a;
      const data = reactive(store.state.menuList);
      let paramsData = reactive({});
      let str = ref("");
      if (params.path.indexOf("_") > -1) {
        str.value = params.path.split("_")[0];
      }
      for (let i = 0; i < data.length; i++) {
        if (!data[i].sname && params.path == data[i].path || data[i].path == str.value) {
          paramsData = {
            params: {
              categoryid: data[i].id,
              pageNum: 1,
              pageSize: 100
              //   order:"sortindex",
            },
            index: params.path,
            sub: i
          };
          if (!((_a = params.query) == null ? void 0 : _a.categoryid)) {
            paramsData.params.categoryid = data[i].children[0].id;
          } else {
            paramsData.params.categoryid = params.query.categoryid;
          }
          return store.dispatch("getPageData", paramsData).then(() => {
            store.commit("setColumnTypes", store.state.menuList[store.state.sub].children);
          });
        }
      }
    });
  }
});
function _sfc_ssrRender(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
  const _component_banner = resolveComponent("banner");
  const _component_el_image = resolveComponent("el-image");
  const _component_pagination = resolveComponent("pagination");
  _push(`<div${ssrRenderAttrs(mergeProps({ class: "pageContain" }, _attrs))}><section class="common-bradcrumb-section">`);
  _push(ssrRenderComponent(_component_banner, null, null, _parent));
  _push(`</section><section style="${ssrRenderStyle({ "background": "#F7F7F7" })}"><div class="container"><div class="row newTypeBox"><!--[-->`);
  ssrRenderList(_ctx.store.state.columnTypes, (item, index2) => {
    _push(`<div class="col-lg-6 col-md-6"><div class="${ssrRenderClass([item.id == _ctx.store.state.acitveId ? "active" : "", "titleOne"])}">${ssrInterpolate(item.categoryName)}</div></div>`);
  });
  _push(`<!--]--></div></div></section><section class="news-content-section pt-70"><div class="container"><div class="row"><div class="col-lg-12 col-md-12 content"><ul><div class="row"><!--[-->`);
  ssrRenderList(_ctx.store.state.pageContent, (item, index2) => {
    _push(`<div class="col-md-4 newItemOne lazyContainer"><div class="oneInnerBox"><div class="img" style="${ssrRenderStyle({ "overflow": "hidden" })}">`);
    _push(ssrRenderComponent(_component_el_image, {
      src: item.image,
      alt: "",
      "data-src": item.image,
      fit: "contain",
      style: { "display": "block" }
    }, null, _parent));
    _push(`</div><a class="line-two">${ssrInterpolate(item.title)}</a><span>${ssrInterpolate(item.createdate)}</span></div></div>`);
  });
  _push(`<!--]--></div></ul>`);
  _push(ssrRenderComponent(_component_pagination, {
    data: _ctx.store.state.pagination,
    onPagination: _ctx.handleCurrentChange
  }, null, _parent));
  _push(`</div></div></div></section></div>`);
}
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/views/news/index.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["ssrRender", _sfc_ssrRender]]);
export {
  index as default
};
