From 8e1b89c65db438797d2d89c508f3e9883bbd7c20 Mon Sep 17 00:00:00 2001 From: wwf <1971391498@qq.com> Date: 星期四, 09 十月 2025 01:10:42 +0800 Subject: [PATCH] 消息、个人中心 --- entry/src/main/ets/pages/message/MessageDetailsPage.ets | 221 ++++++++++++++++++++++++++---------------------------- 1 files changed, 107 insertions(+), 114 deletions(-) diff --git a/entry/src/main/ets/pages/message/MessageDetailsPage.ets b/entry/src/main/ets/pages/message/MessageDetailsPage.ets index 69dbc17..a2ea405 100644 --- a/entry/src/main/ets/pages/message/MessageDetailsPage.ets +++ b/entry/src/main/ets/pages/message/MessageDetailsPage.ets @@ -1,131 +1,124 @@ -import { CommonConstantWX } from '../../common/CommonConstantWX' -import { WxMessageBase } from '../../data/WxMessageBase' -import { WxUserInfoBase } from '../../data/WxUserInfoBase' -import { TitleUtils } from '../../utils/TitleUtils' +import { router } from '@kit.ArkUI' -/** - * @ProjectName : HealthNS - * @FileName : MessageDetailsPage - * @UserName : 淇ⅵ - * @Time : 2025/9/14 16:35 - * @Description : 鏂囦欢鎻忚堪 - */ +class Message { + avatar: string | Resource = '' + content: string = '' + isMe: boolean = false +} + @Entry @Component struct MessageDetailsPage { - @State msgData: Array<WxMessageBase> = CommonConstantWX.mUserMessage - @State mContent:string = '' - private mScroller: Scroller = new Scroller() - @State mUserInfo: WxUserInfoBase = new WxMessageBase() + @State messageList: Message[] = [ + { avatar: '', content: '璇峰彂涓�涓嬩綘鐨勭畝鍘嗙粰鎴戙��', isMe: false }, + { avatar: '', content: '杩欎釜宀椾綅鎴戝崄鍒嗘劅鍏磋叮锛岃鐪嬩竴涓嬫垜鐨勭畝鍘嗭紝鎴戣寰楁垜鍙互鑳滀换杩欎釜宀椾綅', isMe: true }, + + ] aboutToAppear(): void { - let params = this.getUIContext().getRouter().getParams() as Record<string,WxUserInfoBase> - this.mUserInfo = params.userInfo + } build() { - RelativeContainer(){ - TitleUtils({titleName:this.mUserInfo.name}) - .id('heard') - List({space: 15,scroller:this.mScroller}){ - ForEach(this.msgData,(item: WxMessageBase) => { - ListItem(){ - MessageDetailsItem({item: item,icon: this.mUserInfo.img}) - } - }) - } - .id('list') - .alignRules({ - top:{anchor: 'heard',align: VerticalAlign.Bottom}, - bottom: {anchor: 'rowBottom',align: VerticalAlign.Top} - }) - .padding(10) - Row({space: 5}){ - Image($r('app.media.wx_voice_icon')).MessageImageSty() - TextArea({text: this.mContent}) - .backgroundColor(Color.White) - .borderRadius(5) - .width('70%') - .offset({y: 5}) - .onChange((value: string) => { - this.mContent = value + Column() { + Row() { + Image($r('app.media.left_icon')) + .width(20) + .height(20) + .onClick(() => { + router.back() }) - Image($r('app.media.wx_smile_icon')).MessageImageSty() - if (this.mContent.trim().length === 0 || !this.mContent){ - Image($r('app.media.wx_more_icon')).MessageImageSty() - } else { - Button(){ - Text('鍙戦��') - .fontSize(15) - .fontColor(Color.White) - } - .padding(5) - //鍙戦�佹暟鎹紝娣诲姞鍒颁簡鑱婂ぉ鍒楄〃 - .onClick(() =>{ - this.msgData.push({ - id: 99, - content: this.mContent, - img: $r('app.media.avatar_icon1'), - category: 1 - }) - this.mContent = '' - //婊氬姩鍒板簳閮� - this.mScroller.scrollToIndex(this.msgData.length - 1) - }) + Column() { + Text('鏉庡コ澹�') + .fontSize(16) + .fontWeight(700) + Text('鎽╃背绉诲姩绉戞妧') + .fontSize(12) + .fontColor('#666666') + .margin({ top: 4 }) } + Row() } .width('100%') - .alignItems(VerticalAlign.Bottom) .padding(10) - .backgroundColor("#ffe9e6e6") - .id('rowBottom') - .alignRules({ - bottom: {anchor: '__container__',align: VerticalAlign.Bottom} - }) + .justifyContent(FlexAlign.SpaceBetween) + .backgroundColor('#fff') + + Column() { + List({ space: 20, initialIndex: 0 }){ + ForEach(this.messageList, (item: Message) => { + ListItem() { + if (item.isMe) { + Row({ space: 10 }) { + Text(item.content) + .fontSize(14) + .fontColor(Color.White) + .fontWeight(500) + .backgroundColor('#1761f4') + .padding(10) + .borderRadius({ topLeft: 12, topRight: 12, bottomLeft: 12 }) + .constraintSize({ maxWidth: 250 }) + Image($r('app.media.me_icon')) + .width(32) + .height(32) + } + .width('100%') + .justifyContent(FlexAlign.End) + .alignItems(VerticalAlign.Bottom) + } else { + Row({ space: 10 }) { + Image($r('app.media.avatar')) + .width(32) + .height(32) + Text(item.content) + .fontSize(14) + .fontColor(Color.Black) + .fontWeight(500) + .backgroundColor('#FFF') + .padding(10) + .borderRadius({ topLeft: 12, topRight: 12, bottomRight: 12 }) + .constraintSize({ maxWidth: 250 }) + } + .width('100%') + .alignItems(VerticalAlign.Bottom) + .justifyContent(FlexAlign.Start) + } + } + }) + } + .listDirection(Axis.Vertical) // 鎺掑垪鏂瑰悜 + .scrollBar(BarState.Off) + .friction(0.6) + .edgeEffect(EdgeEffect.Spring) + .width('100%') + } + .padding(16) + .width('100%') + .height(600) + + Row({ space: 8 }) { + Image($r('app.media.audio_icon')) + .width(24) + .height(24) + TextInput() + .width(240) + .placeholderColor('#999999') + .backgroundColor('#f3f7fe') + Image($r('app.media.expression_icon')) + .width(24) + .height(24) + Image($r('app.media.add_icon')) + .width(24) + .height(24) + } + .backgroundColor('#FFF') + .width('100%') + .height(60) + .padding(10) + .alignItems(VerticalAlign.Center) + } .width('100%') .height('100%') - .backgroundColor('#ccc') + .backgroundColor('#f5f5f7') } -} - -@Component -struct MessageDetailsItem { - @Prop item: WxMessageBase - @Prop icon: ResourceStr - build() { - if (this.item.category === 0){ - Row({space:5}){ - Image(this.icon) - .width(40) - .height(40) - Text(this.item.content) - .backgroundColor(Color.White) - .padding(5) - } - .width('78%') - } else { - Row({space:5}){ - Row(){ - Text(this.item.content) - .backgroundColor("#ff3cc12e") - .padding(5) - } - .justifyContent(FlexAlign.End) - .width('78%') - Image($r('app.media.avatar_icon1')) - .width(40) - .height(40) - } - .width('100%') - .justifyContent(FlexAlign.End) - } - - } -} - -@Extend(Image) -function MessageImageSty() { - .width(25) - .height(25) - .objectFit(ImageFit.Fill) -} +} \ No newline at end of file -- Gitblit v1.8.0