hookehuyr

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

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