hookehuyr

fix: 修复免费课程价格显示问题

为免费课程添加条件判断,当价格为0.00时显示"免费"而非价格
<!--
* @Date: 2025-03-20 20:36:36
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-04-29 14:12:16
* @LastEditTime: 2025-09-24 22:59:47
* @FilePath: /mlaj/src/components/ui/CourseCard.vue
* @Description: 文件描述
-->
......@@ -20,7 +20,10 @@
<div class="text-gray-500 text-xs">{{ course.subtitle }}</div>
</div>
<div class="flex justify-between items-end mt-1">
<div class="text-orange-500 font-semibold">¥{{ course.price }}</div>
<div v-if="course?.price !== '0.00'" class="text-orange-500 font-semibold">¥{{ course.price }}</div>
<div v-else class="text-orange-500 text-xs font-semibold">
免费
</div>
<div class="text-gray-400 text-xs">
{{ course.buy_count }}人订阅
</div>
......
......@@ -16,7 +16,10 @@
<h1 class="text-2xl text-white font-bold mb-1">{{ course?.title }}</h1>
<h2 class="text-lg text-white/90">{{ course?.subtitle }}</h2>
<div class="mt-4 flex justify-between items-center">
<div class="text-orange-300 font-bold text-2xl">¥{{ course?.price }}</div>
<div v-if="course?.price !== '0.00'" class="text-orange-300 font-bold text-2xl">¥{{ course?.price }}</div>
<div v-else class="text-orange-300 text-sm">
免费
</div>
<div class="bg-orange-500/30 text-orange-100 text-xs px-3 py-1 rounded-full">
限时优惠
</div>
......@@ -233,8 +236,8 @@
</div>
<div class="flex items-center">
<div v-if="!course?.is_buy" class="mr-2">
<div class="text-red-500 font-bold">¥{{ course?.price || 0 }}</div>
<div class="text-xs text-gray-400 line-through">
<div v-if="course?.price !== '0.00'" class="text-red-500 font-bold">¥{{ course?.price || 0 }}</div>
<div v-if="course?.price !== '0.00'" class="text-xs text-gray-400 line-through">
¥{{ Math.round((course?.price || 0) * 1.2) }}
</div>
</div>
......
......@@ -14,7 +14,8 @@
<!-- 标题和价格区域 -->
<div class="flex items-start justify-between gap-3 mb-2">
<h1 class="text-black text-xl font-bold flex-1 min-w-0">{{ course?.title }}</h1>
<div class="text-orange-500 font-bold text-xl flex-shrink-0">¥{{ course?.price || '0' }}</div>
<div v-if="course?.price !== '0.00'" class="text-orange-500 font-bold text-xl flex-shrink-0">¥{{ course?.price || '0' }}</div>
<div v-else class="text-orange-500 text-base font-semibold"> 免费 </div>
</div>
<div class="flex items-center text-gray-500 text-sm">
<span>已更新 {{ course?.count }} 期</span>
......