Showing
1 changed file
with
93 additions
and
89 deletions
| @@ -123,95 +123,99 @@ export struct LiveHorizontalCardComponent { | @@ -123,95 +123,99 @@ export struct LiveHorizontalCardComponent { | ||
| 123 | .margin({ top: 8, bottom: 8 }) | 123 | .margin({ top: 8, bottom: 8 }) |
| 124 | .width(CommonConstants.FULL_WIDTH) | 124 | .width(CommonConstants.FULL_WIDTH) |
| 125 | 125 | ||
| 126 | - // 多个 | ||
| 127 | - if (this.compDTO.operDataList.length >= 2) { | ||
| 128 | - Scroll(this.scroller) { | ||
| 129 | - Row() { | ||
| 130 | - Row() { | ||
| 131 | - ForEach(this.compDTO.operDataList, (item: ContentDTO, index: number) => { | ||
| 132 | - Column() { | ||
| 133 | - Stack({ alignContent: Alignment.BottomEnd }) { | ||
| 134 | - Image(this.loadImg ? item.coverUrl : '') | ||
| 135 | - .backgroundColor(0xf5f5f5) | ||
| 136 | - .aspectRatio(16 / 9) | ||
| 137 | - .width(this.compDTO.operDataList.length == 2 ? 210 : 150) | ||
| 138 | - .borderRadius(4) | ||
| 139 | - .objectFit(ImageFit.Cover) | ||
| 140 | - CardMediaInfo({ | ||
| 141 | - livePeopleNum:false, | ||
| 142 | - contentDTO: item | ||
| 143 | - }) | ||
| 144 | - } | ||
| 145 | - | ||
| 146 | - Text(item.newsTitle) | ||
| 147 | - .fontSize($r("app.float.font_size_14")) | ||
| 148 | - .fontColor($r("app.color.color_212228")) | ||
| 149 | - .fontWeight(400) | ||
| 150 | - .maxLines(2) | ||
| 151 | - .textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。 | ||
| 152 | - .textAlign(TextAlign.Start) | ||
| 153 | - .margin({ top: 8 }) | ||
| 154 | - .width(this.compDTO.operDataList.length == 2 ? 210 : 150) | ||
| 155 | - .height(42) | ||
| 156 | - .lineHeight(21) | ||
| 157 | - } | ||
| 158 | - .padding({ right: 16 }) | ||
| 159 | - .onClick(() => { | ||
| 160 | - InfomationCardClick.track(this.compDTO, item, this.pageId, this.pageName) | ||
| 161 | - if (item.objectType != '0') { | ||
| 162 | - console.log(item.objectId) | ||
| 163 | - this.gotoLive(item) | ||
| 164 | - } | ||
| 165 | - }) | ||
| 166 | - }) | ||
| 167 | - } | ||
| 168 | - if (this.compDTO.operDataList.length >= 2) { | ||
| 169 | - Column() { | ||
| 170 | - if (this.moreWidth > this.initMoreWidth + 2) { | ||
| 171 | - Text(this.moreTips) | ||
| 172 | - .fontSize(8) | ||
| 173 | - .fontColor(0x858585) | ||
| 174 | - .width(8) | ||
| 175 | - } | ||
| 176 | - } | ||
| 177 | - .justifyContent(FlexAlign.Center) | ||
| 178 | - .align(Alignment.Center) | ||
| 179 | - .width(this.moreWidth) | ||
| 180 | - .backgroundColor(0xf1f3f4) | ||
| 181 | - .borderRadius({ topLeft: 5, bottomLeft: 5 }) | ||
| 182 | - .height(this.compDTO.operDataList.length == 2 ? 180 : 146) | ||
| 183 | - } | ||
| 184 | - } | ||
| 185 | - } | ||
| 186 | - .align(Alignment.Start) | ||
| 187 | - .scrollable(this.compDTO.operDataList.length >= 2 ? ScrollDirection.Horizontal : ScrollDirection.None) | ||
| 188 | - .scrollBar(BarState.Off) | ||
| 189 | - .edgeEffect(EdgeEffect.None) | ||
| 190 | - .onReachEnd(() => { | ||
| 191 | - this.edgeAnimation() | ||
| 192 | - }) | ||
| 193 | - .onScrollStop(() => { | ||
| 194 | - // this.resetEdgeAnimation(); | ||
| 195 | - }) | ||
| 196 | - .onScroll((xOffset: number, yOffset: number) => { | ||
| 197 | - if (xOffset < 0) { | ||
| 198 | - this.reverseEdgeAnimation(); | ||
| 199 | - } | ||
| 200 | - }) | ||
| 201 | - .onTouch((event?: TouchEvent) => { | ||
| 202 | - if(event) { | ||
| 203 | - if (event.type === TouchType.Up) { | ||
| 204 | - this.toMore(); | ||
| 205 | - this.resetEdgeAnimation(); | ||
| 206 | - } | ||
| 207 | - } | ||
| 208 | - }) | ||
| 209 | - .width(CommonConstants.FULL_WIDTH) | ||
| 210 | - .height(this.compDTO.operDataList.length == 2 ? 180 : 136) | ||
| 211 | - } else if (this.compDTO.operDataList.length) { | ||
| 212 | - // 一个 | ||
| 213 | - LiveHorizontalCardForOneComponent({ contentDTO: this.compDTO.operDataList[0] }) | ||
| 214 | - } | 126 | + Row(){ |
| 127 | + // 多个 | ||
| 128 | + if (this.compDTO.operDataList.length >= 2) { | ||
| 129 | + Scroll(this.scroller) { | ||
| 130 | + Row() { | ||
| 131 | + Row() { | ||
| 132 | + ForEach(this.compDTO.operDataList, (item: ContentDTO, index: number) => { | ||
| 133 | + Column() { | ||
| 134 | + Stack({ alignContent: Alignment.BottomEnd }) { | ||
| 135 | + Image(this.loadImg ? item.coverUrl : '') | ||
| 136 | + .backgroundColor(0xf5f5f5) | ||
| 137 | + .aspectRatio(16 / 9) | ||
| 138 | + .width(this.compDTO.operDataList.length == 2 ? 210 : 150) | ||
| 139 | + .borderRadius(4) | ||
| 140 | + .objectFit(ImageFit.Cover) | ||
| 141 | + CardMediaInfo({ | ||
| 142 | + livePeopleNum:false, | ||
| 143 | + contentDTO: item | ||
| 144 | + }) | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + Text(item.newsTitle) | ||
| 148 | + .fontSize($r("app.float.font_size_14")) | ||
| 149 | + .fontColor($r("app.color.color_212228")) | ||
| 150 | + .fontWeight(400) | ||
| 151 | + .maxLines(2) | ||
| 152 | + .textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。 | ||
| 153 | + .textAlign(TextAlign.Start) | ||
| 154 | + .margin({ top: 8 }) | ||
| 155 | + .width(this.compDTO.operDataList.length == 2 ? 210 : 150) | ||
| 156 | + .height(42) | ||
| 157 | + .lineHeight(21) | ||
| 158 | + } | ||
| 159 | + .padding({ right: 16 }) | ||
| 160 | + .onClick(() => { | ||
| 161 | + InfomationCardClick.track(this.compDTO, item, this.pageId, this.pageName) | ||
| 162 | + if (item.objectType != '0') { | ||
| 163 | + console.log(item.objectId) | ||
| 164 | + this.gotoLive(item) | ||
| 165 | + } | ||
| 166 | + }) | ||
| 167 | + }) | ||
| 168 | + } | ||
| 169 | + if (this.compDTO.operDataList.length >= 2) { | ||
| 170 | + Column() { | ||
| 171 | + if (this.moreWidth > this.initMoreWidth + 2) { | ||
| 172 | + Text(this.moreTips) | ||
| 173 | + .fontSize(8) | ||
| 174 | + .fontColor(0x858585) | ||
| 175 | + .width(8) | ||
| 176 | + } | ||
| 177 | + } | ||
| 178 | + .justifyContent(FlexAlign.Center) | ||
| 179 | + .align(Alignment.Center) | ||
| 180 | + .width(this.moreWidth) | ||
| 181 | + .backgroundColor(0xf1f3f4) | ||
| 182 | + .borderRadius({ topLeft: 5, bottomLeft: 5 }) | ||
| 183 | + .height(this.compDTO.operDataList.length == 2 ? 180 : 146) | ||
| 184 | + } | ||
| 185 | + } | ||
| 186 | + } | ||
| 187 | + .align(Alignment.Start) | ||
| 188 | + .scrollable(this.compDTO.operDataList.length >= 2 ? ScrollDirection.Horizontal : ScrollDirection.None) | ||
| 189 | + .scrollBar(BarState.Off) | ||
| 190 | + .edgeEffect(EdgeEffect.None) | ||
| 191 | + .onReachEnd(() => { | ||
| 192 | + this.edgeAnimation() | ||
| 193 | + }) | ||
| 194 | + .onScrollStop(() => { | ||
| 195 | + // this.resetEdgeAnimation(); | ||
| 196 | + }) | ||
| 197 | + .onScroll((xOffset: number, yOffset: number) => { | ||
| 198 | + if (xOffset < 0) { | ||
| 199 | + this.reverseEdgeAnimation(); | ||
| 200 | + } | ||
| 201 | + }) | ||
| 202 | + .onTouch((event?: TouchEvent) => { | ||
| 203 | + if(event) { | ||
| 204 | + if (event.type === TouchType.Up) { | ||
| 205 | + this.toMore(); | ||
| 206 | + this.resetEdgeAnimation(); | ||
| 207 | + } | ||
| 208 | + } | ||
| 209 | + }) | ||
| 210 | + .width(CommonConstants.FULL_WIDTH) | ||
| 211 | + .height(this.compDTO.operDataList.length == 2 ? 180 : 136) | ||
| 212 | + } else if (this.compDTO.operDataList.length) { | ||
| 213 | + Row(){ | ||
| 214 | + LiveHorizontalCardForOneComponent({ contentDTO: this.compDTO.operDataList[0] }) | ||
| 215 | + } | ||
| 216 | + } | ||
| 217 | + }.padding({left:10}) | ||
| 218 | + | ||
| 215 | } | 219 | } |
| 216 | // .width(CommonConstants.FULL_WIDTH) | 220 | // .width(CommonConstants.FULL_WIDTH) |
| 217 | .padding({ | 221 | .padding({ |
-
Please register or login to post a comment