wwf
4 天以前 7f2343d38fa048f6ce179ea0ab2c1a04f41a213c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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
struct BannerDetail {
  @State bannerId: string = '';
  @State bannerInfo: BannerInfo = {
    pic: '',
    content: ''
  }
  aboutToAppear(): void {
    interface Params {
      bannerId: string
    }
    const params: Params = router.getParams() as Params
    if (params) {
      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() {
    Column() {
      Row() {
        Image($r('app.media.left_icon'))
          .width(20)
          .height(20)
          .onClick(() => {
            router.back()
          })
        Text('详情页')
          .fontSize(18)
          .fontWeight(700)
        Row()
      }
      .width('100%')
      .padding(10)
      .justifyContent(FlexAlign.SpaceBetween)
 
      Image(this.bannerInfo.pic)
        .width('100%')
        .height(150)
 
      LvMarkdownIn({ text: this.bannerInfo.content.toString() })
        .width('100%')
        .height(560)
 
    }
    .width('100%')
    .height('100%')
  }
}