陈剑华

精选评论卡ui

  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-06
  11 + */
  12 +const TAG = 'Zh_Single_Row-06'
  13 +
  14 +@Entry
  15 +@Component
  16 +export struct ZhSingleRow06 {
  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.icon_elite_comment"))
  102 + .width(24)
  103 + .height(24)
  104 + .margin({ right: 4 })
  105 + Text('精选评论')
  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 + Flex({direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween}) {
  151 + Column() {
  152 + Row() {
  153 + Image('')
  154 + .width(20)
  155 + .height(20)
  156 + .margin({right: 4})
  157 + .border({width: 1, color: 0xcccccc, radius: 10})
  158 + Text('立志之间')
  159 + .fontColor(0x212228)
  160 + .fontSize(12)
  161 + }
  162 + }
  163 +
  164 + Column() {
  165 + Row() {
  166 + Image($r('app.media.icon_like_no'))
  167 + .width(16)
  168 + .height(16)
  169 + .margin({right: 4})
  170 + Text('3835')
  171 + .fontSize(14)
  172 + .fontColor(0x999999)
  173 + }
  174 + }
  175 + }
  176 + .margin({top: 10, left: 10, right: 10, bottom: 8})
  177 +
  178 + Text('就业不仅是民生问题,也是发展问题,就业不仅是民生问题,也是发展问题,就业不仅是民生问题,也是发展问题,')
  179 + .maxLines(2)
  180 + .textOverflow({overflow: TextOverflow.Ellipsis})
  181 + .margin({left: 10, right: 10, bottom: 8})
  182 + .fontSize(17)
  183 + .fontColor(0x212228)
  184 + .lineHeight(25)
  185 +
  186 + Row() {
  187 + Image('')
  188 + .width(66)
  189 + .height(44)
  190 + .borderRadius({topLeft: 3, topRight: 0, bottomLeft: 3, bottomRight: 0})
  191 + Text('原文|强化就业优先政策 健全就业促进机制原文|强化就业优先政策 健全就业促进机制原文|强化就业优先政策 健全就业促进机制')
  192 + .margin({left: 8})
  193 + .width(172)
  194 + .maxLines(2)
  195 + .textOverflow({overflow: TextOverflow.Ellipsis})
  196 + }
  197 + .linearGradient({
  198 + direction: GradientDirection.Right,
  199 + colors: [[0xffffff, 0.0],[0xffffff, 0.8], [0xf9f9f9, 1.0]]
  200 + })
  201 + }
  202 + .width(276)
  203 + .height(150)
  204 + .margin({ right: 10 })
  205 + .borderWidth(1)
  206 + .borderColor($r('app.color.color_EDEDED'))
  207 + .borderRadius($r('app.float.image_border_radius'))
  208 + .backgroundColor(0xf9f9f9)
  209 + }
  210 + .onClick(() => {
  211 + console.log('跳转到rmh');
  212 + })
  213 + }
  214 +
  215 + /**
  216 + * 关注号主 TODO 这里后面需要抽离
  217 + */
  218 + handleAccention(item: ContentDTO, status: number) {
  219 + this.rmhIsAttention = this.rmhIsAttention ? 0 : 1
  220 + return
  221 + // 未登录,跳转登录
  222 + if (!HttpUrlUtils.getUserId()) {
  223 + WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
  224 + return
  225 + }
  226 +
  227 + const params: postInteractAccentionOperateParams = {
  228 + attentionUserType: item.rmhInfo?.userType || '', //被关注用户类型(1 普通用户 2 视频号 3 矩阵号)
  229 + attentionUserId: item.rmhInfo?.userId || '', // 被关注用户号主id
  230 + attentionCreatorId: item.rmhInfo?.rmhId || '', // 被关注用户号主id
  231 + // userType: 1,
  232 + // userId: '1', // TODO 用户id需要从本地获取
  233 + status: status,
  234 + }
  235 + PageRepository.postInteractAccentionOperate(params).then(res => {
  236 + console.log(TAG, '关注号主==', JSON.stringify(res.data))
  237 + if (status === 1) {
  238 + this.rmhIsAttention = 0
  239 + } else {
  240 + this.rmhIsAttention = 1
  241 + }
  242 + })
  243 + }
  244 +}