Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
wangliang_wd
2024-06-19 10:40:26 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d858828d4c7767220ffd32e4835a590adf16a766
d858828d
1 parent
980f878b
feat:优化早晚报评论显示
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
1 deletions
sight_harmony/features/wdComponent/src/main/ets/components/page/CardView.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/CardView.ets
View file @
d858828
...
...
@@ -574,7 +574,7 @@ export struct PaperSingleColumn999CardView {
.fontColor('#B0B0B0')
.margin({ left: this.item?.source.length > 0?0:16 })
if (this.item.objectType != '2' && this.interactData && this.interactData.commentNum && Number(this.interactData.commentNum) > 0) {
Text(this.
interactData.commentNum
+ "评")
Text(this.
handlerNum(this.interactData.commentNum.toString())
+ "评")
.fontSize(12)
.fontColor('#B0B0B0')
.margin({ left: this.getPublishTime().length >0? 6:0 })
...
...
@@ -671,4 +671,28 @@ export struct PaperSingleColumn999CardView {
}
return contentString;
}
/**
* 全域数字显示规则
* 1、当数量为千位以內时,显示数字,不保留小数点,比如 4585
* 2、当数量为万位~1亿时,显示xx 万,保留小数点后一位,比如1517.9w、2.9w
* 3、当数量为1亿~千亿时,显示XX 亿,保留小数点后一位,比如1517.9亿、2.9亿
* 4、不进行四舍五入
* 5、0 和空 不显示
*/
handlerNum(number: string) {
const num = number??'0';
if (Number.parseInt(num) <= 9999) {
return Number.parseInt(num).toString()
} else if (Number.parseInt(num) > 9999 && Number.parseInt(num) <= 99999999) {
const num1: string = num.slice(0, -4); // 万
const num2: string = num.slice(-4, -3); // 千
return num2 === '0' ? num1 +'万' : num1 + '.' + num2 + '万'
} else if (Number.parseInt(num) > 99999999) {
const num1: string = num.slice(0, -8); // 亿
const num2: string = num.slice(-8, -7);
return num2 === '0' ? num1 +'亿' : num1 + '.' + num2 + '亿'
}
return num
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment