张善主

Merge remote-tracking branch 'origin/main'

Showing 48 changed files with 619 additions and 219 deletions
... ... @@ -2,8 +2,8 @@
"app": {
"bundleName": "com.peopledailychina.hosactivity",
"vendor": "$string:app_vendor",
"versionCode": 10000,
"versionName": "1.0.0",
"versionCode": 7370,
"versionName": "7.3.7.0",
"icon": "$media:app_icon",
"label": "$string:app_name"
}
... ...
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="24" height="24" viewBox="0 0 24 24"><g><g></g><g style="opacity:0.5;"><g><path d="M20.314453125,11.330568125C20.314453125,6.360008125,16.285053124999997,2.330566406,11.314453125,2.330566406C6.343893125,2.330566406,2.314453125,6.360008125,2.314453125,11.330568125C2.314453125,13.375078125,2.999354125,15.317678125,4.237673125,16.891578125000002C5.933093125,19.046478125,8.518933125,20.330578125,11.314453125,20.330578125C16.285053124999997,20.330578125,20.314453125,16.301178125,20.314453125,11.330568125ZM4.314453125,11.330568125C4.314453125,7.464568125,7.448463125,4.330568125,11.314453125,4.330568125C15.180453125,4.330568125,18.314453125,7.464568125,18.314453125,11.330568125C18.314453125,15.196578125,15.180453125,18.330578125,11.314453125,18.330578125C9.138813125,18.330578125,7.129653125,17.332878125,5.8094931249999995,15.654978125C4.846133125,14.430478125,4.314453125,12.922378125,4.314453125,11.330568125Z" fill-rule="evenodd" fill="#8794A3" fill-opacity="1"/></g><g transform="matrix(0.7071067690849304,0.7071067690849304,-0.7071067690849304,0.7071067690849304,16.41416933434084,-7.627309776376933)" style="opacity:0.800000011920929;"><path d="M17.6140625,16L22.7906525,16C22.9393225,16,23.0360225,16.156463,22.9695325,16.289443L22.1695325,17.88944C22.1356625,17.9572,22.0664025,18,21.9906525,18L17.6140625,18C17.5036056,18,17.4140625,17.91046,17.4140625,17.8L17.4140625,16.2C17.4140625,16.0895431,17.5036056,16,17.6140625,16" fill="#8794A3" fill-opacity="0.800000011920929"/></g></g></g></svg>
\ No newline at end of file
... ...
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="24" height="24" viewBox="0 0 24 24"><g><g></g><g style="opacity:0.5;"><g><path d="M20.314453125,11.330568125C20.314453125,6.360008125,16.285053124999997,2.330566406,11.314453125,2.330566406C6.343893125,2.330566406,2.314453125,6.360008125,2.314453125,11.330568125C2.314453125,13.375078125,2.999354125,15.317678125,4.237673125,16.891578125000002C5.933093125,19.046478125,8.518933125,20.330578125,11.314453125,20.330578125C16.285053124999997,20.330578125,20.314453125,16.301178125,20.314453125,11.330568125ZM4.314453125,11.330568125C4.314453125,7.464568125,7.448463125,4.330568125,11.314453125,4.330568125C15.180453125,4.330568125,18.314453125,7.464568125,18.314453125,11.330568125C18.314453125,15.196578125,15.180453125,18.330578125,11.314453125,18.330578125C9.138813125,18.330578125,7.129653125,17.332878125,5.8094931249999995,15.654978125C4.846133125,14.430478125,4.314453125,12.922378125,4.314453125,11.330568125Z" fill-rule="evenodd" fill="#000000" fill-opacity="1"/></g><g transform="matrix(0.7071067690849304,0.7071067690849304,-0.7071067690849304,0.7071067690849304,16.41416933434084,-7.627309776376933)" style="opacity:0.800000011920929;"><path d="M17.6140625,16L22.7906525,16C22.9393225,16,23.0360225,16.156463,22.9695325,16.289443L22.1695325,17.88944C22.1356625,17.9572,22.0664025,18,21.9906525,18L17.6140625,18C17.5036056,18,17.4140625,17.91046,17.4140625,17.8L17.4140625,16.2C17.4140625,16.0895431,17.5036056,16,17.6140625,16" fill="#000000" fill-opacity="0.800000011920929"/></g></g></g></svg>
\ No newline at end of file
... ...
... ... @@ -40,6 +40,9 @@ instance.interceptors.request.use(
// 公共请求参数
// config.params.key = key
Logger.debug('HttpRequest', 'request: ' + config.url)
// TODO 临时打印token,测试token失效。待删除
Logger.debug('HttpRequest', 'request token: ' + config?.headers?.get('RMRB-X-TOKEN'))
Logger.debug('HttpRequest', 'request cookie: ' + config?.headers?.get('cookie'))
return config;
},
(error: AxiosError) => {
... ...
... ... @@ -29,10 +29,11 @@ export class HttpBizUtil {
// 403:临时token;406:强制下线、封禁、清空登录信息还要跳转登录页面
if (res.code == 403 || res.code == 406) {
HttpBizUtil.refreshToken().then((token: string) => {
if (headers) {
headers.replace('RMRB-X-TOKEN', token)
headers.replace('cookie', 'RMRB-X-TOKEN=' + token)
if (!headers) {
headers = new HashMap()
}
headers?.replace('RMRB-X-TOKEN', token)
headers?.replace('cookie', 'RMRB-X-TOKEN=' + token)
Logger.debug(TAG, 'get again send: ' + token)
// refreshToken为空场景不处理,直接请求接口。
WDHttp.get<T>(url, headers).then((againResDTO: T) => {
... ... @@ -67,10 +68,11 @@ export class HttpBizUtil {
Logger.debug(TAG, 'post catch error: ' + JSON.stringify(res))
if (res.code == 403 || res.code == 406) {
HttpBizUtil.refreshToken().then((token: string) => {
if (headers) {
headers.replace('RMRB-X-TOKEN', token)
headers.replace('cookie', 'RMRB-X-TOKEN=' + token)
if (!headers) {
headers = new HashMap()
}
headers?.replace('RMRB-X-TOKEN', token)
headers?.replace('cookie', 'RMRB-X-TOKEN=' + token)
Logger.debug(TAG, 'post again send: ' + token)
// refreshToken为空场景不处理,直接请求接口。
WDHttp.post<T>(url, data, headers).then((againResDTO: T) => {
... ...
... ... @@ -32,6 +32,11 @@ export class HttpUrlUtils {
* 详情页面详情接口
*/
static readonly DETAIL_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail";
/**
* 获取视频直播间拉流地址
*/
static readonly PULL_STREAM_PATH: string = "/api/live-center-video/zh/c/vlive/pull-stream/";
/**
* 批查接口,查询互动相关数据,如收藏数、评论数等
*/
... ... @@ -676,6 +681,15 @@ export class HttpUrlUtils {
return url
}
static getLiveSendBarrageUrl() {
let url = HttpUrlUtils.getHost() + "/api/live-center-message/zh/c/live/message/chat/send"
return url
}
static getLiveTouristSendBarrageUrl() {
let url = HttpUrlUtils.getHost() + "/api/live-center-message/zh/a/live/message/chat/tourist/send"
return url
}
static getAppointmentStatusUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_APPOINTMENT_BATCH_PATH
return url
... ...
... ... @@ -70,6 +70,8 @@ export { NewspaperTimeItemBean } from './src/main/ets/bean/newspaper/NewspaperTi
export { ContentDetailDTO } from './src/main/ets/bean/detail/ContentDetailDTO';
export { GetPullAddressBean } from './src/main/ets/bean/live/GetPullAddressBean';
export { RmhInfoDTO } from './src/main/ets/bean/detail/RmhInfoDTO';
export { UserInfoDTO } from './src/main/ets/bean/detail/UserInfoDTO';
... ...
... ... @@ -102,6 +102,7 @@ export class ContentDTO implements BaseDTO {
liveRoomDataBean : LiveRoomDataBean = {} as LiveRoomDataBean// 批查获取到的直播观看人数
//本地字段:时间轴专题页节点组件时间;【如果开启模糊则显示时间->左右;0:否,1:是】
timeBlurred:number = 0
top:number = 0
static clone(old: ContentDTO): ContentDTO {
let content = new ContentDTO();
... ...
... ... @@ -19,4 +19,9 @@ export interface RmhInfoDTO {
userId: string;
userType: string;
honoraryIcon:string;
/**
* 发布标识,0-cms;1-表示号主发布
*/
rmhPlatform:number
}
... ...
/**
* 获取拉流地址解析类
*/
export class GetPullAddressBean {
origin: OriginBean = new OriginBean();
transCode: Array<TransCodeBean> = new Array;
}
class OriginBean {
expireTime: number = -1;
definition: string = '';
flvUrl: string = '';
m3u8Url: string = '';
rtmpUrl: string = '';
rtsUrl: string = '';
}
export class TransCodeBean {
expireTime: number = -1;
definition: string = '';
flvUrl: string = '';
m3u8Url: string = '';
rtmpUrl: string = '';
rtsUrl: string = '';
}
\ No newline at end of file
... ...
... ... @@ -117,9 +117,6 @@ export struct FollowChildComponent{
}.height('202lpx')
.justifyContent(FlexAlign.Start)
// Text().backgroundColor($r('app.color.color_EDEDED'))
// .width('100%')
// .height('2lpx')
Divider()
.width('100%')
.height('2lpx')
... ... @@ -236,10 +233,6 @@ export struct FollowChildComponent{
}.height('146lpx')
.justifyContent(FlexAlign.Center)
// Text().backgroundColor($r('app.color.color_EDEDED'))
// .width('100%')
// .height('2lpx')
Divider()
.width('100%')
.height('2lpx')
... ...
... ... @@ -95,6 +95,8 @@ export struct FollowFirstTabsComponent{
TabContent(){
FollowSecondTabsComponent({data:$data,firstIndex:index})
}.tabBar(this.TabBuilder(index,item))
.backgroundColor($r('app.color.white'))
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
}, (item: FollowListItem, index: number) => index.toString())
}
.vertical(false)
... ... @@ -108,9 +110,11 @@ export struct FollowFirstTabsComponent{
trackTabFirstClick(this.data[index].directoryName)
})
.width('100%')
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
.layoutWeight(1)
}
}.width('100%')
.height("100%")
}
reloadNetWork(){
... ...
... ... @@ -91,8 +91,6 @@ export struct FollowListDetailUI {
ListItem() {
FollowChildComponent({ data: item, type: this.type })
}
.onClick(() => {
})
}, (item: FollowListDetailItem) => item.creatorId)
//没有更多数据 显示提示
... ... @@ -102,6 +100,7 @@ export struct FollowListDetailUI {
}
}
}
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
.edgeEffect(EdgeEffect.None)
.cachedCount(5)
.padding({ left: '31lpx', right: '31lpx' })
... ... @@ -118,6 +117,7 @@ export struct FollowListDetailUI {
}
}
.width('100%')
.layoutWeight(1)
}
async addFollowStatusObserver() {
... ...
... ... @@ -22,15 +22,35 @@ export struct FollowSecondTabsComponent{
if(this.data != null){
if(this.data[this.firstIndex].children == null || this.data[this.firstIndex].children.length == 0){
FollowListDetailUI({creatorDirectoryId:this.data[this.firstIndex].id,type:1})
.layoutWeight(1)
Stack({ alignContent: Alignment.Top }){
Row()
.width("100%")
.height("100%")
.backgroundColor($r('app.color.color_transparent'))
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
FollowListDetailUI({creatorDirectoryId:this.data[this.firstIndex].id,type:1})
.height("100%")
.width("100%")
}.width("100%")
.layoutWeight(1)
}else{
this.FollowSecondUI()
Stack({ alignContent: Alignment.Top }){
Row()
.width("100%")
.height("100%")
.backgroundColor($r('app.color.color_transparent'))
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
this.FollowSecondUI()
}.width("100%")
.layoutWeight(1)
}
}
}
.width('100%')
.layoutWeight(1)
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
}
@Builder FollowSecondUI(){
... ... @@ -51,6 +71,7 @@ export struct FollowSecondTabsComponent{
.scrollBar(BarState.Off)
.height('100%')
}.height('100%')
.backgroundColor($r('app.color.color_F9F9F9'))
.alignItems(HorizontalAlign.Center)
}
.alignItems(VerticalAlign.Top)
... ... @@ -60,8 +81,7 @@ export struct FollowSecondTabsComponent{
ForEach(this.data[this.firstIndex].children, (item: FollowSecondListItem, index: number ) => {
TabContent(){
FollowThirdTabsComponent({data:$data,firstIndex:$firstIndex,secondIndex:index})
}
.backgroundColor($r('app.color.white'))
}.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
}, (item: FollowListItem, index: number) => index.toString())
}
.vertical(true)
... ... @@ -73,6 +93,7 @@ export struct FollowSecondTabsComponent{
.barWidth(0)
.height('100%')
.layoutWeight(1)
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
}.width('100%')
}
... ...
... ... @@ -104,6 +104,8 @@ export struct FollowThirdTabsComponent{
this.currentIndex = index
})
.width('100%')
.layoutWeight(1)
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
}
}
... ...
... ... @@ -23,7 +23,7 @@ struct ChannelSubscriptionLayout {
@Link myChannelList: TopNavDTO []
@Link moreChannelList: TopNavDTO []
@Link localChannelList: TopNavDTO []
@Link channelIds: number []
@State channelIds: number [] = []
@State isShow: boolean = false
@State dragItem: number = -1
private dragRefOffsetX: number = 0
... ... @@ -40,6 +40,9 @@ struct ChannelSubscriptionLayout {
aboutToAppear() {
this.currentTopNavSelectedItem = this.myChannelList[this.currentTopNavSelectedIndex]
this.myChannelList.forEach(item=>{
this.channelIds.push(item.channelId)
})
}
//交换我的频道数组中的位置
... ... @@ -54,7 +57,7 @@ struct ChannelSubscriptionLayout {
delChannelItem(index: number){
let item = this.myChannelList.splice(index, 1)[0]
this.channelIds.splice(index, 1)
AppStorage.setOrCreate('channelIds', this.channelIds.join(','))
AppStorage.setOrCreate('channelIds', JSON.stringify(this.channelIds))
if (item.moreChannel === '1') {
this.moreChannelList.unshift(item)
}
... ...
... ... @@ -29,7 +29,7 @@ struct FollowListPage {
//Tab 详情
FollowFirstTabsComponent({changeIndex:Number(this.curIndex)})
}
.backgroundColor($r('app.color.color_F9F9F9'))
.backgroundColor($r('app.color.white'))
.height('100%')
.width('100%')
}
... ...
... ... @@ -61,13 +61,17 @@ export struct MinePageComponent {
@Prop isMinePage:boolean = false;
//第一次还没创建时候 pageShow 接收不到监听
pageShowForUpdateData(): void {
async pageShowForUpdateData() {
if(this.isMinePage){
this.getMessageData()
let userid = await SPHelper.default.get(SpConstants.USER_ID,"")
if(StringUtils.isNotEmpty(userid)){
this.getMessageData()
}
this.pageShowTime = DateTimeUtils.getTimeStamp()
}
}
pageHideForUpdateData(): void {
pageHideForUpdateData(){
if(this.isMinePage){
this.pageHideTime = DateTimeUtils.getTimeStamp()
let duration = 0
... ... @@ -83,10 +87,9 @@ export struct MinePageComponent {
aboutToAppear(){
this.pageFirstCreateTime = DateTimeUtils.getTimeStamp()
this.getUserLogin()
this.getFunctionData()
this.getUserLogin()
this.addLoginStatusObserver()
this.getMessageData()
}
getMessageData(){
... ... @@ -177,6 +180,7 @@ export struct MinePageComponent {
let userid = await SPHelper.default.get(SpConstants.USER_ID,"")
if(StringUtils.isNotEmpty(userid)){
this.isLogin = true
this.getMessageData()
}else{
this.isLogin = false
}
... ...
... ... @@ -28,7 +28,7 @@ struct PeopleShipHomePage {
// 总滑动空间
scroller: Scroller = new Scroller()
// 顶部透明度
@State topOpacity: number = 0
@Watch('topOpacityChange') @State topOpacity: number = 0
//发布数量
@State publishCount: number = 0
// 是否关注
... ... @@ -42,6 +42,22 @@ struct PeopleShipHomePage {
@State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
@State isConnectNetwork : boolean = NetworkUtil.isNetConnected()
onPageShow(): void {
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff'})
}
onPageHide(): void {
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', })
}
topOpacityChange(){
if(this.topOpacity > 0.8){
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', })
}else{
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff'})
}
}
build() {
if(this.isConnectNetwork){
Stack({ alignContent: Alignment.TopStart }) {
... ... @@ -50,7 +66,8 @@ struct PeopleShipHomePage {
Image($r('app.media.home_page_bg'))
.width('100%')
.height('120vp')
.objectFit(ImageFit.Fill)
.objectFit(ImageFit.Auto)
.objectRepeat(ImageRepeat.NoRepeat)
.backgroundColor(Color.White)
.visibility(this.isLoading ? Visibility.None : Visibility.Visible)
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP])
... ...
... ... @@ -46,8 +46,6 @@ export struct TopNavigationComponentNew {
// 顶导数据
@State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = []
@State indexSettingChannelId: number = AppStorage.get<number>('indexSettingChannelId') || 2002
//我的频道id列表
@State channelIds: number[] = []
//本地缓存频道id列表
@State storageChannelIds: string = AppStorage.get<string>('channelIds') || ''
@State homeChannelList: TopNavDTO[] = []
... ... @@ -192,7 +190,6 @@ export struct TopNavigationComponentNew {
myChannelList: $myChannelList,
moreChannelList: $moreChannelList,
localChannelList: $localChannelList,
channelIds: $channelIds,
changeTab: (index) => {
this.changePage(index)
}
... ... @@ -260,7 +257,7 @@ export struct TopNavigationComponentNew {
.edgeEffect(EdgeEffect.None)
.height($r('app.float.top_tab_bar_height_common'))
.backgroundColor(this.barBackgroundColor)
.margin({top:10})
.margin({ top: 10 })
.onAreaChange((oldValue: Area, newValue: Area) => {
let width = Number.parseFloat(newValue.width.toString())
this.tabsWidth = Number.isNaN(width) ? 0 : width
... ... @@ -342,8 +339,6 @@ export struct TopNavigationComponentNew {
//处理新闻tab顶导频道数据
topNavListHandle() {
let cityName = SPHelper.default.getSync(SpConstants.LOCATION_CITY_NAME, '') as string
let _channelIds: number [] = []
let _myChannelList: TopNavDTO [] = []
let _storageChannelIds: string [] = [] //list1
let defaultMyChannelList: TopNavDTO[] = []
... ... @@ -379,11 +374,7 @@ export struct TopNavigationComponentNew {
}
})
defaultList.unshift(...defaultMyChannelList)
defaultList.forEach((item, index) => {
if (this.storageChannelIds && _storageChannelIds.includes(String(item.channelId))) {
item.myChannel = '1'
}
if (item.channelType === 2) {
if (cityName.includes(item.name)) {
item.myChannel = '1'
... ... @@ -399,32 +390,34 @@ export struct TopNavigationComponentNew {
item.moreChannel = '1'
}
}
if (this.storageChannelIds && _storageChannelIds.includes(String(item.channelId))) {
item.myChannel = '1'
}
//频道分类
if (item.name !== '播报') { //暂时隐藏播报
if (item.myChannel === '1' && !this.storageChannelIds) {
if (item.myChannel === '1') {
_myChannelList.push(item)
_channelIds.push(item.channelId)
}
if (item.moreChannel === '1') {
if (item.moreChannel === '1' && item.myChannel !== '1') {
this.moreChannelList.push(item)
}
if (item.localChannel === '1' && item.myChannel !== '1') {
this.localChannelList.push(item)
}
}
})
if(this.storageChannelIds){
_storageChannelIds.forEach((_item:string)=>{
let index = defaultList.findIndex(ele => Number(_item) === ele.channelId)
if(index > -1){
_myChannelList.push(defaultList[index])
_channelIds.push(defaultList[index].channelId)
}
})
//根据缓存数组排序
if (this.storageChannelIds) {
let sortedyChannelList = _myChannelList.sort((item1, item2) => {
let index1 = this.storageChannelIds.indexOf(String(item1.channelId));
let index2 = this.storageChannelIds.indexOf(String(item2.channelId));
return index1 - index2;
});
_myChannelList = sortedyChannelList
}
if (cityName) {
let index = _myChannelList.findIndex(ele => cityName.includes(ele.name))
const localChannelitem = _myChannelList.splice(index, 1)[0];
... ... @@ -432,7 +425,6 @@ export struct TopNavigationComponentNew {
_myChannelList.splice(3, 0, localChannelitem);
}
this.channelIds = _channelIds
this.myChannelList = _myChannelList
//缓存首页频道
... ... @@ -620,22 +612,22 @@ export struct TopNavigationComponentNew {
})
}
clickMorningEveningPaper(){
clickMorningEveningPaper() {
if (NetworkUtil.isNetConnected()) {
DailyPaperTopicModel.getDailyPaperTopic().then(dailyPaperTopicBean =>{
DailyPaperTopicModel.getDailyPaperTopic().then(dailyPaperTopicBean => {
if (dailyPaperTopicBean && dailyPaperTopicBean.id > 0) {
SPHelper.default.saveSync('dailyPaperTopicPageId', dailyPaperTopicBean.id);
ProcessUtils.gotoMorningEveningPaper()
TrackingButton.click('morning_evening_news_click',TrackConstants.SummaryType.MorningAndEveningNews,TrackConstants.SummaryType.MorningAndEveningNews)
}else {
TrackingButton.click('morning_evening_news_click', TrackConstants.SummaryType.MorningAndEveningNews,
TrackConstants.SummaryType.MorningAndEveningNews)
} else {
ToastUtils.showToast('暂无早晚报信息', 1000)
}
}).catch((err:string) =>{
}).catch((err: string) => {
ToastUtils.showToast('暂无早晚报信息', 1000)
})
} else {
ToastUtils.showToast('网络出小差了,请检查网络后重试', 1000)
}
}
}
\ No newline at end of file
... ...
... ... @@ -276,6 +276,7 @@ export struct PeopleShipHomeArticleListComponent {
let extModel = element.contentExt[0];
contentDTO.openLikes = extModel.openLikes;
contentDTO.openComment = extModel.openComment;
contentDTO.top = extModel.top //是否置顶
}
// 页面
if (contentDTO.appStyle == '2' || contentDTO.appStyle == '13' || contentDTO.appStyle == '20') {
... ...
... ... @@ -40,7 +40,9 @@ export struct PeopleShipHomePageTopComponent {
Image($r('app.media.home_page_bg'))
.width('100%')
.height('48vp')
.objectFit(ImageFit.Fill)
.objectFit(ImageFit.Auto)
.objectRepeat(ImageRepeat.NoRepeat)
.objectFit(ImageFit.Auto)
.backgroundColor(Color.White)
// 头像和名称
Row() {
... ...
... ... @@ -466,7 +466,8 @@ export struct SearchResultContentComponent {
rmhDesc: obj.introduction,
userId: obj.userId,
userType: obj.userType,
honoraryIcon:''
honoraryIcon:'',
rmhPlatform:0
}
if(rem.length>0){
rem.forEach(item=>{
... ... @@ -491,7 +492,8 @@ export struct SearchResultContentComponent {
rmhDesc: item.introduction,
userId: item.userId,
userType: item.userType,
honoraryIcon:''
honoraryIcon:'',
rmhPlatform:0
}
}
})
... ...
... ... @@ -372,6 +372,7 @@ export struct LiveOperRowListView {
this.publishCommentModel.rootCommentId = '-1';
this.publishCommentModel.parentId = '-1';
this.publishCommentModel.placeHolderText = "说两句..."
this.publishCommentModel.commentContent = ""
this.commentInputDialogController?.open();
}
... ... @@ -466,14 +467,20 @@ export struct LiveOperRowListView {
this.showCommentInput = canComment
let mLiveId: string = this.contentDetailData.liveInfo.mlive.mliveId as string
if (!HttpUtils.isLogin() || mLiveId == undefined) {
if (!mLiveId) {
return
}
if (!HttpUtils.isLogin()) {
this.banComment = false
return
}
// 查询是否被禁言
PageRepository.fetchLiveBarrageBan(mLiveId).then(res => {
this.banComment = res.data as boolean
this.showCommentInput = !this.banComment && canComment
if (res.code == 0) {
this.banComment = res.data as boolean
this.showCommentInput = !this.banComment && canComment
}
})
}
}
\ No newline at end of file
... ...
... ... @@ -883,7 +883,8 @@ class MinePageDatasModel{
rmhDesc: obj.introduction,
userId: obj.userId,
userType: obj.userType,
honoraryIcon:''
honoraryIcon:'',
rmhPlatform:0
}
if(rem.length>0){
rem.forEach(item=>{
... ... @@ -908,7 +909,8 @@ class MinePageDatasModel{
rmhDesc: item.introduction,
userId: item.userId,
userType: item.userType,
honoraryIcon:''
honoraryIcon:'',
rmhPlatform:0
}
}
})
... ...
... ... @@ -27,32 +27,60 @@ export class SearchShowRed {
res.push(content);
}
SearchShowRed.formatTitle(html, res, 0, textArr);
console.log('SearchShowRed-res', JSON.stringify(res))
SearchShowRed.formatTitle(
html.replaceAll('<em>', '').replaceAll('</em>', ''),
res,
0,
textArr
);
}
const titleInitRes: titleInitRes = {
titleMarked,
textArr
}
console.log('SearchShowRed-titleInitRes', JSON.stringify(titleInitRes))
return titleInitRes
}
private static formatTitle(textStr: string, matchArr: string[], index: number, textArr: textItem[]) {
const item: string = matchArr[index];
const arr = textStr.split(item);
arr.forEach((str: string, ind: number) => {
if (ind === 0) {
textArr.push({
content: str.replaceAll('<em>', '').replaceAll('</em>', ''),
isRed: false
} as textItem)
textArr.push({
content: item,
isRed: true
})
} else if (ind === 1) {
SearchShowRed.formatTitle(str, matchArr, index + 1, textArr)
}
})
if (!item) {
textArr.push({
content: textStr,
isRed: false
})
return;
}
const ind = textStr.indexOf(item);
const len = item.length;
if (ind === 0) {
textArr.push({
content: item,
isRed: true
})
SearchShowRed.formatTitle(textStr.slice(len), matchArr, index + 1, textArr);
} else if (ind + len === textStr.length) {
textArr.push({
content: textStr.slice(0, ind),
isRed: false
})
textArr.push({
content: item,
isRed: true
})
} else {
textArr.push({
content: textStr.slice(0, ind),
isRed: false
})
textArr.push({
content: item,
isRed: true
})
SearchShowRed.formatTitle(textStr.slice(ind + len), matchArr, index + 1, textArr);
}
}
}
\ No newline at end of file
... ...
import { Logger, ResourcesUtils, EmitterUtils, EmitterEventId } from 'wdKit';
import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { ContentDetailDTO, InteractDataDTO } from 'wdBean';
import { ContentDetailDTO, GetPullAddressBean, InteractDataDTO } from 'wdBean';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
const TAG = 'ContentDetailRequest';
... ... @@ -208,6 +208,19 @@ export class ContentDetailRequest {
return url;
}
static getLiveRoomPullStreamUrl(vliveId:string){
let url = HttpUrlUtils.getHost() + HttpUrlUtils.PULL_STREAM_PATH
url = url + vliveId
return url;
}
static getLiveRoomPullStream(vliveId: string): Promise<ResponseDTO<GetPullAddressBean>> {
let url = ContentDetailRequest.getLiveRoomPullStreamUrl(vliveId)
return WDHttp.get<ResponseDTO<GetPullAddressBean>>(url)
}
static getContentDetail(params: ContentDetailRequestParams): Promise<ResponseDTO<ContentDetailDTO[]>> {
if (mock_switch) {
return ContentDetailRequest.getContentDetailDataMock(getContext());
... ... @@ -216,6 +229,8 @@ export class ContentDetailRequest {
return WDHttp.get<ResponseDTO<ContentDetailDTO[]>>(url)
}
/**
* 查询沉浸式视频频道推荐楼层数据
* @returns
... ...
import { Action, ContentDetailDTO } from 'wdBean/Index';
import { Action, ContentDetailDTO, GetPullAddressBean } from 'wdBean/Index';
import { LiveViewModel } from '../viewModel/LiveViewModel';
import router from '@ohos.router';
... ... @@ -78,14 +78,7 @@ export struct DetailPlayLiveCommon {
this.liveState = detailData.liveInfo?.liveState
if (this.liveState === 'wait' || this.liveLandscape === 'news') {
this.contentDetailData = data[0]
} else if (this.liveLandscape === 'general') {
//todo 不加setTimeOut ,接口返回的数据 就没法让PlayerComponent #@Consume @Watch('updateData') liveDetailsBean 的updateData方法运行
setTimeout(() => {
this.contentDetailData = data[0]
}, 10)
}
this.contentDetailData = data[0]
console.log(TAG, '查询视频详情用于评论展示 openComment:', detailData.openComment)
this.publishCommentModel.targetId = String(detailData?.newsId || '')
... ... @@ -106,7 +99,20 @@ export struct DetailPlayLiveCommon {
if (detailData.liveInfo.liveState == 'end') {
this.playUrl = detailData.liveInfo.vlive[0].replayUri
}
//console.error('XXXXZZZZ', "liveLandscape =" + this.liveLandscape + ' this.liveState =' + this.liveState)
//人民号类型单独获取直播地址
if (detailData.rmhPlatform === 1) {
let vliveId = detailData.liveInfo.vlive[0].vliveId as string
console.error(TAG, 'vliveId==' + vliveId)
this.liveViewModel.getLiveRoomPullAddress(vliveId)
.then((data: GetPullAddressBean) => {
console.log(TAG, ' GetPullAddressBean:', JSON.stringify(data))
})
}
}
})
}
... ...
import { ContentDetailDTO, LiveRoomDataBean } from 'wdBean/Index';
import { ContentDetailDTO, LiveRoomDataBean, LiveRoomItemBean } from 'wdBean/Index';
import { LiveViewModel } from '../viewModel/LiveViewModel';
import { TabComponent } from '../widgets/details/TabComponent';
import { TopPlayComponent } from '../widgets/details/video/TopPlayComponet';
... ... @@ -35,6 +35,10 @@ export struct DetailPlayLivePage {
@Consume contentDetailData: ContentDetailDTO
@Consume publishCommentModel: publishCommentModel
// 尽量不要动属性。用来作为输入了评论之后,值传递
@State lastInputedLiveComment: LiveRoomItemBean = {} as LiveRoomItemBean // 上次输入的直播间消息
@State lastInputedChatComment: LiveRoomItemBean = {} as LiveRoomItemBean // 上次输入的大家聊消息
aboutToAppear(): void {
Logger.info(TAG, `wyj-aboutToAppear`)
... ... @@ -65,7 +69,10 @@ export struct DetailPlayLivePage {
TopPlayComponent({ playerController: this.playerController })
.height(this.displayDirection == DisplayDirection.VERTICAL ? 211 : '100%')
TabComponent({ tabs: this.tabs, changeToTab: this.changeToTab })
TabComponent({ tabs: this.tabs,
changeToTab: this.changeToTab,
lastInputedLiveComment: this.lastInputedLiveComment,
lastInputedChatComment: this.lastInputedChatComment})
.layoutWeight(1)
.visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None)
... ... @@ -79,7 +86,16 @@ export struct DetailPlayLivePage {
},
onCommentInputed: (content) => {
if (content.comment) {
this.liveViewModel.sendComment(content.comment)
this.liveViewModel.sendComment(content.comment, this.contentDetailData).then(result => {
if (!result) {
return
}
if (result.isWall == 1) {
this.lastInputedLiveComment = result
} else {
this.lastInputedChatComment = result
}
})
}
}
}).visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None)
... ...
import { HttpUrlUtils, ResponseDTO } from 'wdNetwork';
import { HttpUrlUtils, HttpUtils, ResponseDTO } from 'wdNetwork';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
import { Logger, ToastUtils, EmitterEventId, EmitterUtils } from 'wdKit';
import { ContentDetailDTO, LiveDetailsBean, LiveRoomBean, LiveRoomDataBean, ReserveItemBean, ValueType } from 'wdBean/Index';
import { Logger, ToastUtils, EmitterEventId, EmitterUtils, SPHelper } from 'wdKit';
import { ContentDetailDTO, LiveDetailsBean, LiveRoomBean, LiveRoomDataBean,
LiveRoomItemBean,
ReserveItemBean, ValueType } from 'wdBean/Index';
import { ContentDetailRequest } from 'wdDetailPlayApi/Index';
import { SpConstants } from 'wdConstant/Index';
const TAG = 'LiveModel'
... ... @@ -266,5 +269,61 @@ export class LiveModel {
})
})
}
liveSendComment(comment: string, content: ContentDetailDTO) {
let tourist: boolean = !HttpUtils.isLogin()
let roomId: string = content.liveInfo.mlive.roomId as string
let liveId: string = content.newsId + ''
let mLiveId: string = content.liveInfo.mlive.mliveId as string
let commentItem: LiveRoomItemBean = {} as LiveRoomItemBean
commentItem.text = comment
commentItem.isWall = 0
commentItem.dataType = "ZH_TEXT_MSG"
let params: Record<string, string | number> = {};
params["liveId"] = liveId
params["mliveId"] = mLiveId
params["roomId"] = roomId
params["title"] = content.newsTitle
params["text"] = comment
if (tourist) {
params["deviceId"] = HttpUtils.getDeviceId()
params["senderUserName"] = SPHelper.default.getSync(SpConstants.TOURIST_NICK_NAME, "") as string
} else {
params["senderUserId"] = SPHelper.default.getSync(SpConstants.USER_ID, "") as string
params["senderAvatarUrl"] = SPHelper.default.getSync(SpConstants.USER_HEAD_PHOTO_URL, "") as string
params["senderUserName"] = SPHelper.default.getSync(SpConstants.USER_NAME, "") as string
commentItem.senderUserAvatarUrl = params["senderAvatarUrl"]
}
commentItem.senderUserName = params["senderUserName"]
params["customizeExpression"] = 0
params["role"] = tourist ? "tourist" : "audience"
commentItem.role = tourist ? "tourist" : "audience"
let url = tourist ? HttpUrlUtils.getLiveTouristSendBarrageUrl() : HttpUrlUtils.getLiveSendBarrageUrl()
return new Promise<SendLiveCommentRes>((success, fail) => {
HttpRequest.post<ResponseDTO<SendLiveCommentInterfaceRes>>(url, params).then((data) => {
let res:SendLiveCommentRes = {
preDisplay: data.data?.preDisplay || false,
tipMessage: data.message,
commentItem: commentItem
}
success(res)
}, (error: Error) => {
fail(error.message)
Logger.debug(TAG + ":error ", error.toString())
})
})
}
}
interface SendLiveCommentInterfaceRes {
preDisplay: boolean
}
export interface SendLiveCommentRes {
preDisplay: boolean
tipMessage: string
commentItem: LiveRoomItemBean
}
\ No newline at end of file
... ...
import { ContentDetailDTO, LiveDetailsBean, LiveRoomBean, LiveRoomDataBean, ValueType } from 'wdBean/Index'
import { ContentDetailDTO,
GetPullAddressBean,
LiveDetailsBean, LiveRoomBean, LiveRoomDataBean,
LiveRoomItemBean,
ValueType } from 'wdBean/Index'
import { ContentDetailRequest } from 'wdDetailPlayApi/Index'
import { Logger } from 'wdKit/Index'
import { ToastUtils } from 'wdKit/src/main/ets/utils/ToastUtils'
import { ResponseDTO } from 'wdNetwork/Index'
import { LiveModel } from './LiveModel'
... ... @@ -24,6 +30,28 @@ export class LiveViewModel {
}
getLiveRoomPullAddress(vliveId:string){
// return new Promise<GetPullAddressBean>((success, fail) => {
// this.liveModel.getContentDetail(contentId, relId, relType).then((data) => {
// success(data)
// }).catch((message: string) => {
// fail(message)
// })
// })
return new Promise<GetPullAddressBean>((success, fail) => {
ContentDetailRequest.getLiveRoomPullStream(vliveId).then(async (resDTO: ResponseDTO<GetPullAddressBean>) => {
console.log(TAG, 'getContentDetail:', JSON.stringify(resDTO.data))
if (resDTO.data) {
success(resDTO.data)
}
}).catch(() => {
fail("数据为空")
})
})
}
//直播详情
getLiveDetails(contentId: string, relId: string, relType: string) {
... ... @@ -111,7 +139,40 @@ export class LiveViewModel {
})
}
sendComment(comment: string) {
// 发送评论
sendComment(comment: string, content: ContentDetailDTO) {
return new Promise<LiveRoomItemBean | undefined>((success, fail) => {
this.liveModel.liveSendComment(comment, content).then((data) => {
Logger.debug(TAG, "发送评论结果: " + JSON.stringify(data))
if (data.preDisplay) {
success(data.commentItem)
} else {
success(undefined)
}
ToastUtils.showToast(data.tipMessage, 3000)
}).catch((message: string) => {
fail(message)
})
})
}
deepCopyLiveRoomItem(item: LiveRoomItemBean) {
return item
let retItem: LiveRoomItemBean = {} as LiveRoomItemBean
retItem.text = item.text
retItem.senderUserAvatarUrl = item.senderUserAvatarUrl
retItem.senderUserName = item.senderUserName
retItem.pictureUrls = item.pictureUrls
retItem.time = item.time
retItem.isWall = item.isWall
retItem.isTop = item.isTop
retItem.dataType = item.dataType
retItem.transcodeImageUrl = item.transcodeImageUrl
retItem.videoUrl = item.videoUrl
retItem.pictureResolutions = item.pictureResolutions
retItem.duration = item.duration
retItem.audioUrl = item.audioUrl
retItem.fullColumnImgUrlDto = item.fullColumnImgUrlDto
return retItem
}
}
\ No newline at end of file
}
... ...
... ... @@ -23,6 +23,7 @@ export struct TabChatComponent {
@State liveChatList: Array<LiveRoomItemBean> = []
@Consume contentDetailData: ContentDetailDTO
@Consume publishCommentModel: publishCommentModel
@Prop @Watch("lastInputedCommentChanged") lastInputedComment: LiveRoomItemBean
aboutToAppear(): void {
this.getLiveChatList()
... ... @@ -46,6 +47,12 @@ export struct TabChatComponent {
})
}
lastInputedCommentChanged(info: string) {
Logger.debug(TAG, "2显示评论》》》: " + JSON.stringify(this.lastInputedComment))
this.liveChatList.push(this.liveViewModel.deepCopyLiveRoomItem(this.lastInputedComment))
this.pageModel.viewType = ViewType.LOADED;
}
build() {
Stack() {
if (this.pageModel.viewType == ViewType.LOADING) {
... ...
import { LiveRoomItemBean, Action, PhotoListBean, Params } from 'wdBean/Index'
import { StringUtils } from 'wdKit/Index'
import { Logger, 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'
const TAG = "TabChatItemComponent"
@Component
export struct TabChatItemComponent {
item: LiveRoomItemBean = {} as LiveRoomItemBean
aboutToAppear(): void {
Logger.debug(TAG, "评论内容: " + this.item.text + " 评论sender: " + this.item.senderUserName)
}
build() {
... ...
import { LiveRoomItemBean } from 'wdBean/Index'
import { TabChatComponent } from './TabChatComponent'
import { TabInfoComponent } from './TabInfoComponent'
import { TabLiveComponent } from './TabLiveComponent'
... ... @@ -13,6 +14,9 @@ export struct TabComponent {
@State currentIndex: number = 0
private controller: TabsController = new TabsController()
@Prop tabs: string[] = []
@Prop lastInputedLiveComment: LiveRoomItemBean // 上次输入的直播间消息
@Prop lastInputedChatComment: LiveRoomItemBean // 上次输入的大家聊消息
aboutToAppear(): void {
}
... ... @@ -34,9 +38,9 @@ export struct TabComponent {
if ('简介' === item) {
TabInfoComponent()
} else if ('直播间' === item) {
TabLiveComponent()
TabLiveComponent({lastInputedComment: this.lastInputedLiveComment})
} else if ('大家聊' === item) {
TabChatComponent()
TabChatComponent({lastInputedComment: this.lastInputedChatComment})
}
}
.backgroundColor('#F5F5F5')
... ... @@ -105,4 +109,4 @@ export struct TabComponent {
aboutToDisappear(): void {
}
}
\ No newline at end of file
}
... ...
... ... @@ -23,11 +23,18 @@ export struct TabLiveComponent {
@Consume @Watch('updateData') contentDetailData: ContentDetailDTO
@State private pageModel: PageModel = new PageModel()
private scroller: Scroller = new Scroller()
@Prop @Watch("lastInputedCommentChanged") lastInputedComment: LiveRoomItemBean
aboutToAppear(): void {
this.getLiveList()
}
lastInputedCommentChanged(info: string) {
Logger.debug(TAG, "1显示评论》》》: " + JSON.stringify(this.lastInputedComment))
this.liveList.push(this.liveViewModel.deepCopyLiveRoomItem(this.lastInputedComment))
this.pageModel.viewType = ViewType.LOADED;
}
build() {
Stack() {
if (this.pageModel.viewType == ViewType.LOADING) {
... ... @@ -200,4 +207,4 @@ export struct TabLiveComponent {
}
this.getLiveList()
}
}
\ No newline at end of file
}
... ...
... ... @@ -52,7 +52,6 @@ export struct TopPlayComponent {
} else if (status === PlayerConstants.STATUS_COMPLETION) {
// 播放完成
} else {
this.isError = false
}
... ...
... ... @@ -10,7 +10,7 @@ import { LiveViewModel } from '../../viewModel/LiveViewModel'
import { ChartItemCompereComponent } from './ChartItemCompereComponent'
import { ChatItemComponent } from './ChartItemComponent'
import { router } from '@kit.ArkUI'
import { EmitterEventId, EmitterUtils, SPHelper, WindowModel } from 'wdKit/Index'
import { EmitterEventId, EmitterUtils, Logger, SPHelper, WindowModel } from 'wdKit/Index'
const TAG = "PlayerCommentComponent"
... ... @@ -28,22 +28,6 @@ export struct PlayerCommentComponent {
async aboutToAppear(): Promise<void> {
this.getLiveChatList()
//注册通知
EmitterUtils.receiveEvent(EmitterEventId.COMMENT_PUBLISH, async (targetId?: string) => {
if (targetId) {
if (targetId == this.publishCommentModel.targetId) {
const info = {
senderUserName: this.publishCommentModel.lastCommentModel.fromUserName,
text: this.publishCommentModel.lastCommentModel.commentContent,
} as LiveRoomItemBean
this.liveChatList.push(info)
this.scroller.scrollEdge(Edge.Bottom)
console.log(TAG, '发布评论:', JSON.stringify(this.publishCommentModel.lastCommentModel))
}
}
})
}
generateRandomString() {
... ... @@ -122,7 +106,14 @@ export struct PlayerCommentComponent {
},
onCommentInputed: (content) => {
if (content.comment) {
this.liveViewModel.sendComment(content.comment)
this.liveViewModel.sendComment(content.comment, this.contentDetailData).then(result => {
if (!result) {
return
}
Logger.debug(TAG, "3显示评论》》》: " + JSON.stringify(result))
this.liveChatList.push(result)
this.scroller.scrollEdge(Edge.Bottom)
})
}
},
onBack: () => {
... ...
... ... @@ -28,7 +28,10 @@ export struct PlayerComponent {
this.playerController?.pause()
}
aboutToAppear(): void {
async aboutToAppear(): Promise<void> {
setTimeout(() => {
this.updateData()
}, 10)
}
async aboutToDisappear(): Promise<void> {
... ... @@ -36,6 +39,7 @@ export struct PlayerComponent {
await this.playerController?.pause()
await this.playerController?.stop()
await this.playerController?.release()
}
updateData() {
... ... @@ -58,6 +62,7 @@ export struct PlayerComponent {
this.liveStreamType = liveStreamType
this.playUrl = playUrl
}
console.error("XXXXZZZZ", 'updateData ----liveState==>' + this.playUrl)
}
build() {
... ... @@ -69,6 +74,7 @@ export struct PlayerComponent {
playerController: this.playerController,
onLoad: () => {
this.isCanplay = true
console.error("XXXXZZZZ", '------2------------')
this.playerController?.firstPlay(this.playUrl);
}
})
... ... @@ -77,7 +83,7 @@ export struct PlayerComponent {
playerController: this.playerController,
onLoad: () => {
this.isCanplay = true
console.error('WDAliPlayerController', '------1------------')
console.error('XXXXZZZZ', '------1------------')
this.playerController?.firstPlay(this.playUrl);
}
}).margin({ top: 195 }).height(211)
... ...
... ... @@ -4,20 +4,24 @@ import { SpConstants } from 'wdConstant/Index'
import { ContentDetailRequest, postInteractAccentionOperateParams } from 'wdDetailPlayApi/Index'
import { NumberFormatterUtils, DateTimeUtils, SPHelper } from 'wdKit/Index'
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
import { router } from '@kit.ArkUI'
const TAG = 'PlayerEndView'
@Preview
@Component
export struct PlayerEndView {
// @Consume liveDetailsBean: LiveDetailsBean
// @Consume liveDetailsBean: LiveDetailsBean
@Consume contentDetailData: ContentDetailDTO
@Consume liveRoomDataBean: LiveRoomDataBean
@State duration: string = ''
@State followStatus: String = '0';
private onBack: () => void = () => {
}
aboutToAppear(): void {
const sn = DateTimeUtils.parseDate(this.contentDetailData.liveInfo.startTime, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN)
const sn =
DateTimeUtils.parseDate(this.contentDetailData.liveInfo.startTime, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN)
const en = DateTimeUtils.parseDate(this.contentDetailData.liveInfo.endTime, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN)
const sd = DateTimeUtils.getDuration(sn, en)
this.duration = DateTimeUtils.secondToTime(sd / 1000)
... ... @@ -113,7 +117,12 @@ export struct PlayerEndView {
.fontWeight(400)
.fontSize(16)
.fontColor(Color.White)
.padding({ top: 8, bottom: 8, left: 122, right: 122 })
.padding({
top: 8,
bottom: 8,
left: 122,
right: 122
})
.backgroundColor(this.followStatus == '0' ? '#FFED2800' : Color.Grey)
.borderRadius(4)
.onClick(() => {
... ... @@ -140,8 +149,30 @@ export struct PlayerEndView {
}
.width(307)
.padding({ top: 40 })
Blank()
// 返回按钮
Row() {
Image($r('app.media.icon_arrow_left_white'))
.width(24)
.height(24)
.aspectRatio(1)
.interpolation(ImageInterpolation.High)
.hoverEffect(HoverEffect.Scale)
.margin({ bottom: 30 ,left:14})
.onClick(() => {
if (this.onBack) {
this.onBack()
}
router.back();
})
}.width('100%')
}
.height('100%')
.width('100%')
}
}
\ No newline at end of file
... ...
... ... @@ -7,12 +7,13 @@ import {
paused,
stopped,
completion,
error} from 'premierlibrary/src/main/ets/com/aliyun/player/IPlayer';
error
} from 'premierlibrary/src/main/ets/com/aliyun/player/IPlayer';
import { initGlobalPlayerSettings, setupPlayerConfig } from '../utils/GlobalSetting';
import prompt from '@ohos.promptAction';
import { PlayerConstants, AVPlayerStatus, Events } from '../constants/PlayerConstants';
import { Logger } from 'wdKit/Index';
import { Logger, StringUtils } from 'wdKit/Index';
const TAG = "WDAliPlayerController"
... ... @@ -26,7 +27,6 @@ const TAG = "WDAliPlayerController"
export class WDAliPlayerController {
private initPromise: Promise<void>;
private avPlayer?: AliPlayer;
// 内部播放器状态
private avPlayerStatus: number = idle
private duration: number = 0;
... ... @@ -38,18 +38,14 @@ export class WDAliPlayerController {
private seekTime: number = 0;
private positionY: number = 0;
private startTime: number = 0
public errorCode?: number
public errorMesage?: string
public onVideoSizeChange?: (width: number, height: number) => void;
public onBufferUpdate?: (buffered: number, duration: number) => void;
public onTimeUpdate?: (position: number, duration: number) => void;
public onVolumeUpdate?: (volume: number) => void;
// 播放完成,决定是否继续播放回调
public continue?: () => void;
// 准备完成,决定是否播放回调。如果不实现,则自动播放
public onCanplay?: () => void;
public onStatusChange?: (status: number) => void;
... ... @@ -94,11 +90,11 @@ export class WDAliPlayerController {
private bindState() {
this.avPlayer?.setOnPreparedListener({
// 当调用play()方法后,会调用
onPrepared: () => {
this.duration = this.avPlayer?.getDuration();
Logger.debug(TAG, "已准备好", `${this.duration}`)
}
onPrepared: () => {
this.duration = this.avPlayer?.getDuration();
Logger.debug(TAG, "已准备好", `${this.duration}`)
}
}
);
this.avPlayer?.setOnRenderingStartListener({
onRenderingStart: () => {
... ... @@ -117,12 +113,12 @@ export class WDAliPlayerController {
onInfo: (bean: InfoBean) => {
if (bean.getCode() === InfoCode.CurrentPosition) {
let position : number = bean.getExtraValue()
let position: number = bean.getExtraValue()
Logger.debug(TAG, `播放进度条:${position}/ ${this.duration}`)
this.initProgress(position);
} else if (bean.getCode() === InfoCode.BufferedPosition) {
let buffer : number = bean.getExtraValue()
let buffer: number = bean.getExtraValue()
if (this.onBufferUpdate) {
this.onBufferUpdate(buffer, this.duration)
}
... ... @@ -140,7 +136,8 @@ export class WDAliPlayerController {
switch (status) {
case initalized: {
//this.avPlayer?.prepare();
} break
}
break
case prepared: {
if (this.startTime) {
this.setSeekTime(this.startTime, SliderChangeMode.Begin);
... ... @@ -154,20 +151,24 @@ export class WDAliPlayerController {
} else {
this.play()
}
} break
}
break
case started: {
this.setBright();
this.status = PlayerConstants.STATUS_START;
this.watchStatus();
} break
}
break
case paused: {
this.status = PlayerConstants.STATUS_PAUSE;
this.watchStatus();
} break
}
break
case stopped: {
this.status = PlayerConstants.STATUS_STOP;
this.watchStatus();
} break
}
break
case completion: {
this.status = PlayerConstants.STATUS_COMPLETION;
this.watchStatus();
... ... @@ -179,7 +180,8 @@ export class WDAliPlayerController {
//this.url = this.avPlayer.url || '';
//this.avPlayer.reset();
}
} break
}
break
case error: {
// 这里拿不到错误信息
// this.status = PlayerConstants.STATUS_ERROR;
... ... @@ -189,7 +191,7 @@ export class WDAliPlayerController {
}
});
this.avPlayer?.setOnErrorListener({
onError:(errorInfo) => {
onError: (errorInfo) => {
Logger.error(TAG, "播放错误", JSON.stringify(errorInfo))
this.errorCode = errorInfo.getCode()
this.errorMesage = errorInfo.getMsg()
... ... @@ -220,21 +222,29 @@ export class WDAliPlayerController {
}
private setAliPlayerURL(url: string) {
let urlSource : UrlSource = new UrlSource()
let urlSource: UrlSource = new UrlSource()
urlSource.setUri(url)
this.avPlayer?.setUrlDataSource(urlSource)
}
private getStatusStringWith(status: number) : string {
private getStatusStringWith(status: number): string {
switch (status) {
case idle: return 'idle'
case initalized: return 'initalized'
case prepared: return 'prepared'
case started: return 'started'
case paused: return 'paused'
case stopped: return 'stopped'
case completion: return 'completion'
case error: return 'error'
case idle:
return 'idle'
case initalized:
return 'initalized'
case prepared:
return 'prepared'
case started:
return 'started'
case paused:
return 'paused'
case stopped:
return 'stopped'
case completion:
return 'completion'
case error:
return 'error'
}
return 'unknow'
}
... ... @@ -256,6 +266,11 @@ export class WDAliPlayerController {
}
async firstPlay(url: string) {
if (StringUtils.isEmpty(url)) {
Logger.error(TAG, "播放链接为空")
return
}
this.url = url;
if (this.avPlayer == null) {
Logger.info(TAG, "等待播放器初始化")
... ... @@ -278,7 +293,7 @@ export class WDAliPlayerController {
this.avPlayer?.setAutoPlay(false)
Logger.debug(TAG, "开始播放", this.url)
Logger.debug(TAG, "开始播放: " + this.url)
this.setAliPlayerURL(this.url);
Logger.info(TAG, "设置SurfaceId: " + this.surfaceId)
... ... @@ -459,4 +474,4 @@ export class WDAliPlayerController {
setStartTime(time?: number) {
this.startTime = time ?? 0;
}
}
\ No newline at end of file
}
... ...
... ... @@ -175,7 +175,7 @@ export class WDPlayerController {
this.pageParam = pageParam
}
if (this.avPlayer == null) {
Logger.error("等待")
console.log("等待")
await this.initPromise;
} else {
if (this.avPlayer.state != AVPlayerStatus.IDLE) {
... ... @@ -188,7 +188,7 @@ export class WDPlayerController {
if (this.avPlayer == null) {
return
}
Logger.error("开始播放", this.url)
console.log("开始播放", this.url)
this.avPlayer.url = this.url;
//加载时长prepareTime
this.creatEndTime = DateTimeUtils.getTimeStamp()
... ...
... ... @@ -3,9 +3,10 @@ import { ProcessUtils, WDRouterRule } from 'wdRouter';
import { WDRouterPage } from 'wdRouter';
import { Logger, SPHelper } from 'wdKit/Index';
import { SpConstants } from 'wdConstant/Index';
import LaunchDataModel from '../viewModel/LaunchDataModel'
import LaunchDataModel, { defaultLaunchModel } from '../viewModel/LaunchDataModel'
import { ParamType, TrackConstants, TrackingButton, TrackingContent } from 'wdTracking/Index';
import { ContentDTO } from 'wdBean/Index';
@Entry
... ... @@ -13,14 +14,11 @@ import { ParamType, TrackConstants, TrackingButton, TrackingContent } from 'wdTr
struct LaunchAdvertisingPage {
@State time: number = 4
timer :number = -1
@State model : LaunchDataModel = {} as LaunchDataModel
pageParam: ParamType = {}
@State defaultModel:defaultLaunchModel = new defaultLaunchModel()
enter() {
// router.replaceUrl({
// url:'pages/MainPage'
// })
WDRouterRule.jumpWithReplacePage(WDRouterPage.mainPage)
clearInterval(this.timer)
}
... ... @@ -28,12 +26,16 @@ struct LaunchAdvertisingPage {
aboutToAppear(): void {
let dataModelStr : string = SPHelper.default.getSync(SpConstants.APP_LAUNCH_PAGE_DATA_MODEL,'') as string
let dataModel : LaunchDataModel = JSON.parse(dataModelStr)
this.model = dataModel
console.log(dataModelStr)
if(this.model.launchAdInfo.length){
this.rebaseDefaultModel(dataModel)
if(this.defaultModel){
//设置倒计时时间
this.time = this.model.launchAdInfo[0].displayDuration
this.time = this.defaultModel.durations
}
this.contentTrackingDict()
this.trackingLaunchShow()
... ... @@ -41,7 +43,6 @@ struct LaunchAdvertisingPage {
onPageShow(){
this.timer = setInterval(() => {
this.time--
if (this.time < 1) {
... ... @@ -49,29 +50,22 @@ struct LaunchAdvertisingPage {
clearInterval(this.timer)
}
},1000)
}
build(){
Column(){
Stack({alignContent:Alignment.Bottom}){
Stack({alignContent:Alignment.Bottom}){
Column(){
if(this.model.launchAdInfo.length && !(this.model.launchAdInfo[0].matInfo.matType == '1')){
if(this.defaultModel.showType === '1'){
//显示视频播放
}else {
//显示图片
Image(this.model.launchAdInfo[0].matInfo.matImageUrl[0])
Image(this.defaultModel.bootScreenUrl)
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
.width('100%')
.height('100%')
// .margin({
// top:'128lpx',left:'48lpx',right:'48lpx',bottom:'128lpx'
// })
}else {
//显示视频播放
}
}
.justifyContent(FlexAlign.Center)
.width('100%')
... ... @@ -83,6 +77,7 @@ struct LaunchAdvertisingPage {
Stack({alignContent:Alignment.TopEnd}){
Button(){
Text(this.time + 's 跳过')
// .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
.fontSize('27lpx')
.fontColor(Color.White)
.margin({left:'28lpx',right:'28lpx'})
... ... @@ -90,7 +85,7 @@ struct LaunchAdvertisingPage {
}
.width('148lpx')
.height('56lpx')
.margin({top:'54lpx',right:'19lpx'})
.margin({top:'10lpx',right:'19lpx'})
.backgroundColor('#80000000')
.onClick(() => {
this.enter()
... ... @@ -99,11 +94,12 @@ struct LaunchAdvertisingPage {
}
.width('100%')
.height('100%')
if(this.model.launchAdInfo.length && !(this.model.launchAdInfo[0].matInfo.startStyle == 1)){
if(this.defaultModel.screenType != '2'){
//底部logo样式 按钮加载在背景展示图上
Button(){
Row(){
Text('点击跳转至详情或第三方应用')
Text('点击跳转至详情')
.fontSize('31lpx')
.fontColor(Color.White)
.margin({
... ... @@ -126,17 +122,16 @@ struct LaunchAdvertisingPage {
})
}
}
}
.width('100%')
.height('84%')
.margin({top:'0'})
if(this.model.launchAdInfo.length && this.model.launchAdInfo[0].matInfo.startStyle == 1){
if(this.defaultModel.screenType === '2'){
//全屏样式,底部无logo 按钮放在原底部logo位置
Button(){
Row(){
Text('点击跳转至详情或第三方应用')
Text('点击跳转至详情')
.fontSize('31lpx')
.fontColor(Color.White)
.margin({
... ... @@ -164,8 +159,8 @@ struct LaunchAdvertisingPage {
.height('154lpx')
.margin({top: '28lpx'})
}
}
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
.width('100%')
.height('100%')
.backgroundColor(Color.White)
... ... @@ -179,25 +174,59 @@ struct LaunchAdvertisingPage {
///埋点
this.trackingLaunchClick()
if(this.model.launchAdInfo.length){
if (this.model.launchAdInfo[0].matInfo.openType == '2') {
if(this.defaultModel.linkUrl.length > 0){
if (this.defaultModel.objectType == '2') {
//端外打开
ProcessUtils.jumpExternalWebPage(this.model.launchAdInfo[0].matInfo.linkUrl)
//clearInterval(this.timer)
ProcessUtils.jumpExternalWebPage(this.defaultModel.linkUrl)
}else {
//端内打开
ProcessUtils.gotoDefaultWebPage(this.model.launchAdInfo[0].matInfo.linkUrl)
//clearInterval(this.timer)
ProcessUtils.gotoDefaultWebPage(this.defaultModel.linkUrl)
}
}else if(this.defaultModel.objectId.length > 0){
let contentDTO :ContentDTO = new ContentDTO();
contentDTO.objectType = this.defaultModel.objectType
contentDTO.objectId = this.defaultModel.objectId
ProcessUtils.processPage(contentDTO)
}
}
rebaseDefaultModel(dataModel : LaunchDataModel){
if (dataModel.launchPageInfo){
this.defaultModel.ID = dataModel.launchPageInfo.ID
this.defaultModel.screenName = dataModel.launchPageInfo.screenName
this.defaultModel.objectType = dataModel.launchPageInfo.objectType
this.defaultModel.objectId = dataModel.launchPageInfo.objectId
this.defaultModel.objectLevel = dataModel.launchPageInfo.objectLevel
this.defaultModel.pageId = dataModel.launchPageInfo.pageId
this.defaultModel.durations = dataModel.launchPageInfo.durations
this.defaultModel.linkUrl = dataModel.launchPageInfo.linkUrl
this.defaultModel.screenType = dataModel.launchPageInfo.screenType
this.defaultModel.bootScreenUrl = dataModel.launchPageInfo.bootScreenUrl
this.defaultModel.bootVideoUrl = dataModel.launchPageInfo.bootScreenUrl
this.defaultModel.bootVideoScreenUrl = dataModel.launchPageInfo.bootVideoScreenUrl
this.defaultModel.showType = dataModel.launchPageInfo.showType
this.defaultModel.isAd = dataModel.launchPageInfo.isAd
this.defaultModel.bottomNavId = dataModel.launchPageInfo.bottomNavId
this.defaultModel.relId = dataModel.launchPageInfo.relId
this.defaultModel.openType = '1'
}else if (dataModel.launchAdInfo.length > 0){
this.defaultModel.ID = dataModel.launchAdInfo[0].ID
this.defaultModel.screenName = dataModel.launchAdInfo[0].matInfo.advTitle
this.defaultModel.durations = dataModel.launchAdInfo[0].displayDuration
this.defaultModel.linkUrl = dataModel.launchAdInfo[0].matInfo.linkUrl
this.defaultModel.screenType = dataModel.launchAdInfo[0].matInfo.startStyle
this.defaultModel.bootScreenUrl = dataModel.launchAdInfo[0].matInfo.matImageUrl[0]
this.defaultModel.bootVideoUrl = dataModel.launchAdInfo[0].matInfo.matVideoUrl
this.defaultModel.showType = dataModel.launchAdInfo[0].matInfo.matType
this.defaultModel.isAd = '1'
}
}
contentTrackingDict(){
this.pageParam = {
'adType':'0',
'adId':this.model.launchAdInfo[0]?.matInfo.id.toString(),
'adName':this.model.launchAdInfo[0]?.matInfo.advTitle,
'adType':this.defaultModel.showType,
'adId':this.defaultModel.ID,
'adName':this.defaultModel.screenName,
'regionName':'0'
}
}
... ...
... ... @@ -10,7 +10,6 @@ import { ParamType, TrackConstants, TrackingContent } from 'wdTracking/Index';
@Component
struct LaunchInterestsHobbiesPage {
@State message: string = 'Hello World'
@State dataArray: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
@State selectCount: number = 0
@State interestsArray: InterestsList[] = []
... ... @@ -20,7 +19,6 @@ struct LaunchInterestsHobbiesPage {
this.requestInterestsData()
}
build() {
Column() {
Row(){
... ...
... ... @@ -113,7 +113,7 @@ struct LaunchPage {
let dataModel : LaunchDataModel = JSON.parse(dataModelStr)
console.log(dataModelStr)
if (dataModel.launchAdInfo.length) {
if (dataModel.launchPageInfo || dataModel.launchAdInfo.length) {
//跳转广告页
this.jumpToAdvertisingPage();
... ...
... ... @@ -56,9 +56,9 @@ export struct VideoChannelPage {
*/
getTopNavFontColor(item: TopNavDTO, index: number): Color | string {
if (item.name === '视频' && this.currentBottomNavInfo.name === '视频') {
return this.currentTopNavSelectedIndex === index ? Color.White : '#e5e0e0'
return this.currentTopNavSelectedIndex === index ? Color.White : '#949494'
} else {
return this.currentTopNavSelectedIndex === index ? Color.Black : "#999999"
return this.currentTopNavSelectedIndex === index ? Color.Black : "#B2B2B2"
}
}
... ... @@ -74,7 +74,7 @@ export struct VideoChannelPage {
@Builder
topNavView() {
Stack({ alignContent: Alignment.TopEnd }) {
Stack({ alignContent: Alignment.End }) {
Row() {
ForEach(this.topNavList, (item: TopNavDTO, index: number) => {
Column() {
... ... @@ -117,7 +117,7 @@ export struct VideoChannelPage {
// 搜索按钮
Row() {
Image($r('app.media.icon_search'))
Image($r(this.currentTopNavSelectedIndex === 0 ? 'app.media.icon_search_gray_svg' :'app.media.icon_search_svg'))
.width('24vp')
.height('24vp')
}
... ...
... ... @@ -8,7 +8,7 @@ export interface NetLayerLaunchOperatModel {
objectId : string //跳转id
objectLevel : string //频道(1:一级频道,2:二级频道),专题(1:普通专题,2:主题专题,3:作者专题 21:文章专题,22:音频专题,23:直播专题,24:话题专题)
pageId : string //跳转页面id,objectType=5,14使用页面跳转
durations : string //展示时长(单位:秒)
durations : number //展示时长(单位:秒)
linkUrl : string //转链接地址【objectType=6,13】
screenType : string // 0, 1 : WDDisplayStyle_Logo 2 : WDDisplayStyle_Full
bootScreenUrl : string //开机屏封面图/视频地址
... ... @@ -17,14 +17,13 @@ export interface NetLayerLaunchOperatModel {
isAd : string //0-非广告,1-是广告
bottomNavId : string //底部导航ID
relId : string //频道/专题内容关系id
}
export interface NetLayerLauncherADMaterialModel{
matType : string //1 video 其他 image
startStyle : number // 1 WDDisplayStyle_Full 全屏样式 其他 WDDisplayStyle_Logo 底部logo样式
startStyle : string // 1 WDDisplayStyle_Full 全屏样式 其他 WDDisplayStyle_Logo 底部logo样式
advTitle : string
id:number
matImageUrl : string[] //取firstObject
... ... @@ -64,4 +63,24 @@ export default interface LaunchDataModel{
launchAdInfo : NetLayerLauncherADInfoModel[]
h5Template : NetLayerLauncherH5TemplateInfoModel[]
}
export class defaultLaunchModel{
ID : string = ''
screenName : string = '' //开机屏名称
objectType : string = '' // WDPublicProgramType 对象类型 0:不跳转,1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,11:图文,12:组图,13:H5新闻,14:频道
objectId : string = '' //跳转id
objectLevel : string = '' //频道(1:一级频道,2:二级频道),专题(1:普通专题,2:主题专题,3:作者专题 21:文章专题,22:音频专题,23:直播专题,24:话题专题)
pageId : string = '' //跳转页面id,objectType=5,14使用页面跳转
durations : number = 0 //展示时长(单位:秒)
linkUrl : string = '' //转链接地址【objectType=6,13】
screenType : string = '' // 0, 1 : WDDisplayStyle_Logo 2 : WDDisplayStyle_Full
bootScreenUrl : string = '' //开机屏封面图/视频地址
bootVideoUrl : string = '' //开机屏封面图/视频地址
bootVideoScreenUrl : string = '' //视频封面地址
showType : string = '' //文件类型WDPublicFileType 2: 视频 其他: 图片
isAd : string = '' //0-非广告,1-是广告
bottomNavId : string = '' //底部导航ID
relId : string = '' //频道/专题内容关系id
openType : string = '' //链接打开方式,0-没链接,不用打开,1-端内打开,2-端外打开
}
\ No newline at end of file
... ...
... ... @@ -18,6 +18,7 @@ import { JSON } from '@kit.ArkTS'
import app from '@system.app'
import { GetuiPush, HWLocationUtils } from 'wdHwAbility/Index'
import { ImageKnife, ImageKnifeGlobal } from '@ohos/imageknife'
import { webview } from '@kit.ArkWeb'
const TAG = "[StartupManager]"
... ... @@ -120,7 +121,8 @@ export class StartupManager {
GetuiPush.sharedInstance().onReachMainPage()
//TODO:
// 提前初始化webview
webview.WebviewController.initializeWebEngine()
resolve()
})
}
... ...