Merge branch 'main' of http://192.168.1.42/developOne/harmonyPool into main
* 'main' of http://192.168.1.42/developOne/harmonyPool: desc:消息中心 和 预约消息 wdkit/index 更新 新增键值型数据库,简单封装 无用代码删除 首页返回键逻辑处理,改为切后台 fix: 17364 UI还原问题--单图卡两行三行标题鸿蒙版的行距与安卓不一致 fix: 17362 UI还原问题--单图卡鸿蒙版图片大小与安卓不一致,鸿蒙版图片偏大
Showing
22 changed files
with
889 additions
and
105 deletions
| @@ -20,6 +20,8 @@ export { WindowModel } from './src/main/ets/utils/WindowModel' | @@ -20,6 +20,8 @@ export { WindowModel } from './src/main/ets/utils/WindowModel' | ||
| 20 | 20 | ||
| 21 | export { SPHelper } from './src/main/ets/utils/SPHelper' | 21 | export { SPHelper } from './src/main/ets/utils/SPHelper' |
| 22 | 22 | ||
| 23 | +export { KVStoreHelper } from './src/main/ets/utils/KVStoreHelper' | ||
| 24 | + | ||
| 23 | export { AccountManagerUtils } from './src/main/ets/utils/AccountManagerUtils' | 25 | export { AccountManagerUtils } from './src/main/ets/utils/AccountManagerUtils' |
| 24 | 26 | ||
| 25 | export { CollectionUtils } from './src/main/ets/utils/CollectionUtils' | 27 | export { CollectionUtils } from './src/main/ets/utils/CollectionUtils' |
| 1 | +import { distributedKVStore } from '@kit.ArkData'; | ||
| 2 | +import { BusinessError } from '@kit.BasicServicesKit'; | ||
| 3 | +import { AppUtils } from './AppUtils'; | ||
| 4 | +import { Logger } from './Logger'; | ||
| 5 | + | ||
| 6 | +const TAG = 'KVStoreHelper' | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 键值型数据库管理类,类似sp,存储变大,单条数据,value<4M | ||
| 10 | + */ | ||
| 11 | +export class KVStoreHelper { | ||
| 12 | + private static _context: Context; | ||
| 13 | + // TODO 待优化,可以指定数据库名,创建多个数据库。当前没有需求,只创建一个,缓存接口数据用。 | ||
| 14 | + private static _default_store_id: string = 'default_kv_store'; | ||
| 15 | + private kvManager: distributedKVStore.KVManager | undefined = undefined; | ||
| 16 | + private kvStore: distributedKVStore.SingleKVStore | undefined = undefined; | ||
| 17 | + | ||
| 18 | + private constructor() { | ||
| 19 | + Logger.error(TAG, 'constructor') | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + static init(context: Context) { | ||
| 23 | + Logger.error(TAG, 'init') | ||
| 24 | + KVStoreHelper._context = context; | ||
| 25 | + KVStoreHelper.default.createKVManager() | ||
| 26 | + KVStoreHelper.default.createKVStore() | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + // 静态属性 | ||
| 30 | + static default: KVStoreHelper = new KVStoreHelper(); | ||
| 31 | + | ||
| 32 | + private createKVManager() { | ||
| 33 | + if (this.kvManager) { | ||
| 34 | + return | ||
| 35 | + } | ||
| 36 | + if (!KVStoreHelper._context) { | ||
| 37 | + Logger.fatal(TAG, 'context is null, must be initialized first') | ||
| 38 | + return | ||
| 39 | + } | ||
| 40 | + let context: Context = KVStoreHelper._context; | ||
| 41 | + const kvManagerConfig: distributedKVStore.KVManagerConfig = { | ||
| 42 | + context: context, | ||
| 43 | + bundleName: AppUtils.getPackageName(context) | ||
| 44 | + }; | ||
| 45 | + try { | ||
| 46 | + // 创建KVManager实例 | ||
| 47 | + this.kvManager = distributedKVStore.createKVManager(kvManagerConfig); | ||
| 48 | + Logger.info(TAG, 'Succeeded in creating KVManager.'); | ||
| 49 | + // 继续创建获取数据库 | ||
| 50 | + } catch (e) { | ||
| 51 | + let error = e as BusinessError; | ||
| 52 | + Logger.error(TAG, `Failed to create KVManager. Code:${error.code},message:${error.message}`); | ||
| 53 | + } | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + private createKVStore() { | ||
| 57 | + if (this.kvStore) { | ||
| 58 | + return | ||
| 59 | + } | ||
| 60 | + if (!this.kvManager) { | ||
| 61 | + this.createKVManager() | ||
| 62 | + // 直接拦截,避免陷入循环 | ||
| 63 | + Logger.error(TAG, 'kvManager is null, please re-create it and try again') | ||
| 64 | + return | ||
| 65 | + } | ||
| 66 | + try { | ||
| 67 | + const options: distributedKVStore.Options = { | ||
| 68 | + createIfMissing: true, | ||
| 69 | + encrypt: false, | ||
| 70 | + backup: false, | ||
| 71 | + autoSync: false, | ||
| 72 | + // kvStoreType不填时,默认创建多设备协同数据库 | ||
| 73 | + kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION, | ||
| 74 | + securityLevel: distributedKVStore.SecurityLevel.S1 | ||
| 75 | + }; | ||
| 76 | + this.kvManager?.getKVStore<distributedKVStore.SingleKVStore>(KVStoreHelper._default_store_id, options, | ||
| 77 | + (err, store: distributedKVStore.SingleKVStore) => { | ||
| 78 | + if (err) { | ||
| 79 | + Logger.error(TAG, `Failed to get KVStore: Code:${err.code},message:${err.message}`); | ||
| 80 | + return; | ||
| 81 | + } | ||
| 82 | + Logger.info(TAG, 'Succeeded in getting KVStore.'); | ||
| 83 | + this.kvStore = store; | ||
| 84 | + // 请确保获取到键值数据库实例后,再进行相关数据操作 | ||
| 85 | + }); | ||
| 86 | + } catch (e) { | ||
| 87 | + let error = e as BusinessError; | ||
| 88 | + Logger.error(TAG, `An unexpected error occurred. Code:${error.code},message:${error.message}`); | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + private checkStoreCreated() { | ||
| 93 | + if (!this.kvManager) { | ||
| 94 | + this.createKVManager() | ||
| 95 | + } | ||
| 96 | + if (!this.kvStore) { | ||
| 97 | + this.createKVStore() | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + get(key: string, def: boolean | string | number | Uint8Array): Promise<boolean | string | number | Uint8Array> { | ||
| 102 | + // this.checkStoreCreated() | ||
| 103 | + return new Promise<boolean | string | number | Uint8Array>((success, failed) => { | ||
| 104 | + try { | ||
| 105 | + this.kvStore?.get(key, (err, data) => { | ||
| 106 | + if (err != undefined) { | ||
| 107 | + Logger.debug(TAG, `Failed to get data. Code:${err.code},message:${err.message}`); | ||
| 108 | + success(def) | ||
| 109 | + return; | ||
| 110 | + } | ||
| 111 | + success(data) | ||
| 112 | + Logger.debug(TAG, `Succeeded in getting data. Data:${data}`); | ||
| 113 | + }); | ||
| 114 | + } catch (e) { | ||
| 115 | + success(def) | ||
| 116 | + let error = e as BusinessError; | ||
| 117 | + Logger.error(TAG, `Failed to get data. Code:${error.code},message:${error.message}`); | ||
| 118 | + } | ||
| 119 | + }); | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + put(key: string, value: boolean | string | number | Uint8Array) { | ||
| 123 | + // this.checkStoreCreated() | ||
| 124 | + try { | ||
| 125 | + this.kvStore?.put(key, value, (err) => { | ||
| 126 | + if (err !== undefined) { | ||
| 127 | + Logger.debug(TAG, `Failed to put data. Code:${err.code},message:${err.message}`); | ||
| 128 | + return; | ||
| 129 | + } | ||
| 130 | + Logger.debug(TAG, 'Succeeded in putting data.'); | ||
| 131 | + }); | ||
| 132 | + } catch (e) { | ||
| 133 | + let error = e as BusinessError; | ||
| 134 | + Logger.error(TAG, `An unexpected error occurred. Code:${error.code},message:${error.message}`); | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + del(key: string) { | ||
| 139 | + // this.checkStoreCreated() | ||
| 140 | + try { | ||
| 141 | + this.kvStore?.delete(key, (err) => { | ||
| 142 | + if (err !== undefined) { | ||
| 143 | + Logger.debug(TAG, `Failed to delete data. Code:${err.code},message:${err.message}`); | ||
| 144 | + return; | ||
| 145 | + } | ||
| 146 | + Logger.debug(TAG, 'Succeeded in deleting data.'); | ||
| 147 | + }); | ||
| 148 | + } catch (e) { | ||
| 149 | + let error = e as BusinessError; | ||
| 150 | + Logger.error(TAG, `An unexpected error occurred. Code:${error.code},message:${error.message}`); | ||
| 151 | + } | ||
| 152 | + } | ||
| 153 | +} |
| @@ -4,7 +4,7 @@ import { Logger } from './Logger'; | @@ -4,7 +4,7 @@ import { Logger } from './Logger'; | ||
| 4 | const TAG = 'SPHelper' | 4 | const TAG = 'SPHelper' |
| 5 | 5 | ||
| 6 | /** | 6 | /** |
| 7 | - * sp存储 | 7 | + * sp存储,单条数据,value<1k;业务数据超过1k的,建议使用KVStoreHelper |
| 8 | */ | 8 | */ |
| 9 | export class SPHelper { | 9 | export class SPHelper { |
| 10 | private static context: Context; | 10 | private static context: Context; |
| @@ -329,6 +329,16 @@ export class HttpUrlUtils { | @@ -329,6 +329,16 @@ export class HttpUrlUtils { | ||
| 329 | */ | 329 | */ |
| 330 | static readonly MESSAGE_UN_READ_DATA_PATH: string = "/api/rmrb-inside-mail/zh/c/inside-mail/private/polymerizationInfo?createTime="; | 330 | static readonly MESSAGE_UN_READ_DATA_PATH: string = "/api/rmrb-inside-mail/zh/c/inside-mail/private/polymerizationInfo?createTime="; |
| 331 | 331 | ||
| 332 | + /** | ||
| 333 | + * 点击消息 | ||
| 334 | + */ | ||
| 335 | + static readonly SEND_MESSAGE_PATH: string = "/api/rmrb-inside-mail/zh/c/inside-mail/private/touch?createTime="; | ||
| 336 | + | ||
| 337 | + /** | ||
| 338 | + * 推送消息 | ||
| 339 | + */ | ||
| 340 | + static readonly HISTORY_PUSH_MESSAGE_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/push"; | ||
| 341 | + | ||
| 332 | static getHost(): string { | 342 | static getHost(): string { |
| 333 | return HostManager.getHost(); | 343 | return HostManager.getHost(); |
| 334 | } | 344 | } |
| @@ -746,4 +756,16 @@ export class HttpUrlUtils { | @@ -746,4 +756,16 @@ export class HttpUrlUtils { | ||
| 746 | let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/common/user/c/device/push"; | 756 | let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/common/user/c/device/push"; |
| 747 | return url; | 757 | return url; |
| 748 | } | 758 | } |
| 759 | + | ||
| 760 | + //点击消息 | ||
| 761 | + static getSendClickMessageUrl() { | ||
| 762 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.SEND_MESSAGE_PATH | ||
| 763 | + return url | ||
| 764 | + } | ||
| 765 | + | ||
| 766 | + //消息 历史推送消息 | ||
| 767 | + static getHistoryPushUrl() { | ||
| 768 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.HISTORY_PUSH_MESSAGE_PATH | ||
| 769 | + return url | ||
| 770 | + } | ||
| 749 | } | 771 | } |
| @@ -119,6 +119,8 @@ export class WDRouterPage { | @@ -119,6 +119,8 @@ export class WDRouterPage { | ||
| 119 | static searchPage = new WDRouterPage("wdComponent", "ets/pages/SearchPage"); | 119 | static searchPage = new WDRouterPage("wdComponent", "ets/pages/SearchPage"); |
| 120 | //消息主页 | 120 | //消息主页 |
| 121 | static mineMessagePage = new WDRouterPage("wdComponent", "ets/pages/MineMessagePage"); | 121 | static mineMessagePage = new WDRouterPage("wdComponent", "ets/pages/MineMessagePage"); |
| 122 | + //预约消息主页 | ||
| 123 | + static subscribeMessagePage = new WDRouterPage("wdComponent", "ets/pages/SubscribeMessagePage"); | ||
| 122 | //搜索人民号主页 | 124 | //搜索人民号主页 |
| 123 | static searchCreatorPage = new WDRouterPage("wdComponent", "ets/pages/SearchCreatorPage"); | 125 | static searchCreatorPage = new WDRouterPage("wdComponent", "ets/pages/SearchCreatorPage"); |
| 124 | //人民号主页 | 126 | //人民号主页 |
| @@ -45,6 +45,7 @@ export struct Card6Component { | @@ -45,6 +45,7 @@ export struct Card6Component { | ||
| 45 | Text(`${this.contentDTO.newsTitle}`) | 45 | Text(`${this.contentDTO.newsTitle}`) |
| 46 | .fontColor(this.clicked ? 0x848484 : 0x222222) | 46 | .fontColor(this.clicked ? 0x848484 : 0x222222) |
| 47 | .fontSize(16) | 47 | .fontSize(16) |
| 48 | + .lineHeight(24) | ||
| 48 | .fontWeight(FontWeight.Normal) | 49 | .fontWeight(FontWeight.Normal) |
| 49 | .maxLines(3) | 50 | .maxLines(3) |
| 50 | .alignSelf(ItemAlign.Start) | 51 | .alignSelf(ItemAlign.Start) |
| @@ -70,7 +71,7 @@ export struct Card6Component { | @@ -70,7 +71,7 @@ export struct Card6Component { | ||
| 70 | .backgroundColor(this.loadImg ? $r('app.color.color_B0B0B0') : 0xf5f5f5) | 71 | .backgroundColor(this.loadImg ? $r('app.color.color_B0B0B0') : 0xf5f5f5) |
| 71 | .borderRadius(5) | 72 | .borderRadius(5) |
| 72 | .aspectRatio(this.contentDTO.appStyle === CompStyle.Card_13 ? 3 / 2 : 3 / 4) | 73 | .aspectRatio(this.contentDTO.appStyle === CompStyle.Card_13 ? 3 / 2 : 3 / 4) |
| 73 | - .height(this.contentDTO.appStyle === CompStyle.Card_13 ? 90 : 180) | 74 | + .height(this.contentDTO.appStyle === CompStyle.Card_13 ? 78 : 156) |
| 74 | CardMediaInfo({ contentDTO: this.contentDTO }) | 75 | CardMediaInfo({ contentDTO: this.contentDTO }) |
| 75 | } | 76 | } |
| 76 | .alignContent(Alignment.BottomEnd) | 77 | .alignContent(Alignment.BottomEnd) |
| 1 | import { WDRouterRule, WDRouterPage } from 'wdRouter' | 1 | import { WDRouterRule, WDRouterPage } from 'wdRouter' |
| 2 | +import MinePageDatasModel from '../../model/MinePageDatasModel' | ||
| 2 | import MinePagePersonalFunctionsItem from '../../viewmodel/MinePagePersonalFunctionsItem' | 3 | import MinePagePersonalFunctionsItem from '../../viewmodel/MinePagePersonalFunctionsItem' |
| 3 | import { PagePersonFunction } from './PagePersonFunction' | 4 | import { PagePersonFunction } from './PagePersonFunction' |
| 4 | 5 | ||
| 6 | + | ||
| 7 | +const TAG = "MinePagePersonFunctionUI" | ||
| 5 | @Component | 8 | @Component |
| 6 | export default struct MinePagePersonFunctionUI { | 9 | export default struct MinePagePersonFunctionUI { |
| 7 | @Link personalData:MinePagePersonalFunctionsItem[] | 10 | @Link personalData:MinePagePersonalFunctionsItem[] |
| @@ -62,6 +65,7 @@ export default struct MinePagePersonFunctionUI { | @@ -62,6 +65,7 @@ export default struct MinePagePersonFunctionUI { | ||
| 62 | WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | 65 | WDRouterRule.jumpWithPage(WDRouterPage.loginPage) |
| 63 | return | 66 | return |
| 64 | } | 67 | } |
| 68 | + this.messageClick() | ||
| 65 | WDRouterRule.jumpWithPage(WDRouterPage.mineMessagePage) | 69 | WDRouterRule.jumpWithPage(WDRouterPage.mineMessagePage) |
| 66 | break; | 70 | break; |
| 67 | } | 71 | } |
| @@ -75,5 +79,13 @@ export default struct MinePagePersonFunctionUI { | @@ -75,5 +79,13 @@ export default struct MinePagePersonFunctionUI { | ||
| 75 | .height('234lpx') | 79 | .height('234lpx') |
| 76 | .margin({top:'31lpx',left:'23lpx',right:'23lpx' }) | 80 | .margin({top:'31lpx',left:'23lpx',right:'23lpx' }) |
| 77 | } | 81 | } |
| 82 | + | ||
| 83 | + messageClick(){ | ||
| 84 | + MinePageDatasModel.sendClickMessageData().then((value) => { | ||
| 85 | + console.log(TAG, "进入消息页面") | ||
| 86 | + }).catch((err: Error) => { | ||
| 87 | + console.log(TAG, JSON.stringify(err)) | ||
| 88 | + }) | ||
| 89 | + } | ||
| 78 | } | 90 | } |
| 79 | 91 |
sight_harmony/features/wdComponent/src/main/ets/components/mine/message/MessageListItemUI.ets
0 → 100644
| 1 | +import { StringUtils } from 'wdKit/Index' | ||
| 2 | +import { MessageItem } from '../../../viewmodel/MessageItem' | ||
| 3 | + | ||
| 4 | +const TAG = "MessageListUI" | ||
| 5 | + | ||
| 6 | +@Component | ||
| 7 | +export struct MessageListItemUI { | ||
| 8 | + @ObjectLink item: MessageItem | ||
| 9 | + @State index:number = -1 | ||
| 10 | + | ||
| 11 | + build() { | ||
| 12 | + Column(){ | ||
| 13 | + Column() { | ||
| 14 | + Row() { | ||
| 15 | + Row() { | ||
| 16 | + Image(this.item.imgSrc) | ||
| 17 | + .objectFit(ImageFit.Auto) | ||
| 18 | + .width('92lpx') | ||
| 19 | + .height('92lpx') | ||
| 20 | + .margin({ right: '15lpx' }) | ||
| 21 | + | ||
| 22 | + Column() { | ||
| 23 | + Text(this.item.title) | ||
| 24 | + .fontWeight(500) | ||
| 25 | + .fontSize('31lpx') | ||
| 26 | + .lineHeight('42lpx') | ||
| 27 | + .fontColor($r('app.color.color_222222')) | ||
| 28 | + .maxLines(1) | ||
| 29 | + .margin({ bottom: StringUtils.isNotEmpty(this.item.desc)?'8lpx':0 }) | ||
| 30 | + | ||
| 31 | + if(StringUtils.isNotEmpty(this.item.desc)){ | ||
| 32 | + Text(`${this.item.desc}`) | ||
| 33 | + .fontColor($r('app.color.color_999999')) | ||
| 34 | + .fontSize('27lpx') | ||
| 35 | + .lineHeight('38lpx') | ||
| 36 | + .fontWeight(400) | ||
| 37 | + .maxLines(1) | ||
| 38 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 39 | + } | ||
| 40 | + } | ||
| 41 | + .height('92lpx') | ||
| 42 | + .layoutWeight(1) | ||
| 43 | + .alignItems(HorizontalAlign.Start) | ||
| 44 | + .justifyContent(StringUtils.isNotEmpty(this.item.desc)?FlexAlign.Start:FlexAlign.Center) | ||
| 45 | + }.layoutWeight(1) | ||
| 46 | + | ||
| 47 | + Column() { | ||
| 48 | + Text(`${this.item.time}`) | ||
| 49 | + .fontColor($r('app.color.color_999999')) | ||
| 50 | + .fontSize('23lpx') | ||
| 51 | + .fontWeight(500) | ||
| 52 | + .lineHeight('35lpx') | ||
| 53 | + .margin({ bottom: this.item.unReadCount > 0 ?'8lpx':0 }) | ||
| 54 | + | ||
| 55 | + if(this.item.unReadCount > 0){ | ||
| 56 | + Button(){ | ||
| 57 | + Text(`${this.item.unReadCount}`) | ||
| 58 | + .fontWeight(400) | ||
| 59 | + .fontSize("18lpx") | ||
| 60 | + .fontColor($r('app.color.white')) | ||
| 61 | + } | ||
| 62 | + .type((this.item.unReadCount>0 && this.item.unReadCount < 10 ? ButtonType.Circle:ButtonType.Capsule)) | ||
| 63 | + .backgroundColor($r("app.color.color_ED2800")) | ||
| 64 | + .stateEffect(false) | ||
| 65 | + .height("27lpx") | ||
| 66 | + .constraintSize({minWidth:"27lpx"}) | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | + .justifyContent(FlexAlign.Start) | ||
| 70 | + .alignItems(HorizontalAlign.End) | ||
| 71 | + .height('92lpx') | ||
| 72 | + } | ||
| 73 | + .width('100%') | ||
| 74 | + .height('92lpx') | ||
| 75 | + .justifyContent(FlexAlign.SpaceBetween) | ||
| 76 | + | ||
| 77 | + }.height('154lpx') | ||
| 78 | + .width("100%") | ||
| 79 | + .justifyContent(FlexAlign.Center) | ||
| 80 | + | ||
| 81 | + Text().backgroundColor($r('app.color.color_EDEDED')) | ||
| 82 | + .width('100%') | ||
| 83 | + .height('1lpx') | ||
| 84 | + .visibility(this.index != 3 ?Visibility.Visible:Visibility.None) | ||
| 85 | + } | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + | ||
| 89 | +} |
| 1 | -import { StringUtils, ToastUtils } from 'wdKit/Index' | 1 | +import { DateTimeUtils, StringUtils, ToastUtils } from 'wdKit/Index' |
| 2 | import { WDRouterPage, WDRouterRule } from 'wdRouter/Index' | 2 | import { WDRouterPage, WDRouterRule } from 'wdRouter/Index' |
| 3 | import MinePageDatasModel from '../../../model/MinePageDatasModel' | 3 | import MinePageDatasModel from '../../../model/MinePageDatasModel' |
| 4 | import { MessageItem } from '../../../viewmodel/MessageItem' | 4 | import { MessageItem } from '../../../viewmodel/MessageItem' |
| 5 | import { CustomTitleUI } from '../../reusable/CustomTitleUI' | 5 | import { CustomTitleUI } from '../../reusable/CustomTitleUI' |
| 6 | +import { MessageListItemUI } from './MessageListItemUI' | ||
| 6 | 7 | ||
| 7 | const TAG = "MessageListUI" | 8 | const TAG = "MessageListUI" |
| 8 | 9 | ||
| @@ -12,84 +13,143 @@ export struct MessageListUI { | @@ -12,84 +13,143 @@ export struct MessageListUI { | ||
| 12 | 13 | ||
| 13 | aboutToAppear() { | 14 | aboutToAppear() { |
| 14 | this.msgData = MinePageDatasModel.getMessageData() | 15 | this.msgData = MinePageDatasModel.getMessageData() |
| 16 | + this.getHistoryPush() | ||
| 17 | + this.getMessagePush() | ||
| 15 | } | 18 | } |
| 16 | 19 | ||
| 17 | - build() { | ||
| 18 | - Column() { | ||
| 19 | - //标题栏目 | ||
| 20 | - CustomTitleUI({ titleName: "消息" }) | 20 | + //历史推送 |
| 21 | + getHistoryPush() { | ||
| 22 | + MinePageDatasModel.getHistoryPushData("1", "1").then((value) => { | ||
| 23 | + if (value != null && value.list != null && value.list.length > 0) { | ||
| 24 | + this.msgData.forEach((item) => { | ||
| 25 | + if (item.title == "历史推送") { | ||
| 26 | + if (value.list != null && value.list[0] != null) { | ||
| 27 | + if (value.list[0].newsTitle) { | ||
| 28 | + item.desc = value.list[0].newsTitle | ||
| 29 | + } | ||
| 30 | + if (value.list[0].publishTime) { | ||
| 31 | + item.time = this.getPublishTime("",value.list[0].publishTime) | ||
| 32 | + } | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | + }) | ||
| 36 | + } | ||
| 37 | + }).catch((err: Error) => { | ||
| 38 | + console.log(TAG, JSON.stringify(err)) | ||
| 39 | + }) | ||
| 40 | + } | ||
| 21 | 41 | ||
| 22 | - List() { | ||
| 23 | - ForEach(this.msgData, (item: MessageItem, index: number) => { | ||
| 24 | - ListItem() { | ||
| 25 | - Column(){ | ||
| 26 | - Column() { | ||
| 27 | - Row() { | ||
| 28 | - Row() { | ||
| 29 | - Image(item.imgSrc) | ||
| 30 | - .objectFit(ImageFit.Auto) | ||
| 31 | - .width('92lpx') | ||
| 32 | - .height('92lpx') | ||
| 33 | - .margin({ right: '15lpx' }) | 42 | + //互动消息 预约消息 系统消息 |
| 43 | + getMessagePush() { | ||
| 44 | + MinePageDatasModel.getMessageUnReadData().then((value) => { | ||
| 45 | + this.msgData.forEach((item) => { | ||
| 46 | + if (item.title == "预约消息") { | ||
| 47 | + if (value.subscribeInfo != null) { | ||
| 48 | + if (value.subscribeInfo.title) { | ||
| 49 | + item.desc = value.subscribeInfo.title | ||
| 50 | + } | ||
| 51 | + if (value.subscribeInfo.time) { | ||
| 52 | + item.time = this.getPublishTime(value.subscribeInfo.time,DateTimeUtils.getDateTimestamp(value.subscribeInfo.time)+"") | ||
| 53 | + } | ||
| 54 | + } | ||
| 55 | + if(value.subscribeCount > 0){ | ||
| 56 | + item.unReadCount = value.subscribeCount | ||
| 57 | + } | ||
| 58 | + } else if (item.title == "系统消息") { | ||
| 59 | + if (value.systemInfo != null) { | ||
| 60 | + if (value.systemInfo.title) { | ||
| 61 | + item.desc = value.systemInfo.title | ||
| 62 | + } | ||
| 63 | + if (value.systemInfo.time) { | ||
| 64 | + item.time = this.getPublishTime(value.subscribeInfo.time,DateTimeUtils.getDateTimestamp(value.systemInfo.time) + "") | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + if(value.systemCount > 0){ | ||
| 68 | + item.unReadCount = value.systemCount | ||
| 69 | + } | ||
| 70 | + }else if(item.title == "互动消息"){ | ||
| 71 | + if(value.activeCount > 0){ | ||
| 72 | + item.unReadCount = value.activeCount | ||
| 73 | + } | ||
| 74 | + if (value.activeInfo != null) { | ||
| 75 | + if (value.activeInfo.title) { | ||
| 76 | + item.desc = value.activeInfo.title | ||
| 77 | + } | ||
| 78 | + if (value.activeInfo.time) { | ||
| 79 | + item.time = this.getPublishTime(value.subscribeInfo.time,DateTimeUtils.getDateTimestamp(value.activeInfo.time) + "") | ||
| 80 | + } | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + }) | ||
| 84 | + }).catch((err: Error) => { | ||
| 85 | + console.log(TAG, JSON.stringify(err)) | ||
| 86 | + }) | ||
| 87 | + } | ||
| 34 | 88 | ||
| 35 | - Column() { | ||
| 36 | - Text(item.title) | ||
| 37 | - .fontWeight(500) | ||
| 38 | - .fontSize('31lpx') | ||
| 39 | - .lineHeight('42lpx') | ||
| 40 | - .fontColor($r('app.color.color_222222')) | ||
| 41 | - .maxLines(1) | ||
| 42 | - .margin({ bottom: StringUtils.isNotEmpty(item.desc)?'8lpx':0 }) | 89 | + getPublishTime(data:string,publishTime: string): string { |
| 90 | + const publishTimestamp = parseInt(publishTime) | ||
| 91 | + const currentTime = Date.now(); // 当前时间戳 | ||
| 43 | 92 | ||
| 44 | - if(StringUtils.isNotEmpty(item.desc)){ | ||
| 45 | - Text(`${item.desc}`) | ||
| 46 | - .fontColor($r('app.color.color_B0B0B0')) | ||
| 47 | - .fontSize('23lpx') | ||
| 48 | - .lineHeight('38lpx') | ||
| 49 | - .fontWeight(400) | ||
| 50 | - .maxLines(1) | ||
| 51 | - .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 52 | - } | ||
| 53 | - } | ||
| 54 | - .height('92lpx') | ||
| 55 | - .layoutWeight(1) | ||
| 56 | - .alignItems(HorizontalAlign.Start) | ||
| 57 | - .justifyContent(StringUtils.isNotEmpty(item.desc)?FlexAlign.Start:FlexAlign.Center) | ||
| 58 | - }.layoutWeight(1) | 93 | + // 计算差异 |
| 94 | + const timeDifference = currentTime - publishTimestamp; | ||
| 59 | 95 | ||
| 60 | - Row() { | ||
| 61 | - Text(`${item.time}`) | ||
| 62 | - .fontColor($r('app.color.color_999999')) | ||
| 63 | - .fontSize('23lpx') | ||
| 64 | - .fontWeight(500) | ||
| 65 | - .lineHeight('35lpx') | 96 | + // 转换为分钟、小时和天 |
| 97 | + const minutes = Math.floor(timeDifference / (1000 * 60)); | ||
| 98 | + const hours = Math.floor(timeDifference / (1000 * 60 * 60)); | ||
| 99 | + const days = Math.floor(timeDifference / (1000 * 60 * 60 * 24)); | ||
| 100 | + | ||
| 101 | + // 根据时间差返回对应的字符串 | ||
| 102 | + let result: string; | ||
| 103 | + | ||
| 104 | + if (minutes < 60) { | ||
| 105 | + result = `${minutes}分钟前`; | ||
| 106 | + if(minutes === 0){ | ||
| 107 | + result = `刚刚`; | ||
| 108 | + } | ||
| 109 | + } else if (hours < 24) { | ||
| 110 | + result = `${hours}小时前`; | ||
| 111 | + } else { | ||
| 112 | + result = `${days}天前`; | ||
| 113 | + if(days > 1){ | ||
| 114 | + let arr = data.split(" ") | ||
| 115 | + if(arr.length === 2){ | ||
| 116 | + let arr2 = arr[0].split("-") | ||
| 117 | + if(arr2.length === 3){ | ||
| 118 | + result = `${arr2[1]}-${arr2[2]}` | ||
| 119 | + } | ||
| 120 | + }else{ | ||
| 121 | + //原始数据是时间戳 需要转成dateString | ||
| 122 | + let time = DateTimeUtils.formatDate(Number(publishTime)) | ||
| 123 | + let arr = time.split("-") | ||
| 124 | + if(arr.length === 3){ | ||
| 125 | + result = `${arr[1]}-${arr[2]}` | ||
| 126 | + } | ||
| 127 | + } | ||
| 66 | } | 128 | } |
| 67 | - .justifyContent(FlexAlign.Start) | ||
| 68 | - .alignItems(VerticalAlign.Top) | ||
| 69 | - .height('92lpx') | ||
| 70 | } | 129 | } |
| 71 | - .width('100%') | ||
| 72 | - .height('92lpx') | ||
| 73 | - .justifyContent(FlexAlign.SpaceBetween) | ||
| 74 | - | ||
| 75 | - }.height('154lpx') | ||
| 76 | - .width("100%") | ||
| 77 | - .justifyContent(FlexAlign.Center) | ||
| 78 | 130 | ||
| 79 | - Text().backgroundColor($r('app.color.color_EDEDED')) | ||
| 80 | - .width('100%') | ||
| 81 | - .height('1lpx') | ||
| 82 | - .visibility(index != 3 ?Visibility.Visible:Visibility.None) | 131 | + console.log(result); |
| 132 | + return result | ||
| 83 | } | 133 | } |
| 134 | + | ||
| 135 | + build() { | ||
| 136 | + Column() { | ||
| 137 | + //标题栏目 | ||
| 138 | + CustomTitleUI({ titleName: "消息" }) | ||
| 139 | + | ||
| 140 | + List() { | ||
| 141 | + ForEach(this.msgData, (item: MessageItem, index: number) => { | ||
| 142 | + ListItem() { | ||
| 143 | + MessageListItemUI({ item: item, index: index }) | ||
| 84 | } | 144 | } |
| 85 | - .padding({left:"31lpx",right:"31lpx"}) | 145 | + .padding({ left: "31lpx", right: "31lpx" }) |
| 86 | .onClick(() => { | 146 | .onClick(() => { |
| 87 | - ToastUtils.shortToast(index+"") | ||
| 88 | switch (index) { | 147 | switch (index) { |
| 89 | case 0: //互动消息 | 148 | case 0: //互动消息 |
| 90 | WDRouterRule.jumpWithPage(WDRouterPage.interactMessagePage) | 149 | WDRouterRule.jumpWithPage(WDRouterPage.interactMessagePage) |
| 91 | break; | 150 | break; |
| 92 | case 1: //预约消息 | 151 | case 1: //预约消息 |
| 152 | + WDRouterRule.jumpWithPage(WDRouterPage.subscribeMessagePage) | ||
| 93 | break; | 153 | break; |
| 94 | case 2: //历史推送 | 154 | case 2: //历史推送 |
| 95 | break; | 155 | break; |
| 1 | +import { SubscribeMessageModel } from '../../../../model/InteractMessageModel' | ||
| 2 | + | ||
| 3 | +@Component | ||
| 4 | +export struct SubscribeListChildComponent{ | ||
| 5 | + @ObjectLink item: SubscribeMessageModel | ||
| 6 | + | ||
| 7 | + build() { | ||
| 8 | + Column(){ | ||
| 9 | + Row(){ | ||
| 10 | + Text(`${this.item.dealTime}`) | ||
| 11 | + .margin({top:"31lpx",bottom:"23lpx"}) | ||
| 12 | + .fontWeight(400) | ||
| 13 | + .fontSize("23lpx") | ||
| 14 | + .lineHeight("33lpx") | ||
| 15 | + .fontColor($r('app.color.color_999999')) | ||
| 16 | + }.width('100%') | ||
| 17 | + .backgroundColor($r('app.color.color_F5F5F5')) | ||
| 18 | + .justifyContent(FlexAlign.Center) | ||
| 19 | + | ||
| 20 | + Column(){ | ||
| 21 | + Column(){ | ||
| 22 | + Text(`${this.item.title}`) | ||
| 23 | + .fontSize("31lpx") | ||
| 24 | + .lineHeight("46lpx") | ||
| 25 | + .fontWeight(500) | ||
| 26 | + .fontColor($r('app.color.color_333333')) | ||
| 27 | + .margin({top:"27lpx",bottom:"25lpx"}) | ||
| 28 | + .maxLines(1) | ||
| 29 | + | ||
| 30 | + Text().backgroundColor($r('app.color.color_F5F5F5')) | ||
| 31 | + .width('100%') | ||
| 32 | + .height('1lpx') | ||
| 33 | + }.alignItems(HorizontalAlign.Start) | ||
| 34 | + .width("100%") | ||
| 35 | + .height("98lpx") | ||
| 36 | + | ||
| 37 | + Row(){ | ||
| 38 | + Image(`${this.item.imgUrl}`) | ||
| 39 | + .width('204lpx') | ||
| 40 | + .height('115lpx') | ||
| 41 | + .borderRadius("6lpx") | ||
| 42 | + .objectFit(ImageFit.Auto) | ||
| 43 | + .margin({right:"23lpx"}) | ||
| 44 | + | ||
| 45 | + Text(`${this.item.desc}`) | ||
| 46 | + .fontSize("27lpx") | ||
| 47 | + .lineHeight("38lpx") | ||
| 48 | + .fontWeight(400) | ||
| 49 | + .fontColor($r('app.color.color_222222')) | ||
| 50 | + .layoutWeight(1) | ||
| 51 | + }.alignItems(VerticalAlign.Center) | ||
| 52 | + .width("100%") | ||
| 53 | + .height("160lpx") | ||
| 54 | + | ||
| 55 | + Text().backgroundColor($r('app.color.color_F5F5F5')) | ||
| 56 | + .width('100%') | ||
| 57 | + .height('1lpx') | ||
| 58 | + | ||
| 59 | + Row(){ | ||
| 60 | + Text(`${this.item.time}开始`) | ||
| 61 | + .fontSize("23lpx") | ||
| 62 | + .fontWeight(600) | ||
| 63 | + .lineHeight("31lpx") | ||
| 64 | + | ||
| 65 | + Row(){ | ||
| 66 | + Text("查看详情") | ||
| 67 | + .fontSize("23lpx") | ||
| 68 | + .lineHeight("38lpx") | ||
| 69 | + .fontWeight(400) | ||
| 70 | + .fontColor($r('app.color.color_666666')) | ||
| 71 | + .margin({right:"8lpx"}) | ||
| 72 | + | ||
| 73 | + Image($r('app.media.subscribe_arrow_icon')) | ||
| 74 | + .width('23lpx') | ||
| 75 | + .height('13lpx') | ||
| 76 | + .objectFit(ImageFit.Auto) | ||
| 77 | + .interpolation(ImageInterpolation.High) | ||
| 78 | + .margin({right:"4lpx"}) | ||
| 79 | + } | ||
| 80 | + }.alignItems(VerticalAlign.Center) | ||
| 81 | + .justifyContent(FlexAlign.SpaceBetween) | ||
| 82 | + .width("100%") | ||
| 83 | + .height("73lpx") | ||
| 84 | + | ||
| 85 | + }.backgroundColor($r('app.color.white')) | ||
| 86 | + .borderRadius("8lpx") | ||
| 87 | + .width("100%") | ||
| 88 | + .padding({left:"23lpx",right:"23lpx"}) | ||
| 89 | + } | ||
| 90 | + .backgroundColor($r('app.color.color_F5F5F5')) | ||
| 91 | + .width("100%") | ||
| 92 | + .padding({left:"31lpx",right:"31lpx"}) | ||
| 93 | + .alignItems(HorizontalAlign.Center) | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + | ||
| 97 | +} |
| 1 | +import { LazyDataSource, StringUtils } from 'wdKit/Index'; | ||
| 2 | +import { Remark, SubscribeMessageModel, | ||
| 3 | + WDMessageCenterMessageType } from '../../../../model/InteractMessageModel'; | ||
| 4 | +import MinePageDatasModel from '../../../../model/MinePageDatasModel'; | ||
| 5 | +import { CustomTitleUI } from '../../../reusable/CustomTitleUI'; | ||
| 6 | +import { ListHasNoMoreDataUI } from '../../../reusable/ListHasNoMoreDataUI'; | ||
| 7 | +import { EmptyComponent } from '../../../view/EmptyComponent'; | ||
| 8 | +import { SubscribeListChildComponent } from './SubscribeListChildComponent'; | ||
| 9 | + | ||
| 10 | +const TAG = "SubscribeMessageComponent" | ||
| 11 | + | ||
| 12 | +@Component | ||
| 13 | +export struct SubscribeMessageComponent{ | ||
| 14 | + @State data: LazyDataSource<SubscribeMessageModel> = new LazyDataSource(); | ||
| 15 | + @State count: number = 0; | ||
| 16 | + @State isLoading: boolean = false | ||
| 17 | + @State hasMore: boolean = true | ||
| 18 | + curPageNum: number = 1; | ||
| 19 | + @State isGetRequest: boolean = false | ||
| 20 | + | ||
| 21 | + aboutToAppear() { | ||
| 22 | + this.getNewPageData() | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + build() { | ||
| 26 | + Column() { | ||
| 27 | + //标题栏目 | ||
| 28 | + CustomTitleUI({ titleName: "预约消息" }) | ||
| 29 | + if (this.count == 0) { | ||
| 30 | + if (this.isGetRequest == true) { | ||
| 31 | + EmptyComponent({ emptyType: 5 }) | ||
| 32 | + .height('100%') | ||
| 33 | + .width('100%') | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + } else { | ||
| 37 | + //刷新控件 TODO | ||
| 38 | + //List | ||
| 39 | + List() { | ||
| 40 | + LazyForEach(this.data, (item: SubscribeMessageModel, index: number) => { | ||
| 41 | + ListItem() { | ||
| 42 | + SubscribeListChildComponent({ item: item }) | ||
| 43 | + }.width('100%') | ||
| 44 | + .onClick(() => { | ||
| 45 | + }) | ||
| 46 | + }) | ||
| 47 | + | ||
| 48 | + //没有更多数据 显示提示 | ||
| 49 | + if (!this.hasMore) { | ||
| 50 | + ListItem() { | ||
| 51 | + ListHasNoMoreDataUI() | ||
| 52 | + } | ||
| 53 | + } | ||
| 54 | + }.width('100%') | ||
| 55 | + .cachedCount(4) | ||
| 56 | + .scrollBar(BarState.Off) | ||
| 57 | + .layoutWeight(1) | ||
| 58 | + .onReachEnd(() => { | ||
| 59 | + if (!this.isLoading) { | ||
| 60 | + //加载分页数据 | ||
| 61 | + this.getNewPageData() | ||
| 62 | + } | ||
| 63 | + }) | ||
| 64 | + } | ||
| 65 | + } | ||
| 66 | + .backgroundColor($r('app.color.color_F9F9F9')) | ||
| 67 | + .height('100%') | ||
| 68 | + .width('100%') | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + getNewPageData() { | ||
| 72 | + this.isLoading = true | ||
| 73 | + if (this.hasMore) { | ||
| 74 | + MinePageDatasModel.getSubscribeMessageData(WDMessageCenterMessageType.WDMessageCenterMessageType_Subscribe,"20",`${this.curPageNum}`).then((value) => { | ||
| 75 | + if (!this.data || value.list.length == 0) { | ||
| 76 | + this.hasMore = false | ||
| 77 | + } else { | ||
| 78 | + value.list.forEach((value) => { | ||
| 79 | + let dealTime = this.DealStartTime(value.time,1) | ||
| 80 | + let dealTime2 = this.DealStartTime(value.time,2) | ||
| 81 | + | ||
| 82 | + let remark = JSON.parse(value.remark) as Remark | ||
| 83 | + | ||
| 84 | + this.data.push(new SubscribeMessageModel(dealTime,value.message,remark.coverImageUrl,value.title,dealTime2,value.contentId)) | ||
| 85 | + }) | ||
| 86 | + this.data.notifyDataReload() | ||
| 87 | + this.count = this.data.totalCount() | ||
| 88 | + if (this.data.totalCount() < value.totalCount) { | ||
| 89 | + this.curPageNum++ | ||
| 90 | + } else { | ||
| 91 | + this.hasMore = false | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + this.isGetRequest = true | ||
| 95 | + this.isLoading = false | ||
| 96 | + }).catch((err: Error) => { | ||
| 97 | + console.log(TAG, JSON.stringify(err)) | ||
| 98 | + this.isGetRequest = true | ||
| 99 | + this.isLoading = false | ||
| 100 | + }) | ||
| 101 | + } | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + | ||
| 105 | + DealStartTime(planStartTime: string,type:number): string { | ||
| 106 | + let dealData: string = "" | ||
| 107 | + | ||
| 108 | + if (StringUtils.isEmpty(planStartTime)) { | ||
| 109 | + console.log(TAG, "格式有误") | ||
| 110 | + return planStartTime | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + if (planStartTime.indexOf(" ") === -1) { | ||
| 114 | + console.log(TAG, "格式有误") | ||
| 115 | + return planStartTime | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + let arr = planStartTime.split(" ") | ||
| 119 | + if (arr != null && StringUtils.isNotEmpty(arr[0])) { //处理年月日 | ||
| 120 | + let time = arr[0].split("-"); | ||
| 121 | + if (time.length === 3) { | ||
| 122 | + dealData = `${time[1]}-${time[2]}` | ||
| 123 | + if(type === 1){ | ||
| 124 | + return dealData | ||
| 125 | + } | ||
| 126 | + } | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + if (arr != null && StringUtils.isNotEmpty(arr[1])) { //处理时分 | ||
| 130 | + let time = arr[1].split(":"); | ||
| 131 | + if (time.length === 3) { | ||
| 132 | + dealData = `${dealData} ${time[0]}:${time[1]}` | ||
| 133 | + } | ||
| 134 | + } | ||
| 135 | + console.log(TAG, JSON.stringify(dealData)) | ||
| 136 | + return dealData | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + | ||
| 140 | +} |
| @@ -32,6 +32,9 @@ export struct MinePageComponent { | @@ -32,6 +32,9 @@ export struct MinePageComponent { | ||
| 32 | }else { | 32 | }else { |
| 33 | this.isLogin = true | 33 | this.isLogin = true |
| 34 | this.addRecordDialog() | 34 | this.addRecordDialog() |
| 35 | + if(this.personalData.length > 0){ | ||
| 36 | + this.getMessageData() | ||
| 37 | + } | ||
| 35 | } | 38 | } |
| 36 | } | 39 | } |
| 37 | } | 40 | } |
| @@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
| 4 | */ | 4 | */ |
| 5 | export const enum WDMessageCenterMessageType { | 5 | export const enum WDMessageCenterMessageType { |
| 6 | WDMessageCenterMessageType_Interact = 1, //互动通知 | 6 | WDMessageCenterMessageType_Interact = 1, //互动通知 |
| 7 | - WDMessageCenterMessageType_Subscribe, //预约消息 | 7 | + WDMessageCenterMessageType_Subscribe = 2, //预约消息 |
| 8 | WDMessageCenterMessageType_System, //系统消息 | 8 | WDMessageCenterMessageType_System, //系统消息 |
| 9 | } | 9 | } |
| 10 | 10 | ||
| @@ -81,3 +81,29 @@ export interface InteractMDTO{ | @@ -81,3 +81,29 @@ export interface InteractMDTO{ | ||
| 81 | data: number; | 81 | data: number; |
| 82 | timestamp?: number; | 82 | timestamp?: number; |
| 83 | } | 83 | } |
| 84 | + | ||
| 85 | +@Observed | ||
| 86 | +export class SubscribeMessageModel{ | ||
| 87 | + dealTime:string = "" | ||
| 88 | + title:string = "" | ||
| 89 | + imgUrl:string = "" | ||
| 90 | + desc:string = "" | ||
| 91 | + time:string = "" | ||
| 92 | + contentId:string = "" | ||
| 93 | + | ||
| 94 | + constructor(dealTime: string, title: string, imgUrl: string, desc: string , time: string, contentId: string) { | ||
| 95 | + this.dealTime = dealTime | ||
| 96 | + this.title = title | ||
| 97 | + this.imgUrl = imgUrl | ||
| 98 | + this.desc = desc | ||
| 99 | + this.time = time | ||
| 100 | + this.contentId = contentId | ||
| 101 | + } | ||
| 102 | +} | ||
| 103 | + | ||
| 104 | +export class Remark{ | ||
| 105 | + relationType:string = "" | ||
| 106 | + coverImageUrl:string = "" | ||
| 107 | + relationId:string = "" | ||
| 108 | + status:string = "" | ||
| 109 | +} |
| @@ -25,6 +25,9 @@ import { FollowOperationRequestItem } from '../viewmodel/FollowOperationRequestI | @@ -25,6 +25,9 @@ import { FollowOperationRequestItem } from '../viewmodel/FollowOperationRequestI | ||
| 25 | import { SpConstants } from 'wdConstant/Index'; | 25 | import { SpConstants } from 'wdConstant/Index'; |
| 26 | import { MessageItem } from '../viewmodel/MessageItem'; | 26 | import { MessageItem } from '../viewmodel/MessageItem'; |
| 27 | import { MessageUnReadItem } from '../viewmodel/MessageUnReadItem'; | 27 | import { MessageUnReadItem } from '../viewmodel/MessageUnReadItem'; |
| 28 | +import { HistoryPushDataItem } from '../viewmodel/HistoryPushDataItem'; | ||
| 29 | +import { HashMap } from '@kit.ArkTS'; | ||
| 30 | +import { InteractMessageMItem } from './InteractMessageModel'; | ||
| 28 | 31 | ||
| 29 | const TAG = "MinePageDatasModel" | 32 | const TAG = "MinePageDatasModel" |
| 30 | 33 | ||
| @@ -601,8 +604,6 @@ class MinePageDatasModel{ | @@ -601,8 +604,6 @@ class MinePageDatasModel{ | ||
| 601 | 604 | ||
| 602 | /** | 605 | /** |
| 603 | * 获取消息未读数据 | 606 | * 获取消息未读数据 |
| 604 | - * @param pageSize | ||
| 605 | - * @param pageNum | ||
| 606 | * @returns | 607 | * @returns |
| 607 | */ | 608 | */ |
| 608 | getMessageUnReadData(): Promise<MessageUnReadItem> { | 609 | getMessageUnReadData(): Promise<MessageUnReadItem> { |
| @@ -625,6 +626,81 @@ class MinePageDatasModel{ | @@ -625,6 +626,81 @@ class MinePageDatasModel{ | ||
| 625 | return WDHttp.get<ResponseDTO<MessageUnReadItem>>(url) | 626 | return WDHttp.get<ResponseDTO<MessageUnReadItem>>(url) |
| 626 | }; | 627 | }; |
| 627 | 628 | ||
| 629 | + /** | ||
| 630 | + * 点击消息(进入消息页面) | ||
| 631 | + * @returns | ||
| 632 | + */ | ||
| 633 | + sendClickMessageData(): Promise<String> { | ||
| 634 | + return new Promise<String>((success, error) => { | ||
| 635 | + this.fetchClickMessageData().then((navResDTO: ResponseDTO<String>) => { | ||
| 636 | + if (!navResDTO || navResDTO.code != 0) { | ||
| 637 | + error(null) | ||
| 638 | + return | ||
| 639 | + } | ||
| 640 | + success("1"); | ||
| 641 | + }).catch((err: Error) => { | ||
| 642 | + error(err) | ||
| 643 | + }) | ||
| 644 | + }) | ||
| 645 | + } | ||
| 646 | + | ||
| 647 | + fetchClickMessageData() { | ||
| 648 | + let url = HttpUrlUtils.getSendClickMessageUrl() | ||
| 649 | + return WDHttp.get<ResponseDTO<String>>(url) | ||
| 650 | + }; | ||
| 651 | + | ||
| 652 | + /** | ||
| 653 | + * 历史推送消息 | ||
| 654 | + * @returns | ||
| 655 | + */ | ||
| 656 | + getHistoryPushData(pageSize:string,pageNum:string): Promise<HistoryPushDataItem> { | ||
| 657 | + return new Promise<HistoryPushDataItem>((success, error) => { | ||
| 658 | + this.fetchHistoryPushData(pageSize,pageNum).then((navResDTO: ResponseDTO<HistoryPushDataItem>) => { | ||
| 659 | + if (!navResDTO || navResDTO.code != 0) { | ||
| 660 | + error(null) | ||
| 661 | + return | ||
| 662 | + } | ||
| 663 | + let navigationBean = navResDTO.data as HistoryPushDataItem | ||
| 664 | + success(navigationBean); | ||
| 665 | + }).catch((err: Error) => { | ||
| 666 | + error(err) | ||
| 667 | + }) | ||
| 668 | + }) | ||
| 669 | + } | ||
| 670 | + | ||
| 671 | + fetchHistoryPushData(pageSize:string,pageNum:string) { | ||
| 672 | + let url = HttpUrlUtils.getHistoryPushUrl()+ `?pageSize=${pageSize}&pageNum=${pageNum}` | ||
| 673 | + let headers: HashMap<string, string> = new HashMap<string, string>(); | ||
| 674 | + headers.set('system', 'Android'); | ||
| 675 | + return WDHttp.get<ResponseDTO<HistoryPushDataItem>>(url, headers) | ||
| 676 | + }; | ||
| 677 | + | ||
| 678 | + /** | ||
| 679 | + * 推送消息 | ||
| 680 | + * @returns | ||
| 681 | + */ | ||
| 682 | + getSubscribeMessageData(contentType:number,pageSize:string,pageNum:string): Promise<InteractMessageMItem> { | ||
| 683 | + return new Promise<InteractMessageMItem>((success, error) => { | ||
| 684 | + this.fetchSubscribeMessageData(contentType,pageSize,pageNum).then((navResDTO: ResponseDTO<InteractMessageMItem>) => { | ||
| 685 | + if (!navResDTO || navResDTO.code != 0) { | ||
| 686 | + error(null) | ||
| 687 | + return | ||
| 688 | + } | ||
| 689 | + let navigationBean = navResDTO.data as InteractMessageMItem | ||
| 690 | + success(navigationBean); | ||
| 691 | + }).catch((err: Error) => { | ||
| 692 | + error(err) | ||
| 693 | + }) | ||
| 694 | + }) | ||
| 695 | + } | ||
| 696 | + | ||
| 697 | + fetchSubscribeMessageData(contentType:number,pageSize:string,pageNum:string) { | ||
| 698 | + let userID = HttpUtils.getUserId(); | ||
| 699 | + let url = HttpUrlUtils.getMessageListDataUrl()+`?createTime=${''}&contentType=${contentType}&userId=${userID}&pageSize=${pageSize}&pageNum=${pageNum}` | ||
| 700 | + return WDHttp.get<ResponseDTO<InteractMessageMItem>>(url) | ||
| 701 | + }; | ||
| 702 | + | ||
| 703 | + | ||
| 628 | } | 704 | } |
| 629 | 705 | ||
| 630 | const minePageDatasModel = MinePageDatasModel.getInstance() | 706 | const minePageDatasModel = MinePageDatasModel.getInstance() |
| 1 | +export class HistoryPushDataItem{ | ||
| 2 | + hasNext: number = 0 | ||
| 3 | + list: Array< HistoryPushItem > = [] | ||
| 4 | + pageNum: number = 0 | ||
| 5 | + pageSize: number = 0 | ||
| 6 | + totalCount: number = 0 | ||
| 7 | +} | ||
| 8 | + | ||
| 9 | +export class HistoryPushItem{ | ||
| 10 | + activityExt?: null | ||
| 11 | + appStyle: string = "" | ||
| 12 | + askInfo?: null | ||
| 13 | + axisColor: string = "" | ||
| 14 | + bestNoticer?: null | ||
| 15 | + bottomNavId?: null | ||
| 16 | + cardItemId: string = "" | ||
| 17 | + channelId: number= 0 | ||
| 18 | + commentInfo?: null | ||
| 19 | + corner: string = "" | ||
| 20 | + coverSize: string = "" | ||
| 21 | + coverType?: number | ||
| 22 | + coverUrl: string = "" | ||
| 23 | + expIds: string = "" | ||
| 24 | + extra: string = "" | ||
| 25 | + fullColumnImgUrls: Array< FullColumnImgUrl > = [] | ||
| 26 | + hasMore?: null | ||
| 27 | + itemId: string = "" | ||
| 28 | + itemType: string = "" | ||
| 29 | + itemTypeCode: string = "" | ||
| 30 | + keyArticle: number= 0 | ||
| 31 | + landscape?: null | ||
| 32 | + likeStyle?: null | ||
| 33 | + linkUrl: string = "" | ||
| 34 | + liveInfo?: null | ||
| 35 | + menuShow: number = 0 | ||
| 36 | + newTags: string = "" | ||
| 37 | + newsAuthor: string = "" | ||
| 38 | + newsSubTitle: string = "" | ||
| 39 | + newsSummary: string = "" | ||
| 40 | + newsTitle: string = "" | ||
| 41 | + newsTitleColor: string = "" | ||
| 42 | + objectId: string = "" | ||
| 43 | + objectLevel: string = "" | ||
| 44 | + objectType: string = "" | ||
| 45 | + openComment?: null | ||
| 46 | + openLikes?: null | ||
| 47 | + pageId: string = "" | ||
| 48 | + photoNum?: null | ||
| 49 | + position?: null | ||
| 50 | + productNum?: null | ||
| 51 | + publishTime: string = "" | ||
| 52 | + pushTime: number = 0 | ||
| 53 | + pushUnqueId: number = 0 | ||
| 54 | + readFlag: number = 0 | ||
| 55 | + recommend?: null | ||
| 56 | + relId: number = 0 | ||
| 57 | + relObjectId: string = "" | ||
| 58 | + relType: number = 0 | ||
| 59 | + rmhInfo?: null | ||
| 60 | + rmhPlatform: number = 0 | ||
| 61 | + sceneId: string = "" | ||
| 62 | + shareInfo?: null | ||
| 63 | + // slideShows: Array< unknown > | ||
| 64 | + sortValue?: null | ||
| 65 | + source: string = "" | ||
| 66 | + subObjectType: string = "" | ||
| 67 | + subSceneId: string = "" | ||
| 68 | + // tagIds: Array< unknown > | ||
| 69 | + tagWord?: null | ||
| 70 | + titleShow?: null | ||
| 71 | + titleShowPolicy?: null | ||
| 72 | + topicTemplate?: null | ||
| 73 | + traceId: string = "" | ||
| 74 | + traceInfo: string = "" | ||
| 75 | + userInfo?: null | ||
| 76 | + videoInfo?: null | ||
| 77 | + visitorComment: number = 0 | ||
| 78 | + voiceInfo?: null | ||
| 79 | +} | ||
| 80 | + | ||
| 81 | +export class FullColumnImgUrl{ | ||
| 82 | + | ||
| 83 | +} |
| 1 | +@Observed | ||
| 1 | export class MessageItem{ | 2 | export class MessageItem{ |
| 2 | imgSrc:Resource = $r("app.media.xxhdpi_pic_wb") | 3 | imgSrc:Resource = $r("app.media.xxhdpi_pic_wb") |
| 3 | title:string = "" | 4 | title:string = "" |
| 4 | desc:string = "" | 5 | desc:string = "" |
| 5 | time:string = "" | 6 | time:string = "" |
| 7 | + unReadCount:number = 0 | ||
| 6 | 8 | ||
| 7 | constructor(imgSrc:Resource,title:string,desc:string,time:string){ | 9 | constructor(imgSrc:Resource,title:string,desc:string,time:string){ |
| 8 | this.imgSrc = imgSrc | 10 | this.imgSrc = imgSrc |
sight_harmony/features/wdComponent/src/main/resources/base/media/subscribe_arrow_icon.png
0 → 100644
253 Bytes
| @@ -25,6 +25,7 @@ | @@ -25,6 +25,7 @@ | ||
| 25 | "pages/ShowUserHeaderPage", | 25 | "pages/ShowUserHeaderPage", |
| 26 | "pages/MineMessagePage", | 26 | "pages/MineMessagePage", |
| 27 | "components/page/InteractMessagePage", | 27 | "components/page/InteractMessagePage", |
| 28 | - "pages/ShowHomePageHeaderPage" | 28 | + "pages/ShowHomePageHeaderPage", |
| 29 | + "pages/SubscribeMessagePage" | ||
| 29 | ] | 30 | ] |
| 30 | } | 31 | } |
| @@ -4,21 +4,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; | @@ -4,21 +4,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; | ||
| 4 | import Want from '@ohos.app.ability.Want'; | 4 | import Want from '@ohos.app.ability.Want'; |
| 5 | import window from '@ohos.window'; | 5 | import window from '@ohos.window'; |
| 6 | import { BusinessError } from '@ohos.base'; | 6 | import { BusinessError } from '@ohos.base'; |
| 7 | -import { registerRouter } from 'wdRouter'; | ||
| 8 | -import { | ||
| 9 | - EmitterEventId, | ||
| 10 | - EmitterUtils, | ||
| 11 | - Logger, | ||
| 12 | - MpaasUtils, | ||
| 13 | - NetworkManager, | ||
| 14 | - NetworkType, | ||
| 15 | - SPHelper, | ||
| 16 | - StringUtils, | ||
| 17 | - UmengStats, | ||
| 18 | - WindowModel | ||
| 19 | -} from 'wdKit'; | ||
| 20 | -import { HostEnum, HostManager, WDHttp } from 'wdNetwork'; | ||
| 21 | -import { LoginModule } from 'wdLogin/src/main/ets/LoginModule'; | 7 | +import { EmitterEventId, EmitterUtils, WindowModel } from 'wdKit'; |
| 22 | import { ConfigurationConstant } from '@kit.AbilityKit'; | 8 | import { ConfigurationConstant } from '@kit.AbilityKit'; |
| 23 | import { WDPushNotificationManager } from 'wdHwAbility/Index'; | 9 | import { WDPushNotificationManager } from 'wdHwAbility/Index'; |
| 24 | import { StartupManager } from '../startupmanager/StartupManager'; | 10 | import { StartupManager } from '../startupmanager/StartupManager'; |
| @@ -60,7 +46,7 @@ export default class EntryAbility extends UIAbility { | @@ -60,7 +46,7 @@ export default class EntryAbility extends UIAbility { | ||
| 60 | AppStorage.setOrCreate('topSafeHeight', topSafeHeight); | 46 | AppStorage.setOrCreate('topSafeHeight', topSafeHeight); |
| 61 | AppStorage.setOrCreate('windowWidth', width); | 47 | AppStorage.setOrCreate('windowWidth', width); |
| 62 | AppStorage.setOrCreate('windowHeight', height); | 48 | AppStorage.setOrCreate('windowHeight', height); |
| 63 | - let audioWidth = px2vp(width)*0.65 | 49 | + let audioWidth = px2vp(width) * 0.65 |
| 64 | console.info('floatWindowClass audioWidth' + audioWidth); | 50 | console.info('floatWindowClass audioWidth' + audioWidth); |
| 65 | 51 | ||
| 66 | 52 | ||
| @@ -71,7 +57,8 @@ export default class EntryAbility extends UIAbility { | @@ -71,7 +57,8 @@ export default class EntryAbility extends UIAbility { | ||
| 71 | hilog.info(0x0000, 'testTag', 'setPreferredOrientation Succeeded'); | 57 | hilog.info(0x0000, 'testTag', 'setPreferredOrientation Succeeded'); |
| 72 | }) | 58 | }) |
| 73 | .catch((err: Error) => { | 59 | .catch((err: Error) => { |
| 74 | - hilog.error(0x0000, 'testTag', `setPreferredOrientation catch, error error.name : ${err.name}, error.message:${err.message}`); | 60 | + hilog.error(0x0000, 'testTag', |
| 61 | + `setPreferredOrientation catch, error error.name : ${err.name}, error.message:${err.message}`); | ||
| 75 | }) | 62 | }) |
| 76 | //../../../../../../features/wdLogin/src/main/ets/pages/launchPage/LaunchPage | 63 | //../../../../../../features/wdLogin/src/main/ets/pages/launchPage/LaunchPage |
| 77 | windowStage.loadContent('pages/launchPage/LaunchPage', (err, data) => { | 64 | windowStage.loadContent('pages/launchPage/LaunchPage', (err, data) => { |
| @@ -3,12 +3,12 @@ import { BreakpointConstants } from 'wdConstant'; | @@ -3,12 +3,12 @@ import { BreakpointConstants } from 'wdConstant'; | ||
| 3 | 3 | ||
| 4 | import { HWLocationUtils, WDPushNotificationManager } from 'wdHwAbility/Index'; | 4 | import { HWLocationUtils, WDPushNotificationManager } from 'wdHwAbility/Index'; |
| 5 | import { common } from '@kit.AbilityKit'; | 5 | import { common } from '@kit.AbilityKit'; |
| 6 | -import { BreakpointSystem, EmitterEventId, EmitterUtils, Logger, MpaasUpgradeCheck } from 'wdKit'; | ||
| 7 | -import router from '@ohos.router'; | ||
| 8 | -import { promptAction } from '@kit.ArkUI'; | 6 | +import { BreakpointSystem, EmitterEventId, EmitterUtils, Logger, MpaasUpgradeCheck, WindowModel } from 'wdKit'; |
| 7 | +import { promptAction, window } from '@kit.ArkUI'; | ||
| 9 | import { UpgradeTipDialog } from "./upgradePage/UpgradeTipDialog" | 8 | import { UpgradeTipDialog } from "./upgradePage/UpgradeTipDialog" |
| 10 | import { ProcessUtils } from 'wdRouter/Index'; | 9 | import { ProcessUtils } from 'wdRouter/Index'; |
| 11 | import { StartupManager } from '../startupmanager/StartupManager'; | 10 | import { StartupManager } from '../startupmanager/StartupManager'; |
| 11 | +import { BusinessError } from '@kit.BasicServicesKit'; | ||
| 12 | 12 | ||
| 13 | const TAG = 'MainPage'; | 13 | const TAG = 'MainPage'; |
| 14 | 14 | ||
| @@ -18,7 +18,8 @@ struct MainPage { | @@ -18,7 +18,8 @@ struct MainPage { | ||
| 18 | @Provide pageShow: number = -1 | 18 | @Provide pageShow: number = -1 |
| 19 | @Provide pageHide: number = -1 | 19 | @Provide pageHide: number = -1 |
| 20 | private breakpointSystem: BreakpointSystem = new BreakpointSystem() | 20 | private breakpointSystem: BreakpointSystem = new BreakpointSystem() |
| 21 | - @StorageLink('currentBreakpoint') @Watch('watchCurrentBreakpoint') currentBreakpoint: string = BreakpointConstants.BREAKPOINT_XS; | 21 | + @StorageLink('currentBreakpoint') @Watch('watchCurrentBreakpoint') currentBreakpoint: string = |
| 22 | + BreakpointConstants.BREAKPOINT_XS; | ||
| 22 | @State isPermission: boolean = false | 23 | @State isPermission: boolean = false |
| 23 | upgradeDialogController?: CustomDialogController | 24 | upgradeDialogController?: CustomDialogController |
| 24 | 25 | ||
| @@ -47,7 +48,7 @@ struct MainPage { | @@ -47,7 +48,7 @@ struct MainPage { | ||
| 47 | LogoutViewModel.clearLoginInfo() | 48 | LogoutViewModel.clearLoginInfo() |
| 48 | }) | 49 | }) |
| 49 | EmitterUtils.receiveEvent(EmitterEventId.LOCATION, () => { | 50 | EmitterUtils.receiveEvent(EmitterEventId.LOCATION, () => { |
| 50 | - this.isPermission=true | 51 | + this.isPermission = true |
| 51 | }) | 52 | }) |
| 52 | } | 53 | } |
| 53 | 54 | ||
| @@ -81,7 +82,7 @@ struct MainPage { | @@ -81,7 +82,7 @@ struct MainPage { | ||
| 81 | 82 | ||
| 82 | this.upgradeDialogController = new CustomDialogController({ | 83 | this.upgradeDialogController = new CustomDialogController({ |
| 83 | builder: UpgradeTipDialog({ | 84 | builder: UpgradeTipDialog({ |
| 84 | - tipContent:data, | 85 | + tipContent: data, |
| 85 | confirm: () => { | 86 | confirm: () => { |
| 86 | ProcessUtils.jumpExternalWebPage(data.downloadUrl); | 87 | ProcessUtils.jumpExternalWebPage(data.downloadUrl); |
| 87 | } | 88 | } |
| @@ -104,12 +105,26 @@ struct MainPage { | @@ -104,12 +105,26 @@ struct MainPage { | ||
| 104 | 105 | ||
| 105 | onBackPress() { | 106 | onBackPress() { |
| 106 | Logger.info(TAG, 'onBackPress'); | 107 | Logger.info(TAG, 'onBackPress'); |
| 108 | + try { | ||
| 109 | + // 拦截返回键,切到后台 | ||
| 110 | + const windowClass = WindowModel.shared.getWindowClass() as window.Window | ||
| 111 | + windowClass.minimize().then(() => { | ||
| 112 | + Logger.debug(TAG, 'Succeeded in minimizing the window.'); | ||
| 113 | + }).catch((err: BusinessError) => { | ||
| 114 | + Logger.error(TAG, 'Failed to minimize the window. Cause: ' + JSON.stringify(err)); | ||
| 115 | + return false | ||
| 116 | + }); | ||
| 117 | + } catch (err) { | ||
| 118 | + Logger.error(TAG, 'Failed to minimize: ' + JSON.stringify(err)); | ||
| 119 | + return false | ||
| 120 | + } | ||
| 121 | + return true | ||
| 107 | } | 122 | } |
| 108 | 123 | ||
| 109 | build() { | 124 | build() { |
| 110 | - Stack({alignContent:Alignment.Top}) { | 125 | + Stack({ alignContent: Alignment.Top }) { |
| 111 | BottomNavigationComponent() | 126 | BottomNavigationComponent() |
| 112 | - if(this.isPermission){ | 127 | + if (this.isPermission) { |
| 113 | PermissionDesComponent() | 128 | PermissionDesComponent() |
| 114 | } | 129 | } |
| 115 | } | 130 | } |
| @@ -135,18 +135,18 @@ export class StartupManager { | @@ -135,18 +135,18 @@ export class StartupManager { | ||
| 135 | private initNetwork() { | 135 | private initNetwork() { |
| 136 | Logger.debug(TAG, "App 网络 初始化") | 136 | Logger.debug(TAG, "App 网络 初始化") |
| 137 | WDHttp.initHttpHeader() | 137 | WDHttp.initHttpHeader() |
| 138 | - // 注册监听网络连接 | ||
| 139 | - EmitterUtils.receiveEvent(EmitterEventId.NETWORK_CONNECTED, ((str?: string) => { | ||
| 140 | - let type: NetworkType | null = null | ||
| 141 | - if (str) { | ||
| 142 | - type = JSON.parse(str) as NetworkType | ||
| 143 | - } | ||
| 144 | - Logger.info('network connected: ' + type?.toString()) | ||
| 145 | - })) | ||
| 146 | - // 注册监听网络断开 | ||
| 147 | - EmitterUtils.receiveEvent(EmitterEventId.NETWORK_DISCONNECTED, (() => { | ||
| 148 | - Logger.info('network disconnected') | ||
| 149 | - })) | 138 | + // 注册监听网络连接,没有实质业务意义,可删除 |
| 139 | + // EmitterUtils.receiveEvent(EmitterEventId.NETWORK_CONNECTED, ((str?: string) => { | ||
| 140 | + // let type: NetworkType | null = null | ||
| 141 | + // if (str) { | ||
| 142 | + // type = JSON.parse(str) as NetworkType | ||
| 143 | + // } | ||
| 144 | + // Logger.info('network connected: ' + type?.toString()) | ||
| 145 | + // })) | ||
| 146 | + // // 注册监听网络断开 | ||
| 147 | + // EmitterUtils.receiveEvent(EmitterEventId.NETWORK_DISCONNECTED, (() => { | ||
| 148 | + // Logger.info('network disconnected') | ||
| 149 | + // })) | ||
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | private initCheckDeviceId() { | 152 | private initCheckDeviceId() { |
-
Please register or login to post a comment