陈剑华

小视频横划卡

  1 +import { CompDTO, ContentDTO, Params } from 'wdBean';
  2 +import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
  3 +import { HttpUrlUtils } from 'wdNetwork/Index';
  4 +import { postInteractAccentionOperateParams } from 'wdBean';
  5 +import { PageRepository } from '../../repository/PageRepository';
  6 +import { CommonConstants } from 'wdConstant/Index';
  7 +
  8 +/**
  9 + * 小视频横划卡
  10 + * Zh_Single_Row-02
  11 + */
  12 +const TAG = 'Zh_Single_Row-02'
  13 +
  14 +@Entry
  15 +@Component
  16 +export struct ZhSingleRow02 {
  17 + @State compDTO: CompDTO = {
  18 + objectTitle: '大标题',
  19 + operDataList: [
  20 + {
  21 + rmhInfo: {
  22 + rmhId: '2489729',
  23 + rmhName: '陕西青年职业学院',
  24 + rmhDesc: '陕西青年职业学院陕西青年职业学院是经陕西省人民政陕西青年职业学院是经陕西省人民政是经陕西省人民政',
  25 + rmhHeadUrl: 'https://cdnjdphoto.aikan.pdnews.cn//upload/ueditor/image/20210113/a_533807397399949312' +
  26 + '.png?x-oss-process=image/resize,l_100/auto-orient,1/quality,q_90/format,jpg'
  27 + }
  28 + },
  29 + {
  30 + rmhInfo: {
  31 + rmhId: '2489729',
  32 + rmhName: '陕西青年职业学院',
  33 + rmhDesc: '陕西青年职业学院陕西青年职业学院是经陕西省人民政陕西青年职业学院是经陕西省人民政是经陕西省人民政',
  34 + rmhHeadUrl: 'https://cdnjdphoto.aikan.pdnews.cn//upload/ueditor/image/20210113/a_533807397399949312' +
  35 + '.png?x-oss-process=image/resize,l_100/auto-orient,1/quality,q_90/format,jpg'
  36 + }
  37 + },
  38 + {
  39 + rmhInfo: {
  40 + rmhId: '2489729',
  41 + rmhName: '陕西青年职业学院',
  42 + rmhDesc: '陕西青年职业学院陕西青年职业学院是经陕西省人民政陕西青年职业学院是经陕西省人民政是经陕西省人民政',
  43 + rmhHeadUrl: 'https://cdnjdphoto.aikan.pdnews.cn//upload/ueditor/image/20210113/a_533807397399949312' +
  44 + '.png?x-oss-process=image/resize,l_100/auto-orient,1/quality,q_90/format,jpg'
  45 + }
  46 + },
  47 + {
  48 + rmhInfo: {
  49 + rmhId: '2489729',
  50 + rmhName: '陕西青年职业学院',
  51 + rmhDesc: '陕西青年职业学院陕西青年职业学院是经陕西省人民政陕西青年职业学院是经陕西省人民政是经陕西省人民政',
  52 + rmhHeadUrl: 'https://cdnjdphoto.aikan.pdnews.cn//upload/ueditor/image/20210113/a_533807397399949312' +
  53 + '.png?x-oss-process=image/resize,l_100/auto-orient,1/quality,q_90/format,jpg'
  54 + }
  55 + },
  56 + {
  57 + rmhInfo: {
  58 + rmhId: '2489729',
  59 + rmhName: '陕西青年职业学院',
  60 + rmhDesc: '陕西青年职业学院陕西青年职业学院是经陕西省人民政陕西青年职业学院是经陕西省人民政是经陕西省人民政',
  61 + rmhHeadUrl: 'https://cdnjdphoto.aikan.pdnews.cn//upload/ueditor/image/20210113/a_533807397399949312' +
  62 + '.png?x-oss-process=image/resize,l_100/auto-orient,1/quality,q_90/format,jpg'
  63 + }
  64 + },
  65 + ]
  66 + } as CompDTO
  67 +
  68 + build() {
  69 + Column() {
  70 + //顶部
  71 + this.CompHeader(this.compDTO)
  72 + Row(){
  73 + // 列表内容
  74 + List() {
  75 + ForEach(this.compDTO.operDataList, (item: ContentDTO, index: number) => {
  76 + CreatorItem({
  77 + item
  78 + })
  79 + .margin({right: index === this.compDTO.operDataList.length - 1 ? $r('app.float.card_comp_pagePadding_lf') : 0})
  80 + })
  81 + }
  82 + .listDirection(Axis.Horizontal)
  83 + }
  84 + .width(CommonConstants.FULL_WIDTH)
  85 + .height(208)
  86 + }
  87 + .padding({
  88 + left: $r('app.float.card_comp_pagePadding_lf'),
  89 + // right: $r('app.float.card_comp_pagePadding_lf'),
  90 + top: $r('app.float.card_comp_pagePadding_tb'),
  91 + bottom: $r('app.float.card_comp_pagePadding_tb')
  92 + })
  93 + .backgroundColor($r('app.color.white'))
  94 + .margin({ bottom: 8 })
  95 + }
  96 +
  97 + @Builder
  98 + CompHeader(item: CompDTO) {
  99 + Row() {
  100 + Row() {
  101 + Image($r("app.media.redLine"))
  102 + .width(3)
  103 + .height(16)
  104 + .margin({ right: 4 })
  105 + Text(item.objectTitle)
  106 + .fontSize($r("app.float.font_size_17"))
  107 + .fontColor($r("app.color.color_222222"))
  108 + .fontWeight(600)
  109 + }
  110 +
  111 + Row() {
  112 + Text("更多")
  113 + .fontSize($r("app.float.font_size_14"))
  114 + .fontColor($r("app.color.color_999999"))
  115 + .margin({ right: 1 })
  116 + Image($r("app.media.more"))
  117 + .width(14)
  118 + .height(14)
  119 + .onClick(() => {
  120 + // TODO 跳转的页面,定义的入参可能不合理。推荐id: 41
  121 + let params: Params = {
  122 + pageID: "1"
  123 + }
  124 + WDRouterRule.jumpWithPage(WDRouterPage.followListPage, params)
  125 + })
  126 + }
  127 + .padding({
  128 + right: $r('app.float.card_comp_pagePadding_lf'),
  129 + })
  130 + }
  131 + .justifyContent(FlexAlign.SpaceBetween)
  132 + .margin({ top: 8, bottom: 8 })
  133 + .width('100%')
  134 + }
  135 +}
  136 +
  137 +@Extend(Text)
  138 +function textOverflowStyle(maxLine: number) {
  139 + .maxLines(maxLine)
  140 + .textOverflow({ overflow: TextOverflow.Ellipsis })
  141 +}
  142 +
  143 +@Component
  144 +struct CreatorItem {
  145 + @Prop item: ContentDTO
  146 + @State rmhIsAttention: number = 0
  147 + build() {
  148 + ListItem() {
  149 + Column() {
  150 + Stack({ alignContent: Alignment.Bottom }) {
  151 + Image('')
  152 + .width(156)
  153 + .height(208)
  154 + Row()
  155 + .width(156)
  156 + .height(80)
  157 + .linearGradient({
  158 + direction: GradientDirection.Bottom,
  159 + colors: [[0xffffff, 0.0], [0x000000, 1.0]]
  160 + })
  161 + .opacity(0.3)
  162 + Text('这里显示卡片标题这里显示卡片标题这里显示卡片标题这里显示卡片标题这里显示卡片标题')
  163 + .fontColor(0xffffff)
  164 + .fontSize(14)
  165 + .maxLines(2)
  166 + .textOverflow({overflow: TextOverflow.Ellipsis})
  167 + .width(140)
  168 + .height(40)
  169 + .margin({bottom: 8})
  170 + }
  171 +
  172 + }
  173 + .width(156)
  174 + .height(208)
  175 + .margin({ right: 11 })
  176 + .borderWidth(1)
  177 + .borderColor($r('app.color.color_EDEDED'))
  178 + .borderRadius($r('app.float.image_border_radius'))
  179 + }
  180 + .onClick(() => {
  181 + console.log('跳转到rmh');
  182 + })
  183 + }
  184 +
  185 + /**
  186 + * 关注号主 TODO 这里后面需要抽离
  187 + */
  188 + handleAccention(item: ContentDTO, status: number) {
  189 + this.rmhIsAttention = this.rmhIsAttention ? 0 : 1
  190 + return
  191 + // 未登录,跳转登录
  192 + if (!HttpUrlUtils.getUserId()) {
  193 + WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
  194 + return
  195 + }
  196 +
  197 + const params: postInteractAccentionOperateParams = {
  198 + attentionUserType: item.rmhInfo?.userType || '', //被关注用户类型(1 普通用户 2 视频号 3 矩阵号)
  199 + attentionUserId: item.rmhInfo?.userId || '', // 被关注用户号主id
  200 + attentionCreatorId: item.rmhInfo?.rmhId || '', // 被关注用户号主id
  201 + // userType: 1,
  202 + // userId: '1', // TODO 用户id需要从本地获取
  203 + status: status,
  204 + }
  205 + PageRepository.postInteractAccentionOperate(params).then(res => {
  206 + console.log(TAG, '关注号主==', JSON.stringify(res.data))
  207 + if (status === 1) {
  208 + this.rmhIsAttention = 0
  209 + } else {
  210 + this.rmhIsAttention = 1
  211 + }
  212 + })
  213 + }
  214 +}