wangliang_wd

feat:优化他人主页,优化无网状态下UI展示

@@ -57,7 +57,6 @@ export struct OtherHomePageBottomCommentComponent { @@ -57,7 +57,6 @@ export struct OtherHomePageBottomCommentComponent {
57 this.curPageNum = 1; 57 this.curPageNum = 1;
58 this.hasMore = true 58 this.hasMore = true
59 this.isGetRequest = false 59 this.isGetRequest = false
60 - this.data_comment.clear()  
61 60
62 if (!this.isLoading){ 61 if (!this.isLoading){
63 this.getNewPageData() 62 this.getNewPageData()
@@ -134,6 +133,8 @@ export struct OtherHomePageBottomCommentComponent { @@ -134,6 +133,8 @@ export struct OtherHomePageBottomCommentComponent {
134 let object = new OtherUserCommentListRequestItem("", 20, this.curPageNum, time, "1", this.curUserId) 133 let object = new OtherUserCommentListRequestItem("", 20, this.curPageNum, time, "1", this.curUserId)
135 134
136 MinePageDatasModel.getOtherCommentListData(object, getContext(this)).then((value) => { 135 MinePageDatasModel.getOtherCommentListData(object, getContext(this)).then((value) => {
  136 + if (this.curPageNum === 1) this.data_comment.clear()
  137 +
137 if (!this.data_comment || value.list.length == 0) { 138 if (!this.data_comment || value.list.length == 0) {
138 this.hasMore = false 139 this.hasMore = false
139 this.isLoading = false 140 this.isLoading = false
@@ -16,10 +16,10 @@ const TAG = "OtherNormalUserHomePage" @@ -16,10 +16,10 @@ const TAG = "OtherNormalUserHomePage"
16 struct OtherNormalUserHomePage { 16 struct OtherNormalUserHomePage {
17 @State params:Record<string, string> = router.getParams() as Record<string, string>; 17 @State params:Record<string, string> = router.getParams() as Record<string, string>;
18 @Watch('change') @State curUserId: string = '-1'; 18 @Watch('change') @State curUserId: string = '-1';
19 - @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0  
20 pageShowTime:number = 0; 19 pageShowTime:number = 0;
21 pageHideTime:number = 0; 20 pageHideTime:number = 0;
22 - 21 + @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
  22 + @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
23 23
24 onPageShow() { 24 onPageShow() {
25 this.curUserId = this.params?.['userId']; 25 this.curUserId = this.params?.['userId'];
@@ -68,7 +68,7 @@ struct OtherNormalUserHomePage { @@ -68,7 +68,7 @@ struct OtherNormalUserHomePage {
68 Stack({ alignContent: Alignment.Top }){ 68 Stack({ alignContent: Alignment.Top }){
69 Image($r('app.media.title_bg')) 69 Image($r('app.media.title_bg'))
70 .width('100%') 70 .width('100%')
71 - .height('355lpx') 71 + .height(`calc(${295 + this.topSafeHeight + 'lpx'})`)
72 .objectFit(ImageFit.Cover) 72 .objectFit(ImageFit.Cover)
73 73
74 Row() 74 Row()
@@ -83,7 +83,7 @@ struct OtherNormalUserHomePage { @@ -83,7 +83,7 @@ struct OtherNormalUserHomePage {
83 Stack({ alignContent: Alignment.Top }){ 83 Stack({ alignContent: Alignment.Top }){
84 this.MineHomeTitleTransparent() 84 this.MineHomeTitleTransparent()
85 this.MineHomeTitleWhite() 85 this.MineHomeTitleWhite()
86 - } 86 + }.margin({top:px2vp(this.topSafeHeight)})
87 87
88 Scroll() { 88 Scroll() {
89 Column() { 89 Column() {
@@ -175,7 +175,7 @@ struct OtherNormalUserHomePage { @@ -175,7 +175,7 @@ struct OtherNormalUserHomePage {
175 this.tileOpacity = persent 175 this.tileOpacity = persent
176 } 176 }
177 }) 177 })
178 - .backgroundColor($r('app.color.color_transparent')) 178 + // .backgroundColor($r('app.color.color_transparent'))
179 .height('184lpx') 179 .height('184lpx')
180 .width('100%') 180 .width('100%')
181 .padding({ left: '6lpx' }) 181 .padding({ left: '6lpx' })
@@ -184,7 +184,7 @@ struct OtherNormalUserHomePage { @@ -184,7 +184,7 @@ struct OtherNormalUserHomePage {
184 if(StringUtils.isNotEmpty(this.desc)){ 184 if(StringUtils.isNotEmpty(this.desc)){
185 Column() { 185 Column() {
186 Row() { 186 Row() {
187 - Text(this.desc) 187 + Text('简介:'+this.desc)
188 .fontSize('27lpx') 188 .fontSize('27lpx')
189 .maxLines(3) 189 .maxLines(3)
190 .textOverflow({ overflow: TextOverflow.Ellipsis }) 190 .textOverflow({ overflow: TextOverflow.Ellipsis })
@@ -2,12 +2,12 @@ import { CommentListItem } from './CommentListItem' @@ -2,12 +2,12 @@ import { CommentListItem } from './CommentListItem'
2 2
3 export class MineCommentListDetailItem{ 3 export class MineCommentListDetailItem{
4 list:CommentListItem[] = [] 4 list:CommentListItem[] = []
5 - 5 + hasNext: number = 1
6 pageNum: number = 0 6 pageNum: number = 0
7 pageSize: number = 20 7 pageSize: number = 20
8 totalCount: number = 0 8 totalCount: number = 0
9 9
10 - constructor(list?:CommentListItem[],pageNum?: number,pageSize?: number,totalCount?: number) { 10 + constructor(list?:CommentListItem[],hasNext?: number,pageNum?: number,pageSize?: number,totalCount?: number) {
11 } 11 }
12 12
13 } 13 }
@@ -59,9 +59,12 @@ struct LoginProtocolWebview { @@ -59,9 +59,12 @@ struct LoginProtocolWebview {
59 .width(24) 59 .width(24)
60 .aspectRatio(1) 60 .aspectRatio(1)
61 .onClick(() => { 61 .onClick(() => {
62 - if(this.webviewController.accessBackward()){  
63 - this.webviewController.backward()  
64 - return 62 + if (this.isConnectNetwork){
  63 + ///无网络状态下 执行webviewController.accessBackward方法 会crash
  64 + if(this.webviewController.accessBackward()){
  65 + this.webviewController.backward()
  66 + return
  67 + }
65 } 68 }
66 router.back(); 69 router.back();
67 }).margin({ left: 16 }) 70 }).margin({ left: 16 })
1 import {InterestsHobbiesModel, InterestsList} from '../viewModel/InterestsHobbiesModel' 1 import {InterestsHobbiesModel, InterestsList} from '../viewModel/InterestsHobbiesModel'
2 import { WDRouterRule } from 'wdRouter'; 2 import { WDRouterRule } from 'wdRouter';
3 import { WDRouterPage } from 'wdRouter'; 3 import { WDRouterPage } from 'wdRouter';
4 -import { SPHelper } from 'wdKit/Index';  
5 -import { SpConstants } from 'wdConstant/Index'; 4 +import { NetworkUtil, SPHelper } from 'wdKit/Index';
  5 +import { SpConstants, ViewType } from 'wdConstant/Index';
6 import { CustomToast} from 'wdKit' 6 import { CustomToast} from 'wdKit'
7 import { ButtonOptions, promptAction, window } from '@kit.ArkUI'; 7 import { ButtonOptions, promptAction, window } from '@kit.ArkUI';
8 import { ParamType, TrackConstants, TrackingContent } from 'wdTracking/Index'; 8 import { ParamType, TrackConstants, TrackingContent } from 'wdTracking/Index';
9 import { ImageKnifeComponent,ScaleType } from '@ohos/imageknife'; 9 import { ImageKnifeComponent,ScaleType } from '@ohos/imageknife';
  10 +import { EmptyComponent, WDViewDefaultType } from 'wdComponent/Index';
10 11
11 @Entry 12 @Entry
12 @Component 13 @Component
@@ -16,7 +17,7 @@ struct LaunchInterestsHobbiesPage { @@ -16,7 +17,7 @@ struct LaunchInterestsHobbiesPage {
16 @State interestsArray: InterestsList[] = [] 17 @State interestsArray: InterestsList[] = []
17 @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 18 @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
18 @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 19 @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
19 - 20 + @State isConnectNetwork : boolean = NetworkUtil.isNetConnected()
20 dialogToast: CustomDialogController = new CustomDialogController({ 21 dialogToast: CustomDialogController = new CustomDialogController({
21 builder: CustomToast({ 22 builder: CustomToast({
22 msg: '请先选择您感兴趣的内容哦', 23 msg: '请先选择您感兴趣的内容哦',
@@ -72,71 +73,81 @@ struct LaunchInterestsHobbiesPage { @@ -72,71 +73,81 @@ struct LaunchInterestsHobbiesPage {
72 .height('35lpx') 73 .height('35lpx')
73 .margin({top:'12lpx'}) 74 .margin({top:'12lpx'})
74 75
75 - Grid( ){  
76 - ForEach(this.interestsArray,(item:InterestsList,index:number)=>{  
77 - GridItem(){  
78 - Stack({alignContent:Alignment.TopStart}){  
79 - ImageKnifeComponent({imageKnifeOption:{loadSrc:item.pic?item.pic:'',mainScaleType:ScaleType.FIT_XY}})  
80 - .width('100%')  
81 - .height('100%')  
82 - .backgroundColor(Color.White)  
83 - .borderRadius(5)  
84 - // Image(item.pic)  
85 - // .width('100%')  
86 - // .height('100%')  
87 - // .backgroundColor(Color.White)  
88 - // .borderRadius(5)  
89 - Stack(){  
90 - Image('') 76 + if(!this.isConnectNetwork){
  77 + EmptyComponent({ emptyType: 1,emptyHeight:"60%" ,retry: () => {
  78 + this.isConnectNetwork = NetworkUtil.isNetConnected()
  79 + }})
  80 + .layoutWeight(1)
  81 + .width('100%')
  82 + }else{
  83 + Grid( ){
  84 + ForEach(this.interestsArray,(item:InterestsList,index:number)=>{
  85 + GridItem(){
  86 + Stack({alignContent:Alignment.TopStart}){
  87 + ImageKnifeComponent({imageKnifeOption:{loadSrc:item.pic?item.pic:'',mainScaleType:ScaleType.FIT_XY}})
91 .width('100%') 88 .width('100%')
92 .height('100%') 89 .height('100%')
93 - .backgroundColor(Color.Black)  
94 - .opacity(item.choose?0.5:0) 90 + .backgroundColor(Color.White)
95 .borderRadius(5) 91 .borderRadius(5)
96 - }  
97 - Stack(){  
98 - Column({}){  
99 - Text(item.name)  
100 - .fontSize(18)  
101 - .fontColor('#FFFFFF')  
102 - .margin({top:'21lpx',left:'19lpx'})  
103 - .width('100%')  
104 - .height('46lpx')  
105 - .fontWeight(FontWeight.Bold)  
106 - Text(item.title)  
107 - .fontSize('23lpx')  
108 - .fontColor('#FFFFFF')  
109 - .margin({top:'2lpx',left:'19lpx'}) 92 + // Image(item.pic)
  93 + // .width('100%')
  94 + // .height('100%')
  95 + // .backgroundColor(Color.White)
  96 + // .borderRadius(5)
  97 + Stack(){
  98 + Image('')
110 .width('100%') 99 .width('100%')
111 - .height('31lpx')  
112 - Image(item.choose ? $r('app.media.interestsSelected') : $r('app.media.interestsSelectNot'))  
113 - .height('32lpx')  
114 - .width('32lpx')  
115 - .margin({top:'80lpx',left:'120lpx'}) 100 + .height('100%')
  101 + .backgroundColor(Color.Black)
  102 + .opacity(item.choose?0.5:0)
  103 + .borderRadius(5)
  104 + }
  105 + Stack(){
  106 + Column({}){
  107 + Text(item.name)
  108 + .fontSize(18)
  109 + .fontColor('#FFFFFF')
  110 + .margin({top:'21lpx',left:'19lpx'})
  111 + .width('100%')
  112 + .height('46lpx')
  113 + .fontWeight(FontWeight.Bold)
  114 + Text(item.title)
  115 + .fontSize('23lpx')
  116 + .fontColor('#FFFFFF')
  117 + .margin({top:'2lpx',left:'19lpx'})
  118 + .width('100%')
  119 + .height('31lpx')
  120 + Image(item.choose ? $r('app.media.interestsSelected') : $r('app.media.interestsSelectNot'))
  121 + .height('32lpx')
  122 + .width('32lpx')
  123 + .margin({top:'80lpx',left:'120lpx'})
  124 +
  125 + }.justifyContent(FlexAlign.Start)
  126 + }
116 127
117 - }.justifyContent(FlexAlign.Start)  
118 } 128 }
119 -  
120 } 129 }
121 - }  
122 - .width('192lpx')  
123 - .height('230lpx')  
124 - .borderRadius('8lpx')  
125 - .onClick(()=>{  
126 - //选择后改变已选择属性  
127 - item.choose = !item.choose  
128 - this.interestsArray.splice(index,1,item)  
129 - this.selectCount = this.interestsArray.filter(item => item.choose).length  
130 - }) 130 + .width('192lpx')
  131 + .height('230lpx')
  132 + .borderRadius('8lpx')
  133 + .onClick(()=>{
  134 + //选择后改变已选择属性
  135 + item.choose = !item.choose
  136 + this.interestsArray.splice(index,1,item)
  137 + this.selectCount = this.interestsArray.filter(item => item.choose).length
  138 + })
131 139
132 - }) 140 + })
  141 + }
  142 + .width('90%')
  143 + .margin({top:'61lpx',bottom:'300lpx'})
  144 + .columnsTemplate('1fr 1fr 1fr')
  145 + .columnsGap('23lpx')
  146 + .rowsGap('23lpx')
  147 + .scrollBar(BarState.Off)
133 } 148 }
134 - .width('90%')  
135 - .margin({top:'61lpx',bottom:'300lpx'})  
136 - .columnsTemplate('1fr 1fr 1fr')  
137 - .columnsGap('23lpx')  
138 - .rowsGap('23lpx')  
139 - .scrollBar(BarState.Off) 149 +
  150 +
140 } 151 }
141 .width('100%') 152 .width('100%')
142 .height('100%') 153 .height('100%')
@@ -110,7 +110,7 @@ export default struct CustomDialogComponent { @@ -110,7 +110,7 @@ export default struct CustomDialogComponent {
110 .margin({top: 1}) 110 .margin({top: 1})
111 } 111 }
112 .width('528lpx') 112 .width('528lpx')
113 - .borderRadius('15') 113 + .borderRadius('10')
114 .backgroundColor(Color.White) 114 .backgroundColor(Color.White)
115 .clip(true) 115 .clip(true)
116 116