Files
Yi.Admin/Yi.Bbs.Vue3/src/views/shop/components/ShopCard.vue

105 lines
2.4 KiB
Vue
Raw Normal View History

2024-11-03 18:01:47 +08:00
<script setup>
import {computed, ref, watch} from "vue";
2024-11-10 13:41:04 +08:00
import { dayjs } from 'element-plus'
2024-11-03 18:01:47 +08:00
const data=ref({});
const realData=ref({});
const props = defineProps([
"data","realData"
]);
const emit = defineEmits(['clickBuy'])
watch(()=>props.data,(n)=>{
data.value=n;
},{deep:true, immediate: true})
watch(()=>props.realData,(n)=>{
realData.value=n;
},{deep:true, immediate: true})
const clickBuy=async ()=>{
emit('clickBuy',data.value)
}
const isConformToRule=computed(()=>{
if (data.value.isLimit===true)
{
return true;
}
if (realData.value.money>=data.value.needMoney
&&realData.value.value>=data.value.needValue
&&realData.value.points>=data.value.needPoints
&&data.value.stockNumber>0)
{
return true;
}
return false
})
</script>
2024-11-10 13:41:04 +08:00
<template >
<div class="shop-card" >
2024-11-02 19:50:01 +08:00
<el-card shadow="hover">
2024-11-03 18:01:47 +08:00
<template #header>{{data.name}}</template>
2024-11-02 19:50:01 +08:00
<img
2024-11-03 18:01:47 +08:00
:src="data.imageUrl"
2024-11-02 19:50:01 +08:00
style="width: 100%"
alt=""/>
2024-11-10 13:41:04 +08:00
2024-11-02 19:50:01 +08:00
<ul>
2024-11-10 13:41:04 +08:00
<li style="font-size: smaller;color: #7c8188;margin-bottom: 5px">简介{{data.describe}}</li>
2024-11-03 18:01:47 +08:00
<li :class="{'less-li': realData.money<data.needMoney}">所需钱钱{{data.needMoney}}</li>
<li :class="{'less-li': realData.value<data.needValue}">所需价值{{data.needValue}}</li>
<li :class="{'less-li': realData.points<data.needPoints}">所需积分{{data.needPoints}}</li>
2024-11-10 13:41:04 +08:00
<li >到期时间{{dayjs(data.endTime).format("YYYY/MM/DD")}}</li>
2024-11-03 18:01:47 +08:00
<li>限购数量{{data.limitNumber}}</li>
<li>剩余{{data.stockNumber}}</li>
2024-11-02 19:50:01 +08:00
</ul>
<el-divider />
<div class="bottom">
2024-11-03 18:01:47 +08:00
<el-button v-if="!isConformToRule" :disabled="true" type="danger">条件不足</el-button>
<el-button v-else :disabled="data.isLimit" type="success" @click="clickBuy">{{data.isLimit===true?"已申请":"申请购买"}} </el-button>
2024-11-02 19:50:01 +08:00
</div>
</el-card>
2024-11-10 13:41:04 +08:00
</div>
2024-11-02 19:50:01 +08:00
</template>
2024-11-03 18:01:47 +08:00
2024-11-02 19:50:01 +08:00
<style scoped lang="scss">
.bottom
{
display: flex;
justify-content: flex-end;
2024-11-10 13:41:04 +08:00
margin: 10px;
2024-11-02 19:50:01 +08:00
}
2024-11-03 18:01:47 +08:00
.less-li{
color: red;
}
2024-11-10 13:41:04 +08:00
img{
height: 100px;
width: 100%;
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}
.shop-card :deep(.el-card__body) {
padding: 0 2px 0 0!important;
}
.shop-card :deep(.el-card__header)
{
display: flex;
justify-content: center;
padding: 5px;
//color: red;
font-weight: bolder;
}
ul{
padding: 10px;
}
.shop-card :deep(.el-divider)
{
margin: 0;
}
2024-11-02 19:50:01 +08:00
</style>