mrr.sj.front/pages/shop/groupBuying/components/listCard.vue

259 lines
6.3 KiB
Vue
Raw Normal View History

2026-03-24 11:45:13 +08:00
<template>
<view class="listCard">
<view class="listCard-content" @click.stop="emitClick">
<view class="listCard-content__title">{{ info.title }}</view>
<view class="listCard-content__group">
<view class="listCard-content__group__text">几人团:</view>
<view class="listCard-content__group__num"
>{{ info.person_num }}人团</view
>
</view>
<view class="listCard-content__group">
<view class="listCard-content__group__text">总开团数:</view>
<view class="listCard-content__group__num">{{ info.team_num }}</view>
</view>
<view class="listCard-content__group">
<view class="listCard-content__group__text">已开团数:</view>
<view class="listCard-content__group__num">{{ info.open_team_num
}}</view>
</view>
<view class="listCard-content__active">
<view class="listCard-content__active__title">活动时间</view>
<view class="listCard-content__active__time">{{ useTime }}</view>
</view>
</view>
<view class="listCard-btn">
<view
class="listCard-btn__button"
@click.stop="emitCancel"
v-if="info.state != 7 && info.state != 3"
>
{{ info.expire_state==1? `失效审核中`:info.expire_state==3? `失效驳回`:`失效` }}
</view>
<view
class="listCard-btn__button"
@click.stop="emitEdit"
v-if="info.state != 7 && info.state != 3 && info.state != 6"
>
编辑
</view>
<view
class="listCard-btn__button"
@click.stop="emitCopy"
v-if="info.state == 7 || info.state == 3"
>
复制活动
</view>
</view>
<view class="listCard-tip">{{ getTip.text }}</view>
</view>
</template>
<script>
export default {
data() {
return {};
},
props: {
info: {
type: Object,
},
},
computed: {
getTip() {
const list = [
{
id: 5,
text: "未开始",
},
{
id: 6,
text: "进行中",
},
{
id: 7,
text: "已结束",
},
{
id: 3,
text: "已失效",
},
{
id: 1,
text: "审核中",
},
{
id: 4,
text: "已驳回",
},
];
const item = list.find((it) => it.id == this.info.state) || {};
return item;
},
useTime() {
const start = this.info.start_time;
const endTime = this.info.end_time;
function formatTimeRange(startTimeStr, endTimeStr) {
// 解析开始时间为Date对象
const startTime = new Date(startTimeStr.replace(/-/g, "/"));
const endTime = new Date(endTimeStr.replace(/-/g, "/"));
if (isNaN(startTime.getTime())) {
throw new Error(
"无效的开始时间格式,请使用类似'2025-08-04 14:00:00'的格式"
);
}
// 格式化单个时间为 MM.DD HH:MM 格式
const formatTime = (date) => {
const year = date.getFullYear(); // 获取四位年份
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
return `${year}.${month}.${day} ${hours}:${minutes}`; // 格式变为 年.月.日 时:分
};
// 格式化开始时间和结束时间并拼接
return `${formatTime(startTime)}${formatTime(endTime)}`;
}
return formatTimeRange(start, endTime);
},
},
methods: {
emitCancel() {
if(this.info.expire_state==1) return;
this.$emit("cancel", this.info);
},
emitEdit() {
this.$emit("edit", this.info);
},
emitCopy() {
let formData = { ...this.info };
delete formData.id;
this.$emit("copy", formData);
},
emitClick(){
this.$emit("check", this.info);
},
},
};
</script>
<style scoped lang="less">
.listCard {
padding: 20rpx;
background-color: #fff;
border-radius: 20rpx;
position: relative;
.listCard-tip {
position: absolute;
right: 0;
top: 0;
padding: 10rpx 18rpx;
background: rgba(252, 67, 124, 0.15);
border-radius: 0rpx 20rpx 0rpx 20rpx;
font-weight: 400;
font-size: 26rpx;
color: #E8101E;
line-height: 37rpx;
text-align: left;
font-style: normal;
}
.listCard-content {
padding-left: 10rpx;
padding-bottom: 24rpx;
border-bottom: 3rpx solid #f6f5f5;
&__title {
font-weight: 500;
font-size: 32rpx;
color: #333333;
line-height: 34rpx;
text-align: left;
font-style: normal;
margin-bottom: 30rpx;
}
&__group {
font-weight: 400;
font-size: 26rpx;
line-height: 37rpx;
text-align: left;
font-style: normal;
display: flex;
flex-wrap: nowrap;
align-items: center;
margin-top: 20rpx;
&__text {
color: #999999;
display: flex;
align-items: center;
margin-right: 16rpx;
}
&__text::before {
content: "";
background-color: #999999;
border-radius: 50%;
display: inline-block;
height: 6rpx;
width: 6rpx;
margin-right: 10rpx;
}
&__num {
color: #333333;
}
}
&__active {
margin-top: 30rpx;
&__title {
font-weight: 400;
font-size: 26rpx;
color: #333333;
line-height: 37rpx;
text-align: left;
font-style: normal;
}
&__time {
margin-top: 11rpx;
font-weight: 500;
font-size: 26rpx;
color: #333333;
line-height: 37rpx;
text-align: left;
font-style: normal;
}
}
}
.listCard-btn {
display: flex;
flex-wrap: nowrap;
justify-content: flex-end;
column-gap: 40rpx;
margin-top: 30rpx;
margin-bottom: 20rpx;
&__button {
display: flex;
align-items: center;
justify-content: center;
width: 160rpx;
height: 64rpx;
border-radius: 64rpx;
display: inline-flex;
border: 2rpx solid #979797;
font-weight: 400;
font-size: 26rpx;
color: #333333;
line-height: 37rpx;
text-align: left;
font-style: normal;
}
}
}
</style>