wwf
2 天以前 791a96ae03cf92478244127b294c1fe520d31e89
entry/src/main/ets/pages/home/BannerDetail.ets
@@ -1,17 +1,56 @@
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"
import { DOMAIN } from "../../utils/config";
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() {
    let httpRequest = http.createHttp();
    httpRequest.request(
      `${DOMAIN}/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 +59,9 @@
        Image($r('app.media.left_icon'))
          .width(20)
          .height(20)
          .onClick(() => {
            router.back()
          })
        Text('详情页')
          .fontSize(18)
          .fontWeight(700)
@@ -29,31 +71,14 @@
      .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)
        .padding({ left: 10, right: 10 })
    }
    .width('100%')