From 23fa268f56dcd99c8dcd46f50f3ffcaa4cdcbc49 Mon Sep 17 00:00:00 2001 From: wwf <1971391498@qq.com> Date: 星期五, 10 十月 2025 17:25:53 +0800 Subject: [PATCH] 功能完善 --- entry/src/main/ets/pages/home/ActiveDetail.ets | 110 ++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 81 insertions(+), 29 deletions(-) diff --git a/entry/src/main/ets/pages/home/ActiveDetail.ets b/entry/src/main/ets/pages/home/ActiveDetail.ets index 1865836..93bb3ee 100644 --- a/entry/src/main/ets/pages/home/ActiveDetail.ets +++ b/entry/src/main/ets/pages/home/ActiveDetail.ets @@ -1,38 +1,97 @@ -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 { ROMAIN } from "../../utils/config" + +class Activity { + id: string = '' + name: string = '' + pic: string = '' + startDate: string = '' + endTime: string = '' + signupCount: number = 0 + status: string = '' + content: string = '' +} @Entry @Component export struct ActiveDetail { - @State index: number = 0 + @State hotTrainingId: string = '' + @State activeInfo: Activity = { + id: '', + name: '', + pic: '', + startDate: '', + endTime: '', + signupCount: 0, + status: '', + content: '', + } aboutToAppear(): void { interface Params { - index: number + id: string } const params: Params = router.getParams() as Params - this.index = params.index + this.hotTrainingId = params.id + this.getDetail() } + getDetail() { + let httpRequest = http.createHttp(); + httpRequest.request( + `${ROMAIN}/quiz-community/public/v1.0/home/hotTraining/details?hotTrainingId=${this.hotTrainingId}`, + { + method: http.RequestMethod.GET, + header: { 'Content-Type': 'application/json', 'x-jwt-token': `Bearer ${AppStorage.get('x-jwt-token')}` }, + }, + (err, data) => { + console.log('response', '/home/hotTraining/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<Activity> + if (resData.code == 200) { + this.activeInfo = resData.data as Activity + } else { + promptAction.showToast({ message: resData.msg }) + } + } + } + ) + } getTagFontColor(statusText: string) { switch (statusText) { - case '鎶ュ悕涓�': + case 'signup': return '#10920e' - case '杩涜涓�': + case 'training': return '#ffa100' default : return '#666666' } } - getTagBgColor(statusText: string) { - switch (statusText) { - case '鎶ュ悕涓�': + getTagBgColor(status: string) { + switch (status) { + case 'signup': return '#d5f2db' - case '杩涜涓�': + case 'training': return '#fff0cc' default : return '#ebebeb' } + } + + getStatusText(status: string) { + if (status == 'signup') { + return '鎶ュ悕涓�' + } else if (status == 'training') { + return '杩涜涓�' + } else if (status == 'finished') { + return '宸茬粨鏉�' + } + return '' } build() { @@ -41,6 +100,9 @@ Image($r('app.media.left_icon')) .width(20) .height(20) + .onClick(() => { + router.back() + }) Text('璇︽儏椤�') .fontSize(18) .fontWeight(700) @@ -55,50 +117,40 @@ .height(150) Column({ space: 14 }) { - Text('鍖椾含浜哄伐鏅鸿兘IE') + Text(this.activeInfo.name) .fontWeight(800) .width('100%') Row({ space: 10 }) { - Text('鎶ュ悕涓�') + Text(this.getStatusText(this.activeInfo.status)) .fontSize(10) .fontWeight(500) .padding({ left: 4, right: 4, top: 2, bottom: 2 }) .borderRadius(10) - .fontColor(this.getTagFontColor('鎶ュ悕涓�')) - .backgroundColor(this.getTagBgColor('鎶ュ悕涓�')) + .fontColor(this.getTagFontColor(this.activeInfo.status)) + .backgroundColor(this.getTagBgColor(this.activeInfo.status)) Row() { Image($r('app.media.date_icon')) .width(12) .height(12) - Text('20250520-20250620') + Text(`${this.activeInfo.startDate}-${this.activeInfo.endTime}`) .fontSize(10) .fontColor('#676767') .margin({ left: 4 }) } - Text(`80浜哄凡鎶ュ悕`) + Text(`${this.activeInfo.signupCount}浜哄凡鎶ュ悕`) .fontSize(10) .fontColor('#676767') } .width('100%') .justifyContent(FlexAlign.Start) - Text('璇剧▼浠嬬粛') + LvMarkdownIn({ text: this.activeInfo.content }) .width('100%') - .fontSize(14) - .fontWeight(800) - - Text('鏈绋嬫槸璁$畻鏈虹綉缁滄妧鏈�侀�氫俊鎶�鏈瓑涓撲笟鐨勪笓涓氭牳蹇冭绋嬶紝鏃ㄥ湪鍩瑰吇瀛︾敓鐨勭綉缁滄妧鏈亴涓氳兘鍔涖�佽亴涓氱礌鍏诲拰鍒涙柊鑳藉姏銆�' + - '\n閲囩敤椤圭洰寮忓疄璁暀瀛︼紝閫氳繃寮曞叆涓�涓惊搴忔笎杩涚殑浼佷笟缃戠粶缁勫缓妗堜緥锛岃瀛︾敓鍦ㄦā鎷熺湡瀹炲満鏅腑鎺屾彙涓皬鍨嬩紒涓氱綉缁滅粍寤虹殑鐭ヨ瘑鍜岃兘鍔�' + - '鏁欐潗鍐呭瑕嗙洊鍗庝负鈥�1+X鈥濊瘉涔﹁�冭瘯瑕佹眰锛屽寘鍚ぇ閲忓疄鎿嶇粌涔犮��') - .width('100%') - .fontSize(13) - .lineHeight(20) + .height(560) + .padding({ left: 10, right: 10 }) } .padding(14) - - - } .width('100%') .height('100%') -- Gitblit v1.8.0