<template>
  <div class="custom-product-detail">
    <ModuleCard
      :label="parent_title"
      :list="ProductList.list"
      @change="onChange"
    ></ModuleCard>
    <CustomLoading v-show="loading"></CustomLoading>
  </div>
</template>

<script lang="ts" setup>
import { useRoute } from 'vue-router';
import { onMounted, reactive, ref } from 'vue';
import { show_message } from '@/utils/tdesign_tool';
import ModuleCard from '@/components/modulecard.vue';
import { getScenesList } from '@/utils/api/scenes';
import CustomLoading from '@/components/custom/loading2.vue';
import { JumpDetailPage } from '@/constants/router';
// 会带一个id
const route = useRoute();
const params_id = route.query.id;
const loading = ref(false);
// 产品大标题
const parent_title = ref('');
// 产品列表
const ProductList = reactive({
  list: [],
});
// 跳转
const onChange = (item: any) => {
  JumpDetailPage(item);
};
// 获取当前分类所有产品
const getallproduct = async () => {
  try {
    if (typeof params_id == 'undefined') {
      show_message('没有类目id');
      return;
    }
    loading.value = true;
    let res: any = await getScenesList(params_id, 'parent');
    if (res.code == 0) {
      parent_title.value = res.data[0].parent_title;
      ProductList.list = res.data;
    }
    console.log(res);
    loading.value = false;
  } catch (e) {
    console.log(e);
    loading.value = false;
  }
};
onMounted(() => {
  // 获取数据
  getallproduct();
});
</script>

<style lang="less">
.custom-product-detail {
  box-sizing: border-box;
  height: 100%;
  position: relative;
  .custom-recommend {
    margin-top: 0;
    padding-top: 30px;
  }
}
</style>
