wangyong_wd

人民号横划卡开发

@@ -4,7 +4,7 @@ import { VideoInfoDTO } from '../detail/VideoInfoDTO'; @@ -4,7 +4,7 @@ import { VideoInfoDTO } from '../detail/VideoInfoDTO';
4 import { InteractDataDTO } from './InteractDataDTO'; 4 import { InteractDataDTO } from './InteractDataDTO';
5 import { slideShows } from '../morningevening/slideShows'; 5 import { slideShows } from '../morningevening/slideShows';
6 import { VoiceInfoDTO } from '../detail/VoiceInfoDTO'; 6 import { VoiceInfoDTO } from '../detail/VoiceInfoDTO';
7 - 7 +import { RmhInfoDTO } from '../detail/RmhInfoDTO'
8 export interface ContentDTO { 8 export interface ContentDTO {
9 appStyle: string; 9 appStyle: string;
10 cityCode: string; 10 cityCode: string;
@@ -66,4 +66,5 @@ export interface ContentDTO { @@ -66,4 +66,5 @@ export interface ContentDTO {
66 slideShows: slideShows[], 66 slideShows: slideShows[],
67 voiceInfo: VoiceInfoDTO, 67 voiceInfo: VoiceInfoDTO,
68 tagWord: number, 68 tagWord: number,
  69 + rmhInfo: RmhInfoDTO, // 人民号信息
69 } 70 }
@@ -15,13 +15,29 @@ export struct ZhSingleColumn05 { @@ -15,13 +15,29 @@ export struct ZhSingleColumn05 {
15 15
16 build() { 16 build() {
17 Row() { 17 Row() {
18 - Image($r('app.media.rmh_join_log'))  
19 - .height(18)  
20 - .margin({ right: 10 })  
21 - Text('快速入住通道')  
22 - Image($r('app.media.arrow_icon_right'))  
23 - .width(16)  
24 - .height(16) 18 + Row(){
  19 + Image($r('app.media.rmh_join_log'))
  20 + .height(18)
  21 + .margin({ right: 10 })
  22 + Text('快速入住通道')
  23 + Image($r('app.media.arrow_icon_right'))
  24 + .width(16)
  25 + .height(16)
  26 + }
  27 + .padding(10)
  28 + .width(CommonConstants.FULL_WIDTH)
  29 + .backgroundColor($r('app.color.color_F9F9F9'))
  30 + .justifyContent(FlexAlign.Center)
  31 + .borderRadius($r('app.float.button_border_radius'))
  32 + .onClick(() => {
  33 + let taskAction: Action = {
  34 + type: 'JUMP_H5_BY_WEB_VIEW',
  35 + params: {
  36 + url: this.compDTO.linkUrl
  37 + } as Params,
  38 + };
  39 + WDRouterRule.jumpWithAction(taskAction)
  40 + })
25 } 41 }
26 .width(CommonConstants.FULL_WIDTH) 42 .width(CommonConstants.FULL_WIDTH)
27 .padding({ 43 .padding({
@@ -30,17 +46,7 @@ export struct ZhSingleColumn05 { @@ -30,17 +46,7 @@ export struct ZhSingleColumn05 {
30 top: $r('app.float.card_comp_pagePadding_tb'), 46 top: $r('app.float.card_comp_pagePadding_tb'),
31 bottom: $r('app.float.card_comp_pagePadding_tb') 47 bottom: $r('app.float.card_comp_pagePadding_tb')
32 }) 48 })
33 - .backgroundColor($r('app.color.color_fff'))  
34 - .justifyContent(FlexAlign.Center)  
35 - .onClick(() => {  
36 - let taskAction: Action = {  
37 - type: 'JUMP_H5_BY_WEB_VIEW',  
38 - params: {  
39 - url: this.compDTO.linkUrl  
40 - } as Params,  
41 - };  
42 - WDRouterRule.jumpWithAction(taskAction)  
43 - }) 49 +
44 } 50 }
45 } 51 }
46 52
  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-05
  11 + */
  12 +const TAG = 'Zh_Single_Row-05'
  13 +
  14 +@Entry
  15 +@Component
  16 +export struct ZhSingleRow05 {
  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 + } as CompDTO
  31 +
  32 + build() {
  33 + Column() {
  34 + //顶部
  35 + this.CompHeader(this.compDTO)
  36 + Row(){
  37 + // 列表内容
  38 + List({ space: 8 }) {
  39 + ForEach(this.compDTO.operDataList, (item: ContentDTO, index: number) => {
  40 + CreatorItem({
  41 + item
  42 + })
  43 + .margin({right: index === this.compDTO.operDataList.length - 1 ? $r('app.float.card_comp_pagePadding_lf') : 0})
  44 + })
  45 + }
  46 + .listDirection(Axis.Horizontal)
  47 + }
  48 + .width(CommonConstants.FULL_WIDTH)
  49 + .height(170)
  50 + }
  51 + .padding({
  52 + left: $r('app.float.card_comp_pagePadding_lf'),
  53 + // right: $r('app.float.card_comp_pagePadding_lf'),
  54 + top: $r('app.float.card_comp_pagePadding_tb'),
  55 + bottom: $r('app.float.card_comp_pagePadding_tb')
  56 + })
  57 + .backgroundColor($r('app.color.white'))
  58 + .margin({ bottom: 8 })
  59 + }
  60 +
  61 + @Builder
  62 + CompHeader(item: CompDTO) {
  63 + Row() {
  64 + Row() {
  65 + Image($r("app.media.redLine"))
  66 + .width(3)
  67 + .height(16)
  68 + .margin({ right: 4 })
  69 + Text(item.objectTitle)
  70 + .fontSize($r("app.float.font_size_17"))
  71 + .fontColor($r("app.color.color_222222"))
  72 + .fontWeight(600)
  73 + }
  74 +
  75 + Row() {
  76 + Text("更多")
  77 + .fontSize($r("app.float.font_size_14"))
  78 + .fontColor($r("app.color.color_999999"))
  79 + .margin({ right: 1 })
  80 + Image($r("app.media.more"))
  81 + .width(14)
  82 + .height(14)
  83 + .onClick(() => {
  84 + // TODO 跳转的页面,定义的入参可能不合理。推荐id: 41
  85 + let params: Params = {
  86 + pageID: "1"
  87 + }
  88 + WDRouterRule.jumpWithPage(WDRouterPage.followListPage, params)
  89 + })
  90 + }
  91 + .padding({
  92 + right: $r('app.float.card_comp_pagePadding_lf'),
  93 + })
  94 + }
  95 + .justifyContent(FlexAlign.SpaceBetween)
  96 + .margin({ top: 8, bottom: 8 })
  97 + .width('100%')
  98 + }
  99 +}
  100 +
  101 +@Extend(Text)
  102 +function textOverflowStyle(maxLine: number) {
  103 + .maxLines(maxLine)
  104 + .textOverflow({ overflow: TextOverflow.Ellipsis })
  105 +}
  106 +
  107 +@Component
  108 +struct CreatorItem {
  109 + @Prop item: ContentDTO
  110 + @State rmhIsAttention: number = 0
  111 + build() {
  112 + ListItem() {
  113 + Column() {
  114 + Image(this.item.rmhInfo.rmhHeadUrl)
  115 + .width(44)
  116 + .height(44)
  117 + .margin({ top: 12, bottom: 8 })
  118 + Text(this.item.rmhInfo.rmhName)
  119 + .fontColor($r('app.color.color_222222'))
  120 + .fontSize($r('app.float.font_size_14'))
  121 + .fontWeight(500)
  122 + .textOverflowStyle(1)
  123 + Text(this.item.rmhInfo.rmhDesc)
  124 + .fontColor($r('app.color.color_B0B0B0'))
  125 + .fontSize($r('app.float.font_size_12'))
  126 + .margin({ top: 8, bottom: 14 })
  127 + .textOverflowStyle(2)
  128 + if (!this.rmhIsAttention) {
  129 + Text('关注')
  130 + .width(60)
  131 + .height(24)
  132 + .textAlign(TextAlign.Center)
  133 + .fontSize($r('app.float.font_size_12'))
  134 + .borderRadius($r('app.float.button_border_radius'))
  135 + .backgroundColor($r('app.color.color_ED2800'))
  136 + .fontColor($r('app.color.color_fff'))
  137 + .onClick(() => {
  138 + this.handleAccention(this.item, 1)
  139 + })
  140 + } else {
  141 + Text('已关注')
  142 + .width(60)
  143 + .height(24)
  144 + .borderWidth(1)
  145 + .textAlign(TextAlign.Center)
  146 + .fontSize($r('app.float.font_size_12'))
  147 + .borderRadius($r('app.float.button_border_radius'))
  148 + .borderColor($r('app.color.color_CCCCCC'))
  149 + .fontColor($r('app.color.color_CCCCCC'))
  150 + .onClick(() => {
  151 + this.handleAccention(this.item, 0)
  152 + })
  153 + }
  154 +
  155 + }
  156 + .width(100)
  157 + .height(170)
  158 + .padding({ left: 6, right: 6 })
  159 + .borderWidth(1)
  160 + .borderColor($r('app.color.color_EDEDED'))
  161 + .borderRadius($r('app.float.image_border_radius'))
  162 + }
  163 + .onClick(() => {
  164 + console.log('跳转到rmh');
  165 + })
  166 + }
  167 +
  168 + /**
  169 + * 关注号主 TODO 这里后面需要抽离
  170 + */
  171 + handleAccention(item: ContentDTO, status: number) {
  172 + this.rmhIsAttention = this.rmhIsAttention ? 0 : 1
  173 + return
  174 + // 未登录,跳转登录
  175 + if (!HttpUrlUtils.getUserId()) {
  176 + WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
  177 + return
  178 + }
  179 +
  180 + const params: postInteractAccentionOperateParams = {
  181 + attentionUserType: item.rmhInfo?.userType || '', //被关注用户类型(1 普通用户 2 视频号 3 矩阵号)
  182 + attentionUserId: item.rmhInfo?.userId || '', // 被关注用户号主id
  183 + attentionCreatorId: item.rmhInfo?.rmhId || '', // 被关注用户号主id
  184 + // userType: 1,
  185 + // userId: '1', // TODO 用户id需要从本地获取
  186 + status: status,
  187 + }
  188 + PageRepository.postInteractAccentionOperate(params).then(res => {
  189 + console.log(TAG, '关注号主==', JSON.stringify(res.data))
  190 + if (status === 1) {
  191 + this.rmhIsAttention = 0
  192 + } else {
  193 + this.rmhIsAttention = 1
  194 + }
  195 + })
  196 + }
  197 +}