wangliang_wd

feat:优化H5界面布局,优化点赞

@@ -24,6 +24,13 @@ export struct WdWebComponent { @@ -24,6 +24,13 @@ export struct WdWebComponent {
24 @Link isPageEnd: boolean 24 @Link isPageEnd: boolean
25 @State subjectData : string = '' 25 @State subjectData : string = ''
26 26
  27 + @StorageProp('currentBreakpoint') @Watch("currentChanged")currentBreakpoint: string = 'sm';
  28 +
  29 + currentChanged(){
  30 + ///折叠屏转换
  31 + this.webviewControl.refresh()
  32 + }
  33 +
27 build() { 34 build() {
28 Column() { 35 Column() {
29 Web({ src: this.webUrl, controller: this.webviewControl }) 36 Web({ src: this.webUrl, controller: this.webviewControl })
@@ -61,22 +61,20 @@ export struct H5NewsWebPageComponent { @@ -61,22 +61,20 @@ export struct H5NewsWebPageComponent {
61 private navTitle = '人民日报'; 61 private navTitle = '人民日报';
62 62
63 build() { 63 build() {
64 - Column() {  
65 - Blank().height(`${this.topSafeHeight}px`)  
66 - //标题栏目  
67 - CustomTitleUI({ titleName: this.navTitle })  
68 - Stack({ alignContent: Alignment.Bottom }) {  
69 - Column() { 64 + Stack({ alignContent: Alignment.Top }){
  65 + Stack(){
  66 + Column(){
  67 + CustomTitleUI({ titleName: this.navTitle })
70 WdWebComponent({ 68 WdWebComponent({
71 webviewControl: this.webviewControl, 69 webviewControl: this.webviewControl,
72 webUrl: this.webUrl, 70 webUrl: this.webUrl,
73 isPageEnd: $isPageEnd 71 isPageEnd: $isPageEnd
74 }) 72 })
75 - }  
76 - .width(CommonConstants.FULL_WIDTH)  
77 - .height(CommonConstants.FULL_HEIGHT)  
78 - .padding({ bottom: 150}) 73 + }.width(CommonConstants.FULL_WIDTH)
  74 + .height(`calc(85% - ${ this.topSafeHeight + 'px'})`)
  75 + }
79 76
  77 + Stack(){
80 //底部交互区 78 //底部交互区
81 OperRowListView({ 79 OperRowListView({
82 contentDetailData: this.contentDetailData, 80 contentDetailData: this.contentDetailData,
@@ -87,21 +85,15 @@ export struct H5NewsWebPageComponent { @@ -87,21 +85,15 @@ export struct H5NewsWebPageComponent {
87 this.showCommentList = true 85 this.showCommentList = true
88 } 86 }
89 }) 87 })
  88 + }
  89 + .alignContent(Alignment.Top)
  90 + .position({y:'85%'})
90 .width(CommonConstants.FULL_WIDTH) 91 .width(CommonConstants.FULL_WIDTH)
91 .backgroundColor(Color.White) 92 .backgroundColor(Color.White)
92 .height(150) 93 .height(150)
93 94
94 - //全部评论  
95 - CommentDialogView({  
96 - index: $index,  
97 - currentIndex: $currentIndex,  
98 - showCommentList: $showCommentList,  
99 - publishCommentModel: $publishCommentModel,  
100 - interactData: $interactData,  
101 - }).visibility(this.showComment ? Visibility.Visible : Visibility.Hidden)  
102 - }  
103 -  
104 } 95 }
  96 + .margin({top: `${this.topSafeHeight}px`, bottom: `${this.bottomSafeHeight}px`})
105 .width(CommonConstants.FULL_WIDTH) 97 .width(CommonConstants.FULL_WIDTH)
106 .height(CommonConstants.FULL_HEIGHT) 98 .height(CommonConstants.FULL_HEIGHT)
107 } 99 }
@@ -99,6 +99,9 @@ export struct LikeComponent { @@ -99,6 +99,9 @@ export struct LikeComponent {
99 } else if (this.componentType == 5) { 99 } else if (this.componentType == 5) {
100 // 图集点赞,展示标识 100 // 图集点赞,展示标识
101 this.likeCompStyle5() 101 this.likeCompStyle5()
  102 + }else if (this.componentType == 6) {
  103 + // H5
  104 + this.likeCompStyle6()
102 } else { 105 } else {
103 //1: 底部栏目样式 默认样式 106 //1: 底部栏目样式 默认样式
104 this.likeCompStyle1() 107 this.likeCompStyle1()
@@ -342,6 +345,58 @@ export struct LikeComponent { @@ -342,6 +345,58 @@ export struct LikeComponent {
342 345
343 } 346 }
344 347
  348 +
  349 + @Builder
  350 + likeCompStyle6() {
  351 + //1:H5 底部栏目样式 默认样式
  352 + Stack({ alignContent: Alignment.Bottom }) {
  353 + Image(this.transLikeStyle().url)
  354 + .width(24)
  355 + .height(24)
  356 + if (this.likeCount > 0){
  357 + RelativeContainer() {
  358 + Image(this.likeStatus ? $r('app.media.ic_like_white_Select') : $r('app.media.ic_like_back'))
  359 + .objectFit(ImageFit.Fill)
  360 + .resizable({
  361 + slice: {
  362 + top: 1,
  363 + left: 20,
  364 + right: 1,
  365 + bottom: 1
  366 + }
  367 + })
  368 + .alignRules({
  369 + top: { anchor: "Text", align: VerticalAlign.Top },
  370 + left: { anchor: "Text", align: HorizontalAlign.Start },
  371 + right: { anchor: "Text", align: HorizontalAlign.End },
  372 + bottom: { anchor: "Text", align: VerticalAlign.Bottom },
  373 + })
  374 + .id("Image")
  375 +
  376 + Text(NumberFormatterUtils.formatNumberWithWan(this.likeCount || ''))// Text("44444444")
  377 + .fontSize(8)
  378 + .fontColor('#ffffff')// .backgroundColor('#ED2800')
  379 + .height(12)
  380 + .textAlign(TextAlign.Center)
  381 + .alignRules({
  382 + top: { anchor: "__container__", align: VerticalAlign.Top },
  383 + left: { anchor: "__container__", align: HorizontalAlign.Start }
  384 + })/*动态计算文字宽度*/
  385 + .width(this.getMeasureText(NumberFormatterUtils.formatNumberWithWan(this.likeCount || '')) +
  386 + 12)// .backgroundColor(Color.Green)
  387 + .id("Text")
  388 + .visibility(this.likeCount > 0 ? Visibility.Visible : Visibility.Hidden)
  389 + }
  390 + .offset({
  391 + x: 12
  392 + })
  393 + }
  394 + }.width(24).height(24).onClick(() => {
  395 + this.clickButtonEvent()
  396 + })
  397 + .visibility(this.likesStyle == 4 || this.likesStyle == 'empty' || !this.openLikes ? Visibility.None : Visibility.Visible)
  398 + }
  399 +
345 async clickButtonEvent() { 400 async clickButtonEvent() {
346 console.log(TAG, '点赞点击') 401 console.log(TAG, '点赞点击')
347 // 未登录,跳转登录 402 // 未登录,跳转登录
@@ -325,7 +325,7 @@ export struct OperRowListView { @@ -325,7 +325,7 @@ export struct OperRowListView {
325 LikeComponent({ 325 LikeComponent({
326 data: this.likeBean, 326 data: this.likeBean,
327 styleType: this.styleType, 327 styleType: this.styleType,
328 - componentType: 5, 328 + componentType: 6,
329 pageComponentType: this.pageComponentType 329 pageComponentType: this.pageComponentType
330 }) 330 })
331 } 331 }