Browse Source

修改bug

dev
岳鹏龙 12 months ago
parent
commit
a45d8d4149
  1. 20
      src/pages/electionList/info.vue

20
src/pages/electionList/info.vue

@ -3,6 +3,20 @@ import { getVoteDetail } from '@/api/common'
const info = ref<any>({})
function toFixed2(value: any, defaultValue = '0.00') {
//
const number = Number(value);
if (isNaN(number)) {
return defaultValue;
}
// 1.005.toFixed(2) => 1.00
const fixedNumber = Math.round(number * 100) / 100;
// toFixed(2) 1.0005 1.0
return fixedNumber.toFixed(2);
}
onLoad((opt) => {
getVoteDetail({ id: opt?.id }).then((res: any) => {
info.value = res.data
@ -46,21 +60,21 @@ onLoad((opt) => {
<view class="progress">
<view class="flex-center-between progress-text">
<text>同意</text>
<text class="b">{{ v.agree_num }} ({{ v.ageree_percent.toFixed(2) }}%)</text>
<text class="b">{{ v.agree_num }} ({{ toFixed2(v.ageree_percent) }}%)</text>
</view>
<u-line-progress :percentage="v.ageree_percent" height="8rpx" active-color="#2563EB" :show-text="false" />
</view>
<view class="progress">
<view class="flex-center-between progress-text">
<text>反对</text>
<text class="e">{{ v.disagree_num }} ({{ v.giveup_percent.toFixed(2) }}%)</text>
<text class="e">{{ v.disagree_num }} ({{ toFixed2(v.giveup_percent) }}%)</text>
</view>
<u-line-progress :percentage="v.giveup_percent" height="8rpx" active-color="#ef4444" :show-text="false" />
</view>
<view class="progress">
<view class="flex-center-between progress-text">
<text>弃权</text>
<text class="f">{{ v.giveup_num }} ({{ v.giveup_percent.toFixed(2) }}%)</text>
<text class="f">{{ v.giveup_num }} ({{ toFixed2(v.giveup_percent) }}%)</text>
</view>
<u-line-progress :percentage="v.giveup_percent" height="8rpx" active-color="#9CA3AF" :show-text="false" />
</view>

Loading…
Cancel
Save