From 1ce875be27d9011c3944c6b975d9f817947ecdf8 Mon Sep 17 00:00:00 2001 From: wwf <1971391498@qq.com> Date: 星期三, 01 十月 2025 16:22:24 +0800 Subject: [PATCH] 登录、注册 --- entry/src/main/ets/pages/message/MessagePage.ets | 94 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 94 insertions(+), 0 deletions(-) diff --git a/entry/src/main/ets/pages/message/MessagePage.ets b/entry/src/main/ets/pages/message/MessagePage.ets new file mode 100644 index 0000000..af21043 --- /dev/null +++ b/entry/src/main/ets/pages/message/MessagePage.ets @@ -0,0 +1,94 @@ +import { CommonConstantWX } from "../../common/CommonConstantWX" +import { WxUserInfoBase } from "../../data/WxUserInfoBase" + +/* + * Search({placeholder: '璇疯緭鍏ユ偍瑕佹悳绱㈢殑鍐呭',value: 'DeepSeek'}) + .width('90%') + .backgroundColor(Color.White) + .searchButton('鎼滅储') + .onChange((value: string) => { + console.info(`杈撳叆鐨勫唴瀹逛负锛�${value}`) + }) + //鎻愪氦鏂规硶 + .onSubmit((value:string) => { + console.info(`鎻愪氦鐨勫唴瀹逛负锛�${value}`) + }) + * */ +@Entry +@Component +export struct MessagePage { + @State userList:Array<WxUserInfoBase> = CommonConstantWX.mUser + @State searchUser:Array<WxUserInfoBase> = [] + build() { + Column({space: 10}) { + Search({placeholder: '鎼滅储'}) + .backgroundColor(Color.White) + .width('90%') + .borderRadius(5) + .onChange((value: string) =>{ + //姣忔杈撳叆閮借娓呯┖searchUser鏁扮粍 + this.searchUser = [] + let searchCount = 0 + //杩涜閬嶅巻锛屽湪鏁扮粍婧愬ご鏌ユ壘鍜寁alue鐩稿叧鐨勬暟鎹� + for (let index = 0; index < this.userList.length; index++) { + const element = this.userList[index]; + //鍒ゆ柇姣忎竴鏉℃暟鎹槸鍚︽湁鍜孷alue鐩稿叧鐨勫唴瀹� + if (element.name?.indexOf(value) != -1) { + //鎵惧埌鐩稿叧鐨勬暟鎹紝娣诲姞鍒皊earch鏁扮粍褰撲腑锛屽苟涓旀暟鎹姞涓� + searchCount ++ + this.searchUser.push(element) + } + } + //鍒ゆ柇SearchCount鏄惁涓�0 + if (searchCount === 0) { + //琛ㄧず鏌ユ棤姝や汉 + this.searchUser.push({ + id: 999, + name: '鏃犳鐢ㄦ埛', + img:$r('app.media.avatar_icon') + }) + } + + }) + List({space: 20}){ + ForEach(this.searchUser.length === 0 ? this.userList: this.searchUser,(item: WxUserInfoBase) => { + ListItem(){ + userInfoItem({item: item}) + } + }) + } + .height('90%') + .padding({top:10}) + .margin({bottom: 30}) + .backgroundColor(Color.White) + .divider({strokeWidth: 2,color: '#ccc'}) + } + .height('100%') + .width('100%') + .backgroundColor('#ccc') + } +} + +@Component +struct userInfoItem { + @Prop item: WxUserInfoBase + build() { + Row({space: 15}){ + Image(this.item.img) + .width(40) + .height(40) + .objectFit(ImageFit.Cover) + Text(this.item.name) + .fontSize(20) + } + .onClick(() => { + this.getUIContext().getRouter().pushUrl({ + url: 'pages/message/MessageDetailsPage', + params:{ + userInfo: this.item + } + }) + }) + .padding(10) + } +} \ No newline at end of file -- Gitblit v1.8.0