import { defineComponent, ref, reactive, resolveComponent, resolveDirective, 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, ssrGetDirectiveProps } 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();
    const requestParams = ref({});
    let paramsData = reactive({
      params: {
        categoryid: 0,
        pageNum: 1,
        pageSize: 100,
        order: "sortindex",
        active: true
      },
      index: "",
      sub: 0
    });
    let oldCategoryId = ref();
    function facilityClick(item) {
      if (item.id != oldCategoryId.value) {
        requestParams.value = item;
        paramsData = {
          params: {
            categoryid: item.id,
            pageNum: 1,
            pageSize: 10,
            order: "sortindex",
            active: true
          },
          index: store.state.currentPagePath,
          sub: store.state.sub
        };
        oldCategoryId.value = item.id;
        store.dispatch("getPageData", paramsData);
      }
    }
    function details(item) {
      let params = {
        path: `/services_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).then(() => {
      });
    }
    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 = store.state.menuList;
      let paramsData = reactive({
        params: {
          categoryid: 0,
          pageNum: 1,
          pageSize: 100,
          order: "sortindex"
        },
        index: "",
        sub: 0
      });
      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_pagination = resolveComponent("pagination");
  const _directive_lazy = resolveDirective("lazy");
  _push(`<div${ssrRenderAttrs(mergeProps({ class: "pageContain" }, _attrs))}><section class="common-bradcrumb-section">`);
  _push(ssrRenderComponent(_component_banner, null, null, _parent));
  _push(`<section class="product-grid-section" style="${ssrRenderStyle([{ "text-align": "center", "position": "absolute", "bottom": "0" }, { "width": "100%" }])}"><ul class="cannot_selected tabs_selected"><!--[-->`);
  ssrRenderList(_ctx.store.state.columnTypes, (item, index2) => {
    _push(`<a class="${ssrRenderClass(item.id == _ctx.store.state.acitveId ? "active" : "")}" style="${ssrRenderStyle({ "width": 1 / _ctx.store.state.columnTypes.length * 100 + "%" })}">${ssrInterpolate(item.categoryName)}</a>`);
  });
  _push(`<!--]--></ul></section></section><section class="product-grid-section container pt-20 pb-60 lazyContainer"><div class="row pt-80 content"><!--[-->`);
  ssrRenderList(_ctx.store.state.pageContent, (item) => {
    _push(`<div class="col-md-4 newItemOne"><div class="oneInnerBox"><div class="img"><img${ssrRenderAttrs(mergeProps({
      alt: "",
      "data-src": item.image
    }, ssrGetDirectiveProps(_ctx, _directive_lazy, item.image)))}></div><a class="line-two">${ssrInterpolate(item.title)}</a><span class="line-two">${ssrInterpolate(item.zhaiyao)}</span></div></div>`);
  });
  _push(`<!--]--></div>`);
  _push(ssrRenderComponent(_component_pagination, {
    data: _ctx.store.state.pagination,
    onPagination: _ctx.handleCurrentChange
  }, null, _parent));
  _push(`</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/services/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
};
