Pārlūkot izejas kodu

fix: 用 computed + 单 text 解决双 text 拼接不渲染问题

双 <text> + v-if/v-else 在小程序里有兼容问题;再换成内联三元在某些版本
也会被吃掉。
改为 computed 输出完整字符串,单 <text> 渲染,最稳。
Developer 5 dienas atpakaļ
vecāks
revīzija
909eab48f2
1 mainītis faili ar 13 papildinājumiem un 6 dzēšanām
  1. 13 6
      components/pages/nonprofitActivety/index.vue

+ 13 - 6
components/pages/nonprofitActivety/index.vue

@@ -26,8 +26,7 @@
 		</view>
 		</view>
 		<view class="na-bottom adfacjb">
 		<view class="na-bottom adfacjb">
 			<view class="na-bottom-left adf" v-if="item.activeState===0||item.activeState===1">
 			<view class="na-bottom-left adf" v-if="item.activeState===0||item.activeState===1">
-				<text class="na-bottom-status">报名中</text>
-				<text class="na-bottom-count"> · 已报{{ item.recruitmentNow || 0 }}{{ item.recruitmentMax ? '/' + item.recruitmentMax : '' }}人</text>
+				<text class="na-bottom-status">{{ signupText }}</text>
 			</view>
 			</view>
 			<!-- <view class="na-bottom-right" @click.stop="toApply">立即报名</view> -->
 			<!-- <view class="na-bottom-right" @click.stop="toApply">立即报名</view> -->
 		</view>
 		</view>
@@ -35,7 +34,8 @@
 </template>
 </template>
 
 
 <script setup name="nonprofitActivety">
 <script setup name="nonprofitActivety">
-	defineProps({
+	import { ref, computed } from 'vue'
+	const props = defineProps({
 		item:{
 		item:{
 			typeof:Object,
 			typeof:Object,
 			default:null
 			default:null
@@ -45,7 +45,6 @@
 			default:0
 			default:0
 		}
 		}
 	})
 	})
-	import { ref } from 'vue'
 	import { useUserStore } from '@/common/stores/user';
 	import { useUserStore } from '@/common/stores/user';
 	const userStore = useUserStore();
 	const userStore = useUserStore();
 	import { useGlobalShare } from '@/common/composables/useGlobalShare';
 	import { useGlobalShare } from '@/common/composables/useGlobalShare';
@@ -57,14 +56,22 @@
 		2:'进行中',
 		2:'进行中',
 		3:'已结束'
 		3:'已结束'
 	})
 	})
-	
+
+	// 「报名中 · 已报 X 人」或「已报 X/Y 人」
+	const signupText = computed(() => {
+		const it = props.item || {}
+		const now = it.recruitmentNow || 0
+		const max = it.recruitmentMax
+		return `报名中 · 已报${now}${max ? '/' + max : ''}人`
+	})
+
 	const handleDetail = item => {
 	const handleDetail = item => {
 		if(!isLogin()) return
 		if(!isLogin()) return
 		uni.navigateTo({
 		uni.navigateTo({
 			url:'/pagesHome/activityDetail?id='+item.id
 			url:'/pagesHome/activityDetail?id='+item.id
 		})
 		})
 	}
 	}
-	
+
 	const toApply = () => {
 	const toApply = () => {
 		userStore.openLoginModal();
 		userStore.openLoginModal();
 	}
 	}