douaojie

Merge remote-tracking branch 'origin/main'

Showing 137 changed files with 2922 additions and 718 deletions
... ... @@ -47,4 +47,5 @@ export class SpConstants{
//游客状态下首次评论时间
static FIRSTCOMMENTTIME = 'firstCommentTime'
static TOURIST_NICK_NAME = 'touristNickName'
}
\ No newline at end of file
... ...
... ... @@ -20,6 +20,8 @@ export { WindowModel } from './src/main/ets/utils/WindowModel'
export { SPHelper } from './src/main/ets/utils/SPHelper'
export { KVStoreHelper } from './src/main/ets/utils/KVStoreHelper'
export { AccountManagerUtils } from './src/main/ets/utils/AccountManagerUtils'
export { CollectionUtils } from './src/main/ets/utils/CollectionUtils'
... ...
import { distributedKVStore } from '@kit.ArkData';
import { BusinessError } from '@kit.BasicServicesKit';
import { AppUtils } from './AppUtils';
import { Logger } from './Logger';
const TAG = 'KVStoreHelper'
/**
* 键值型数据库管理类,类似sp,存储变大,单条数据,value<4M
*/
export class KVStoreHelper {
private static _context: Context;
// TODO 待优化,可以指定数据库名,创建多个数据库。当前没有需求,只创建一个,缓存接口数据用。
private static _default_store_id: string = 'default_kv_store';
private kvManager: distributedKVStore.KVManager | undefined = undefined;
private kvStore: distributedKVStore.SingleKVStore | undefined = undefined;
private constructor() {
Logger.error(TAG, 'constructor')
}
static init(context: Context) {
Logger.error(TAG, 'init')
KVStoreHelper._context = context;
KVStoreHelper.default.createKVManager()
KVStoreHelper.default.createKVStore()
}
// 静态属性
static default: KVStoreHelper = new KVStoreHelper();
private createKVManager() {
if (this.kvManager) {
return
}
if (!KVStoreHelper._context) {
Logger.fatal(TAG, 'context is null, must be initialized first')
return
}
let context: Context = KVStoreHelper._context;
const kvManagerConfig: distributedKVStore.KVManagerConfig = {
context: context,
bundleName: AppUtils.getPackageName(context)
};
try {
// 创建KVManager实例
this.kvManager = distributedKVStore.createKVManager(kvManagerConfig);
Logger.info(TAG, 'Succeeded in creating KVManager.');
// 继续创建获取数据库
} catch (e) {
let error = e as BusinessError;
Logger.error(TAG, `Failed to create KVManager. Code:${error.code},message:${error.message}`);
}
}
private createKVStore() {
if (this.kvStore) {
return
}
if (!this.kvManager) {
this.createKVManager()
// 直接拦截,避免陷入循环
Logger.error(TAG, 'kvManager is null, please re-create it and try again')
return
}
try {
const options: distributedKVStore.Options = {
createIfMissing: true,
encrypt: false,
backup: false,
autoSync: false,
// kvStoreType不填时,默认创建多设备协同数据库
kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION,
securityLevel: distributedKVStore.SecurityLevel.S1
};
this.kvManager?.getKVStore<distributedKVStore.SingleKVStore>(KVStoreHelper._default_store_id, options,
(err, store: distributedKVStore.SingleKVStore) => {
if (err) {
Logger.error(TAG, `Failed to get KVStore: Code:${err.code},message:${err.message}`);
return;
}
Logger.info(TAG, 'Succeeded in getting KVStore.');
this.kvStore = store;
// 请确保获取到键值数据库实例后,再进行相关数据操作
});
} catch (e) {
let error = e as BusinessError;
Logger.error(TAG, `An unexpected error occurred. Code:${error.code},message:${error.message}`);
}
}
private checkStoreCreated() {
if (!this.kvManager) {
this.createKVManager()
}
if (!this.kvStore) {
this.createKVStore()
}
}
get(key: string, def: boolean | string | number | Uint8Array): Promise<boolean | string | number | Uint8Array> {
// this.checkStoreCreated()
return new Promise<boolean | string | number | Uint8Array>((success, failed) => {
try {
this.kvStore?.get(key, (err, data) => {
if (err != undefined) {
Logger.debug(TAG, `Failed to get data. Code:${err.code},message:${err.message}`);
success(def)
return;
}
success(data)
Logger.debug(TAG, `Succeeded in getting data. Data:${data}`);
});
} catch (e) {
success(def)
let error = e as BusinessError;
Logger.error(TAG, `Failed to get data. Code:${error.code},message:${error.message}`);
}
});
}
put(key: string, value: boolean | string | number | Uint8Array) {
// this.checkStoreCreated()
try {
this.kvStore?.put(key, value, (err) => {
if (err !== undefined) {
Logger.debug(TAG, `Failed to put data. Code:${err.code},message:${err.message}`);
return;
}
Logger.debug(TAG, 'Succeeded in putting data.');
});
} catch (e) {
let error = e as BusinessError;
Logger.error(TAG, `An unexpected error occurred. Code:${error.code},message:${error.message}`);
}
}
del(key: string) {
// this.checkStoreCreated()
try {
this.kvStore?.delete(key, (err) => {
if (err !== undefined) {
Logger.debug(TAG, `Failed to delete data. Code:${err.code},message:${err.message}`);
return;
}
Logger.debug(TAG, 'Succeeded in deleting data.');
});
} catch (e) {
let error = e as BusinessError;
Logger.error(TAG, `An unexpected error occurred. Code:${error.code},message:${error.message}`);
}
}
}
\ No newline at end of file
... ...
... ... @@ -4,7 +4,7 @@ import { Logger } from './Logger';
const TAG = 'SPHelper'
/**
* sp存储
* sp存储,单条数据,value<1k;业务数据超过1k的,建议使用KVStoreHelper
*/
export class SPHelper {
private static context: Context;
... ...
... ... @@ -12,3 +12,5 @@ export { HttpUtils } from "./src/main/ets/utils/HttpUtils"
export { HostEnum, HostManager } from "./src/main/ets/http/HttpHostManager"
export { CacheData } from "./src/main/ets/utils/CacheData"
... ...
... ... @@ -135,6 +135,14 @@ export class HttpUrlUtils {
*/
static readonly APPOINTMENT_ExecuteCollcet_PATH: string = "/api/rmrb-interact/interact/zh/c/collect/executeCollcetRecord";
/**
* 个人中心 - 消息
*/
static readonly APPOINTMENT_MessageList_PATH: string = "/api/rmrb-inside-mail/zh/c/inside-mail/private";
/**
* 个人中心 - 消息 点赞数
*/
static readonly APPOINTMENT_getMessageLikeCount_PATH: string = "/api/rmrb-inside-mail/zh/c/inside-mail/private/getLikeCount";
/**
* 个人中心 我的评论列表
*/
static readonly MINE_COMMENT_LIST_DATA_PATH: string = "/api/rmrb-comment/comment/zh/c/myCommentList";
... ... @@ -316,6 +324,25 @@ export class HttpUrlUtils {
*/
static readonly FEEDBACK_TYPE_PATH: string = "/api/rmrb-interact/interact/c/user/optionClassify/list";
/**
* 查询点赞、回复我的、系统消息的未读数量以及回复/评论人
*/
static readonly MESSAGE_UN_READ_DATA_PATH: string = "/api/rmrb-inside-mail/zh/c/inside-mail/private/polymerizationInfo?createTime=";
/**
* 直播详情-直播人数
*/
static readonly LIVE_ROOM_BATCH_ALL_DATA_PATH: string = "/api/live-center-message/zh/a/live/room/number/batch/all";
/**
* 点击消息
*/
static readonly SEND_MESSAGE_PATH: string = "/api/rmrb-inside-mail/zh/c/inside-mail/private/touch?createTime=";
/**
* 推送消息
*/
static readonly HISTORY_PUSH_MESSAGE_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/push";
static getHost(): string {
return HostManager.getHost();
... ... @@ -478,6 +505,16 @@ export class HttpUrlUtils {
return url
}
static getMessageListDataUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.APPOINTMENT_MessageList_PATH
return url
}
static getMessageLikeCount() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.APPOINTMENT_getMessageLikeCount_PATH
return url
}
static getExecuteCollcetUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.APPOINTMENT_ExecuteCollcet_PATH
return url
... ... @@ -714,4 +751,33 @@ export class HttpUrlUtils {
return url;
}
}
\ No newline at end of file
//获取消息未读接口
static getMessageUnReadDataUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.MESSAGE_UN_READ_DATA_PATH
return url
}
static reportDeviceInfo() {
let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/common/user/c/device/push";
return url;
}
//获取直播人数
static getLiveRoomBatchAllDataUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_ROOM_BATCH_ALL_DATA_PATH
return url
}
//点击消息
static getSendClickMessageUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.SEND_MESSAGE_PATH
return url
}
//消息 历史推送消息
static getHistoryPushUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.HISTORY_PUSH_MESSAGE_PATH
return url
}
}
... ...
/**
* 接口数据存储封装类
*/
import { DateTimeUtils, StringUtils } from 'wdKit/Index';
import { CacheDataSaveUtil } from './CacheDataSaveUtil';
export class CacheData {
// 接口返回数据
networkData?: object;
// 数据更新时间戳
updateTimeInMillis: number = 0;
// 接口返回md5,用于判断接口数据是否更新
md5: string = '';
constructor(md5: string, timeMillis: number, networkData: object) {
this.md5 = md5
this.updateTimeInMillis = timeMillis
this.networkData = networkData
}
/**
* 根据新旧md5值进行判断,是否需要刷新数据
* @param responseMd5 新值,接口返回
* @returns
*/
needRefreshByMd5(responseMd5: string): boolean {
if (StringUtils.isEmpty(this.md5) || StringUtils.isEmpty(responseMd5)) {
return false
}
return this.md5 != responseMd5
}
static saveCacheData(cacheKey: string, data: object, responseMd5: string) {
if (!data) {
return
}
let time = DateTimeUtils.getTimeStamp()
let cacheData = new CacheData(responseMd5, time, data)
CacheDataSaveUtil.save(cacheKey, JSON.stringify(cacheData))
}
/**
* 获取缓存数据
*/
static getLocalCacheData(key: string): Promise<CacheData | null> {
return new Promise<CacheData | null>((success) => {
if (StringUtils.isEmpty(key)) {
success(null)
return
}
let ll = CacheDataSaveUtil.get(key)
if (ll instanceof Promise) {
ll.then((data) => {
let str = data as string
let cache = JSON.parse(str) as CacheData
success(cache)
})
} else {
success(null)
}
})
}
}
\ No newline at end of file
... ...
import { KVStoreHelper, StringUtils } from 'wdKit/Index';
/**
* 接口数据存储工具类
*/
export class CacheDataSaveUtil {
static save(key: string, value: string) {
if (StringUtils.isEmpty(key)) {
return
}
KVStoreHelper.default.put(key, value)
}
static get(key: string) {
if (StringUtils.isEmpty(key)) {
return ''
}
return KVStoreHelper.default.get(key, '')
}
}
\ No newline at end of file
... ...
... ... @@ -119,6 +119,8 @@ export class WDRouterPage {
static searchPage = new WDRouterPage("wdComponent", "ets/pages/SearchPage");
//消息主页
static mineMessagePage = new WDRouterPage("wdComponent", "ets/pages/MineMessagePage");
//预约消息主页
static subscribeMessagePage = new WDRouterPage("wdComponent", "ets/pages/SubscribeMessagePage");
//搜索人民号主页
static searchCreatorPage = new WDRouterPage("wdComponent", "ets/pages/SearchCreatorPage");
//人民号主页
... ... @@ -136,4 +138,9 @@ export class WDRouterPage {
//意见反馈
static feedBackActivity = new WDRouterPage("wdComponent", "ets/components/FeedBackActivity");
// 人民号主页头像显示
static showHomePageHeaderPage = new WDRouterPage("wdComponent", "ets/pages/ShowHomePageHeaderPage");
}
... ...
... ... @@ -55,7 +55,7 @@ export struct WdWebLocalComponent {
.mixedMode(MixedMode.All)
.onlineImageAccess(true)
.enableNativeEmbedMode(true)
.layoutMode(WebLayoutMode.FIT_CONTENT)
// .layoutMode(WebLayoutMode.FIT_CONTENT)
// .nestedScroll({ scrollForward: NestedScrollMode.SELF_FIRST, scrollBackward: NestedScrollMode.PARENT_FIRST })
.height(this.webHeight)
.onPageBegin((event) => {
... ...
... ... @@ -69,6 +69,7 @@ export struct DynamicDetailComponent {
@State isNetConnected: boolean = true
@State isPageEnd: boolean = false
@State publishCommentModel: publishCommentModel = new publishCommentModel()
@State reachEndIncreament: number = 0
async aboutToAppear() {
await this.getContentDetailData()
... ... @@ -709,4 +710,4 @@ interface radiusType {
topRight: number | Resource;
bottomLeft: number | Resource;
bottomRight: number | Resource;
}
\ No newline at end of file
}
... ...
... ... @@ -148,18 +148,19 @@ export struct ENewspaperPageComponent {
this.calendarDialogController.close()
}
})
Image($r('app.media.icon_share'))
.height($r('app.float.top_arrow_size'))
.width($r('app.float.top_arrow_size'))
.alignRules({
right: { anchor: "__container__", align: HorizontalAlign.End },
center: { anchor: "__container__", align: VerticalAlign.Center }
})
.id('e_newspaper_share')
.onClick(() => {
ToastUtils.showToast('分享为公共方法,待开发', 1000);
})
if (this.newspaperListBean && this.newspaperListBean.list && this.newspaperListBean.list.length > 0) {
Image($r('app.media.icon_share'))
.height($r('app.float.top_arrow_size'))
.width($r('app.float.top_arrow_size'))
.alignRules({
right: { anchor: "__container__", align: HorizontalAlign.End },
center: { anchor: "__container__", align: VerticalAlign.Center }
})
.id('e_newspaper_share')
.onClick(() => {
ToastUtils.showToast('分享为公共方法,待开发', 1000);
})
}
}
.margin({ left: $r('app.float.margin_16'), right: $r('app.float.margin_16') })
.height($r('app.float.top_bar_height'))
... ... @@ -311,6 +312,7 @@ export struct ENewspaperPageComponent {
.width('100%')
.height('100%')
.backgroundColor($r('app.color.color_80000000'))
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
.id('e_newspaper_container')
if (this.isOpenListDialog) {
... ...
... ... @@ -52,6 +52,7 @@ export struct ImageAndTextPageComponent {
@State isNetConnected: boolean = true
@State info: Area | null = null
@State likeNum: number = 0
@State reachEndIncreament : number = 0
build() {
Column() {
... ... @@ -141,7 +142,12 @@ export struct ImageAndTextPageComponent {
if (this.contentDetailData?.openComment) {
Divider().strokeWidth(6).color('#f5f5f5')
CommentComponent({
publishCommentModel: this.publishCommentModel
publishCommentModel: this.publishCommentModel,
fixedHeightMode: false,
reachEndIncreament: this.reachEndIncreament,
reachEndLoadMoreFinish: () => {
}
}).onAreaChange((oldValue: Area, newValue: Area) => {
this.info = newValue
})
... ... @@ -157,6 +163,9 @@ export struct ImageAndTextPageComponent {
.padding({ bottom: 76 })
.scrollBar(BarState.Off)
.align(Alignment.Top)
.onReachEnd(() => {
this.reachEndIncreament += 1
})
if (!this.isNetConnected) {
EmptyComponent({
... ... @@ -228,6 +237,7 @@ export struct ImageAndTextPageComponent {
this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId)
this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle)
this.publishCommentModel.targetType = String(this.contentDetailData?.newsType)
this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment)
}
if (this.contentDetailData?.openAudio && this.contentDetailData?.audioList?.length &&
this.contentDetailData?.audioList[0].audioUrl) {
... ... @@ -340,4 +350,4 @@ export struct ImageAndTextPageComponent {
aboutToDisappear() {
}
}
\ No newline at end of file
}
... ...
import { ContentDTO } from 'wdBean/Index';
import { ProcessUtils } from 'wdRouter/Index';
import { InteractMessageModel } from '../../model/InteractMessageModel'
@Component
export struct InteractMComponent {
messageModel:InteractMessageModel = new InteractMessageModel;
///"remark": "{"beReply":"乐事薯片,大家的最爱!!",
// "headUrl":"https: //uatjdcdnphoto.aikan.pdnews.cn//zhbj/img/user/2023122211/2A59F725E69849A38CEE8823B0D9D141.jpg",
// "contentId":"30035774121","contentRelObjectid":"2012","contentTitle":"乐事推出华夏风光限定罐七款城市地标包装让出游“有滋有味”",
// "commentContent":"大家都爱吃!!","userName":"人民日报网友a8dKCV","userId":"504964178466309","contentRelId":"500002866426",
// "shareUrl":"https: //pd-people-uat.pdnews.cn/column/30035774121-500002866426","userType":"1",
// "contentRelType":"1","visitor":"0","contentType":"8"}",
build() {
Row(){
Image('')
.backgroundColor(Color.Red)
Image(this.messageModel.InteractMsubM.headUrl)
.width(36)
.height(36)
.borderRadius(18)
Column(){
Row(){
Text('用户名')
Text(this.messageModel.InteractMsubM.userName)
.fontSize('14fp').fontColor('#222222')
Text('回复了你的评论')
Text(this.buildContentString())
.fontSize('14fp').fontColor('#999999')
.margin({left:5})
}.width('100%')
Text('两天前')
Text(this.messageModel.time)
.margin({top:2})
.fontSize('12fp').fontColor('#B0B0B0')
Text('评论内容')
.margin({top:8,bottom:10})
.fontSize('16fp').fontColor('#222222')
.width('100%')
.constraintSize({maxHeight:500})
.fontSize('12fp').fontColor('#B0B0B0').margin({top:10,bottom:10})
Column(){
Text('[你的评论]乐事薯片,大家的最爱').fontSize('14fp').fontColor('#666666').constraintSize({maxHeight:500})
.margin({top:5,bottom:5})
if (this.messageModel.contentType === '208' || this.messageModel.contentType === '209'){
Text(this.messageModel.message)
.margin({bottom:10})
.fontSize('16fp').fontColor('#222222')
.width('100%')
.constraintSize({maxHeight:500})
}
Divider()
.color('#f5f5f5')
.backgroundColor('#f5f5f5')
.width('100%')
.height(1)
Column(){
if (this.messageModel.contentType === '207' || this.messageModel.contentType === '209'){
Text('[你的评论]'+this.buildCommentContent()).fontSize('14fp').fontColor('#666666').constraintSize({maxHeight:500})
.margin({top:15,bottom:10})
.width('100%')
Divider()
.color('#EDEDED')
.backgroundColor('#EDEDED')
.width('100%')
.height(1)
}
Row(){
Text('乐事薯片,大家的最爱!!!!').fontSize('12fp').fontColor('#666666').constraintSize({maxHeight:500})
Image($r('app.media.MessageOriginTextIcon'))
.width('12')
.height('12')
Text(this.messageModel.InteractMsubM.contentTitle)
.fontSize('12fp')
.fontColor('#666666')
.maxLines(1)
.width('90%')
.textOverflow({overflow:TextOverflow.Ellipsis})
Blank()
Image($r('app.media.mine_user_edit'))
.width('12')
.height('12')
}.margin({top:5,bottom:5}).width('100%')
}.alignItems(HorizontalAlign.Start).backgroundColor('#f5f5f5').borderRadius(5)
}.padding({left:5}).alignItems(HorizontalAlign.Start)
}.padding({top:5,left:16,right:16}).width('100%').height(160).alignItems(VerticalAlign.Top).backgroundColor(Color.Red)
}.margin({top:10,bottom:15})
}.padding({left:10,right:10}).alignItems(HorizontalAlign.Start).backgroundColor('#f5f5f5').borderRadius(5)
.onClick(()=>{
let contentDTO :ContentDTO = new ContentDTO();
contentDTO.objectType = this.messageModel.InteractMsubM.contentType
contentDTO.objectId = this.messageModel.InteractMsubM.contentId
ProcessUtils.processPage(contentDTO)
})
}.padding({left:5,right:5}).alignItems(HorizontalAlign.Start).width('90%')
}.padding({top:10,left:16,right:16}).width('100%').alignItems(VerticalAlign.Top)
}
buildContentString(): string {
let contentString: string = ''
if (this.messageModel.contentType === '206') {
contentString = '赞了你的作品'
}else if(this.messageModel.contentType === '207'){
contentString = '赞了你的评论'
}else if(this.messageModel.contentType === '208'){
contentString = '评论了你的作品'
}else if(this.messageModel.contentType === '209'){
contentString = '回复了你的评论'
}else if(this.messageModel.contentType === '210'){
contentString = '转发了您的作品'
}else if(this.messageModel.contentType === '211'){
contentString = '关注了你'
}
return contentString;
}
buildCommentContent(): string {
let contentString : string = this.messageModel.contentType === '207'?this.messageModel.message:this.messageModel.InteractMsubM.beReply;
return contentString;
}
}
\ No newline at end of file
... ...
... ... @@ -61,6 +61,8 @@ export struct MorningEveningPaperComponent {
@State mixedBgColor: string = ''
// 顶部安全高度赋值
@State topSafeHeight: number = 0;
@State bottomSafeHeight: number = 0;
private audioDataList: AudioDataList[] = []
private playerController: WDPlayerController = new WDPlayerController();
simpleAudioDialog: CustomDialogController = new CustomDialogController({
... ... @@ -112,6 +114,7 @@ export struct MorningEveningPaperComponent {
// await windowHight.setWindowLayoutFullScreen(true);
// WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff', })
this.topSafeHeight = px2vp(windowHight.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM).topRect.height)
this.bottomSafeHeight = px2vp(windowHight.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM).bottomRect.height)
const dailyPaperTopicPageId = await SPHelper.default.getSync('dailyPaperTopicPageId', "") as String
console.info(TAG, `aboutToAppear = ` + dailyPaperTopicPageId)
... ... @@ -248,14 +251,15 @@ export struct MorningEveningPaperComponent {
})
}
}
.height('100%')
.height(`calc(100% - ${this.bottomSafeHeight + this.topSafeHeight + 'vp'})`)
PaperTitleComponent()
}
.width('100%')
.height('100%')
.padding({
top: this.topSafeHeight
top: this.topSafeHeight,
bottom: this.bottomSafeHeight
})
// .backgroundColor(Color.Black)
// .backgroundColor(this.pageInfoBean?.backgroundColor ?? Color.Black)
... ...
... ... @@ -366,6 +366,7 @@ export struct MultiPictureDetailPageComponent {
publishCommentModel: this.publishCommentModel,
operationButtonList: this.operationButtonList,
styleType: 2,
componentType:5,
})
}
.transition(TransitionEffect.OPACITY.animation({ duration: this.duration, curve: Curve.Ease }).combine(
... ... @@ -449,6 +450,7 @@ export struct MultiPictureDetailPageComponent {
this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId)
this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle)
this.publishCommentModel.targetType = String(this.contentDetailData?.newsType)
this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment)
}
// this.contentDetailData.photoList = []
if (this.contentDetailData?.photoList && this.contentDetailData?.photoList?.length === 0) {
... ...
... ... @@ -72,6 +72,7 @@ export struct SpacialTopicPageComponent {
this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId)
this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle)
this.publishCommentModel.targetType = String(this.contentDetailData?.newsType)
this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment)
// }
this.trySendData2H5()
}
... ... @@ -113,4 +114,4 @@ export struct SpacialTopicPageComponent {
}
this.getDetail()
}
}
\ No newline at end of file
}
... ...
... ... @@ -102,6 +102,9 @@ struct createImg {
CardMediaInfo({ contentDTO: this.contentDTO })
}
.align(Alignment.BottomEnd)
.onClick((event: ClickEvent) => {
ProcessUtils.gotoVod(this.contentDTO)
})
}
}
}
... ...
... ... @@ -45,6 +45,7 @@ export struct Card6Component {
Text(`${this.contentDTO.newsTitle}`)
.fontColor(this.clicked ? 0x848484 : 0x222222)
.fontSize(16)
.lineHeight(24)
.fontWeight(FontWeight.Normal)
.maxLines(3)
.alignSelf(ItemAlign.Start)
... ... @@ -70,7 +71,7 @@ export struct Card6Component {
.backgroundColor(this.loadImg ? $r('app.color.color_B0B0B0') : 0xf5f5f5)
.borderRadius(5)
.aspectRatio(this.contentDTO.appStyle === CompStyle.Card_13 ? 3 / 2 : 3 / 4)
.height(this.contentDTO.appStyle === CompStyle.Card_13 ? 90 : 180)
.height(this.contentDTO.appStyle === CompStyle.Card_13 ? 78 : 156)
CardMediaInfo({ contentDTO: this.contentDTO })
}
.alignContent(Alignment.BottomEnd)
... ...
... ... @@ -20,6 +20,8 @@ export class publishCommentModel {
targetType: string = ''
/*评论总数*/
totalCommentNumer: string = '0'
/// 游客评论开关:visitorComment 1:打开;0:关闭
visitorComment: string = "0"
//评论传参
/*评论图片url,多个逗号隔开*/
... ...
... ... @@ -8,9 +8,11 @@ import { HttpUtils } from 'wdNetwork/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import NoMoreLayout from '../../page/NoMoreLayout';
import { EmptyComponent } from '../../view/EmptyComponent';
import { ContentDetailDTO, Params } from 'wdBean/Index';
const TAG = 'CommentComponent';
const testString = '因为读书的人\n是低着头向上看的人\n身处一隅,却能放眼世界\n2,因为读书的人\n总是比不读书的人\n活得有趣一点\n3,因为读书的人\n即使平凡,绝不平庸'
// @Entry
... ... @@ -22,14 +24,20 @@ export struct CommentComponent {
@State isComments: boolean = true
/*必传*/
@ObjectLink publishCommentModel: publishCommentModel
@Consume contentDetailData: ContentDetailDTO
listScroller: ListScroller = new ListScroller(); // scroller控制器
historyOffset: number = 0; // 上次浏览到列表距离顶端的偏移量offset
isloading: boolean = false
@State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource();
@State dialogController: CustomDialogController | null = null;
// @State private browSingModel: commentListModel = new commentListModel()
// 是否为固定高度模式。true时,里面上拉加载更多生效,外层不能包Scroll。
// false时,外层实现加载更多,并通过reachEndIncreament通知开发加载更多,reachEndLoadMoreFinish 通知上层加载更多完成
fixedHeightMode: boolean = false
@Prop @Watch("parentOnReachEnd") reachEndIncreament : number = 0
reachEndLoadMoreFinish?: () => void
// 在自定义组件即将析构销毁时将dialogControlle置空
aboutToDisappear() {
this.dialogController = null // 将dialogController置空
... ... @@ -180,31 +188,52 @@ export struct CommentComponent {
}
}
}, (item: commentItemModel, index: number) => JSON.stringify(item) + index.toString())
// 加载更多
ListItem() {
if (this.hasMore === false) {
if (this.hasMore == false) {
NoMoreLayout()
}
}
}
}
.margin({bottom: 10})
.onReachEnd(() => {
if (!this.fixedHeightMode) {
return
}
if (this.hasMore) {
this.getData()
}
})
.enableScrollInteraction(false)
.enableScrollInteraction(this.fixedHeightMode ? true: false)
// .nestedScroll({
// scrollForward: NestedScrollMode.PARENT_FIRST,
// scrollBackward: NestedScrollMode.SELF_FIRST
// })
}
}
parentOnReachEnd() {
if (this.fixedHeightMode) {
return
}
if (this.hasMore) {
this.getData()
} else {
if (this.reachEndLoadMoreFinish) {
this.reachEndLoadMoreFinish()
}
}
}
//获取数据
async getData() {
commentViewModel.fetchContentCommentList(this.currentPage + '', this.publishCommentModel.targetId,
this.publishCommentModel.targetType)
.then(commentListModel => {
console.log('评论:', JSON.stringify(commentListModel.list))
this.currentPage++
if (Number.parseInt(commentListModel.totalCommentNum) >
... ... @@ -237,6 +266,9 @@ export struct CommentComponent {
} else {
this.hasMore = false
}
if (!this.fixedHeightMode && this.reachEndLoadMoreFinish) {
this.reachEndLoadMoreFinish()
}
})
}
}
... ... @@ -247,6 +279,7 @@ struct ChildCommentItem {
@Link publishCommentModel: publishCommentModel
@Link dialogController: CustomDialogController | null
@ObjectLink item: commentItemModel
@Consume contentDetailData: ContentDetailDTO
build() {
Column() {
... ... @@ -271,6 +304,14 @@ struct ChildCommentItem {
.alignContent(Alignment.Center)
.onClick(() => {
// TODO 跳转个人详情
// 跳转到号主页
if (this.contentDetailData.rmhInfo?.cnMainControl === 1) {
const params: Params = {
creatorId: this.contentDetailData.rmhInfo.rmhId,
pageID: ''
}
WDRouterRule.jumpWithPage(WDRouterPage.peopleShipHomePage, params)
}
})
//昵称
... ... @@ -455,7 +496,7 @@ struct commentHeaderView {
.margin({ left: 8 })
.alignContent(Alignment.Center)
.onClick(() => {
// TODO 跳转个人详情
commentViewModel.jumpToAccountPage(this.item)
})
//昵称
... ...
import { ContentDetailDTO, PageInfoDTO } from 'wdBean/Index'
import { publishCommentModel } from '../model/PublishCommentModel'
@CustomDialog
export struct CommentListDialog {
/// 内部使用
private publishCommentModel: publishCommentModel = new publishCommentModel()
controller?: CustomDialogController
/// 外部初始化
contentDetail?: ContentDetailDTO
pageInfo?: PageInfoDTO
build() {
}
}
\ No newline at end of file
... ...
... ... @@ -11,11 +11,12 @@ export struct CommentTabComponent {
}
@ObjectLink publishCommentModel: publishCommentModel
@Prop contentDetail: ContentDetailDTO
@Prop pageComponentType: number = -1 //1:视频详情页
/*展示类型*/
@State type: number = 1
@State placeHolder: string = '说两句...'
@State dialogController: CustomDialogController | null = null;
styleType : number = 1 //1: 白色背景(图文底部栏) 2: 黑色背景(图集底部栏)
styleType: number = 1 //1: 白色背景(图文底部栏) 2: 黑色背景(图集底部栏)
/*回调方法*/
dialogControllerConfirm: () => void = () => {
}
... ... @@ -46,16 +47,44 @@ export struct CommentTabComponent {
Row() {
Stack({ alignContent: Alignment.Start }) {
RelativeContainer() {
Image($r('app.media.comment_img_input_hui'))
.objectFit(ImageFit.Fill)
.resizable({ slice: { top: 1, left: 1, right: 20, bottom: 1 } })
if (this.pageComponentType === 1) {
Row() {
}
.width('100%')
.height(30)
.borderRadius(2)
.backgroundColor(this.pageComponentType === 1 ? '#1a1a1a' : Color.Transparent)
.margin({
right: 16,
})
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
left: { anchor: "__container__", align: HorizontalAlign.Start },
right: { anchor: "__container__", align: HorizontalAlign.End },
bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
})
.id("Image")
.id("RowBg")
} else {
Image($r('app.media.comment_img_input_hui'))
.objectFit(ImageFit.Fill)
.resizable({
slice: {
top: 1,
left: 1,
right: 20,
bottom: 1
}
})
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
left: { anchor: "__container__", align: HorizontalAlign.Start },
right: { anchor: "__container__", align: HorizontalAlign.End },
bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
})
.id("Image")
}
Text(this.placeHolder)
.fontSize(12)
.fontColor('#999999')
... ... @@ -91,7 +120,7 @@ export struct CommentIconComponent {
@ObjectLink publishCommentModel: publishCommentModel
/*展示类型*/
@State type: number = 1
styleType : number = 1 //1: 白色背景(图文底部栏) 2: 黑色背景(图集底部栏)
styleType: number = 1 //1: 白色背景(图文底部栏) 2: 黑色背景(图集底部栏)
// aboutToAppear(): void {
// setTimeout(() => {
// this.publishCommentModel.totalCommentNumer = '444'
... ...
... ... @@ -412,33 +412,7 @@ struct QualityCommentItem {
jumpToAccountOwner() {
let url = HttpUrlUtils.getOtherUserDetailDataUrl()
let item : Record<string, string >= {
"creatorId": this.item.fromCreatorId || "",
"userType": `${this.item.fromUserType}`,
"userId": this.item.fromUserId || "-1",
}
HttpBizUtil.post<ResponseDTO<MasterDetailRes>>(url, item).then((result) => {
if (!result.data || result.data.mainControl != 1) {
ToastUtils.longToast("暂时无法查看该创作者主页")
return
}
if (result.data.banControl == 1) {
ToastUtils.longToast("该账号已封禁,不予访问")
return
}
if (result.data.userType === "1") { // 普通用户
let params: Record<string, string> = {'userId': result.data.userId};
WDRouterRule.jumpWithPage(WDRouterPage.otherNormalUserHomePagePage,params)
} else { // 非普通用户
ProcessUtils.gotoPeopleShipHomePage(result.data.creatorId)
}
}).catch(() => {
ToastUtils.longToast("暂时无法查看该创作者主页")
})
commentViewModel.jumpToAccountPage(this.item)
}
jumpToDetail() {
... ...
import { MasterDetailRes } from 'wdBean/Index';
import { SpConstants } from 'wdConstant/Index';
import { DateTimeUtils, Logger, SPHelper, ToastUtils, UserDataLocal } from 'wdKit/Index';
import {
AccountManagerUtils,
DateTimeUtils, DeviceUtil, Logger, SPHelper, ToastUtils, UserDataLocal } from 'wdKit/Index';
import { HttpBizUtil, HttpUrlUtils, HttpUtils, ResponseDTO } from 'wdNetwork/Index';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
import { ProcessUtils, WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import {
commentItemModel,
commentListModel,
... ... @@ -160,7 +164,9 @@ class CommentViewModel {
publishComment(model: publishCommentModel) {
return new Promise<commentItemModel>((success, fail) => {
let url = HttpUrlUtils.getPublishCommentUrl()
const visitorMode = model.visitorComment == "1" && AccountManagerUtils.isLoginSync() == false
let url = visitorMode ? HttpUrlUtils.getNoUserPublishCommentUrl() : HttpUrlUtils.getPublishCommentUrl()
let bean: Record<string, string> = {};
bean['targetId'] = model.targetId;
... ... @@ -176,6 +182,11 @@ class CommentViewModel {
bean['targetType'] = model.targetType
bean['parentId'] = model.parentId
if (visitorMode) {
bean['deviceId'] = DeviceUtil.clientId()
bean['userName'] = SPHelper.default.getSync(SpConstants.TOURIST_NICK_NAME, "") as string
}
HttpRequest.post<ResponseDTO<commentItemModel>>(url, bean).then((data: ResponseDTO<commentItemModel>) => {
if (data.code != 0) {
ToastUtils.showToast(data.message, 1000);
... ... @@ -185,10 +196,9 @@ class CommentViewModel {
ToastUtils.showToast(data.message, 1000);
let model = data.data as commentItemModel
let userId = HttpUtils.getUserId()
let FIRSTCOMMENTTIME = SPHelper.default.getSync(SpConstants.FIRSTCOMMENTTIME, '')
let firstCommentTime = SPHelper.default.getSync(SpConstants.FIRSTCOMMENTTIME, '') as string
if (!userId && !FIRSTCOMMENTTIME) {
if (visitorMode && firstCommentTime.length == 0) {
//保存首次评论时间
SPHelper.default.saveSync(SpConstants.FIRSTCOMMENTTIME, DateTimeUtils.formatDate(data.timestamp, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN))
}
... ... @@ -472,6 +482,36 @@ class CommentViewModel {
}
return false
}
jumpToAccountPage(commentItem: commentItemModel) {
let url = HttpUrlUtils.getOtherUserDetailDataUrl()
let item : Record<string, string >= {
"creatorId": commentItem.fromCreatorId || "",
"userType": `${commentItem.fromUserType}`,
"userId": commentItem.fromUserId || "-1",
}
HttpBizUtil.post<ResponseDTO<MasterDetailRes>>(url, item).then((result) => {
if (!result.data || result.data.mainControl != 1) {
ToastUtils.longToast("暂时无法查看该创作者主页")
return
}
if (result.data.banControl == 1) {
ToastUtils.longToast("该账号已封禁,不予访问")
return
}
if (result.data.userType === "1") { // 普通用户
let params: Record<string, string> = {'userId': result.data.userId};
WDRouterRule.jumpWithPage(WDRouterPage.otherNormalUserHomePagePage,params)
} else { // 非普通用户
ProcessUtils.gotoPeopleShipHomePage(result.data.creatorId)
}
}).catch(() => {
ToastUtils.longToast("暂时无法查看该创作者主页")
})
}
}
... ...
/**
* 直播页面点赞动画
*/
interface animationItem {
x: string | number;
y: string | number;
opacity: number;
name: string;
key: string;
url: Resource
}
@Component
export struct LikeAnimationView {
@State @Watch('countChange') count: number = 0
@State imgList: Resource[] =
[$r('app.media.like_animation_1'), $r('app.media.like_animation_2'), $r('app.media.like_animation_3')]
@State animationList: animationItem[] = []
countChange() {
this.animationList.push({
name: 'xxxx',
x: 0,
y: 0,
opacity: 1,
key: Math.random() + '',
url: this.getRandomUrl()
})
}
getRandomUrl(): Resource {
if (Math.random() >= 0 && Math.random() >= 0.33) {
return this.imgList[0]
} else if (Math.random() >= 0.33 && Math.random() >= 0.66) {
return this.imgList[1]
} else {
return this.imgList[2]
}
}
startAnimation() {
}
stopAnimation() {
}
aboutToAppear(): void {
}
aboutToDisappear(): void {
}
build() {
Stack() {
ForEach(this.animationList, (item: animationItem) => {
Image(item.url)
.width(48)
.height(48)
}, (item: animationItem) => item.key)
}
}
}
\ No newline at end of file
... ...
import { WDRouterRule, WDRouterPage } from 'wdRouter'
import MinePageDatasModel from '../../model/MinePageDatasModel'
import MinePagePersonalFunctionsItem from '../../viewmodel/MinePagePersonalFunctionsItem'
import { PagePersonFunction } from './PagePersonFunction'
const TAG = "MinePagePersonFunctionUI"
@Component
export default struct MinePagePersonFunctionUI {
@Link personalData:MinePagePersonalFunctionsItem[]
... ... @@ -10,30 +14,7 @@ export default struct MinePagePersonFunctionUI {
Grid(){
ForEach(this.personalData,(item:MinePagePersonalFunctionsItem,index:number)=>{
GridItem(){
Row(){
Column(){
Image(item.imgSrc)
.width('46lpx')
.height('46lpx')
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
Text(`${item.msg}`)
.margin({top:'8lpx'})
.height('23lpx')
.fontColor($r('app.color.color_222222'))
.fontSize('23lpx')
}
.alignItems(HorizontalAlign.Center)
.width('100%')
Blank()
.layoutWeight(1)
if(index % 4 < 3 && index != this.personalData.length-1){
Text().backgroundColor($r('app.color.color_222222'))
.opacity(0.1)
.width('2lpx')
.height('29lpx')
}
}
PagePersonFunction({ item: item, noDivider : (index % 4 < 3 && index != this.personalData.length-1) ? false : true})
}.onClick(()=>{
console.log(index+"")
switch (item.msg){
... ... @@ -84,6 +65,7 @@ export default struct MinePagePersonFunctionUI {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
this.messageClick()
WDRouterRule.jumpWithPage(WDRouterPage.mineMessagePage)
break;
}
... ... @@ -97,4 +79,13 @@ export default struct MinePagePersonFunctionUI {
.height('234lpx')
.margin({top:'31lpx',left:'23lpx',right:'23lpx' })
}
}
\ No newline at end of file
messageClick(){
MinePageDatasModel.sendClickMessageData().then((value) => {
console.log(TAG, "进入消息页面")
}).catch((err: Error) => {
console.log(TAG, JSON.stringify(err))
})
}
}
... ...
import MinePagePersonalFunctionsItem from '../../viewmodel/MinePagePersonalFunctionsItem'
@Component
export struct PagePersonFunction{
@ObjectLink item: MinePagePersonalFunctionsItem
@State noDivider:boolean = false
build() {
Row(){
Column(){
Stack({ alignContent: Alignment.TopEnd }){
Image(this.item.imgSrc)
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
if (this.item.isShowRedPoint) {
Button()
.type(ButtonType.Circle)
.width("12lpx")
.height("12lpx")
.backgroundColor($r('app.color.color_ED2800'))
}
}.width('46lpx')
.height('46lpx')
Text(`${this.item.msg}`)
.margin({top:'8lpx'})
.height('23lpx')
.fontColor($r('app.color.color_222222'))
.fontSize('23lpx')
}
.alignItems(HorizontalAlign.Center)
.width('100%')
Blank()
.layoutWeight(1)
if(!this.noDivider){
Text().backgroundColor($r('app.color.color_222222'))
.opacity(0.1)
.width('2lpx')
.height('29lpx')
}
}
}
}
\ No newline at end of file
... ...
import { StringUtils } from 'wdKit/Index'
import { MessageItem } from '../../../viewmodel/MessageItem'
const TAG = "MessageListUI"
@Component
export struct MessageListItemUI {
@ObjectLink item: MessageItem
@State index:number = -1
build() {
Column(){
Column() {
Row() {
Row() {
Image(this.item.imgSrc)
.objectFit(ImageFit.Auto)
.width('92lpx')
.height('92lpx')
.margin({ right: '15lpx' })
Column() {
Text(this.item.title)
.fontWeight(500)
.fontSize('31lpx')
.lineHeight('42lpx')
.fontColor($r('app.color.color_222222'))
.maxLines(1)
.margin({ bottom: StringUtils.isNotEmpty(this.item.desc)?'8lpx':0 })
if(StringUtils.isNotEmpty(this.item.desc)){
Text(`${this.item.desc}`)
.fontColor($r('app.color.color_999999'))
.fontSize('27lpx')
.lineHeight('38lpx')
.fontWeight(400)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
}
.height('92lpx')
.layoutWeight(1)
.alignItems(HorizontalAlign.Start)
.justifyContent(StringUtils.isNotEmpty(this.item.desc)?FlexAlign.Start:FlexAlign.Center)
}.layoutWeight(1)
Column() {
Text(`${this.item.time}`)
.fontColor($r('app.color.color_999999'))
.fontSize('23lpx')
.fontWeight(500)
.lineHeight('35lpx')
.margin({ bottom: this.item.unReadCount > 0 ?'8lpx':0 })
if(this.item.unReadCount > 0){
Button(){
Text(`${this.item.unReadCount}`)
.fontWeight(400)
.fontSize("18lpx")
.fontColor($r('app.color.white'))
}
.type((this.item.unReadCount>0 && this.item.unReadCount < 10 ? ButtonType.Circle:ButtonType.Capsule))
.backgroundColor($r("app.color.color_ED2800"))
.stateEffect(false)
.height("27lpx")
.constraintSize({minWidth:"27lpx"})
}
}
.justifyContent(FlexAlign.Start)
.alignItems(HorizontalAlign.End)
.height('92lpx')
}
.width('100%')
.height('92lpx')
.justifyContent(FlexAlign.SpaceBetween)
}.height('154lpx')
.width("100%")
.justifyContent(FlexAlign.Center)
Text().backgroundColor($r('app.color.color_EDEDED'))
.width('100%')
.height('1lpx')
.visibility(this.index != 3 ?Visibility.Visible:Visibility.None)
}
}
}
\ No newline at end of file
... ...
import { StringUtils, ToastUtils } from 'wdKit/Index'
import { DateTimeUtils, StringUtils, ToastUtils } from 'wdKit/Index'
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
import MinePageDatasModel from '../../../model/MinePageDatasModel'
import { MessageItem } from '../../../viewmodel/MessageItem'
import { CustomTitleUI } from '../../reusable/CustomTitleUI'
import { MessageListItemUI } from './MessageListItemUI'
const TAG = "MessageListUI"
... ... @@ -11,6 +13,123 @@ export struct MessageListUI {
aboutToAppear() {
this.msgData = MinePageDatasModel.getMessageData()
this.getHistoryPush()
this.getMessagePush()
}
//历史推送
getHistoryPush() {
MinePageDatasModel.getHistoryPushData("1", "1").then((value) => {
if (value != null && value.list != null && value.list.length > 0) {
this.msgData.forEach((item) => {
if (item.title == "历史推送") {
if (value.list != null && value.list[0] != null) {
if (value.list[0].newsTitle) {
item.desc = value.list[0].newsTitle
}
if (value.list[0].publishTime) {
item.time = this.getPublishTime("",value.list[0].publishTime)
}
}
}
})
}
}).catch((err: Error) => {
console.log(TAG, JSON.stringify(err))
})
}
//互动消息 预约消息 系统消息
getMessagePush() {
MinePageDatasModel.getMessageUnReadData().then((value) => {
this.msgData.forEach((item) => {
if (item.title == "预约消息") {
if (value.subscribeInfo != null) {
if (value.subscribeInfo.title) {
item.desc = value.subscribeInfo.title
}
if (value.subscribeInfo.time) {
item.time = this.getPublishTime(value.subscribeInfo.time,DateTimeUtils.getDateTimestamp(value.subscribeInfo.time)+"")
}
}
if(value.subscribeCount > 0){
item.unReadCount = value.subscribeCount
}
} else if (item.title == "系统消息") {
if (value.systemInfo != null) {
if (value.systemInfo.title) {
item.desc = value.systemInfo.title
}
if (value.systemInfo.time) {
item.time = this.getPublishTime(value.subscribeInfo.time,DateTimeUtils.getDateTimestamp(value.systemInfo.time) + "")
}
}
if(value.systemCount > 0){
item.unReadCount = value.systemCount
}
}else if(item.title == "互动消息"){
if(value.activeCount > 0){
item.unReadCount = value.activeCount
}
if (value.activeInfo != null) {
if (value.activeInfo.title) {
item.desc = value.activeInfo.title
}
if (value.activeInfo.time) {
item.time = this.getPublishTime(value.subscribeInfo.time,DateTimeUtils.getDateTimestamp(value.activeInfo.time) + "")
}
}
}
})
}).catch((err: Error) => {
console.log(TAG, JSON.stringify(err))
})
}
getPublishTime(data:string,publishTime: string): string {
const publishTimestamp = parseInt(publishTime)
const currentTime = Date.now(); // 当前时间戳
// 计算差异
const timeDifference = currentTime - publishTimestamp;
// 转换为分钟、小时和天
const minutes = Math.floor(timeDifference / (1000 * 60));
const hours = Math.floor(timeDifference / (1000 * 60 * 60));
const days = Math.floor(timeDifference / (1000 * 60 * 60 * 24));
// 根据时间差返回对应的字符串
let result: string;
if (minutes < 60) {
result = `${minutes}分钟前`;
if(minutes === 0){
result = `刚刚`;
}
} else if (hours < 24) {
result = `${hours}小时前`;
} else {
result = `${days}天前`;
if(days > 1){
let arr = data.split(" ")
if(arr.length === 2){
let arr2 = arr[0].split("-")
if(arr2.length === 3){
result = `${arr2[1]}-${arr2[2]}`
}
}else{
//原始数据是时间戳 需要转成dateString
let time = DateTimeUtils.formatDate(Number(publishTime))
let arr = time.split("-")
if(arr.length === 3){
result = `${arr[1]}-${arr[2]}`
}
}
}
}
console.log(result);
return result
}
build() {
... ... @@ -21,73 +140,16 @@ export struct MessageListUI {
List() {
ForEach(this.msgData, (item: MessageItem, index: number) => {
ListItem() {
Column(){
Column() {
Row() {
Row() {
Image(item.imgSrc)
.objectFit(ImageFit.Auto)
.width('92lpx')
.height('92lpx')
.margin({ right: '15lpx' })
Column() {
Text(item.title)
.fontWeight(500)
.fontSize('31lpx')
.lineHeight('42lpx')
.fontColor($r('app.color.color_222222'))
.maxLines(1)
.margin({ bottom: StringUtils.isNotEmpty(item.desc)?'8lpx':0 })
if(StringUtils.isNotEmpty(item.desc)){
Text(`${item.desc}`)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize('23lpx')
.lineHeight('38lpx')
.fontWeight(400)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
}
.height('92lpx')
.layoutWeight(1)
.alignItems(HorizontalAlign.Start)
.justifyContent(StringUtils.isNotEmpty(item.desc)?FlexAlign.Start:FlexAlign.Center)
}.layoutWeight(1)
Row() {
Text(`${item.time}`)
.fontColor($r('app.color.color_999999'))
.fontSize('23lpx')
.fontWeight(500)
.lineHeight('35lpx')
}
.justifyContent(FlexAlign.Start)
.alignItems(VerticalAlign.Top)
.height('92lpx')
}
.width('100%')
.height('92lpx')
.justifyContent(FlexAlign.SpaceBetween)
}.height('154lpx')
.width("100%")
.justifyContent(FlexAlign.Center)
Text().backgroundColor($r('app.color.color_EDEDED'))
.width('100%')
.height('1lpx')
.visibility(index != 3 ?Visibility.Visible:Visibility.None)
}
MessageListItemUI({ item: item, index: index })
}
.padding({left:"31lpx",right:"31lpx"})
.padding({ left: "31lpx", right: "31lpx" })
.onClick(() => {
ToastUtils.shortToast(index+"")
switch (index) {
case 0: //互动消息
WDRouterRule.jumpWithPage(WDRouterPage.interactMessagePage)
break;
case 1: //预约消息
WDRouterRule.jumpWithPage(WDRouterPage.subscribeMessagePage)
break;
case 2: //历史推送
break;
... ...
import { SubscribeMessageModel } from '../../../../model/InteractMessageModel'
@Component
export struct SubscribeListChildComponent{
@ObjectLink item: SubscribeMessageModel
build() {
Column(){
Row(){
Text(`${this.item.dealTime}`)
.margin({top:"31lpx",bottom:"23lpx"})
.fontWeight(400)
.fontSize("23lpx")
.lineHeight("33lpx")
.fontColor($r('app.color.color_999999'))
}.width('100%')
.backgroundColor($r('app.color.color_F5F5F5'))
.justifyContent(FlexAlign.Center)
Column(){
Column(){
Text(`${this.item.title}`)
.fontSize("31lpx")
.lineHeight("46lpx")
.fontWeight(500)
.fontColor($r('app.color.color_333333'))
.margin({top:"27lpx",bottom:"25lpx"})
.maxLines(1)
Text().backgroundColor($r('app.color.color_F5F5F5'))
.width('100%')
.height('1lpx')
}.alignItems(HorizontalAlign.Start)
.width("100%")
.height("98lpx")
Row(){
Image(`${this.item.imgUrl}`)
.width('204lpx')
.height('115lpx')
.borderRadius("6lpx")
.objectFit(ImageFit.Auto)
.margin({right:"23lpx"})
Text(`${this.item.desc}`)
.fontSize("27lpx")
.lineHeight("38lpx")
.fontWeight(400)
.fontColor($r('app.color.color_222222'))
.layoutWeight(1)
}.alignItems(VerticalAlign.Center)
.width("100%")
.height("160lpx")
Text().backgroundColor($r('app.color.color_F5F5F5'))
.width('100%')
.height('1lpx')
Row(){
Text(`${this.item.time}开始`)
.fontSize("23lpx")
.fontWeight(600)
.lineHeight("31lpx")
Row(){
Text("查看详情")
.fontSize("23lpx")
.lineHeight("38lpx")
.fontWeight(400)
.fontColor($r('app.color.color_666666'))
.margin({right:"8lpx"})
Image($r('app.media.subscribe_arrow_icon'))
.width('23lpx')
.height('13lpx')
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
.margin({right:"4lpx"})
}
}.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.SpaceBetween)
.width("100%")
.height("73lpx")
}.backgroundColor($r('app.color.white'))
.borderRadius("8lpx")
.width("100%")
.padding({left:"23lpx",right:"23lpx"})
}
.backgroundColor($r('app.color.color_F5F5F5'))
.width("100%")
.padding({left:"31lpx",right:"31lpx"})
.alignItems(HorizontalAlign.Center)
}
}
\ No newline at end of file
... ...
import { LazyDataSource, StringUtils } from 'wdKit/Index';
import { Remark, SubscribeMessageModel,
WDMessageCenterMessageType } from '../../../../model/InteractMessageModel';
import MinePageDatasModel from '../../../../model/MinePageDatasModel';
import { CustomTitleUI } from '../../../reusable/CustomTitleUI';
import { ListHasNoMoreDataUI } from '../../../reusable/ListHasNoMoreDataUI';
import { EmptyComponent } from '../../../view/EmptyComponent';
import { SubscribeListChildComponent } from './SubscribeListChildComponent';
const TAG = "SubscribeMessageComponent"
@Component
export struct SubscribeMessageComponent{
@State data: LazyDataSource<SubscribeMessageModel> = new LazyDataSource();
@State count: number = 0;
@State isLoading: boolean = false
@State hasMore: boolean = true
curPageNum: number = 1;
@State isGetRequest: boolean = false
aboutToAppear() {
this.getNewPageData()
}
build() {
Column() {
//标题栏目
CustomTitleUI({ titleName: "预约消息" })
if (this.count == 0) {
if (this.isGetRequest == true) {
EmptyComponent({ emptyType: 5 })
.height('100%')
.width('100%')
}
} else {
//刷新控件 TODO
//List
List() {
LazyForEach(this.data, (item: SubscribeMessageModel, index: number) => {
ListItem() {
SubscribeListChildComponent({ item: item })
}.width('100%')
.onClick(() => {
})
})
//没有更多数据 显示提示
if (!this.hasMore) {
ListItem() {
ListHasNoMoreDataUI()
}
}
}.width('100%')
.cachedCount(4)
.scrollBar(BarState.Off)
.layoutWeight(1)
.onReachEnd(() => {
if (!this.isLoading) {
//加载分页数据
this.getNewPageData()
}
})
}
}
.backgroundColor($r('app.color.color_F9F9F9'))
.height('100%')
.width('100%')
}
getNewPageData() {
this.isLoading = true
if (this.hasMore) {
MinePageDatasModel.getSubscribeMessageData(WDMessageCenterMessageType.WDMessageCenterMessageType_Subscribe,"20",`${this.curPageNum}`).then((value) => {
if (!this.data || value.list.length == 0) {
this.hasMore = false
} else {
value.list.forEach((value) => {
let dealTime = this.DealStartTime(value.time,1)
let dealTime2 = this.DealStartTime(value.time,2)
let remark = JSON.parse(value.remark) as Remark
this.data.push(new SubscribeMessageModel(dealTime,value.message,remark.coverImageUrl,value.title,dealTime2,value.contentId))
})
this.data.notifyDataReload()
this.count = this.data.totalCount()
if (this.data.totalCount() < value.totalCount) {
this.curPageNum++
} else {
this.hasMore = false
}
}
this.isGetRequest = true
this.isLoading = false
}).catch((err: Error) => {
console.log(TAG, JSON.stringify(err))
this.isGetRequest = true
this.isLoading = false
})
}
}
DealStartTime(planStartTime: string,type:number): string {
let dealData: string = ""
if (StringUtils.isEmpty(planStartTime)) {
console.log(TAG, "格式有误")
return planStartTime
}
if (planStartTime.indexOf(" ") === -1) {
console.log(TAG, "格式有误")
return planStartTime
}
let arr = planStartTime.split(" ")
if (arr != null && StringUtils.isNotEmpty(arr[0])) { //处理年月日
let time = arr[0].split("-");
if (time.length === 3) {
dealData = `${time[1]}-${time[2]}`
if(type === 1){
return dealData
}
}
}
if (arr != null && StringUtils.isNotEmpty(arr[1])) { //处理时分
let time = arr[1].split(":");
if (time.length === 3) {
dealData = `${dealData} ${time[0]}:${time[1]}`
}
}
console.log(TAG, JSON.stringify(dealData))
return dealData
}
}
\ No newline at end of file
... ...
... ... @@ -19,19 +19,25 @@ struct EditUserIntroductionPage {
.width('100%')
.height(80)
.backgroundColor(Color.White)
.placeholderColor('#999999')
.onChange(value => {
this.numCount = value.length
if (this.numCount === 60) {
this.textColor = '#ED2800'
}else if(this.numCount === 0){
this.textColor = '#999999'
}else {
this.textColor = '#222222'
}
this.introduction = value
})
Text(this.numCount.toString() + '/60')
.fontColor(this.textColor)
.margin({left: -50})
Row(){
Text(this.numCount.toString())
.fontColor(this.textColor)
Text('/60')
.fontColor('#999999')
}.margin({left: -50})
}
.alignItems(VerticalAlign.Bottom)
... ... @@ -42,7 +48,7 @@ struct EditUserIntroductionPage {
Text('1、账号中(头像、昵称等)不允许含有违禁违规内容;\n2、最多60个字,只能输入中文、数字、英文字母。')
.fontSize(13)
.padding(12)
.fontColor(Color.Gray)
.fontColor(Color.Gray).lineHeight(25)
Button('保存')
.type(ButtonType.Normal)
... ...
... ... @@ -22,19 +22,25 @@ struct EditUserNikeNamePage {
.maxLength(16)
.height(50)
.backgroundColor(Color.White)
.placeholderColor('#999999')
.onChange(value => {
this.numCount = value.length
if (this.numCount === 16) {
this.textColor = '#ED2800'
}else if(this.numCount === 0){
this.textColor = '#999999'
}else {
this.textColor = '#222222'
}
this.nikeName = value
})
Text(this.numCount.toString() + '/16')
.fontColor(this.textColor)
.margin({left: -50})
Row(){
Text(this.numCount.toString())
.fontColor(this.textColor)
Text('/16')
.fontColor('#999999')
}.margin({left: -50})
}
.alignItems(VerticalAlign.Center)
... ... @@ -44,7 +50,7 @@ struct EditUserNikeNamePage {
Text('1、账号中(头像、昵称等)不允许含有违禁违规内容;\n2、最多16个字,只能输入中文、数字、英文字母。')
.fontSize(13)
.padding(12)
.fontColor(Color.Gray)
.fontColor(Color.Gray).lineHeight(25)
Button('保存')
.type(ButtonType.Normal)
... ...
import MyCollectionViewModel from '../../viewmodel/MyCollectionViewModel';
import InteractMessageViewModel from '../../viewmodel/InteractMessageViewModel';
import PageModel from '../../viewmodel/PageModel';
import { CommonConstants, ViewType } from 'wdConstant'
import { EmptyComponent,WDViewDefaultType } from '../view/EmptyComponent'
import { ContentDTO } from 'wdBean'
import NoMoreLayout from './NoMoreLayout'
import CustomRefreshLoadLayout from './CustomRefreshLoadLayout';
import { CustomSelectUI } from '../view/CustomSelectUI';
import { CustomBottomFuctionUI } from '../view/CustomBottomFuctionUI';
import { BigPicCardComponent } from '../view/BigPicCardComponent';
import { CustomTitleUI } from '../reusable/CustomTitleUI';
import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh';
import { InteractMComponent } from '../InteractMessage/InteractMComponent';
import { InteractMessageModel, WDMessageCenterMessageType } from '../../model/InteractMessageModel';
import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh';
@Entry
@Component
... ... @@ -20,39 +15,40 @@ struct InteractMessagePage {
@State private browSingModel: PageModel = new PageModel()
isloading : boolean = false
@Provide isEditState:boolean = false
@State allDatas :ContentDTO[] = [];
@State allDatas :InteractMessageModel[] = [];
private scroller: Scroller = new Scroller();
@State likeNum: number = 20
@State likeNum: number = 0
@State currentPage: number = 1;
aboutToAppear(){
this.getData()
this.getMessageLikeCount()
}
build() {
Column(){
CustomTitleUI({titleName:'互动消息'})
this.ListLayout()
// if(this.browSingModel.viewType == ViewType.ERROR){
// EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NetworkFailed})
// }else if(this.browSingModel.viewType == ViewType.EMPTY){
// EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NoHistory})
// }else {
// CustomPullToRefresh({
// alldata:this.allDatas,
// scroller:this.scroller,
// customList:()=>{
// this.ListLayout()
// },
// onRefresh:(resolve)=>{
// this.browSingModel.currentPage = 0
// this.getData(resolve)
// },
// onLoadMore:(resolve)=> {
// this.browSingModel.currentPage++
// this.getData()
// }
// })
// }
if(this.browSingModel.viewType == ViewType.ERROR){
EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NetworkFailed})
}else if(this.browSingModel.viewType == ViewType.EMPTY){
EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NoHistory})
}else {
CustomPullToRefresh({
alldata:this.allDatas,
scroller:this.scroller,
customList:()=>{
this.ListLayout()
},
onRefresh:(resolve)=>{
this.browSingModel.currentPage = 0
this.getData(resolve)
},
onLoadMore:(resolve)=> {
this.browSingModel.currentPage++
this.getData()
}
})
}
}
.width(CommonConstants.FULL_WIDTH)
... ... @@ -66,9 +62,9 @@ struct InteractMessagePage {
}
// 下拉刷新
ForEach(this.allDatas, (compDTO: ContentDTO, compIndex: number) => {
ForEach(this.allDatas, (InteractM: InteractMessageModel, compIndex: number) => {
ListItem() {
InteractMComponent()
InteractMComponent({messageModel:InteractM})
}
})
// 加载更多
... ... @@ -112,12 +108,22 @@ struct InteractMessagePage {
}
async getData(resolve?: (value: string | PromiseLike<string>) => void){
MyCollectionViewModel.fetchMyCollectList(2,'1',this.browSingModel.currentPage,getContext(this)).then(collectionItem => {
InteractMessageViewModel.fetchMessageList(WDMessageCenterMessageType.WDMessageCenterMessageType_Interact,this.currentPage).then(InteractMessageMItem => {
if(resolve) resolve('刷新成功')
if (collectionItem && collectionItem.list && collectionItem.list.length > 0) {
if (InteractMessageMItem && InteractMessageMItem.list && InteractMessageMItem.list.length > 0) {
this.browSingModel.viewType = ViewType.LOADED;
this.allDatas.push(...collectionItem.list)
if (collectionItem.list.length === this.browSingModel.pageSize) {
if (this.currentPage === 1) {
this.allDatas = []
}
for (let index = 0; index < InteractMessageMItem.list.length; index++) {
const element = InteractMessageMItem.list[index];
element.InteractMsubM = JSON.parse(element.remark)
}
this.allDatas.push(...InteractMessageMItem.list)
if (InteractMessageMItem.list.length === this.browSingModel.pageSize) {
this.browSingModel.currentPage++;
this.browSingModel.hasMore = true;
} else {
... ... @@ -129,4 +135,11 @@ struct InteractMessagePage {
})
}
async getMessageLikeCount(){
InteractMessageViewModel.getMessageLikeCount().then(num => {
this.likeNum = num
})
}
}
... ...
import { ContentDTO } from 'wdBean';
import { ContentDTO, LiveRoomDataBean } from 'wdBean';
import { ProcessUtils } from 'wdRouter';
import { CommonConstants } from 'wdConstant/Index';
import PageViewModel from '../../viewmodel/PageViewModel';
import RefreshLayout from '../page/RefreshLayout';
import { RefreshLayoutBean } from '../page/RefreshLayoutBean';
import PageModel from '../../viewmodel/PageModel';
import { DateTimeUtils, LazyDataSource } from 'wdKit/Index';
import { DateTimeUtils, LazyDataSource, Logger } from 'wdKit/Index';
import { router } from '@kit.ArkUI';
import { ViewType } from 'wdConstant/src/main/ets/enum/ViewType';
import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh';
import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData';
import { EmptyComponent } from '../view/EmptyComponent';
import { ErrorComponent } from '../view/ErrorComponent';
import LoadMoreLayout from '../page/LoadMoreLayout'
const TAG: string = 'LiveMorePage';
... ... @@ -21,60 +24,22 @@ const TAG: string = 'LiveMorePage';
@Entry
@Component
struct LiveMorePage {
@State private pageModel: PageModel = new PageModel();
@State data: LazyDataSource<ContentDTO> = new LazyDataSource();
topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number;
type: number = 1;
currentPage: number = 1;
pageSize: number = 20;
operDataList: ContentDTO[] = [];
title: string = '直播列表'
@State contentDTO: ContentDTO = new ContentDTO();
// appStyle: '15',
// coverType: 1,
// objectType: '9',
// coverUrl: 'https://rmrbcmsonline.peopleapp.com/rb_recsys/img/2024/0413/VL20Z09ISBEKXZU_963672030241091584.jpeg?x-oss-process=image/resize,m_fill,h_450,w_800/quality,q_90',
// fullColumnImgUrls: [
// {
// landscape: 2,
// size: 1,
// url: 'https://rmrbcmsonline.peopleapp.com/rb_recsys/img/2024/0413/VL20Z09ISBEKXZU_963672030241091584.jpeg?x-oss-process=image/resize,m_fill,h_450,w_800/quality,q_90',
// weight: 1170
// }
// ],
// newsTitle: '押解画面公开!被湖北民警从柬埔寨押解回国被湖北民警从柬埔寨押解回国的130名涉赌诈嫌疑人是他们被湖北民警从柬埔寨押解回国的130名涉赌诈嫌疑人是他们的130名涉赌诈嫌疑人是他们',
// publishTime: '1712993333000',
// rmhInfo: {
// authIcon: '',
// authTitle: '',
// authTitle2: '',
// banControl: 0,
// cnIsAttention: 1,
// rmhDesc: '中共武汉市委机关报长江日报官方人民号',
// rmhHeadUrl: 'https://uatjdcdnphoto.aikan.pdnews.cn/vod/content/202302/202302Sa121448724/TUw.png?x-oss-process=image/resize,l_100/auto-orient,1/quality,q_90/format,jpg',
// rmhId: '4255270',
// rmhName: '长江日报',
// userId: '513696944662469',
// userType: '3'
// },
// videoInfo: {
// firstFrameImageUri: '',
// videoDuration: 12,
// // videoLandscape: 2,
// videoUrl: 'https://rmrbcmsonline.peopleapp.com/rb_recsys/video/2024/0413/VL20Z09ISBEKXZU_963672027208609792.mp4'
// },
// photoNum: '9',
// voiceInfo: {
// voiceDuration: 12
// }
// } as ContentDTO;
@State private hasMore: boolean = true
@State private currentPage: number = 1
@State private isLoading: boolean = false
@State viewType: ViewType = ViewType.LOADING
private scroller: Scroller = new Scroller()
@State liveRoomList: LiveRoomDataBean[] = []
aboutToAppear(): void {
PageViewModel.getLiveMoreUrl(this.type, this.currentPage, this.pageSize).then((liveReviewDTO) => {
// this.operDataList = []
// this.operDataList.push(...liveReviewDTO.list)
this.data.push(...liveReviewDTO.list)
})
this.currentPage = 1
this.getData()
}
build() {
... ... @@ -88,48 +53,78 @@ struct LiveMorePage {
Column() {
this.TabbarNormal()
this.ListLayout()
if (this.viewType == ViewType.LOADING) {
this.LoadingLayout()
} else if (this.viewType == ViewType.ERROR) {
ErrorComponent()
.onTouch(() => {
if (this.viewType === ViewType.ERROR) {
this.getData()
}
})
} else if (this.viewType == ViewType.EMPTY) {
EmptyComponent()
} else {
CustomPullToRefresh({
alldata: this.data,
scroller: this.scroller,
hasMore: false,
customList: () => {
this.ListLayout()
},
onRefresh: (resolve) => {
this.currentPage = 1
this.getData(resolve)
},
})
}
}
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
bottom: $r('app.float.card_comp_pagePadding_tb')
})
.onClick((event: ClickEvent) => {
.onClick(() => {
ProcessUtils.processPage(this.contentDTO)
})
}
@Builder
LoadingLayout() {
}
@Builder
ListLayout() {
List() {
List({scroller: this.scroller}) {
// 下拉刷新
ListItem() {
RefreshLayout({
refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullDown, this.pageModel.pullDownRefreshImage,
this.pageModel.pullDownRefreshText, this.pageModel.pullDownRefreshHeight)
})
}
LazyForEach(this.data, (contentDTO: ContentDTO, contentIndex: number) => {
LazyForEach(this.data, (contentDTO: ContentDTO) => {
ListItem() {
// Column() {
// CompParser({ compDTO: compDTO, compIndex: compIndex });
// }
this.buildItem(contentDTO)
}
},
(contentDTO: ContentDTO, contentIndex: number) => contentDTO.pageId + contentIndex.toString()
)
// 加载更多
ListItem() {
if (this.hasMore && this.data && this.data.totalCount() > 0) {
LoadMoreLayout({ isVisible: this.hasMore })
} else if (!this.hasMore && !this.isLoading) {
PeopleShipNoMoreData()
}
}
}
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None)
.cachedCount(8)
.height(CommonConstants.FULL_PARENT)
.onScrollIndex((start: number, end: number) => {
// Listen to the first index of the current list.
this.pageModel.startIndex = start;
// 包含了 头尾item,判断时需要考虑+2
this.pageModel.endIndex = end;
.height('calc(100% - 44vp)')
.onReachEnd(() => {
Logger.debug(TAG, "触底了");
if(!this.isLoading && this.hasMore){
//加载分页数据
this.currentPage++;
this.getData()
}
})
}
... ... @@ -148,22 +143,45 @@ struct LiveMorePage {
.margin({ top: 16, bottom: 8 })
.alignSelf(ItemAlign.Start)
Stack() {
Image(item.fullColumnImgUrls[0].url)
.width('100%')
.height(196)
.borderRadius(4)
this.LiveImage()
if (item.fullColumnImgUrls && item.fullColumnImgUrls.length > 0) {
Image(item.fullColumnImgUrls[0].url)
.width('100%')
.height(196)
.borderRadius(4)
}
this.LiveImage(item)
}
.alignContent(Alignment.BottomEnd)
Text(DateTimeUtils.getCommentTime(Number.parseFloat(item.publishTimestamp)))
.fontSize(13)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 8, bottom: 8 })
.align(Alignment.Start)
.width('100%')
Row() {
if (item.rmhInfo && item.rmhInfo.rmhName) {
Text(item.rmhInfo.rmhName)
.fontSize(12)
.fontWeight(400)
.fontColor($r('app.color.color_B0B0B0'))
.fontFamily('PingFang SC-Medium')
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.align(Alignment.Start)
Image($r('app.media.point_live_icon'))
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
.width(16)
.height(16)
.margin(2)
}
Text(DateTimeUtils.getCommentTime(Number.parseFloat(item.publishTimestamp)))
.fontSize(12)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.align(Alignment.Start)
.width('100%')
.fontColor($r('app.color.color_B0B0B0'))
}
.margin({ top: 8, bottom: 8 })
Divider()
.strokeWidth(1)
... ... @@ -198,10 +216,10 @@ struct LiveMorePage {
Text(this.title)// .height('42lpx')
.maxLines(1)
.id("title")
.fontSize('35lpx')
.fontSize('18vp')
.fontWeight(400)
.fontColor($r('app.color.color_222222'))
.lineHeight('42lpx')
.lineHeight('22vp')
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
... ... @@ -212,17 +230,141 @@ struct LiveMorePage {
}
@Builder
LiveImage() {
LiveImage(item: ContentDTO) {
Row() {
Image($r('app.media.icon_live_status_running'))
.width(22)
.height(18)
Image($r('app.media.icon_live_new_running'))
.width(14)
.height(14)
.margin({
right: '2vp'
})
Text('直播中')
.fontSize('11fp')
.fontSize('12vp')
.fontWeight(400)
.fontColor(Color.White)
.margin({
right: '5vp'
})
Divider()
.vertical(true)
.strokeWidth(1)
.height('12vp')
.margin({ top: 2, bottom: 2 })
.color(Color.White)
if (this.getLiveRoomNumber(item).length > 0) {
Text(this.getLiveRoomNumber(item))
.fontSize('12vp')
.fontWeight(400)
.fontColor(Color.White)
.margin({
left: '5vp'
})
}
}
.backgroundColor('#4D000000')
.justifyContent(FlexAlign.End)
.margin({ right: 8, bottom: 8 })
}
private async getData(resolve?: (value: string | PromiseLike<string>) => void) {
if (this.isLoading) {
if (resolve) {
resolve('已更新至最新')
}
return
}
this.isLoading = true
try {
const liveReviewDTO = await PageViewModel.getLiveMoreUrl(this.type, this.currentPage, this.pageSize)
if (liveReviewDTO && liveReviewDTO.list && liveReviewDTO.list.length > 0) {
if (liveReviewDTO.list.length === this.pageSize) {
this.hasMore = true;
} else {
this.hasMore = false;
}
if (this.currentPage == 1) {
this.data.clear()
}
this.data.push(...liveReviewDTO.list)
this.getLiveRoomDataInfo(liveReviewDTO.list)
} else {
this.hasMore = false;
}
this.resolveEnd(true, resolve)
if (liveReviewDTO.list.length == 0 && this.currentPage == 1) {
this.viewType = ViewType.EMPTY
}
}catch (exception) {
this.resolveEnd(false, resolve)
}
// PageViewModel.getLiveMoreUrl(this.type, this.currentPage, this.pageSize).then(async (liveReviewDTO) => {
// // this.operDataList = []
// // this.operDataList.push(...liveReviewDTO.list)
// this.data.push(...liveReviewDTO.list)
//
// // this.getAppointmentInfo()
// })
}
private resolveEnd(isTop: boolean, resolve?: (value: string | PromiseLike<string>) => void) {
if (resolve) {
if (this.currentPage == 1 && isTop) {
resolve('已更新至最新')
}else {
resolve('')
}
}
if (this.currentPage == 1 && !isTop) {
this.viewType = ViewType.ERROR
} else {
this.viewType = ViewType.LOADED
}
this.isLoading = false
}
private getLiveDetailIds(list: ContentDTO[]): string {
let idList: string[] = []
list.forEach(item => {
idList.push(item.objectId)
});
return idList.join(',')
}
// 获取评论数
async getLiveRoomDataInfo(list: ContentDTO[]) {
const reserveIds = this.getLiveDetailIds(list)
Logger.debug(TAG,'是否预约数据:' +` ${reserveIds}`)
PageViewModel.getLiveRoomBatchInfo(reserveIds).then((result) => {
Logger.debug(TAG,'是否预约数据:' +` ${JSON.stringify(result)}`)
if (result && result.length > 0) {
this.liveRoomList.push(...result)
this.data.reloadData()
}
}).catch(() =>{
// this.data.push(...list)
})
}
// 判断是否预约
getLiveRoomNumber(item: ContentDTO): string {
const objc = this.liveRoomList.find((element: LiveRoomDataBean) => {
return element.liveId.toString() == item.objectId
})
if (objc && objc.pv && objc.pv > 0) {
return this.computeShowNum(objc.pv)
}
return ''
}
private computeShowNum(count: number): string {
if (count >= 10000) {
let num = ( count / 10000).toFixed(1)
if (Number(num.substring(num.length-1)) == 0) {
num = num.substring(0, num.length-2)
}
return num + '万人参加'
}
return `${count}人参加`
}
}
\ No newline at end of file
... ...
... ... @@ -31,7 +31,10 @@ export struct MinePageComponent {
this.isLogin = false
}else {
this.isLogin = true
this.addRecordDialog()
this.addRecordDialog()
if(this.personalData.length > 0){
this.getMessageData()
}
}
}
}
... ... @@ -53,8 +56,25 @@ export struct MinePageComponent {
this.getUserLogin()
this.getFunctionData()
this.addLoginStatusObserver()
this.getMessageData()
}
getMessageData(){
MinePageDatasModel.getMessageUnReadData().then((value) => {
if(value !=null) {
if(value.activeCount >0 ||value.subscribeCount > 0 || value.systemCount > 0){
this.personalData.forEach((value) => {
if(value.msg == "消息")
value.isShowRedPoint = true
})
}
}
}).catch((err: Error) => {
console.log(TAG, JSON.stringify(err))
})
}
async addLoginStatusObserver(){
this.preferences = await SPHelper.default.getPreferences();
this.preferences.on('change', this.observer);
... ...
... ... @@ -21,6 +21,7 @@ const TAG = 'PageComponent';
export struct PageComponent {
@State private pageModel: PageModel = new PageModel();
@State private pageAdvModel: PageAdModel = new PageAdModel();
@State timer: number = -1
navIndex: number = 0;
pageId: string = "";
channelId: string = "";
... ... @@ -29,6 +30,7 @@ export struct PageComponent {
@Prop @Watch('onAutoRefresh') autoRefresh: number = 0
private listScroller: Scroller = new Scroller();
needload: boolean = true;
build() {
Column() {
if (this.pageModel.viewType == ViewType.LOADING) {
... ... @@ -222,9 +224,10 @@ export struct PageComponent {
}
onChange() {
Logger.info(TAG, `onChangezz id: ${this.pageId} , ${this.channelId} , ${this.navIndex} , navIndex: ${this.currentTopNavSelectedIndex}`);
Logger.info(TAG,
`onChangezz id: ${this.pageId} , ${this.channelId} , ${this.navIndex} , navIndex: ${this.currentTopNavSelectedIndex}`);
if (this.navIndex === this.currentTopNavSelectedIndex) {
if(this.needload){
if (this.needload) {
this.getData();
}
this.needload = false;
... ... @@ -242,13 +245,19 @@ export struct PageComponent {
}
async getData() {
Logger.info(TAG, `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`);
this.pageModel.pageId = this.pageId;
this.pageModel.groupId = this.pageId;
this.pageModel.channelId = this.channelId;
this.pageModel.currentPage = 1;
this.pageModel.pageTotalCompSize = 0;
PageHelper.getInitData(this.pageModel, this.pageAdvModel)
if (this.timer) {
clearTimeout(this.timer)
}
this.timer = setTimeout(() => {
Logger.info(TAG, `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`);
this.pageModel.pageId = this.pageId;
this.pageModel.groupId = this.pageId;
this.pageModel.channelId = this.channelId;
this.pageModel.currentPage = 1;
this.pageModel.pageTotalCompSize = 0;
PageHelper.getInitData(this.pageModel, this.pageAdvModel)
}, 100)
}
}
... ...
... ... @@ -13,6 +13,7 @@ import {
PeopleShipUserDetailData,
ArticleCountData
} from 'wdBean'
import { EmptyComponent } from '../view/EmptyComponent'
@Entry
@Component
... ... @@ -35,65 +36,87 @@ struct PeopleShipHomePage {
@Provide @Watch('handleChangeAttentionStata') isLoadingAttention: boolean = false
//关注显示
@State attentionOpacity: boolean = false
@Provide topHeight: number = 400
@Provide topHeight: number = 286
@State isLoading: boolean = true
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
})
Stack({ alignContent: Alignment.TopStart }) {
// 顶部图片
Image($r('app.media.home_page_bg'))
.width('100%')
.height('120vp')
.objectFit(ImageFit.Fill)
.backgroundColor(Color.White)
.visibility(this.isLoading ? Visibility.None : Visibility.Visible)
Column(){
// 头部返回
PeopleShipHomePageNavComponent({
attentionOpacity: this.attentionOpacity,
topOpacity: this.topOpacity,
detailModel: this.detailModel
})
.height($r('app.float.top_bar_height'))
.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)
// 列表
Column(){
PeopleShipHomeListComponent({
publishCount: this.publishCount,
creatorId: this.creatorId
})
}.height('100%')
}
.width("100%")
.height(this.topHeight)
.justifyContent(FlexAlign.Start)
.alignItems(HorizontalAlign.Start)
// .height('100%')
// .height(this.publishCount == 0 ? '100%' : '')
}
.scrollable(ScrollDirection.Vertical)
// .alignSelf(ItemAlign.Start)
// .align(Alignment.Start)
.edgeEffect(EdgeEffect.None)
.friction(0.7)
.backgroundColor(Color.White)
.scrollBar(BarState.Off)
.width('100%')
.height('calc(100% - 44vp)')
// .layoutWeight(1)
.onDidScroll(() => {
// 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
}
Logger.debug('PeopleShipHomePage',`透明度:${this.topOpacity}`)
// 列表
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)
.alignItems(HorizontalAlign.Start)
.justifyContent(FlexAlign.Start)
.width('100%')
.height('100%')
.onDidScroll(() => {
// 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
}
Logger.debug('PeopleShipHomePage',`透明度:${this.topOpacity}`)
})
// .height('100%')
}
}
// .height('100%')
.width('100%')
}
... ... @@ -104,9 +127,11 @@ struct PeopleShipHomePage {
private async getData() {
try {
this.isLoading = true
// 获取页面信息
this.detailModel = await PeopleShipHomePageDataModel.getPeopleShipHomePageDetailInfo(this.creatorId, '', '')
Logger.debug('PeopleShipHomePage', '获取页面信息' + `${JSON.stringify(this.detailModel)}`)
this.isLoading = false
// 获取关注
// 登录后获取,是否关注
... ... @@ -117,7 +142,7 @@ struct PeopleShipHomePage {
}
} catch (exception) {
this.isLoading = false
}
}
... ...
import { insightIntent } from '@kit.IntentsKit';
import { BottomNavDTO, CompDTO, TopNavDTO } from 'wdBean';
import { SpConstants } from 'wdConstant';
import { DisplayUtils, LazyDataSource, Logger, NetworkUtil, SPHelper, ToastUtils } from 'wdKit';
... ... @@ -8,6 +9,7 @@ import { FirstTabTopSearchComponent } from '../search/FirstTabTopSearchComponent
import { AssignChannelParam } from 'wdRouter/src/main/ets/utils/HomeChannelUtils';
import { PeopleShipMainComponent } from '../peopleShip/PeopleShipMainComponent';
import { channelSkeleton } from '../skeleton/channelSkeleton';
import { common } from '@kit.AbilityKit';
const TAG = 'TopNavigationComponent';
... ... @@ -37,6 +39,7 @@ export struct TopNavigationComponent {
// 顶导当前选中/焦点下标
@State currentTopNavSelectedIndex: number = 0;
@State currentTopNavName: string = '';
@State currentTopNavItem: TopNavDTO = {} as TopNavDTO
// 顶导数据
@State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = []
@State compList: LazyDataSource<CompDTO> = new LazyDataSource();
... ... @@ -58,6 +61,8 @@ export struct TopNavigationComponent {
@Prop @Watch('onAutoRefresh') autoRefresh: number = 0
// 传递给page的自动刷新通知
@State autoRefresh2Page: number = 0
//保存当前导航选中时的时间戳 意图开始时间
@State executedStartTime: number = new Date().getTime()
// 当前底导index
@State navIndex: number = 0
@State animationDuration: number = 0
... ... @@ -167,6 +172,7 @@ export struct TopNavigationComponent {
this.currentTopNavSelectedIndex = index
this.currentTopNavName = this.myChannelList[index].name
}
this.currentTopNavItem = this.myChannelList[this.currentTopNavSelectedIndex]
}
isBroadcast(item: TopNavDTO) {
... ... @@ -184,6 +190,49 @@ export struct TopNavigationComponent {
return item.channelType === 3
}
//意图共享
topNavInsightIntentShare(item: TopNavDTO){
let tapNavIntent: insightIntent.InsightIntent = {
intentName: 'ViewColumn',
intentVersion: '1.0.1',
identifier: '52dac3b0-6520-4974-81e5-25f0879449b5',
intentActionInfo: {
actionMode: 'EXPECTED',
currentPercentage: 50,
executedTimeSlots: {
executedEndTime: new Date().getTime(),
executedStartTime: this.executedStartTime
}
},
intentEntityInfo: {
entityName: 'ViewColumn',
entityId: String(item.pageId) || '',
displayName: item.name,
logoURL: 'https://www-file.huawei.com/-/media/corporate/images/home/logo/huawei_logo.png',
rankingHint: 99,
isPublicData: true
}
}
try {
let context = getContext(this) as common.UIAbilityContext;
// 共享数据
insightIntent.shareIntent(context, [tapNavIntent], (error) => {
if (error?.code) {
// 处理业务逻辑错误
console.error(`shareIntent failed, error.code: ${error?.code}, error.message: ${error?.message}`);
return;
}
// 执行正常业务
console.log('shareIntent succeed');
});
} catch (error) {
// 处理异常
console.error(`error.code: ${error?.code}, error.message: ${error?.message}`);
}
}
build() {
Column() {
// 顶部搜索、日报logo、早晚报
... ... @@ -278,7 +327,11 @@ export struct TopNavigationComponent {
if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) &&
!this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])
) {
//在 tab 切换之前意图共享
// this.topNavInsightIntentShare(this.currentTopNavItem)
this.currentTopNavSelectedIndex = index;
this.currentTopNavItem = this.myChannelList[index]
}
if (this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])) {
// 跳转到播报页面
... ... @@ -416,9 +469,11 @@ export struct TopNavigationComponent {
this.changeByClick = true
this.tabsController.changeIndex(index)
}
})
}
aboutToAppear() {
//处理新闻tab顶导频道数据
this.topNavListHandle()
... ...
import { Logger, DisplayUtils} from 'wdKit'
import { Logger} from 'wdKit'
import { PeopleShipHomePageDataModel } from '../../viewmodel/PeopleShipHomePageDataModel'
import {
ContentDTO,
... ... @@ -16,11 +16,11 @@ import {
} 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 { CustomPullToRefresh } from '../reusable/CustomPullToRefresh'
import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData'
import LoadMoreLayout from '../page/LoadMoreLayout'
const TAG = 'PeopleShipHomeArticleListComponent';
... ... @@ -47,45 +47,29 @@ export struct PeopleShipHomeArticleListComponent {
} else if (this.viewType == 2) {
ErrorComponent()
} else {
CustomPullToRefresh({
alldata:this.arr,
scroller:this.scroller,
hasMore: this.hasMore,
customList:()=>{
this.ListLayout()
},
onRefresh:(resolve)=>{
this.currentPage = 1
this.getPeopleShipPageArticleList(resolve)
},
onLoadMore:(resolve)=> {
if (this.hasMore === false) {
if(resolve) {
resolve('')
}
return
}
if(!this.isLoading && this.hasMore){
//加载分页数据
this.currentPage++;
this.getPeopleShipPageArticleList(resolve)
}else {
if(resolve) {
resolve('')
}
}
},
})
this.ListLayout()
// CustomPullToRefresh({
// alldata:this.arr,
// scroller:this.scroller,
// hasMore: false,
// customList:()=>{
// this.ListLayout()
// },
// onRefresh:(resolve)=>{
// this.currentPage = 1
// this.getPeopleShipPageArticleList(resolve)
// },
// })
}
}
@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)
// 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
... ... @@ -93,7 +77,6 @@ export struct PeopleShipHomeArticleListComponent {
List({scroller: this.scroller}) {
// 下拉刷新
ForEach(this.arr, (item: ContentDTO) => {
ListItem() {
CardParser({ contentDTO: item })
... ... @@ -103,11 +86,14 @@ export struct PeopleShipHomeArticleListComponent {
// 加载更多
ListItem() {
if (!this.hasMore && !this.isLoading) {
if (this.hasMore && this.arr && this.arr.length > 0) {
LoadMoreLayout({ isVisible: this.hasMore })
} else if (!this.hasMore && !this.isLoading) {
PeopleShipNoMoreData()
}
}
}
.backgroundColor(Color.Transparent)
.width("100%")
.height("100%")
.edgeEffect(EdgeEffect.None)
... ... @@ -115,13 +101,13 @@ export struct PeopleShipHomeArticleListComponent {
scrollForward: NestedScrollMode.PARENT_FIRST,
scrollBackward: NestedScrollMode.SELF_FIRST
})
// .onReachEnd(() => {
// if(!this.isLoading && this.hasMore){
// //加载分页数据
// this.getPeopleShipPageArticleList()
// }
// })
.onReachEnd(() => {
if(!this.isLoading && this.hasMore){
//加载分页数据
this.currentPage++;
this.getPeopleShipPageArticleList()
}
})
}
aboutToAppear() {
... ... @@ -313,7 +299,6 @@ export struct PeopleShipHomeArticleListComponent {
}
}
// this.arr = listData.list
}
... ...
... ... @@ -24,10 +24,10 @@ export struct PeopleShipHomeListComponent {
// 列表
else if (this.publishCount == 0) {
// 无数据展示
EmptyComponent({emptyType: 12}).height(DisplayUtils.getDeviceHeight() - this.topHeight)
EmptyComponent({emptyType: 12}).height('100%')
} else {
Column() {
Column() {
Stack({ alignContent: Alignment.Top }){
// 页签
Row() {
Scroll() {
... ... @@ -44,54 +44,54 @@ export struct PeopleShipHomeListComponent {
.scrollBar(BarState.Off)
.width('100%')
}
.zIndex(10)
.backgroundColor(Color.White)
.height('44vp')
.alignItems(VerticalAlign.Bottom)
.width('100%')
}
.justifyContent(FlexAlign.Start)
.height('44vp')
.alignItems(HorizontalAlign.Start)
.width('100%')
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 ?? ''))
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.Tab(index, item.name ?? ''))
})
}
.backgroundColor(Color.White)
.barWidth('100%')
.vertical(false)
.barHeight('44vp')
.height('100% ')
.animationDuration(0)
.divider({
strokeWidth: '0.5vp',
color: $r('app.color.color_F5F5F5'),
startMargin: 0,
endMargin: 0
})
.onChange((index: number) => {
this.currentIndex = index
})
}
.backgroundColor(Color.White)
.barWidth('100%')
.barHeight(0)
.vertical(false)
.height(DisplayUtils.getDeviceHeight() - 144)
.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)
// CustomRefreshLoadLayout({
// refreshBean: new RefreshLayoutBean(true,
// $r('app.media.ic_pull_up_load'), $r('app.string.pull_up_load_text'), DisplayUtils.getDeviceHeight() - this.topHeight)
// }).height('100%')
}
// 单独的页签
... ...
... ... @@ -43,9 +43,8 @@ export struct PeopleShipHomePageNavComponent {
}).onClick(()=>{
let params = {
'headPhotoUrl': this.detailModel.headPhotoUrl,
'headType': '1'
} as Record<string, string>;
WDRouterRule.jumpWithPage(WDRouterPage.showUserHeaderPage,params)
WDRouterRule.jumpWithPage(WDRouterPage.showHomePageHeaderPage,params)
}).margin({
left: '10vp',
})
... ...
... ... @@ -56,9 +56,8 @@ export struct PeopleShipHomePageTopComponent {
}).onClick(() => {
let params = {
'headPhotoUrl': this.detailModel.headPhotoUrl,
'headType': '1'
} as Record<string, string>;
WDRouterRule.jumpWithPage(WDRouterPage.showUserHeaderPage, params)
WDRouterRule.jumpWithPage(WDRouterPage.showHomePageHeaderPage, params)
})
... ... @@ -369,7 +368,11 @@ export struct PeopleShipHomePageTopComponent {
private computeShowNum(count: number) {
if (count >= 10000) {
return `${(count / 10000).toFixed(1)}万`
let num = ( count / 10000).toFixed(1)
if (Number(num.substring(num.length-1)) == 0) {
num = num.substring(0, num.length-2)
}
return num + '万'
}
return `${count}`
}
... ...
... ... @@ -12,6 +12,7 @@ import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData';
import { HttpUtils } from 'wdNetwork/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter'
import { LazyDataSource } from 'wdKit/Index';
import LoadMoreLayout from '../page/LoadMoreLayout'
const TAG: string = 'ReserveMorePage';
... ... @@ -95,7 +96,9 @@ struct ReserveMorePage {
)
// 加载更多
ListItem() {
if (!this.hasMore && !this.isLoading) {
if (this.hasMore && this.data && this.data.totalCount() > 0) {
LoadMoreLayout({ isVisible: this.hasMore })
} else if (!this.hasMore && !this.isLoading) {
PeopleShipNoMoreData()
}
}
... ... @@ -104,7 +107,7 @@ struct ReserveMorePage {
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.backgroundColor('#F5F5F5')
.layoutWeight(1)
.height('calc(100% - 44vp)')
.onReachEnd(() => {
Logger.debug(TAG, "触底了");
if(!this.isLoading && this.hasMore){
... ... @@ -124,7 +127,7 @@ struct ReserveMorePage {
buildItem(item: ContentDTO, index: number) {
Column() {
Stack() {
Image(item.fullColumnImgUrls[0].url)
Image(item.fullColumnImgUrls[0]?.url)
.width('100%')
.height(196)
.borderRadius(4)
... ... @@ -136,64 +139,49 @@ struct ReserveMorePage {
Text(item.newsTitle)
.fontSize(17)
.maxLines(2)
.lineHeight(25)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 16, left: 12, right: 12 })
.margin({ top: 4, left: 12, right: 12 })
.alignSelf(ItemAlign.Start)
Row() {
Row() {
Image($r('app.media.reserve_play_icon'))
.width(20)
.height(20)
.margin({ left: 10, top: 2, bottom: 2, right: 6 })
// Text(DateTimeUtils.formatDate(item.liveInfo.liveStartTime, "MM月dd日 HH:mm"))
Text(this.getReserveDate(item.liveInfo.liveStartTime, 1))
.fontSize(12)
.fontWeight(500)
.fontColor('#ED2800')
.fontFamily('PingFang SC-Medium')
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 8, bottom: 8 })
.align(Alignment.Start)
Image($r('app.media.point_icon'))
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
.width(6)
.height(16)
.margin(2)
Text(this.getReserveDate(item.liveInfo.liveStartTime, 2))
.fontSize(12)
.fontWeight(500)
.fontColor('#ED2800')
.fontFamily('PingFang SC-Medium')
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 8, bottom: 8, right: 10 })
.align(Alignment.Start)
if (item.liveInfo && item.liveInfo.liveStartTime) {
Row() {
Image($r('app.media.reserve_play_icon'))
.width(20)
.height(20)
.margin({ left: 10, top: 2, bottom: 2, right: 6 })
Text(this.getReserveDate(item.liveInfo.liveStartTime, 1))
.fontSize(12)
.fontWeight(500)
.fontColor('#ED2800')
.fontFamily('PingFang SC-Medium')
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 8, bottom: 8 })
.align(Alignment.Start)
Image($r('app.media.point_icon'))
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
.width(6)
.height(16)
.margin(2)
Text(this.getReserveDate(item.liveInfo.liveStartTime, 2))
.fontSize(12)
.fontWeight(500)
.fontColor('#ED2800')
.fontFamily('PingFang SC-Medium')
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 8, bottom: 8, right: 10 })
.align(Alignment.Start)
}
.backgroundColor('#F5F5F5')
.margin(12)
}
.backgroundColor('#F5F5F5')
.margin(12)
// Flex({ justifyContent: FlexAlign.Center }) {
// Text(this.isAppointmentLive ? '已预约' : '预约')
// .fontSize(12)
// .fontWeight(400)
// .fontFamily('PingFang SC-Regular')
// .width(52)
// .height(24)
// .fontColor(Color.White)
// .textAlign(TextAlign.Center)
// .onClick(() => {
// this.liveAppointment(item)
// })
// }
// .width(52)
// .backgroundColor('#ED2800')
// .borderRadius(3)
// ReserveMoreAttentionComponent({reserveItem: this.getAttentionItem(item), })
// .margin({ right: 12 })
// 预约
Row() {
LoadingProgress()
.width(20)
... ... @@ -201,7 +189,7 @@ struct ReserveMorePage {
.color(!this.isReserved(item) ? $r('app.color.color_fff') : $r('app.color.color_CCCCCC'))
.visibility((this.isLoadingAttention && this.liveId == item.objectId) ? Visibility.Visible : Visibility.None)
Text(!this.isReserved(item) ? '关注' : '已关注')
Text(!this.isReserved(item) ? '预约' : '已预约')
.fontSize($r('app.float.vp_12'))
.fontWeight(500)
.fontColor(!this.isReserved(item) ? $r('app.color.color_fff') : $r('app.color.color_CCCCCC'))
... ... @@ -253,6 +241,9 @@ struct ReserveMorePage {
.height(24)
.objectFit(ImageFit.Auto)
.id("back_icon")
.margin({
left: '16vp'
})
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
left: { anchor: "__container__", align: HorizontalAlign.Start }
... ... @@ -264,10 +255,10 @@ struct ReserveMorePage {
Text(this.title)// .height('42lpx')
.maxLines(1)
.id("title")
.fontSize('35lpx')
.fontSize('18vp')
.fontWeight(400)
.fontColor($r('app.color.color_222222'))
.lineHeight('42lpx')
.lineHeight('22vp')
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
... ... @@ -281,11 +272,14 @@ struct ReserveMorePage {
@Builder
LiveImage() {
Row() {
Image($r('app.media.reserve_icon'))
.width(22)
.height(18)
Image($r('app.media.reserve_new_icon'))
.width(14)
.height(14)
.margin({
right: 3
})
Text('预约')
.fontSize('11fp')
.fontSize('12vp')
.fontWeight(400)
.fontColor(Color.White)
}
... ... @@ -511,9 +505,5 @@ struct ReserveMorePage {
}
}
async liveAppointment(item: ContentDTO) {
const liveDetail = await LiveModel.liveAppointment(item?.relId || '', item?.objectId || '', this.isAppointmentLive || false)
}
}
\ No newline at end of file
... ...
... ... @@ -131,10 +131,8 @@ export struct SearchResultComponent {
.barWidth('100%')
.barHeight('84lpx')
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.width('100%')
.scrollable(false)
.layoutWeight(1)
}
}.width('100%')
... ...
... ... @@ -15,7 +15,7 @@ export struct CustomBottomFuctionUI {
.height('20')
.margin({right:'31lpx' })
Text(this.isAllSelect?'取消':'全选')
Text(this.isAllSelect?'取消全选':'全选')
.fontColor($r('app.color.color_222222'))
.backgroundColor(Color.White)
}
... ...
... ... @@ -22,7 +22,7 @@ export struct LikeComponent {
@Prop data: Record<string, string>
enableBtn = true
componentType: number = 1 //1: 底部栏目样式 2: 新闻页中间位置样式 3:动态Tab内容下的互动入口
styleType: number = 1 //1: 白色背景(图文底部栏) 2: 黑色背景(图集底部栏)
styleType: number = 1 //1: 白色背景(图文底部栏) 2: 黑色背景(图集底部栏) 3 透明背景
@State likeCount: number = 0 //点赞数
//上层传值 样例
... ... @@ -41,7 +41,6 @@ export struct LikeComponent {
//获取点赞数
this.getLikeCount()
}
}
build() {
... ... @@ -50,11 +49,15 @@ export struct LikeComponent {
//2: 新闻页中间位置样式
this.likeCompStyle2()
} else if (this.componentType == 3) {
//卡片底部互动样式
this.likeCompStyle3()
} else if (this.componentType == 4) {
// 直播,点赞按钮底测有灰色圆角背景+右上点赞数量
this.likeCompStyle4()
} else {
} else if (this.componentType == 5) {
// 图集点赞,展示标识
this.likeCompStyle5()
}else {
//1: 底部栏目样式 默认样式
this.likeCompStyle1()
}
... ... @@ -67,7 +70,7 @@ export struct LikeComponent {
if (this.likesStyle === 1) {
return {
url: this.likeStatus ? $r(`app.media.ic_like_check`) :
this.styleType == 1 ? $r('app.media.icon_like_default') : $r(`app.media.ic_like_uncheck`),
this.styleType == 1 ? this.componentType == 3?$r(`app.media.CarderInteraction_like`):$r('app.media.icon_like_default') : $r(`app.media.ic_like_uncheck`),
name: '赞'
}
} else if (this.likesStyle === 2) {
... ... @@ -133,8 +136,8 @@ export struct LikeComponent {
Image(this.transLikeStyle().url)
.width(18)
.height(18)
// Text(this.likeStatus ? '已赞' : '点赞')
Text(this.likeCount > 0 ? this.likeCount.toString() : '点赞')
Text(this.likeStatus ? '已赞' : '点赞')
// Text(this.likeCount > 0 ? this.likeCount.toString() : '点赞')
.margin({ left: 4 })
.fontSize(14)
.fontColor(this.likeStatus ? '#ED2800' : '#666666')
... ... @@ -160,6 +163,36 @@ export struct LikeComponent {
}
@Builder
likeCompStyle5() {
//1: 底部栏目样式 默认样式
Stack({ alignContent: Alignment.Bottom }) {
Column() {
// Image(this.likeStatus ? $r('app.media.icon_like_select') : $r('app.media.icon_like_default'))
Image(this.transLikeStyle().url)
.width(24)
.height(24)
.onClick(() => {
this.clickButtonEvent()
})
}
Row() {
Text(NumberFormatterUtils.formatNumberWithWan(this.likeCount || ''))
.fontSize(8)
.fontColor(Color.White)
.padding({ left: 4, right: 2 })
}
.height(12)
.alignItems(VerticalAlign.Center)
.position({ x: '100%', })
.markAnchor({ x: '100%' })
.backgroundImage(this.likeStatus? $r('app.media.ic_like_back_Select'):$r('app.media.ic_like_back'))
.backgroundImageSize(ImageSize.Auto)
.visibility(this.likeCount > 0 ? Visibility.Visible : Visibility.Hidden)
}.width(24).height(24)
}
@Builder
likeCompStyle4() {
Stack({ alignContent: Alignment.Bottom }) {
Column() {
... ...
... ... @@ -59,6 +59,7 @@ export struct OperRowListView {
* 7:图集详情页
*/
@Prop componentType: number = 1 //1: 底部栏目样式 2: 新闻页中间位置样式 3:动态Tab内容下的互动入口
@Prop pageComponentType: number = -1 //1:视频详情页
@State likesStyle: number = this.contentDetailData.likesStyle // 赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空
@State operationButtonList: string[] = ['comment', 'collect', 'share'] // 组件展示条件
@State needLike: boolean = true
... ... @@ -115,6 +116,8 @@ export struct OperRowListView {
}
build() {
// 视频详情页
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
// AudioDialog()
Row() {
... ... @@ -162,6 +165,7 @@ export struct OperRowListView {
bottom: `${this.bottomSafeHeight}px`
// bottom: 50
})
}
/**
... ... @@ -174,12 +178,16 @@ export struct OperRowListView {
CommentTabComponent({
publishCommentModel: this.publishCommentModel,
contentDetail: this.contentDetailData,
onCommentFocus: this.onCommentFocus
onCommentFocus: this.onCommentFocus,
pageComponentType: this.pageComponentType
})
}
}
.flexShrink(1)
.layoutWeight(1)
.margin({
right: this.pageComponentType === 1 ? 16 : 0,
})
if (this.showCommentIcon) {
Column() {
if (this.publishCommentModel?.targetId) {
... ... @@ -330,6 +338,8 @@ export struct OperRowListView {
contentList: [{
contentId: this.contentDetailData?.newsId + '',
contentType: this.contentDetailData?.newsType + '',
relType:this.contentDetailData?.reLInfo?.relType + '',
contentRelId:this.contentDetailData?.reLInfo?.relId + '',
}],
}
... ...
... ... @@ -2,6 +2,8 @@ import { Action, NewspaperListBean, NewspaperListItemBean, NewspaperPositionItem
import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO'
import { WDRouterRule } from 'wdRouter/Index'
import { ENewspaperPageDialog } from '../dialog/ENewspaperPageDialog'
import { Logger } from 'wdKit';
import { window } from '@kit.ArkUI';
/**
* 读报纸半屏弹窗
... ... @@ -35,6 +37,12 @@ export struct ENewspaperListDialog {
// listDialogController: CustomDialogController
public closeDialog?: () => void
// 手势滑动相关
private panOption: PanGestureOptions = new PanGestureOptions({ direction: PanDirection.Up | PanDirection.Down })
private topFixedHeight = 124
@State topHeight: number = 124
private deviceHeight: number = 0
//watch监听报纸页码回调
onCurrentPageNumUpdated(): void {
console.log("ENewspaperListDialog-onCurrentPageNumUpdated", "currentPageNum:", this.currentPageNum)
... ... @@ -46,7 +54,13 @@ export struct ENewspaperListDialog {
}
}
aboutToAppear(): void {
async aboutToAppear() {
// 屏幕高度 - 滑动高度计算
let windowClass: window.Window = await window.getLastWindow(getContext(this));
let changeHeight = 85 + 44 + px2vp(windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM).topRect.height)
changeHeight += px2vp(windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM).bottomRect.height)
this.deviceHeight = px2vp(windowClass.getWindowProperties().windowRect.height) - changeHeight
this.isCurrentViewOpen = true
console.log("ENewspaperListDialog-aboutToAppear", "currentPageNum:", this.currentPageNum)
let _scrollIndex = Number.parseInt(this.currentPageNum)
... ... @@ -56,60 +70,76 @@ export struct ENewspaperListDialog {
}
aboutToDisappear() {
// if (this.pageListDialogController) {
// this.pageListDialogController = null
// }
this.isCurrentViewOpen = false
}
build() {
Stack() {
Column() {
Row()
.width(43)
.height(4)
.backgroundColor('#EDEDED')
.margin({
top: 10,
bottom: 10
})
Column() {
Row()
.width(43)
.height(4)
.backgroundColor('#EDEDED')
.margin({
top: 10,
bottom: 10
})
.onClick(() => {
if (this.closeDialog) {
this.closeDialog()
}
})
Row() {
Text(this.currentPageNum)
.fontSize($r('app.float.font_size_36'))
.fontColor($r('app.color.color_222222'))
.fontFamily('BebasNeueBold')
Text('版')
.fontSize($r('app.float.font_size_16'))
.fontColor($r('app.color.color_222222'))
.margin({ bottom: 6 })
Image($r('app.media.icon_triangle_black'))
.width($r('app.float.border_radius_6'))
.height($r('app.float.border_radius_6'))
.margin({ left: 2, bottom: 6 })
}
.alignItems(VerticalAlign.Bottom)
.margin({ left: 15 })
.alignSelf(ItemAlign.Start)
.onClick(() => {
if (this.closeDialog) {
this.closeDialog()
this.pageDialogShow = !this.pageDialogShow
if (this.pageDialogShow) {
this.pageListDialogController.open()
} else {
this.pageListDialogController.close()
}
})
Row() {
Text(this.currentPageNum)
.fontSize($r('app.float.font_size_36'))
.fontColor($r('app.color.color_222222'))
.fontFamily('BebasNeueBold')
Text('版')
.fontSize($r('app.float.font_size_16'))
.fontColor($r('app.color.color_222222'))
.margin({ bottom: 6 })
Image($r('app.media.icon_triangle_black'))
.width($r('app.float.border_radius_6'))
.height($r('app.float.border_radius_6'))
.margin({ left: 2, bottom: 6 })
Image($r('app.media.line'))
.width('100%')
.height(6)
.margin({ top: 20, left: 16, right: 16 })
.objectFit(ImageFit.Contain)
}
.alignItems(VerticalAlign.Bottom)
.margin({ left: 15 })
.alignSelf(ItemAlign.Start)
.onClick(() => {
this.pageDialogShow = !this.pageDialogShow
if (this.pageDialogShow) {
this.pageListDialogController.open()
} else {
this.pageListDialogController.close()
}
})
.width('100%')
.gesture(
PanGesture(this.panOption)
.onActionStart((event: GestureEvent) => {
Logger.debug('ENewspaperListDialog','Pan start')
})
.onActionUpdate((event: GestureEvent) => {
if (this.topFixedHeight + event.offsetY >= this.topFixedHeight) {
this.topHeight = this.topFixedHeight + event.offsetY
}
Logger.debug('ENewspaperListDialog', 'topHeight:' + this.topHeight)
})
.onActionEnd(() => {
this.onCloseGestureDialog()
})
)
Image($r('app.media.line'))
.width('100%')
.height(6)
.margin({ top: 20, left: 16, right: 16 })
.objectFit(ImageFit.Contain)
List({ scroller: this.listScroller, initialIndex: this.scrollIndex }) {
ForEach(this.newspaperListBean?.list, (item: NewspaperListItemBean, index: number) => {
... ... @@ -137,7 +167,7 @@ export struct ENewspaperListDialog {
.fontSize($r('app.float.font_size_14'))
.fontColor($r('app.color.color_222222'))
.fontWeight(600)
.maxLines(2)
// .maxLines(2)
.margin({
bottom: 8
})
... ... @@ -151,7 +181,7 @@ export struct ENewspaperListDialog {
.margin({
bottom: 8
})
.maxLines(2)
// .maxLines(2)
}
if (positionItem.downTitle) {
... ... @@ -162,7 +192,7 @@ export struct ENewspaperListDialog {
.margin({
bottom: 8
})
.maxLines(2)
// .maxLines(2)
}
if (positionItem.newsTxt) {
Text(positionItem.newsTxt)
... ... @@ -251,16 +281,13 @@ export struct ENewspaperListDialog {
this.currentPageNum = `${firstIndex < 9 ? '0' + (firstIndex + 1) : firstIndex + 1}`
// }
})
.onScroll((scrollOffset: number, scrollState: ScrollState) => {
// console.info(`onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + scrollOffset)
// if (this.scrollOffset == 0) {
// this.scrollOffset = 0
// }
})
}
.margin({ top: 124 })
// .margin({ top: 124 })
.margin({ top: this.topHeight })
.width('100%')
.backgroundColor(Color.White)
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
.onClick(() => {
})
... ... @@ -272,6 +299,33 @@ export struct ENewspaperListDialog {
this.closeDialog()
}
})
.gesture(
PanGesture(this.panOption)
.onActionStart((event: GestureEvent) => {
Logger.debug('ENewspaperListDialog','Pan start')
})
.onActionUpdate((event: GestureEvent) => {
if (event) {
if (this.topFixedHeight + event.offsetY >= this.topFixedHeight) {
this.topHeight = this.topFixedHeight + event.offsetY
}
Logger.debug('ENewspaperListDialog', 'topHeight:' + this.topHeight)
}
})
.onActionEnd(() => {
this.onCloseGestureDialog()
})
)
}
onCloseGestureDialog() {
if (this.topHeight >= this.deviceHeight ) {
if (this.closeDialog) {
this.closeDialog()
}
} else {
this.topHeight = this.topFixedHeight
}
}
updateRecordsData() {
... ...
/**
* WDMessageCenterMessageType 拉取消息类型
*/
export const enum WDMessageCenterMessageType {
WDMessageCenterMessageType_Interact = 1, //互动通知
WDMessageCenterMessageType_Subscribe = 2, //预约消息
WDMessageCenterMessageType_System, //系统消息
}
export interface InteractMessageListModel{
data: InteractMessageMItem
code: number
message: string
success: string
timestamp: number
}
export class InteractMessageMItem{
pageNum:number = 0
pageSize:number = 0
totalCount:number = 0
hasNext:number = 0
list:InteractMessageModel[] = []
constructor(list?:InteractMessageModel[],pageNum?: number,pageSize?: number,totalCount?: number,hasNext?:number) {
}
}
export class InteractMessageModel {
classify: string = '';
contentId: string = '';
contentType: string = '';
id: number = 0;
message: string = '';
platform: string = '';
privateMailId: number = 0;
privateMailIdList: number[] = [];
privateMailIds: string = '';
privateMailNum: number = 0;
read: boolean = true;
source: string = '';
time: string = '';
title: string = '';
userId: string = '';
remark: string = '';
InteractMsubM:InteractMsubModel = new InteractMsubModel;
}
export class InteractMsubModel {
beReply: string = '';
headUrl: string = '';
contentId: string = '';
contentRelObjectid: string = '';
contentTitle: string = '';
commentContent: string = '';
userName: string = '';
userId: string = '';
contentRelId: string = '';
shareUrl: string = '';
userType: string = '';
contentRelType: string = '';
visitor: string = '';
contentType: string = '';
}
export interface InteractMParams {
contentType?: string;
pageNum?: string;
pageSize?: string;
userId?: string;
createTime?: string;
}
export interface InteractMDTO{
success: boolean;
code: number;
message: string;
data: number;
timestamp?: number;
}
@Observed
export class SubscribeMessageModel{
dealTime:string = ""
title:string = ""
imgUrl:string = ""
desc:string = ""
time:string = ""
contentId:string = ""
constructor(dealTime: string, title: string, imgUrl: string, desc: string , time: string, contentId: string) {
this.dealTime = dealTime
this.title = title
this.imgUrl = imgUrl
this.desc = desc
this.time = time
this.contentId = contentId
}
}
export class Remark{
relationType:string = ""
coverImageUrl:string = ""
relationId:string = ""
status:string = ""
}
\ No newline at end of file
... ...
... ... @@ -24,6 +24,10 @@ import { CommentLikeOperationRequestItem } from '../viewmodel/CommentLikeOperati
import { FollowOperationRequestItem } from '../viewmodel/FollowOperationRequestItem';
import { SpConstants } from 'wdConstant/Index';
import { MessageItem } from '../viewmodel/MessageItem';
import { MessageUnReadItem } from '../viewmodel/MessageUnReadItem';
import { HistoryPushDataItem } from '../viewmodel/HistoryPushDataItem';
import { HashMap } from '@kit.ArkTS';
import { InteractMessageMItem } from './InteractMessageModel';
const TAG = "MinePageDatasModel"
... ... @@ -597,6 +601,106 @@ class MinePageDatasModel{
})
})
}
/**
* 获取消息未读数据
* @returns
*/
getMessageUnReadData(): Promise<MessageUnReadItem> {
return new Promise<MessageUnReadItem>((success, error) => {
this.fetchMessageUnReadData().then((navResDTO: ResponseDTO<MessageUnReadItem>) => {
if (!navResDTO || navResDTO.code != 0) {
error(null)
return
}
let navigationBean = navResDTO.data as MessageUnReadItem
success(navigationBean);
}).catch((err: Error) => {
error(null)
})
})
}
fetchMessageUnReadData() {
let url = HttpUrlUtils.getMessageUnReadDataUrl()
return WDHttp.get<ResponseDTO<MessageUnReadItem>>(url)
};
/**
* 点击消息(进入消息页面)
* @returns
*/
sendClickMessageData(): Promise<String> {
return new Promise<String>((success, error) => {
this.fetchClickMessageData().then((navResDTO: ResponseDTO<String>) => {
if (!navResDTO || navResDTO.code != 0) {
error(null)
return
}
success("1");
}).catch((err: Error) => {
error(err)
})
})
}
fetchClickMessageData() {
let url = HttpUrlUtils.getSendClickMessageUrl()
return WDHttp.get<ResponseDTO<String>>(url)
};
/**
* 历史推送消息
* @returns
*/
getHistoryPushData(pageSize:string,pageNum:string): Promise<HistoryPushDataItem> {
return new Promise<HistoryPushDataItem>((success, error) => {
this.fetchHistoryPushData(pageSize,pageNum).then((navResDTO: ResponseDTO<HistoryPushDataItem>) => {
if (!navResDTO || navResDTO.code != 0) {
error(null)
return
}
let navigationBean = navResDTO.data as HistoryPushDataItem
success(navigationBean);
}).catch((err: Error) => {
error(err)
})
})
}
fetchHistoryPushData(pageSize:string,pageNum:string) {
let url = HttpUrlUtils.getHistoryPushUrl()+ `?pageSize=${pageSize}&pageNum=${pageNum}`
let headers: HashMap<string, string> = new HashMap<string, string>();
headers.set('system', 'Android');
return WDHttp.get<ResponseDTO<HistoryPushDataItem>>(url, headers)
};
/**
* 推送消息
* @returns
*/
getSubscribeMessageData(contentType:number,pageSize:string,pageNum:string): Promise<InteractMessageMItem> {
return new Promise<InteractMessageMItem>((success, error) => {
this.fetchSubscribeMessageData(contentType,pageSize,pageNum).then((navResDTO: ResponseDTO<InteractMessageMItem>) => {
if (!navResDTO || navResDTO.code != 0) {
error(null)
return
}
let navigationBean = navResDTO.data as InteractMessageMItem
success(navigationBean);
}).catch((err: Error) => {
error(err)
})
})
}
fetchSubscribeMessageData(contentType:number,pageSize:string,pageNum:string) {
let userID = HttpUtils.getUserId();
let url = HttpUrlUtils.getMessageListDataUrl()+`?createTime=${''}&contentType=${contentType}&userId=${userID}&pageSize=${pageSize}&pageNum=${pageNum}`
return WDHttp.get<ResponseDTO<InteractMessageMItem>>(url)
};
}
const minePageDatasModel = MinePageDatasModel.getInstance()
... ...
... ... @@ -43,7 +43,6 @@ export interface MyCollectionListModel{
}
export interface contentListItemParams{
contentId?:string;
contentType?:string;
... ...
... ... @@ -8,5 +8,6 @@ struct SearchPage {
SearchComponent()
}.height('100%')
.width('100%')
.backgroundColor($r('app.color.white'))
}
}
\ No newline at end of file
... ...
import { router } from '@kit.ArkUI';
@Entry
@Component
struct ShowHomePageHeaderPage {
@State headPhotoUrl: string = '';
@State params:Record<string, string> = router.getParams() as Record<string, string>;
onPageShow() {
this.headPhotoUrl = this.params?.['headPhotoUrl'];
}
build() {
Row() {
Image(this.headPhotoUrl)
.alt( $r('app.media.WDAccountOwnerHedaerDefaultIcon') )
.width('100%')
.objectFit(ImageFit.Contain)
}
.width('100%')
.height('100%')
.alignItems(VerticalAlign.Center)
.backgroundColor($r('app.color.color_000000'))
.onClick(()=>{
router.back()
})
}
}
\ No newline at end of file
... ...
... ... @@ -4,18 +4,16 @@ import { router } from '@kit.ArkUI';
@Component
struct ShowUserHeaderPage {
@State headPhotoUrl: string = '';
@State headType: string = ''
@State params:Record<string, string> = router.getParams() as Record<string, string>;
onPageShow() {
this.headPhotoUrl = this.params?.['headPhotoUrl'];
this.headType = this.params?.['headType'] ?? '';
}
build() {
Row() {
Image(this.headPhotoUrl)
.alt(this.headType.length > 0 ? $r('app.media.WDAccountOwnerHedaerDefaultIcon') : $r('app.media.default_head'))
.alt($r('app.media.default_head'))
.width('720lpx')
.height('720lpx')
.objectFit(ImageFit.Auto)
... ...
import { SubscribeMessageComponent } from '../components/mine/message/subscribe/SubscribeMessageComponent'
//预约消息 页面
@Entry
@Component
struct SubscribeMessagePage {
build() {
Column(){
SubscribeMessageComponent()
}
}
}
\ No newline at end of file
... ...
... ... @@ -24,7 +24,8 @@ import {
postInteractAccentionOperateParams,
postRecommendListParams,
GoldenPositionExtraBean,
FeedbackTypeBean
FeedbackTypeBean,
LiveRoomDataBean
} from 'wdBean';
import { PageUIReqBean } from '../components/page/bean/PageUIReqBean';
import { ArrayList } from '@kit.ArkTS';
... ... @@ -470,4 +471,13 @@ export class PageRepository {
url = url + "?dictCode=" + "CN_OPINION_TYPE";
return WDHttp.get<ResponseDTO<FeedbackTypeBean[]>>(url)
};
/**
* 获取更多直播间人数
* */
static fetchLiveRoomBatchAllUrl(ids: string) {
let url = HttpUrlUtils.getLiveRoomBatchAllDataUrl()
url = url + "?liveIdList=" + ids;
return WDHttp.get<ResponseDTO<LiveRoomDataBean[]>>(url)
};
}
... ...
export class HistoryPushDataItem{
hasNext: number = 0
list: Array< HistoryPushItem > = []
pageNum: number = 0
pageSize: number = 0
totalCount: number = 0
}
export class HistoryPushItem{
activityExt?: null
appStyle: string = ""
askInfo?: null
axisColor: string = ""
bestNoticer?: null
bottomNavId?: null
cardItemId: string = ""
channelId: number= 0
commentInfo?: null
corner: string = ""
coverSize: string = ""
coverType?: number
coverUrl: string = ""
expIds: string = ""
extra: string = ""
fullColumnImgUrls: Array< FullColumnImgUrl > = []
hasMore?: null
itemId: string = ""
itemType: string = ""
itemTypeCode: string = ""
keyArticle: number= 0
landscape?: null
likeStyle?: null
linkUrl: string = ""
liveInfo?: null
menuShow: number = 0
newTags: string = ""
newsAuthor: string = ""
newsSubTitle: string = ""
newsSummary: string = ""
newsTitle: string = ""
newsTitleColor: string = ""
objectId: string = ""
objectLevel: string = ""
objectType: string = ""
openComment?: null
openLikes?: null
pageId: string = ""
photoNum?: null
position?: null
productNum?: null
publishTime: string = ""
pushTime: number = 0
pushUnqueId: number = 0
readFlag: number = 0
recommend?: null
relId: number = 0
relObjectId: string = ""
relType: number = 0
rmhInfo?: null
rmhPlatform: number = 0
sceneId: string = ""
shareInfo?: null
// slideShows: Array< unknown >
sortValue?: null
source: string = ""
subObjectType: string = ""
subSceneId: string = ""
// tagIds: Array< unknown >
tagWord?: null
titleShow?: null
titleShowPolicy?: null
topicTemplate?: null
traceId: string = ""
traceInfo: string = ""
userInfo?: null
videoInfo?: null
visitorComment: number = 0
voiceInfo?: null
}
export class FullColumnImgUrl{
}
\ No newline at end of file
... ...
// import { collcetRecordParams, MyCollectionItem, MyCollectionListModel } from '../model/MyCollectionModel';
import { HttpUrlUtils, HttpUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { Logger } from 'wdKit';
import promptAction from '@ohos.promptAction';
import {
InteractMDTO,
InteractMessageListModel, InteractMessageMItem, InteractMParams } from '../model/InteractMessageModel';
const TAG = "MyCollectionViewModel"
class InteractMessageViewModel {
private static instance:InteractMessageViewModel
/**
* 单例模式
* @returns
*/
public static getInstance(): InteractMessageViewModel {
if (!InteractMessageViewModel.instance) {
InteractMessageViewModel.instance = new InteractMessageViewModel();
}
return InteractMessageViewModel.instance;
}
// ///互动通知
// WDMessageCenterMessageType_Interact = 1,
//
// ///预约消息
// WDMessageCenterMessageType_Subscribe = 2,
//
// ///系统消息
// WDMessageCenterMessageType_System = 3
BaseGetRequest(contentType:number,pageNum:number){
let userID = HttpUtils.getUserId();
let url = HttpUrlUtils.getMessageListDataUrl()+`?contentType=${contentType}&userId=${userID}&pageSize=${20}&pageNum=${pageNum}`
return WDHttp.get<InteractMessageListModel>(url)
}
fetchMessageList(contentType:number,pageNum:number):Promise<InteractMessageMItem>{
return new Promise((success,error) => {
this.BaseGetRequest(contentType,pageNum).then((navResDTO: InteractMessageListModel) => {
if (!navResDTO || navResDTO.code != 0) {
return
}
Logger.info(TAG, "fetchMessageList then,navResDTO.timeStamp:" + navResDTO.timestamp);
success(navResDTO.data)
}).catch((err: Error) => {
Logger.error(TAG, `fetchMessageList catch, error.name : ${err.name}, error.message:${err.message}`);
error("page data invalid");
})
})
}
getMessageLikeCount():Promise<number>{
return new Promise((success,error) => {
WDHttp.get<InteractMDTO>(HttpUrlUtils.getMessageLikeCount()).then((navResDTO: InteractMDTO) => {
if (navResDTO.code == 0) {
success(navResDTO.data)
}
})
.catch((error: Error) => {
Logger.info(TAG,'executeCollcet','ResponseDTO')
})
})
}
}
const interactMViewModel = InteractMessageViewModel.getInstance();
export default interactMViewModel as InteractMessageViewModel
\ No newline at end of file
... ...
@Observed
export class MessageItem{
imgSrc:Resource = $r("app.media.xxhdpi_pic_wb")
title:string = ""
desc:string = ""
time:string = ""
unReadCount:number = 0
constructor(imgSrc:Resource,title:string,desc:string,time:string){
this.imgSrc = imgSrc
... ...
export class MessageUnReadItem{
activeCount: number = 0 //互动通知未读数
subscribeCount: number = 0 //预约消息未读数
systemCount: number = 0 //系统通知未读数
subscribeInfo: SubscribeInfo = new SubscribeInfo()
systemInfo: SystemInfo = new SystemInfo()
activeInfo: ActiveInfo = new ActiveInfo
}
class SubscribeInfo{
classify: string = ""
contentId: string = ""
contentType: string = ""
id: number = -1
message: string = ""
platform: string = ""
privateMailId: number = -1
privateMailIdList: Array< string > = []
privateMailIds: string = ""
privateMailNum: number = -1
read: boolean = false
source: string = ""
time: string = ""
title: string = ""
userId: number = -1
remark: string = ""
}
class SystemInfo{
classify: string = ""
contentType: string = ""
id: number = -1
message: string = ""
platform: string = ""
privateMailId: number = -1
privateMailIdList: Array< string > = []
privateMailIds: string = ""
privateMailNum: number = -1
read: boolean = false
source: string = ""
time: string = ""
title: string = ""
userId: number = -1
}
class ActiveInfo{
id:string = ""
message: string = ""
time: string = ""
title: string = ""
}
\ No newline at end of file
... ...
import FunctionsItem from './FunctionsItem'
@Observed
export default class MinePagePersonalFunctionsItem extends FunctionsItem {
isShowRedPoint:boolean = false
}
\ No newline at end of file
... ...
... ... @@ -10,7 +10,8 @@ import {
PageInfoBean,
PageInfoDTO,
GoldenPositionExtraBean,
NavigationDetailDTO
NavigationDetailDTO,
LiveRoomDataBean
} from 'wdBean';
import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit';
... ... @@ -439,6 +440,31 @@ export class PageViewModel extends BaseViewModel {
})
})
}
async getLiveRoomBatchInfo(ids: string): Promise<LiveRoomDataBean[]> {
return new Promise<LiveRoomDataBean[]>((success, error) => {
Logger.info(TAG, `getLiveRoomBatchInfo pageInfo start`);
PageRepository.fetchLiveRoomBatchAllUrl(ids).then((resDTO: ResponseDTO<LiveRoomDataBean[]>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'getLiveRoomBatchInfo then navResDTO is empty');
error('resDTO is empty');
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `getLiveRoomBatchInfo then code:${resDTO.code}, message:${resDTO.message}`);
error('resDTO Response Code is failure');
return
}
// let navResStr = JSON.stringify(navResDTO);
Logger.info(TAG, "getLiveRoomBatchInfo then,navResDTO.timestamp:" + resDTO.timestamp);
success(resDTO.data);
}).catch((err: Error) => {
Logger.error(TAG, `getLiveRoomBatchInfo catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
}
... ...
... ... @@ -24,6 +24,8 @@
"components/page/ThemeListPage",
"pages/ShowUserHeaderPage",
"pages/MineMessagePage",
"components/page/InteractMessagePage"
"components/page/InteractMessagePage",
"pages/ShowHomePageHeaderPage",
"pages/SubscribeMessagePage"
]
}
\ No newline at end of file
... ...
... ... @@ -70,6 +70,7 @@ export struct DetailPlayLiveCommon {
this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId)
this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle)
this.publishCommentModel.targetType = String(this.contentDetailData?.newsType)
this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment)
this.publishCommentModel.commentContent = ''
// }
}
... ...
... ... @@ -121,11 +121,12 @@ export struct PlayUIComponent {
}
}
.width('100%')
// .width(this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL ? 'calc(100% - 80vp)' : 'calc(100% - 32vp)')
.padding({
top: 15,
bottom: 6,
left: 10,
right: 10
left: this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL ? '40vp' : '16vp',
right: this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL ? '40vp' : '16vp'
})
.alignItems(HorizontalAlign.Start)
.visibility(this.isMenuVisible ? Visibility.Visible : Visibility.None)
... ... @@ -292,8 +293,8 @@ export struct PlayUIComponent {
.linearGradient({ angle: 0, colors: [['#99000000', 0], ['#00000000', 1]] })
.width('100%')
.padding({
left: 10,
right: 10,
left: this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL ? '40vp' : '16vp',
right: this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL ? '40vp' : '16vp',
top: 15,
bottom: 15
})
... ...
... ... @@ -28,11 +28,11 @@ export struct TopPlayComponent {
updateData() {
//直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停
if (this.liveDetailsBean.liveInfo && this.liveDetailsBean.liveInfo.previewUrl && this.liveDetailsBean.liveInfo.previewUrl.length > 0) {
if (this.liveDetailsBean.liveInfo && this.liveDetailsBean.liveInfo.previewUrl &&
this.liveDetailsBean.liveInfo.previewUrl.length > 0) {
this.imgUrl = this.liveDetailsBean.liveInfo.previewUrl
Logger.debug(TAG, 'ok+' + `${this.imgUrl}`)
}
else if (this.liveDetailsBean.fullColumnImgUrls && this.liveDetailsBean.fullColumnImgUrls.length > 0) {
} else if (this.liveDetailsBean.fullColumnImgUrls && this.liveDetailsBean.fullColumnImgUrls.length > 0) {
this.imgUrl = this.liveDetailsBean.fullColumnImgUrls[0].url
Logger.debug(TAG, 'ok-' + `${this.imgUrl}`)
}
... ... @@ -81,6 +81,7 @@ export struct TopPlayComponent {
.alignSelf(ItemAlign.Center)
}
aboutToDisappear(): void {
async aboutToDisappear(): Promise<void> {
await this.playerController?.release()
}
}
\ No newline at end of file
... ...
... ... @@ -115,6 +115,7 @@ export struct PlayerCommentComponent {
// 收藏、分享、点赞是否需要根据字段显隐
OperRowListView({
styleType: 3,
componentType: 4,
operationButtonList: ['comment', 'collect', 'share', 'like'],
contentDetailData: this.contentDetailData,
publishCommentModel: this.publishCommentModel,
... ...
... ... @@ -37,11 +37,10 @@ export struct PlayerComponent {
}
}
aboutToDisappear(): void {
async aboutToDisappear(): Promise<void> {
this.playerController?.pause()
this.playerController?.stop()
this.playerController?.release()
await this.playerController?.release()
}
updateData() {
... ...
import { ContentDetailDTO } from 'wdBean/Index'
import {
publishCommentModel
} from '../../../../../wdComponent/src/main/ets/components/comment/model/PublishCommentModel'
import { CommentComponent } from '../../../../../wdComponent/src/main/ets/components/comment/view/CommentComponent'
@Component
export struct CommentComponentPage {
scroller: Scroller = new Scroller()
@Consume contentDetailData: ContentDetailDTO
@Consume showCommentList: boolean
@State publishCommentModel: publishCommentModel = new publishCommentModel()
aboutToAppear(): void {
this.publishCommentModel.targetId = String(this.contentDetailData?.newsId || '')
this.publishCommentModel.targetRelId = String(this.contentDetailData?.reLInfo?.relId)
this.publishCommentModel.targetTitle = this.contentDetailData?.newsTitle
this.publishCommentModel.targetRelType = String(this.contentDetailData?.reLInfo?.relType)
this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId)
this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle)
this.publishCommentModel.targetType = String(this.contentDetailData?.newsType)
}
build() {
Scroll(this.scroller) {
Stack() {
CommentComponent({
publishCommentModel: this.publishCommentModel
})
Image($r("app.media.ic_close_black"))
.width(20)
.height(20)
.onClick(() => {
this.showCommentList = false
})
.margin({ top: 10, right: 20 })
.position({ x: '100%' })
.markAnchor({ x: '100%' })
}
}
.zIndex(1000)
.backgroundColor(Color.White)
}
}
\ No newline at end of file
... ...
import { ContentDetailDTO, InteractDataDTO } from 'wdBean';
import { PlayerConstants, WDPlayerController, WDPlayerRenderView } from 'wdPlayer';
import { WDPlayerController, WDPlayerRenderView } from 'wdPlayer';
import { ContentDetailRequest } from 'wdDetailPlayApi';
import {
batchLikeAndCollectParams,
... ... @@ -11,6 +11,7 @@ import { HttpUtils } from 'wdNetwork/Index';
import { DateTimeUtils } from 'wdKit/Index';
import { PlayerBottomView } from '../view/PlayerBottomView';
import { PlayerRightView } from '../view/PlayerRightView';
import { CommentComponentPage } from './CommentComponentPage';
const TAG = 'DetailPlayShortVideoPage';
... ... @@ -32,6 +33,7 @@ export struct DetailPlayShortVideoPage {
@Provide followStatus: string = '0' // 关注状态
@Provide isOpenDetail: boolean = false // 查看详情按钮点击
@Provide isDragging: boolean = false // 拖动时间进度条
@Provide showCommentList: boolean = false
@Consume @Watch('videoStatusChange') switchVideoStatus: boolean
@Consume @Watch('pageShowChange') pageShow: number
@Consume topSafeHeight: number
... ... @@ -148,6 +150,7 @@ export struct DetailPlayShortVideoPage {
this.progressVal = Math.floor(position * 100 / duration);
}
this.queryNewsInfoOfUser()
}
async aboutToDisappear(): Promise<void> {
... ... @@ -163,10 +166,14 @@ export struct DetailPlayShortVideoPage {
PlayerBottomView({
playerController: this.playerController
})
PlayerRightView({
playerController: this.playerController
})
CommentComponentPage({}).visibility(this.showCommentList ? Visibility.Visible : Visibility.None)
.position({ y: '100%' })
.markAnchor({ y: '100%' })
}
.height('100%')
.width('100%')
... ... @@ -192,6 +199,7 @@ export struct DetailPlayShortVideoPage {
@Builder
playerViewBuilder() {
WDPlayerRenderView({
playerController: this.playerController,
onLoad: async () => {
... ... @@ -205,10 +213,13 @@ export struct DetailPlayShortVideoPage {
.padding({
bottom: this.videoLandScape === 1 ? 115 : 0,
})
.layoutWeight(1)
.align(this.videoLandScape === 0 ? Alignment.Top : Alignment.Center)
.onClick(() => {
console.error('WDPlayerRenderView=== onClick')
this.playerController?.switchPlayOrPause();
})
}
}
\ No newline at end of file
... ...
... ... @@ -43,7 +43,7 @@ export struct DetailDialog {
.height(200)
Row() {
Image($r('app.media.ic_close'))
Image($r("app.media.ic_close_white"))
.height(24).margin({ top: 20 }).onClick(() => {
this.controller.close()
if (this.isOpenDetail) {
... ...
... ... @@ -3,20 +3,56 @@ import { PlayerTitleView } from './PlayerTitleView'
import { PlayerProgressView } from './PlayerProgressView'
import { PlayerCommentView } from './PlayerCommentView'
import { PlayerTimeSeekView } from './PlayerTimeSeekView'
import { OperRowListView } from '../../../../../wdComponent/src/main/ets/components/view/OperRowListView'
import {
publishCommentModel
} from '../../../../../wdComponent/src/main/ets/components/comment/model/PublishCommentModel'
import { ContentDetailDTO } from 'wdBean/Index';
import { WindowModel } from 'wdKit/Index';
@Component
export struct PlayerBottomView {
private playerController?: WDPlayerController;
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
@Consume showComment?: boolean
@Consume isOpenDetail?: boolean
@Consume isDragging?: boolean
@Consume contentDetailData: ContentDetailDTO
@State publishCommentModel: publishCommentModel = new publishCommentModel()
aboutToAppear(): void {
this.publishCommentModel.targetId = String(this.contentDetailData?.newsId || '')
this.publishCommentModel.targetRelId = String(this.contentDetailData?.reLInfo?.relId)
this.publishCommentModel.targetTitle = this.contentDetailData?.newsTitle
this.publishCommentModel.targetRelType = String(this.contentDetailData?.reLInfo?.relType)
this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId)
this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle)
this.publishCommentModel.targetType = String(this.contentDetailData?.newsType)
this.publishCommentModel.commentContent = ''
}
build() {
Column() {
PlayerTitleView()
PlayerProgressView({ playerController: this.playerController })
if (this.showComment) {
PlayerCommentView()
// PlayerCommentView()
OperRowListView({
pageComponentType: 1,
styleType: 3,
componentType: 4,
operationButtonList: ['comment',],
contentDetailData: this.contentDetailData,
publishCommentModel: this.publishCommentModel,
showCommentIcon: false,
onBack: () => {
WindowModel.shared.setWindowLayoutFullScreen(false)
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', })
}
})
.padding({
bottom: -this.bottomSafeHeight + 'px'
})
}
}
.alignItems(HorizontalAlign.Start)
... ...
... ... @@ -32,6 +32,7 @@ export struct PlayerRightView {
@Consume isOpenDetail: boolean
@Consume isDragging: boolean
@Consume showComment?: boolean
@Consume showCommentList: boolean
@State likesStyle: number = this.contentDetailData.likesStyle // 赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空
aboutToAppear() {
... ... @@ -343,7 +344,8 @@ export struct PlayerRightView {
}
.margin({ bottom: 20 })
.onClick((event: ClickEvent) => {
ToastUtils.showToast('评论为公共方法,待开发', 1000);
// ToastUtils.showToast('评论为公共方法,待开发', 1000);
this.showCommentList = true
})
}
... ...
... ... @@ -5,6 +5,14 @@
"value": "#FFFFFF"
},
{
"name": "color_transparent",
"value": "#00000000"
},
{
"name": "color_222222",
"value": "#222222"
},
{
"name": "play_track_color",
"value": "#1AFFFFFF"
},
... ... @@ -29,6 +37,18 @@
"value": "#4DFFFFFF"
},
{
"name": "color_666666",
"value": "#666666"
},
{
"name": "color_B0B0B0",
"value": "#B0B0B0"
},
{
"name": "color_EDEDED",
"value": "#EDEDED"
},
{
"name": "divider_color",
"value": "#D3D3D3"
},
... ...
... ... @@ -3,6 +3,22 @@
{
"name": "shared_desc",
"value": "description"
},
{
"name": "footer_text",
"value": "已显示全部内容"
},
{
"name": "pull_up_load_text",
"value": "加载中..."
},
{
"name": "pull_down_refresh_text",
"value": "下拉刷新"
},
{
"name": "release_refresh_text",
"value": "松开刷新"
}
]
}
\ No newline at end of file
... ...
... ... @@ -2,7 +2,10 @@ import HuaweiAuth from './utils/HuaweiAuth'
import { JumpInterceptorAction, RouterJumpInterceptor, WDRouterPage } from 'wdRouter'
import { BusinessError } from '@kit.BasicServicesKit'
import { router } from '@kit.ArkUI'
import { AccountManagerUtils } from 'wdKit/Index'
import { AccountManagerUtils, SPHelper } from 'wdKit/Index'
import { LoginViewModel } from './pages/login/LoginViewModel'
import { SpConstants } from 'wdConstant/Index'
import { ReportDeviceInfo } from './reportDeviceInfo/ReportDeviceInfo'
class LoginJumpHandler implements JumpInterceptorAction {
... ... @@ -37,4 +40,14 @@ export class LoginModule {
}
}
// 启动进入主页 和 每次登录成功调用
static reportDeviceInfo() {
ReportDeviceInfo.reportDeviceInfo().then((res) => {
let nickName = res.touristNickName
if (res.touristNickName) {
SPHelper.default.save(SpConstants.TOURIST_NICK_NAME, res.touristNickName)
}
})
}
}
\ No newline at end of file
... ...
... ... @@ -82,6 +82,30 @@ export class LoginModel {
})
}
// loginType 0:手机号密码 2:手机号登录 3:QQ 4:微信 5:微博 6:APPLEID 7:手机号一键登录8:账号+密码 9:华为一键登录
thirdPartLogin(loginType: number, otherParams: Record<string, string|number>) {
otherParams['loginType'] = loginType
otherParams['deviceId'] = HttpUtils.getDeviceId()
return new Promise<LoginBean>((success, fail) => {
HttpRequest.post<ResponseDTO<LoginBean>>(HttpUrlUtils.getAppLoginUrl(), otherParams).then((data: ResponseDTO<LoginBean>) => {
Logger.debug("LoginViewModel:success2 ", data.message)
if (!data) {
fail("数据为空")
return
}
if (!data.data||data.code != 0) {
fail(data.message)
return
}
success(data.data)
}, (error: Error) => {
fail(error.message)
Logger.debug("LoginViewModel:error2 ", error.toString())
})
})
}
// {"password":"523acd319228efde34e8a30268ee8ca5e4fc421d72affa531676e1765940d22c","phone":"13625644528","loginType":0,"oldPassword":"BA5FD74F827AF9B271FE17CADC489C36","deviceId":"60da5af6-9c59-3566-8622-8c6c00710994"}
appLoginByPassword(phone: string, loginType: number, password: string, oldPassword: string) {
let bean: Record<string, string | number> = {};
... ...
... ... @@ -407,14 +407,9 @@ struct LoginPage {
queryUserDetail(){
this.loginViewModel.queryUserDetail().then(()=>{
router.back({
url: `${WDRouterPage.getBundleInfo()}`
}
)
router.back()
}).catch(()=>{
router.back({
url: `${WDRouterPage.getBundleInfo()}`
})
router.back()
})
}
... ...
... ... @@ -10,6 +10,7 @@ import { encryptMessage } from '../../utils/cryptoUtil'
import { SpConstants } from 'wdConstant/Index'
import { UserDetail } from 'wdBean/Index';
import { HttpUtils } from 'wdNetwork/Index'
import { LoginModule } from '../../LoginModule'
const TAG = "LoginViewModel"
... ... @@ -47,15 +48,7 @@ export class LoginViewModel {
return new Promise<LoginBean>((success, fail) => {
this.loginModel.appLogin(phone, loginType, verificationCode).then((data: LoginBean) => {
SPHelper.default.saveSync(SpConstants.USER_FIRST_MARK, data.firstMark)
SPHelper.default.saveSync(SpConstants.USER_ID, data.id)
SPHelper.default.saveSync(SpConstants.USER_JWT_TOKEN, data.jwtToken)
SPHelper.default.saveSync(SpConstants.USER_LONG_TIME_NO_LOGIN_MARK, data.longTimeNoLoginMark)
SPHelper.default.saveSync(SpConstants.USER_REFRESH_TOKEN, data.refreshToken)
SPHelper.default.saveSync(SpConstants.USER_STATUS, data.status)
SPHelper.default.saveSync(SpConstants.USER_Type, data.userType)
SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName)
EmitterUtils.sendEmptyEvent(EmitterEventId.LOGIN_SUCCESS)
this.dealWithLoginSuccess(data)
success(data)
}).catch((error:string) => {
fail(error)
... ... @@ -63,6 +56,32 @@ export class LoginViewModel {
})
}
huaweiOneKeyLogin(authCode: string) {
return new Promise<LoginBean>((success, fail) => {
this.loginModel.thirdPartLogin(9, {"idToken": authCode}).then((data: LoginBean) => {
this.dealWithLoginSuccess(data)
success(data)
}).catch((error:string) => {
fail(error)
})
})
}
//TODO: 这里要整体改掉
dealWithLoginSuccess(data: LoginBean) {
SPHelper.default.saveSync(SpConstants.USER_FIRST_MARK, data.firstMark)
SPHelper.default.saveSync(SpConstants.USER_ID, data.id)
SPHelper.default.saveSync(SpConstants.USER_JWT_TOKEN, data.jwtToken)
SPHelper.default.saveSync(SpConstants.USER_LONG_TIME_NO_LOGIN_MARK, data.longTimeNoLoginMark)
SPHelper.default.saveSync(SpConstants.USER_REFRESH_TOKEN, data.refreshToken)
SPHelper.default.saveSync(SpConstants.USER_STATUS, data.status)
SPHelper.default.saveSync(SpConstants.USER_Type, data.userType)
SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName)
EmitterUtils.sendEmptyEvent(EmitterEventId.LOGIN_SUCCESS)
LoginModule.reportDeviceInfo()
}
async appLoginByPassword(phone: string, loginType: number, password: string, oldPassword: string) {
let newLoginType: number
let isPhone = this.verifyIsPhoneNumber(phone)
... ... @@ -75,15 +94,7 @@ export class LoginViewModel {
let passwordNew = await this.doMd(password)
Logger.debug(TAG, "PASSWORD:" + passwordNew)
this.loginModel.appLoginByPassword(phone, newLoginType, passwordNew, oldPassword).then((data: LoginBean) => {
SPHelper.default.saveSync(SpConstants.USER_FIRST_MARK, data.firstMark)
SPHelper.default.saveSync(SpConstants.USER_ID, data.id)
SPHelper.default.saveSync(SpConstants.USER_JWT_TOKEN, data.jwtToken)
SPHelper.default.saveSync(SpConstants.USER_LONG_TIME_NO_LOGIN_MARK, data.longTimeNoLoginMark)
SPHelper.default.saveSync(SpConstants.USER_REFRESH_TOKEN, data.refreshToken)
SPHelper.default.saveSync(SpConstants.USER_STATUS, data.status)
SPHelper.default.saveSync(SpConstants.USER_Type, data.userType)
SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName)
EmitterUtils.sendEmptyEvent(EmitterEventId.LOGIN_SUCCESS)
this.dealWithLoginSuccess(data)
success(data)
}).catch((value: string) => {
fail(value)
... ... @@ -219,18 +230,29 @@ export class LoginViewModel {
this.loginModel.queryUserDetail().then((data: UserDetail) => {
//保存sp
if(data){
SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName)
SPHelper.default.saveSync(SpConstants.USER_PHONE, data.phone)
if(data.userName!=undefined){
SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName)
}
if(data.phone!=undefined){
SPHelper.default.saveSync(SpConstants.USER_PHONE, data.phone)
}
}
if(data.userExtend){
SPHelper.default.saveSync(SpConstants.USER_SEX, data.userExtend.sex)
SPHelper.default.saveSync(SpConstants.USER_CREATOR_ID, data.userExtend.creatorId+"")
SPHelper.default.saveSync(SpConstants.USER_HEAD_PHOTO_URL, data.userExtend.headPhotoUrl)
SPHelper.default.saveSync(SpConstants.USER_BIRTHDAY, data.userExtend.birthday)
if(data.userExtend.sex!=undefined){
SPHelper.default.saveSync(SpConstants.USER_SEX, data.userExtend.sex)
}
if(data.userExtend.creatorId!=undefined){
SPHelper.default.saveSync(SpConstants.USER_CREATOR_ID, data.userExtend.creatorId+"")
}
if(data.userExtend.headPhotoUrl!=undefined){
SPHelper.default.saveSync(SpConstants.USER_HEAD_PHOTO_URL, data.userExtend.headPhotoUrl)
}
if(data.userExtend.birthday!=undefined){
SPHelper.default.saveSync(SpConstants.USER_BIRTHDAY, data.userExtend.birthday)
}
}
success(data)
}).catch(() => {
}).catch((error:Error) => {
fail()
})
})
... ...
... ... @@ -3,13 +3,30 @@ import { Params } from 'wdBean/Index'
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
import HuaweiAuth from '../../utils/HuaweiAuth'
import { BusinessError } from '@kit.BasicServicesKit'
import { ToastUtils } from 'wdKit/Index'
import { Logger, ToastUtils, CustomToast, EmitterUtils, EmitterEventId } from 'wdKit/Index'
import { LoginViewModel } from './LoginViewModel'
import {InterestsHobbiesModel} from '../../../../../../../products/phone/src/main/ets/pages/viewModel/InterestsHobbiesModel'
const TAG = "OneKeyLoginPage"
@Entry
@Component
struct OneKeyLoginPage {
anonymousPhone: string = ''
@State agreeProtocol: boolean = false
viewModel: LoginViewModel = new LoginViewModel()
@State toastText:string = ""
dialogToast: CustomDialogController = new CustomDialogController({
builder: CustomToast({
msg: this.toastText,
}),
autoCancel: false,
alignment: DialogAlignment.Center,
offset: { dx: 0, dy: -20 },
gridCount: 1,
customStyle: true,
maskColor:"#00000000"
})
aboutToAppear(): void {
this.anonymousPhone = HuaweiAuth.sharedInstance().anonymousPhone||""
... ... @@ -44,17 +61,7 @@ struct OneKeyLoginPage {
if (!this.agreeProtocol) {
return
}
HuaweiAuth.sharedInstance().oneKeyLogin().then((authorizeCode) => {
//TODO: 调用服务端接口登录
ToastUtils.shortToast("获取到授权code: " + authorizeCode + ",由于需要后台接口支持,暂时先跳转其他登录方式")
setTimeout(() => {
router.replaceUrl({url: WDRouterPage.loginPage.url()})
}, 3000)
}).catch((error: BusinessError) => {
})
this.requestLogin()
})
}
.padding({ left: 25, right: 25 })
... ... @@ -113,4 +120,47 @@ struct OneKeyLoginPage {
}.margin({ top: 15, right: 15 })
.width("100%")
}
async requestLogin() {
try {
let authorizeCode = await HuaweiAuth.sharedInstance().oneKeyLogin()
let data = await this.viewModel.huaweiOneKeyLogin(authorizeCode)
Logger.debug(TAG, "requestLogin: " + data.jwtToken)
this.showToastTip('登录成功')
///同步兴趣tag
let interestsModel = new InterestsHobbiesModel()
interestsModel.updateInterests()
this.queryUserDetail()
EmitterUtils.sendEvent(EmitterEventId.PEOPLE_SHIP_ATTENTION)
} catch (error) {
if (typeof error == "string") {
this.showToastTip(error)
} else {
(error as BusinessError)
this.showToastTip("登录失败")
}
}
}
showToastTip(msg:string){
this.toastText = msg
this.dialogToast.open()
}
queryUserDetail(){
this.viewModel.queryUserDetail().then(()=>{
router.back({
url: `${WDRouterPage.getBundleInfo()}`
}
)
}).catch(()=>{
router.back({
url: `${WDRouterPage.getBundleInfo()}`
})
})
}
}
\ No newline at end of file
... ...
import { AppUtils, DeviceUtil, Logger, UserDataLocal } from 'wdKit/Index';
import { HttpBizUtil, HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index';
export class ReportDeviceInfo {
static reportDeviceInfo() {
const userId = UserDataLocal.getUserId() || ""
const url = HttpUrlUtils.reportDeviceInfo()
let bean: Record<string, string | number> = {};
bean['deviceId'] = DeviceUtil.clientId()
bean['appVersion'] = AppUtils.getAppVersionCode()
bean['platform'] = 3 /// 1Android 2iOS
bean['userId'] = userId
bean['brand'] = DeviceUtil.getMarketName()
bean['modelSystemVersion'] = DeviceUtil.getDisplayVersion()
bean['tenancy'] = 3 ///1-视界 2-英文版 3-中文版
return new Promise<ReportDeviceInfoRes>((success, fail) => {
HttpBizUtil.post<ResponseDTO<ReportDeviceInfoRes>>(url,bean).then((data: ResponseDTO<ReportDeviceInfoRes>) => {
if (!data) {
fail("数据为空")
return
}
if (data.code != 0) {
fail(data.message)
return
}
success(data.data!)
}, (error: Error) => {
fail(error.message)
Logger.debug("ReportDeviceInfo", error.toString())
})
})
}
}
export class ReportDeviceInfoRes {
clean : number = 0
touristNickName : string = ""
}
\ No newline at end of file
... ...
... ... @@ -94,10 +94,9 @@ export struct WDPlayerRenderView {
.renderFit(RenderFit.RESIZE_COVER)
}
// .onAreaChange(() => {
// this.updateLayout()
// })
.onAreaChange(() => {
this.updateLayout()
})
.backgroundColor("#000000")
// .height('100%')
... ...
... ... @@ -4,21 +4,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
import Want from '@ohos.app.ability.Want';
import window from '@ohos.window';
import { BusinessError } from '@ohos.base';
import { registerRouter } from 'wdRouter';
import {
EmitterEventId,
EmitterUtils,
Logger,
MpaasUtils,
NetworkManager,
NetworkType,
SPHelper,
StringUtils,
UmengStats,
WindowModel
} from 'wdKit';
import { HostEnum, HostManager, WDHttp } from 'wdNetwork';
import { LoginModule } from 'wdLogin/src/main/ets/LoginModule';
import { EmitterEventId, EmitterUtils, WindowModel } from 'wdKit';
import { ConfigurationConstant } from '@kit.AbilityKit';
import { WDPushNotificationManager } from 'wdHwAbility/Index';
import { StartupManager } from '../startupmanager/StartupManager';
... ... @@ -60,7 +46,7 @@ export default class EntryAbility extends UIAbility {
AppStorage.setOrCreate('topSafeHeight', topSafeHeight);
AppStorage.setOrCreate('windowWidth', width);
AppStorage.setOrCreate('windowHeight', height);
let audioWidth = px2vp(width)*0.65
let audioWidth = px2vp(width) * 0.65
console.info('floatWindowClass audioWidth' + audioWidth);
... ... @@ -71,7 +57,8 @@ export default class EntryAbility extends UIAbility {
hilog.info(0x0000, 'testTag', 'setPreferredOrientation Succeeded');
})
.catch((err: Error) => {
hilog.error(0x0000, 'testTag', `setPreferredOrientation catch, error error.name : ${err.name}, error.message:${err.message}`);
hilog.error(0x0000, 'testTag',
`setPreferredOrientation catch, error error.name : ${err.name}, error.message:${err.message}`);
})
//../../../../../../features/wdLogin/src/main/ets/pages/launchPage/LaunchPage
windowStage.loadContent('pages/launchPage/LaunchPage', (err, data) => {
... ...
... ... @@ -16,12 +16,15 @@ struct ImageAndTextDetailPage {
}
}
pageTransition(){
// 定义页面进入时的效果,从右边侧滑入
PageTransitionEnter({ type: RouteType.None, duration: 300 })
pageTransition() {
// 为目标页面时,进入:从右边侧滑入,退出:是右侧划出;跳转别的页面:左侧划出,返回:左侧划入。
PageTransitionEnter({ type: RouteType.Push, duration: 300 })
.slide(SlideEffect.Right)
// 定义页面退出时的效果,向右边侧滑出
PageTransitionExit({ type: RouteType.None, duration: 300 })
PageTransitionEnter({ type: RouteType.Pop, duration: 300 })
.slide(SlideEffect.Left)
PageTransitionExit({ type: RouteType.Push, duration: 300 })
.slide(SlideEffect.Left)
PageTransitionExit({ type: RouteType.Pop, duration: 300 })
.slide(SlideEffect.Right)
}
... ...
... ... @@ -3,11 +3,12 @@ import { BreakpointConstants } from 'wdConstant';
import { HWLocationUtils, WDPushNotificationManager } from 'wdHwAbility/Index';
import { common } from '@kit.AbilityKit';
import { BreakpointSystem, EmitterEventId, EmitterUtils, Logger, MpaasUpgradeCheck } from 'wdKit';
import router from '@ohos.router';
import { promptAction } from '@kit.ArkUI';
import { BreakpointSystem, EmitterEventId, EmitterUtils, Logger, MpaasUpgradeCheck, WindowModel } from 'wdKit';
import { promptAction, window } from '@kit.ArkUI';
import { UpgradeTipDialog } from "./upgradePage/UpgradeTipDialog"
import { ProcessUtils } from 'wdRouter/Index';
import { StartupManager } from '../startupmanager/StartupManager';
import { BusinessError } from '@kit.BasicServicesKit';
const TAG = 'MainPage';
... ... @@ -17,7 +18,8 @@ struct MainPage {
@Provide pageShow: number = -1
@Provide pageHide: number = -1
private breakpointSystem: BreakpointSystem = new BreakpointSystem()
@StorageLink('currentBreakpoint') @Watch('watchCurrentBreakpoint') currentBreakpoint: string = BreakpointConstants.BREAKPOINT_XS;
@StorageLink('currentBreakpoint') @Watch('watchCurrentBreakpoint') currentBreakpoint: string =
BreakpointConstants.BREAKPOINT_XS;
@State isPermission: boolean = false
upgradeDialogController?: CustomDialogController
... ... @@ -27,6 +29,8 @@ struct MainPage {
aboutToAppear() {
StartupManager.sharedInstance().appReachMainPage()
this.breakpointSystem.register()
let context = getContext(this) as common.UIAbilityContext
... ... @@ -44,7 +48,7 @@ struct MainPage {
LogoutViewModel.clearLoginInfo()
})
EmitterUtils.receiveEvent(EmitterEventId.LOCATION, () => {
this.isPermission=true
this.isPermission = true
})
}
... ... @@ -78,7 +82,7 @@ struct MainPage {
this.upgradeDialogController = new CustomDialogController({
builder: UpgradeTipDialog({
tipContent:data,
tipContent: data,
confirm: () => {
ProcessUtils.jumpExternalWebPage(data.downloadUrl);
}
... ... @@ -101,12 +105,26 @@ struct MainPage {
onBackPress() {
Logger.info(TAG, 'onBackPress');
try {
// 拦截返回键,切到后台
const windowClass = WindowModel.shared.getWindowClass() as window.Window
windowClass.minimize().then(() => {
Logger.debug(TAG, 'Succeeded in minimizing the window.');
}).catch((err: BusinessError) => {
Logger.error(TAG, 'Failed to minimize the window. Cause: ' + JSON.stringify(err));
return false
});
} catch (err) {
Logger.error(TAG, 'Failed to minimize: ' + JSON.stringify(err));
return false
}
return true
}
build() {
Stack({alignContent:Alignment.Top}) {
Stack({ alignContent: Alignment.Top }) {
BottomNavigationComponent()
if(this.isPermission){
if (this.isPermission) {
PermissionDesComponent()
}
}
... ...
... ... @@ -18,11 +18,14 @@ struct SpacialTopicPage {
}
pageTransition() {
// 定义页面进入时的效果,从右边侧滑入
PageTransitionEnter({ type: RouteType.None, duration: 300 })
// 为目标页面时,进入:从右边侧滑入,退出:是右侧划出;跳转别的页面:左侧划出,返回:左侧划入。
PageTransitionEnter({ type: RouteType.Push, duration: 300 })
.slide(SlideEffect.Right)
// 定义页面退出时的效果,向右边侧滑出
PageTransitionExit({ type: RouteType.None, duration: 300 })
PageTransitionEnter({ type: RouteType.Pop, duration: 300 })
.slide(SlideEffect.Left)
PageTransitionExit({ type: RouteType.Push, duration: 300 })
.slide(SlideEffect.Left)
PageTransitionExit({ type: RouteType.Pop, duration: 300 })
.slide(SlideEffect.Right)
}
... ...
... ... @@ -70,7 +70,7 @@ struct LaunchInterestsHobbiesPage {
.width('100%')
.height('100%')
.backgroundColor(Color.Gray)
.opacity(item.choose?0.7:0)
.opacity(item.choose?0.85:0)
.borderRadius(5)
}
... ... @@ -134,7 +134,7 @@ struct LaunchInterestsHobbiesPage {
.width('662lpx')
.height('84lpx')
.backgroundColor(Color.White)
.opacity(this.selectCount == 0 ? 0.6 : 0)
.opacity(this.selectCount == 0 ? 0.3 : 0)
.borderRadius('10lpx')
.onClick(()=>{
if (this.selectCount == 0) {
... ...
... ... @@ -90,6 +90,9 @@ export class StartupManager {
appReachMainPage() : Promise<void> {
return new Promise((resolve) => {
Logger.debug(TAG, "App 进入首页,开始其他任务初始化")
LoginModule.reportDeviceInfo()
//TODO:
resolve()
... ... @@ -132,18 +135,18 @@ export class StartupManager {
private initNetwork() {
Logger.debug(TAG, "App 网络 初始化")
WDHttp.initHttpHeader()
// 注册监听网络连接
EmitterUtils.receiveEvent(EmitterEventId.NETWORK_CONNECTED, ((str?: string) => {
let type: NetworkType | null = null
if (str) {
type = JSON.parse(str) as NetworkType
}
Logger.info('network connected: ' + type?.toString())
}))
// 注册监听网络断开
EmitterUtils.receiveEvent(EmitterEventId.NETWORK_DISCONNECTED, (() => {
Logger.info('network disconnected')
}))
// 注册监听网络连接,没有实质业务意义,可删除
// EmitterUtils.receiveEvent(EmitterEventId.NETWORK_CONNECTED, ((str?: string) => {
// let type: NetworkType | null = null
// if (str) {
// type = JSON.parse(str) as NetworkType
// }
// Logger.info('network connected: ' + type?.toString())
// }))
// // 注册监听网络断开
// EmitterUtils.receiveEvent(EmitterEventId.NETWORK_DISCONNECTED, (() => {
// Logger.info('network disconnected')
// }))
}
private initCheckDeviceId() {
... ...
import { insightIntent, InsightIntentExecutor } from '@kit.AbilityKit';
import { window } from '@kit.ArkUI';
import { BusinessError } from '@kit.BasicServicesKit';
/**
* 意图调用
*/
export default class InsightIntentExecutorImpl extends InsightIntentExecutor {
private static readonly ViewColumn = 'ViewColumn';
/**
* override 执行前台UIAbility意图
*
* @param name 意图名称
* @param param 意图参数
* @param pageLoader 窗口
* @returns 意图调用结果
*/
onExecuteInUIAbilityForegroundMode(name: string, param: Record<string, Object>, pageLoader: window.WindowStage):
Promise<insightIntent.ExecuteResult> {
// 根据意图名称分发处理逻辑
switch (name) {
case InsightIntentExecutorImpl.ViewColumn:
return this.jumpToView(param, pageLoader);
default:
break;
}
return Promise.resolve({
code: -1,
result: {
message: 'unknown intent'
}
} as insightIntent.ExecuteResult)
}
/**
* 实现跳转新闻页面功能
*
* @param param 意图参数
* @param pageLoader 窗口
*/
private jumpToView(param: Record<string, Object>, pageLoader: window.WindowStage): Promise<insightIntent.ExecuteResult> {
return new Promise((resolve, reject) => {
// TODO 实现意图调用,loadContent的入参为歌曲落地页路径,例如:pages/SongPage
pageLoader.loadContent('pages/MainPage')
.then(() => {
let entityId: string = (param.items as Array<object>)?.[0]?.['entityId'];
// TODO 调用成功的情况,此处可以打印日志
resolve({
code: 0,
result: {
message: 'Intent execute success'
}
});
})
.catch((err: BusinessError) => {
// TODO 调用失败的情况
resolve({
code: -1,
result: {
message: 'Intent execute failed'
}
})
});
})
}
}
\ No newline at end of file
... ...
{
"insightIntents": [
{
"intentName": "ViewColumn",
"domain": "",
"intentVersion": "1.0.1",
"srcEntry": "./ets/utils/InsightIntentExecutorImpl.ets",
"uiAbility": {
"ability": "EntryAbility",
"executeMode": [
"background",
"foreground"
]
}
}
]
}
\ No newline at end of file
... ...