Showing
2 changed files
with
225 additions
and
0 deletions
| 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 = {} as CompDTO | ||
| 18 | + @State list: Array<string> = ['社会', '三个字', '是四个字', '时事', '社会', '三个字', '是四个字', '时事'] | ||
| 19 | + @State activeIndexs: Array<number> = [] | ||
| 20 | + | ||
| 21 | + getItemWidth(index: number) { | ||
| 22 | + if (index % 4 === 0 || index % 4 === 3) { | ||
| 23 | + return 80 | ||
| 24 | + } else { | ||
| 25 | + return 96 | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + build() { | ||
| 30 | + Column() { | ||
| 31 | + //顶部 | ||
| 32 | + this.CompHeader(this.compDTO) | ||
| 33 | + Grid() { | ||
| 34 | + ForEach(this.list, (item: string, index: number) => { | ||
| 35 | + GridItem() { | ||
| 36 | + Text(item) | ||
| 37 | + .fontSize(14) | ||
| 38 | + .fontColor(this.activeIndexs.includes(index) ? 0x222222 : 0x666666) | ||
| 39 | + .fontWeight(this.activeIndexs.includes(index) ? 600 : 400) | ||
| 40 | + .textAlign(TextAlign.Center) | ||
| 41 | + } | ||
| 42 | + .onClick(() => { | ||
| 43 | + if (this.activeIndexs.includes(index)) { | ||
| 44 | + const ind = this.activeIndexs.indexOf(index); | ||
| 45 | + this.activeIndexs.splice(ind, 1) | ||
| 46 | + } else { | ||
| 47 | + this.activeIndexs.push(index) | ||
| 48 | + } | ||
| 49 | + }) | ||
| 50 | + }) | ||
| 51 | + } | ||
| 52 | + .height(70) | ||
| 53 | + .columnsTemplate('1fr 1fr 1fr 1fr') | ||
| 54 | + .rowsTemplate('1fr 1fr') | ||
| 55 | + .margin({bottom: 10}) | ||
| 56 | + | ||
| 57 | + | ||
| 58 | + Text('选中标签,为您推荐更多您感兴趣的内容') | ||
| 59 | + .fontSize(12) | ||
| 60 | + .fontColor(0xB0B0B0) | ||
| 61 | + .textAlign(TextAlign.Center) | ||
| 62 | + .margin({bottom: 10}) | ||
| 63 | + | ||
| 64 | + Row() { | ||
| 65 | + Text('选好了') | ||
| 66 | + .fontSize(14) | ||
| 67 | + .fontColor(0x000000) | ||
| 68 | + .width('100%') | ||
| 69 | + .textAlign(TextAlign.Center) | ||
| 70 | + } | ||
| 71 | + .height(40) | ||
| 72 | + .backgroundColor(0xf9f9f9) | ||
| 73 | + .width('100%') | ||
| 74 | + .borderRadius(3) | ||
| 75 | + } | ||
| 76 | + .padding({ | ||
| 77 | + left: $r('app.float.card_comp_pagePadding_lf'), | ||
| 78 | + right: $r('app.float.card_comp_pagePadding_lf'), | ||
| 79 | + top: $r('app.float.card_comp_pagePadding_tb'), | ||
| 80 | + bottom: $r('app.float.card_comp_pagePadding_tb') | ||
| 81 | + }) | ||
| 82 | + .backgroundColor($r('app.color.white')) | ||
| 83 | + .margin({ bottom: 8 }) | ||
| 84 | + | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + @Builder | ||
| 88 | + CompHeader(item: CompDTO) { | ||
| 89 | + Row() { | ||
| 90 | + Row() { | ||
| 91 | + Image($r("app.media.icon_interest_ask")) | ||
| 92 | + .width(24) | ||
| 93 | + .height(24) | ||
| 94 | + .margin({ right: 4 }) | ||
| 95 | + Text('以下是否有您感兴趣?') | ||
| 96 | + .fontSize($r("app.float.font_size_17")) | ||
| 97 | + .fontColor(0x000000) | ||
| 98 | + .fontWeight(600) | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + Row() { | ||
| 102 | + Image($r("app.media.close_button")) | ||
| 103 | + .width(14) | ||
| 104 | + .height(14) | ||
| 105 | + .onClick(() => { | ||
| 106 | + }) | ||
| 107 | + } | ||
| 108 | + .padding({ | ||
| 109 | + right: $r('app.float.card_comp_pagePadding_lf'), | ||
| 110 | + }) | ||
| 111 | + } | ||
| 112 | + .justifyContent(FlexAlign.SpaceBetween) | ||
| 113 | + .margin({ top: 8, bottom: 8 }) | ||
| 114 | + .width('100%') | ||
| 115 | + } | ||
| 116 | +} | ||
| 117 | + | ||
| 118 | +@Extend(Text) | ||
| 119 | +function textOverflowStyle(maxLine: number) { | ||
| 120 | + .maxLines(maxLine) | ||
| 121 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 122 | +} | ||
| 123 | + | ||
| 124 | +@Component | ||
| 125 | +struct CreatorItem { | ||
| 126 | + @Prop item: ContentDTO | ||
| 127 | + @State rmhIsAttention: number = 0 | ||
| 128 | + build() { | ||
| 129 | + ListItem() { | ||
| 130 | + Column() { | ||
| 131 | + Flex({direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween}) { | ||
| 132 | + Column() { | ||
| 133 | + Row() { | ||
| 134 | + Image('') | ||
| 135 | + .width(20) | ||
| 136 | + .height(20) | ||
| 137 | + .margin({right: 4}) | ||
| 138 | + .border({width: 1, color: 0xcccccc, radius: 10}) | ||
| 139 | + Text('立志之间') | ||
| 140 | + .fontColor(0x212228) | ||
| 141 | + .fontSize(12) | ||
| 142 | + } | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + Column() { | ||
| 146 | + Row() { | ||
| 147 | + Image($r('app.media.icon_like_no')) | ||
| 148 | + .width(16) | ||
| 149 | + .height(16) | ||
| 150 | + .margin({right: 4}) | ||
| 151 | + Text('3835') | ||
| 152 | + .fontSize(14) | ||
| 153 | + .fontColor(0x999999) | ||
| 154 | + } | ||
| 155 | + } | ||
| 156 | + } | ||
| 157 | + .margin({top: 10, left: 10, right: 10, bottom: 8}) | ||
| 158 | + | ||
| 159 | + Text('就业不仅是民生问题,也是发展问题,就业不仅是民生问题,也是发展问题,就业不仅是民生问题,也是发展问题,') | ||
| 160 | + .maxLines(2) | ||
| 161 | + .textOverflow({overflow: TextOverflow.Ellipsis}) | ||
| 162 | + .margin({left: 10, right: 10, bottom: 8}) | ||
| 163 | + .fontSize(17) | ||
| 164 | + .fontColor(0x212228) | ||
| 165 | + .lineHeight(25) | ||
| 166 | + | ||
| 167 | + Row() { | ||
| 168 | + Image('') | ||
| 169 | + .width(66) | ||
| 170 | + .height(44) | ||
| 171 | + .borderRadius({topLeft: 3, topRight: 0, bottomLeft: 3, bottomRight: 0}) | ||
| 172 | + Text('原文|强化就业优先政策 健全就业促进机制原文|强化就业优先政策 健全就业促进机制原文|强化就业优先政策 健全就业促进机制') | ||
| 173 | + .margin({left: 8}) | ||
| 174 | + .width(172) | ||
| 175 | + .maxLines(2) | ||
| 176 | + .textOverflow({overflow: TextOverflow.Ellipsis}) | ||
| 177 | + } | ||
| 178 | + .linearGradient({ | ||
| 179 | + direction: GradientDirection.Right, | ||
| 180 | + colors: [[0xffffff, 0.0],[0xffffff, 0.8], [0xf9f9f9, 1.0]] | ||
| 181 | + }) | ||
| 182 | + } | ||
| 183 | + .width(276) | ||
| 184 | + .height(150) | ||
| 185 | + .margin({ right: 10 }) | ||
| 186 | + .borderWidth(1) | ||
| 187 | + .borderColor($r('app.color.color_EDEDED')) | ||
| 188 | + .borderRadius($r('app.float.image_border_radius')) | ||
| 189 | + .backgroundColor(0xf9f9f9) | ||
| 190 | + } | ||
| 191 | + .onClick(() => { | ||
| 192 | + console.log('跳转到rmh'); | ||
| 193 | + }) | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + /** | ||
| 197 | + * 关注号主 TODO 这里后面需要抽离 | ||
| 198 | + */ | ||
| 199 | + handleAccention(item: ContentDTO, status: number) { | ||
| 200 | + this.rmhIsAttention = this.rmhIsAttention ? 0 : 1 | ||
| 201 | + return | ||
| 202 | + // 未登录,跳转登录 | ||
| 203 | + if (!HttpUrlUtils.getUserId()) { | ||
| 204 | + WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 205 | + return | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + const params: postInteractAccentionOperateParams = { | ||
| 209 | + attentionUserType: item.rmhInfo?.userType || '', //被关注用户类型(1 普通用户 2 视频号 3 矩阵号) | ||
| 210 | + attentionUserId: item.rmhInfo?.userId || '', // 被关注用户号主id | ||
| 211 | + attentionCreatorId: item.rmhInfo?.rmhId || '', // 被关注用户号主id | ||
| 212 | + // userType: 1, | ||
| 213 | + // userId: '1', // TODO 用户id需要从本地获取 | ||
| 214 | + status: status, | ||
| 215 | + } | ||
| 216 | + PageRepository.postInteractAccentionOperate(params).then(res => { | ||
| 217 | + console.log(TAG, '关注号主==', JSON.stringify(res.data)) | ||
| 218 | + if (status === 1) { | ||
| 219 | + this.rmhIsAttention = 0 | ||
| 220 | + } else { | ||
| 221 | + this.rmhIsAttention = 1 | ||
| 222 | + } | ||
| 223 | + }) | ||
| 224 | + } | ||
| 225 | +} |
-
Please register or login to post a comment