基于Java spring + vue3 + nuxt构建的内容管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

103 lines
3.2 KiB

<template>
<PageBanner :layout="layout" />
<el-tabs v-model="activeName" class="md:w-screen-xl m-auto relative sm:flex pb-2" @tab-click="handleClick">
<el-tab-pane label="最新上架" name="happy"></el-tab-pane>
<el-tab-pane label="免费热榜" name="website"></el-tab-pane>
<el-tab-pane label="付费热榜" name="weShop"></el-tab-pane>
<el-tab-pane label="热门总榜" name="cms"></el-tab-pane>
<el-tab-pane label="我的收藏" name="food"></el-tab-pane>
</el-tabs>
<!-- <el-checkbox-group v-model="checkList" class="md:w-screen-xl m-auto relative sm:flex hidden pb-2">-->
<!-- <el-checkbox label="菜单" value="menu" />-->
<!-- <el-checkbox label="插件" value="plug" />-->
<!-- <el-checkbox label="应用" value="app" />-->
<!-- <el-checkbox label="前端" value="" />-->
<!-- </el-checkbox-group>-->
<CardList :list="list" :disabled="disabled" @done="onSearch" />
</template>
<script setup lang="ts">
import type {ApiResult, PageResult} from "~/api";
import {useServerRequest} from "~/composables/useServerRequest";
import {useWebsite} from "~/composables/configState";
import type {Navigation} from "~/api/cms/navigation/model";
import type {CompanyParam} from "~/api/system/company/model";
import CardList from './components/CardList.vue';
import PageBanner from './components/PageBanner.vue';
import type {CmsProduct} from "~/api/cms/cmsProduct/model";
const route = useRoute();
// 页面信息
const runtimeConfig = useRuntimeConfig();
const list = ref<CmsProduct[]>([]);
const page = ref<number>(1);
const resultText = ref('');
const layout = ref<any>();
const disabled = ref<boolean>(false);
const activeName = ref(undefined)
const checkList = ref(['Value selected and disabled', 'Value A'])
// 获取状态
const form = ref<Navigation>();
const website = useWebsite();
// 搜索表单
const where = reactive<CompanyParam>({
keywords: ''
});
const handleClick = (e:any) => {
console.log(e.index)
}
const onSearch = () => {
if(!disabled.value){
page.value++;
reload(route.path);
}
}
// 请求数据
const reload = async (path: string) => {
const {data: response} = await useServerRequest<ApiResult<PageResult<CmsProduct>>>('/cms/cms-product/page',{baseURL: runtimeConfig.public.apiServer, params: {
page: page.value,limit: 8, keywords: where.keywords
}})
if(response.value?.data){
if (list.value.length < response.value?.data.count) {
disabled.value = false;
if (response.value?.data.list) {
list.value = list.value.concat(response.value?.data.list);
}
}else {
disabled.value = true;
}
if(response.value.data.count == 0){
resultText.value = '暂无相关结果'
}
}
}
const { data: nav } = await useServerRequest<ApiResult<Navigation>>('/cms/cms-navigation/getNavigationByPath',{query: {path: route.path}})
if(nav.value?.data){
form.value = nav.value?.data;
}
// 页面布局
if(form.value?.layout){
layout.value = JSON.parse(form.value?.layout)
}
useHead({
title: `市场 - ${website.value.websiteName}`,
bodyAttrs: {
class: "page-container",
}
});
watch(
() => route.path,
(path) => {
reload(path);
},
{ immediate: true }
);
</script>