陈剑华

人民号无图卡ui

  1 +import { ContentDTO } from 'wdBean';
  2 +import { RmhTitle } from '../cardCommon/RmhTitle'
  3 +import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
  4 +import { CommonConstants } from 'wdConstant/Index';
  5 +
  6 +const TAG = 'Card12Component';
  7 +
  8 +/**
  9 + * 人民号-动态---12:人民号无图卡;
  10 + */
  11 +@Component
  12 +export struct Card12Component {
  13 + @State contentDTO: ContentDTO = {
  14 + appStyle: '20',
  15 + coverType: 1,
  16 + coverUrl: 'https://rmrbcmsonline.peopleapp.com/upload/user_app/gov_dynamic/video/default_image/202105/rmrb_default_image_4GdWrgSw1622451312.jpg?x-oss-process=image/resize,m_fill,h_480,w_360/quality,q_90',
  17 + fullColumnImgUrls: [
  18 + {
  19 + landscape: 1,
  20 + size: 1,
  21 + url: 'https://rmrbcmsonline.peopleapp.com/upload/user_app/gov_dynamic/video/default_image/202105/rmrb_default_image_4GdWrgSw1622451312.jpg?x-oss-process=image/resize,m_fill,h_480,w_360/quality,q_90',
  22 + weight: 1600
  23 + }
  24 + ],
  25 + newsTitle: '好玩!》10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人',
  26 + rmhInfo: {
  27 + authIcon:
  28 + 'https://cdnjdphoto.aikan.pdnews.cn/creator-category/icon/auth/yellow.png',
  29 + authTitle: '10后音乐人王烁然个人人民号',
  30 + authTitle2: '10后音乐人王烁然个人人民号',
  31 + banControl: 0,
  32 + cnIsAttention: 1,
  33 + rmhDesc: '10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人',
  34 + rmhHeadUrl: 'https://cdnjdphoto.aikan.pdnews.cn/image/creator/rmh/20221031/3d3419e86a.jpeg?x-oss-process=image/resize,l_100/auto-orient,1/quality,q_90/format,jpg',
  35 + rmhName: '王烁然',
  36 + userId: '522435359667845',
  37 + userType: '2'
  38 + },
  39 + objectType: '1',
  40 + videoInfo: {
  41 + firstFrameImageUri: '',
  42 + videoDuration: 37,
  43 + videoUrl: 'https://rmrbcmsonline.peopleapp.com/upload/user_app/gov_dynamic/video/mp4/202105/rmrb_GSNARt6P1622451310.mp4'
  44 + }
  45 + } as ContentDTO;
  46 +
  47 + aboutToAppear(): void {
  48 + }
  49 +
  50 + build() {
  51 + Column() {
  52 + // rmh信息
  53 + RmhTitle({ rmhInfo: this.contentDTO.rmhInfo })
  54 + // 标题
  55 + if (this.contentDTO.newsTitle) {
  56 + Text(this.contentDTO.newsTitle)
  57 + .fontSize($r('app.float.font_size_17'))
  58 + .fontColor($r('app.color.color_222222'))
  59 + .width(CommonConstants.FULL_WIDTH)
  60 + .textOverflowStyle(3)
  61 + .margin({ bottom: 8 })
  62 + .height(75)
  63 + .lineHeight(25)
  64 + .fontFamily('PingFang SC-Regular')
  65 + }
  66 +
  67 + // if (this.contentDTO.fullColumnImgUrls?.[0]) {
  68 + // createImg({ contentDTO: this.contentDTO })
  69 + // }
  70 + //TODO 底部的:分享、评论、点赞 功能;需要引用一个公共组件
  71 + }
  72 + .padding({
  73 + left: $r('app.float.card_comp_pagePadding_lf'),
  74 + right: $r('app.float.card_comp_pagePadding_lf'),
  75 + top: $r('app.float.card_comp_pagePadding_tb'),
  76 + bottom: $r('app.float.card_comp_pagePadding_tb')
  77 + })
  78 + }
  79 +}
  80 +
  81 +interface radiusType {
  82 + topLeft: number | Resource;
  83 + topRight: number | Resource;
  84 + bottomLeft: number | Resource;
  85 + bottomRight: number | Resource;
  86 +}
  87 +
  88 +@Component
  89 +struct createImg {
  90 + @Prop contentDTO: ContentDTO
  91 +
  92 + build() {
  93 + GridRow() {
  94 + if (this.contentDTO.fullColumnImgUrls[0].landscape === 1) {
  95 + // 横屏
  96 + GridCol({
  97 + span: { xs: 12 }
  98 + }) {
  99 + Stack() {
  100 + Image(this.contentDTO.coverUrl)
  101 + .width(CommonConstants.FULL_WIDTH)
  102 + .aspectRatio(16 / 9)
  103 + .borderRadius($r('app.float.image_border_radius'))
  104 + CardMediaInfo({ contentDTO: this.contentDTO })
  105 + }
  106 + .align(Alignment.BottomEnd)
  107 + }
  108 + } else {
  109 + // 竖图显示,宽度占50%,高度自适应
  110 + GridCol({
  111 + span: { xs: 6 }
  112 + }) {
  113 + Stack() {
  114 + Image(this.contentDTO.coverUrl)
  115 + .width(CommonConstants.FULL_WIDTH)
  116 + .borderRadius($r('app.float.image_border_radius'))
  117 + CardMediaInfo({ contentDTO: this.contentDTO })
  118 + }
  119 + .align(Alignment.BottomEnd)
  120 + }
  121 + }
  122 + }
  123 + }
  124 +}
  125 +
  126 +
  127 +@Extend(Text)
  128 +function textOverflowStyle(maxLine: number) {
  129 + .maxLines(maxLine)
  130 + .textOverflow({ overflow: TextOverflow.Ellipsis })
  131 +}