liyubing

Merge remote-tracking branch 'origin/main'

... ... @@ -13,8 +13,20 @@ const LOCAL_CHANNEL: string = '地方频道'
const TAG: string = 'ChannelSubscriptionLayout'
@CustomDialog
struct ChannelDialog {
// @Entry
@Component
struct ChannelSubscriptionLayout {
@State indexSettingArray: string [] = ['推荐', '热点']
//当前选中的频道
@Link currentTopNavSelectedIndex: number;
@Prop homeChannelList: TopNavDTO []
@Prop indexSettingChannelId: number
@Link myChannelList: TopNavDTO []
@Link moreChannelList: TopNavDTO []
@Link localChannelList: TopNavDTO []
@Link channelIds: number []
@StorageLink('channelIds') storeChannelIds: string = ''
@State isShow: boolean = false
@State dragItem: number = -1
private dragRefOffsetX: number = 0
private dragRefOffsetY: number = 0
... ... @@ -25,26 +37,40 @@ struct ChannelDialog {
@State indexSettingTabIndex: number = 0
@State isEditIng: boolean = false
@State currentTopNavSelectedItem: TopNavDTO = {} as TopNavDTO
@Link currentTopNavSelectedIndex: number
@Link myChannelList: TopNavDTO[]
@Link moreChannelList: TopNavDTO[]
@Link localChannelList: TopNavDTO[]
@Link homeChannelList: TopNavDTO[]
@Link indexSettingChannelId: number
controller?: CustomDialogController
confirm: (index: number) => void = () => {
}
changeChannelIndex: (index1: number, index2: number) => void = () => {
}
delChannelItem: (index: number) => void = () => {
}
addChannelItem: (item: TopNavDTO) => void = () => {
changeTab: (index: number) => void = () => {
}
aboutToAppear() {
this.currentTopNavSelectedItem = this.myChannelList[this.currentTopNavSelectedIndex]
}
//交换我的频道数组中的位置
changeChannelIndex(index1: number, index2: number) {
let tmp = this.myChannelList.splice(index1, 1)
let channelIdTmp = this.channelIds.splice(index1, 1)
this.myChannelList.splice(index2, 0, tmp[0])
this.channelIds.splice(index2, 0, channelIdTmp[0])
this.storeChannelIds = this.channelIds.join(',')
}
//删除频道
delChannelItem(index: number){
let item = this.myChannelList.splice(index, 1)[0]
this.channelIds.splice(index, 1)
this.storeChannelIds = this.channelIds.join(',')
if (item.moreChannel === '1') {
this.moreChannelList.unshift(item)
}
if (item.localChannel === '1') {
this.localChannelList.unshift(item)
}
}
// 添加频道
addChannelItem(item: TopNavDTO){
this.channelIds.push(item.channelId)
this.myChannelList.push(item)
this.storeChannelIds = this.channelIds.join(',')
}
itemMove(index: number, newIndex: number): void {
let targetItem = this.myChannelList[newIndex]
if (!(targetItem?.headlinesOn === 1 || targetItem?.movePermitted === 0 || targetItem?.homeChannel === '1')) {
... ... @@ -176,7 +202,8 @@ struct ChannelDialog {
}
}
build() {
@Builder
sheetBuilder() {
Column() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
Image($r('app.media.icon_ren_min_ri_bao'))
... ... @@ -185,7 +212,7 @@ struct ChannelDialog {
Image($r('app.media.close_button'))
.width(24)
.onClick(() => {
this.controller?.close()
this.isShow = false
})
}
.width('100%')
... ... @@ -310,8 +337,8 @@ struct ChannelDialog {
this.delChannelItem(index)
}
} else {
this.confirm(index)
this.controller?.close()
this.changeTab(index)
this.isShow = false
}
}),
LongPressGesture({ repeat: true })
... ... @@ -464,73 +491,6 @@ struct ChannelDialog {
})
.backgroundColor('#ffffff')
}
}
// @Entry
@Component
struct ChannelSubscriptionLayout {
@State indexSettingArray: string [] = ['推荐', '热点']
//当前选中的频道
@Link currentTopNavSelectedIndex: number;
@Prop homeChannelList: TopNavDTO []
@Prop indexSettingChannelId: number
@Link myChannelList: TopNavDTO []
@Link moreChannelList: TopNavDTO []
@Link localChannelList: TopNavDTO []
@Link channelIds: number []
@StorageLink('channelIds') storeChannelIds: string = ''
changeTab: (index: number) => void = () => {
}
//频道弹窗点击切换频道
onAccept = (index: number) => {
this.changeTab(index)
}
//交换我的频道数组中的位置
changeChannelIndex = (index1: number, index2: number) => {
let tmp = this.myChannelList.splice(index1, 1)
let channelIdTmp = this.channelIds.splice(index1, 1)
this.myChannelList.splice(index2, 0, tmp[0])
this.channelIds.splice(index2, 0, channelIdTmp[0])
this.storeChannelIds = this.channelIds.join(',')
}
//删除频道
delChannelItem = (index: number) => {
let item = this.myChannelList.splice(index, 1)[0]
this.channelIds.splice(index, 1)
this.storeChannelIds = this.channelIds.join(',')
if (item.moreChannel === '1') {
this.moreChannelList.unshift(item)
}
if (item.localChannel === '1') {
this.localChannelList.unshift(item)
}
}
// 添加频道
addChannelItem = (item: TopNavDTO) => {
this.channelIds.push(item.channelId)
this.myChannelList.push(item)
this.storeChannelIds = this.channelIds.join(',')
}
dialogController: CustomDialogController | null = new CustomDialogController({
builder: ChannelDialog({
currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
indexSettingChannelId: $indexSettingChannelId,
homeChannelList: $homeChannelList,
myChannelList: $myChannelList,
moreChannelList: $moreChannelList,
localChannelList: $localChannelList,
confirm: this.onAccept,
changeChannelIndex: this.changeChannelIndex,
delChannelItem: this.delChannelItem,
addChannelItem: this.addChannelItem
}),
alignment: DialogAlignment.TopEnd,
customStyle: true,
})
aboutToDisappear() {
this.dialogController = null // 将dialogController置空
}
build() {
Row() {
... ... @@ -542,10 +502,9 @@ struct ChannelSubscriptionLayout {
.justifyContent(FlexAlign.Center)
.backgroundColor(Color.White)
.onClick(() => {
if (this.dialogController != null) {
this.dialogController.open()
}
this.isShow = true
})
.bindContentCover(this.isShow, this.sheetBuilder())
}
}
... ...
... ... @@ -7,6 +7,9 @@ import PageModel from 'wdComponent/src/main/ets/viewmodel/PageModel'
import { ViewType } from 'wdConstant/Index'
import { LiveViewModel } from '../../viewModel/LiveViewModel'
import { TabChatItemComponent } from './TabChatItemComponent'
import { Logger } from 'wdKit';
const TAG: string = 'TabChatComponent';
@Component
export struct TabChatComponent {
... ... @@ -84,6 +87,7 @@ export struct TabChatComponent {
20,)
.then(
(data) => {
Logger.debug(TAG, `${JSON.stringify(data)}`)
if (data.barrageResponses && data.barrageResponses.length > 0) {
this.pageModel.viewType = ViewType.LOADED;
this.liveChatList.push(...data.barrageResponses)
... ... @@ -98,7 +102,8 @@ export struct TabChatComponent {
}
},
() => {
Logger.debug(TAG, `error`)
this.pageModel.viewType = ViewType.ERROR;
})
}
... ...
import { LiveRoomItemBean } from 'wdBean/Index'
import { LiveRoomItemBean, Action, PhotoListBean, Params } from 'wdBean/Index'
import { StringUtils } from 'wdKit/Index'
// import { Action, LiveRoomItemBean, Params, PhotoListBean } from 'wdBean/Index'
import { WDRouterRule } from 'wdRouter'
import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO'
@Component
export struct TabChatItemComponent {
... ... @@ -14,17 +17,40 @@ export struct TabChatItemComponent {
.borderRadius(90)
.width(24)
.height(24)
Text() {
Span(this.item.senderUserName + ': ')
.fontColor('#666666')
Span(this.item.text)
.fontColor('#222222')
Column() {
Row() {
Text() {
Span(this.item.senderUserName + ': ')
.fontColor('#666666')
Span(this.item.text)
.fontColor('#222222')
}
.margin({ left: 8 })
.lineHeight(20)
.layoutWeight(1)
.fontSize('14fp')
.fontWeight(400)
}
.alignItems(VerticalAlign.Top)
if (this.item.dataType == 'ZH_TEXT_AND_IMAGE_MSG' && this.item.pictureUrls && this.item.pictureUrls.length > 0) {
Image(this.item.pictureUrls[0])
.width(`100%`)
.objectFit(ImageFit.Contain)
.borderRadius(4)
.margin({
top: 10
})
.onClick(() => {
this.gotoMultipleListImagePage(this.item.pictureUrls[0])
})
}
}
.margin({ left: 8 })
.lineHeight(20)
.margin({
left: 8,
right: 8
})
.layoutWeight(1)
.fontSize('14fp')
.fontWeight(400)
.alignItems(HorizontalAlign.Start)
}
.alignItems(VerticalAlign.Top)
.padding({
... ... @@ -32,6 +58,32 @@ export struct TabChatItemComponent {
top: 15,
right: 15
})
}
/**
* 大图列表页
* @param content
* */
gotoMultipleListImagePage(imgUrl: string) {
const photoList: PhotoListBean[] = []
photoList.push({
width: 0,
height: 0,
picPath: imgUrl,
picDesc: ''
})
let taskAction: Action = {
type: 'JUMP_DETAIL_PAGE',
params: {
detailPageType: 18,
extra: {
photoList: photoList,
swiperIndex: 0,
} as ExtraDTO
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
}
aboutToDisappear(): void {
... ...
... ... @@ -9,6 +9,10 @@ import LoadMoreLayout from 'wdComponent/src/main/ets/components/page/LoadMoreLay
import RefreshLayout from 'wdComponent/src/main/ets/components/page/RefreshLayout'
import { StringUtils } from 'wdKit/Index'
import { LiveViewModel } from '../../viewModel/LiveViewModel'
import { Logger } from 'wdKit'
const TAG: string = 'TabLiveComponent';
@Component
export struct TabLiveComponent {
... ... @@ -86,6 +90,7 @@ export struct TabLiveComponent {
20)
.then(
(data) => {
Logger.debug(TAG, `${JSON.stringify(data)}`)
if (data.barrageResponses && data.barrageResponses.length > 0) {
/**
* 在直播聊天添加一条新内容逻辑:
... ... @@ -119,6 +124,8 @@ export struct TabLiveComponent {
}
},
() => {
Logger.debug(TAG, `Error`)
this.pageModel.viewType = ViewType.ERROR;
})
}
... ...
... ... @@ -88,15 +88,15 @@ export struct TabLiveItemComponent {
if (this.item.pictureUrls.length > 1) {
Image(itemSub)
.width(`${100 / this.item.pictureUrls.length}%`)
.height(70)
.objectFit(ImageFit.Auto)
// .height(70)
.objectFit(ImageFit.Contain)
.borderRadius(4)
} else {
Image(itemSub)
.width(`100%`)
// .aspectRatio(this.getAspectRation())
.height(177)
.objectFit(ImageFit.Auto)
// .height(177)
.objectFit(ImageFit.Contain)
.borderRadius(4)
}
}.onClick(() => {
... ...