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.
87 lines
3.1 KiB
87 lines
3.1 KiB
<template>
|
|
<div class="text-center flex flex-col items-center pb-10">
|
|
<h2 class="text-3xl font-bold tracking-tight text-gray-900 dark:text-white sm:text-4xl lg:text-5xl">
|
|
{{ title }}
|
|
</h2>
|
|
<div class="sub-title">
|
|
<p class="text-gray-500 dark:text-gray-400 py-3">
|
|
{{ comments }}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div class="md:w-screen-xl m-auto relative md:flex md:p-0 p-4">
|
|
<el-row :gutter="24" class="flex">
|
|
<template v-for="(item,index) in list" :key="index">
|
|
<el-col :span="6" :xs="24" class="mb-5 min-w-xs">
|
|
<el-card shadow="hover" :body-style="{ padding: '0px' }" class="hover:bg-gray-50 cursor-pointer">
|
|
<el-image
|
|
:src="`https://oss.wsdns.cn/20240925/e5e47100f4b6471395b3b81f834d2902.jpg?x-oss-process=image/resize,m_fixed,w_750/quality,Q_90`"
|
|
fit="fill" :lazy="true" class="w-full md:h-[150px] h-[199px] cursor-pointer"/>
|
|
<div class="flex-1 px-4 py-5 sm:p-6 !p-4">
|
|
<p class="text-gray-700 dark:text-white text-base font-semibold flex flex-col gap-1.5">
|
|
<div class="flex-1 text-xl cursor-pointer">{{ item.title }}</div>
|
|
<div class="text-red-500">¥{{ item.price }}</div>
|
|
</p>
|
|
<p v-if="item.price > 0" class="flex items-center gap-1.5 py-2 text-gray-500 justify-between">
|
|
<div class="text-gray-500">{{ item.comments }}</div>
|
|
</p>
|
|
<div class="button-group flex justify-center mt-3">
|
|
<el-button class="w-full" :icon="ElIconView" @click="openSpmUrl('/item', item,item.goodsId,true)">
|
|
查看详情
|
|
</el-button>
|
|
<el-button type="primary" v-if="item.price > 0" class="w-full" :icon="ElIconShoppingCart">购买
|
|
</el-button>
|
|
<el-button v-else class="w-full" :icon="ElIconShoppingCart">下载</el-button>
|
|
</div>
|
|
</div>
|
|
</el-card>
|
|
</el-col>
|
|
</template>
|
|
</el-row>
|
|
</div>
|
|
<div v-if="disabled" class="px-1 text-center text-gray-500 min-h-xs">
|
|
没有更多了
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import {openSpmUrl} from "~/utils/common";
|
|
import dayjs from "dayjs";
|
|
import {useServerRequest} from "~/composables/useServerRequest";
|
|
import type {ApiResult, PageResult} from "~/api";
|
|
import type {Product} from "~/api/oa/product/model";
|
|
|
|
const props = withDefaults(
|
|
defineProps<{
|
|
disabled?: boolean;
|
|
title?: string;
|
|
comments?: string;
|
|
}>(),
|
|
{
|
|
title: '卡片标题',
|
|
comments: '卡片描述'
|
|
}
|
|
);
|
|
|
|
const emit = defineEmits<{
|
|
(e: 'done'): void;
|
|
}>();
|
|
|
|
const runtimeConfig = useRuntimeConfig();
|
|
const list = ref<Product[]>([]);
|
|
|
|
// 请求数据
|
|
const reload = async () => {
|
|
const {data: response} = await useServerRequest<ApiResult<PageResult<Product>>>('/cms/cms-product/page', {
|
|
baseURL: runtimeConfig.public.apiServer, params: {
|
|
limit: 8
|
|
}
|
|
})
|
|
if (response.value?.data) {
|
|
if (response.value?.data.list) {
|
|
list.value = response.value?.data.list;
|
|
}
|
|
}
|
|
}
|
|
reload();
|
|
</script>
|