Showing
1 changed file
with
25 additions
and
1 deletions
| @@ -574,7 +574,7 @@ export struct PaperSingleColumn999CardView { | @@ -574,7 +574,7 @@ export struct PaperSingleColumn999CardView { | ||
| 574 | .fontColor('#B0B0B0') | 574 | .fontColor('#B0B0B0') |
| 575 | .margin({ left: this.item?.source.length > 0?0:16 }) | 575 | .margin({ left: this.item?.source.length > 0?0:16 }) |
| 576 | if (this.item.objectType != '2' && this.interactData && this.interactData.commentNum && Number(this.interactData.commentNum) > 0) { | 576 | if (this.item.objectType != '2' && this.interactData && this.interactData.commentNum && Number(this.interactData.commentNum) > 0) { |
| 577 | - Text(this.interactData.commentNum + "评") | 577 | + Text(this.handlerNum(this.interactData.commentNum.toString()) + "评") |
| 578 | .fontSize(12) | 578 | .fontSize(12) |
| 579 | .fontColor('#B0B0B0') | 579 | .fontColor('#B0B0B0') |
| 580 | .margin({ left: this.getPublishTime().length >0? 6:0 }) | 580 | .margin({ left: this.getPublishTime().length >0? 6:0 }) |
| @@ -671,4 +671,28 @@ export struct PaperSingleColumn999CardView { | @@ -671,4 +671,28 @@ export struct PaperSingleColumn999CardView { | ||
| 671 | } | 671 | } |
| 672 | return contentString; | 672 | return contentString; |
| 673 | } | 673 | } |
| 674 | + | ||
| 675 | + /** | ||
| 676 | + * 全域数字显示规则 | ||
| 677 | + * 1、当数量为千位以內时,显示数字,不保留小数点,比如 4585 | ||
| 678 | + * 2、当数量为万位~1亿时,显示xx 万,保留小数点后一位,比如1517.9w、2.9w | ||
| 679 | + * 3、当数量为1亿~千亿时,显示XX 亿,保留小数点后一位,比如1517.9亿、2.9亿 | ||
| 680 | + * 4、不进行四舍五入 | ||
| 681 | + * 5、0 和空 不显示 | ||
| 682 | + */ | ||
| 683 | + handlerNum(number: string) { | ||
| 684 | + const num = number??'0'; | ||
| 685 | + if (Number.parseInt(num) <= 9999) { | ||
| 686 | + return Number.parseInt(num).toString() | ||
| 687 | + } else if (Number.parseInt(num) > 9999 && Number.parseInt(num) <= 99999999) { | ||
| 688 | + const num1: string = num.slice(0, -4); // 万 | ||
| 689 | + const num2: string = num.slice(-4, -3); // 千 | ||
| 690 | + return num2 === '0' ? num1 +'万' : num1 + '.' + num2 + '万' | ||
| 691 | + } else if (Number.parseInt(num) > 99999999) { | ||
| 692 | + const num1: string = num.slice(0, -8); // 亿 | ||
| 693 | + const num2: string = num.slice(-8, -7); | ||
| 694 | + return num2 === '0' ? num1 +'亿' : num1 + '.' + num2 + '亿' | ||
| 695 | + } | ||
| 696 | + return num | ||
| 697 | + } | ||
| 674 | } | 698 | } |
-
Please register or login to post a comment