张善主

Merge remote-tracking branch 'origin/main'

Showing 55 changed files with 786 additions and 323 deletions
... ... @@ -38,4 +38,7 @@ export class SpConstants{
//启动页数据存储key
static APP_LAUNCH_PAGE_DATA_MODEL = 'app_launch_page_data_model'
//频道信息流页面左右挂角
static APP_PAGE_CORNER_ADV = 'app_page_corner_adv_'
}
\ No newline at end of file
... ...
... ... @@ -8,5 +8,7 @@ export enum EmitterEventId {
NETWORK_CONNECTED = 2,
// 网络断开,事件id
NETWORK_DISCONNECTED = 3,
// 跳转首页指定频道,事件id
JUMP_HOME_CHANNEL = 4,
}
... ...
export { ResponseDTO } from "./src/main/ets/bean/ResponseDTO"
export { ResposeError } from "./src/main/ets/bean/ResposeError"
export { HttpRequest as WDHttp } from "./src/main/ets/http/HttpRequest"
export { HttpUrlUtils } from "./src/main/ets/http/HttpUrlUtils"
... ...
/**
* 接口返回错误数据封装
*/
export class ResposeError {
code: number = -1;
message: string = '';
static buildError(message: string, code?: number): ResposeError {
let error = new ResposeError()
error.message = message
if (code) {
error.code = code
}
return error;
}
}
\ No newline at end of file
... ...
... ... @@ -6,6 +6,7 @@ import axios, {
InternalAxiosRequestConfig
} from '@ohos/axios';
import { Logger } from 'wdKit/Index';
import { ResposeError } from '../bean/ResposeError';
// import type ResponseDTO from '../models/ResponseDTO';
... ... @@ -99,17 +100,16 @@ instance.interceptors.response.use(// 响应拦截器response类型就是Axios.r
},
(error: AxiosError) => {
// 异常响应
// console.log('全局响应失败拦截')
// console.log(error.request)
// console.log(error.response)
// 429-流量超标;403-临时token;406-token过期,强制下线
// 这里用来处理http常见错误,进行全局提示
let errorBean = new ResposeError()
if (error != null && error.response != null) {
let message = buildErrorMsg(error.response.status);
// 错误消息可以使用全局弹框展示出来
console.log(`httpStatus:${error.response?.status}-${message},请检查网络或联系管理员!`)
errorBean = buildError(error.response.status)
}
return Promise.reject(error);
return Promise.reject(errorBean);
}
);
... ... @@ -161,3 +161,9 @@ function buildErrorMsg(httpStatus: number): string {
}
return message;
}
function buildError(httpStatus: number): ResposeError {
let message = buildErrorMsg(httpStatus);
let error: ResposeError = ResposeError.buildError(message, httpStatus)
return error;
}
... ...
... ... @@ -4,6 +4,7 @@ import HashMap from '@ohos.util.HashMap';
import { ResponseDTO } from '../bean/ResponseDTO';
import { HttpUrlUtils, WDHttp } from '../../../../Index';
import { RefreshTokenRes } from '../bean/RefreshTokenRes';
import { ResposeError } from '../bean/ResposeError';
const TAG: string = 'HttpBizUtil'
... ... @@ -20,14 +21,12 @@ export class HttpBizUtil {
* @returns 返回值
*/
static get<T = ResponseDTO<string>>(url: string, headers?: HashMap<string, string>): Promise<T> {
return new Promise<T>((success, debug) => {
return new Promise<T>((success, error) => {
WDHttp.get<T>(url, headers).then((originalRes: T) => {
try {
let resDTO = originalRes as ResponseDTO
Logger.debug(TAG, 'get: ' + resDTO.code)
Logger.debug(TAG, 'get: ' + resDTO.message)
success(originalRes)
}).catch((res: ResposeError) => {
// 403:临时token;406:强制下线、封禁、清空登录信息还要跳转登录页面
if (resDTO.code == 403 || resDTO.code == 406) {
if (res.code == 403 || res.code == 406) {
HttpBizUtil.refreshToken().then((token: string) => {
if (headers) {
headers.replace('RMRB-X-TOKEN', token)
... ... @@ -39,18 +38,14 @@ export class HttpBizUtil {
Logger.debug(TAG, 'get again: ' + againResDTO)
success(againResDTO)
}).catch((res: object) => {
debug(res)
error(ResposeError.buildError(JSON.stringify(res)))
})
});
} else {
success(originalRes)
}
} catch (e) {
debug(originalRes)
// 非403、406,直接抛出去
Logger.debug(TAG, 'get else: ' + JSON.stringify(res))
error(res)
}
}).catch((res: object) => {
debug(res)
})
})
}
... ... @@ -63,34 +58,31 @@ export class HttpBizUtil {
* @returns 返回值
*/
static post<T = ResponseDTO<string>>(url: string, data?: object, headers?: HashMap<string, string>): Promise<T> {
return new Promise<T>((success, debug) => {
return new Promise<T>((success, error) => {
WDHttp.post<T>(url, data, headers).then((originalRes: T) => {
try {
let resDTO = originalRes as ResponseDTO
Logger.debug(TAG, 'post: ' + resDTO.code)
Logger.debug(TAG, 'post: ' + resDTO.message)
success(originalRes)
}).catch((res: ResposeError) => {
// 403:临时token;406:强制下线、封禁、清空登录信息还要跳转登录页面
if (resDTO.code == 403 || resDTO.code == 406) {
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)
}
Logger.debug(TAG, 'post again send: ' + token)
// refreshToken为空场景不处理,直接请求接口。
WDHttp.post<T>(url, headers).then((againResDTO: T) => {
WDHttp.post<T>(url, data, headers).then((againResDTO: T) => {
Logger.debug(TAG, 'post again success: ' + JSON.stringify(againResDTO))
success(againResDTO)
}).catch((res: object) => {
debug(res)
error(ResposeError.buildError(JSON.stringify(res)))
})
});
} else {
success(originalRes)
// 非403、406,直接抛出去
error(res)
}
} catch (e) {
success(originalRes)
}
}).catch((res: object) => {
debug(res)
})
})
}
... ... @@ -104,9 +96,9 @@ export class HttpBizUtil {
params.set('refreshToken', HttpUrlUtils.getRefreshToken())
params.set('deviceId', HttpUrlUtils.getDeviceId())
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
Logger.debug(TAG, 'refreshToken getRefreshToken: ' + HttpUrlUtils.getRefreshToken())
// // 请求刷新token接口
return new Promise<string>((success, debug) => {
// Logger.debug(TAG, 'refreshToken getRefreshToken: ' + HttpUrlUtils.getRefreshToken())
// 请求刷新token接口
return new Promise<string>((success, error) => {
WDHttp.post<ResponseDTO<RefreshTokenRes>>(url, params, headers).then((resDTO: ResponseDTO<RefreshTokenRes>) => {
let newToken = ''
if (resDTO) {
... ... @@ -126,6 +118,7 @@ export class HttpBizUtil {
Logger.debug(TAG, 'refreshToken refreshToken: ' + resDTO.data.refreshToken)
}
}
Logger.debug(TAG, 'refreshToken last jwtToken: ' + newToken)
success(newToken)
});
})
... ...
... ... @@ -52,7 +52,7 @@ export class WDRouterPage {
// 点播详情页
static detailPlayVodPage = new WDRouterPage("wdDetailPlayVod", "ets/pages/DetailPlayVodPage");
// 直播详情页
static detailPlayLivePage = new WDRouterPage("wdDetailPlayLive", "ets/pages/DetailPlayLivePage");
// static detailPlayLivePage = new WDRouterPage("wdDetailPlayLive", "ets/pages/DetailPlayLivePage");
static detailPlayVLivePage = new WDRouterPage("wdDetailPlayLive", "ets/pages/DetailPlayVLivePage");
static detailPlayLiveCommon = new WDRouterPage("wdDetailPlayLive", "ets/pages/DetailPlayLiveCommon");
// 多图(图集)详情页
... ... @@ -122,4 +122,6 @@ export class WDRouterPage {
static reserveMorePage = new WDRouterPage("wdComponent", "ets/components/page/ReserveMorePage");
//金刚位聚合页
static themeListPage = new WDRouterPage("wdComponent", "ets/components/page/ThemeListPage");
// 栏目页面、频道详情
static columnPage = new WDRouterPage("phone", "ets/pages/column/ColumnPage");
}
... ...
... ... @@ -14,15 +14,19 @@ export class WDRouterRule {
WDRouterRule.jumpWithPage(page, action)
}
static jumpWithPage(page?: WDRouterPage, params?: object) {
static jumpWithPage(page?: WDRouterPage, params?: object, singleMode?: boolean) {
if (page) {
let mode = router.RouterMode.Standard
if (singleMode) {
mode = router.RouterMode.Single
}
if (params) {
// router.pushUrl({ url: 'pages/routerpage2', , params: params })
console.log('page.url()==',page.url(),JSON.stringify(params))
router.pushUrl({ url: page.url(), params: params })
} else {
router.pushUrl({ url: page.url() }).catch((error:Error)=>{
console.log("err",JSON.stringify(error))//100002 uri is not exist
router.pushUrl({ url: page.url() }, mode).catch((error: Error) => {
console.log("err", JSON.stringify(error)) //100002 uri is not exist
})
}
} else {
... ...
import { BottomNavDTO, NavigationBodyDTO, TopNavDTO } from 'wdBean/Index';
import { EmitterEventId, EmitterUtils, StringUtils } from 'wdKit/Index';
import { WDRouterPage } from '../router/WDRouterPage';
import { WDRouterRule } from '../router/WDRouterRule';
import { HashMap } from '@kit.ArkTS';
/**
* 首页、频道相关跳转、处理
*/
export class HomeChannelUtils {
private bottomNavData: NavigationBodyDTO | null = null
setBottomNavData(bottomNavData: NavigationBodyDTO) {
this.bottomNavData = bottomNavData
}
/**
* 切换到指定频道
*
* @param channelId 频道id【顶导id】
* @param pageId 目标页面id
*/
jumpChannelTab(channelId: string, pageId: string) {
// 1、首页所有展示频道遍历,找到目标频道
// 2、频道管理里的,非我的频道所有列表遍历,找到目标频道 【这步去掉,和this.bottomNavData重复了】
// 3、一级频道【1、2里找到目标】->【切换底导、切换频道/新增临时频道】
// 4、二级频道【1、2里都没有找到目标】->【跳转栏目页面-ColumnPageComponent】
// 1. 遍历查找目标channel
if (this.bottomNavData == null || this.bottomNavData.bottomNavList == null || this.bottomNavData.bottomNavList.length <= 0) {
this.jumpColumn(channelId, pageId)
return
}
let bean = new AssignChannelParam()
bean.channelId = channelId
bean.pageId = pageId ? pageId : ''
let bottomNavList = this.bottomNavData.bottomNavList
for (let i = 0; i < bottomNavList.length; i++) {
let bottomNavDTO: BottomNavDTO = bottomNavList[i]
let channelList = bottomNavDTO.topNavChannelList
if (channelList == null || channelList.length <= 0) {
continue
}
for (let j = 0; j < channelList.length; j++) {
let topNavDTO: TopNavDTO = channelList[j]
if (topNavDTO.channelId.toString() === channelId) {
bean.pageId = topNavDTO.pageId.toString()
bean.bottomNavId = bottomNavDTO.id.toString()
break
}
}
}
if (StringUtils.isEmpty(bean.bottomNavId)) {
this.jumpColumn(channelId, pageId)
} else {
this.jumpHomeChannel(bean)
}
}
jumpColumn(channelId: string, pageId: string) {
let params: AssignChannelParam = new AssignChannelParam()
params.pageId = pageId
params.channelId = channelId
WDRouterRule.jumpWithPage(WDRouterPage.columnPage, params)
}
jumpHomeChannel(param: AssignChannelParam) {
// 跳转首页
WDRouterRule.jumpWithPage(WDRouterPage.mainPage, undefined, true)
// 通知切换频道
EmitterUtils.sendEvent(EmitterEventId.JUMP_HOME_CHANNEL, JSON.stringify(param))
}
}
@Observed
export class AssignChannelParam {
pageId: string = '';
channelId: string = '';
bottomNavId: string = '';
}
let homeChannelUtils = new HomeChannelUtils();
export default homeChannelUtils as HomeChannelUtils;
\ No newline at end of file
... ...
... ... @@ -2,14 +2,13 @@ import { Action, ContentDTO, Params, PhotoListBean, commentInfo } from 'wdBean';
import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO';
import { Logger } from 'wdKit';
import { StringUtils } from 'wdKit/src/main/ets/utils/StringUtils';
import { WDRouterRule } from '../router/WDRouterRule';
import { WDRouterRule, WDRouterPage } from '../../../../Index';
import { ContentConstants } from 'wdConstant';
import { common, Want } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { CompAdvMatInfoBean } from 'wdBean/src/main/ets/bean/adv/CompAdvInfoBean';
import { AdvertsBean } from 'wdBean/src/main/ets/bean/adv/AdvertsBean';
// import { LiveModel } from '../viewmodel/LiveModel';
import HomeChannelUtils from './HomeChannelUtils';
const TAG = 'ProcessUtils';
... ... @@ -390,4 +389,23 @@ export class ProcessUtils {
};
WDRouterRule.jumpWithAction(taskAction)
}
/**
* 切换到指定频道
*
* @param channelId 频道id【顶导id】
*/
public static jumpChannelTab(channelId: string, pageId: string) {
HomeChannelUtils.jumpChannelTab(channelId, pageId)
}
/**
* 跳转人民号主页
*@params creatorId 创作者id
*/
public static gotoPeopleShipHomePage(creatorId: string) {
let params = {'creatorId': creatorId} as Record<string, string>;
WDRouterRule.jumpWithPage(WDRouterPage.peopleShipHomePage, params)
}
}
... ...
... ... @@ -145,6 +145,10 @@ function handleJsCallAppInnerLinkMethod(data: Message) {
content.objectType = ContentConstants.TYPE_FOURTEEN
ProcessUtils.processPage(content)
break;
case 'owner_page':
let creatorId = urlParams.get('creatorId') || ''
ProcessUtils.gotoPeopleShipHomePage(creatorId)
break;
default:
break;
}
... ...
... ... @@ -68,14 +68,9 @@ export interface CompAdvBean {
displayPriority: number;
/**
* 展示的次数
*/
showCount: number;
/**
* 页面id
*/
pageId: String ;
pageId: String;
/**
* 开屏广告-显示时长
... ... @@ -97,6 +92,4 @@ export interface CompAdvBean {
displayRound: number;
}
... ...
... ... @@ -18,9 +18,15 @@ export interface LiveRoomItemBean {
role: string
//ZH_TEXT_AND_IMAGE_MSG :图文,ZH_TEXT_MSG:文本,ZH_VIDEO_MSG:视频,ZH_AUDIO_MSG:音频
dataType: string
//视频封面图
transcodeImageUrl: string
//视频地址
videoUrl: string
//图片宽高
pictureResolutions: string[]
//音视频长度
duration: number
//音频地址
audioUrl: string
}
\ No newline at end of file
... ...
... ... @@ -77,5 +77,7 @@ export { LiveCommentComponent } from "./src/main/ets/components/comment/view/Liv
export { WDViewDefaultType } from "./src/main/ets/components/view/EmptyComponent"
export { AudioRowComponent } from "./src/main/ets/components/live/AudioRowComponent"
export { WDLiveViewDefaultType } from "./src/main/ets/components/view/LiveEmptyComponent"
... ...
... ... @@ -18,6 +18,7 @@
"wdRouter": "file:../../commons/wdRouter",
"wdNetwork": "file:../../commons/wdNetwork",
"wdJsBridge": "file:../../commons/wdJsBridge",
"wdDetailPlayApi":"file:../../features/wdDetailPlayApi"
"wdDetailPlayApi":"file:../../features/wdDetailPlayApi",
"wdHwAbility": "file:../../features/wdHwAbility"
}
}
... ...
import { Logger } from 'wdKit';
import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
import { ContentDetailDTO } from 'wdBean';
import media from '@ohos.multimedia.media';
... ... @@ -6,9 +5,10 @@ import { OperRowListView } from './view/OperRowListView';
import { WDPlayerController } from 'wdPlayer/Index';
const TAG = 'AudioDetailComponent'
interface Arr{
image:string,
title:string
interface Arr {
image: string,
title: string
}
@Component
... ... @@ -18,38 +18,34 @@ export struct AudioDetailComponent {
private relType: string = ''
private avPlayer?: media.AVPlayer;
@State playerController: WDPlayerController = new WDPlayerController();
private arr:Arr[]=[
{image:'clock',title:'定时'},
{image:'theOriginal',title:'原文'},
{image:'list',title:'列表'},
private arr: Arr[] = [
{ image: 'clock', title: '定时' },
{ image: 'theOriginal', title: '原文' },
{ image: 'list', title: '列表' },
]
@State contentDetailData: ContentDetailDTO[] = [] as ContentDetailDTO[]//详情
@State coverImage:string = '' //封面图
@State newsTitle:string = '' //标题
@State audioUrl:string = '' //音频路径
@State duration:number = 0 //时长
@State outSetValueOne:number = 40 //播放进度
@State contentDetailData: ContentDetailDTO[] = [] as ContentDetailDTO[] //详情
@State coverImage: string = '' //封面图
@State newsTitle: string = '' //标题
@State audioUrl: string = '' //音频路径
@State duration: number = 0 //时长
@State outSetValueOne: number = 40 //播放进度
@State isPlay: boolean = false
async aboutToAppear() {
await this.getContentDetailData()
this.playerController.firstPlay(this.audioUrl);
this.playerController.onCanplay = () => {
this.playerController.play()
this.isPlay = true
}
this.playerController.onTimeUpdate = (nowSeconds, totalSeconds) =>{
console.log('现在时间',nowSeconds)
console.log('总时间',totalSeconds)
this.playerController.onTimeUpdate = (nowSeconds, totalSeconds) => {
console.log('现在时间', nowSeconds)
console.log('总时间', totalSeconds)
this.outSetValueOne = nowSeconds
this.duration = totalSeconds
}
}
onPageHide() {
this.playerController?.pause();
}
build() {
Row() {
Column() {
... ... @@ -63,6 +59,7 @@ export struct AudioDetailComponent {
.justifyContent(FlexAlign.Center)
.width('100%')
.margin({ top: 64 })
// 标题
Row() {
Text(this.newsTitle)
... ... @@ -75,11 +72,12 @@ export struct AudioDetailComponent {
}
.padding({ left: 34, right: 34 })
.margin({ top: 32 })
// 操作矩阵
Row() {
ForEach(this.arr,(item:Arr)=>{
ForEach(this.arr, (item: Arr) => {
Column() {
Image(item.image=='clock'?$r('app.media.clock_close'):item.image=='theOriginal'?$r('app.media.theOriginal_close'):item.image=='list'?$r('app.media.list_close'):'')
Image(item.image == 'clock' ? $r('app.media.clock_close') : item.image == 'theOriginal' ? $r('app.media.theOriginal_close') : item.image == 'list' ? $r('app.media.list_close') : '')
.width(28)
.height(28)
Text(item.title)
... ... @@ -96,9 +94,9 @@ export struct AudioDetailComponent {
.justifyContent(FlexAlign.SpaceBetween)
.margin({ top: 60 })
Column(){
Column() {
// 进度条
Row(){
Row() {
Slider({
value: this.outSetValueOne,
step: 1
... ... @@ -107,16 +105,17 @@ export struct AudioDetailComponent {
.trackColor('rgba(0,0,0,0.5)')
.selectedColor('#ED2800')
.onChange((value: number, mode: SliderChangeMode) => {
console.log('滑块长度',value)
console.log('滑块长度', value)
this.playerController?.setSeekTime(value, mode);
})
}
.width('100%')
.padding({left:24,right:24})
.margin({top:110})
.padding({ left: 24, right: 24 })
.margin({ top: 110 })
// 播放按钮
Row(){
Column(){
Row() {
Column() {
Image($r('app.media.loop_close'))
.width(24)
.height(24)
... ... @@ -130,26 +129,27 @@ export struct AudioDetailComponent {
Image($r('app.media.Backward_close'))
.width(24)
.height(24)
Stack({ alignContent: Alignment.Center }){
Image(this.isPlay?$r('app.media.suspend'):$r('app.media.playicon'))
Stack({ alignContent: Alignment.Center }) {
Image(this.isPlay ? $r('app.media.suspend') : $r('app.media.playicon'))
.width(32)
.height(32)
}
.padding(28)
.backgroundColor('#4D5258')
.borderRadius(50)
.onClick(()=>{
if(this.isPlay){
.onClick(() => {
if (this.isPlay) {
this.playerController.pause()
}else{
} else {
this.playerController.play()
}
this.isPlay = !this.isPlay
})
Image($r('app.media.fastForward_close'))
.width(24)
.height(24)
Column(){
Column() {
Image($r('app.media.doubleSpeed_close'))
.width(24)
.height(24)
... ... @@ -162,30 +162,32 @@ export struct AudioDetailComponent {
}
.width('100%')
.justifyContent(FlexAlign.SpaceBetween)
.margin({top:56})
.padding({left:32,right:32})
.margin({ top: 56 })
.padding({ left: 32, right: 32 })
}
.layoutWeight(1)
OperRowListView()
}
}
}
private async getContentDetailData() {
try {
let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType)
this.contentDetailData = data;
console.log('音乐详情',JSON.stringify(this.contentDetailData))
console.log('音乐详情', JSON.stringify(this.contentDetailData))
this.newsTitle = this.contentDetailData[0].newsTitle
console.log('标题',JSON.stringify(this.newsTitle))
console.log('标题', JSON.stringify(this.newsTitle))
this.coverImage = this.contentDetailData[0].fullColumnImgUrls[0].url
console.log('封面图',JSON.stringify(this.coverImage))
console.log('封面图', JSON.stringify(this.coverImage))
this.duration = this.contentDetailData[0].audioList[0].duration
console.log('音频时长',JSON.stringify(this.duration))
console.log('音频时长', JSON.stringify(this.duration))
this.audioUrl = this.contentDetailData[0].audioList[0].audioUrl
console.log('音频时长',JSON.stringify(this.audioUrl))
console.log('音频时长', JSON.stringify(this.audioUrl))
} catch (exception) {
console.log('请求失败',JSON.stringify(exception))
console.log('请求失败', JSON.stringify(exception))
}
}
}
\ No newline at end of file
... ...
... ... @@ -2,6 +2,7 @@ import { ContentDTO, FullColumnImgUrlDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant/Index';
import { ProcessUtils } from 'wdRouter';
import { CardSourceInfo } from '../cardCommon/CardSourceInfo'
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
const TAG: string = 'Card4Component';
/**
... ... @@ -81,6 +82,7 @@ export struct Card4Component {
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
//三图
Stack(){
Row() {
GridRow({ gutter: 2 }) {
ForEach(this.contentDTO.fullColumnImgUrls, (item: FullColumnImgUrlDTO, index: number) => {
... ... @@ -100,8 +102,14 @@ export struct Card4Component {
})
}
}
.width('100%')
.width(CommonConstants.FULL_PARENT)
.margin({ top: 8 })
CardMediaInfo({
contentDTO: this.contentDTO
})
}
.width(CommonConstants.FULL_PARENT)
.alignContent(Alignment.BottomEnd)
}
.width('100%')
.justifyContent(FlexAlign.Start)
... ...
... ... @@ -220,7 +220,7 @@ struct ChildCommentItem {
Span(this.item.fromUserName)
if (this.item.toUserName) {
Span(' ')
ImageSpan($r('app.media.comment_reply')).size({ width: 6, height: 9 }).offset({ y: -2.5 })
ImageSpan($r('app.media.comment_reply')).size({ width: 6, height: 9 }).offset({ y: -2.7 })
Span(' ')
Span(this.item.toUserName)
}
... ...
... ... @@ -44,7 +44,8 @@ export struct CommentText {
textContent: this.longMessage,
fontSize: this.fontSize,
fontWeight: this.fontWeight,
constraintWidth: (this.screenWidth - padding)
constraintWidth: (this.screenWidth - padding),
wordBreak:WordBreak.BREAK_ALL
})
console.log(`文本宽度为:${this.textWidth}`)
... ... @@ -71,7 +72,8 @@ export struct CommentText {
textContent: string,
fontSize: this.fontSize,
fontWeight: this.fontWeight,
constraintWidth: (this.screenWidth - padding)
constraintWidth: (this.screenWidth - padding),
wordBreak:WordBreak.BREAK_ALL
})
//计算有误差20
... ... @@ -130,6 +132,7 @@ export struct CommentText {
.fontWeight(this.fontWeight)
.fontColor(this.fontColor)
.maxLines(this.lines)
.wordBreak(WordBreak.BREAK_ALL)
// .backgroundColor(Color.Red)
... ...
... ... @@ -7,6 +7,7 @@ import { CustomTitleUI } from '../../reusable/CustomTitleUI'
import { MyCommentDataSource } from '../model/MyCommentDataSource'
import { HttpUtils } from 'wdNetwork/src/main/ets/utils/HttpUtils'
import { HttpUrlUtils } from 'wdNetwork/Index'
import PageModel from '../../../viewmodel/PageModel'
const TAG = 'QualityCommentsComponent';
... ... @@ -14,12 +15,14 @@ const TAG = 'QualityCommentsComponent';
@Preview
@Component
export struct QualityCommentsComponent {
@State private browSingModel: PageModel = new PageModel()
isloading : boolean = false
@State tileOpacity: number = 0;
firstPositionY: number = 0;
bottomSafeHeight: string = AppStorage.get<number>('bottomSafeHeight') + 'px';
topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number;
// @State private browSingModel: commentListModel = new commentListModel()
isloading: boolean = false
lastWindowColor: string = '#ffffff'
currentWindowColor: string = '#FF4202'
@State allDatas: MyCommentDataSource = new MyCommentDataSource();
... ...
... ... @@ -221,7 +221,7 @@ class CommentViewModel {
//子评论
if (element.childComments.length) {
if (element.childComments) {
for (const obj2 of element.childComments) {
if ((obj2.id + '').length > 0) {
commentIDs.push(obj2.id + '')
... ... @@ -267,7 +267,7 @@ class CommentViewModel {
if (element.commentId == commentModel.id) {
commentModel.api_status = element.status
}
if (commentModel.childComments.length) {
if (commentModel.childComments) {
for (const childCommentModel of commentModel.childComments) {
if (element.commentId == childCommentModel.id) {
childCommentModel.api_status = element.status
... ... @@ -310,7 +310,7 @@ class CommentViewModel {
if (element.userId == commentModel.fromUserId) {
commentModel.api_levelHead = element.levelHead
}
if (commentModel.childComments.length) {
if (commentModel.childComments) {
for (const childCommentModel of commentModel.childComments) {
if (element.userId == childCommentModel.fromUserId) {
childCommentModel.api_levelHead = element.levelHead
... ... @@ -356,7 +356,7 @@ class CommentViewModel {
if (element.creatorId == commentModel.fromCreatorId) {
commentModel.api_authIcon = element.authIcon
}
if (commentModel.childComments.length) {
if (commentModel.childComments) {
for (const childCommentModel of commentModel.childComments) {
if (element.creatorId == childCommentModel.fromCreatorId) {
childCommentModel.api_authIcon = element.authIcon
... ...
... ... @@ -4,6 +4,7 @@ import { BreakPointType, Logger } from 'wdKit';
import { CompUtils } from '../../utils/CompUtils';
import { ProcessUtils } from 'wdRouter';
import { EmptyComponent } from '../view/EmptyComponent';
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
const TAG = 'Zh_Carousel_Layout-01';
... ... @@ -73,7 +74,7 @@ export struct ZhCarouselLayout01 {
ForEach(this.compDTO?.operDataList, (item: ContentDTO, index: number) => {
CarouselLayout01CardView({
item: item,
index: index
length: this.compDTO.operDataList.length
})
})
}
... ... @@ -102,6 +103,7 @@ export struct ZhCarouselLayout01 {
console.info("onAnimationEnd, index: " + index)
})
if (this.compDTO?.operDataList.length > 1) {
// 自定义indicator
GridRow({
columns: this.data.totalCount(),
... ... @@ -133,6 +135,7 @@ export struct ZhCarouselLayout01 {
})
.alignItems(ItemAlign.End)
}
}
.alignContent(Alignment.BottomEnd)
.width(CommonConstants.FULL_WIDTH)
.padding({
... ... @@ -159,7 +162,7 @@ export struct ZhCarouselLayout01 {
@Component
struct CarouselLayout01CardView {
private item: ContentDTO = {} as ContentDTO;
private index: number = -1;
private length: number = 1; // 轮播图数量
build() {
Stack() {
... ... @@ -167,6 +170,7 @@ struct CarouselLayout01CardView {
.width(CommonConstants.FULL_PARENT)
.height(CommonConstants.FULL_PARENT)
.objectFit(ImageFit.Cover)
Row()
.width(CommonConstants.FULL_PARENT)
.height(60)
... ... @@ -174,6 +178,13 @@ struct CarouselLayout01CardView {
direction: GradientDirection.Top, // 渐变方向:to Top/从下往上
colors: [[0x7508111A, 0.0], [0x7508111A, 0.3], [Color.Transparent, 1.0]]
})
Column() {
// 这里用于展示轮播图右上角信息,这里只对直播类型的展示
if (this.item.objectType === '2') {
CardMediaInfo({ contentDTO: this.item })
.width(CommonConstants.FULL_PARENT)
}
Blank()
// 文本信息
Text(`${this.item.corner}${this.item.newsTitle}`)
.width(CommonConstants.FULL_PARENT)
... ... @@ -183,7 +194,7 @@ struct CarouselLayout01CardView {
right: 10
})
.margin({
bottom: 28
bottom: this.length > 1 ? 28 : 10
})
.fontColor(Color.White)
.fontSize($r('app.float.font_size_16'))
... ... @@ -193,6 +204,9 @@ struct CarouselLayout01CardView {
.maxLines(CompUtils.MAX_LINES_2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
.width(CommonConstants.FULL_PARENT)
.height(CommonConstants.FULL_PARENT)
}
.width(CommonConstants.FULL_WIDTH)
.aspectRatio(CompUtils.ASPECT_RATIO_2_1)
.alignContent(Alignment.BottomStart)
... ... @@ -244,7 +258,7 @@ struct indicatorAnimations {
.width('100%')
.alignContent(Alignment.Start)
Text(`0${this.index + 1}`)
Text(this.index + 1 < 10 ? `0${this.index + 1}` : `${this.index + 1}`)
.fontSize(this.centerFontSize)
.fontColor($r('app.color.white'))
.width(16)
... ...
import { DateTimeUtils, Logger } from 'wdKit/Index';
import { WDPlayerController } from 'wdPlayer/Index';
let TAG: string = 'AudioRowComponent'
@Component
export struct AudioRowComponent {
@State playerController: WDPlayerController = new WDPlayerController();
@State audioUrl: string = '' //音频路径
@State duration: number = 0 //时长
@State outSetValueOne: number = 0 //播放进度
@State isPlaying: boolean = false
aboutToAppear(): void {
this.playerController.firstPlay(this.audioUrl)
// this.playerController.onTimeUpdate = (nowSeconds, totalSeconds) => {
// console.log('现在时间', nowSeconds)
// console.log('总时间', totalSeconds)
// this.outSetValueOne = nowSeconds
// this.duration = totalSeconds
// }
}
build() {
Row() {
Image($r('app.media.icon_voice'))
.width(20)
.aspectRatio(1)
.margin({
left: 8,
right: 6
})
.visibility(this.isPlaying ? Visibility.Visible : Visibility.Hidden)
Text(`${DateTimeUtils.getFormattedDuration(this.duration)}`)
.fontColor('#666666')
.fontWeight(400)
.fontSize('14fp')
}
.backgroundColor(Color.White)
.height(36)
.borderRadius(4)
.margin({ top: 8, right: 16 })
.width('100%')
.onClick(() => {
this.isPlaying = !this.isPlaying
this.playerController?.switchPlayOrPause()
})
.onVisibleAreaChange([0.0, 1.0], (isVisible: boolean, currentRatio: number) => {
Logger.debug(TAG, `当前屏幕可见区域大小: currentRatio:' +${currentRatio}`)
// if (isVisible && currentRatio >= 1.0) {
// Logger.debug(TAG, `播放器-播放. currentRatio:' +${currentRatio}`)
// this.playerController?.play()
// }
if (!isVisible && currentRatio <= 0.0) {
Logger.debug(TAG, `播放器-暂停. currentRatio:' +${currentRatio}`)
this.playerController?.pause()
}
})
}
aboutToDisappear(): void {
this.playerController?.release()
}
}
\ No newline at end of file
... ...
... ... @@ -10,6 +10,7 @@ import { QueryListIsFollowedItem } from '../../../viewmodel/QueryListIsFollowedI
import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI';
import { FollowChildComponent } from './FollowChildComponent';
import dataPreferences from '@ohos.data.preferences';
import { EmptyComponent } from '../../view/EmptyComponent';
const TAG = "FollowListDetailUI"
... ... @@ -32,8 +33,9 @@ export struct FollowListDetailUI {
build() {
Column() {
if (this.count === 0) {
ListHasNoMoreDataUI({ style: 2 })
.height('100%')
EmptyComponent({emptyType:14})
.layoutWeight(1)
.width('100%')
} else {
List({ space: 3 }) {
LazyForEach(this.data, (item: FollowListDetailItem, index: number = 0) => {
... ...
... ... @@ -15,6 +15,7 @@ export struct ChildCommentComponent {
@State isExpandParent: boolean = false;
@State isOverLines: boolean = false
@State isOverLinesParent: boolean = false
testText:string = "1,因为读书的人\n是低着头向上看的人\n身处一隅,却能放眼世界\n2,因为读书的人\n总是比不读书的人\n活得有趣一点\n3,因为读书的人\n即使平凡,绝不平庸"
build() {
Column() {
... ... @@ -71,7 +72,7 @@ export struct ChildCommentComponent {
})
}
}
.margin({ bottom: '10lpx' })
.margin({ bottom: '5lpx' })
.width('100%')
.height('108lpx')
.padding({ left: '31lpx', right: '31lpx' })
... ... @@ -93,6 +94,7 @@ export struct ChildCommentComponent {
})
}
}.maxLines(5)
.wordBreak(WordBreak.BREAK_ALL)
.textStyle()
}
}.padding({ left: '31lpx', right: '31lpx' })
... ... @@ -138,6 +140,7 @@ export struct ChildCommentComponent {
})
}
}.maxLines(5)
.wordBreak(WordBreak.BREAK_ALL)
.textAlign(TextAlign.Start)
.width('100%')
}
... ... @@ -243,11 +246,13 @@ export struct ChildCommentComponent {
let measureTruncateWidth: number = measure.measureText({
textContent: truncateContent,
fontSize: px2fp(fontSize),
wordBreak:WordBreak.BREAK_ALL
})
if(type === 1){
measureTruncateWidth = measureTruncateWidth + measure.measureText({
textContent: `@${this.data.parentCommentUserName}:`,
fontSize: px2fp(fontSize),
wordBreak:WordBreak.BREAK_ALL
})
}
let clipStr: string = ''
... ... @@ -255,6 +260,7 @@ export struct ChildCommentComponent {
if (measure.measureText({
textContent: clipStr,
fontSize: px2fp(fontSize),
wordBreak:WordBreak.BREAK_ALL
}) >= textWidth * maxLines - measureTruncateWidth) {
if (type === 0) {
this.isOverLines = true
... ...
... ... @@ -95,7 +95,7 @@ export struct HomePageBottomComponent{
WDRouterRule.jumpWithPage(WDRouterPage.followListPage,params)
})
EmptyComponent({emptyType:4})
EmptyComponent({emptyType:14})
.layoutWeight(1)
.width('100%')
}.layoutWeight(1)
... ...
... ... @@ -5,6 +5,7 @@ import MinePageDatasModel from '../../../model/MinePageDatasModel';
import { FollowListDetailItem } from '../../../viewmodel/FollowListDetailItem';
import { UserFollowListRequestItem } from '../../../viewmodel/UserFollowListRequestItem';
import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI';
import { EmptyComponent } from '../../view/EmptyComponent';
import { FollowChildComponent } from '../follow/FollowChildComponent';
const TAG = "HomePageBottomComponent"
... ... @@ -30,8 +31,37 @@ export struct OtherHomePageBottomFollowComponent{
.backgroundColor($r('app.color.color_EDEDED'))
if(this.count === 0){
ListHasNoMoreDataUI({style:2})
.height('100%')
Column(){
Row(){
Text("关注更多人民号")
.fontWeight('400lpx')
.fontColor($r('app.color.color_222222'))
.lineHeight('38lpx')
.fontSize('27lpx')
.textAlign(TextAlign.Center)
.margin({right:'4lpx'})
Image($r('app.media.arrow_icon_right'))
.objectFit(ImageFit.Auto)
.width('27lpx')
.height('27lpx')
}.height('69lpx')
.width('659lpx')
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.Center)
.backgroundColor($r('app.color.color_F5F5F5'))
.margin({top:'31lpx',bottom:'4lpx'})
.onClick(()=>{
let params: Params = {
pageID: "1"
}
WDRouterRule.jumpWithPage(WDRouterPage.followListPage,params)
})
EmptyComponent({emptyType:14})
.layoutWeight(1)
.width('100%')
}.layoutWeight(1)
.justifyContent(FlexAlign.Start)
}else{
List({ space: 3 }) {
... ...
import { BottomNavi, CommonConstants } from 'wdConstant';
import { BottomNavDTO } from 'wdBean';
import { Logger } from 'wdKit';
import { EmitterEventId, EmitterUtils, Logger } from 'wdKit';
import { TopNavigationComponent } from './TopNavigationComponent';
import { MinePageComponent } from './MinePageComponent';
import { CompUtils } from '../../utils/CompUtils';
import PageViewModel from '../../viewmodel/PageViewModel';
import HomeChannelUtils, { AssignChannelParam } from 'wdRouter/src/main/ets/utils/HomeChannelUtils';
const TAG = 'BottomNavigationComponent';
let storage = LocalStorage.getShared();
... ... @@ -39,6 +40,10 @@ export struct BottomNavigationComponent {
* Component opacity value: 0.6.
*/
readonly SIXTY_OPACITY: number = 0.6;
// 接收指定频道跳转的参数
@State assignChannel: AssignChannelParam = new AssignChannelParam()
// 用于传参到顶导组件,【不用channelParam,主要是时序问题,需要先底导处理完,再延时触发顶导处理】
@State assignChannel1: AssignChannelParam = new AssignChannelParam()
async aboutToAppear() {
Logger.info(TAG, `aboutToAppear currentNavIndex: ${this.currentNavIndex}`);
... ... @@ -49,6 +54,16 @@ export struct BottomNavigationComponent {
bottomNav.bottomNavList = bottomNav.bottomNavList.filter(item => item.name !== '服务');
this.bottomNavList = bottomNav.bottomNavList
}
HomeChannelUtils.setBottomNavData(bottomNav)
EmitterUtils.receiveEvent(EmitterEventId.JUMP_HOME_CHANNEL, (str?: string) => {
Logger.debug(TAG, 'receiveEvent JUMP_HOME_CHANNEL: ' + str)
if (str) {
// 跳转指定频道场景,传参底导id、频道id
this.assignChannel = JSON.parse(str) as AssignChannelParam
this.changeBottomNav()
}
})
}
aboutToDisappear() {
... ... @@ -69,8 +84,8 @@ export struct BottomNavigationComponent {
topNavList: navItem.topNavChannelList.filter(item => item.channelId != 2073),
_currentNavIndex: $currentNavIndex,
currentBottomNavName: navItem.name,
barBackgroundColor: $barBackgroundColor
barBackgroundColor: $barBackgroundColor,
assignChannel: this.assignChannel1
})
}
... ... @@ -145,4 +160,30 @@ export struct BottomNavigationComponent {
// Logger.info(TAG, `onBottomNavigationDataUpdated currentNavIndex: ${this.currentNavIndex},length:${this.bottomNavItemList.length}`);
this.onBottomNavigationIndexChange()
}
/**
* 底导id变化,即指定频道跳转场景
*/
changeBottomNav() {
let index = -1
for (let i = 0; i < this.bottomNavList.length; i++) {
let bottomNavDTO: BottomNavDTO = this.bottomNavList[i]
if (bottomNavDTO.id.toString() === this.assignChannel.bottomNavId) {
index = i
break
}
}
if (index >= 0 && index != this.currentNavIndex) {
// 切底导
this.currentNavIndex = index
}
setTimeout(() => {
// 底导切换后,触发顶导切换
this.assignChannel1 = new AssignChannelParam()
this.assignChannel1.pageId = this.assignChannel.pageId
this.assignChannel1.channelId = this.assignChannel.channelId
this.assignChannel1.bottomNavId = this.assignChannel.bottomNavId
}, 20)
}
}
\ No newline at end of file
... ...
... ... @@ -2,8 +2,7 @@ import { Action, ContentDTO, Params } from 'wdBean';
import { CommonConstants, ConfigConstants, ScreenType } from 'wdConstant';
import { Logger } from 'wdKit';
import { CompUtils } from '../../utils/CompUtils';
import { WDRouterRule } from 'wdRouter';
import { ProcessUtils } from 'wdRouter';
import { ProcessUtils, WDRouterRule } from 'wdRouter';
const TAG: string = 'CardView';
... ... @@ -24,8 +23,7 @@ export struct CarouselLayout01CardView {
Image(this.item.coverUrl)
.width(CommonConstants.FULL_PARENT)
.height(CommonConstants.FULL_PARENT)
.objectFit(ImageFit.Cover)
// .borderRadius($r("app.float.border_radius_6"))
.objectFit(ImageFit.Cover)// .borderRadius($r("app.float.border_radius_6"))
.alignRules({
top: { anchor: '__container__', align: VerticalAlign.Top },
left: { anchor: '__container__', align: HorizontalAlign.Start }
... ... @@ -435,11 +433,10 @@ export struct PaperSingleColumn999CardView {
.fontSize(12)
.fontColor(Color.Gray)
.margin({ left: 22 })
Image($r('app.media.icon_share'))
Image($r('app.media.icon_forward'))
.width(16)
.height(16)
.margin({ left: 10, right: 22, top: 10, bottom: 10 })
.backgroundColor(Color.Brown)
}.width(CommonConstants.FULL_PARENT)
.justifyContent(FlexAlign.SpaceBetween)
}
... ... @@ -447,7 +444,7 @@ export struct PaperSingleColumn999CardView {
.backgroundColor(Color.White)
.margin({ bottom: 5, left: 12, right: 12 })
.borderRadius(4)
.onClick(()=>{
.onClick(() => {
ProcessUtils.processPage(this.item)
})
}
... ...
... ... @@ -65,7 +65,6 @@ export struct PageComponent {
this.pageModel.pullDownRefreshText, this.pageModel.pullDownRefreshHeight)
})
}
LazyForEach(this.pageModel.compList, (compDTO: CompDTO, compIndex: number) => {
ListItem() {
Column() {
... ... @@ -124,9 +123,10 @@ export struct PageComponent {
if (this.pageAdvModel.isShowAds) {
if (this.pageAdvModel.pageCornerAdv.matInfo != null) {
// 页面右边挂角
// 广告中心的挂角广告
this.drawPageCornerAdvView(1, 1 == this.pageAdvModel.isRightAdv)
} else if (this.pageAdvModel.pageCornerContentInfo.advert != null) {
// 展现中心的挂角广告业务
this.drawPageCornerAdvView(2, 1 == this.pageAdvModel.isRightAdv)
}
}
... ...
... ... @@ -5,6 +5,7 @@ import hilog from '@ohos.hilog';
import { PrivacySettingModel } from '../../model/PrivacySettingModel'
import { Params } from 'wdBean';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import { HttpUrlUtils } from 'wdNetwork/Index';
const TAG = 'PrivacySettingPage';
const DiyString = '开启个性化推荐'
... ... @@ -23,6 +24,9 @@ export struct PrivacySettingPage {
}
aboutToAppear() {
if (!HttpUrlUtils.getUserId()) {
this.listData.splice(0, 1);
}
// 获取权限=
// SPHelper.default.save('sdf','sdf');
// this.initListData();
... ... @@ -60,7 +64,7 @@ export struct PrivacySettingPage {
List({ space: '23lpx' }) {
ForEach(this.listData, (item: PrivacySettingModel, index:number) => {
ListItem() {
if (index == 0) {
if (item.privacyName == DiyString) {
getTuiJianCell({ item:item, index:index });
} else {
getArrowCell({ item:item, index:index });
... ... @@ -73,6 +77,8 @@ export struct PrivacySettingPage {
PermissionUtil.reqPermissionsFromUser([item.permissionKey], this).then((res)=>{
item.permission = res;
});
}else{
PermissionUtil.openPermissionsInSystemSettings(this);
}
}
})
... ...
import { Action, CompDTO, Params, TopNavDTO } from 'wdBean';
import { LazyDataSource, Logger } from 'wdKit';
import { LazyDataSource, Logger, StringUtils } from 'wdKit';
import { ProcessUtils } from 'wdRouter';
import { PageComponent } from './PageComponent';
import { ChannelSubscriptionLayout } from './ChannelSubscriptionLayout';
... ... @@ -7,6 +7,7 @@ import { FirstTabTopSearchComponent } from '../search/FirstTabTopSearchComponent
import window from '@ohos.window';
import { WindowModel } from 'wdKit';
import { VideoChannelDetail } from 'wdDetailPlayShortVideo/Index';
import { AssignChannelParam } from 'wdRouter/src/main/ets/utils/HomeChannelUtils';
const TAG = 'TopNavigationComponent';
... ... @@ -49,6 +50,7 @@ export struct TopNavigationComponent {
// 地方频道列表
@State localChannelList: TopNavDTO[] = []
readonly MAX_LINE: number = 1;
@ObjectLink @Watch('onAssignChannelChange') assignChannel: AssignChannelParam
//处理新闻tab顶导频道数据
topNavListHandle() {
... ... @@ -308,4 +310,81 @@ export struct TopNavigationComponent {
onTopNavigationDataUpdated() {
Logger.info(TAG, `onTopNavigationDataUpdated currentTopNavIndex: ${this.currentTopNavSelectedIndex},topNavList.length:${this.topNavList.length}`);
}
/**
* 频道id变化,即指定频道跳转场景
*/
onAssignChannelChange() {
let channelId = this.assignChannel.channelId
let index = -1
if (this._currentNavIndex === 0) {
// 第一个,新闻,先拿我的,再拿其他
index = this.getChannelByMine(channelId)
if (index == -1) {
// 不在我的里,需要临时新增频道展示
let channel = this.getChannelByOthers(channelId)
if (channel) {
this.myChannelList.push(channel)
setTimeout(() => {
this.tabsController.changeIndex(this.myChannelList.length - 1)
}, 20)
}
} else {
// 直接切换
this.tabsController.changeIndex(index)
}
} else {
index = this.getChannelByTopNav(channelId)
if (index > -1) {
// 找到了,直接切换,否则不处理
this.tabsController.changeIndex(index)
}
}
}
/**
* 非新闻,从topNav里拿数据
*/
private getChannelByTopNav(channelId: string) {
for (let i = 0; i < this.topNavList.length; i++) {
let topNavDTO: TopNavDTO = this.topNavList[i]
if (topNavDTO.channelId.toString() === channelId) {
return i
}
}
return -1
}
/**
* 新闻,从myChannelList里拿数据
*/
private getChannelByMine(channelId: string) {
for (let i = 0; i < this.myChannelList.length; i++) {
let topNavDTO: TopNavDTO = this.myChannelList[i]
if (topNavDTO.channelId.toString() === channelId) {
return i
}
}
return -1
}
/**
* 新闻,从其他里拿数据
*/
private getChannelByOthers(channelId: string) {
for (let i = 0; i < this.moreChannelList.length; i++) {
let topNavDTO: TopNavDTO = this.moreChannelList[i]
if (topNavDTO.channelId.toString() === channelId) {
return topNavDTO
}
}
for (let j = 0; j < this.localChannelList.length; j++) {
let topNavDTO: TopNavDTO = this.localChannelList[j]
if (topNavDTO.channelId.toString() === channelId) {
return topNavDTO
}
}
return null
}
}
\ No newline at end of file
... ...
... ... @@ -24,7 +24,7 @@ export struct PeopleShipHomeListComponent {
// 列表
else if (this.publishCount == 0) {
// 无数据展示
EmptyComponent().height(DisplayUtils.getDeviceHeight() - this.topHeight)
EmptyComponent({emptyType: 13}).height(DisplayUtils.getDeviceHeight() - this.topHeight)
} else {
Column() {
Column() {
... ... @@ -46,6 +46,7 @@ export struct PeopleShipHomeListComponent {
.alignItems(VerticalAlign.Bottom)
.width('100%')
}
.height('44vp')
.alignItems(HorizontalAlign.Start)
.width('100%')
... ... @@ -109,8 +110,8 @@ export struct PeopleShipHomeListComponent {
.justifyContent(FlexAlign.Center)
.constraintSize({ minWidth: 35 })
.margin({
left: '16vp',
right: '16vp'
left: index == 0 ? '16vp' : '10vp',
right: index == this.tabArr.length - 1 ? '16vp' : '10vp'
})
.height('44vp')
.onClick(() => {
... ...
... ... @@ -6,6 +6,7 @@ import { Logger } from 'wdKit'
import { PeopleShipHomePageDataModel } from '../../viewmodel/PeopleShipHomePageDataModel'
import { InfluenceData, PeopleShipUserDetailData } from 'wdBean'
import { PeopleShipHomeAttentionComponent } from './PeopleShipHomeAttentionComponent'
import { HWLocationUtils } from 'wdHwAbility'
@Component
... ... @@ -29,6 +30,7 @@ export struct PeopleShipHomePageTopComponent {
@State topFixedHeight: number = 320
@State lineInNum: number = 1
@Link topHeight: number
@State provinceName: string = ''
build() {
Column() {
Stack({ alignContent: Alignment.TopStart}) {
... ... @@ -136,7 +138,6 @@ export struct PeopleShipHomePageTopComponent {
.margin({
left: '16vp',
right: '16vp',
bottom: '10vp'
})
}.width('100%')
.alignItems(VerticalAlign.Top)
... ... @@ -151,14 +152,14 @@ export struct PeopleShipHomePageTopComponent {
.margin({
left: '16vp',
right: '16vp',
bottom: '10vp'
})
}.width('100%')
.alignItems(VerticalAlign.Top)
}
// IP归属地
Text(`IP归属地:${this.detailModel.region}`)
if (this.provinceName && this.provinceName.length > 0) {
Text(`IP归属地:${this.provinceName}`)
.lineHeight('18vp')
.fontSize($r('app.float.vp_12'))
.fontColor($r('app.color.color_999999'))
... ... @@ -168,7 +169,9 @@ export struct PeopleShipHomePageTopComponent {
.margin({
right: '16vp',
left: '16vp',
top: '10vp'
})
}
// 发布, 粉丝, 影响力
Row() {
... ... @@ -294,7 +297,8 @@ export struct PeopleShipHomePageTopComponent {
})
}
onIntroductionUpdated() {
async onIntroductionUpdated() {
if (this.content.length == 0 && this.detailModel.introduction ) {
this.lineInNum = this.getTextLineNum(`简介:${this.detailModel.introduction}`, DisplayUtils.getDeviceWidth() - 32, 21, $r('app.float.vp_14'))
if (this.lineInNum > 3) {
... ... @@ -303,7 +307,12 @@ export struct PeopleShipHomePageTopComponent {
}
}
if (this.detailModel) {
this.topFixedHeight = 336
this.topFixedHeight = 308
if (this.detailModel.region && this.detailModel.region.length > 0) {
this.provinceName = this.detailModel.region
}else {
this.provinceName = await this.computeIPRegion(this.detailModel.province)
}
if(this.detailModel.authId == 1 && this.detailModel.categoryAuth.length > 0) {
this.topFixedHeight += this.getTextLineNum(this.detailModel.categoryAuth, DisplayUtils.getDeviceWidth() - 90, 22, $r('app.float.vp_12'))*22
}
... ... @@ -325,6 +334,10 @@ export struct PeopleShipHomePageTopComponent {
}else {
this.topHeight = this.topFixedHeight + (this.isCollapse ? 21*3 : 21 * this.lineInNum )
}
// IP归属地
if (this.provinceName && this.provinceName.length > 0) {
this.topHeight += 28
}
}
}
... ... @@ -335,4 +348,17 @@ export struct PeopleShipHomePageTopComponent {
return `${count}`
}
// 通过省份code获取IP问题
private async computeIPRegion(province: string) {
if (province && province.length) {
try {
let provinceName = await HWLocationUtils.getProvinceName(province) ;
return provinceName
} catch (e) {
return ''
}
}
return ''
}
}
\ No newline at end of file
... ...
... ... @@ -41,6 +41,8 @@ export const enum WDViewDefaultType {
WDViewDefaultType_NoVideo,
/// 16.暂无内容1
WDViewDefaultType_NoContent1,
// 17. 暂无评论快来抢沙发
WDViewDefaultType_NoComment1
}
/**
... ... @@ -210,6 +212,8 @@ export struct EmptyComponent {
contentString = '暂无内容'
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoFollow) {
contentString = '暂无关注'
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoComment1) {
contentString = '暂无评论,快来抢沙发'
}
return contentString
... ... @@ -222,7 +226,7 @@ export struct EmptyComponent {
imageString = $r('app.media.icon_no_collection')
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoMessage) {
imageString = $r('app.media.icon_no_message')
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoComment) {
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoComment || this.emptyType === WDViewDefaultType.WDViewDefaultType_NoComment1) {
imageString = $r('app.media.icon_no_comment')
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoSearchResult) {
imageString = $r('app.media.icon_no_result')
... ... @@ -254,3 +258,4 @@ export struct EmptyComponent {
}
}
}
... ...
... ... @@ -46,38 +46,12 @@ export struct LiveEmptyComponent {
private timer: number = -1
retry: () => void = () => {
}
createTimer() {
if (this.emptyType === 8) {
this.timer = setInterval(() => {
this.timeNum--;
if (this.timeNum === 0) {
clearInterval(this.timer);
}
}, 1000);
}
}
destroyTimer() {
if (this.emptyType === 8) {
clearInterval(this.timer);
}
}
onPageShow(): void {
this.createTimer()
}
aboutToAppear(): void {
this.createTimer()
}
onPageHide(): void {
this.destroyTimer()
}
aboutToDisappear() {
this.destroyTimer()
}
build() {
... ... @@ -98,7 +72,7 @@ export struct LiveEmptyComponent {
// .width('this.EMPTY_IMAGE_WIDTH')
// .height(this.EMPTY_IMAGE_HEIGHT)
Text(this.emptyType !== 8 ? this.buildNoDataTip() : `${this.buildNoDataTip()}(${this.timeNum}s)`)
Text(this.buildNoDataTip())
.fontSize($r('app.float.font_size_14'))
.fontColor('#FF999999')
.fontWeight(FontWeight.Normal)
... ... @@ -107,42 +81,6 @@ export struct LiveEmptyComponent {
.onClick((event: ClickEvent) => {
Logger.info(TAG, `noProgrammeData onClick event?.source: ${event.source}`);
})
if (this.isShowButton()) {
if (this.emptyType !== 15) {
Button('点击重试')
.type(ButtonType.Normal)
.width(80)
.height(28)
.backgroundColor('#fffffff')
.fontColor('#FF666666')
.border({ width: 1 })
.borderColor('#FFEDEDED')
.borderRadius(4)
.fontSize($r('app.float.font_size_12'))
.margin({ top: 16 })
.padding(0)
.onClick(() => {
this.retry()
})
} else {
Button('点击重试')
.type(ButtonType.Normal)
.width(80)
.height(28)
.backgroundColor(Color.Black)
.fontColor('#FFCCCCCC')
.border({ width: 1 })
.borderColor('#4DFFFFFF')
.borderRadius(4)
.fontSize($r('app.float.font_size_12'))
.margin({ top: 16 })
.padding(0)
.onClick(() => {
this.retry()
})
}
}
}
.justifyContent(FlexAlign.Center)
.width(this.emptyWidth)
... ... @@ -172,12 +110,4 @@ export struct LiveEmptyComponent {
}
return imageString
}
isShowButton() {
if (this.emptyType === 1 || this.emptyType === 9 || this.emptyType === 15) {
return true
} else {
return false
}
}
}
... ...
... ... @@ -6,7 +6,6 @@ import { StringUtils } from 'wdKit/Index'
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO'
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
import { LiveModel } from '../../viewmodel/LiveModel'
@Component
export struct LiveHorizontalReservationComponent {
... ... @@ -20,7 +19,7 @@ export struct LiveHorizontalReservationComponent {
.width(3)
.height(16)
.margin({ right: 4 })
Text(StringUtils.isNotEmpty(this?.compDTO?.objectTitle) ? this?.compDTO?.objectTitle : "直播预")
Text(StringUtils.isNotEmpty(this?.compDTO?.objectTitle) ? this?.compDTO?.objectTitle : "直播预")
.fontSize($r("app.float.font_size_17"))
.fontColor($r("app.color.color_222222"))
.fontWeight(600)
... ... @@ -82,6 +81,7 @@ export struct LiveHorizontalReservationComponent {
})
})
}.listDirection(Axis.Horizontal)
.scrollBar(BarState.Off)
.width(CommonConstants.FULL_WIDTH)
.height(this.compDTO.operDataList.length == 2 ? 180 : 136)
} else if (this.compDTO.operDataList.length) {
... ...
import { PageInfoDTO } from 'wdBean/Index';
import { AdvRuleBean, CompAdvBean } from 'wdBean/src/main/ets/bean/adv/AdvsRuleBean';
import { DateTimeUtils, SPHelper } from 'wdKit/Index';
import { ArrayList } from '@kit.ArkTS';
import { SpConstants } from 'wdConstant/Index';
/**
* @Description: 处理页面的广告业务
... ... @@ -18,16 +21,11 @@ export default class PageAdModel {
// 1:右边;2:左边 -> 默认右边
pageCornerContentInfo: AdvRuleBean = {} as AdvRuleBean
// 展现中心业务信息
/**
* 解析广告资源
* @param pageInfo
*/
analysisAdvSource(pageInfo: PageInfoDTO): void {
async analysisAdvSource(pageInfo: PageInfoDTO) {
if (pageInfo.hasAdInfo === 1 && pageInfo.cornersAdv != null) {
// 优先展示展现中心广告
... ... @@ -55,12 +53,26 @@ export default class PageAdModel {
} else if (pageInfo.cornersAdv2 != null && pageInfo.cornersAdv2.length > 0) {
// 广告中心-挂角广告信息
let cornersAdv2 = pageInfo.cornersAdv2
// 获取
let showCompAdvBean = cornersAdv2[0]
if (cornersAdv2.length == 0) {
return
}
// 加工处理广告中心的广告数据
let pageCoreAdvArray = this.treatPageInfoAdsData(cornersAdv2);
let advLength = pageCoreAdvArray.length;
let pageId = pageInfo.id.toString();
let a = 0;
if (advLength > 1) {
a = await this.calPageAdvIndex(pageId,advLength)
}
// 获取投放
let showCompAdvBean = pageCoreAdvArray.convertToArray()[a]
if (showCompAdvBean.matInfo == null) {
return
}
this.saveReleaseAdvIndex(pageId, a)
//
let slotInfo = showCompAdvBean.slotInfo;
let postion = slotInfo.position
... ... @@ -76,4 +88,84 @@ export default class PageAdModel {
}
}
/**
* 计算投放广告的序列号
* @param pageId
* @param advLength
* @returns
*/
private async calPageAdvIndex(pageId: string , advLength: number): Promise<number>{
let index = await this.obtainReleaseAdvIndex(pageId);
let a = await index + 1;
if (a >= advLength) {
a = 0;
}
return a;
}
/**
* 获取已投放挂角广告的编号
* @param pageId
* @returns
*/
private async obtainReleaseAdvIndex(pageId: string): Promise<number> {
let index: number = await SPHelper.default.get(SpConstants.APP_PAGE_CORNER_ADV + pageId, -1) as number;
return index;
}
/**
* 存储已经投放广告的编号
* @param pageId
* @param index
*/
private async saveReleaseAdvIndex(pageId: string, index: number) {
await SPHelper.default.save(SpConstants.APP_PAGE_CORNER_ADV + pageId, index)
}
/**
* 删除数据
* @param pageId
*/
private async clearHistoryAdvIndex(pageId: string){
SPHelper.default.deleteSync(SpConstants.APP_PAGE_CORNER_ADV + pageId)
}
private checkPageCornerAdv(pageId: string): Promise<boolean> {
let haveData = SPHelper.default.has(SpConstants.APP_PAGE_CORNER_ADV + pageId)
return haveData
}
/**
* 对广告中心的广告 数据按不同维度加工 筛选出符合的数据
* @param cornersAdv2 页面的广告数据
* @param pageId 所在页面pageid
*/
private treatPageInfoAdsData(cornersAdv2: CompAdvBean[]): ArrayList<CompAdvBean> {
// 按时间维度过滤出广告数据
let compAdsArray: ArrayList<CompAdvBean> = new ArrayList();
let serverTimeLong: number = DateTimeUtils.getTimeStamp();
for (let advBean of cornersAdv2) {
let startLong = advBean.startTime;
let endLong = advBean.endTime;
if (serverTimeLong >= startLong && serverTimeLong <= endLong) {
//符合开始时间和结束时间要求
compAdsArray.add(advBean)
}
}
//按展现优先级维度 数值越小,等级越高
if (compAdsArray.length > 1) {
//B、按展现优先级维度 数值越小,等级越高
compAdsArray.sort((a: CompAdvBean, b: CompAdvBean) => a.displayPriority - b.displayPriority)
}
return compAdsArray;
}
}
\ No newline at end of file
... ...
... ... @@ -51,12 +51,6 @@ export default class PageModel {
// keyGenerator相关字符串,用于刷新list布局
timestamp: String = '1';
// //左右挂角广告对象
// pageCornerAdv:CompAdvBean = {} as CompAdvBean // 挂角广告
// isShowAds : boolean = false;
// isRightAdv : number = 1;// 1:右边;2:左边 -> 默认右边
// pageCornerContentInfo:AdvRuleBean = {} as AdvRuleBean // 展现中心业务信息
/**
* 简单复制业务数据
... ...
... ... @@ -52,6 +52,10 @@
{
"name": "comp_advertisement",
"value": "广告"
},
{
"name": "location_reason",
"value": " "
}
]
}
\ No newline at end of file
... ...
... ... @@ -2,15 +2,15 @@ import { Action, LiveDetailsBean } from 'wdBean/Index';
import { LiveViewModel } from '../viewModel/LiveViewModel';
import router from '@ohos.router';
import { DetailPlayLivePage } from './DetailPlayLivePage'
import { DetailPlayVLivePage } from './DetailPlayVLivePage'
import { DetailPlayLivePage } from './DetailPlayLivePage';
import { DetailPlayVLivePage } from './DetailPlayVLivePage';
import { Logger } from 'wdKit/Index';
const TAG = 'DetailPlayLiveCommon'
@Entry()
@Entry
@Component
export struct DetailPlayLiveCommon {
TAG: string = 'DetailPlayLiveCommon';
private liveViewModel: LiveViewModel = new LiveViewModel()
@State liveDetailsBean: LiveDetailsBean = {} as LiveDetailsBean
@State liveState: string = ''
... ... @@ -18,8 +18,12 @@ export struct DetailPlayLiveCommon {
@State relId: string = ''
@State contentId: string = ''
@State relType: string = ''
@Provide pageShow: number = -1
@Provide pageHide: number = -1
@Provide pageBackPress: number = -1
aboutToAppear(): void {
Logger.debug(TAG, 'aboutToAppear')
//https://pdapis.pdnews.cn/api/rmrb-bff-display-zh/content/zh/c/content/detail?relId=500005302448&relType=1&contentId=20000016340
const par: Action = router.getParams() as Action;
const params = par?.params;
... ... @@ -56,5 +60,21 @@ export struct DetailPlayLiveCommon {
})
}
onPageShow() {
this.pageShow = Math.random()
Logger.debug(TAG, 'onPageShow')
}
onPageHide() {
this.pageHide = Math.random()
Logger.debug(TAG, 'onPageHide')
}
onBackPress(): boolean | void {
this.pageBackPress = Math.random()
Logger.debug(TAG, 'onBackPress')
return true
}
}
... ...
import { Action, LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Index';
import { LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Index';
import { LiveViewModel } from '../viewModel/LiveViewModel';
import { TabComponent } from '../widgets/details/TabComponent';
import { TopPlayComponent } from '../widgets/details/video/TopPlayComponet';
import router from '@ohos.router';
import { DisplayDirection } from 'wdConstant/Index';
import mediaquery from '@ohos.mediaquery';
import { Logger, WindowModel } from 'wdKit/Index';
import { window } from '@kit.ArkUI';
import { router, window } from '@kit.ArkUI';
import { devicePLSensorManager } from 'wdDetailPlayApi/Index';
import { LiveCommentComponent } from 'wdComponent/Index';
import { WDPlayerController } from 'wdPlayer/Index';
@Entry
let TAG: string = 'DetailPlayLivePage';
@Component
export struct DetailPlayLivePage {
//横竖屏,默认竖屏
@Provide displayDirection: DisplayDirection = DisplayDirection.VERTICAL
playerController: WDPlayerController = new WDPlayerController();
TAG: string = 'DetailPlayLivePage';
liveViewModel: LiveViewModel = new LiveViewModel()
@State relId: string = ''
@State contentId: string = ''
... ... @@ -27,11 +26,14 @@ export struct DetailPlayLivePage {
@State tabs: string[] = []
//监听屏幕横竖屏变化
listener = mediaquery.matchMediaSync('(orientation: landscape)');
@Consume @Watch('onPageShowCus') pageShow: number
@Consume @Watch('onPageHideCus') pageHide: number
@Consume @Watch('onBackPressCus') pageBackPress: number
aboutToAppear(): void {
Logger.info(this.TAG, `wyj-aboutToAppear`)
Logger.info(TAG, `wyj-aboutToAppear`)
this.listener?.on("change", (mediaQueryResult) => {
Logger.info(this.TAG, `change;${mediaQueryResult.matches}`)
Logger.info(TAG, `change;${mediaQueryResult.matches}`)
if (mediaQueryResult?.matches) {
this.displayDirection = DisplayDirection.VIDEO_HORIZONTAL
} else {
... ... @@ -39,11 +41,6 @@ export struct DetailPlayLivePage {
}
WindowModel.shared.setMainWindowFullScreen(this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL)
})
let par: Action = router.getParams() as Action;
let params = par?.params;
this.relId = params?.extra?.relId || '';
this.relType = params?.extra?.relType || '';
this.contentId = params?.contentID || '';
this.getLiveDetails()
this.getLiveRoomData()
}
... ... @@ -62,18 +59,39 @@ export struct DetailPlayLivePage {
.width('100%')
}
onPageShow(): void {
Logger.info(this.TAG, `wyj-onPageShow`)
aboutToDisappear(): void {
Logger.info(TAG, `wyj-aboutToDisappear`)
this.playerController?.stop()
this.playerController?.release()
}
onPageShowCus(): void {
Logger.info(TAG, `wyj-onPageShowCus`)
// WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED);
}
onPageHide(): void {
Logger.info(this.TAG, `wyj-onPageHide`)
onPageHideCus(): void {
Logger.info(TAG, `wyj-onPageHideCus`)
devicePLSensorManager.devicePLSensorOff();
// WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED);
this.playerController?.pause()
}
onBackPressCus(): boolean | void {
if (this.displayDirection == DisplayDirection.VERTICAL) {
router.back()
} else {
this.displayDirection = DisplayDirection.VERTICAL
}
WindowModel.shared.setPreferredOrientation(this.displayDirection == DisplayDirection.VERTICAL ?
window.Orientation.PORTRAIT :
window.Orientation.LANDSCAPE)
devicePLSensorManager.devicePLSensorOn(this.displayDirection == DisplayDirection.VERTICAL ?
window.Orientation.PORTRAIT :
window.Orientation.LANDSCAPE);
return true
}
getLiveDetails() {
this.liveViewModel.getLiveDetails(this.contentId, this.relId, this.relType)
.then(
... ... @@ -102,23 +120,4 @@ export struct DetailPlayLivePage {
})
}
aboutToDisappear(): void {
Logger.info(this.TAG, `wyj-aboutToDisappear`)
}
onBackPress(): boolean | void {
if (this.displayDirection == DisplayDirection.VERTICAL) {
router.back()
} else {
this.displayDirection = DisplayDirection.VERTICAL
}
WindowModel.shared.setPreferredOrientation(this.displayDirection == DisplayDirection.VERTICAL ?
window.Orientation.PORTRAIT :
window.Orientation.LANDSCAPE)
devicePLSensorManager.devicePLSensorOn(this.displayDirection == DisplayDirection.VERTICAL ?
window.Orientation.PORTRAIT :
window.Orientation.LANDSCAPE);
return true
}
}
\ No newline at end of file
... ...
... ... @@ -53,7 +53,7 @@ export struct DetailPlayVLivePage {
build() {
Column() {
// 直播结束且无回看
if (this.liveState === 'end' || !this.playUrl) {
if (this.liveState === 'end' && !this.playUrl) {
LiveEmptyComponent({
emptyType: WDLiveViewDefaultType.WDViewDefaultType_NoLiveEnd
})
... ...
... ... @@ -26,7 +26,7 @@ export struct TabChatComponent {
} else if (this.pageModel.viewType == ViewType.ERROR) {
ErrorComponent()
} else if (this.pageModel.viewType == ViewType.EMPTY) {
EmptyComponent({ emptyType: WDViewDefaultType.WDViewDefaultType_NoContent1 })
EmptyComponent({ emptyType: WDViewDefaultType.WDViewDefaultType_NoComment1 })
} else {
this.ListLayout()
}
... ...
import { LiveRoomItemBean } from 'wdBean/Index'
import { StringUtils } from 'wdKit/Index'
@Component
export struct TabChatItemComponent {
... ... @@ -9,7 +10,7 @@ export struct TabChatItemComponent {
build() {
Row() {
Image(this.item.senderUserAvatarUrl)
Image(StringUtils.isEmpty(this.item.senderUserAvatarUrl) ? $r('app.media.default_head') : this.item.senderUserAvatarUrl)
.borderRadius(90)
.width(24)
.height(24)
... ...
import { Action, LiveRoomItemBean, Params, PhotoListBean } from 'wdBean/Index'
import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO'
import { AudioRowComponent } from 'wdComponent/Index'
import { DateTimeUtils, StringUtils } from 'wdKit/Index'
import { WDRouterRule } from 'wdRouter/Index'
... ... @@ -106,29 +107,14 @@ export struct TabLiveItemComponent {
.listDirection(Axis.Horizontal)
.margin({
top: 8,
right: 16
})
}
//音频
else if (this.item.dataType === 'ZH_AUDIO_MSG') {
Row() {
Image($r('app.media.icon_voice'))
.width(20)
.aspectRatio(1)
.margin({
left: 8,
right: 6
AudioRowComponent({
audioUrl: this.item.audioUrl,
duration: this.item.duration
})
Text(DateTimeUtils.getFormattedDuration(this.item.duration))
.fontColor('#666666')
.fontWeight(400)
.fontSize('14fp')
}
.backgroundColor(Color.White)
.height(36)
.borderRadius(4)
.margin({ top: 8, right: 16 })
.width('100%')
}
//视频
else if (this.item.dataType === 'ZH_VIDEO_MSG') {
... ... @@ -160,14 +146,12 @@ export struct TabLiveItemComponent {
}
.margin({
top: 8,
right: 16
})
.aspectRatio(Number.parseFloat(this.item.pictureResolutions[0]?.split('*')[0]) / Number.parseFloat(this.item.pictureResolutions[0]?.split('*')[1]))
.onClick(() => {
this.gotoVideoPlayPage()
})
}
}
.margin({
left: 8,
... ...
... ... @@ -75,7 +75,7 @@ export struct PlayUIComponent {
if (this.liveDetailsBean.liveInfo?.liveState != 'wait') {
Text(this.liveDetailsBean.newsTitle)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.textOverflow({ overflow: TextOverflow.MARQUEE })
.fontSize('16fp')
.fontWeight(500)
.fontColor(Color.White)
... ... @@ -269,8 +269,7 @@ export struct PlayUIComponent {
.blockSize({
width: 18,
height: 12
})
// .blockStyle({
})// .blockStyle({
// type: SliderBlockType.IMAGE,
// image: $r('app.media.ic_player_block')
// })
... ...
import { LiveDetailsBean } from 'wdBean/Index';
import { Logger } from 'wdKit/Index';
import { WDPlayerController, WDPlayerRenderLiveView } from 'wdPlayer/Index';
import { PlayUIComponent } from './PlayUIComponent';
... ... @@ -7,13 +6,15 @@ import { PlayUIComponent } from './PlayUIComponent';
export struct TopPlayComponent {
TAG: string = 'TopPlayComponent'
@Consume @Watch('updateData') liveDetailsBean: LiveDetailsBean
playerController: WDPlayerController = new WDPlayerController();
playerController?: WDPlayerController
@State imgUrl: string = ''
@State isWait: boolean = false
aboutToAppear(): void {
if (this.playerController) {
this.playerController.onCanplay = () => {
this.playerController.play()
this.playerController?.play()
}
}
}
... ... @@ -30,7 +31,7 @@ export struct TopPlayComponent {
} else if (this.liveDetailsBean.liveInfo.liveState == 'end') {
playUrl = this.liveDetailsBean.liveInfo.vlive[0].replayUri
}
this.playerController.firstPlay(playUrl);
this.playerController?.firstPlay(playUrl);
}
}
... ... @@ -44,18 +45,6 @@ export struct TopPlayComponent {
.height('100%')
.width('100%')
.visibility(this.isWait ? Visibility.None : Visibility.Visible)
.onVisibleAreaChange([0.0, 1.0], (isVisible: boolean, currentRatio: number) => {
Logger.debug(this.TAG, `当前屏幕可见区域大小: currentRatio:' +${currentRatio}`)
if (isVisible && currentRatio >= 1.0) {
Logger.debug(this.TAG, `播放器-暂停. currentRatio:' +${currentRatio}`)
this.playerController.play()
}
if (!isVisible && currentRatio <= 0.0) {
Logger.debug(this.TAG, `播放器-播放. currentRatio:' +${currentRatio}`)
this.playerController.pause()
}
})
Image(this.imgUrl)
.objectFit(ImageFit.Contain)
.visibility(this.isWait ? Visibility.Visible : Visibility.None)
... ... @@ -65,8 +54,5 @@ export struct TopPlayComponent {
}
aboutToDisappear(): void {
this.playerController.pause()
this.playerController.stop()
this.playerController.release()
}
}
\ No newline at end of file
... ...
... ... @@ -35,6 +35,10 @@
{
"name": "reason_read_write_media",
"value": "user_grant"
},
{
"name": "location_reason",
"value": " "
}
]
}
\ No newline at end of file
... ...
{
"src": [
"pages/DetailPlayLivePage",
"pages/DetailPlayVLivePage",
"pages/DetailPlayLiveCommon"
]
... ...
{
"src": [
"pages/DetailVideoListPage",
"pages/VideoChannelDetail"
"pages/DetailVideoListPage"
]
}
\ No newline at end of file
... ...
... ... @@ -152,6 +152,22 @@ export class HWLocationUtils {
}
return ''
}
// 通过省份code获取省份名称
static async getProvinceName(provinceCode: string) {
let bean = await ResourcesUtils.getResourcesJson<ResponseDTO<Array<LocalData>>>(getContext(), 'areaList_data.json');
if (bean) {
if (bean.code == 0 && bean.data) {
for (let i = 0; i < bean.data.length; i++) {
if (bean.data[i].code == provinceCode) {
return bean.data[i].label
}
}
}
}
return ''
}
}
interface LocalData {
... ...
import { PageComponent } from './PageComponent';
import { PageComponent } from 'wdComponent/Index';
import { HashMap } from '@kit.ArkTS';
import { router } from '@kit.ArkUI';
import { AssignChannelParam } from 'wdRouter/src/main/ets/utils/HomeChannelUtils';
const TAG = 'ColumnPageComponent';
const TAG = 'ColumnPage';
/**
* 二级栏目页面,展排数据
*/
@Entry
@Component
export struct ColumnPageComponent {
export struct ColumnPage {
@State currentTopNavSelectedIndex: number = 0;
@State param: AssignChannelParam = router.getParams() as AssignChannelParam
pageId: string = "";
channelId: string = "";
aboutToAppear() {
this.pageId = this.param.pageId
this.channelId = this.param.channelId
}
build() {
Column() {
PageComponent({
currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
navIndex: this.currentTopNavSelectedIndex,
pageId: this.pageId,
channelId: this.channelId,
});
}
}
}
... ...
... ... @@ -13,6 +13,7 @@
"pages/launchPage/LaunchAdvertisingPage",
"pages/broadcast/BroadcastPage",
"pages/launchPage/LaunchInterestsHobbiesPage",
"pages/SpacialTopicPage"
"pages/SpacialTopicPage",
"pages/column/ColumnPage"
]
}
\ No newline at end of file
... ...