detail.uvue 1.6 KB
Newer Older
W
微调  
wanganxp 已提交
1
<template>
H
hdx 已提交
2 3 4
  <!-- #ifdef APP -->
  <scroll-view style="flex: 1">
  <!-- #endif -->
W
微调  
wanganxp 已提交
5 6 7 8 9
    <view class="banner">
      <image class="banner-img" :src="cover"></image>
      <text class="banner-title">{{title}}</text>
    </view>
    <rich-text :nodes="htmlNodes" style="padding: 3px"></rich-text>
H
hdx 已提交
10 11 12
  <!-- #ifdef APP -->
  </scroll-view>
  <!-- #endif -->
W
微调  
wanganxp 已提交
13 14 15
</template>

<script>
H
hdx 已提交
16 17 18 19 20 21 22 23 24 25
  export default {
    data() {
      return {
        htmlNodes: "",
        title: '',
        cover: "",
        post_id: "",
      }
    },
    onLoad(event : OnLoadOptions) {
26 27 28
      this.post_id = event["post_id"] ?? "";
      this.cover = event["cover"] ?? "";
      this.title = event["title"] ?? "";
H
hdx 已提交
29 30 31 32 33 34 35
      this.getDetail();
    },
    methods: {
      getDetail() {
        uni.request({
          url: 'https://unidemo.dcloud.net.cn/api/news/36kr/' + this.post_id,
          success: (data) => {
W
微调  
wanganxp 已提交
36
            if (data.statusCode == 200) {
37
              const result = data.data as UTSJSONObject
W
微调  
wanganxp 已提交
38 39 40
              // console.log(result["content"]);
              this.htmlNodes = result["content"] as string;
            }
H
hdx 已提交
41 42 43 44 45 46 47 48
          },
          fail: () => {
            console.log('fail');
          }
        });
      },
    }
  }
W
微调  
wanganxp 已提交
49 50 51
</script>

<style>
H
hdx 已提交
52 53 54 55 56 57
  .banner {
    height: 180px;
    overflow: hidden;
    position: relative;
    background-color: #ccc;
  }
W
微调  
wanganxp 已提交
58

H
hdx 已提交
59 60 61
  .banner-img {
    width: 100%;
  }
W
微调  
wanganxp 已提交
62

H
hdx 已提交
63 64 65 66 67 68 69 70 71 72 73 74
  .banner-title {
    max-height: 42px;
    overflow: hidden;
    position: absolute;
    left: 15px;
    bottom: 15px;
    width: 90%;
    font-size: 16px;
    font-weight: 400;
    line-height: 21px;
    color: white;
  }
75
</style>