yangchenggong1_wd

fix:bug[16758] 【uat】搜索输入框不应展示搜索图标,叉号和安卓不一致。

@@ -39,6 +39,11 @@ export struct SearchComponent { @@ -39,6 +39,11 @@ export struct SearchComponent {
39 SearcherAboutDataModel.searchHistoryData = [] 39 SearcherAboutDataModel.searchHistoryData = []
40 //获取搜索历史 40 //获取搜索历史
41 this.getSearchHistoryData() 41 this.getSearchHistoryData()
  42 +
  43 + let intervalID = setInterval(() => {
  44 + sendEventByKey("searchId", 10, "")
  45 + clearInterval(intervalID);
  46 + }, 1000);
42 } 47 }
43 48
44 getRelatedSearchContent() { 49 getRelatedSearchContent() {
@@ -56,12 +61,18 @@ export struct SearchComponent { @@ -56,12 +61,18 @@ export struct SearchComponent {
56 while (tempValue.indexOf(this.searchText) != -1){ 61 while (tempValue.indexOf(this.searchText) != -1){
57 let index = tempValue.indexOf(this.searchText) 62 let index = tempValue.indexOf(this.searchText)
58 if(index === 0){ 63 if(index === 0){
59 - tempArr.push(this.searchText)  
60 - tempValue = tempValue.substring(this.searchText.length,tempValue.length) 64 + try {
  65 + tempArr.push(this.searchText)
  66 + tempValue = tempValue.substring(this.searchText.length,tempValue.length)
  67 + } catch (e) {
  68 + }
61 }else { 69 }else {
62 - tempArr.push(tempValue.substring(0,index))  
63 - tempArr.push(this.searchText)  
64 - tempValue = tempValue.substring(index+this.searchText.length,tempValue.length) 70 + try {
  71 + tempArr.push(tempValue.substring(0,index))
  72 + tempArr.push(this.searchText)
  73 + tempValue = tempValue.substring(index+this.searchText.length,tempValue.length)
  74 + } catch (e) {
  75 + }
65 } 76 }
66 } 77 }
67 if(StringUtils.isNotEmpty(tempValue)){ 78 if(StringUtils.isNotEmpty(tempValue)){
@@ -218,7 +229,7 @@ export struct SearchComponent { @@ -218,7 +229,7 @@ export struct SearchComponent {
218 .textAlign(TextAlign.Start) 229 .textAlign(TextAlign.Start)
219 .maxLines(1) 230 .maxLines(1)
220 .textOverflow({ overflow: TextOverflow.Clip }) 231 .textOverflow({ overflow: TextOverflow.Clip })
221 - .margin({ left: '70lpx' }) 232 + .margin({ left: '40lpx' })
222 }) 233 })
223 } 234 }
224 .loop(true) 235 .loop(true)
@@ -238,7 +249,15 @@ export struct SearchComponent { @@ -238,7 +249,15 @@ export struct SearchComponent {
238 .height('69lpx') 249 .height('69lpx')
239 .backgroundColor($r('app.color.color_transparent')) 250 .backgroundColor($r('app.color.color_transparent'))
240 .textFont({ size: "27lpx", weight: "400lpx" }) 251 .textFont({ size: "27lpx", weight: "400lpx" })
241 - .defaultFocus(true) 252 + // .defaultFocus(true)
  253 + .id("searchId")
  254 + .focusable(true)
  255 + .searchIcon({
  256 + size:0
  257 + })
  258 + .cancelButton({
  259 + style:CancelButtonStyle.INVISIBLE
  260 + })
242 .caretStyle({color:Color.Pink}) 261 .caretStyle({color:Color.Pink})
243 .onSubmit((value: string) => { 262 .onSubmit((value: string) => {
244 if(StringUtils.isNotEmpty(this.searchText)){ 263 if(StringUtils.isNotEmpty(this.searchText)){
@@ -278,9 +297,20 @@ export struct SearchComponent { @@ -278,9 +297,20 @@ export struct SearchComponent {
278 } 297 }
279 } 298 }
280 }) 299 })
281 -  
282 - }.padding({right:'30lpx'}) 300 + }.padding({right:'70lpx'})
283 .layoutWeight(1) 301 .layoutWeight(1)
  302 +
  303 + Image($r('app.media.search_input_del_icon'))
  304 + .width("31lpx")
  305 + .height("31lpx")
  306 + .objectFit(ImageFit.Auto)
  307 + .interpolation(ImageInterpolation.Medium)
  308 + .margin({left:"495lpx"})
  309 + .onClick(()=>{
  310 + this.searchText = ""
  311 + })
  312 + .visibility(StringUtils.isEmpty(this.searchText) ? Visibility.Hidden : Visibility.Visible)
  313 +
284 } 314 }
285 .backgroundImage($r('app.media.search_page_input_bg')) 315 .backgroundImage($r('app.media.search_page_input_bg'))
286 .backgroundImageSize(ImageSize.Cover) 316 .backgroundImageSize(ImageSize.Cover)