Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
wangliang_wd
2024-05-16 13:40:28 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3703e2f2ea4b50ce20fb0253caa1041971863c4e
3703e2f2
1 parent
65ae6f5b
feat:优化互动消息
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
101 additions
and
45 deletions
sight_harmony/features/wdComponent/src/main/ets/components/InteractMessage/InteractMComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/InteractMessagePage.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/MyCollectionListPage.ets
sight_harmony/features/wdComponent/src/main/ets/components/InteractMessage/InteractMComponent.ets
View file @
3703e2f
import { ContentDTO } from 'wdBean/Index';
import { ProcessUtils } from 'wdRouter/Index';
import { InteractMessageModel } from '../../model/InteractMessageModel'
import { DateTimeUtils} from 'wdKit/Index'
@Component
export struct InteractMComponent {
messageModel:InteractMessageModel = new InteractMessageModel;
...
...
@@ -15,6 +15,7 @@ export struct InteractMComponent {
build() {
Row(){
Image(this.messageModel.InteractMsubM.headUrl)
.alt($r('app.media.default_head'))
.width(36)
.height(36)
.borderRadius(18)
...
...
@@ -29,7 +30,7 @@ export struct InteractMComponent {
.margin({left:5})
}.width('100%')
Text(this.
messageModel.time
)
Text(this.
getPublishTime(this.messageModel.time,DateTimeUtils.getDateTimestamp(this.messageModel.time)+"")
)
.margin({top:2})
.fontSize('12fp').fontColor('#B0B0B0').margin({top:10,bottom:10})
...
...
@@ -41,42 +42,44 @@ export struct InteractMComponent {
.constraintSize({maxHeight:500})
}
Column(){
if (this.messageModel.contentType === '207' || this.messageModel.contentType === '209'){
Text('[你的评论]'+this.buildCommentContent()).fontSize('14fp').fontColor('#666666').constraintSize({maxHeight:500})
.margin({top:15,bottom:10})
.width('100%')
if(this.messageModel.contentType != '211' && this.messageModel.contentType != '210'){
Column(){
if (this.messageModel.contentType === '207' || this.messageModel.contentType === '209'){
Text('[你的评论]'+this.buildCommentContent()).fontSize('14fp').fontColor('#666666').constraintSize({maxHeight:500})
.margin({top:15,bottom:10})
.width('100%')
Divider()
.color('#EDEDED')
.backgroundColor('#EDEDED')
.width('100%')
.height(1)
}
Row(){
Image($r('app.media.MessageOriginTextIcon'))
.width('12')
.height('12')
Text(this.messageModel.InteractMsubM.contentTitle)
.fontSize('12fp')
.fontColor('#666666')
.maxLines(1)
.width('90%')
.textOverflow({overflow:TextOverflow.Ellipsis})
Divider()
.color('#EDEDED')
.backgroundColor('#EDEDED')
.width('100%')
.height(1)
}
Row(){
Image($r('app.media.MessageOriginTextIcon'))
.width('12')
.height('12')
Text(this.messageModel.InteractMsubM.contentTitle)
.fontSize('12fp')
.fontColor('#666666')
.maxLines(1)
.width('90%')
.textOverflow({overflow:TextOverflow.Ellipsis})
Blank()
Blank()
Image($r('app.media.mine_user_edit'))
.width('12')
.height('12')
}.margin({top:10,bottom:15})
}.padding({left:10,right:10}).alignItems(HorizontalAlign.Start).backgroundColor('#f5f5f5').borderRadius(5)
.onClick(()=>{
let contentDTO :ContentDTO = new ContentDTO();
contentDTO.objectType = this.messageModel.InteractMsubM.contentType
contentDTO.objectId = this.messageModel.InteractMsubM.contentId
ProcessUtils.processPage(contentDTO)
})
Image($r('app.media.mine_user_edit'))
.width('12')
.height('12')
}.margin({top:10,bottom:15})
}.padding({left:10,right:10}).alignItems(HorizontalAlign.Start).backgroundColor('#f5f5f5').borderRadius(5)
.onClick(()=>{
let contentDTO :ContentDTO = new ContentDTO();
contentDTO.objectType = this.messageModel.InteractMsubM.contentType
contentDTO.objectId = this.messageModel.InteractMsubM.contentId
ProcessUtils.processPage(contentDTO)
})
}
}.padding({left:5,right:5}).alignItems(HorizontalAlign.Start).width('90%')
}.padding({top:10,left:16,right:16}).width('100%').alignItems(VerticalAlign.Top)
}
...
...
@@ -102,4 +105,49 @@ export struct InteractMComponent {
let contentString : string = this.messageModel.contentType === '207'?this.messageModel.message:this.messageModel.InteractMsubM.beReply;
return contentString;
}
getPublishTime(data:string,publishTime: string): string {
const publishTimestamp = parseInt(publishTime)
const currentTime = Date.now(); // 当前时间戳
// 计算差异
const timeDifference = currentTime - publishTimestamp;
// 转换为分钟、小时和天
const minutes = Math.floor(timeDifference / (1000 * 60));
const hours = Math.floor(timeDifference / (1000 * 60 * 60));
const days = Math.floor(timeDifference / (1000 * 60 * 60 * 24));
// 根据时间差返回对应的字符串
let result: string;
if (minutes < 60) {
result = `${minutes}分钟前`;
if (minutes === 0) {
result = `刚刚`;
}
} else if (hours < 24) {
result = `${hours}小时前`;
} else {
result = `${days}天前`;
if (days > 1) {
let arr = data.split(" ")
if (arr.length === 2) {
let arr2 = arr[0].split("-")
if (arr2.length === 3) {
result = `${arr2[1]}-${arr2[2]}`
}
} else {
//原始数据是时间戳 需要转成dateString
let time = DateTimeUtils.formatDate(Number(publishTime))
let arr = time.split("-")
if (arr.length === 3) {
result = `${arr[1]}-${arr[2]}`
}
}
}
}
console.log(result);
return result
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/InteractMessagePage.ets
View file @
3703e2f
...
...
@@ -31,21 +31,26 @@ struct InteractMessagePage {
if(this.browSingModel.viewType == ViewType.ERROR){
EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NetworkFailed})
}else if(this.browSingModel.viewType == ViewType.EMPTY){
EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_No
History
})
EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_No
Message
})
}else {
CustomPullToRefresh({
alldata:this.allDatas,
scroller:this.scroller,
hasMore:this.browSingModel.hasMore,
customList:()=>{
this.ListLayout()
},
onRefresh:(resolve)=>{
this.
browSingModel.currentPage = 0
this.
currentPage = 1
this.getData(resolve)
},
onLoadMore:(resolve)=> {
this.browSingModel.currentPage++
this.getData()
if (this.browSingModel.hasMore === false) {
if(resolve) resolve('')
return
}
this.currentPage++
this.getData(resolve)
}
})
}
...
...
@@ -75,6 +80,7 @@ struct InteractMessagePage {
}
}
}
.scrollBar(BarState.Off)
.height(CommonConstants.FULL_PARENT)
.edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
}
...
...
@@ -120,17 +126,18 @@ struct InteractMessagePage {
for (let index = 0; index < InteractMessageMItem.list.length; index++) {
const element = InteractMessageMItem.list[index];
element.InteractMsubM = JSON.parse(element.remark)
this.allDatas.push(element)
}
this.allDatas.push(...InteractMessageMItem.list)
if (InteractMessageMItem.list.length === this.browSingModel.pageSize) {
this.browSingModel.currentPage++;
this.browSingModel.hasMore = true;
} else {
if (InteractMessageMItem.hasNext === 0) {
this.browSingModel.hasMore = false;
} else {
this.browSingModel.hasMore = true;
}
} else {
this.browSingModel.viewType = ViewType.EMPTY;
if (this.currentPage === 1) {
this.browSingModel.viewType = ViewType.EMPTY;
}
}
})
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/MyCollectionListPage.ets
View file @
3703e2f
...
...
@@ -114,6 +114,7 @@ struct MyCollectionListPage {
if (this.browSingModel.hasMore === false) NoMoreLayout()
}
}
.scrollBar(BarState.Off)
.height(CommonConstants.FULL_PARENT)
.edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
}
...
...
Please
register
or
login
to post a comment