陈剑华

fix: 19347 卡片来源显示规则-来源过长时,不符合省略优先级

@@ -115,24 +115,29 @@ export struct CardSourceInfo { @@ -115,24 +115,29 @@ export struct CardSourceInfo {
115 * 5、0 和空 不显示 115 * 5、0 和空 不显示
116 */ 116 */
117 handlerNum(number: string) { 117 handlerNum(number: string) {
118 - const num = number ?? '0'; 118 + const num = number??'0';
119 if (Number.parseInt(num) <= 9999) { 119 if (Number.parseInt(num) <= 9999) {
120 return Number.parseInt(num).toString() 120 return Number.parseInt(num).toString()
121 } else if (Number.parseInt(num) > 9999 && Number.parseInt(num) <= 99999999) { 121 } else if (Number.parseInt(num) > 9999 && Number.parseInt(num) <= 99999999) {
122 - const num1: string = num.slice(0, -4); // 万  
123 - const num2: string = num.slice(-4, -3); // 千  
124 - return num2 === '0' ? num1 + '万' : num1 + '.' + num2 + '万' 122 + let num1: string = num.slice(0, -4); // 万
  123 + let num2: string = num.slice(-4, -3); // 千
  124 + const num3: string = num.slice(-3, -2); // 百
  125 + if (Math.round(Number(`0.${num3}`)) === 1) num2 = `${Number(num2) + 1}`
  126 + if (Number(num2) === 10) {
  127 + num2 = '0';
  128 + num1 = `${Number(num1) + 1}`
  129 + }
  130 + return num2 === '0' ? num1 +'万' : num1 + '.' + num2 + '万'
125 } else if (Number.parseInt(num) > 99999999) { 131 } else if (Number.parseInt(num) > 99999999) {
126 let num1: string = num.slice(0, -8); // 亿 132 let num1: string = num.slice(0, -8); // 亿
127 let num2: string = num.slice(-8, -7); 133 let num2: string = num.slice(-8, -7);
128 - const num3: string = `0.${num.slice(-7, -6)}`  
129 - if (Math.round(Number(num3)) > Number(num3)) {  
130 - if (`${Number(num2) + 1}`.length === 2) {  
131 - num1 = `${Number(num1) + 1}`  
132 - num2 = '0'  
133 - } 134 + const num3: string = num.slice(-3, -2); // 百
  135 + if (Math.round(Number(`0.${num3}`)) === 1) num2 = `${Number(num2) + 1}`
  136 + if (Number(num2) === 10) {
  137 + num2 = '0';
  138 + num1 = `${Number(num1) + 1}`
134 } 139 }
135 - return num2 === '0' ? num1 + '亿' : num1 + '.' + num2 + '亿' 140 + return num2 === '0' ? num1 +'亿' : num1 + '.' + num2 + '亿'
136 } 141 }
137 return num 142 return num
138 } 143 }
@@ -177,10 +182,10 @@ export struct CardSourceInfo { @@ -177,10 +182,10 @@ export struct CardSourceInfo {
177 } 182 }
178 183
179 getContentSize(textContent: string, fontSize: number ) { 184 getContentSize(textContent: string, fontSize: number ) {
180 - return px2vp(Number(measure.measureTextSize({ 185 + return Number(measure.measureTextSize({
181 textContent, 186 textContent,
182 fontSize 187 fontSize
183 - }).width)) 188 + }).width)
184 } 189 }
185 190
186 calcContentSpace() { 191 calcContentSpace() {
@@ -188,27 +193,25 @@ export struct CardSourceInfo { @@ -188,27 +193,25 @@ export struct CardSourceInfo {
188 193
189 const screenWidth = px2vp(display.getDefaultDisplaySync().width) 194 const screenWidth = px2vp(display.getDefaultDisplaySync().width)
190 let leftSpace = screenWidth; 195 let leftSpace = screenWidth;
191 -  
192 const souceSize = this.getContentSize(this.displayText, 12); 196 const souceSize = this.getContentSize(this.displayText, 12);
193 - const cornerSize = this.getContentSize(this.contentDTO.cornerMark || this.contentDTO.corner, 12);  
194 const dotSize = 11; 197 const dotSize = 11;
195 - const timeSize = this.getContentSize(this.handleTimeStr(), 12);  
196 -  
197 - const commentNum = this.getContentDtoBean()?.interactData?.commentNum  
198 - let commentSize = 0;  
199 - if (commentNum) {  
200 - commentSize = this.getContentSize(`${this.handlerNum(commentNum.toString())}评`, 12);  
201 - }  
202 198
203 if (this.contentDTO.cornerMark || this.contentDTO.corner) { 199 if (this.contentDTO.cornerMark || this.contentDTO.corner) {
  200 + const cornerSize = this.getContentSize(this.contentDTO.cornerMark || this.contentDTO.corner, 12);
204 leftSpace = leftSpace - cornerSize 201 leftSpace = leftSpace - cornerSize
205 } 202 }
206 203
207 if (this.showTime()) { 204 if (this.showTime()) {
  205 + const timeSize = this.getContentSize(this.handleTimeStr(), 12);
208 leftSpace = leftSpace - dotSize - timeSize 206 leftSpace = leftSpace - dotSize - timeSize
209 } 207 }
210 208
211 if (!this.isEllipsisActive) { 209 if (!this.isEllipsisActive) {
  210 + let commentSize = 0;
  211 + const commentNum = this.getContentDtoBean()?.interactData?.commentNum
  212 + if (commentNum) {
  213 + commentSize = this.getContentSize(`${this.handlerNum(commentNum.toString())}评`, 12);
  214 + }
212 leftSpace = leftSpace - dotSize - commentSize 215 leftSpace = leftSpace - dotSize - commentSize
213 } 216 }
214 217