yanlu

fix:合并代码

Showing 26 changed files with 893 additions and 109 deletions
... ... @@ -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;
... ...
... ... @@ -334,6 +334,16 @@ export class HttpUrlUtils {
*/
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();
}
... ... @@ -759,4 +769,15 @@ export class HttpUrlUtils {
}
//点击消息
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
}
}
... ...
... ... @@ -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");
//人民号主页
... ...
... ... @@ -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)
... ...
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[]
... ... @@ -62,6 +65,7 @@ export default struct MinePagePersonFunctionUI {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
this.messageClick()
WDRouterRule.jumpWithPage(WDRouterPage.mineMessagePage)
break;
}
... ... @@ -75,5 +79,13 @@ export default struct MinePagePersonFunctionUI {
.height('234lpx')
.margin({top:'31lpx',left:'23lpx',right:'23lpx' })
}
messageClick(){
MinePageDatasModel.sendClickMessageData().then((value) => {
console.log(TAG, "进入消息页面")
}).catch((err: Error) => {
console.log(TAG, JSON.stringify(err))
})
}
}
... ...
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"
... ... @@ -12,84 +13,143 @@ export struct MessageListUI {
aboutToAppear() {
this.msgData = MinePageDatasModel.getMessageData()
this.getHistoryPush()
this.getMessagePush()
}
build() {
Column() {
//标题栏目
CustomTitleUI({ titleName: "消息" })
//历史推送
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))
})
}
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' })
//互动消息 预约消息 系统消息
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))
})
}
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 })
getPublishTime(data:string,publishTime: string): string {
const publishTimestamp = parseInt(publishTime)
const currentTime = Date.now(); // 当前时间戳
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)
// 计算差异
const timeDifference = currentTime - publishTimestamp;
Row() {
Text(`${item.time}`)
.fontColor($r('app.color.color_999999'))
.fontSize('23lpx')
.fontWeight(500)
.lineHeight('35lpx')
// 转换为分钟、小时和天
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]}`
}
}
}
.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)
console.log(result);
return result
}
build() {
Column() {
//标题栏目
CustomTitleUI({ titleName: "消息" })
List() {
ForEach(this.msgData, (item: MessageItem, index: number) => {
ListItem() {
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
... ...
... ... @@ -3,7 +3,6 @@ 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 { CustomTitleUI } from '../reusable/CustomTitleUI';
import { InteractMComponent } from '../InteractMessage/InteractMComponent';
... ...
... ... @@ -32,6 +32,9 @@ export struct MinePageComponent {
}else {
this.isLogin = true
this.addRecordDialog()
if(this.personalData.length > 0){
this.getMessageData()
}
}
}
}
... ...
... ... @@ -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)
}
... ...
... ... @@ -338,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 + '',
}],
}
... ...
... ... @@ -4,7 +4,7 @@
*/
export const enum WDMessageCenterMessageType {
WDMessageCenterMessageType_Interact = 1, //互动通知
WDMessageCenterMessageType_Subscribe, //预约消息
WDMessageCenterMessageType_Subscribe = 2, //预约消息
WDMessageCenterMessageType_System, //系统消息
}
... ... @@ -81,3 +81,29 @@ export interface InteractMDTO{
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
... ...
... ... @@ -25,6 +25,9 @@ import { FollowOperationRequestItem } from '../viewmodel/FollowOperationRequestI
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"
... ... @@ -601,8 +604,6 @@ class MinePageDatasModel{
/**
* 获取消息未读数据
* @param pageSize
* @param pageNum
* @returns
*/
getMessageUnReadData(): Promise<MessageUnReadItem> {
... ... @@ -625,6 +626,81 @@ class MinePageDatasModel{
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()
... ...
import { SubscribeMessageComponent } from '../components/mine/message/subscribe/SubscribeMessageComponent'
//预约消息 页面
@Entry
@Component
struct SubscribeMessagePage {
build() {
Column(){
SubscribeMessageComponent()
}
}
}
\ No newline at end of file
... ...
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
... ...
@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
... ...
... ... @@ -25,6 +25,7 @@
"pages/ShowUserHeaderPage",
"pages/MineMessagePage",
"components/page/InteractMessagePage",
"pages/ShowHomePageHeaderPage"
"pages/ShowHomePageHeaderPage",
"pages/SubscribeMessagePage"
]
}
\ No newline at end of file
... ...
... ... @@ -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) => {
... ...
... ... @@ -3,12 +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';
... ... @@ -18,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
... ... @@ -47,7 +48,7 @@ struct MainPage {
LogoutViewModel.clearLoginInfo()
})
EmitterUtils.receiveEvent(EmitterEventId.LOCATION, () => {
this.isPermission=true
this.isPermission = true
})
}
... ... @@ -81,7 +82,7 @@ struct MainPage {
this.upgradeDialogController = new CustomDialogController({
builder: UpgradeTipDialog({
tipContent:data,
tipContent: data,
confirm: () => {
ProcessUtils.jumpExternalWebPage(data.downloadUrl);
}
... ... @@ -104,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()
}
}
... ...
... ... @@ -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) {
... ...
... ... @@ -135,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() {
... ...