From 7f2343d38fa048f6ce179ea0ab2c1a04f41a213c Mon Sep 17 00:00:00 2001 From: wwf <1971391498@qq.com> Date: 星期四, 09 十月 2025 18:05:11 +0800 Subject: [PATCH] 功能完善 --- entry/src/main/ets/pages/home/BannerDetail.ets | 83 ++++++++++++++++++++++++++++------------- 1 files changed, 56 insertions(+), 27 deletions(-) diff --git a/entry/src/main/ets/pages/home/BannerDetail.ets b/entry/src/main/ets/pages/home/BannerDetail.ets index 8b2a858..832260e 100644 --- a/entry/src/main/ets/pages/home/BannerDetail.ets +++ b/entry/src/main/ets/pages/home/BannerDetail.ets @@ -1,17 +1,61 @@ -import { router } from "@kit.ArkUI"; +import { promptAction, router } from "@kit.ArkUI"; +import { http } from "@kit.NetworkKit"; +import { HttpResponseResult } from "../../data/HttpResponse"; +import { LvMarkdownIn } from "@luvi/lv-markdown-in" + +class BannerInfo { + pic: string = '' + content: string = '' +} @Entry @Component -export struct BannerDetail { - @State index: number = 0; +struct BannerDetail { + @State bannerId: string = ''; + @State bannerInfo: BannerInfo = { + pic: '', + content: '' + } aboutToAppear(): void { interface Params { - index: number + bannerId: string } const params: Params = router.getParams() as Params if (params) { - this.index = params.index + this.bannerId = params.bannerId + console.log('bannerId', this.bannerId) + this.getDetail() } + + } + + getDetail() { + interface PostData { + bannerId: string, + } + let postData: PostData = { + bannerId: this.bannerId + } + let httpRequest = http.createHttp(); + httpRequest.request( + `http://192.168.20.70:8080/quiz-community/public/v1.0/home/slideshows/details?bannerId=${this.bannerId}`, + { + method: http.RequestMethod.GET, + header: { 'Content-Type': 'application/json', 'x-jwt-token': `Bearer ${AppStorage.get('x-jwt-token')}` }, + }, + (err, data) => { + console.log('response', '/home/slideshows/details') + console.log(JSON.stringify(data.result)) + if (data.responseCode == 200) { + const resData = (typeof data.result == 'string' ? JSON.parse(data.result) : data.result) as HttpResponseResult<BannerInfo> + if (resData.code == 200) { + this.bannerInfo = resData.data as BannerInfo + } else { + promptAction.showToast({ message: resData.msg }) + } + } + } + ) } build() { @@ -20,6 +64,9 @@ Image($r('app.media.left_icon')) .width(20) .height(20) + .onClick(() => { + router.back() + }) Text('璇︽儏椤�') .fontSize(18) .fontWeight(700) @@ -29,31 +76,13 @@ .padding(10) .justifyContent(FlexAlign.SpaceBetween) - Image($r('app.media.image1')) + Image(this.bannerInfo.pic) .width('100%') .height(150) - Column({ space: 10 }) { - Text('鍗庝负[1+X]銆婄綉缁滅郴缁熷缓璁句笌杩愮淮銆�') - .fontWeight(800) - .width('100%') - - Text('璇剧▼浠嬬粛') - .width('100%') - .fontSize(14) - .fontWeight(800) - .margin({ top: 10 }) - - Text('鏈绋嬫槸璁$畻鏈虹綉缁滄妧鏈�侀�氫俊鎶�鏈瓑涓撲笟鐨勪笓涓氭牳蹇冭绋嬶紝鏃ㄥ湪鍩瑰吇瀛︾敓鐨勭綉缁滄妧鏈亴涓氳兘鍔涖�佽亴涓氱礌鍏诲拰鍒涙柊鑳藉姏銆�' + - '\n閲囩敤椤圭洰寮忓疄璁暀瀛︼紝閫氳繃寮曞叆涓�涓惊搴忔笎杩涚殑浼佷笟缃戠粶缁勫缓妗堜緥锛岃瀛︾敓鍦ㄦā鎷熺湡瀹炲満鏅腑鎺屾彙涓皬鍨嬩紒涓氱綉缁滅粍寤虹殑鐭ヨ瘑鍜岃兘鍔�' + - '鏁欐潗鍐呭瑕嗙洊鍗庝负鈥�1+X鈥濊瘉涔﹁�冭瘯瑕佹眰锛屽寘鍚ぇ閲忓疄鎿嶇粌涔犮��') - .width('100%') - .fontSize(13) - .lineHeight(20) - } - .padding(14) - - + LvMarkdownIn({ text: this.bannerInfo.content.toString() }) + .width('100%') + .height(560) } .width('100%') -- Gitblit v1.8.0