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