张善主

Merge remote-tracking branch 'origin/main'

Showing 88 changed files with 3610 additions and 524 deletions
... ... @@ -19,4 +19,6 @@ export { DurationEnum } from './src/main/ets/enum/DurationEnum';
export { ScreenType } from './src/main/ets/enum/ScreenType';
export { SpConstants } from './src/main/ets/constants/SpConstants';
\ No newline at end of file
export { SpConstants } from './src/main/ets/constants/SpConstants';
export { DisplayDirection } from './src/main/ets/constants/VideoConstants';
... ...
export enum DisplayDirection {
VERTICAL,
VIDEO_HORIZONTAL
}
\ No newline at end of file
... ...
import { Action } from './Action';
interface dataObject {
operateType?: string
webViewHeight?: string
dataJson?: string
}
... ...
... ... @@ -101,4 +101,9 @@ export class SPHelper {
// preferences.clearSync()
// preferences.flush()
// }
public getPreferences(){
let preferences = data_preferences.getPreferences(SPHelper.context, SPHelper.spFilename);
return preferences;
}
}
\ No newline at end of file
... ...
... ... @@ -26,6 +26,7 @@ export class Size {
export class WindowModel {
private windowStage?: window.WindowStage;
private windowClass?: window.Window;
private isFullScreen: boolean = false
static shared: WindowModel = new WindowModel()
static TAG = "WindowModel";
... ... @@ -129,7 +130,15 @@ export class WindowModel {
this.windowClass?.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => {
callback && callback(err)
})
}
setWindowLayoutFullScreen(isFullScreen: boolean) {
this.isFullScreen = isFullScreen
this.windowClass?.setWindowLayoutFullScreen(isFullScreen)
}
getIsFullScreen(): boolean {
return this.isFullScreen
}
}
... ...
... ... @@ -238,6 +238,20 @@ export class HttpUrlUtils {
* 创作者详情接口
*/
static readonly CREATOR_DETAIL_LIST_DATA_PATH: string = "/api/rmrb-contact/contact/zh/c/master/detailList";
/**
* 客态查询发布作品数量
*/
static readonly ARTICLE_COUNT_HOTS_DATA_PATH: string = "/api/rmrb-content-search/zh/c/article/count";
/**
* 客户端 客态主页页面-获取作品-从发布库获取该创作者下 稿件列表
*/
static readonly ARTICLE_LIST_HOTS_DATA_PATH: string = "/api/rmrb-content-search/zh/c/article/articleList";
/**
* 客户端 客态主页页面-获取影响力
*/
static readonly CREATOR_INFLUENCE_HOTS_DATA_PATH: string = "/api/rmrb-bigdata-bi/zh/c/stats/creator/influence/info";
/**
* 早晚报列表
... ... @@ -727,6 +741,21 @@ export class HttpUrlUtils {
return url
}
static getArticleCountHotsDataUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.ARTICLE_COUNT_HOTS_DATA_PATH
return url
}
static getArticleListHotsDataUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.ARTICLE_LIST_HOTS_DATA_PATH
return url
}
static getCreatorInfluenceInfoHotsDataUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.CREATOR_INFLUENCE_HOTS_DATA_PATH
return url
}
// static getYcgCommonHeaders(): HashMap<string, string> {
// let headers: HashMap<string, string> = new HashMap<string, string>()
//
... ...
... ... @@ -8,6 +8,7 @@
"version": "1.0.0",
"dependencies": {
"wdKit": "file:../wdKit",
"wdBean": "file:../../features/wdBean"
"wdBean": "file:../../features/wdBean",
"wdNetwork": "file:../../commons/wdNetwork"
}
}
}
\ No newline at end of file
... ...
... ... @@ -50,13 +50,17 @@ export function registerRouter() {
Action2Page.register("JUMP_DETAIL_PAGE", (action: Action) => {
if (action.params?.detailPageType == 2 || action.params?.detailPageType == 6) {
return WDRouterPage.detailPlayLivePage
if (action.params?.liveStyle === 0) {
return WDRouterPage.detailPlayLivePage
} else {
return WDRouterPage.detailPlayVLivePage
}
} else if (action.params?.detailPageType == 7 || action.params?.detailPageType == 8) {
return WDRouterPage.detailVideoListPage
}else if(action.params?.detailPageType == 9){
} else if (action.params?.detailPageType == 9) {
//图集详情页
return WDRouterPage.multiPictureDetailPage
}else if(action.params?.detailPageType == 14 || action.params?.detailPageType == 15){
} else if (action.params?.detailPageType == 14 || action.params?.detailPageType == 15) {
//动态详情页
return WDRouterPage.dynamicDetailPage
} else if (action.params?.detailPageType == 17) {
... ...
... ... @@ -14,6 +14,16 @@ export class WDRouterPage {
return `@bundle:${bundleInfo.name}/${"phone"}/${"ets/pages/MainPage"}`
}
static getLoginBundleInfo() {
let bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT)
return `@bundle:${bundleInfo.name}/${"wdLogin"}/${"ets/pages/login/LoginPage"}`
}
static getSettingBundleInfo() {
let bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT)
return `@bundle:${bundleInfo.name}/${"wdComponent"}/${"ets/components/page/SettingPage"}`
}
url() {
let bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT)
... ... @@ -97,4 +107,8 @@ export class WDRouterPage {
static broadcastPage = new WDRouterPage("phone", "ets/pages/broadcast/BroadcastPage");
//搜索主页
static searchPage = new WDRouterPage("wdComponent", "ets/pages/SearchPage");
//搜索人民号主页
static searchCreatorPage = new WDRouterPage("wdComponent", "ets/pages/SearchCreatorPage");
//人民号主页
static peopleShipHomePage = new WDRouterPage("wdComponent", "ets/components/page/PeopleShipHomePage");
}
... ...
... ... @@ -41,6 +41,7 @@ export function performJSCallNative(data: Message, call: Callback) {
class AppInfo {
plat: string = ''
system: string = ''
networkStatus: number = 1
// TODO 完善
}
... ... @@ -52,6 +53,7 @@ function getAppPublicInfo(): string {
info.plat = 'Phone'
// 直接用Android,后续适配再新增鸿蒙
info.system = 'Android'
info.networkStatus = 1
let result = JSON.stringify(info)
return result;
}
... ...
... ... @@ -83,7 +83,7 @@ export struct WdWebLocalComponent {
//webview 高度设置
private setCurrentPageOperate: (data: Message) => void = (data) => {
console.log("setCurrentPageOperate", JSON.stringify(data))
if (data.handlerName === H5CallNativeType.jsCall_currentPageOperate) {
if (data.handlerName === H5CallNativeType.jsCall_currentPageOperate && data?.data?.operateType === '8') {
if (typeof this.webHeight === 'number') {
if (Number(data?.data?.webViewHeight) > this.webHeight) {
this.webHeight = Number(data?.data?.webViewHeight)
... ...
... ... @@ -37,7 +37,8 @@ export {
postExecuteCollectRecordParams,
contentListParams,
postInteractAccentionOperateParams,
postRecommendListParams
postRecommendListParams,
contentListItem
} from './src/main/ets/bean/detail/MultiPictureDetailPageDTO';
export { InteractParam, ContentBean } from './src/main/ets/bean/content/InteractParam';
... ... @@ -122,3 +123,21 @@ export { LiveRoomBean,LiveRoomItemBean } from './src/main/ets/bean/live/LiveRoom
export { LiveRoomDataBean } from './src/main/ets/bean/live/LiveRoomDataBean';
export { LiveInfoDTO } from './src/main/ets/bean/detail/LiveInfoDTO';
export { LiveDTO } from './src/main/ets/bean/peoples/LiveDTO';
export { contentVideosDTO } from './src/main/ets/bean/content/contentVideosDTO';
export { ContentExtDTO } from './src/main/ets/bean/peoples/ContentExtDTO';
export { ContentShareDTO } from './src/main/ets/bean/peoples/ContentShareDTO';
export {
PeopleShipUserDetailData,
ArticleCountData,
ArticleTypeData,
ArticleListData,
InfluenceData
} from './src/main/ets/bean/peoples/PeopleShipUserDetailData';
... ...
... ... @@ -6,9 +6,14 @@
*/
import { appStyleImagesDTO } from '../content/appStyleImagesDTO'
import {contentVideosDTO} from '../content/contentVideosDTO'
import { VlivesDTO } from '../peoples/VlivesDTO'
import { LiveDTO } from '../peoples/LiveDTO'
import { ContentExtDTO } from '../peoples/ContentExtDTO'
import { ContentShareDTO } from '../peoples/ContentShareDTO'
export interface ArticleListDTO {
listTitle: string;
mainPicCount: string;
mainPicCount: number;
videosCount: string;
voicesCount: string;
landscape: number;
... ... @@ -20,7 +25,7 @@ export interface ArticleListDTO {
id: string;
serialsId: string;
oldContentId: string;
type: string;
type: number;
tenancy: string;
clientPubFlag: string;
grayScale: string;
... ... @@ -62,11 +67,12 @@ export interface ArticleListDTO {
joinActivity: string;
userType: string;
content: object;
contentShare: [];
contentShare: ContentShareDTO[];
contentLinkData: string;
contentExt: [];
contentExt: ContentExtDTO[];
contentVideos: contentVideosDTO[];
contentPictures: [];
appStyleVideos: contentVideosDTO[];
contentPictures: appStyleImagesDTO[];
contentPayments: string;
contentPaymentStaffs: string;
contentTxt: [];
... ... @@ -78,7 +84,7 @@ export interface ArticleListDTO {
contentStatistics: string;
topicExistHeadImage: string;
topicComps: string;
live: string;
live: LiveDTO;
statusInfo: string;
askInfo: string;
askAttachmentList: string;
... ... @@ -87,5 +93,5 @@ export interface ArticleListDTO {
ttopicInteracts: string;
ttopic: string;
mlive: string;
vlives: string
vlives: VlivesDTO[];
}
\ No newline at end of file
... ...
... ... @@ -12,4 +12,5 @@ export interface ExtraDTO extends ItemDTO {
sourcePage: string;
relId: string;
relType: string;
liveStreamType?: number
}
\ No newline at end of file
... ...
... ... @@ -21,6 +21,7 @@ export interface ContentDTO {
lengthTime?: object;
linkUrl: string;
openLikes: number;
openComment?: number;
openUrl: string;
pageId: string;
// playUrls: any[];
... ...
... ... @@ -18,5 +18,6 @@ export interface Params {
// 8.专辑竖屏详情页
// 13.音频详情页
// 17.多图(图集)详情页
detailPageType?:number; // 详情页类型
detailPageType?: number; // 详情页类型
liveStyle?: number; // 直播类型:0横屏,1竖屏
}
... ...
... ... @@ -160,7 +160,7 @@ export interface postExecuteCollectRecordParams {
contentList: postExecuteCollectRecordParamsItem[]
}
interface contentListItem {
export interface contentListItem {
contentId: string;
contentType: number;
}
... ...
export interface H5ReceiveDataExtraBean {
creatorId: string;
isLogin: string;
networkStatus: number;
loadImageOnlyWifiSwitch: string
}
\ No newline at end of file
... ...
... ... @@ -164,6 +164,7 @@ export interface LiveDetailsBean {
//迁移id
oldNewsId: string
reLInfo: ReLInfo
rmhInfo: RmhInfo
}
export interface LiveInfo {
... ... @@ -189,8 +190,18 @@ export interface Vlive {
liveUrl: string
//直播回看地址,多路直播录制文件URL
replayUri: string
// 画面兼容 0-横屏流画面,1-竖屏流画面(仅竖屏直播使用)【前端使用, 可能竖屏模式但是直播流画面是横屏流,前端使用该字段】
liveStreamType: number | null
}
export interface ReLInfo {
relId: string
}
export interface RmhInfo {
rmhName: string;
rmhHeadUrl: string;
rmhId: string;
userId: string;
userType: string;
}
\ No newline at end of file
... ...
export interface ContentExtDTO {
id: number;
contentId: number;
openLikes: number;
openComment: number;
openDownload: number;
likesStyle: number;
top: number;
joinActivity: number;
hotFlag: number;
preCommentFlag: number;
currentPoliticsFlag: number;
appStyle: number;
tenancy: number;
downloadFlag: number;
publishType: number;
payment: number;
deleted: number;
createUser: string;
createTime: string;
updateUser: string;
updateTime: string;
keyArticle: number;
toExamine: number;
bestNoticer: number;
commentDisplay: number;
imageQuality: number;
haveAdver: number;
openAudio: number;
withdrawNum: number;
menuShow: string;
recommendShow: string;
recommendSelf: string;
concentration: string;
objectPosId: string;
articleExistVote: number;
zhExpireTimeAi: number;
zhTagsAi: string;
appReadCountShow: number;
}
\ No newline at end of file
... ...
export interface ContentShareDTO {
id?: number;
shareSwitch: number;
contentId?: number;
sharePicture: string;
fullUrl: string;
shareTitle: string;
shareDescription: string;
}
\ No newline at end of file
... ...
export interface LiveDTO {
status: string;
previewType: number;
planStartTime: number;
tplId: number;
startTime: number;
endTime: number;
userOrigin: string;
liveStyle: number;
liveWay: number;
liveStreamType: number;
liveExperienceSwitch: boolean;
liveExperienceTime: number;
handAngleSwitch: boolean;
likeStyle: string;
liveType: string;
preDisplay: number;
playbackSwitch: boolean;
originalAddress: string;
provinceName: string;
liveRemindSwitch: boolean;
recordUrlFlag: number;
vr: number;
landscape: string;
recordUrl: string;
uri: string;
}
\ No newline at end of file
... ...
import { ArticleListDTO } from '../component/ArticleListDTO'
/**
* http://192.168.1.3:3300/project/3796/interface/api/188629
* 接口名称:客户端 客态主页页面-获取作品-从发布库获取该创作者下 稿件列表
* 接口路径:/contact/zh/c/master/detail
* 人民号-主页详情页面数据
*/
export interface PeopleShipUserDetailData {
articleCreation: number;
attentionNum: number;
authIcon: string;
authId: number;
authPersonal: string;
authTitle: string;
avatarFrame: string;
banControl: number;
browseNum: number;
categoryAuth: string;
city: string;
cnContentPublish: number;
cnIsComment: number;
cnIsLike: number;
cnLiveCommentControl: number;
cnLiveGiftControl: number;
cnLiveLikeControl: number;
cnLivePublish: number;
cnLiveShareControl: number;
cnShareControl: number;
contentPublish: number;
creatorId: string;
district: string;
dynamicControl: number;
dynamicCreation: number;
fansNum: number;
headPhotoUrl: string;
honoraryIcon: string;
honoraryTitle: string;
introduction: string;
isAttention: number;
isComment: number;
isLike: number;
liveCommentControl: number;
liveGiftControl: number;
liveLikeControl: number;
livePublish: number;
liveShareControl: number;
liveSwitch: number;
mainControl: number;
originUserId: string;
pictureCollectionCreation: number;
posterShareControl: number;
province: string;
region: string;
registTime: number;
shareControl: number;
shareUrl: string;
subjectType: number;
userId: string;
userName: string;
userType: string;
videoCollectionCreation: number;
videoCreation: number;
}
//article/count
/*
* 客户端 客态查询发布作品数量
* http://192.168.1.3:3300/project/3856/interface/api/190579
* 接口路径:/zh/c/article/count
* */
export interface ArticleCountData {
zbCount: number; //直播数量 (直播)
dtCount: number; //动态数量 (动态)
twCount: number; //图文数量 (文章)
ztCount: number; //组图数量 (图集)
spCount: number; // 视频数量 (视频)
publishCount: number; // 发布数量
serialsCount: number; //
}
export class ArticleTypeData {
name?: string; //名称
type?: number; // 类型
constructor(name?: string, type?: number) {
this.name = name;
this.type = type;
}
}
export interface ArticleListData {
totalCount: number;
pageNum: number;
pageSize: number;
list: ArticleListDTO[];
}
// 影响力
export interface InfluenceData {
creatorId: string;
influence: number;
influenceTotal: number;
}
\ No newline at end of file
... ...
export interface VlivesDTO {
id: number;
type: string;
// definition?: any;
// streamAppName?: any;
// streamName?: any;
pullStreamUrl: string;
// streamStatus?: any;
// shiftEnable?: any;
// clipEnable?: any;
// recordEnable?: any;
status: string;
liveId: number;
name: string;
// serialNum?: any;
streamWH: string;
recordUrl: string;
// playPreviewImageUri?: any;
// playPreviewImageFullUrl?: any;
// playPreviewImageBucket?: any;
showPad: boolean;
// liveStreamManagerId?: any;
// recordBucket?: any;
// recordUri?: any;
}
\ No newline at end of file
... ...
... ... @@ -55,7 +55,13 @@ export struct ImageAndTextWebComponent {
}
// TODO 对接user信息、登录情况
let h5ReceiveDataExtraBean: H5ReceiveDataExtraBean = { creatorId: '', isLogin: '0' } as H5ReceiveDataExtraBean
let h5ReceiveDataExtraBean: H5ReceiveDataExtraBean = {
creatorId: '',
isLogin: '0',
networkStatus: 1,
loadImageOnlyWifiSwitch: '2',
} as H5ReceiveDataExtraBean
let h5ReceiveDataJsonBean: H5ReceiveDataJsonBean = {
contentId: contentId,
contentType: contentType
... ... @@ -86,7 +92,7 @@ export struct ImageAndTextWebComponent {
webResource: $rawfile('apph5/index.html'),
backVisibility: false,
onWebPrepared: this.onWebPrepared.bind(this),
isPageEnd:$isPageEnd
isPageEnd: $isPageEnd
})
}
... ...
import { WDRouterRule, WDRouterPage } from 'wdRouter'
import MinePagePersonalFunctionsItem from '../../viewmodel/MinePagePersonalFunctionsItem'
import router from '@ohos.router'
@Component
export default struct MinePagePersonFunctionUI {
@Link personalData:MinePagePersonalFunctionsItem[]
@Prop isLogin:boolean
@Consume('isLogin')@Watch('loginChange') loginState:Record<string,string>
loginChange(){
if(this.loginState){
this.isLogin=true
}else{
this.isLogin=false
}
}
build() {
Grid(){
... ... @@ -47,6 +38,15 @@ export default struct MinePagePersonFunctionUI {
}.onClick(()=>{
console.log(index+"")
switch (item.msg){
case "评论":{
if(!this.isLogin){
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}else {
WDRouterRule.jumpWithPage(WDRouterPage.mineHomePage)
}
break;
}
case "预约":{
if(!this.isLogin){
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
... ...
import { Logger, UserDataLocal } from 'wdKit'
import { Logger, StringUtils, UserDataLocal } from 'wdKit'
import { WDRouterPage, WDRouterRule } from 'wdRouter'
import MinePageDatasModel from '../../model/MinePageDatasModel'
const TAG = "MinePageUserSimpleInfoUI"
... ... @@ -12,20 +12,13 @@ export default struct MinePageUserSimpleInfoUI {
@State levelHead:string = ""
@State levelId:number = 0
@Consume('isLogin') @Watch('loginChange') loginState:Record<string,string>
loginChange(){
Logger.debug("isLogin",'MinePageUserSimpleInfoUI')
if(this.loginState){
this.isLogin=true
}else {
this.isLogin=false
}
}
loginStateChange(){
if(this.isLogin){
this.getUserInfo()
this.getUserLevel()
}else{
this.headPhotoUrl = ""
this.levelHead = ""
}
}
... ... @@ -33,17 +26,20 @@ export default struct MinePageUserSimpleInfoUI {
Row(){
//头像
Stack(){
Image(this.headPhotoUrl)
Image(this.headPhotoUrl==""?$r('app.media.default_head'):this.headPhotoUrl)
.alt($r('app.media.default_head'))
.width('100lpx')
.height('100lpx')
.objectFit(ImageFit.Cover)
.borderRadius(50)
Image(this.levelHead)
.width('130lpx')
.height('130lpx')
.objectFit(ImageFit.Cover)
.borderRadius(50)
if(StringUtils.isNotEmpty(this.levelHead)){
Image(this.levelHead)
.width('130lpx')
.height('130lpx')
.objectFit(ImageFit.Cover)
.borderRadius(50)
}
}.width('130lpx')
.height('130lpx')
.alignContent(Alignment.Center)
... ...
import { StringUtils } from 'wdKit/Index'
import { HttpUrlUtils } from 'wdNetwork/Index'
import MinePageDatasModel from '../../../model/MinePageDatasModel'
import { FollowListDetailItem } from '../../../viewmodel/FollowListDetailItem'
import { FollowOperationRequestItem } from '../../../viewmodel/FollowOperationRequestItem'
@Component
export struct FollowChildComponent{
@ObjectLink data: FollowListDetailItem
@State type:number = 0
build() {
if(this.type == 0 ){
Column(){
Blank().height('27lpx')
Row() {
Image(StringUtils.isEmpty(this.data.headPhotoUrl)?$r('app.media.default_head'):this.data.headPhotoUrl)
.objectFit(ImageFit.Auto)
.width('92lpx')
.height('92lpx')
.margin({right:'15lpx'})
Column(){
Text(this.data.cnUserName)
.fontWeight('400lpx')
.fontSize('31lpx')
.lineHeight('38lpx')
.fontColor($r('app.color.color_222222'))
.maxLines(1)
Text(`粉丝${this.data.cnFansNum}`)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize('23lpx')
.maxLines(1)
Text(`${this.data.introduction}`)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize('23lpx')
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}.layoutWeight(1)
.alignItems(HorizontalAlign.Start)
if(this.data.status == "1"){
Row(){
Text(`已关注`)
.fontColor($r('app.color.color_CCCCCC'))
.fontSize('23lpx')
.fontWeight('500lpx')
.lineHeight('35lpx')
}.backgroundColor($r('app.color.color_F5F5F5'))
.borderRadius('6lpx')
.borderColor($r('app.color.color_F5F5F5'))
.borderWidth('2lpx')
.justifyContent(FlexAlign.Center)
.width('100lpx')
.height('46lpx')
.margin({left:'4lpx',top:'23lpx'})
.onClick(()=>{
this.followOperation()
// this.data.status = "0"
})
}else{
Row(){
Image($r('app.media.follow_icon'))
.margin({right:'4lpx'})
.width('23lpx')
.height('23lpx')
Text(`关注`)
.fontColor($r('app.color.color_ED2800'))
.fontSize('23lpx')
.fontWeight('500lpx')
.lineHeight('35lpx')
}.borderColor($r('app.color.color_1AED2800'))
.borderRadius('6lpx')
.borderWidth('2lpx')
.justifyContent(FlexAlign.Center)
.width('100lpx')
.height('46lpx')
.margin({left:'4lpx',top:'23lpx'})
.onClick(()=>{
this.followOperation()
// this.data.status = "1"
})
}
}.alignItems(VerticalAlign.Top)
.width('100%')
.layoutWeight(1)
Divider().width('100%')
.height('2lpx')
.strokeWidth('1lpx')
.backgroundColor($r('app.color.color_EDEDED'))
}.height('146lpx')
.justifyContent(FlexAlign.Center)
.onClick(()=>{
//跳转 人民号的 主页
})
}else if(this.type == 1 ){
Column(){
Column(){
Row() {
Row(){
Image(StringUtils.isEmpty(this.data.headPhotoUrl)?$r('app.media.default_head'):this.data.headPhotoUrl)
.objectFit(ImageFit.Auto)
.width('92lpx')
.height('92lpx')
.margin({right:'15lpx'})
.borderRadius(50)
.borderWidth('1lpx')
.borderColor($r('app.color.color_0D000000'))
Column(){
Text(this.data.cnUserName)
.fontWeight('400lpx')
.fontSize('31lpx')
.lineHeight('38lpx')
.fontColor($r('app.color.color_222222'))
.maxLines(1)
.margin({bottom:'12lpx'})
Row(){
Text(`粉丝${this.data.cnFansNum}`)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize('23lpx')
Image($r("app.media.point"))
.width('31lpx')
.height('31lpx')
.objectFit(ImageFit.Auto)
Text(`${this.data.introduction}`)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize('23lpx')
.layoutWeight(1)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}.width('100%')
}
.layoutWeight(1)
.alignItems(HorizontalAlign.Start)
}.layoutWeight(1)
if(this.data.status == "1"){
Row(){
Text(`已关注`)
.fontColor($r('app.color.color_CCCCCC'))
.fontSize('23lpx')
.fontWeight('500lpx')
.lineHeight('35lpx')
}
.justifyContent(FlexAlign.Center)
.width('100lpx')
.height('46lpx')
.onClick(()=>{
this.followOperation()
})
}else{
Row(){
Image($r('app.media.follow_icon'))
.margin({right:'4lpx'})
.width('23lpx')
.height('23lpx')
Text(`关注`)
.fontColor($r('app.color.color_ED2800'))
.fontSize('23lpx')
.fontWeight('500lpx')
.lineHeight('35lpx')
}.borderColor($r('app.color.color_1AED2800'))
.borderRadius('6lpx')
.borderWidth('2lpx')
.justifyContent(FlexAlign.Center)
.width('100lpx')
.height('46lpx')
.onClick(()=>{
this.followOperation()
})
}
}
.width('100%')
.height('92lpx')
.justifyContent(FlexAlign.SpaceBetween)
}.height('146lpx')
.justifyContent(FlexAlign.Center)
.onClick(()=>{
})
Divider().width('100%')
.height('1lpx')
.strokeWidth('1lpx')
.backgroundColor($r('app.color.color_EDEDED'))
}.width('100%')
}
}
followOperation(){
let item = new FollowOperationRequestItem(this.data.cnUserType,this.data.cnUserId,this.data.creatorId,HttpUrlUtils.getUserType(),HttpUrlUtils.getUserId(),this.data.status==="0" ? 1:0)
MinePageDatasModel.getFollowOperation(item,getContext(this)).then((value)=>{
if(value!=null){
if (value.code === 0 || value.code.toString() === "0") {
this.data.status = this.data.status ==="0"?"1":"0"
}
}
})
}
}
\ No newline at end of file
... ...
import { Params } from 'wdBean';
import { LazyDataSource, StringUtils } from 'wdKit';
import { HttpUrlUtils } from 'wdNetwork';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import { LazyDataSource } from 'wdKit';
import MinePageDatasModel from '../../../model/MinePageDatasModel';
import { FollowListDetailItem } from '../../../viewmodel/FollowListDetailItem'
import { FollowListDetailRequestItem } from '../../../viewmodel/FollowListDetailRequestItem';
import { FollowListStatusRequestItem } from '../../../viewmodel/FollowListStatusRequestItem';
import { FollowOperationRequestItem } from '../../../viewmodel/FollowOperationRequestItem';
import { MineFollowListDetailItem } from '../../../viewmodel/MineFollowListDetailItem';
import { QueryListIsFollowedItem } from '../../../viewmodel/QueryListIsFollowedItem';
import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI';
import { FollowChildComponent } from './FollowChildComponent';
const TAG = "FollowListDetailUI"
@Component
export struct FollowListDetailUI{
@State creatorDirectoryId:number = -1;
@State type:number = 0
@State data: LazyDataSource<FollowListDetailItem> = new LazyDataSource();
@State count:number = 0;
@State isLoading:boolean = false
... ... @@ -22,7 +20,6 @@ export struct FollowListDetailUI{
curPageNum:number = 1;
aboutToAppear(){
console.log("YCG","aboutToAppear==="+this.creatorDirectoryId);
this.getNewPageData()
}
... ... @@ -35,7 +32,7 @@ export struct FollowListDetailUI{
List({ space: 3 }) {
LazyForEach(this.data, (item: FollowListDetailItem, index: number = 0) => {
ListItem() {
ChildComponent({data: item})
FollowChildComponent({data: item,type:this.type})
}
.onClick(() => {
})
... ... @@ -76,7 +73,8 @@ export struct FollowListDetailUI{
this.hasMore = false
}else{
value.list.forEach((value)=>{
this.data.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,value.fansNum,value.introduction,value.attentionCreatorId,"1",value.attentionUserId,value.attentionUserType,value.attentionUserId))
this.data.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,value.fansNum+"",value.introduction,value.attentionCreatorId,"1",value.attentionUserId,value.attentionUserType,value.attentionUserId))
})
this.data.notifyDataReload()
this.count = this.data.totalCount()
... ... @@ -148,112 +146,4 @@ export struct FollowListDetailUI{
})
}
}
@Component
struct ChildComponent {
@ObjectLink data: FollowListDetailItem
build() {
Column(){
Blank().height('27lpx')
Row() {
Image(StringUtils.isEmpty(this.data.headPhotoUrl)?$r('app.media.default_head'):this.data.headPhotoUrl)
.objectFit(ImageFit.Auto)
.width('92lpx')
.height('92lpx')
.margin({right:'15lpx'})
Column(){
Text(this.data.cnUserName)
.fontWeight('400lpx')
.fontSize('31lpx')
.lineHeight('38lpx')
.fontColor($r('app.color.color_222222'))
.maxLines(1)
Text(`粉丝${this.data.cnFansNum}`)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize('23lpx')
.maxLines(1)
Text(`${this.data.introduction}`)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize('23lpx')
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}.layoutWeight(1)
.alignItems(HorizontalAlign.Start)
if(this.data.status == "1"){
Row(){
Text(`已关注`)
.fontColor($r('app.color.color_CCCCCC'))
.fontSize('23lpx')
.fontWeight('500lpx')
.lineHeight('35lpx')
}.backgroundColor($r('app.color.color_F5F5F5'))
.borderRadius('6lpx')
.borderColor($r('app.color.color_F5F5F5'))
.borderWidth('2lpx')
.justifyContent(FlexAlign.Center)
.width('100lpx')
.height('46lpx')
.margin({left:'4lpx',top:'23lpx'})
.onClick(()=>{
this.followOperation()
// this.data.status = "0"
})
}else{
Row(){
Image($r('app.media.follow_icon'))
.margin({right:'4lpx'})
.width('23lpx')
.height('23lpx')
Text(`关注`)
.fontColor($r('app.color.color_ED2800'))
.fontSize('23lpx')
.fontWeight('500lpx')
.lineHeight('35lpx')
}.borderColor($r('app.color.color_1AED2800'))
.borderRadius('6lpx')
.borderWidth('2lpx')
.justifyContent(FlexAlign.Center)
.width('100lpx')
.height('46lpx')
.margin({left:'4lpx',top:'23lpx'})
.onClick(()=>{
this.followOperation()
// this.data.status = "1"
})
}
}.alignItems(VerticalAlign.Top)
.width('100%')
.layoutWeight(1)
Divider().width('100%')
.height('2lpx')
.strokeWidth('1lpx')
.backgroundColor($r('app.color.color_EDEDED'))
}.height('146lpx')
.justifyContent(FlexAlign.Center)
.onClick(()=>{
//跳转 人民号的 主页
// let params: Params = {
// pageID: this.data.attentionUserId
// }
// WDRouterRule.jumpWithPage(WDRouterPage.otherNormalUserHomePagePage,params)
})
}
followOperation(){
let item = new FollowOperationRequestItem(this.data.cnUserType,this.data.cnUserId,this.data.creatorId,HttpUrlUtils.getUserType(),HttpUrlUtils.getUserId(),this.data.status==="0" ? 1:0)
MinePageDatasModel.getFollowOperation(item,getContext(this)).then((value)=>{
if(value!=null){
if (value.code === 0 || value.code.toString() === "0") {
this.data.status = this.data.status ==="0"?"1":"0"
}
}
})
}
}
\ No newline at end of file
... ...
... ... @@ -23,7 +23,8 @@ 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}).layoutWeight(1)
FollowListDetailUI({creatorDirectoryId:this.data[this.firstIndex].id,type:1})
.layoutWeight(1)
}else{
this.FollowSecondUI()
}
... ...
... ... @@ -184,7 +184,7 @@ export struct HomePageBottomComponent{
this.hasMore = false
}else{
value.list.forEach((value)=>{
this.data_follow.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,value.fansNum,value.introduction,value.attentionCreatorId,"1",value.attentionUserId,value.attentionUserType,value.attentionUserId))
this.data_follow.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,value.fansNum+"",value.introduction,value.attentionCreatorId,"1",value.attentionUserId,value.attentionUserType,value.attentionUserId))
})
this.data_follow.notifyDataReload()
this.count = this.data_follow.totalCount()
... ...
... ... @@ -116,7 +116,7 @@ export struct OtherHomePageBottomFollowComponent{
this.hasMore = false
}else{
value.list.forEach((value)=>{
this.data_follow.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,value.fansNum,value.introduction,value.attentionCreatorId,"1",value.attentionUserId,value.cnUserType,value.cnUserId))
this.data_follow.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,value.fansNum+"",value.introduction,value.attentionCreatorId,"1",value.attentionUserId,value.cnUserType,value.cnUserId))
})
this.data_follow.notifyDataReload()
this.count = this.data_follow.totalCount()
... ...
... ... @@ -4,11 +4,10 @@ import MinePageMoreFunctionModel from '../../viewmodel/MinePageMoreFunctionModel
import MinePageDatasModel from '../../model/MinePageDatasModel'
import MinePageUserSimpleInfoUI from '../mine/MinePageUserSimpleInfoUI'
import MinePagePersonFunctionUI from '../mine/MinePagePersonFunctionUI'
import MinePageCardUI from '../mine/MinePageCardUI'
import MinePageCreatorFunctionUI from '../mine/MinePageCreatorFunctionUI'
import MinePageMoreFunctionUI from '../mine/MinePageMoreFunctionUI'
import { SPHelper, StringUtils } from 'wdKit'
import { SpConstants } from 'wdConstant'
import dataPreferences from '@ohos.data.preferences';
const TAG = 'MinePageComponent';
... ... @@ -24,12 +23,29 @@ export struct MinePageComponent {
@State creatorData:MinePageCreatorFunctionsItem[] = []
@State moreData:MinePageMoreFunctionModel[] = []
scroller: Scroller = new Scroller()
preferences: dataPreferences.Preferences | null = null;
aboutToAppear(){
this.getUserLogin()
this.getFunctionData()
this.addLoginStatusObserver()
}
async addLoginStatusObserver(){
this.preferences = await SPHelper.default.getPreferences();
let observer = (key: string) => {
if(key == SpConstants.USER_ID){
if(StringUtils.isEmpty(SPHelper.default.getSync(SpConstants.USER_ID,""))){
this.isLogin = false
}else {
this.isLogin = true
}
}
}
this.preferences.on('change', observer);
}
getFunctionData(){
//个人功能数据
this.personalData = MinePageDatasModel.getPersonalFunctionsData()
... ...
import router from '@ohos.router'
import { PeopleShipHomePageNavComponent } from '../peopleShipHomePage/PeopleShipHomeNavComponent'
import { PeopleShipHomePageTopComponent } from '../peopleShipHomePage/PeopleShipHomePageTopComponent'
import { Logger } from 'wdKit'
import { PeopleShipHomePageDataModel } from '../../viewmodel/PeopleShipHomePageDataModel'
import { PeopleShipHomeListComponent } from '../peopleShipHomePage/PeopleShipHomeListComponent'
import { QueryListIsFollowedItem } from '../../viewmodel/QueryListIsFollowedItem'
import { HttpUrlUtils } from 'wdNetwork/Index'
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
import { PageRepository } from '../../repository/PageRepository'
import {
postInteractAccentionOperateParams,
PeopleShipUserDetailData,
ArticleCountData
} from 'wdBean'
@Entry
@Component
struct PeopleShipHomePage {
// Todo 传入数据 后续在修改
creatorId: string = (router.getParams() as Record<string, string>)['creatorId'];
@State arr: number[] = []
// 页面详情数据
@Provide detailModel: PeopleShipUserDetailData = {} as PeopleShipUserDetailData
// 每个分类数量
@State articleModel: ArticleCountData = {} as ArticleCountData
// 总滑动空间
scroller: Scroller = new Scroller()
// 顶部透明度
@State topOpacity: number = 0
//发布数量
@State publishCount: number = 0
// 是否关注
@Provide isAttention: string = '0'
// 是否开始更新关注
@Provide @Watch('handleChangeAttentionStata') isLoadingAttention: boolean = false
//关注显示
@Prop attentionOpacity: boolean = false
@Provide topHeight: number = 400
build() {
Stack({ alignContent: Alignment.TopStart }) {
// 头部返回
PeopleShipHomePageNavComponent({
attentionOpacity: this.attentionOpacity,
topOpacity: this.topOpacity,
detailModel: this.detailModel
})
.height($r('app.float.top_bar_height'))
.zIndex(100)
.backgroundColor(Color.Transparent)
if (this.detailModel && this.detailModel.userName) {
Scroll(this.scroller) {
Column() {
// 顶部相关
PeopleShipHomePageTopComponent({
creatorId: this.creatorId,
detailModel: this.detailModel,
publishCount: this.publishCount,
topHeight: this.topHeight
})
.width("100%")
.height(this.topHeight)
.backgroundColor(Color.White)
// 列表
PeopleShipHomeListComponent({
publishCount: this.publishCount,
creatorId: this.creatorId
})
}
.width("100%")
.justifyContent(FlexAlign.Start)
// .height(this.publishCount == 0 ? '100%' : '')
}
.edgeEffect(EdgeEffect.None)
.friction(0.6)
.backgroundColor(Color.White)
.scrollBar(BarState.Off)
.width('100%')
.height('100%')
.onScroll(() => {
// this.topOpacity = yOffset / (this.getDeviceHeight() * 0.2)
this.topOpacity = this.scroller.currentOffset().yOffset / 100
if (this.scroller.currentOffset().yOffset >= this.topHeight - 66) {
this.attentionOpacity = true
} else {
this.attentionOpacity = false
}
console.log(`全局请求失败拦截,message:${this.topOpacity}`)
// System.out.println("输出高度:"+ AttrHelper.vp2px(height,this));
})
}
}
}
async aboutToAppear() {
try {
// 获取页面信息
this.detailModel = await PeopleShipHomePageDataModel.getPeopleShipHomePageDetailInfo(this.creatorId, '', '')
Logger.debug('PeopleShipHomePage', '获取页面信息', `${JSON.stringify(this.detailModel)}`)
// 获取关注
let followList: QueryListIsFollowedItem[] = await PeopleShipHomePageDataModel.getHomePageFollowListStatusData(this.creatorId)
Logger.debug('PeopleShipHomePage', '获取关注信息', `${JSON.stringify(followList)}`)
this.findFollowStata(followList)
} catch (exception) {
}
}
findFollowStata(followList: QueryListIsFollowedItem[]) {
if (followList.length > 0) {
let item: QueryListIsFollowedItem = followList[0]
Logger.debug('PeopleShipHomePage', '关注', `${JSON.stringify(item.status)}`)
this.isAttention = item.status
}
}
handleChangeAttentionStata() {
if (!this.isLoadingAttention) {
return
}
// 未登录,跳转登录
if (!HttpUrlUtils.getUserId()) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
let status = 0
if (this.isAttention == '0') {
status = 1
}
const params: postInteractAccentionOperateParams = {
attentionUserType: this.detailModel.userType || '', //被关注用户类型(1 普通用户 2 视频号 3 矩阵号)
attentionUserId: this.detailModel.userId || '', // 被关注用户号主id
attentionCreatorId: this.creatorId || '', // 被关注用户号主id
// userType: 1,
// userId: HttpUrlUtils.getUserId(),
status: status,
}
PageRepository.postInteractAccentionOperate(params).then(res => {
if (this.isAttention == '1') {
this.isAttention = '0'
} else {
this.isAttention = '1'
}
this.isLoadingAttention = false
})
.catch(() => {
this.isLoadingAttention = false
})
}
}
... ...
import { Logger, DisplayUtils} from 'wdKit'
import { PeopleShipHomePageDataModel } from '../../viewmodel/PeopleShipHomePageDataModel'
import {
ContentDTO,
ArticleListDTO,
LiveDTO,
LiveInfoDTO,
FullColumnImgUrlDTO,
VideoInfoDTO,
RmhInfoDTO,
contentListParams,
InteractDataDTO,
ArticleTypeData,
ArticleListData,
PeopleShipUserDetailData
} from 'wdBean'
import { CardParser } from '../CardParser'
import { PageRepository } from '../../repository/PageRepository'
import { RefreshLayoutBean } from '../page/RefreshLayoutBean'
import CustomRefreshLoadLayout from '../page/CustomRefreshLoadLayout'
import { ErrorComponent } from '../view/ErrorComponent';
import NoMoreLayout from '../page/NoMoreLayout';
import { LazyDataSource } from 'wdKit';
const TAG = 'PeopleShipHomeArticleListComponent';
@Component
export struct PeopleShipHomeArticleListComponent {
// @State arr: ContentDTO[] = []
@State arr: LazyDataSource<ContentDTO> = new LazyDataSource();
@State typeModel: ArticleTypeData = new ArticleTypeData()
@State creatorId: string = ''
@Consume detailModel: PeopleShipUserDetailData
@State private viewType: number = 1;
currentIndex: number = 0
@Link @Watch('onChange') currentTopSelectedIndex: number
@State private hasMore: boolean = true
@State currentPage: number = 1
@State private isLoading: boolean = false
@Consume topHeight: number
build() {
if (this.viewType == 1) {
// LoadingComponent()
this.LoadingLayout()
} else if (this.viewType == 2) {
ErrorComponent()
} else {
this.ListLayout()
}
}
@Builder
LoadingLayout() {
CustomRefreshLoadLayout({
refreshBean: new RefreshLayoutBean(true,
$r('app.media.ic_pull_up_load'), $r('app.string.pull_up_load_text'), 20)
}).height(DisplayUtils.getDeviceHeight() - this.topHeight)
}
@Builder
ListLayout() {
List() {
// 下拉刷新
LazyForEach(this.arr, (item: ContentDTO) => {
ListItem() {
CardParser({ contentDTO: item })
}.width("100%")
.backgroundColor(Color.Transparent)
}, (item: ContentDTO, index: number) => item.objectId + index.toString())
// 加载更多
ListItem() {
if (!this.hasMore) {
NoMoreLayout()
}
}
}
.width("100%")
.height("100%")
.edgeEffect(EdgeEffect.Spring)
.nestedScroll({
scrollForward: NestedScrollMode.PARENT_FIRST,
scrollBackward: NestedScrollMode.SELF_FIRST
})
.onReachEnd(() => {
if(!this.isLoading && this.hasMore){
//加载分页数据
this.getPeopleShipPageArticleList()
}
})
}
aboutToAppear() {
if (this.currentIndex == this.currentTopSelectedIndex) {
this.currentPage = 1
this.getPeopleShipPageArticleList()
}
}
onChange() {
if (this.currentIndex == this.currentTopSelectedIndex) {
this.currentPage = 1
this.getPeopleShipPageArticleList()
}
}
private async getPeopleShipPageArticleList() {
Logger.info(`获取页面信息PeopleShipHomeArticleListComponent${this.typeModel.type}`)
if (this.isLoading) {
return
}
try {
this.isLoading = true
let listData: ArticleListData = await PeopleShipHomePageDataModel.getPeopleShipHomePageArticleListData(this.creatorId, this.currentPage, 20, this.typeModel.type)
Logger.debug(TAG, `获取页面信息, ${listData.list.length}`);
if (listData && listData.list && listData.list.length > 0) {
this.viewType = 3;
if (listData.list.length === 20) {
this.currentPage++;
this.hasMore = true;
} else {
this.hasMore = false;
}
} else {
this.viewType = 1;
}
this.queryArticleContentInteractCount(listData)
Logger.debug(TAG, '展示的总数', `${this.arr.totalCount()}`)
}catch (exception) {
this.isLoading = false
if (this.arr.totalCount() == 0) {
this.viewType = 2
}
}
}
/**
* 查询点赞、收藏数量
*/
private queryArticleContentInteractCount(listData: ArticleListData) {
if (listData && listData.list && listData.list.length > 0) {
const params: contentListParams = {
contentList: []
}
listData.list.map((item: ArticleListDTO) => {
params.contentList.push({
contentId: item.id,
contentType: item.type
})
});
PageRepository.getContentInteract(params).then(res => {
this.articleListDTOChangeContentDTO(listData, res.data ?? [])
}).catch(() => {
this.articleListDTOChangeContentDTO(listData, [])
})
}
}
private articleListDTOChangeContentDTO(listData: ArticleListData, listCom: InteractDataDTO[]) {
this.isLoading = false
if (listData.list.length) {
for (const element of listData.list) {
let contentDTO = {} as ContentDTO
contentDTO.appStyle = this.changeCommon(element.appStyle)
contentDTO.newsTitle = element.title;
contentDTO.newsSummary = element.description;
contentDTO.objectId = element.id;
// 评论数
const comModel = listCom.find((item) => {
return item.contentId == element.id
})
if (comModel) {
contentDTO.interactData = comModel
}
//1:小图卡,2:大图卡,3:无图卡(全标题),
// 4:三图卡,5:头图卡,6:小视频卡,7:作者卡,8:财经快讯卡,
// 9:时间轴卡,10:大专题卡,
// 11.无图卡(标题缩略),12.无图卡(标题缩略)-人民号,
// 13.单图卡,14.单图卡-人民号,
// 15.大图卡-人民号,16.三图卡-人民号,17.图集卡,18.图集卡-人民号,
// 19.动态图文卡-人民号,20.动态视频卡-人民号,
// 21 小视频卡-人民号
contentDTO.objectType = `${element.type}`;
// contentDTO.productNum = element.productCount;
// if (master) {
// contentDTO.customWorkStatus = element.workStatus;
// }
// contentDTO.customSchedulePublishTime = element.contentPublishTasks.firstObject.schedulePublishTime;
contentDTO.fullColumnImgUrls = this.fullColumnImgUrls(element);
let rmhInfo = this.convertToRmhInfoWithAccountModel()
if (rmhInfo) {
contentDTO.rmhInfo = rmhInfo;
}
let liveInfo = this.convertToProgramLiveInfoModel(element.live);
if (liveInfo) {
contentDTO.liveInfo = liveInfo;
if (element.vlives && element.vlives.length > 0) {
let vlivesModel = element.vlives[0]
if (vlivesModel.recordUrl && vlivesModel.recordUrl.length > 0) {
contentDTO.liveInfo.replayUri = vlivesModel.recordUrl
}
}
}
let videInfo1 = this.convertToVideoInfo(element);
if (videInfo1) {
contentDTO.videoInfo = videInfo1
}
// contentDTO.shareInfo = [self.contentShare.firstObject convertToShareInfo];
// contentDTO.shareInfo.shareUrl = self.shareUrl;
if (element.createTime.length > 0) {
contentDTO.publishTime = this.convertPublishTimeWith(element.createTime);
} else if (element.updateTime.length > 0) {
contentDTO.publishTime = this.convertPublishTimeWith(element.updateTime);
} else if (element.firstPublishTime.length > 0) {
contentDTO.publishTime = this.convertPublishTimeWith(element.firstPublishTime);
} else if (element.publishTime.length > 0) {
contentDTO.publishTime = this.convertPublishTimeWith(element.publishTime);
}
//图集数量
contentDTO.photoNum = element.mainPicCount;
if (element.contentExt && element.contentExt.length > 0) {
let extModel = element.contentExt[0];
contentDTO.openLikes = extModel.openLikes;
contentDTO.openComment = extModel.openComment;
}
// 页面
if (contentDTO.appStyle == '2' || contentDTO.appStyle == '13' || contentDTO.appStyle == '20') {
if (element.appStyleImages && element.appStyleImages.length > 0) {
contentDTO.coverUrl = element.appStyleImages[0].fullUrl
} else if (element.contentPictures && element.contentPictures.length > 0) {
contentDTO.coverUrl = element.contentPictures[0].fullUrl
}
}
// infoModel.api_isFollowListDataSource = YES;
// //infoModel.topicTemplate = [self.topicTemplate integerValue];
// //infoModel.objectLevel = self.topicType;
// //infoModel.pageId = self.pageId;
contentDTO.source = this.detailModel.userName;
// infoModel.opusAllowEdit = master && !([self.workStatus isEqualToString:@"2"] ||
// [self.workStatus isEqualToString:@"6"] ||
// [self.workStatus isEqualToString:@"5"] ||
// [self.workStatus isEqualToString:@"8"] ||
// !self.workStatus);
// infoModel.newsTag = [self convertNewsTagIsMaster:master];
// if (isSerial) {
// contentDTO.coverUrl = element.fullUrl;
// }
this.arr.push(contentDTO)
}
}
// this.arr = listData.list
}
//人民号主页
private convertToRmhInfoWithAccountModel() {
if (this.detailModel) {
let rmhInfo = {} as RmhInfoDTO
rmhInfo.rmhHeadUrl = this.detailModel.headPhotoUrl;
rmhInfo.rmhName = this.detailModel.userName;
rmhInfo.rmhId = this.detailModel.creatorId;
rmhInfo.userId = this.detailModel.userId;
rmhInfo.userType = this.detailModel.userType
rmhInfo.rmhDesc = this.detailModel.introduction;
rmhInfo.cnIsAttention = 0;
rmhInfo.cnIsComment = this.detailModel.isComment;
rmhInfo.cnIsLike = this.detailModel.cnIsLike;
rmhInfo.cnMainControl = this.detailModel.mainControl;
rmhInfo.cnShareControl = this.detailModel.shareControl;
rmhInfo.authIcon = this.detailModel.authIcon;
rmhInfo.authTitle = this.detailModel.authTitle;
// rmhInfo.honoraryIcon = this.detailModel.honoraryIcon;
// rmhInfo.honoraryTitle = this.detailModel.honoraryTitle;
rmhInfo.banControl = this.detailModel.banControl;
return rmhInfo
}
return null
}
//视频信息转换
private convertToVideoInfo(model: ArticleListDTO) {
if (model.appStyleVideos && model.appStyleVideos.length > 0) {
let firstModel = model.appStyleVideos[0]
let videoInfo: VideoInfoDTO = {} as VideoInfoDTO
videoInfo.videoDuration = firstModel.duration
videoInfo.videoUrl = firstModel.url
videoInfo.videoLandscape = firstModel.landscape
videoInfo.firstFrameImageUri = firstModel.fullUrl
return videoInfo
}
else if (model.contentVideos && model.contentVideos.length > 0) {
let firstModel = model.contentVideos[0]
let videoInfo: VideoInfoDTO = {} as VideoInfoDTO
videoInfo.videoDuration = firstModel.duration
videoInfo.videoUrl = firstModel.url
videoInfo.videoLandscape = firstModel.landscape
videoInfo.firstFrameImageUri = firstModel.fullUrl
return videoInfo
}
return null
}
// 直播信息转换
private convertToProgramLiveInfoModel(model: LiveDTO): LiveInfoDTO | null {
if (model) {
let liveInfo = {} as LiveInfoDTO
liveInfo.vrType = model.vr
liveInfo.liveState = model.status
liveInfo.liveLandscape = model.landscape
if (model.recordUrl && model.recordUrl.length > 0) {
liveInfo.replayUri = model.recordUrl
} else if (model.uri && model.uri.length > 0) {
liveInfo.replayUri = model.uri
}
return liveInfo
}
return null
}
// 图片转换
private fullColumnImgUrls(model: ArticleListDTO) {
let imagesList: FullColumnImgUrlDTO[] = [] as FullColumnImgUrlDTO[]
if (model.appStyleImages && model.appStyleImages.length > 0) {
for (const element of model.appStyleImages) {
let imgUrl: FullColumnImgUrlDTO = {} as FullColumnImgUrlDTO
imgUrl.format = element.format
imgUrl.height = element.height
imgUrl.weight = element.weight
imgUrl.size = element.size
imgUrl.landscape = element.landscape
imgUrl.url = element.fullUrl
imgUrl.fullUrl = element.fullUrl
imagesList.push(imgUrl)
}
}
else if (model.contentPictures && model.contentPictures.length > 0) {
for (const element of model.contentPictures) {
let imgUrl: FullColumnImgUrlDTO = {} as FullColumnImgUrlDTO
imgUrl.format = element.format
imgUrl.height = element.height
imgUrl.weight = element.weight
imgUrl.size = element.size
imgUrl.landscape = element.landscape
imgUrl.url = element.fullUrl
imgUrl.fullUrl = element.fullUrl
imagesList.push(imgUrl)
}
}
return imagesList
}
//时间转时间戳
private convertPublishTimeWith(time: string): string {
if (time.length) {
return `${new Date(time).getTime()}`
}
return `${new Date().getTime()}`
}
private changeCommon(appStyle: number): string {
if (appStyle == 12) {
return '11'
}
if (appStyle == 14) {
return '13'
}
if (appStyle == 15) {
return '2'
}
if (appStyle == 16) {
return '4'
}
if (appStyle == 18) {
return '17'
}
if (appStyle == 21) {
return '6'
}
return `${appStyle}`
}
}
\ No newline at end of file
... ...
@Component
export struct PeopleShipHomeAttentionComponent {
@Consume isAttention: string
@Consume isLoadingAttention: boolean
build() {
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Button({type: ButtonType.Normal, stateEffect: false } ) {
Stack() {
Image(this.isAttention == '0'? $r('app.media.home_attention_no_left') : $r('app.media.home_attention_left'))
.width('100%')
.height('100%')
.objectFit(ImageFit.Cover)
Row() {
if(this.isAttention == '0') {
if(this.isLoadingAttention) {
LoadingProgress()
.width(20)
.height(20)
.color($r('app.color.color_fff'))
}else {
Text('+ 关注')
.fontColor(Color.White)
.fontSize($r('app.float.vp_14'))
.fontWeight(500)
.margin({
right: '10vp'
})
}
}else {
if(this.isLoadingAttention) {
LoadingProgress()
.width(20)
.height(20)
.color( $r('app.color.color_CCCCCC'))
}else {
Text('已关注')
.fontSize($r('app.float.vp_14'))
.fontWeight(500)
.fontColor($r('app.color.color_CCCCCC'))
.margin({
right: '10vp'
})
}
}
}
.justifyContent(FlexAlign.Center)
.alignItems(VerticalAlign.Center)
.width('100%')
.height('100%')
}
.width('100%')
.height('100%')
}
.backgroundColor(Color.Transparent)
.width(176)
.height(36)
.padding(0)
.fontColor(Color.Black)
.margin({
right: '-5vp'
})
.onClick(() => {
if(this.isLoadingAttention) {
return
}
this.isLoadingAttention = true
})
Button({type: ButtonType.Normal, stateEffect: false}) {
Stack() {
Image($r('app.media.home_share_right_icon'))
.width('100%')
.height('100%')
.objectFit(ImageFit.Cover)
Row() {
Image($r('app.media.QR_code_icon'))
.width(16)
.height(16)
.objectFit(ImageFit.Cover)
.margin({
left: '10vp'
})
Text('分享名片')
.fontSize($r('app.float.vp_14'))
.fontColor($r('app.color.color_222222'))
.fontWeight(500)
.margin({ left: 5 })
}
.justifyContent(FlexAlign.Center)
.alignItems(VerticalAlign.Center)
.width('100%')
.height('100%')
}
.width('100%')
.height('100%')
}
.backgroundColor(Color.Transparent)
.width(176)
.height(36)
.padding(0)
.fontColor(Color.White)
.margin({
left: '-5vp'
})
.onClick(() => {
})
}
}
}
\ No newline at end of file
... ...
import { DisplayUtils, Logger } from 'wdKit'
import { PeopleShipHomePageDataModel } from '../../viewmodel/PeopleShipHomePageDataModel'
import { PeopleShipHomeArticleListComponent } from './PeopleShipHomeArticleListComponent'
import { ArticleCountData, ArticleTypeData } from 'wdBean'
import CustomRefreshLoadLayout from '../page/CustomRefreshLoadLayout'
import { EmptyComponent } from '../view/EmptyComponent';
import { RefreshLayoutBean } from '../page/RefreshLayoutBean'
@Component
export struct PeopleShipHomeListComponent {
private controller: TabsController = new TabsController()
@State tabArr: ArticleTypeData[] = []
@State creatorId: string = ''
// 发布数量
@Link publishCount: number
@State currentIndex: number = 0
@State private isLoading: boolean = false
@Consume topHeight: number
build() {
if (this.isLoading) {
this.LoadingLayout()
}
// 列表
else if(this.publishCount == 0) {
// 无数据展示
EmptyComponent().height(DisplayUtils.getDeviceHeight() - this.topHeight)
} else {
Tabs({ barPosition: BarPosition.Start, controller: this.controller}) {
ForEach(this.tabArr, (item: ArticleTypeData, index: number) => {
TabContent() {
PeopleShipHomeArticleListComponent({
typeModel: item,
creatorId: this.creatorId,
currentTopSelectedIndex: this.currentIndex,
currentIndex: index
})
}.tabBar(this.tabBuilder(index, item.name ?? ''))
})
}
.backgroundColor(Color.White)
.barWidth('100%')
.barHeight('44vp')
.vertical(false)
.height(DisplayUtils.getDeviceHeight() - 100)
.animationDuration(0)
.divider({
strokeWidth: '0.5vp',
color: $r('app.color.color_F5F5F5'),
startMargin: 0,
endMargin: 0
})
.onChange((index: number) => {
this.currentIndex = index
})
}
}
@Builder
LoadingLayout() {
CustomRefreshLoadLayout({
refreshBean: new RefreshLayoutBean(true,
$r('app.media.ic_pull_up_load'), $r('app.string.pull_up_load_text'), DisplayUtils.getDeviceHeight() - this.topHeight)
}).height(DisplayUtils.getDeviceHeight() - this.topHeight)
}
@Builder tabBuilder(index: number, name: string) {
Column() {
Text(name)
.fontColor(this.currentIndex === index ? $r('app.color.color_222222') : $r('app.color.color_666666') )
.fontSize(18)
.fontWeight(this.currentIndex === index ? 500 : 400)
.lineHeight(22)
.height(22)
.margin({ top: 11, bottom: 1 })
Divider()
.width('15vp')
.strokeWidth(2)
.color('#CB0000')
.opacity(this.currentIndex === index ? 1 : 0)
}.width('100%')
}
async aboutToAppear() {
try {
this.isLoading = true
// 1:点播(视频),2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,8:图文,9:组图,10:H5新闻,11:频道,12:组件 13:音频 14:动态图文 15:动态视频
let articleModel = await PeopleShipHomePageDataModel.getPeopleShipHomePageArticleCountData(1, this.creatorId)
Logger.debug('PeopleShipHomeListComponent', '获取页面信息', `${JSON.stringify(articleModel)}`)
this.updateTopBarData(articleModel)
this.isLoading = false
} catch (exception) {
this.isLoading = false
}
}
// 设置顶部数据
updateTopBarData(articleModel: ArticleCountData) {
if (articleModel) {
this.publishCount = articleModel.publishCount
this.tabArr = []
if (articleModel.publishCount != 0) {
let model: ArticleTypeData = new ArticleTypeData('全部')
this.tabArr.push(model)
}
if (articleModel.twCount != 0) {
let model: ArticleTypeData = new ArticleTypeData('文章', 8)
this.tabArr.push(model)
}
if (articleModel.spCount != 0) {
let model: ArticleTypeData = new ArticleTypeData('视频', 1)
this.tabArr.push(model)
}
if (articleModel.zbCount != 0) {
let model: ArticleTypeData = new ArticleTypeData('直播', 2)
this.tabArr.push(model)
}
if (articleModel.dtCount != 0) {
let model: ArticleTypeData = new ArticleTypeData('动态', 4)
this.tabArr.push(model)
}
if (articleModel.ztCount != 0) {
let model: ArticleTypeData = new ArticleTypeData('图集', 9)
this.tabArr.push(model)
}
}
}
}
\ No newline at end of file
... ...
import router from '@ohos.router'
import { PeopleShipUserDetailData } from 'wdBean'
import { PeopleShipHomePageHeadComponent } from './PeopleShipHomePageHeadComponent'
@Component
export struct PeopleShipHomePageNavComponent {
@Prop topOpacity: number
@Consume isAttention: string
@Consume isLoadingAttention: boolean
@Prop attentionOpacity: boolean
// 页面详情数据
@Prop detailModel: PeopleShipUserDetailData = {} as PeopleShipUserDetailData
build() {
Row() {
Stack({ alignContent: Alignment.TopStart }) {
Row()
.width('100%')
.height('100%')
.backgroundColor($r('app.color.white'))
.opacity(this.topOpacity)
Row() {
Row() {
// 返回
Image((this.topOpacity > 0.5 ? $r('app.media.icon_arrow_left') : $r('app.media.icon_arrow_left_white')))
.width('24vp')
.height('24vp')
.objectFit(ImageFit.Auto)
.margin({ left: '10vp' })
.onClick(() => {
router.back()
})
// 头像
PeopleShipHomePageHeadComponent({
diameter: 30,
iconDiameter: 10,
headPhotoUrl: this.detailModel.headPhotoUrl,
authIcon: this.detailModel.authIcon
})
.margin({
left: '10vp',
})
.visibility((this.topOpacity > 0.5 ? Visibility.Visible : Visibility.Hidden))
// 文字
Text(this.detailModel.userName)
.height('46vp')
.fontSize($r('app.float.vp_14'))
.fontColor($r('app.color.color_222222'))
.margin({
left: '6vp'
})
.visibility((this.topOpacity > 0.5 ? Visibility.Visible : Visibility.Hidden))
if (this.isAttention == '0') {
// 关注
Button('+关注', { type: ButtonType.Normal, stateEffect: true })
.borderRadius(4)
.backgroundColor($r('app.color.color_ED2800'))
.width('54vp')
.height('24vp')
.onClick(() => {
if (this.isLoadingAttention){
return
}
this.isLoadingAttention = true
})
.margin({
left: '12vp',
})
.padding(0)
.fontSize($r('app.float.vp_12'))
.fontColor(Color.White)
.visibility((this.attentionOpacity ? Visibility.Visible : Visibility.Hidden))
} else {
Button('已关注', { type: ButtonType.Normal, stateEffect: true })
.borderRadius(4)
.backgroundColor($r('app.color.color_F5F5F5'))
.width('54vp')
.height('24vp')
.onClick(() => {
if (this.isLoadingAttention){
return
}
this.isLoadingAttention = true
})
.margin({
left: '12vp',
})
.padding(0)
.fontSize($r('app.float.vp_12'))
.fontColor($r('app.color.color_999999'))
.visibility((this.attentionOpacity ? Visibility.Visible : Visibility.Hidden))
}
}
.height('100%')
Blank()
// 分享
Image((this.topOpacity > 0.5 ? $r('app.media.icon_forward') : $r('app.media.icon_share')))
.width('24vp')
.height('24vp')
.objectFit(ImageFit.Auto)
.margin({ right: '10vp' })
.onClick(() => {
})
}
.width('100%')
.height('100%')
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.SpaceBetween)
}
.zIndex(1000)
.width('100%')
.height('100%')
}
}
}
\ No newline at end of file
... ...
@Component
export struct PeopleShipHomePageAttestationComponent {
@Prop name: string
@Prop content: string
build() {
Row() {
Text(this.name)
.lineHeight('16vp')
.fontColor($r('app.color.color_ED2800'))
.fontSize($r('app.float.vp_11'))
.backgroundColor($r('app.color.color_1AED2800'))
.textAlign(TextAlign.Center)
.borderRadius('2vp')
.margin({
right: '4vp',
left: '16vp',
})
.padding({
top: '3vp',
bottom: '3vp',
right: '6vp',
left: '6vp'
})
Text(this.content)
.lineHeight('22vp')
.fontSize($r('app.float.vp_12'))
.layoutWeight(1)
.fontColor($r('app.color.color_222222'))
.textAlign(TextAlign.Start)
.margin({
right: '16vp'
})
}
.width('100%')
.alignItems(VerticalAlign.Top)
}
}
\ No newline at end of file
... ...
@Component
export struct PeopleShipHomePageHeadComponent {
@State diameter: number = 30
@State iconDiameter: number = 10
@Prop headPhotoUrl: string = ''
@Prop authIcon: string = ''
build() {
Stack({ alignContent: Alignment.BottomEnd }) {
// 头像
Image( this.headPhotoUrl.length > 0 ? this.headPhotoUrl : $r('app.media.home_page_header_authority') )
.width(this.diameter)
.height(this.diameter)
.borderRadius(this.diameter/2)
.borderWidth('1vp')
.borderStyle(BorderStyle.Solid)
.borderColor(Color.White)
.objectFit(ImageFit.Auto)
if(this.authIcon.length > 0 ) {
Image( this.authIcon )
.width(this.iconDiameter)
.height(this.iconDiameter)
.borderRadius(this.iconDiameter/2)
.objectFit(ImageFit.Auto)
.margin({
right: '-3vp'
})
}
}
}
}
\ No newline at end of file
... ...
import measure from '@ohos.measure'
import { DisplayUtils } from 'wdKit'
import { PeopleShipHomePageHeadComponent } from './PeopleShipHomePageHeadComponent'
import { PeopleShipHomePageAttestationComponent } from './PeopleShipHomePageAttestationComponent'
import { Logger } from 'wdKit'
import { PeopleShipHomePageDataModel } from '../../viewmodel/PeopleShipHomePageDataModel'
import { InfluenceData, PeopleShipUserDetailData } from 'wdBean'
import { PeopleShipHomeAttentionComponent } from './PeopleShipHomeAttentionComponent'
@Component
export struct PeopleShipHomePageTopComponent {
@State creatorId: string = ''
// 是否关注
// @Prop isAttention: string
@State introductionType: number = 0
@State heightComponent: number = 0
// 页面详情数据
@Prop @Watch('onIntroductionUpdated') detailModel: PeopleShipUserDetailData
@Prop publishCount: number
// 影响力
@State influenceTotal: number = 0
// 简介是否可以展开
@State isCollapse: boolean = true
@State maxLines: number = Infinity
@State collapseTxt: string = '…展开';
private subTxt: string = '';
@State content: string = ''
@State topFixedHeight: number = 320
@State lineInNum: number = 1
@Link topHeight: number
build() {
Column() {
Stack({ alignContent: Alignment.TopStart}) {
// 顶部图片
Image($r('app.media.home_page_bg'))
.width('100%')
.height('120vp')
.objectFit(ImageFit.Fill)
.backgroundColor(Color.Black)
// 头像和名称
Row() {
// 头像
PeopleShipHomePageHeadComponent({
diameter: 80,
iconDiameter: 20,
headPhotoUrl: this.detailModel.headPhotoUrl,
authIcon: this.detailModel.authIcon
}).margin({
left: '10vp',
bottom: '20vp'
})
// 文字
Text(this.detailModel.userName)
.height('50vp')
.fontSize($r('app.float.vp_22'))
.fontColor($r('app.color.color_222222'))
.fontWeight(500)
.textAlign(TextAlign.Start)
.textOverflow({overflow: TextOverflow.Ellipsis})
.maxLines(2)
.layoutWeight(1)
.margin({
left: '12vp',
bottom: '10vp',
right: '12vp'
})
}
.width('100%')
.height('100%')
.alignItems(VerticalAlign.Bottom)
}
.width('100%')
.height('180vp')
.backgroundColor(Color.Transparent)
// 认证id:1蓝2黄,蓝v 只有官方认证,黄v有领域和身份认证
// 官方认证
if(this.detailModel.authId == 1 && this.detailModel.categoryAuth.length > 0) {
PeopleShipHomePageAttestationComponent({name: '官方认证', content: this.detailModel.categoryAuth})
.margin({
top: '10vp',
bottom: '10vp'
})
}
if(this.detailModel.authId == 2) {
if (this.detailModel.authTitle && this.detailModel.authTitle.length > 0 ){
PeopleShipHomePageAttestationComponent({name: '领域认证', content: this.detailModel.authTitle})
.margin({
top: '10vp',
bottom: '10vp'
})
}
if (this.detailModel.authPersonal && this.detailModel.authPersonal.length > 0 ){
PeopleShipHomePageAttestationComponent({name: '身份认证', content: this.detailModel.authPersonal})
.margin({
top: '10vp',
bottom: '10vp'
})
}
}
// 简介
if(this.lineInNum > 3) {
Row() {
Text() {
Span(this.content)
.fontColor($r('app.color.color_222222'))
Span(this.collapseTxt)
.onClick(()=>{
if(this.isCollapse){
this.maxLines = Infinity;
this.content = `简介:${this.detailModel.introduction}`
this.isCollapse = false;
this.collapseTxt = '收起';
this.topHeight = this.topFixedHeight + 21 * this.lineInNum
}else{
this.isCollapse = true;
this.collapseTxt = '…展开';
this.content = this.subTxt;
this.topHeight = this.topFixedHeight + 21 * 3
}
})
.fontColor($r('app.color.color_B0B0B0'))
}
.lineHeight('21vp')
.maxLines(this.maxLines)
.textOverflow({overflow: TextOverflow.Ellipsis})
.fontSize($r('app.float.vp_14'))
.key('home_page_introduction')
.margin({
left: '16vp',
right: '16vp',
bottom: '10vp'
})
}.width('100%')
.alignItems(VerticalAlign.Top)
}else {
Row() {
Text(`简介:${this.detailModel.introduction}`)
.fontSize($r('app.float.vp_14'))
.fontColor($r('app.color.color_222222'))
.lineHeight('21vp')
.maxLines(3)
.textOverflow({overflow: TextOverflow.Ellipsis})
.margin({
left: '16vp',
right: '16vp',
bottom: '10vp'
})
}.width('100%')
.alignItems(VerticalAlign.Top)
}
// IP归属地
Text(`IP归属地:${this.detailModel.region}`)
.lineHeight('18vp')
.fontSize($r('app.float.vp_12'))
.fontColor($r('app.color.color_999999'))
.textAlign(TextAlign.Start)
.width('100%')
.alignSelf(ItemAlign.Start)
.margin({
right: '16vp',
left: '16vp',
})
// 发布, 粉丝, 影响力
Row() {
// 发布
Text(this.computeShowNum(this.publishCount))
.fontSize($r('app.float.vp_20'))
.fontColor($r('app.color.color_222222'))
.lineHeight('22vp')
.textAlign(TextAlign.Center)
.fontWeight(600)
.margin({
right: '4vp',
left: '16vp'
})
Text('发布')
.fontSize($r('app.float.vp_12'))
.fontColor($r('app.color.color_666666'))
.align(Alignment.Center)
.height('22vp')
// 粉丝
Text(this.computeShowNum(this.detailModel.fansNum))
.fontSize($r('app.float.vp_20'))
.fontColor($r('app.color.color_222222'))
.lineHeight('22vp')
.fontWeight(600)
.textAlign(TextAlign.Center)
.margin({
right: '4vp',
left: '12vp'
})
Text('粉丝')
.fontSize($r('app.float.vp_12'))
.fontColor($r('app.color.color_666666'))
.height('22vp')
.align(Alignment.Center)
//影响力
Text(this.computeShowNum(this.influenceTotal))
.lineHeight('22vp')
.fontSize($r('app.float.vp_20'))
.fontColor($r('app.color.color_222222'))
.fontWeight(600)
.height('22vp')
.margin({
right: '4vp',
left: '12vp'
})
Text('影响力')
.fontSize($r('app.float.vp_12'))
.fontColor($r('app.color.color_666666'))
.height('22vp')
.align(Alignment.Center)
}
.alignItems(VerticalAlign.Center)
.backgroundColor(Color.Transparent)
.width('100%')
.margin({
top: '16vp'
})
// 分享-关注
PeopleShipHomeAttentionComponent()
.width('100%')
.margin({
top: '10vp',
bottom: '16vp'
})
Row()
.backgroundColor($r('app.color.color_F5F5F5'))
.width('100%')
.height('6vp')
}
.width('100%')
.height('100%')
}
async aboutToAppear() {
try {
// 获取影响力
let infData: InfluenceData = await PeopleShipHomePageDataModel.getCreatorInfluenceInfoData(this.creatorId)
Logger.debug('PeopleShipHomePageTopComponent', '获取获取影响力信息', `${JSON.stringify(infData)}`)
this.influenceTotal = infData.influenceTotal
} catch (exception) {
}
if (this.content.length == 0) {
this.onIntroductionUpdated()
}
}
// 不听减去2个字-一直到时3行
private compIntroductionTextHeights() {
let introduction = `简介:${this.detailModel.introduction}`
let lineInNum1 = this.getTextLineNum(introduction, DisplayUtils.getDeviceWidth() - 32, 21, $r('app.float.vp_14'))
while (lineInNum1 > 3 ) {
introduction = introduction.substring(0, introduction.length - 2);
lineInNum1 = this.getTextLineNum(introduction, DisplayUtils.getDeviceWidth() - 32, 21, $r('app.float.vp_14'))
}
introduction = introduction.substring(0, introduction.length - 3);
Logger.debug('PeopleShipHomePageTopComponent', '3行简介:', `${introduction}`)
this.subTxt = introduction;
}
// 获取文本几行
private getTextLineNum(text: string, constraintWidth: number, lineHeight: number, fontSize: number | string | Resource) {
let size = this.topMeasureText(text, constraintWidth, lineHeight, fontSize)
let height: number = Number(size.height)
return Math.ceil(px2vp(height)/lineHeight)
}
private topMeasureText(text: string, constraintWidth: number, lineHeight: number, fontSize: number | string | Resource) {
return measure.measureTextSize({
textContent: text,
fontSize: fontSize,
lineHeight: lineHeight,
constraintWidth: constraintWidth,
})
}
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) {
this.compIntroductionTextHeights()
this.content = this.subTxt
}
}
if (this.detailModel) {
this.topFixedHeight = 336
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
}
else if(this.detailModel.authId == 2) {
if (this.detailModel.authTitle && this.detailModel.authTitle.length > 0 ){
this.topFixedHeight += this.getTextLineNum(this.detailModel.authTitle, DisplayUtils.getDeviceWidth() - 90, 22, $r('app.float.vp_12'))*22
}
if (this.detailModel.authPersonal && this.detailModel.authPersonal.length > 0 ){
if (this.detailModel.authTitle && this.detailModel.authTitle.length > 0 ){
this.topFixedHeight += 10
}
this.topFixedHeight += this.getTextLineNum(this.detailModel.authPersonal, DisplayUtils.getDeviceWidth() - 90, 22, $r('app.float.vp_12'))*22
}
}
this.lineInNum = this.getTextLineNum(`简介:${this.detailModel.introduction}`, DisplayUtils.getDeviceWidth() - 32, 21, $r('app.float.vp_14'))
if (this.lineInNum <= 3) {
this.topFixedHeight += (21 * this.lineInNum)
this.topHeight = this.topFixedHeight
}else {
this.topHeight = this.topFixedHeight + (this.isCollapse ? 21*3 : 21 * this.lineInNum )
}
}
}
private computeShowNum(count: number) {
if(count >= 10000) {
return `${(count/10000).toFixed(1)}万`
}
return `${count}`
}
}
\ No newline at end of file
... ...
import { SearchRmhDescription } from '../../viewmodel/SearchResultContentItem'
@Component
export struct SearchCreatorComponent{
@ObjectLink item: SearchRmhDescription
build() {
Column(){
Image(this.item.headerPhotoUrl)
.width('92lpx')
.alt($r('app.media.default_head'))
.height('92lpx')
.margin({bottom:'15lpx'})
.borderRadius(50)
Text(this.item.creatorName)
.fontSize('25lpx')
.fontWeight('400lpx')
.lineHeight('35lpx')
.constraintSize({maxWidth:'150lpx'})
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}.alignItems(HorizontalAlign.Center)
.justifyContent(FlexAlign.Center)
}
}
\ No newline at end of file
... ...
import { ContentDTO,
contentListParams,
FullColumnImgUrlDTO, InteractDataDTO, RmhInfoDTO, VideoInfoDTO } from 'wdBean/Index'
FullColumnImgUrlDTO, InteractDataDTO,
Params,
RmhInfoDTO, VideoInfoDTO } from 'wdBean/Index'
import { LiveInfoDTO } from 'wdBean/src/main/ets/bean/detail/LiveInfoDTO'
import { VoiceInfoDTO } from 'wdBean/src/main/ets/bean/detail/VoiceInfoDTO'
import { LazyDataSource, StringUtils, ToastUtils } from 'wdKit/Index'
import { LazyDataSource, Logger, StringUtils, ToastUtils } from 'wdKit/Index'
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
import SearcherAboutDataModel from '../../model/SearcherAboutDataModel'
import { CreatorDetailRequestItem } from '../../viewmodel/CreatorDetailRequestItem'
import { SearchResultContentData } from '../../viewmodel/SearchResultContentData'
... ... @@ -11,6 +14,7 @@ import { SearchRmhDescription } from '../../viewmodel/SearchResultContentItem'
import { CardParser } from '../CardParser'
import { ListHasNoMoreDataUI } from '../reusable/ListHasNoMoreDataUI'
import { ActivityItemComponent } from './ActivityItemComponent'
import { SearchCreatorComponent } from './SearchCreatorComponent'
const TAG = "SearchResultContentComponent"
... ... @@ -20,9 +24,8 @@ export struct SearchResultContentComponent{
@State searchType:string = ""
@State data: LazyDataSource<ContentDTO> = new LazyDataSource();
@State data_rmh: SearchRmhDescription[] = []
@State count:number = 0;
@State count:number = -1;
@State isLoading:boolean = false
@State isLoading2:boolean = false
@State hasMore:boolean = true
curPageNum:number = 1;
... ... @@ -53,24 +56,30 @@ export struct SearchResultContentComponent{
this.isLoading = false
}else{
if(value.list[0].dataList!=null){
this.data_rmh = value.list[0].dataList
let data_temp: SearchRmhDescription[] = []
data_temp = value.list[0].dataList
//TODO 查询创作者详情接口
let request = new CreatorDetailRequestItem()
this.data_rmh .forEach((data)=>{
data_temp.forEach((data)=>{
request.creatorIdList.push(data.creatorId)
})
SearcherAboutDataModel.getCreatorDetailListData(request).then((value)=>{
if(value!=null && value.length>0){
this.data_rmh.forEach((data)=>{
data_temp.forEach((data)=>{
value.forEach((item)=>{
if(data.creatorId == item.creatorId){
data.headerPhotoUrl = item.headPhotoUrl
data.headerPhotoUrl = item.headPhotoUrl.split("?")[0]
}
})
})
}
data_temp.forEach((data)=>{
this.data_rmh.push(data)
})
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
})
... ... @@ -80,6 +89,7 @@ export struct SearchResultContentComponent{
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
this.isLoading = false
this.count = this.count===-1?0:this.count
})
}
}
... ... @@ -155,7 +165,7 @@ export struct SearchResultContentComponent{
vImageUrl: "",
screenType: "",
source: StringUtils.isEmpty(value.data.creatorName) ? value.data.sourceName : value.data.creatorName,
objectId: "",
objectId: value.data.id,
objectType: value.data.type,
channelId: value.data.channelId,
relId: value.data.relId,
... ... @@ -196,6 +206,7 @@ export struct SearchResultContentComponent{
}).catch((err:Error)=>{
console.log(TAG,"请求失败")
this.isLoading = false
this.count = this.count===-1?0:this.count
})
}
... ... @@ -210,23 +221,7 @@ export struct SearchResultContentComponent{
List({space:'8lpx'}) {
ForEach(this.data_rmh, (item: SearchRmhDescription, index: number) => {
ListItem() {
Column(){
Image(item.headerPhotoUrl)
.width('92lpx')
.alt($r('app.media.default_head'))
.height('92lpx')
.margin({bottom:'15lpx'})
.borderRadius(50)
Text(item.creatorName)
.fontSize('25lpx')
.fontWeight('400lpx')
.lineHeight('35lpx')
.constraintSize({maxWidth:'150lpx'})
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}.alignItems(HorizontalAlign.Center)
.justifyContent(FlexAlign.Center)
SearchCreatorComponent({item:item})
}.onClick(()=>{
//TODO 跳转
})
... ... @@ -235,16 +230,27 @@ export struct SearchResultContentComponent{
})
ListItem(){
Text("查看更多")
.height('180lpx')
.textAlign(TextAlign.Center)
.width('77lpx')
.backgroundColor($r('app.color.color_EDEDED'))
.fontColor($r('app.color.color_9E9E9E'))
.borderRadius({topLeft:'4lpx',bottomLeft:'4lpx'})
Column(){
Text("查看更多")
.width('19lpx')
.fontSize('19lpx')
.fontWeight('400lpx')
.lineHeight('27lpx')
.fontColor($r('app.color.color_9E9E9E'))
}.borderRadius({topLeft:'4lpx',bottomLeft:'4lpx'})
.height('180lpx')
.width('77lpx')
.backgroundColor($r('app.color.color_EDEDED'))
.justifyContent(FlexAlign.Center)
}.height('100%')
.margin({left:'23lpx'})
.onClick(()=>{
let params: Params = {
pageID: this.keywords
}
WDRouterRule.jumpWithPage(WDRouterPage.searchCreatorPage,params)
})
}
.cachedCount(6)
.edgeEffect(EdgeEffect.Spring)
... ... @@ -252,14 +258,6 @@ export struct SearchResultContentComponent{
.listDirection(Axis.Horizontal)
.width('100%')
.height('219lpx')
.onReachEnd(()=>{
if(!this.isLoading2){
this.isLoading2 = true
//进入更多关注页
ToastUtils.shortToast("进入更多关注页")
}
})
Divider()
.width('100%')
... ...
... ... @@ -2,7 +2,6 @@ import router from '@ohos.router'
import { Params } from 'wdBean';
import { StringUtils } from 'wdKit';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import { CardParser } from '../components/CardParser';
import { HomePageBottomComponent } from '../components/mine/home/HomePageBottomComponent';
import MinePageDatasModel from '../model/MinePageDatasModel';
... ... @@ -53,100 +52,100 @@ struct MineHomePage {
Scroll() {
Column() {
//用户信息区域
Row() {
Stack(){
Image(this.headPhotoUrl)
.alt($r('app.media.default_head'))
.width('100lpx')
.height('100lpx')
.objectFit(ImageFit.Auto)
.borderRadius(50)
Image(this.levelHead)
.width('130lpx')
.height('130lpx')
.objectFit(ImageFit.Cover)
}.onClick(()=>{
let params: Params = {
pageID: "531267787833221"//sit 测试用 512157124138245
}
WDRouterRule.jumpWithPage(WDRouterPage.otherNormalUserHomePagePage,params)
}).width('135lpx')
.height('135lpx')
Column() {
Row() {
Text(`${this.userName}`)
.fontColor($r('app.color.white'))
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize('38lpx')
.lineHeight('50lpx')
.fontWeight('500lpx')
Text(`等级${this.levelId}`)
.textAlign(TextAlign.Center)
.fontColor($r('app.color.color_ED2800'))
.backgroundColor($r('app.color.white'))
.fontSize('19lpx')
.width('96lpx')
.height('35lpx')
.margin({ left: '10lpx' })
Blank()
}.width('507lpx')
Row() {
Stack(){
Image(this.headPhotoUrl)
.alt($r('app.media.default_head'))
.width('100lpx')
.height('100lpx')
.objectFit(ImageFit.Auto)
.borderRadius(50)
Image(this.levelHead)
.width('130lpx')
.height('130lpx')
.objectFit(ImageFit.Cover)
}.onClick(()=>{
let params: Params = {
pageID: "531267787833221"//sit 测试用 512157124138245
}
WDRouterRule.jumpWithPage(WDRouterPage.otherNormalUserHomePagePage,params)
}).width('135lpx')
.height('135lpx')
Column() {
Row() {
Text(`${this.userName}`)
.fontColor($r('app.color.white'))
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize('38lpx')
.lineHeight('50lpx')
.fontWeight('500lpx')
Text(`等级${this.levelId}`)
.textAlign(TextAlign.Center)
.fontColor($r('app.color.color_ED2800'))
.backgroundColor($r('app.color.white'))
.fontSize('19lpx')
.width('96lpx')
.height('35lpx')
.margin({ left: '10lpx' })
Blank()
}.width('507lpx')
Row() {
Row() {
Row() {
Text(`${this.browseNum}`)
.textStyle()
Text("阅读")
.textStyle2()
}
.margin({ right: '15lpx' })
Divider()
.height('19lpx')
.width('2lpx')
.color($r('app.color.white'))
.vertical(true)
.opacity(0.4)
Row() {
Text(`${this.commentNum}`)
.textStyle()
Text("评论")
.textStyle2()
}.margin({ right: '15lpx', left: '15lpx' })
Divider()
.height('19lpx')
.width('2lpx')
.color($r('app.color.white'))
.vertical(true)
.opacity(0.4)
Row() {
Text(`${this.attentionNum}`)
.textStyle()
Text("关注")
.textStyle2()
}.margin({ left: '15lpx' })
}.margin({ top: '23lpx' })
}.alignItems(HorizontalAlign.Start)
.margin({ left: '32lpx' })
}
.onAreaChange((oldValue: Area, newValue: Area) => {
if (this.firstPositionY === 0) {
this.firstPositionY = newValue.globalPosition.y as number
}else{
let persent = (this.firstPositionY - Number(newValue.globalPosition.y)) / (this.firstPositionY * 0.3)
if(persent > 1){
persent = 1
Text(`${this.browseNum}`)
.textStyle()
Text("阅读")
.textStyle2()
}
this.tileOpacity = persent
.margin({ right: '15lpx' })
Divider()
.height('19lpx')
.width('2lpx')
.color($r('app.color.white'))
.vertical(true)
.opacity(0.4)
Row() {
Text(`${this.commentNum}`)
.textStyle()
Text("评论")
.textStyle2()
}.margin({ right: '15lpx', left: '15lpx' })
Divider()
.height('19lpx')
.width('2lpx')
.color($r('app.color.white'))
.vertical(true)
.opacity(0.4)
Row() {
Text(`${this.attentionNum}`)
.textStyle()
Text("关注")
.textStyle2()
}.margin({ left: '15lpx' })
}.margin({ top: '23lpx' })
}.alignItems(HorizontalAlign.Start)
.margin({ left: '32lpx' })
}
.onAreaChange((oldValue: Area, newValue: Area) => {
if (this.firstPositionY === 0) {
this.firstPositionY = newValue.globalPosition.y as number
}else{
let persent = (this.firstPositionY - Number(newValue.globalPosition.y)) / (this.firstPositionY * 0.3)
if(persent > 1){
persent = 1
}
})
.backgroundColor($r('app.color.color_transparent'))
.height('184lpx')
.width('100%')
.padding({ left: '35lpx' })
this.tileOpacity = persent
}
})
.backgroundColor($r('app.color.color_transparent'))
.height('184lpx')
.width('100%')
.padding({ left: '35lpx' })
//用户简介区域
Column() {
Row() {
... ... @@ -183,46 +182,21 @@ struct MineHomePage {
Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
Column(){
Column() {
// 页签
Row({ space: 7 }) {
Scroll() {
Row() {
this.TabBuilder(0,"评论")
this.TabBuilder(1,"关注")
}
.justifyContent(FlexAlign.Start)
}
.align(Alignment.Start)
.scrollable(ScrollDirection.Horizontal)
.scrollBar(BarState.Off)
.width('90%')
.padding({left:'31lpx'})
}
.alignItems(VerticalAlign.Bottom)
.width('100%')
}
.alignItems(HorizontalAlign.Start)
.width('100%')
//tab 页面
Tabs({controller: this.controller}) {
TabContent() {
HomePageBottomComponent({style:0})
}
TabContent() {
HomePageBottomComponent({style:1})
}
}
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
.barHeight(0)
//tab 页面
Tabs({controller: this.controller}) {
TabContent() {
HomePageBottomComponent({style:0})
}.tabBar(this.TabBuilder(0,"评论"))
TabContent() {
HomePageBottomComponent({style:1})
}.tabBar(this.TabBuilder(1,"关注"))
}
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
}.width("100%")
}
.edgeEffect(EdgeEffect.None)
... ... @@ -232,8 +206,8 @@ struct MineHomePage {
}
}.width('100%')
.layoutWeight(1)
}
}
@Builder MineHomeTitleTransparent() {
RelativeContainer() {
//标题栏目
... ... @@ -291,35 +265,35 @@ struct MineHomePage {
.onClick(() => {
router.back()
})
Image(`${this.headPhotoUrl}`)
.alt($r('app.media.default_head'))
.width('60lpx')
.height('60lpx')
.objectFit(ImageFit.Auto)
.id("head_icon")
.borderRadius(50)
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
left: { anchor: "back_icon", align: HorizontalAlign.End }
})
.margin({ left: '31lpx' })
.onClick(() => {
router.back()
})
Text(`${this.userName}`)
.height('42lpx')
.maxLines(1)
.id("title")
.fontSize('35lpx')
.fontWeight('400lpx')
.fontColor($r('app.color.color_222222'))
.lineHeight('42lpx')
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
left: { anchor: "head_icon", align: HorizontalAlign.End }
})
.margin({ left: '12lpx' })
Image(`${this.headPhotoUrl}`)
.alt($r('app.media.default_head'))
.width('60lpx')
.height('60lpx')
.objectFit(ImageFit.Auto)
.id("head_icon")
.borderRadius(50)
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
left: { anchor: "back_icon", align: HorizontalAlign.End }
})
.margin({ left: '31lpx' })
.onClick(() => {
router.back()
})
Text(`${this.userName}`)
.height('42lpx')
.maxLines(1)
.id("title")
.fontSize('35lpx')
.fontWeight('400lpx')
.fontColor($r('app.color.color_222222'))
.lineHeight('42lpx')
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
left: { anchor: "head_icon", align: HorizontalAlign.End }
})
.margin({ left: '12lpx' })
Text("编辑资料")
.height('42lpx')
... ... @@ -368,9 +342,9 @@ struct MineHomePage {
this.currentIndex = index
this.controller.changeIndex(this.currentIndex)
})
.height('77lpx')
.width('70lpx')
.margin({right:'29lpx'})
.height('100%')
.width('100%')
.margin({right:'9lpx'})
}
/**
... ...
... ... @@ -14,7 +14,7 @@ struct OtherNormalUserHomePage {
@State params:Params = router.getParams() as Params;
@Watch('change') @State curUserId: string = '-1';
onPageShow() {
onPageShow() {
this.curUserId = this.params?.pageID;
}
... ... @@ -172,51 +172,24 @@ struct OtherNormalUserHomePage {
.width('100%')
.backgroundColor($r('app.color.white'))
}
//间隔符
Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
Column(){
Column() {
// 页签
Row({ space: 7 }) {
Scroll() {
Row() {
this.TabBuilder(0,"评论")
this.TabBuilder(1,"关注")
}
.justifyContent(FlexAlign.Start)
}
.align(Alignment.Start)
.scrollable(ScrollDirection.Horizontal)
.scrollBar(BarState.Off)
.width('90%')
.padding({left:'31lpx'})
}
.alignItems(VerticalAlign.Bottom)
.width('100%')
}
.backgroundColor($r('app.color.white'))
.alignItems(HorizontalAlign.Start)
.width('100%')
//tab 页面
Tabs({controller: this.controller}) {
TabContent() {
OtherHomePageBottomCommentComponent({curUserId:this.curUserId,levelHead:this.levelHead,commentNum:$commentNum})
}
TabContent() {
OtherHomePageBottomFollowComponent({curUserId:this.curUserId})
}
}
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
.barHeight(0)
//tab 页面
Tabs({controller: this.controller}) {
TabContent() {
OtherHomePageBottomCommentComponent({curUserId:this.curUserId,levelHead:this.levelHead,commentNum:$commentNum})
}.tabBar(this.TabBuilder(0,"评论"))
TabContent() {
OtherHomePageBottomFollowComponent({curUserId:this.curUserId})
}.tabBar(this.TabBuilder(1,"关注"))
}
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
}.width("100%")
}
.edgeEffect(EdgeEffect.None)
... ... @@ -327,9 +300,9 @@ struct OtherNormalUserHomePage {
this.currentIndex = index
this.controller.changeIndex(this.currentIndex)
})
.height('77lpx')
.width('70lpx')
.margin({right:'29lpx'})
.height('100%')
.width('100%')
.margin({right:'9lpx'})
}
... ...
import { Params } from 'wdBean/Index';
import { CustomTitleUI } from '../components/reusable/CustomTitleUI';
import { router } from '@kit.ArkUI';
import { FollowListDetailItem } from '../viewmodel/FollowListDetailItem';
import { LazyDataSource } from 'wdKit/Index';
import SearcherAboutDataModel from '../model/SearcherAboutDataModel';
import { CreatorDetailRequestItem } from '../viewmodel/CreatorDetailRequestItem';
import { FollowListStatusRequestItem } from '../viewmodel/FollowListStatusRequestItem';
import { QueryListIsFollowedItem } from '../viewmodel/QueryListIsFollowedItem';
import MinePageDatasModel from '../model/MinePageDatasModel';
import { ListHasNoMoreDataUI } from '../components/reusable/ListHasNoMoreDataUI';
import { FollowChildComponent } from '../components/mine/follow/FollowChildComponent';
const TAG = "SearchCreatorPage"
@Entry
@Component
struct SearchCreatorPage {
@State params: Params = router.getParams() as Params;
@State keyword: string = '';
@State searchType:string = ""
@State data_temp: FollowListDetailItem[] = []
@State data: LazyDataSource<FollowListDetailItem> = new LazyDataSource();
@State count: number = -1;
@State isLoading: boolean = false
@State hasMore: boolean = true
curPageNum: number = 1;
onPageShow() {
this.keyword = this.params?.pageID;
this.searchType = "onlyRmh"
this.getNewPageData()
}
getNewPageData() {
this.isLoading = true
if (this.hasMore) {
SearcherAboutDataModel.getSearchResultListData("20",`${this.curPageNum}`,this.searchType,this.keyword,getContext(this)).then((result)=>{
if (!this.data || result.list.length == 0){
this.hasMore = false
this.isLoading = false
}else{
result.list.forEach((data)=>{
this.data_temp.push(new FollowListDetailItem("",data.data.creatorName,"0","",data.data.id,"0",data.data.userId,data.data.userType,data.data.userId))
})
let request = new CreatorDetailRequestItem()
this.data_temp.forEach((data)=>{
request.creatorIdList.push(data.creatorId)
})
SearcherAboutDataModel.getCreatorDetailListData(request).then((value)=>{
if(value!=null && value.length>0){
this.data_temp.forEach((data)=>{
value.forEach((item)=>{
if(data.creatorId == item.creatorId){
data.headPhotoUrl = item.headPhotoUrl
if(item.fansNum>10000){
let temp = (item.fansNum/10000)+""
let index = temp.indexOf('.')
if(index != -1){
temp = temp.substring(0,index+2)
}else{
temp = temp
}
data.cnFansNum = temp + "万"
}else{
data.cnFansNum = item.fansNum + ""
}
data.introduction = item.introduction
}
})
})
this.getFollowListStatus(result.totalCount)
}
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
this.isLoading = false
this.count = this.count===-1?0:this.count
})
}
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
this.isLoading = false
this.count = this.count===-1?0:this.count
})
}
}
getFollowListStatus(totalCount:number){
let status = new FollowListStatusRequestItem()
this.data_temp.forEach((item)=>{
status.creatorIds.push(new QueryListIsFollowedItem(item.creatorId))
})
MinePageDatasModel.getFollowListStatusData(status,getContext(this)).then((newValue)=>{
newValue.forEach((item)=>{
this.data_temp.forEach((list)=>{
if (item.creatorId == list.creatorId) {
list.status = item.status
}
})
})
this.data_temp.forEach((item)=>{
this.data.push(new FollowListDetailItem(item.headPhotoUrl,item.cnUserName,item.cnFansNum,item.introduction,item.creatorId,item.status,item.attentionUserId,item.cnUserType,item.cnUserId))
})
this.data.notifyDataReload()
this.count = this.data.totalCount()
if (this.data.totalCount() < totalCount) {
this.curPageNum++
}else {
this.hasMore = false
}
this.isLoading = false
}).catch((err:Error)=>{
console.log(TAG,"请求失败")
this.isLoading = false
this.count = this.count===-1?0:this.count
})
}
build() {
Column() {
CustomTitleUI({ titleName: "全部结果" })
Divider()
.width('100%')
.height('1lpx')
.color($r('app.color.color_F5F5F5'))
.strokeWidth('1lpx')
Column(){
if(this.count === 0){
ListHasNoMoreDataUI({style:2})
.height('100%')
}else{
List({ space: 3 }) {
LazyForEach(this.data, (item: FollowListDetailItem, index: number = 0) => {
ListItem() {
FollowChildComponent({data: item,type:1})
}
.onClick(() => {
})
}, (item: FollowListDetailItem, index: number) => index.toString())
//没有更多数据 显示提示
if(!this.hasMore){
ListItem(){
ListHasNoMoreDataUI()
}
}
}.cachedCount(10)
.padding({left:'31lpx',right:'31lpx'})
.layoutWeight(1)
.scrollBar(BarState.Off)
.onReachEnd(()=>{
console.log(TAG,"触底了");
if(!this.isLoading){
this.isLoading = true
//加载分页数据
this.getNewPageData()
}
})
}
}.layoutWeight(1)
.width('100%')
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
... ...
... ... @@ -4,6 +4,7 @@ import { Logger } from 'wdKit';
import { StringUtils } from 'wdKit/src/main/ets/utils/StringUtils';
import { WDRouterRule } from 'wdRouter';
import { ContentConstants } from '../constants/ContentConstants';
import { LiveModel } from '../viewmodel/LiveModel';
const TAG = 'ProcessUtils';
... ... @@ -42,12 +43,12 @@ export class ProcessUtils {
// 图文详情,跳转h5
ProcessUtils.gotoWeb(content);
break;
//图集详情页
//图集详情页
case ContentConstants.TYPE_NINE:
ProcessUtils.gotoAtlasDetailPage(content);
break;
case ContentConstants.TYPE_SPECIAL_TOPIC:
// 专题详情,跳转h5
// 专题详情,跳转h5
ProcessUtils.gotoSpecialTopic(content);
break;
//动态详情页(动态图文)
... ... @@ -71,7 +72,7 @@ export class ProcessUtils {
params: {
detailPageType: 14,
contentID: content?.objectId,
extra:{
extra: {
relType: content?.relType,
relId: content?.relId,
} as ExtraDTO
... ... @@ -91,7 +92,7 @@ export class ProcessUtils {
params: {
detailPageType: 17,
contentID: content?.objectId,
extra:{
extra: {
relType: content?.relType,
relId: content?.relId,
} as ExtraDTO
... ... @@ -111,6 +112,7 @@ export class ProcessUtils {
};
WDRouterRule.jumpWithAction(taskAction)
}
private static gotoWeb(content: ContentDTO) {
// // topicId
// content.channelId;
... ... @@ -126,7 +128,7 @@ export class ProcessUtils {
params: {
contentID: content?.objectId,
pageID: 'IMAGE_TEXT_DETAIL',
extra:{
extra: {
relType: content?.relType,
relId: content?.relId,
channelId: content?.channelId,
... ... @@ -144,7 +146,7 @@ export class ProcessUtils {
params: {
detailPageType: 7,
contentID: content?.objectId,
extra:{
extra: {
relType: content?.relType,
relId: content?.relId,
} as ExtraDTO
... ... @@ -153,13 +155,23 @@ export class ProcessUtils {
WDRouterRule.jumpWithAction(taskAction)
Logger.debug(TAG, `gotoVod, ${content.objectId}`);
}
private static gotoLive(content: ContentDTO) {
private static async gotoLive(content: ContentDTO) {
const liveDetail = await LiveModel.getLiveDetails(content?.objectId || '', content?.relId || '', content?.relType || '')
const liveStyle = liveDetail[0].liveInfo.liveStyle
const liveState = liveDetail[0].liveInfo.liveState
console.error('liveDetail===', liveDetail)
let taskAction: Action = {
type: 'JUMP_DETAIL_PAGE',
params: {
detailPageType: 2,
contentID: content?.objectId,
extra:{
liveStyle: liveState === 'wait' ? 0 : liveStyle,
extra: {
relType: content?.relType,
relId: content?.relId,
} as ExtraDTO
... ... @@ -168,13 +180,14 @@ export class ProcessUtils {
WDRouterRule.jumpWithAction(taskAction)
Logger.debug(TAG, `gotoLive, ${content.objectId}`);
}
private static gotoAudio(content: ContentDTO) {
let taskAction: Action = {
type: 'JUMP_DETAIL_PAGE',
params: {
detailPageType: 13,
contentID: content?.objectId,
extra:{
extra: {
relType: content?.relType,
relId: content?.relId,
} as ExtraDTO
... ... @@ -183,5 +196,4 @@ export class ProcessUtils {
WDRouterRule.jumpWithAction(taskAction)
Logger.debug(TAG, `gotoAudio, ${content.objectId}`);
}
}
\ No newline at end of file
... ...
... ... @@ -63,7 +63,7 @@
export class FollowListDetailItem{
headPhotoUrl:string //头像
cnUserName:string //昵称
cnFansNum:number //粉丝数
cnFansNum:string //粉丝数
introduction:string //介绍
status:string = "0" //是否已经关注
creatorId:string = ""
... ... @@ -80,7 +80,7 @@ export class FollowListDetailItem{
fansNum :number = 0
constructor(headPhotoUrl:string,cnUserName:string,cnFansNum:number,introduction:string,creatorId:string,status:string,attentionUserId:string,cnUserType:string,cnUserId:string) {
constructor(headPhotoUrl:string,cnUserName:string,cnFansNum:string,introduction:string,creatorId:string,status:string,attentionUserId:string,cnUserType:string,cnUserId:string) {
this.headPhotoUrl = headPhotoUrl
this.cnUserName = cnUserName
this.cnFansNum = cnFansNum
... ...
import HashMap from '@ohos.util.HashMap';
import { HttpUrlUtils, ResponseDTO } from 'wdNetwork';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
import { Logger } from 'wdKit';
import { LiveDetailsBean } from 'wdBean/Index';
const TAG = 'LiveModel'
export class LiveModel {
/**
* 直播内容详情
* @param contentId
* @param relId 关系id
* @param relType 关系类型;1.频道关系;2.专题关系;
* @returns
*/
static getLiveDetails(contentId: string, relId: string, relType: string) {
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return new Promise<Array<LiveDetailsBean>>((success, fail) => {
HttpRequest.get<ResponseDTO<Array<LiveDetailsBean>>>(
HttpUrlUtils.getLiveDetailsUrl() + `?relId=${relId}&relType=${relType}&contentId=${contentId}`,
headers).then((data: ResponseDTO<Array<LiveDetailsBean>>) => {
if (!data || !data.data) {
fail("数据为空")
return
}
if (data.code != 0) {
fail(data.message)
return
}
success(data.data)
}, (error: Error) => {
fail(error.message)
Logger.debug(TAG + ":error ", error.toString())
})
})
}
}
... ...
import { OtherUserDetailRequestItem } from './OtherUserDetailRequestItem';
import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { PeopleShipUserDetailData, ArticleCountData, ArticleListData, InfluenceData } from 'wdBean';
import HashMap from '@ohos.util.HashMap';
import { Logger } from 'wdKit';
import { FollowListStatusRequestItem } from './FollowListStatusRequestItem';
import { QueryListIsFollowedItem } from './QueryListIsFollowedItem';
const TAG = 'PeopleShipHomePageDataModel';
export class PeopleShipHomePageDataModel {
/*获取人民号主页详情*/
static fetchPeopleUserDetailData(item: OtherUserDetailRequestItem) {
let url = HttpUrlUtils.getOtherUserDetailDataUrl()
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post<ResponseDTO<PeopleShipUserDetailData>>(url, item, headers)
}
static async getPeopleShipHomePageDetailInfo(creatorId: string, userType: string, userId: string): Promise<PeopleShipUserDetailData> {
let model = new OtherUserDetailRequestItem(creatorId, userType, userId)
return new Promise<PeopleShipUserDetailData>((success, error) => {
Logger.debug(TAG, `getMorningEveningCompInfo pageInfo start`);
PeopleShipHomePageDataModel.fetchPeopleUserDetailData(model)
.then((resDTO: ResponseDTO<PeopleShipUserDetailData>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'getPeopleShipHomePageDetailInfo then navResDTO is empty');
error('resDTO is empty');
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `getPeopleShipHomePageDetailInfo then code:${resDTO.code}, message:${resDTO.message}`);
error('resDTO Response Code is failure');
return
}
Logger.debug(TAG, "getPeopleShipHomePageDetailInfo then,navResDTO.timestamp:" + resDTO.timestamp);
success(resDTO.data);
})
.catch((err: Error) => {
Logger.error(TAG, `getPeopleShipHomePageDetailInfo catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
/*客户端 客态查询发布作品数量*/
static fetchArticleCountHotsData(includeLive: number, creatorId: string) {
let url = HttpUrlUtils.getArticleCountHotsDataUrl() + `?includeLive=${includeLive}&creatorId=${creatorId}`
// let url = 'https://pdapis.pdnews.cn/api/rmrb-content-search/zh/c/article/count' + `?includeLive=${includeLive}&creatorId=${creatorId}`
Logger.debug(TAG, `${url}`);
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.get<ResponseDTO<ArticleCountData>>(url, headers)
}
static async getPeopleShipHomePageArticleCountData(includeLive: number, creatorId: string): Promise<ArticleCountData> {
Logger.debug(TAG, `getPeopleShipHomePageArticleCountData start`);
return new Promise<ArticleCountData>((success, error) => {
Logger.debug(TAG, `getPeopleShipHomePageArticleCountData pageInfo start`);
PeopleShipHomePageDataModel.fetchArticleCountHotsData(includeLive, creatorId)
.then((resDTO: ResponseDTO<ArticleCountData>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'getPeopleShipHomePageArticleCountData then ArticleCountData is empty');
error('resDTO is empty');
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `getPeopleShipHomePageArticleCountData then code:${resDTO.code}, message:${resDTO.message}`);
error(resDTO.message);
return
}
Logger.debug(TAG, "getPeopleShipHomePageArticleCountData then,ArticleCountData.timestamp:" + resDTO.timestamp);
success(resDTO.data);
})
.catch((err: Error) => {
Logger.error(TAG, `getPeopleShipHomePageArticleCountData catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
/*客户端 客态主页页面-获取作品-从发布库获取该创作者下 稿件列表*/
static fetchArticleListHotsData(creatorId: string, pageNum: number, pageSize: number, type?: number) {
let url = HttpUrlUtils.getArticleListHotsDataUrl() + `?creatorId=${creatorId}&pageNum=${pageNum}&pageSize=${pageSize}`
if (type) {
url += `&type=${type}`
}
Logger.debug(TAG, `${url}`);
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.get<ResponseDTO<ArticleListData>>(url, headers)
}
static async getPeopleShipHomePageArticleListData(creatorId: string, pageNum: number, pageSize: number, type?: number): Promise<ArticleListData> {
Logger.debug(TAG, `getPeopleShipHomePageArticleListData start`);
return new Promise<ArticleListData>((success, error) => {
Logger.debug(TAG, `getPeopleShipHomePageArticleListData pageInfo start`);
PeopleShipHomePageDataModel.fetchArticleListHotsData(creatorId, pageNum, pageSize, type)
.then((resDTO: ResponseDTO<ArticleListData>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'getPeopleShipHomePageArticleListData then ArticleCountData is empty');
error('resDTO is empty');
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `getPeopleShipHomePageArticleListData then code:${resDTO.code}, message:${resDTO.message}`);
error(resDTO.message);
return
}
Logger.debug(TAG, "getPeopleShipHomePageArticleListData then,ArticleCountData.timestamp:" + resDTO.timestamp);
success(resDTO.data);
})
.catch((err: Error) => {
Logger.error(TAG, `getPeopleShipHomePageArticleListData catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
/*客户端 客态查询影响力*/
static fetchCreatorInfluenceInfoHotsData(creatorId: string) {
let url = HttpUrlUtils.getCreatorInfluenceInfoHotsDataUrl() + `?creatorId=${creatorId}`
Logger.debug(TAG, `${url}`);
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.get<ResponseDTO<InfluenceData>>(url, headers)
}
static async getCreatorInfluenceInfoData(creatorId: string): Promise<InfluenceData> {
Logger.debug(TAG, `getCreatorInfluenceInfoData start`);
return new Promise<InfluenceData>((success, error) => {
Logger.debug(TAG, `getCreatorInfluenceInfoData pageInfo start`);
PeopleShipHomePageDataModel.fetchCreatorInfluenceInfoHotsData(creatorId)
.then((resDTO: ResponseDTO<InfluenceData>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'getCreatorInfluenceInfoData then ArticleCountData is empty');
error('resDTO is empty');
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `getCreatorInfluenceInfoData then code:${resDTO.code}, message:${resDTO.message}`);
error(resDTO.message);
return
}
Logger.debug(TAG, "getCreatorInfluenceInfoData then,ArticleCountData.timestamp:" + resDTO.timestamp);
success(resDTO.data);
})
.catch((err: Error) => {
Logger.error(TAG, `getCreatorInfluenceInfoData catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
// 获取关注
static fetchHomePageFollowListStatusData(creatorId: string) {
let url = HttpUrlUtils.getFollowListStatusDataUrl()
let model = new QueryListIsFollowedItem(creatorId)
let object = new FollowListStatusRequestItem()
object.creatorIds = [model]
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post<ResponseDTO<QueryListIsFollowedItem[]>>(url,object, headers)
};
static async getHomePageFollowListStatusData(creatorId: string): Promise<QueryListIsFollowedItem[]> {
Logger.debug(TAG, `getCreatorInfluenceInfoData start`);
return new Promise<QueryListIsFollowedItem[]>((success, error) => {
Logger.debug(TAG, `getCreatorInfluenceInfoData pageInfo start`);
PeopleShipHomePageDataModel.fetchHomePageFollowListStatusData(creatorId)
.then((resDTO: ResponseDTO<QueryListIsFollowedItem[]>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'getCreatorInfluenceInfoData then ArticleCountData is empty');
error('resDTO is empty');
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `getCreatorInfluenceInfoData then code:${resDTO.code}, message:${resDTO.message}`);
error(resDTO.message);
return
}
Logger.debug(TAG, "getCreatorInfluenceInfoData then,ArticleCountData.timestamp:" + resDTO.timestamp);
success(resDTO.data);
})
.catch((err: Error) => {
Logger.error(TAG, `getCreatorInfluenceInfoData catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
}
... ...
... ... @@ -181,6 +181,7 @@ class SearchDescription{
}
@Observed
export class SearchRmhDescription{
likeEnable: string= ""
previewUri: string= ""
... ...
... ... @@ -147,6 +147,10 @@
{
"name": "color_9E9E9E",
"value": "#9E9E9E"
},
{
"name": "color_0D000000",
"value": "#0D000000"
}
]
}
\ No newline at end of file
... ...
... ... @@ -231,6 +231,18 @@
{
"name": "margin_116",
"value": "116vp"
},
{
"name": "vp_11",
"value": "11vp"
},
{
"name": "vp_22",
"value": "22vp"
},
{
"name": "vp_14",
"value": "14vp"
}
]
}
... ...
... ... @@ -13,6 +13,8 @@
"components/page/BrowsingHistoryPage",
"components/page/MyCollectionListPage",
"pages/OtherNormalUserHomePage",
"pages/SearchPage"
"pages/SearchPage",
"pages/SearchCreatorPage",
"components/page/PeopleShipHomePage"
]
}
\ No newline at end of file
... ...
... ... @@ -4,10 +4,17 @@ import { BottomComponent } from '../widgets/details/BottomComponent';
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 { devicePLSensorManager } from 'wdDetailPlayApi/Index';
@Entry
@Component
export struct DetailPlayLivePage {
//横竖屏,默认竖屏
@Provide displayDirection: DisplayDirection = DisplayDirection.VERTICAL
TAG: string = 'DetailPlayLivePage';
liveViewModel: LiveViewModel = new LiveViewModel()
@State relId: string = ''
... ... @@ -18,7 +25,17 @@ export struct DetailPlayLivePage {
@State tabs: string[] = ['直播间', '大家聊']
aboutToAppear(): void {
//https://pdapis.pdnews.cn/api/rmrb-bff-display-zh/content/zh/c/content/detail?relId=500005302448&relType=1&contentId=20000016340
//监听屏幕横竖屏变化
let listener = mediaquery.matchMediaSync('(orientation: landscape)');
listener.on("change", (mediaQueryResult) => {
Logger.info(this.TAG,`change;${mediaQueryResult.matches}`)
if (mediaQueryResult.matches) {
this.displayDirection = DisplayDirection.VIDEO_HORIZONTAL
} else {
this.displayDirection = DisplayDirection.VERTICAL
}
// WindowModel.shared.setMainWindowFullScreen(this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL)
})
let par: Action = router.getParams() as Action;
let params = par?.params;
this.relId = params?.extra?.relId || '';
... ... @@ -31,15 +48,24 @@ export struct DetailPlayLivePage {
build() {
Column() {
TopPlayComponent()
.layoutWeight(211)
TabComponent({ tabs: this.tabs })
.layoutWeight(503)
.visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None)
BottomComponent()
.visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None)
}
.height('100%')
.width('100%')
}
onPageShow(): void {
WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED);
}
onPageHide(): void {
devicePLSensorManager.devicePLSensorOff();
WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED);
}
getLiveDetails() {
... ... @@ -72,4 +98,19 @@ export struct DetailPlayLivePage {
aboutToDisappear(): void {
}
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
... ...
import { BottomComponent } from '../widgets/details/BottomComponent';
import { TopPlayComponent } from '../widgets/details/video/TopPlayComponet';
import { TopPlayVComponent } from '../widgets/details/video/TopPlayVComponet';
import { Action, LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Index';
import { LiveViewModel } from '../viewModel/LiveViewModel';
import router from '@ohos.router';
import { WindowModel } from 'wdKit/Index';
import { PlayerComponent } from '../widgets/vertical/PlayerComponent';
import { PlayerInfoComponent } from '../widgets/vertical/PlayerInfoComponent';
import { WDPlayerController } from 'wdPlayer/Index';
const storage = LocalStorage.getShared();
@Entry(storage)
@Component
export struct DetailPlayVLivePage {
TAG: string = 'DetailPlayLivePage';
private liveViewModel: LiveViewModel = new LiveViewModel()
private playerController: WDPlayerController = new WDPlayerController();
private swiperController: SwiperController = new SwiperController()
@Provide bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
@Provide topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
@Provide liveDetailsBean: LiveDetailsBean = {} as LiveDetailsBean
@Provide liveRoomDataBean: LiveRoomDataBean = {} as LiveRoomDataBean
@Provide isMenuVisible: boolean = false
@State relId: string = ''
@State contentId: string = ''
@State relType: string = ''
@State swiperIndex: number = 1
aboutToAppear(): void {
WindowModel.shared.setWindowLayoutFullScreen(true)
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff', })
//https://pdapis.pdnews.cn/api/rmrb-bff-display-zh/content/zh/c/content/detail?relId=500005302448&relType=1&contentId=20000016340
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()
}
aboutToDisappear(): void {
WindowModel.shared.setWindowLayoutFullScreen(false)
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', })
}
build() {
Column() {
TopPlayVComponent()
// TabComponent()
BottomComponent()
Stack() {
PlayerComponent({
playerController: this.playerController
})
.onClick(() => {
this.isMenuVisible = !this.isMenuVisible
})
PlayerInfoComponent({
playerController: this.playerController,
swiperController: this.swiperController,
swiperIndex: $swiperIndex
})
Image($r('app.media.icon_live_more'))
.width(40)
.aspectRatio(1)// .visibility(this.swiperIndex === 0 ? Visibility.Visible : Visibility.Hidden)
.animation({ duration: 500 })
.position({ x: '95%', y: '95%' })
.onClick(() => {
this.swiperController.showNext()
})
}
.height('100%')
.width('100%')
}
.height('100%')
.width('100%')
... ... @@ -23,7 +82,29 @@ export struct DetailPlayVLivePage {
}
aboutToDisappear(): void {
getLiveDetails() {
this.liveViewModel.getLiveDetails(this.contentId, this.relId, this.relType)
.then(
(data) => {
if (data.length > 0) {
this.liveDetailsBean = data[0]
console.error('liveDetailsBean===', JSON.stringify((this.liveDetailsBean)))
}
},
() => {
})
}
getLiveRoomData() {
this.liveViewModel.getLiveRoomData(this.contentId)
.then(
(data) => {
this.liveRoomDataBean = data
},
() => {
})
}
}
\ No newline at end of file
}
... ...
import { window } from '@kit.ArkUI'
import { NumberFormatterUtils, WindowModel } from 'wdKit/Index'
import { devicePLSensorManager } from 'wdDetailPlayApi/Index'
import { DateFormatUtil, WDPlayerController } from 'wdPlayer/Index'
import { LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Index'
import { DisplayDirection } from 'wdConstant/Index'
@Entry
@Component
export struct PlayUIComponent {
playerController: WDPlayerController = new WDPlayerController();
//菜单键是否可见
@State isMenuVisible: boolean = true
@State isFullScreen: boolean = false
@Consume liveDetailsBean: LiveDetailsBean
@Consume liveRoomDataBean: LiveRoomDataBean
@State currentTime: string = ''
... ... @@ -19,6 +17,7 @@ export struct PlayUIComponent {
@State progressVal: number = 0;
//是否处于播放状态中
@State isPlayStatus: boolean = true
@Consume displayDirection: DisplayDirection
aboutToAppear(): void {
//播放进度监听
... ... @@ -47,10 +46,19 @@ export struct PlayUIComponent {
Image($r('app.media.icon_arrow_left_white'))
.width(24)
.aspectRatio(1)
.visibility(Visibility.None)
.visibility(this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL ? Visibility.Visible : Visibility.None)
.margin({
right: 10
})
.onClick(() => {
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);
})
if (this.liveDetailsBean.liveInfo?.liveState != 'wait') {
Text(this.liveDetailsBean.newsTitle)
.maxLines(1)
... ... @@ -66,7 +74,7 @@ export struct PlayUIComponent {
Image($r('app.media.icon_share'))
.width(24)
.aspectRatio(1)
.visibility(Visibility.None)
.visibility(this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL ? Visibility.Visible : Visibility.None)
}
.width('100%')
.alignItems(VerticalAlign.Center)
... ... @@ -196,9 +204,13 @@ export struct PlayUIComponent {
.width(24)
.height(24)
.onClick(() => {
this.isFullScreen = !this.isFullScreen
WindowModel.shared.setPreferredOrientation(this.isFullScreen ? window.Orientation.LANDSCAPE : window.Orientation.PORTRAIT);
devicePLSensorManager.devicePLSensorOn(this.isFullScreen ? window.Orientation.LANDSCAPE : window.Orientation.PORTRAIT);
this.displayDirection = this.displayDirection == DisplayDirection.VERTICAL ? DisplayDirection.VIDEO_HORIZONTAL : 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);
})
}
.alignItems(VerticalAlign.Center)
... ...
import { window } from '@kit.ArkUI'
import { NumberFormatterUtils, WindowModel } from 'wdKit/Index'
import { devicePLSensorManager } from 'wdDetailPlayApi/Index'
import { DateFormatUtil, WDPlayerController } from 'wdPlayer/Index'
import { LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Index'
@Entry
@Component
export struct PlayVUIComponent {
playerController: WDPlayerController = new WDPlayerController();
//菜单键是否可见
@State isMenuVisible: boolean = true
@State isFullScreen: boolean = false
@Consume liveDetailsBean: LiveDetailsBean
@Consume liveRoomDataBean: LiveRoomDataBean
@State currentTime: string = ''
@State totalTime: string = ''
@State progressVal: number = 0;
//是否处于播放状态中
@State isPlayStatus: boolean = true
aboutToAppear(): void {
//播放进度监听
this.playerController.onTimeUpdate = (position: number, duration: number) => {
this.currentTime = DateFormatUtil.secondToTime(Math.floor(position / 1000));
this.totalTime = DateFormatUtil.secondToTime(Math.floor(duration / 1000));
this.progressVal = Math.floor(position * 100 / duration);
}
}
build() {
Column() {
this.getTopUIComponent()
this.getMiddleUIComponent()
this.getBottomUIComponent()
}
.width('100%')
.height('100%')
.alignItems(HorizontalAlign.Start)
}
@Builder
getTopUIComponent() {
Column() {
Row() {
Image($r('app.media.icon_arrow_left_white'))
.width(24)
.aspectRatio(1)
.visibility(Visibility.None)
.margin({
right: 10
})
if (this.liveDetailsBean.liveInfo?.liveState != 'wait') {
Text(this.liveDetailsBean.newsTitle)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize('16fp')
.fontWeight(500)
.fontColor(Color.White)
.textAlign(TextAlign.Start)
.layoutWeight(1)
} else {
Blank()
}
Image($r('app.media.icon_share'))
.width(24)
.aspectRatio(1)
.visibility(Visibility.None)
}
.width('100%')
.alignItems(VerticalAlign.Center)
.margin({
bottom: 10
})
this.getLiveStatusView()
}.width('100%')
.padding({
top: 20,
bottom: 6,
left: 10,
right: 10
})
.alignItems(HorizontalAlign.Start)
.visibility(this.isMenuVisible ? Visibility.Visible : Visibility.None)
}
@Builder
getLiveStatusView() {
// 直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停
// 预约
if (this.liveDetailsBean.liveInfo?.liveState == 'wait') {
Row() {
Image($r('app.media.icon_live_status_wait'))
.width(22)
.height(18)
Text('预约')
.fontSize('11fp')
.fontWeight(400)
.fontColor(Color.White)
}
.backgroundColor('#4D000000')
.padding({
top: 1,
right: 4,
bottom: 1
})
}
// 直播中
else if (this.liveDetailsBean.liveInfo?.liveState == 'running') {
Row() {
Image($r('app.media.icon_live_status_running'))
.width(22)
.height(18)
Text('直播中')
.fontSize('11fp')
.fontWeight(400)
.fontColor(Color.White)
Image($r('app.media.icon_live_player_status_end'))
.width(12)
.height(12)
Text(`${NumberFormatterUtils.formatNumberWithWan(this.liveRoomDataBean.pv)}人参与`)
.fontSize('11fp')
.fontWeight(400)
.fontColor(Color.White)
}
.backgroundColor('#4D000000')
.padding({
top: 1,
right: 4,
bottom: 1
})
}
//回看
else if (this.liveDetailsBean.liveInfo?.liveState == 'end') {
Row() {
Text('回看')
.fontSize('11fp')
.fontWeight(400)
.fontColor(Color.White)
Image($r('app.media.icon_live_player_status_end'))
.width(12)
.height(12)
Text(`${NumberFormatterUtils.formatNumberWithWan(this.liveRoomDataBean.pv)}人参与`)
.fontSize('11fp')
.fontWeight(400)
.fontColor(Color.White)
}
.backgroundColor('#4D000000')
.padding({
left: 4,
top: 1,
right: 4,
bottom: 1
})
}
}
@Builder
getMiddleUIComponent() {
Stack()
.layoutWeight(1)
.width('100%')
.onClick(() => {
this.isMenuVisible = !this.isMenuVisible
})
}
@Builder
getBottomUIComponent() {
Row() {
if (this.liveDetailsBean?.liveInfo?.liveState == 'end') {
this.playOrPauseBtn()
Text(this.currentTime)
.fontColor(Color.White)
.fontWeight(600)
.fontSize('12fp')
.margin({
left: 16
})
this.playProgressView()
Text(this.totalTime)
.fontColor(Color.White)
.fontWeight(600)
.fontSize('12fp')
.margin({
right: 16
})
} else {
Blank()
}
Image($r('app.media.icon_live_player_full_screen'))
.width(24)
.height(24)
.onClick(() => {
this.isFullScreen = !this.isFullScreen
WindowModel.shared.setPreferredOrientation(this.isFullScreen ? window.Orientation.LANDSCAPE : window.Orientation.PORTRAIT);
devicePLSensorManager.devicePLSensorOn(this.isFullScreen ? window.Orientation.LANDSCAPE : window.Orientation.PORTRAIT);
})
}
.alignItems(VerticalAlign.Center)
.linearGradient({ angle: 0, colors: [['#99000000', 0], ['#00000000', 1]] })
.width('100%')
.padding({
left: 10,
right: 10,
top: 15,
bottom: 15
})
.visibility(this.isMenuVisible ? Visibility.Visible : Visibility.None)
}
@Builder
playOrPauseBtn() {
//暂停、播放
Image(this.isPlayStatus ? $r('app.media.icon_live_player_pause') : $r('app.media.player_play_ic'))
.width(24)
.height(24)
.onClick(() => {
if (this.isPlayStatus) {
this.isPlayStatus = false
this.playerController.pause()
} else {
this.isPlayStatus = true
this.playerController.play()
}
})
}
@Builder
playProgressView() {
Slider({
value: this.progressVal,
step: 1,
style: SliderStyle.OutSet
})
.blockSize({
width: 18,
height: 12
})// .blockStyle({
// type: SliderBlockType.IMAGE,
// image: $r('app.media.ic_player_block')
// })
.blockColor(Color.White)
.trackColor('#4DFFFFFF')
.selectedColor('#FFED2800')
.height(14)
.trackThickness(1)
.layoutWeight(1)
.margin({
left: 8,
right: 8
})
.onChange((value: number, mode: SliderChangeMode) => {
this.playerController?.setSeekTime(value, mode);
})
}
}
\ No newline at end of file
... ...
... ... @@ -47,7 +47,6 @@ export struct TopPlayComponent {
.visibility(this.isWait ? Visibility.Visible : Visibility.None)
PlayUIComponent({ playerController: this.playerController })
}
.height(211)
.width('100%')
}
... ...
@Component
export struct PlayerCommentComponent {
build() {
}
}
\ No newline at end of file
... ...
import { LiveDetailsBean } from 'wdBean/Index';
import { WDPlayerController, WDPlayerRenderVLiveView, WDPlayerRenderView } from 'wdPlayer/Index';
import componentUtils from '@ohos.arkui.componentUtils';
@Component
export struct PlayerComponent {
private playerController?: WDPlayerController;
// playerController: WDPlayerController = new WDPlayerController();
@Consume @Watch('updateData') liveDetailsBean: LiveDetailsBean
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
@State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
@State imgUrl: string = ''
@State isWait: boolean = false
@State liveStreamType: number | null = -1
aboutToAppear(): void {
if (this.playerController) {
this.playerController.onCanplay = () => {
console.log('可以播放了')
this.playerController?.play()
// this.playerController.selfSize
}
}
}
aboutToDisappear(): void {
this.playerController?.pause()
this.playerController?.stop()
this.playerController?.release()
}
updateData() {
console.error('updateData=============')
//直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停
if (this.liveDetailsBean.fullColumnImgUrls && this.liveDetailsBean.fullColumnImgUrls.length > 0) {
this.imgUrl = this.liveDetailsBean.fullColumnImgUrls[0].url
}
this.isWait = this.liveDetailsBean?.liveInfo?.liveState == 'wait'
if (this.liveDetailsBean.liveInfo && this.liveDetailsBean.liveInfo.vlive.length > 0) {
let playUrl = ''
let liveStreamType: number | null = null
if (this.liveDetailsBean.liveInfo.liveState == 'running') {
playUrl = this.liveDetailsBean.liveInfo.vlive[0].liveUrl
liveStreamType = this.liveDetailsBean.liveInfo.vlive[0].liveStreamType
} else if (this.liveDetailsBean.liveInfo.liveState == 'end') {
playUrl = this.liveDetailsBean.liveInfo.vlive[0].replayUri
liveStreamType = this.liveDetailsBean.liveInfo.vlive[0].liveStreamType
}
this.liveStreamType = liveStreamType
this.playerController?.firstPlay(playUrl);
}
}
build() {
Column() {
Stack() {
Image(this.imgUrl)
.height('100%')
.width('100%')
.blur(100)
// TODO:判断横竖屏,liveStreamType=1竖屏铺满屏幕,liveStreamType=0横屏正常展示
if (this.liveStreamType == null) {
WDPlayerRenderVLiveView({
playerController: this.playerController,
onLoad: () => {
}
}).height('100%')
.width('100%')
} else if (this.liveStreamType == 0) {
WDPlayerRenderView({
playerController: this.playerController,
onLoad: () => {
}
}).padding({ top: 195 })
}
}
.height('100%')
.width('100%')
.align(Alignment.Top)
.alignContent(Alignment.Top)
}
.height('100%')
.width('100%')
}
}
\ No newline at end of file
... ...
import { WDPlayerController } from 'wdPlayer/Index'
import { PlayerUIComponent } from './PlayerUIComponent'
@Component
export struct PlayerInfoComponent {
swiperController?: SwiperController
@Prop playerController: WDPlayerController
@Consume bottomSafeHeight: number
@Consume topSafeHeight: number
@Link swiperIndex: number
build() {
Column() {
Swiper(this.swiperController) {
Text('')
PlayerUIComponent({ playerController: this.playerController }).margin({
bottom: this.bottomSafeHeight + 'px',
top: this.topSafeHeight + 'px'
})
}
.cachedCount(2)
.indicator(false)
.loop(false)
.width('100%')
.height('100%')
.index(this.swiperIndex)
.onChange((index) => {
this.swiperIndex = index
})
}
.height('100%')
.width('100%')
}
}
\ No newline at end of file
... ...
import { LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Index'
import { NumberFormatterUtils } from 'wdKit/Index'
@Component
export struct PlayerTitleComponent {
@Consume liveDetailsBean: LiveDetailsBean
@Consume liveRoomDataBean: LiveRoomDataBean
build() {
Column() {
Row() {
Image($r('app.media.icon_arrow_left_white'))
.width(24)
.aspectRatio(1)
.visibility(Visibility.None)
.margin({
right: 10
})
if (this.liveDetailsBean.liveInfo?.liveState != 'wait') {
Text(this.liveDetailsBean.newsTitle)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize('16fp')
.fontWeight(500)
.fontColor(Color.White)
.textAlign(TextAlign.Start)
.layoutWeight(1)
} else {
Blank()
}
Image($r('app.media.icon_share'))
.width(24)
.aspectRatio(1)
.visibility(Visibility.None)
}
.width('100%')
.alignItems(VerticalAlign.Center)
.margin({
bottom: 10
})
this.getLiveStatusView()
}.width('100%')
.padding({
top: 20,
bottom: 6,
left: 10,
right: 10
})
.alignItems(HorizontalAlign.Start)
.visibility(Visibility.Visible)
}
@Builder
getLiveStatusView() {
Row() {
Image(this.liveDetailsBean.rmhInfo.rmhHeadUrl)
.width(22)
.height(18)
Text(this.liveDetailsBean.rmhInfo.rmhName)
.fontSize('11fp')
.fontWeight(400)
.fontColor(Color.White)
}
.backgroundColor('#4D000000')
.padding({
top: 1,
right: 4,
bottom: 1
})
// 直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停
// 预约
if (this.liveDetailsBean.liveInfo?.liveState == 'wait') {
Row() {
Image($r('app.media.icon_live_status_wait'))
.width(22)
.height(18)
Text('预约')
.fontSize('11fp')
.fontWeight(400)
.fontColor(Color.White)
}
.backgroundColor('#4D000000')
.padding({
top: 1,
right: 4,
bottom: 1
})
}
// 直播中
else if (this.liveDetailsBean.liveInfo?.liveState == 'running') {
Row() {
Image($r('app.media.icon_live_status_running'))
.width(22)
.height(18)
Text('直播中')
.fontSize('11fp')
.fontWeight(400)
.fontColor(Color.White)
Image($r('app.media.icon_live_player_status_end'))
.width(12)
.height(12)
Text(`${NumberFormatterUtils.formatNumberWithWan(this.liveRoomDataBean.pv)}人参与`)
.fontSize('11fp')
.fontWeight(400)
.fontColor(Color.White)
}
.backgroundColor('#4D000000')
.padding({
top: 1,
right: 4,
bottom: 1
})
}
//回看
else if (this.liveDetailsBean.liveInfo?.liveState == 'end') {
Row() {
Text('回看')
.fontSize('11fp')
.fontWeight(400)
.fontColor(Color.White)
Image($r('app.media.icon_live_player_status_end'))
.width(12)
.height(12)
Text(`${NumberFormatterUtils.formatNumberWithWan(this.liveRoomDataBean.pv)}人参与`)
.fontSize('11fp')
.fontWeight(400)
.fontColor(Color.White)
}
.backgroundColor('#4D000000')
.padding({
left: 4,
top: 1,
right: 4,
bottom: 1
})
}
}
}
... ...
import { WDPlayerController } from 'wdPlayer/Index';
@Component
export struct PlayerUIComponent {
playerController: WDPlayerController = new WDPlayerController();
build() {
}
}
\ No newline at end of file
... ...
import { window } from '@kit.ArkUI'
import { NumberFormatterUtils, WindowModel } from 'wdKit/Index'
import { devicePLSensorManager } from 'wdDetailPlayApi/Index'
import { DateFormatUtil, WDPlayerController } from 'wdPlayer/Index'
import { LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Index'
@Component
export struct PlayerVideoControlComponent {
playerController: WDPlayerController = new WDPlayerController();
@Consume liveDetailsBean: LiveDetailsBean
@Consume liveRoomDataBean: LiveRoomDataBean
//菜单键是否可见
@State isMenuVisible: boolean = true
@State isFullScreen: boolean = false
@State currentTime: string = ''
@State totalTime: string = ''
@State progressVal: number = 0;
//是否处于播放状态中
@State isPlayStatus: boolean = true
aboutToAppear(): void {
//播放进度监听
this.playerController.onTimeUpdate = (position: number, duration: number) => {
this.currentTime = DateFormatUtil.secondToTime(Math.floor(position / 1000));
this.totalTime = DateFormatUtil.secondToTime(Math.floor(duration / 1000));
this.progressVal = Math.floor(position * 100 / duration);
}
}
build() {
Row() {
this.getBottomUIComponent()
}
}
@Builder
getBottomUIComponent() {
Row() {
if (this.liveDetailsBean?.liveInfo?.liveState == 'end') {
this.playOrPauseBtn()
Text(this.currentTime)
.fontColor(Color.White)
.fontWeight(600)
.fontSize('12fp')
.margin({
left: 16
})
this.playProgressView()
Text(this.totalTime)
.fontColor(Color.White)
.fontWeight(600)
.fontSize('12fp')
.margin({
right: 16
})
} else {
Blank()
}
Image($r('app.media.icon_live_player_full_screen'))
.width(24)
.height(24)
.onClick(() => {
this.isFullScreen = !this.isFullScreen
WindowModel.shared.setPreferredOrientation(this.isFullScreen ? window.Orientation.LANDSCAPE : window.Orientation.PORTRAIT);
devicePLSensorManager.devicePLSensorOn(this.isFullScreen ? window.Orientation.LANDSCAPE : window.Orientation.PORTRAIT);
})
}
.alignItems(VerticalAlign.Center)
.linearGradient({ angle: 0, colors: [['#99000000', 0], ['#00000000', 1]] })
.width('100%')
.padding({
left: 10,
right: 10,
top: 15,
bottom: 15
})
.visibility(this.isMenuVisible ? Visibility.Visible : Visibility.None)
}
@Builder
playOrPauseBtn() {
//暂停、播放
Image(this.isPlayStatus ? $r('app.media.icon_live_player_pause') : $r('app.media.player_play_ic'))
.width(24)
.height(24)
.onClick(() => {
if (this.isPlayStatus) {
this.isPlayStatus = false
this.playerController.pause()
} else {
this.isPlayStatus = true
this.playerController.play()
}
})
}
@Builder
playProgressView() {
Slider({
value: this.progressVal,
step: 1,
style: SliderStyle.OutSet
})
.blockSize({
width: 18,
height: 12
})// .blockStyle({
// type: SliderBlockType.IMAGE,
// image: $r('app.media.ic_player_block')
// })
.blockColor(Color.White)
.trackColor('#4DFFFFFF')
.selectedColor('#FFED2800')
.height(14)
.trackThickness(1)
.layoutWeight(1)
.margin({
left: 8,
right: 8
})
.onChange((value: number, mode: SliderChangeMode) => {
this.playerController?.setSeekTime(value, mode);
})
}
}
\ No newline at end of file
... ...
{
"src": [
"pages/DetailPlayLivePage"
"pages/DetailPlayLivePage",
"pages/DetailPlayVLivePage"
]
}
}
\ No newline at end of file
... ...
... ... @@ -179,7 +179,6 @@ export struct DetailPlayShortVideoPage {
})
.height('100%')
.width('100%')
.margin({ top: this.contentDetailData?.videoInfo[0]?.videoLandScape === 1 ? 218 : 0 })
.onClick(() => {
console.error('WDPlayerRenderView=== onClick')
this.playerController?.switchPlayOrPause();
... ...
... ... @@ -166,8 +166,7 @@ export struct DetailVideoListPage {
})
}.width('100%')
.height('100%')
// 扩展至所有非安全区域
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
}, (item: ContentDetailDTO) => item.newsId + '')
}
.clip(false)
... ...
... ... @@ -61,32 +61,35 @@ export struct PlayerDetailContainer {
build() {
RelativeContainer() {
Stack() {
Row() {
this.playerView()
}
.height('100%')
.width('100%')
.zIndex(0)
Row() {
Stack() {
Row() {
this.playerView()
}
.height('100%')
.width('100%')
.zIndex(0)
.margin({ top: this.videoLandScape === 1 ? 218 : 0 })
Row() {
this.playControlView()
Row() {
this.playControlView()
}
.height('100%')
.width('100%')
.zIndex(1)
}
.height('100%')
.width('100%')
.zIndex(1)
}
.width('100%')
.height('100%')
// .aspectRatio(this.isFullScreen ? 0.1 : 16 / 9.0) // 若width值确定,当aspectRatio值越小,则height值越大
// .height(this.isFullScreen ? '100%' : this.buildVideoHeight())
// .margin({ top: this.isFullScreen ? 0 : this.buildVideoTo() })
// .margin({ bottom: this.isFullScreen ? 0 : this.buildVideoBottom() })
.alignRules({
top: { anchor: '__container__', align: VerticalAlign.Top },
// middle: { anchor: '__container__', align: HorizontalAlign.Center }
})
.id('stk_player_container')
.height('100%')
// .aspectRatio(this.isFullScreen ? 0.1 : 16 / 9.0) // 若width值确定,当aspectRatio值越小,则height值越大
// .height(this.isFullScreen ? '100%' : this.buildVideoHeight())
// .margin({ top: this.isFullScreen ? 0 : this.buildVideoTo() })
// .margin({ bottom: this.isFullScreen ? 0 : this.buildVideoBottom() })
.alignRules({
top: { anchor: '__container__', align: VerticalAlign.Top },
// middle: { anchor: '__container__', align: HorizontalAlign.Center }
})
.id('stk_player_container')
}.height('100%').layoutWeight(1)
if (this.isShowBottomView()) {
Row() {
... ...
export interface CheckVerifyBean{
temToken: string
tempToken: string
jwtToken: string
}
\ No newline at end of file
... ...
import { Logger } from 'wdKit'
import { SpConstants } from 'wdConstant/Index'
import { Logger, SPHelper } from 'wdKit'
@Component
export struct LoginInputComponent {
... ... @@ -16,15 +17,16 @@ export struct LoginInputComponent {
}.width('100%').padding({ left: 25, right: 25 })
}
aboutToAppear(){
async aboutToAppear(){
if (this.pageType == 1) {
this.phoneContent = '18655957611';
this.phoneContent = await SPHelper.default.get(SpConstants.USER_PHONE,"") as string;
Logger.debug("ddd")
}
}
@Builder
addCodeLayout() {
if (this.pageType == 1){
TextInput({ placeholder: this.securityPhone('18655957611') })
TextInput({ placeholder: this.securityPhone(this.phoneContent) })
.fontSize(16)
.height(48)
.maxLength(11)
... ...
... ... @@ -200,36 +200,15 @@ export class LoginModel {
bean['tempToken'] = tempToken;
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
// let JwtToken = SPHelper.default.getSync(SpConstants.USER_JWT_TOKEN, '') as string;
// headers.set('JwtToken',(JwtToken));
// headers.set('rmrb-x-token',(JwtToken));
// headers.set('cookie', 'RMRB-X-TOKEN=' + JwtToken)
// let obj: Record<string, string> = {};
// headers.forEach((value, key) =>{
// if(key != undefined && key != null && value != undefined && value != null) {
// obj[key as string] = value;
// }
// })
// let headerString = JSON.stringify(obj);
// let beanString = JSON.stringify(bean);
// AlertDialog.show({
// message:headerString + beanString
// })
return new Promise<string>((success, fail) => {
HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.getForgetPasswordUrl(), bean, headers).then((data: ResponseDTO<string>) => {
return new Promise<object>((success, fail) => {
HttpRequest.post<ResponseDTO<object>>(HttpUrlUtils.getForgetPasswordUrl(), bean, headers).then((data: ResponseDTO<object>) => {
if (data.code != 0) {
fail(data.message)
return
}
if (!data || !data.data) {
fail("数据为空")
return
}
success(data.data)
success(data)
}, (error: Error) => {
fail(error.message)
Logger.debug("LoginViewModel:error ", error.toString())
... ...
... ... @@ -331,7 +331,7 @@ struct LoginPage {
router.back({
params: { userName: data.userName,
userId:data.id},
url: 'pages/MainPage'
url: `${WDRouterPage.getBundleInfo()}`
})
}).catch((value: string) => {
promptAction.showToast({ message: value })
... ...
... ... @@ -95,7 +95,7 @@ export class LoginViewModel {
return new Promise<CheckVerifyBean>((success, reject) => {
this.loginModel.checkVerifyCode(phone, verifyCode).then((data: CheckVerifyBean) => {
//todo 保存数据
SPHelper.default.save(SpConstants.USER_TEMP_TOKEN, data.temToken)
SPHelper.default.save(SpConstants.USER_TEMP_TOKEN, data.tempToken)
SPHelper.default.save(SpConstants.USER_JWT_TOKEN, data.jwtToken)
success(data)
... ... @@ -108,7 +108,7 @@ export class LoginViewModel {
return new Promise<CheckVerifyBean>((success, reject) => {
this.loginModel.checkVerifyCodeByToken(verifyCode).then((data: CheckVerifyBean) => {
//todo 保存数据
SPHelper.default.save(SpConstants.USER_TEMP_TOKEN, data.temToken)
SPHelper.default.save(SpConstants.USER_TEMP_TOKEN, data.tempToken)
SPHelper.default.save(SpConstants.USER_JWT_TOKEN, data.jwtToken)
success(data)
... ... @@ -134,7 +134,7 @@ export class LoginViewModel {
//忘记密码
forgotPassword(password: string, tempToken: string) {
return new Promise<string>(async (success, fail) => {
return new Promise<object>(async (success, fail) => {
let passwordNew = await encryptMessage(password)
this.loginModel.forgotPassword(passwordNew, tempToken).then((data) => {
success(data)
... ...
... ... @@ -3,7 +3,7 @@ import promptAction from '@ohos.promptAction';
import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/Index';
import router from '@ohos.router';
import { LoginViewModel } from './LoginViewModel';
import { Logger, SPHelper } from 'wdKit';
import { Logger, SPHelper, ToastUtils } from 'wdKit';
import {
SpConstants
} from '../../../../../../../commons/wdNetwork/oh_modules/wdConstant/src/main/ets/constants/SpConstants'
... ... @@ -303,7 +303,7 @@ export struct SettingPasswordLayout {
/***************************** 事件处理 ******************************************/
// 提交按钮点击事件
buttonClick() {
async buttonClick() {
if (this.btnStatus) {
// 需要+手机号校验
if (this.password01.length < 6 || this.password01.length > 20) {
... ... @@ -315,18 +315,27 @@ export struct SettingPasswordLayout {
return
}
if(this.pageId == 1){ //设置密码
SPHelper.default.get(SpConstants.USER_JWT_TOKEN, '').then((str) => {
SPHelper.default.get(SpConstants.USER_TEMP_TOKEN, '').then((str) => {
this.loginViewModel.forgotPassword(this.password01, str.toString()).then((data =>{
if (this.pageType == 0) {//登录页
WDRouterRule.jumpWithPage(WDRouterPage.loginPage);
ToastUtils.shortToast("修改成功")
router.back({
url: `${WDRouterPage.getLoginBundleInfo()}`
})
}else if(this.pageType == 1){//设置
let params: Params = {
pageID: 'AccountAndSecurityLayout'
}
WDRouterRule.jumpWithPage(WDRouterPage.settingPage, params)
ToastUtils.shortToast("修改成功")
router.back({
params:params,
url: `${WDRouterPage.getSettingBundleInfo()}`
})
// WDRouterRule.jumpWithPage(WDRouterPage.settingPage, params)
}
}))
}).catch((err: Error) => {
}).catch((err: string) => {
ToastUtils.shortToast(err)
Logger.error(TAG, 'catch err:' + JSON.stringify(err));
});
}
... ...
... ... @@ -4,6 +4,8 @@ export { WDPlayerRenderView } from "./src/main/ets/pages/WDPlayerRenderView"
export { WDPlayerRenderLiveView } from "./src/main/ets/pages/WDPlayerRenderLiveView"
export { WDPlayerRenderVLiveView } from "./src/main/ets/pages/WDPlayerRenderVLiveView"
export { PlayerConstants } from "./src/main/ets/constants/PlayerConstants"
export { SpeedBean } from "./src/main/ets/bean/SpeedBean"
... ...
... ... @@ -45,7 +45,7 @@ export struct WDPlayerRenderLiveView {
videoWidth: number = 0
videoHeight: number = 0
@State selfSize: Size = new Size('100%', '100%');
private insId: string = "WDPlayRenderView" + insIndex;
private insId: string = "WDPlayerRenderLiveView" + insIndex;
aboutToAppear() {
MGPlayRenderViewIns.add();
... ... @@ -97,7 +97,7 @@ export struct WDPlayerRenderLiveView {
}
.id(this.insId)
.onAreaChange(() => {
// this.updateLayout()
this.updateLayout()
})
.backgroundColor("#000000")
.justifyContent(FlexAlign.Center)
... ...
import componentUtils from '@ohos.arkui.componentUtils';
import { WDPlayerController } from '../controller/WDPlayerController'
import { WindowModel } from 'wdKit';
import { Logger } from '../utils/Logger';
class Size {
width: Length = "100%";
height: Length = "100%";
constructor(width: Length, height: Length) {
this.width = width;
this.height = height;
}
}
let insIndex: number = 0;
const TAG = 'WDPlayerRenderView'
class MGPlayRenderViewIns {
static intCount: number = 0;
static add() {
MGPlayRenderViewIns.intCount++;
WindowModel.shared.setWindowKeepScreenOn(true);
console.log("add-- +1")
}
static del() {
console.log("del-- -1")
MGPlayRenderViewIns.intCount--;
if (MGPlayRenderViewIns.intCount <= 0) {
WindowModel.shared.setWindowKeepScreenOn(false);
}
}
}
/**
* 播放窗口组件
*/
@Component
export struct WDPlayerRenderVLiveView {
private playerController?: WDPlayerController;
private xComponentController: XComponentController = new XComponentController();
private insId: string = "WDPlayRenderView" + insIndex;
onLoad?: ((event?: object) => void);
@State videoWidth: number = 0
@State videoHeight: number = 0
@State selfSize: Size = new Size('100%', '100%');
aboutToAppear() {
MGPlayRenderViewIns.add();
insIndex++;
if (!this.playerController) {
return
}
this.playerController.onVideoSizeChange = (width: number, height: number) => {
// console.log(`WDPlayerRenderView onVideoSizeChange width:${width} videoTop:${height}`)
Logger.info(TAG, ` onVideoSizeChange width:${width} videoTop:${height}`)
this.videoWidth = width;
this.videoHeight = height;
this.updateLayout()
}
}
aboutToDisappear() {
Logger.info(TAG, `aboutToDisappear`)
MGPlayRenderViewIns.del();
}
build() {
Row() {
// 设置为“surface“类型时XComponent组件可以和其他组件一起进行布局和渲染。
XComponent({
id: 'xComponentId',
type: 'surface',
controller: this.xComponentController
})
.onLoad(async (event) => {
Logger.info(TAG, 'onLoad')
// const surfaceId = this.xComponentController.getXComponentSurfaceId()
this.xComponentController.setXComponentSurfaceSize({
surfaceWidth: 1920,
surfaceHeight: 1080
});
this.playerController?.setXComponentController(this.xComponentController)
if (this.onLoad) {
this.onLoad(event)
}
})// .width(this.selfSize.width)
// .height(this.selfSize.height)
.height('100%')
.width('100%')
}
.id(this.insId)
.onAreaChange(() => {
// this.updateLayout()
})
.backgroundColor("#000000")
.height('100%')
.width('100%')
}
updateLayout() {
let info = componentUtils.getRectangleById(this.insId);
if (info.size.width > 0 && info.size.height > 0 && this.videoHeight > 0 && this.videoWidth > 0) {
if (info.size.width / info.size.height > this.videoWidth / this.videoHeight) {
let scale = info.size.height / this.videoHeight;
this.selfSize = new Size((this.videoWidth * scale / info.size.width) * 100 + "%", '100%');
} else {
let scale = info.size.width / this.videoWidth;
this.selfSize = new Size('100%', (this.videoHeight * scale / info.size.height) * 100 + "%");
}
}
}
}
\ No newline at end of file
... ...
... ... @@ -97,8 +97,11 @@ export struct WDPlayerRenderView {
// this.updateLayout()
})
.backgroundColor("#000000")
// .height('100%')
// .width('100%')
}
updateLayout() {
let info = componentUtils.getRectangleById(this.insId);
if (info.size.width > 0 && info.size.height > 0 && this.videoHeight > 0 && this.videoWidth > 0) {
... ...
... ... @@ -11,7 +11,6 @@ const TAG = 'MainPage';
@Entry
@Component
struct MainPage {
@Provide('isLogin') isLogin:Record<string,string>={}
private breakpointSystem: BreakpointSystem = new BreakpointSystem()
@StorageLink('currentBreakpoint') @Watch('watchCurrentBreakpoint') currentBreakpoint: string = BreakpointConstants.BREAKPOINT_XS;
... ... @@ -34,11 +33,6 @@ struct MainPage {
Logger.info(TAG, 'aboutToDisappear');
}
onPageShow() {
Logger.info(TAG, 'onPageShow');
let params=router.getParams() as Record<string,string>
this.isLogin=params
}
onPageHide() {
Logger.info(TAG, 'onPageHide');
... ...
... ... @@ -33,7 +33,7 @@ struct DefaultWebPage {
webUrl: this.url,
backVisibility: false,
reload: this.reload,
isPageEnd:this.isPageEnd
isPageEnd:$isPageEnd
})
}
}
... ...