yangchenggong1_wd

desc:缺省图

@@ -9,12 +9,13 @@ import { EmptyComponent } from '../../view/EmptyComponent'; @@ -9,12 +9,13 @@ import { EmptyComponent } from '../../view/EmptyComponent';
9 const TAG = "AppointmentListUI" 9 const TAG = "AppointmentListUI"
10 10
11 @Component 11 @Component
12 -export struct AppointmentListUI{ 12 +export struct AppointmentListUI {
13 @State data: LazyDataSource<MineAppointmentItem> = new LazyDataSource(); 13 @State data: LazyDataSource<MineAppointmentItem> = new LazyDataSource();
14 - @State count:number = 0;  
15 - @State isLoading:boolean = false  
16 - @State hasMore:boolean = true  
17 - curPageNum:number = 1; 14 + @State count: number = 0;
  15 + @State isLoading: boolean = false
  16 + @State hasMore: boolean = true
  17 + curPageNum: number = 1;
  18 + @State isGetRequest: boolean = false
18 19
19 aboutToAppear() { 20 aboutToAppear() {
20 this.getNewPageData() 21 this.getNewPageData()
@@ -23,37 +24,41 @@ export struct AppointmentListUI{ @@ -23,37 +24,41 @@ export struct AppointmentListUI{
23 build() { 24 build() {
24 Column() { 25 Column() {
25 //标题栏目 26 //标题栏目
26 - CustomTitleUI({titleName:"预约列表"})  
27 - if(this.count == 0){  
28 - EmptyComponent({emptyType:10})  
29 - .height('100%')  
30 - .width('100%')  
31 - }else{ 27 + CustomTitleUI({ titleName: "预约列表" })
  28 + if (this.count == 0) {
  29 + if (this.isGetRequest == true) {
  30 + EmptyComponent({ emptyType: 10 })
  31 + .height('100%')
  32 + .width('100%')
  33 + }
  34 +
  35 + } else {
32 //刷新控件 TODO 36 //刷新控件 TODO
33 //List 37 //List
34 List({ space: '6lpx' }) { 38 List({ space: '6lpx' }) {
35 LazyForEach(this.data, (item: MineAppointmentItem, index: number) => { 39 LazyForEach(this.data, (item: MineAppointmentItem, index: number) => {
36 ListItem() { 40 ListItem() {
37 - AppointmentListChildComponent({item:item}) 41 + AppointmentListChildComponent({ item: item })
38 } 42 }
39 - .onClick(()=>{ 43 + .onClick(() => {
40 //TODO 跳转 44 //TODO 跳转
41 }) 45 })
42 }, (item: MineAppointmentItem, index: number) => index.toString()) 46 }, (item: MineAppointmentItem, index: number) => index.toString())
43 47
44 //没有更多数据 显示提示 48 //没有更多数据 显示提示
45 - if(!this.hasMore){  
46 - ListItem(){ 49 + if (!this.hasMore) {
  50 + ListItem() {
47 ListHasNoMoreDataUI() 51 ListHasNoMoreDataUI()
48 } 52 }
49 } 53 }
50 - }.cachedCount(4) 54 + }
  55 + .cachedCount(4)
51 .scrollBar(BarState.Off) 56 .scrollBar(BarState.Off)
52 - .margin({top:'23lpx',left:'23lpx',right:'23lpx'}) 57 + .margin({ top: '23lpx', left: '23lpx', right: '23lpx' })
53 .layoutWeight(1) 58 .layoutWeight(1)
54 - .onReachEnd(()=>{  
55 - console.log(TAG,"触底了");  
56 - if(!this.isLoading){ 59 + .onReachEnd(() => {
  60 + console.log(TAG, "触底了");
  61 + if (!this.isLoading) {
57 //加载分页数据 62 //加载分页数据
58 this.getNewPageData() 63 this.getNewPageData()
59 } 64 }
@@ -65,70 +70,73 @@ export struct AppointmentListUI{ @@ -65,70 +70,73 @@ export struct AppointmentListUI{
65 .width('100%') 70 .width('100%')
66 } 71 }
67 72
68 - getNewPageData(){ 73 + getNewPageData() {
69 this.isLoading = true 74 this.isLoading = true
70 - if(this.hasMore){  
71 - MinePageDatasModel.getAppointmentListData("20",`${this.curPageNum}`,getContext(this)).then((value)=>{  
72 - if (!this.data || value.list.length == 0){  
73 - this.hasMore = false  
74 - }else{  
75 - value.list.forEach((value)=>{  
76 - let dealTime = this.DealStartTime(value.planStartTime)  
77 - if(dealTime!=null && dealTime.length === 2){  
78 - this.data.push(new MineAppointmentItem(value.imageUrl,value.status,value.title,true,dealTime[0],dealTime[1],value.relType,value.liveId,value.relId))  
79 - }else {  
80 - this.data.push(new MineAppointmentItem(value.imageUrl,value.status,value.title,true,"","",value.relType,value.liveId,value.relId))  
81 - }  
82 - })  
83 - this.data.notifyDataReload()  
84 - this.count = this.data.totalCount()  
85 - if (this.data.totalCount() < value.totalCount) {  
86 - this.curPageNum++  
87 - }else {  
88 - this.hasMore = false 75 + if (this.hasMore) {
  76 + MinePageDatasModel.getAppointmentListData("20", `${this.curPageNum}`, getContext(this)).then((value) => {
  77 + if (!this.data || value.list.length == 0) {
  78 + this.hasMore = false
  79 + } else {
  80 + value.list.forEach((value) => {
  81 + let dealTime = this.DealStartTime(value.planStartTime)
  82 + if (dealTime != null && dealTime.length === 2) {
  83 + this.data.push(new MineAppointmentItem(value.imageUrl, value.status, value.title, true, dealTime[0], dealTime[1], value.relType, value.liveId, value.relId))
  84 + } else {
  85 + this.data.push(new MineAppointmentItem(value.imageUrl, value.status, value.title, true, "", "", value.relType, value.liveId, value.relId))
89 } 86 }
  87 + })
  88 + this.data.notifyDataReload()
  89 + this.count = this.data.totalCount()
  90 + if (this.data.totalCount() < value.totalCount) {
  91 + this.curPageNum++
  92 + } else {
  93 + this.hasMore = false
90 } 94 }
91 - }).catch((err:Error)=>{  
92 - console.log(TAG,JSON.stringify(err))  
93 - }) 95 + }
  96 + this.isGetRequest = true
  97 + this.isLoading = false
  98 + }).catch((err: Error) => {
  99 + console.log(TAG, JSON.stringify(err))
  100 + this.isGetRequest = true
  101 + this.isLoading = false
  102 + })
94 } 103 }
95 - this.isLoading = false  
96 } 104 }
97 105
98 - DealStartTime(planStartTime:string):string[]{  
99 - let dealData:string[] = [] 106 + DealStartTime(planStartTime: string): string[] {
  107 + let dealData: string[] = []
100 108
101 - if(!StringUtils.isNotEmpty(planStartTime)){  
102 - console.log(TAG,"格式有误") 109 + if (!StringUtils.isNotEmpty(planStartTime)) {
  110 + console.log(TAG, "格式有误")
103 return dealData 111 return dealData
104 } 112 }
105 113
106 - if(planStartTime.indexOf(" ") === -1){  
107 - console.log(TAG,"格式有误") 114 + if (planStartTime.indexOf(" ") === -1) {
  115 + console.log(TAG, "格式有误")
108 return dealData 116 return dealData
109 } 117 }
110 let arr = planStartTime.split(" ") 118 let arr = planStartTime.split(" ")
111 - if(arr!=null && StringUtils.isNotEmpty(arr[0])){ //处理年月日 119 + if (arr != null && StringUtils.isNotEmpty(arr[0])) { //处理年月日
112 let time = arr[0].split("-"); 120 let time = arr[0].split("-");
113 - if(time.length === 3){  
114 - let month = time[1].indexOf("0") === 0 ? time[1].substring(1):time[1] 121 + if (time.length === 3) {
  122 + let month = time[1].indexOf("0") === 0 ? time[1].substring(1) : time[1]
115 let day = time[2] 123 let day = time[2]
116 124
117 dealData[0] = `${month}月${day}日` 125 dealData[0] = `${month}月${day}日`
118 - let today = `${new Date().getMonth()+1}月${new Date().getDate()}日`  
119 - if(dealData[0] === today){ 126 + let today = `${new Date().getMonth() + 1}月${new Date().getDate()}日`
  127 + if (dealData[0] === today) {
120 dealData[0] = "今日" 128 dealData[0] = "今日"
121 } 129 }
122 } 130 }
123 } 131 }
124 132
125 - if(arr!=null && StringUtils.isNotEmpty(arr[1])){ //处理时分 133 + if (arr != null && StringUtils.isNotEmpty(arr[1])) { //处理时分
126 let time = arr[1].split(":"); 134 let time = arr[1].split(":");
127 - if(time.length === 3){  
128 - dealData[1] = `${time[0]}:${time[1]}` 135 + if (time.length === 3) {
  136 + dealData[1] = `${time[0]}:${time[1]}`
129 } 137 }
130 } 138 }
131 - console.log(TAG,JSON.stringify(dealData)) 139 + console.log(TAG, JSON.stringify(dealData))
132 return dealData 140 return dealData
133 } 141 }
134 } 142 }
@@ -256,11 +256,13 @@ export struct FollowChildComponent{ @@ -256,11 +256,13 @@ export struct FollowChildComponent{
256 if (value.code === 0 || value.code.toString() === "0") { 256 if (value.code === 0 || value.code.toString() === "0") {
257 this.data.status = this.data.status ==="0"?"1":"0" 257 this.data.status = this.data.status ==="0"?"1":"0"
258 258
259 - if(this.data.status === "1"){  
260 - UserDataLocal.setUserFollowOperation(DateTimeUtils.getTimeStamp()+"")  
261 - }else{  
262 - UserDataLocal.setUserFollowOperation(DateTimeUtils.getTimeStamp()+","+this.data.creatorId)  
263 - } 259 + UserDataLocal.setUserFollowOperation(this.data.creatorId+","+this.data.status)
  260 +
  261 + // if(this.data.status === "1"){
  262 + // UserDataLocal.setUserFollowOperation(DateTimeUtils.getTimeStamp()+"")
  263 + // }else{
  264 + // UserDataLocal.setUserFollowOperation(DateTimeUtils.getTimeStamp()+","+this.data.creatorId)
  265 + // }
264 } 266 }
265 } 267 }
266 }) 268 })
@@ -24,6 +24,7 @@ export struct FollowListDetailUI { @@ -24,6 +24,7 @@ export struct FollowListDetailUI {
24 @State hasMore: boolean = true 24 @State hasMore: boolean = true
25 curPageNum: number = 1; 25 curPageNum: number = 1;
26 preferences: dataPreferences.Preferences | null = null; 26 preferences: dataPreferences.Preferences | null = null;
  27 + @State isGetRequest: boolean = false
27 28
28 aboutToAppear() { 29 aboutToAppear() {
29 this.getNewPageData() 30 this.getNewPageData()
@@ -33,9 +34,12 @@ export struct FollowListDetailUI { @@ -33,9 +34,12 @@ export struct FollowListDetailUI {
33 build() { 34 build() {
34 Column() { 35 Column() {
35 if (this.count === 0) { 36 if (this.count === 0) {
36 - EmptyComponent({emptyType:14})  
37 - .layoutWeight(1)  
38 - .width('100%') 37 + if (this.isGetRequest == true) {
  38 + EmptyComponent({ emptyType: 14 })
  39 + .layoutWeight(1)
  40 + .width('100%')
  41 + }
  42 +
39 } else { 43 } else {
40 List({ space: 3 }) { 44 List({ space: 3 }) {
41 LazyForEach(this.data, (item: FollowListDetailItem, index: number = 0) => { 45 LazyForEach(this.data, (item: FollowListDetailItem, index: number = 0) => {
@@ -47,7 +51,7 @@ export struct FollowListDetailUI { @@ -47,7 +51,7 @@ export struct FollowListDetailUI {
47 }, (item: FollowListDetailItem) => item.creatorId) 51 }, (item: FollowListDetailItem) => item.creatorId)
48 52
49 //没有更多数据 显示提示 53 //没有更多数据 显示提示
50 - if (!this.hasMore) { 54 + if (!this.hasMore && this.count != 0) {
51 ListItem() { 55 ListItem() {
52 ListHasNoMoreDataUI() 56 ListHasNoMoreDataUI()
53 } 57 }
@@ -75,16 +79,17 @@ export struct FollowListDetailUI { @@ -75,16 +79,17 @@ export struct FollowListDetailUI {
75 let observer = (key: string) => { 79 let observer = (key: string) => {
76 if (key == UserDataLocal.USER_FOLLOW_OPERATION) { 80 if (key == UserDataLocal.USER_FOLLOW_OPERATION) {
77 if (this.creatorDirectoryId === -1) { 81 if (this.creatorDirectoryId === -1) {
78 - let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION,"") as string 82 + let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION, "") as string
79 let arr = value.split(',') 83 let arr = value.split(',')
80 - if(arr!=null && arr.length === 2){  
81 - this.data.getDataArray().forEach((element,index) => {  
82 - if (element.creatorId === arr[1]) { 84 + if (arr[1] == "0") {
  85 + this.data.getDataArray().forEach((element, index) => {
  86 + if (element.creatorId === arr[0]) {
83 this.data.deleteItem(index) 87 this.data.deleteItem(index)
  88 + this.count = this.data.size()
84 } 89 }
85 }); 90 });
86 - }else{  
87 - if(!this.isLoading){ 91 + } else {
  92 + if (!this.isLoading) {
88 this.isLoading = true 93 this.isLoading = true
89 this.hasMore = true 94 this.hasMore = true
90 this.curPageNum = 1 95 this.curPageNum = 1
@@ -93,6 +98,16 @@ export struct FollowListDetailUI { @@ -93,6 +98,16 @@ export struct FollowListDetailUI {
93 this.getMyFollowListDetail() 98 this.getMyFollowListDetail()
94 } 99 }
95 } 100 }
  101 + }else{
  102 + let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION, "") as string
  103 + let arr = value.split(',')
  104 + if (arr[1] == "0"){
  105 + this.data.getDataArray().forEach((element, index) => {
  106 + if (element.creatorId === arr[0]) {
  107 + this.data.getData(index).status = "0"
  108 + }
  109 + })
  110 + }
96 } 111 }
97 } 112 }
98 } 113 }
@@ -109,7 +124,7 @@ export struct FollowListDetailUI { @@ -109,7 +124,7 @@ export struct FollowListDetailUI {
109 this.isLoading = false 124 this.isLoading = false
110 } else { 125 } else {
111 value.list.forEach((value) => { 126 value.list.forEach((value) => {
112 - let fansNum:number = value.fansNum 127 + let fansNum: number = value.fansNum
113 let fansNumString = "" 128 let fansNumString = ""
114 if (fansNum > 10000) { 129 if (fansNum > 10000) {
115 let temp = (fansNum / 10000) + "" 130 let temp = (fansNum / 10000) + ""
@@ -123,7 +138,7 @@ export struct FollowListDetailUI { @@ -123,7 +138,7 @@ export struct FollowListDetailUI {
123 } else { 138 } else {
124 fansNumString = fansNum + "" 139 fansNumString = fansNum + ""
125 } 140 }
126 - this.data.push(new FollowListDetailItem(value.attentionHeadPhotoUrl, value.attentionUserName, fansNumString, value.introduction, value.attentionCreatorId, "1", value.attentionUserId, value.attentionUserType, value.attentionUserId, value.mainControl, value.banControl,value.authIcon)) 141 + this.data.push(new FollowListDetailItem(value.attentionHeadPhotoUrl, value.attentionUserName, fansNumString, value.introduction, value.attentionCreatorId, "1", value.attentionUserId, value.attentionUserType, value.attentionUserId, value.mainControl, value.banControl, value.authIcon))
127 }) 142 })
128 this.data.notifyDataReload() 143 this.data.notifyDataReload()
129 this.count = this.data.totalCount() 144 this.count = this.data.totalCount()
@@ -134,12 +149,15 @@ export struct FollowListDetailUI { @@ -134,12 +149,15 @@ export struct FollowListDetailUI {
134 } 149 }
135 } 150 }
136 this.isLoading = false 151 this.isLoading = false
  152 + this.isGetRequest = true
137 }).catch((err: Error) => { 153 }).catch((err: Error) => {
138 console.log(TAG, "请求失败") 154 console.log(TAG, "请求失败")
  155 + this.isGetRequest = true
139 this.isLoading = false 156 this.isLoading = false
140 }) 157 })
141 - }else { 158 + } else {
142 this.isLoading = false 159 this.isLoading = false
  160 + this.isGetRequest = true
143 } 161 }
144 } 162 }
145 163
@@ -161,6 +179,7 @@ export struct FollowListDetailUI { @@ -161,6 +179,7 @@ export struct FollowListDetailUI {
161 }).catch((err: Error) => { 179 }).catch((err: Error) => {
162 console.log(TAG, "请求失败") 180 console.log(TAG, "请求失败")
163 this.isLoading = false 181 this.isLoading = false
  182 + this.isGetRequest = true
164 }) 183 })
165 } 184 }
166 } 185 }
@@ -169,7 +188,7 @@ export struct FollowListDetailUI { @@ -169,7 +188,7 @@ export struct FollowListDetailUI {
169 getFollowListStatus(result: MineFollowListDetailItem) { 188 getFollowListStatus(result: MineFollowListDetailItem) {
170 let data_temp: FollowListDetailItem[] = [] 189 let data_temp: FollowListDetailItem[] = []
171 result.list.forEach((item) => { 190 result.list.forEach((item) => {
172 - data_temp.push(new FollowListDetailItem(item.headPhotoUrl, item.cnUserName, item.cnFansNum, item.introduction, item.creatorId, "0", item.attentionUserId, item.cnUserType, item.cnUserId, item.cnMainControl, -1,item.authIcon)) 191 + data_temp.push(new FollowListDetailItem(item.headPhotoUrl, item.cnUserName, item.cnFansNum, item.introduction, item.creatorId, "0", item.attentionUserId, item.cnUserType, item.cnUserId, item.cnMainControl, -1, item.authIcon))
173 }) 192 })
174 let request = new CreatorDetailRequestItem() 193 let request = new CreatorDetailRequestItem()
175 194
@@ -206,6 +225,7 @@ export struct FollowListDetailUI { @@ -206,6 +225,7 @@ export struct FollowListDetailUI {
206 console.log(TAG, JSON.stringify(err)) 225 console.log(TAG, JSON.stringify(err))
207 this.isLoading = false 226 this.isLoading = false
208 this.count = this.count === -1 ? 0 : this.count 227 this.count = this.count === -1 ? 0 : this.count
  228 + this.isGetRequest = true
209 }) 229 })
210 } 230 }
211 231
@@ -225,7 +245,7 @@ export struct FollowListDetailUI { @@ -225,7 +245,7 @@ export struct FollowListDetailUI {
225 }) 245 })
226 246
227 result.forEach((item) => { 247 result.forEach((item) => {
228 - this.data.push(new FollowListDetailItem(item.headPhotoUrl, item.cnUserName, item.cnFansNum, item.introduction, item.creatorId, item.status, item.attentionUserId, item.cnUserType, item.cnUserId, item.mainControl, item.banControl,item.authIcon)) 248 + this.data.push(new FollowListDetailItem(item.headPhotoUrl, item.cnUserName, item.cnFansNum, item.introduction, item.creatorId, item.status, item.attentionUserId, item.cnUserType, item.cnUserId, item.mainControl, item.banControl, item.authIcon))
229 }) 249 })
230 250
231 this.data.notifyDataReload() 251 this.data.notifyDataReload()
@@ -238,9 +258,11 @@ export struct FollowListDetailUI { @@ -238,9 +258,11 @@ export struct FollowListDetailUI {
238 } 258 }
239 259
240 this.isLoading = false 260 this.isLoading = false
  261 + this.isGetRequest = true
241 }).catch((err: Error) => { 262 }).catch((err: Error) => {
242 console.log(TAG, "请求失败") 263 console.log(TAG, "请求失败")
243 this.isLoading = false 264 this.isLoading = false
  265 + this.isGetRequest = true
244 }) 266 })
245 } 267 }
246 } 268 }
@@ -27,6 +27,7 @@ export struct HomePageBottomComponent{ @@ -27,6 +27,7 @@ export struct HomePageBottomComponent{
27 @State userId:string = ""; 27 @State userId:string = "";
28 @Link commentNum:number 28 @Link commentNum:number
29 preferences: dataPreferences.Preferences | null = null; 29 preferences: dataPreferences.Preferences | null = null;
  30 + @State isGetRequest:boolean = false
30 31
31 aboutToAppear(){ 32 aboutToAppear(){
32 this.getNewPageData() 33 this.getNewPageData()
@@ -39,10 +40,11 @@ export struct HomePageBottomComponent{ @@ -39,10 +40,11 @@ export struct HomePageBottomComponent{
39 if (key == UserDataLocal.USER_FOLLOW_OPERATION) { 40 if (key == UserDataLocal.USER_FOLLOW_OPERATION) {
40 let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION,"") as string 41 let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION,"") as string
41 let arr = value.split(',') 42 let arr = value.split(',')
42 - if(arr!=null && arr.length === 2){ 43 + if(arr[1] == "0"){
43 this.data_follow.getDataArray().forEach((element,index) => { 44 this.data_follow.getDataArray().forEach((element,index) => {
44 - if (element.creatorId === arr[1]) { 45 + if (element.creatorId === arr[0]) {
45 this.data_follow.deleteItem(index) 46 this.data_follow.deleteItem(index)
  47 + this.count = this.data_follow.size()
46 } 48 }
47 }); 49 });
48 }else{ 50 }else{
@@ -62,12 +64,14 @@ export struct HomePageBottomComponent{ @@ -62,12 +64,14 @@ export struct HomePageBottomComponent{
62 64
63 build(){ 65 build(){
64 Column(){ 66 Column(){
65 - Divider().width('100%')  
66 - .height('2lpx')  
67 - .strokeWidth('1lpx')  
68 - .backgroundColor($r('app.color.color_EDEDED')) 67 + if(this.isGetRequest == true){
  68 + Divider().width('100%')
  69 + .height('2lpx')
  70 + .strokeWidth('1lpx')
  71 + .backgroundColor($r('app.color.color_EDEDED'))
  72 + }
69 73
70 - if(this.count === 0){ 74 + if(this.count === 0 ){
71 if(this.style === 1){ 75 if(this.style === 1){
72 Column(){ 76 Column(){
73 Row(){ 77 Row(){
@@ -92,15 +96,19 @@ export struct HomePageBottomComponent{ @@ -92,15 +96,19 @@ export struct HomePageBottomComponent{
92 let params = {'index': "1"} as Record<string, string> 96 let params = {'index': "1"} as Record<string, string>
93 WDRouterRule.jumpWithPage(WDRouterPage.followListPage,params) 97 WDRouterRule.jumpWithPage(WDRouterPage.followListPage,params)
94 }) 98 })
95 -  
96 - EmptyComponent({emptyType:14})  
97 - .layoutWeight(1)  
98 - .width('100%') 99 + if(this.isGetRequest == true){
  100 + EmptyComponent({emptyType:14})
  101 + .layoutWeight(1)
  102 + .width('100%')
  103 + }
99 }.layoutWeight(1) 104 }.layoutWeight(1)
100 .justifyContent(FlexAlign.Start) 105 .justifyContent(FlexAlign.Start)
101 }else{ 106 }else{
102 - ListHasNoMoreDataUI({style:2})  
103 - .layoutWeight(1) 107 + if(this.isGetRequest == true){
  108 + EmptyComponent({emptyType:11})
  109 + .layoutWeight(1)
  110 + .width('100%')
  111 + }
104 } 112 }
105 }else{ 113 }else{
106 if(this.style === 1){ 114 if(this.style === 1){
@@ -244,12 +252,15 @@ export struct HomePageBottomComponent{ @@ -244,12 +252,15 @@ export struct HomePageBottomComponent{
244 } 252 }
245 } 253 }
246 this.isLoading = false 254 this.isLoading = false
  255 + this.isGetRequest = true
247 }).catch((err:Error)=>{ 256 }).catch((err:Error)=>{
248 console.log(TAG,"请求失败") 257 console.log(TAG,"请求失败")
249 this.isLoading = false 258 this.isLoading = false
  259 + this.isGetRequest = true
250 }) 260 })
251 }else{ 261 }else{
252 this.isLoading = false 262 this.isLoading = false
  263 + this.isGetRequest = true
253 } 264 }
254 } 265 }
255 266
@@ -266,17 +277,18 @@ export struct HomePageBottomComponent{ @@ -266,17 +277,18 @@ export struct HomePageBottomComponent{
266 MinePageDatasModel.getMineCommentListData(time,object,getContext(this)).then((value)=>{ 277 MinePageDatasModel.getMineCommentListData(time,object,getContext(this)).then((value)=>{
267 if (!this.data_comment || value.list.length == 0){ 278 if (!this.data_comment || value.list.length == 0){
268 this.hasMore = false 279 this.hasMore = false
  280 + this.isLoading = false
269 }else{ 281 }else{
270 this.getCommentListStatus(value) 282 this.getCommentListStatus(value)
271 } 283 }
272 - this.isLoading = false  
273 - this.commentNum = value.totalCount  
274 }).catch((err:Error)=>{ 284 }).catch((err:Error)=>{
275 console.log(TAG,"请求失败") 285 console.log(TAG,"请求失败")
276 this.isLoading = false 286 this.isLoading = false
  287 + this.isGetRequest = true
277 }) 288 })
278 }else{ 289 }else{
279 this.isLoading = false 290 this.isLoading = false
  291 + this.isGetRequest = true
280 } 292 }
281 } 293 }
282 } 294 }
@@ -329,9 +341,11 @@ export struct HomePageBottomComponent{ @@ -329,9 +341,11 @@ export struct HomePageBottomComponent{
329 } 341 }
330 342
331 this.isLoading = false 343 this.isLoading = false
  344 + this.isGetRequest = true
332 }).catch((err:Error)=>{ 345 }).catch((err:Error)=>{
333 console.log(TAG,"请求失败") 346 console.log(TAG,"请求失败")
334 this.isLoading = false 347 this.isLoading = false
  348 + this.isGetRequest = true
335 }) 349 })
336 } 350 }
337 351
@@ -6,50 +6,61 @@ import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI'; @@ -6,50 +6,61 @@ import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI';
6 import { MineCommentListDetailItem } from '../../../viewmodel/MineCommentListDetailItem'; 6 import { MineCommentListDetailItem } from '../../../viewmodel/MineCommentListDetailItem';
7 import { OtherUserCommentLikeStatusRequestItem } from '../../../viewmodel/OtherUserCommentLikeStatusRequestItem'; 7 import { OtherUserCommentLikeStatusRequestItem } from '../../../viewmodel/OtherUserCommentLikeStatusRequestItem';
8 import { ChildCommentComponent } from './ChildCommentComponent'; 8 import { ChildCommentComponent } from './ChildCommentComponent';
  9 +import { EmptyComponent } from '../../view/EmptyComponent';
9 10
10 const TAG = "HomePageBottomComponent" 11 const TAG = "HomePageBottomComponent"
  12 +
11 @Component 13 @Component
12 -export struct OtherHomePageBottomCommentComponent{ 14 +export struct OtherHomePageBottomCommentComponent {
13 @Prop curUserId: string 15 @Prop curUserId: string
14 @State data_comment: LazyDataSource<CommentListItem> = new LazyDataSource(); 16 @State data_comment: LazyDataSource<CommentListItem> = new LazyDataSource();
15 - @State isLoading:boolean = false  
16 - @State hasMore:boolean = true  
17 - curPageNum:number = 1;  
18 - @State count:number = 0;  
19 - @Prop levelHead:string  
20 - @Link commentNum:number  
21 -  
22 - aboutToAppear(){ 17 + @State isLoading: boolean = false
  18 + @State hasMore: boolean = true
  19 + curPageNum: number = 1;
  20 + @State count: number = 0;
  21 + @Prop levelHead: string
  22 + @Link commentNum: number
  23 + @State isGetRequest: boolean = false
  24 +
  25 + aboutToAppear() {
23 this.getNewPageData() 26 this.getNewPageData()
24 } 27 }
25 28
26 - build(){  
27 - Column(){ 29 + build() {
  30 + Column() {
28 Divider().width('100%') 31 Divider().width('100%')
29 .height('2lpx') 32 .height('2lpx')
30 .strokeWidth('1lpx') 33 .strokeWidth('1lpx')
31 .backgroundColor($r('app.color.color_EDEDED')) 34 .backgroundColor($r('app.color.color_EDEDED'))
32 35
33 - if(this.count === 0){  
34 - ListHasNoMoreDataUI({style:2})  
35 - .height('100%')  
36 - }else{ 36 + if (this.count === 0) {
  37 + if (this.isGetRequest == true) {
  38 + EmptyComponent({emptyType:11})
  39 + .height('100%')
  40 + .layoutWeight(1)
  41 + }
  42 + } else {
37 List({ space: 3 }) { 43 List({ space: 3 }) {
38 LazyForEach(this.data_comment, (item: CommentListItem, index: number = 0) => { 44 LazyForEach(this.data_comment, (item: CommentListItem, index: number = 0) => {
39 ListItem() { 45 ListItem() {
40 - ChildCommentComponent({data: item,levelHead:this.levelHead,isLastItem:index===this.data_comment.totalCount()-1}) 46 + ChildCommentComponent({
  47 + data: item,
  48 + levelHead: this.levelHead,
  49 + isLastItem: index === this.data_comment.totalCount() - 1
  50 + })
41 } 51 }
42 .onClick(() => { 52 .onClick(() => {
43 }) 53 })
44 }, (item: CommentListItem, index: number) => index.toString()) 54 }, (item: CommentListItem, index: number) => index.toString())
45 55
46 //没有更多数据 显示提示 56 //没有更多数据 显示提示
47 - if(!this.hasMore){  
48 - ListItem(){ 57 + if (!this.hasMore) {
  58 + ListItem() {
49 ListHasNoMoreDataUI() 59 ListHasNoMoreDataUI()
50 } 60 }
51 } 61 }
52 - }.cachedCount(15) 62 + }
  63 + .cachedCount(15)
53 .layoutWeight(1) 64 .layoutWeight(1)
54 .scrollBar(BarState.Off) 65 .scrollBar(BarState.Off)
55 .edgeEffect(EdgeEffect.None) 66 .edgeEffect(EdgeEffect.None)
@@ -57,9 +68,9 @@ export struct OtherHomePageBottomCommentComponent{ @@ -57,9 +68,9 @@ export struct OtherHomePageBottomCommentComponent{
57 scrollForward: NestedScrollMode.PARENT_FIRST, 68 scrollForward: NestedScrollMode.PARENT_FIRST,
58 scrollBackward: NestedScrollMode.SELF_FIRST 69 scrollBackward: NestedScrollMode.SELF_FIRST
59 }) 70 })
60 - .onReachEnd(()=>{  
61 - console.log(TAG,"触底了");  
62 - if(!this.isLoading){ 71 + .onReachEnd(() => {
  72 + console.log(TAG, "触底了");
  73 + if (!this.isLoading) {
63 this.isLoading = true 74 this.isLoading = true
64 //加载分页数据 75 //加载分页数据
65 this.getNewPageData() 76 this.getNewPageData()
@@ -72,7 +83,6 @@ export struct OtherHomePageBottomCommentComponent{ @@ -72,7 +83,6 @@ export struct OtherHomePageBottomCommentComponent{
72 .justifyContent(FlexAlign.Start) 83 .justifyContent(FlexAlign.Start)
73 } 84 }
74 85
75 -  
76 @Styles 86 @Styles
77 listStyle() { 87 listStyle() {
78 .backgroundColor(Color.White) 88 .backgroundColor(Color.White)
@@ -81,60 +91,64 @@ export struct OtherHomePageBottomCommentComponent{ @@ -81,60 +91,64 @@ export struct OtherHomePageBottomCommentComponent{
81 .borderRadius(12) 91 .borderRadius(12)
82 } 92 }
83 93
84 - getNewPageData(){ 94 + getNewPageData() {
85 this.isLoading = true 95 this.isLoading = true
86 - if(this.hasMore){ 96 + if (this.hasMore) {
87 let time = encodeURI(DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN)) 97 let time = encodeURI(DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN))
88 - let object = new OtherUserCommentListRequestItem("",20,this.curPageNum,time,"1",this.curUserId) 98 + let object = new OtherUserCommentListRequestItem("", 20, this.curPageNum, time, "1", this.curUserId)
89 99
90 - MinePageDatasModel.getOtherCommentListData(object,getContext(this)).then((value)=>{  
91 - if (!this.data_comment || value.list.length == 0){ 100 + MinePageDatasModel.getOtherCommentListData(object, getContext(this)).then((value) => {
  101 + if (!this.data_comment || value.list.length == 0) {
92 this.hasMore = false 102 this.hasMore = false
93 this.isLoading = false 103 this.isLoading = false
94 - }else{ 104 + } else {
95 this.getCommentListStatus(value) 105 this.getCommentListStatus(value)
96 } 106 }
97 - }).catch((err:Error)=>{  
98 - console.log(TAG,"请求失败") 107 + }).catch((err: Error) => {
  108 + console.log(TAG, "请求失败")
99 this.isLoading = false 109 this.isLoading = false
  110 + this.isGetRequest = true
100 }) 111 })
  112 + } else {
  113 + this.isGetRequest = true
  114 + this.isLoading = false
101 } 115 }
102 } 116 }
103 117
104 - getCommentListStatus(value:MineCommentListDetailItem){ 118 + getCommentListStatus(value: MineCommentListDetailItem) {
105 119
106 let status = new OtherUserCommentLikeStatusRequestItem() 120 let status = new OtherUserCommentLikeStatusRequestItem()
107 - let data : CommentListItem[] = []  
108 - value.list.forEach((item)=>{  
109 - if(item.checkStatus === 2){ 121 + let data: CommentListItem[] = []
  122 + value.list.forEach((item) => {
  123 + if (item.checkStatus === 2) {
110 status.commentIdList.push(item.id) 124 status.commentIdList.push(item.id)
111 } 125 }
112 let commentContent = item.commentContent 126 let commentContent = item.commentContent
113 - if(item.sensitiveShow === 0 && item.sensitiveExist === 1){ 127 + if (item.sensitiveShow === 0 && item.sensitiveExist === 1) {
114 commentContent = item.commentContentSensitive 128 commentContent = item.commentContentSensitive
115 } 129 }
116 let parentCommentContent = "" 130 let parentCommentContent = ""
117 - if(item.parentCommentVo!=null ){ 131 + if (item.parentCommentVo != null) {
118 parentCommentContent = item.parentCommentVo.commentContent 132 parentCommentContent = item.parentCommentVo.commentContent
119 } 133 }
120 let parentCommentUserName = "" 134 let parentCommentUserName = ""
121 - if(item.parentCommentVo!=null ){ 135 + if (item.parentCommentVo != null) {
122 parentCommentUserName = item.parentCommentVo.fromUserName 136 parentCommentUserName = item.parentCommentVo.fromUserName
123 } 137 }
124 - data.push(new CommentListItem(item.fromUserHeader,item.fromUserName,item.targetTitle,item.createTime,commentContent,item.likeNum,0,item.id,item.targetId,item.targetType,item.targetRelId,item.targetRelObjectId,item.targetRelType,item.targetStatus,item.checkStatus,parentCommentContent,parentCommentUserName)) 138 + data.push(new CommentListItem(item.fromUserHeader, item.fromUserName, item.targetTitle, item.createTime, commentContent, item.likeNum, 0, item.id, item.targetId, item.targetType, item.targetRelId, item.targetRelObjectId, item.targetRelType, item.targetStatus, item.checkStatus, parentCommentContent, parentCommentUserName))
125 }) 139 })
126 140
127 - MinePageDatasModel.getOtherUserCommentLikeStatusData(status,getContext(this)).then((newValue)=>{  
128 - newValue.forEach((item)=>{  
129 - data.forEach((list)=>{ 141 + MinePageDatasModel.getOtherUserCommentLikeStatusData(status, getContext(this)).then((newValue) => {
  142 + newValue.forEach((item) => {
  143 + data.forEach((list) => {
130 if (item.commentId == list.id) { 144 if (item.commentId == list.id) {
131 list.like_status = item.status 145 list.like_status = item.status
132 } 146 }
133 }) 147 })
134 }) 148 })
135 149
136 - data.forEach((item)=>{  
137 - this.data_comment.push(new CommentListItem(item.fromUserHeader,item.fromUserName,item.targetTitle,item.createTime,item.commentContent,item.likeNum,item.like_status,item.id,item.targetId,item.targetType,item.targetRelId,item.targetRelObjectId,item.targetRelType,item.targetStatus,item.checkStatus,item.parentCommentContent,item.parentCommentUserName)) 150 + data.forEach((item) => {
  151 + this.data_comment.push(new CommentListItem(item.fromUserHeader, item.fromUserName, item.targetTitle, item.createTime, item.commentContent, item.likeNum, item.like_status, item.id, item.targetId, item.targetType, item.targetRelId, item.targetRelObjectId, item.targetRelType, item.targetStatus, item.checkStatus, item.parentCommentContent, item.parentCommentUserName))
138 }) 152 })
139 153
140 this.data_comment.notifyDataReload() 154 this.data_comment.notifyDataReload()
@@ -143,14 +157,16 @@ export struct OtherHomePageBottomCommentComponent{ @@ -143,14 +157,16 @@ export struct OtherHomePageBottomCommentComponent{
143 this.commentNum = value.totalCount 157 this.commentNum = value.totalCount
144 if (this.data_comment.totalCount() < value.totalCount) { 158 if (this.data_comment.totalCount() < value.totalCount) {
145 this.curPageNum++ 159 this.curPageNum++
146 - }else { 160 + } else {
147 this.hasMore = false 161 this.hasMore = false
148 } 162 }
149 163
150 this.isLoading = false 164 this.isLoading = false
151 - }).catch((err:Error)=>{  
152 - console.log(TAG,"请求失败") 165 + this.isGetRequest = true
  166 + }).catch((err: Error) => {
  167 + console.log(TAG, "请求失败")
153 this.isLoading = false 168 this.isLoading = false
  169 + this.isGetRequest = true
154 }) 170 })
155 } 171 }
156 } 172 }
@@ -17,6 +17,7 @@ export struct OtherHomePageBottomFollowComponent{ @@ -17,6 +17,7 @@ export struct OtherHomePageBottomFollowComponent{
17 curPageNum:number = 1; 17 curPageNum:number = 1;
18 @State count:number = 0; 18 @State count:number = 0;
19 @Prop curUserId: string 19 @Prop curUserId: string
  20 + @State isGetRequest:boolean = false
20 21
21 22
22 aboutToAppear(){ 23 aboutToAppear(){
@@ -54,10 +55,11 @@ export struct OtherHomePageBottomFollowComponent{ @@ -54,10 +55,11 @@ export struct OtherHomePageBottomFollowComponent{
54 let params = {'index': "1"} as Record<string, string> 55 let params = {'index': "1"} as Record<string, string>
55 WDRouterRule.jumpWithPage(WDRouterPage.followListPage,params) 56 WDRouterRule.jumpWithPage(WDRouterPage.followListPage,params)
56 }) 57 })
57 -  
58 - EmptyComponent({emptyType:14})  
59 - .layoutWeight(1)  
60 - .width('100%') 58 + if(this.isGetRequest == true){
  59 + EmptyComponent({emptyType:14})
  60 + .layoutWeight(1)
  61 + .width('100%')
  62 + }
61 }.layoutWeight(1) 63 }.layoutWeight(1)
62 .justifyContent(FlexAlign.Start) 64 .justifyContent(FlexAlign.Start)
63 }else{ 65 }else{
@@ -155,10 +157,15 @@ export struct OtherHomePageBottomFollowComponent{ @@ -155,10 +157,15 @@ export struct OtherHomePageBottomFollowComponent{
155 } 157 }
156 } 158 }
157 this.isLoading = false 159 this.isLoading = false
  160 + this.isGetRequest = true
158 }).catch((err:Error)=>{ 161 }).catch((err:Error)=>{
159 console.log(TAG,"请求失败") 162 console.log(TAG,"请求失败")
160 this.isLoading = false 163 this.isLoading = false
  164 + this.isGetRequest = true
161 }) 165 })
  166 + }else{
  167 + this.isGetRequest = true
  168 + this.isLoading = false
162 } 169 }
163 } 170 }
164 } 171 }
@@ -63,8 +63,4 @@ export struct SearchRelatedComponent { @@ -63,8 +63,4 @@ export struct SearchRelatedComponent {
63 .padding({ left: '31lpx', right: '31lpx' }) 63 .padding({ left: '31lpx', right: '31lpx' })
64 } 64 }
65 65
66 - test(){  
67 - let c = "12121212121"  
68 -  
69 - }  
70 } 66 }