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
陈剑华
2024-09-21 16:30:53 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
745d3c74d385b7846385be0bcac2b0d6bc79bcf0
745d3c74
1 parent
361a7394
fix: 19347 卡片来源显示规则-来源过长时,不符合省略优先级
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
21 deletions
sight_harmony/features/wdComponent/src/main/ets/components/cardCommon/CardSourceInfo.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardCommon/CardSourceInfo.ets
View file @
745d3c7
...
...
@@ -115,24 +115,29 @@ export struct CardSourceInfo {
* 5、0 和空 不显示
*/
handlerNum(number: string) {
const num = number
??
'0';
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 + '万'
let num1: string = num.slice(0, -4); // 万
let num2: string = num.slice(-4, -3); // 千
const num3: string = num.slice(-3, -2); // 百
if (Math.round(Number(`0.${num3}`)) === 1) num2 = `${Number(num2) + 1}`
if (Number(num2) === 10) {
num2 = '0';
num1 = `${Number(num1) + 1}`
}
return num2 === '0' ? num1 +'万' : num1 + '.' + num2 + '万'
} else if (Number.parseInt(num) > 99999999) {
let num1: string = num.slice(0, -8); // 亿
let num2: string = num.slice(-8, -7);
const num3: string = `0.${num.slice(-7, -6)}`
if (Math.round(Number(num3)) > Number(num3)) {
if (`${Number(num2) + 1}`.length === 2) {
const num3: string = num.slice(-3, -2); // 百
if (Math.round(Number(`0.${num3}`)) === 1) num2 = `${Number(num2) + 1}`
if (Number(num2) === 10) {
num2 = '0';
num1 = `${Number(num1) + 1}`
num2 = '0'
}
}
return num2 === '0' ? num1 +
'亿' : num1 + '.' + num2 + '亿'
return num2 === '0' ? num1 +'亿' : num1 + '.' + num2 + '亿'
}
return num
}
...
...
@@ -177,10 +182,10 @@ export struct CardSourceInfo {
}
getContentSize(textContent: string, fontSize: number ) {
return
px2vp(
Number(measure.measureTextSize({
return Number(measure.measureTextSize({
textContent,
fontSize
}).width)
)
}).width)
}
calcContentSpace() {
...
...
@@ -188,27 +193,25 @@ export struct CardSourceInfo {
const screenWidth = px2vp(display.getDefaultDisplaySync().width)
let leftSpace = screenWidth;
const souceSize = this.getContentSize(this.displayText, 12);
const cornerSize = this.getContentSize(this.contentDTO.cornerMark || this.contentDTO.corner, 12);
const dotSize = 11;
const timeSize = this.getContentSize(this.handleTimeStr(), 12);
const commentNum = this.getContentDtoBean()?.interactData?.commentNum
let commentSize = 0;
if (commentNum) {
commentSize = this.getContentSize(`${this.handlerNum(commentNum.toString())}评`, 12);
}
if (this.contentDTO.cornerMark || this.contentDTO.corner) {
const cornerSize = this.getContentSize(this.contentDTO.cornerMark || this.contentDTO.corner, 12);
leftSpace = leftSpace - cornerSize
}
if (this.showTime()) {
const timeSize = this.getContentSize(this.handleTimeStr(), 12);
leftSpace = leftSpace - dotSize - timeSize
}
if (!this.isEllipsisActive) {
let commentSize = 0;
const commentNum = this.getContentDtoBean()?.interactData?.commentNum
if (commentNum) {
commentSize = this.getContentSize(`${this.handlerNum(commentNum.toString())}评`, 12);
}
leftSpace = leftSpace - dotSize - commentSize
}
...
...
Please
register
or
login
to post a comment