Merge branch 'main' of http://192.168.1.42/developOne/harmonyPool
Showing
37 changed files
with
1295 additions
and
129 deletions
| 1 | -import { AboutPageUI} from 'wdComponent'; | 1 | +import { PrivacySettingComponents} from 'wdComponent'; |
| 2 | 2 | ||
| 3 | @Entry | 3 | @Entry |
| 4 | @Component | 4 | @Component |
| 5 | struct PrivacySettingPage { | 5 | struct PrivacySettingPage { |
| 6 | build() { | 6 | build() { |
| 7 | Column(){ | 7 | Column(){ |
| 8 | - AboutPageUI() | 8 | + PrivacySettingComponents() |
| 9 | } | 9 | } |
| 10 | } | 10 | } |
| 11 | } | 11 | } |
| @@ -32,6 +32,58 @@ | @@ -32,6 +32,58 @@ | ||
| 32 | } | 32 | } |
| 33 | ] | 33 | ] |
| 34 | } | 34 | } |
| 35 | + ], | ||
| 36 | + "requestPermissions": [ | ||
| 37 | + { | ||
| 38 | + "name": "ohos.permission.CAMERA", | ||
| 39 | + "reason": "$string:EntryAbility_desc", | ||
| 40 | + "usedScene": { | ||
| 41 | + "abilities": [ | ||
| 42 | + "FormAbility" | ||
| 43 | + ], | ||
| 44 | + "when": "inuse" | ||
| 45 | + } | ||
| 46 | + }, | ||
| 47 | + { | ||
| 48 | + "name": "ohos.permission.READ_MEDIA", | ||
| 49 | + "reason": "$string:EntryAbility_desc", | ||
| 50 | + "usedScene": { | ||
| 51 | + "abilities": [ | ||
| 52 | + "FormAbility" | ||
| 53 | + ], | ||
| 54 | + "when": "inuse" | ||
| 55 | + } | ||
| 56 | + }, | ||
| 57 | + { | ||
| 58 | + "name": "ohos.permission.WRITE_MEDIA", | ||
| 59 | + "reason": "$string:EntryAbility_desc", | ||
| 60 | + "usedScene": { | ||
| 61 | + "abilities": [ | ||
| 62 | + "FormAbility" | ||
| 63 | + ], | ||
| 64 | + "when": "inuse" | ||
| 65 | + } | ||
| 66 | + }, | ||
| 67 | + { | ||
| 68 | + "name": "ohos.permission.LOCATION", | ||
| 69 | + "reason": "$string:EntryAbility_desc", | ||
| 70 | + "usedScene": { | ||
| 71 | + "abilities": [ | ||
| 72 | + "FormAbility" | ||
| 73 | + ], | ||
| 74 | + "when": "inuse" | ||
| 75 | + } | ||
| 76 | + }, | ||
| 77 | + { | ||
| 78 | + "name": "ohos.permission.MICROPHONE", | ||
| 79 | + "reason": "$string:EntryAbility_desc", | ||
| 80 | + "usedScene": { | ||
| 81 | + "abilities": [ | ||
| 82 | + "FormAbility" | ||
| 83 | + ], | ||
| 84 | + "when": "inuse" | ||
| 85 | + } | ||
| 86 | + } | ||
| 35 | ] | 87 | ] |
| 36 | } | 88 | } |
| 37 | } | 89 | } |
| @@ -32,6 +32,8 @@ export { MineSettingComponent } from "./components/page/MineSettingComponent" | @@ -32,6 +32,8 @@ export { MineSettingComponent } from "./components/page/MineSettingComponent" | ||
| 32 | 32 | ||
| 33 | export { AboutPageUI } from "./components/page/about/AboutPageUI" | 33 | export { AboutPageUI } from "./components/page/about/AboutPageUI" |
| 34 | 34 | ||
| 35 | +export { PrivacySettingComponents } from "./components/page/PrivacySettingComponents" | ||
| 36 | + | ||
| 35 | export { AppointmentListUI } from "./components/page/mine/AppointmentListUI" | 37 | export { AppointmentListUI } from "./components/page/mine/AppointmentListUI" |
| 36 | 38 | ||
| 37 | export { AccountAndSecurityLayout } from "./components/page/AccountAndSecurityLayout" | 39 | export { AccountAndSecurityLayout } from "./components/page/AccountAndSecurityLayout" |
| @@ -6,6 +6,7 @@ import { BottomNavDTO } from '../../repository/bean/BottomNavDTO'; | @@ -6,6 +6,7 @@ import { BottomNavDTO } from '../../repository/bean/BottomNavDTO'; | ||
| 6 | import { UIUtils } from '../../repository/UIUtils'; | 6 | import { UIUtils } from '../../repository/UIUtils'; |
| 7 | import { MinePageComponent } from './MinePageComponent'; | 7 | import { MinePageComponent } from './MinePageComponent'; |
| 8 | import PageViewModel from '../../viewmodel/PageViewModel'; | 8 | import PageViewModel from '../../viewmodel/PageViewModel'; |
| 9 | +import RouteManager from '../../utils/RouteManager' | ||
| 9 | 10 | ||
| 10 | import storageStatistics from "@ohos.file.storageStatistics"; | 11 | import storageStatistics from "@ohos.file.storageStatistics"; |
| 11 | import { BusinessError } from '@ohos.base'; | 12 | import { BusinessError } from '@ohos.base'; |
| @@ -74,8 +75,9 @@ export struct MineSettingComponent { | @@ -74,8 +75,9 @@ export struct MineSettingComponent { | ||
| 74 | RouteManager.jumpNewPage("pages/SettingPasswordPage") // 调用跳转方法,跳转新页面 | 75 | RouteManager.jumpNewPage("pages/SettingPasswordPage") // 调用跳转方法,跳转新页面 |
| 75 | 76 | ||
| 76 | console.log(subIndex + "") | 77 | console.log(subIndex + "") |
| 77 | - if (subIndex == 4) { | 78 | + if (subIndex == 2) { |
| 78 | // RouteManager.jumpNewPage("pages/SettingPage") // 调用跳转方法,跳转新页面 | 79 | // RouteManager.jumpNewPage("pages/SettingPage") // 调用跳转方法,跳转新页面 |
| 80 | + RouteManager.jumpNewPage("pages/PrivacySettingPage") | ||
| 79 | } | 81 | } |
| 80 | 82 | ||
| 81 | }) | 83 | }) |
PeopleDaily_Harmony/wdComponent/src/main/ets/components/page/PrivacySettingComponents.ets
0 → 100644
| 1 | +import dataPreferences from '@ohos.data.preferences'; | ||
| 2 | +import { PermissionUtil } from 'wdKit' | ||
| 3 | +import { SPHelper } from 'wdKit' | ||
| 4 | +import hilog from '@ohos.hilog'; | ||
| 5 | +import {PrivacySettingModel} from '../../viewmodel/PrivacySettingModel' | ||
| 6 | + | ||
| 7 | +const TAG = 'PrivacySettingComponents'; | ||
| 8 | + | ||
| 9 | +@Component | ||
| 10 | +export struct PrivacySettingComponents { | ||
| 11 | + @State listData: Array<PrivacySettingModel> = [new PrivacySettingModel('开启个性推荐', false, null), new PrivacySettingModel('相册权限', false, 'ohos.permission.READ_MEDIA'), new PrivacySettingModel('相机权限', false, 'ohos.permission.CAMERA'), new PrivacySettingModel('定位权限', false, 'ohos.permission.LOCATION'), new PrivacySettingModel('麦克风权限', false, 'ohos.permission.MICROPHONE')]; | ||
| 12 | + @State tips: string = '设置前可查阅' | ||
| 13 | + @State privacyTips: string = '《隐私政策》' | ||
| 14 | + | ||
| 15 | + aboutToAppear() { | ||
| 16 | + // 获取权限= | ||
| 17 | + // SPHelper.default.save('sdf','sdf'); | ||
| 18 | + // this.initListData(); | ||
| 19 | + this.getPermissionStatus(); | ||
| 20 | + RefreshStatus; | ||
| 21 | + | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + // initListData(){ | ||
| 25 | + // let model1 = new PrivacySettingModel('开启个性推荐', false, null); | ||
| 26 | + // let model2 = new PrivacySettingModel('相册权限', false, 'ohos.permission.READ_MEDIA'); | ||
| 27 | + // let model3 = new PrivacySettingModel('相机权限', false, 'ohos.permission.CAMERA'); | ||
| 28 | + // let model4 = new PrivacySettingModel('定位权限', false, 'ohos.permission.LOCATION'); | ||
| 29 | + // let model5 = new PrivacySettingModel('麦克风权限', false, 'ohos.permission.MICROPHONE'); | ||
| 30 | + // | ||
| 31 | + // this.listData.push(model1, model2, model3, model4, model5); | ||
| 32 | + // } | ||
| 33 | + | ||
| 34 | + async getPermissionStatus(){ | ||
| 35 | + const permissionUtil = new PermissionUtil(); | ||
| 36 | + for (const element of this.listData) { | ||
| 37 | + if (!element.permissionKey) { | ||
| 38 | + continue; | ||
| 39 | + } | ||
| 40 | + const result = await permissionUtil.checkPermissions(element.permissionKey); | ||
| 41 | + element.permission = result; | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + build() { | ||
| 46 | + Navigation() { | ||
| 47 | + //滑动区域 | ||
| 48 | + this.PrivacySettingComponentsUI() | ||
| 49 | + | ||
| 50 | + }.titleMode(NavigationTitleMode.Mini) | ||
| 51 | + .title('隐私设置') | ||
| 52 | + .backgroundColor('#F8F8F8') | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + @Builder PrivacySettingComponentsUI() { | ||
| 56 | + Column() { | ||
| 57 | + | ||
| 58 | + List({space:'23lpx'}){ | ||
| 59 | + ForEach(this.listData, (item:PrivacySettingModel, index) =>{ | ||
| 60 | + ListItem() { | ||
| 61 | + if (index == 0) { | ||
| 62 | + getTuiJianCell({item, index}); | ||
| 63 | + }else{ | ||
| 64 | + getArrowCell({item, index}); | ||
| 65 | + } | ||
| 66 | + }.onClick(()=>{ | ||
| 67 | + if (index != 0) { | ||
| 68 | + if (!item.permission){ | ||
| 69 | + //跳转权限设置 | ||
| 70 | + const permissionUtil = new PermissionUtil(); | ||
| 71 | + PermissionUtil.reqPermissionsFromUser([item.permissionKey]); | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + }) | ||
| 75 | + }, item => item) | ||
| 76 | + } | ||
| 77 | + .padding({left:'29lpx', right:'29lpx'}) | ||
| 78 | + .margin({top:'38lpx'}) | ||
| 79 | + | ||
| 80 | + Row(){ | ||
| 81 | + Text(this.tips) | ||
| 82 | + .fontSize('25lpx') | ||
| 83 | + .textAlign(TextAlign.Start) | ||
| 84 | + .fontColor($r("app.color.color_666666")) | ||
| 85 | + .margin({left:'29lpx', top:'46lpx'}) | ||
| 86 | + // .backgroundColor(Color.Orange) | ||
| 87 | + Text(this.privacyTips) | ||
| 88 | + .fontSize('25lpx') | ||
| 89 | + .textAlign(TextAlign.Start) | ||
| 90 | + .fontColor('#ED2800') | ||
| 91 | + .margin({top:'46lpx'}) | ||
| 92 | + .onClick(()=>{ | ||
| 93 | + //跳转隐私政策 | ||
| 94 | + }) | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + | ||
| 98 | + } | ||
| 99 | + .width('100%') | ||
| 100 | + .height('100%') | ||
| 101 | + .backgroundColor('#F8F8F8') | ||
| 102 | + .alignItems(HorizontalAlign.Start) | ||
| 103 | + } | ||
| 104 | +} | ||
| 105 | + | ||
| 106 | + | ||
| 107 | +@Component | ||
| 108 | +struct getArrowCell { | ||
| 109 | + @ObjectLink item: PrivacySettingModel; | ||
| 110 | + index; | ||
| 111 | + // 右文字+箭头cell | ||
| 112 | + // @Builder getArrowCell(item:PrivacySettingModel, index) { | ||
| 113 | + build() { | ||
| 114 | + Row() { | ||
| 115 | + // 左侧标题 | ||
| 116 | + Text(this.item.privacyName) | ||
| 117 | + .fontColor('#666666') | ||
| 118 | + .fontSize('31lpx') | ||
| 119 | + | ||
| 120 | + Row() { | ||
| 121 | + Text(this.item.permission ? '已开启' : '去设置') | ||
| 122 | + .fontColor(this.item.permission ? '#666666' : '#CCCCCC') | ||
| 123 | + .fontSize('31lpx') | ||
| 124 | + .margin({ right: '8lpx' }) | ||
| 125 | + | ||
| 126 | + Image($r('app.media.mine_user_arrow')) | ||
| 127 | + .width('27lpx') | ||
| 128 | + .height('27lpx') | ||
| 129 | + .objectFit(ImageFit.Auto) | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + } | ||
| 133 | + .alignItems(VerticalAlign.Center) | ||
| 134 | + .justifyContent(FlexAlign.SpaceBetween) | ||
| 135 | + .height('97lpx') | ||
| 136 | + .width('100%') | ||
| 137 | + .padding({ left: '29lpx', right: '29lpx' }) | ||
| 138 | + .backgroundColor('#FFFFFF') | ||
| 139 | + .borderRadius('8lpx') | ||
| 140 | + } | ||
| 141 | +} | ||
| 142 | + | ||
| 143 | +@Component | ||
| 144 | +struct getTuiJianCell{ | ||
| 145 | + @ObjectLink item :PrivacySettingModel; | ||
| 146 | + index; | ||
| 147 | + build() { | ||
| 148 | + //@Builder getTuiJianCell(item:PrivacySettingModel, index) | ||
| 149 | + Column() { | ||
| 150 | + | ||
| 151 | + Row() { | ||
| 152 | + // 左侧标题 | ||
| 153 | + Text(this.item.privacyName) | ||
| 154 | + .fontColor('#666666') | ||
| 155 | + .fontSize('31lpx') | ||
| 156 | + | ||
| 157 | + Row() { | ||
| 158 | + Toggle({ type: ToggleType.Switch, isOn: this.item.permission }) | ||
| 159 | + .height('58lpx') | ||
| 160 | + .width('96lpx') | ||
| 161 | + // .selectedColor(Color.Pink) | ||
| 162 | + .onChange((isOn: boolean) => { | ||
| 163 | + // this.privacySwitch = isOn; | ||
| 164 | + }) | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + } | ||
| 168 | + .alignItems(VerticalAlign.Center) | ||
| 169 | + .justifyContent(FlexAlign.SpaceBetween) | ||
| 170 | + .height('97lpx') | ||
| 171 | + .width('100%') | ||
| 172 | + | ||
| 173 | + | ||
| 174 | + Blank() | ||
| 175 | + .backgroundColor('#EDEDED') | ||
| 176 | + .height('1lpx') | ||
| 177 | + | ||
| 178 | + Text('关闭后,将无法看到个性化推荐的服务') | ||
| 179 | + .fontColor('#999999') | ||
| 180 | + .fontSize('23lpx') | ||
| 181 | + .margin({ right: '8lpx' }) | ||
| 182 | + .height('69lpx') | ||
| 183 | + | ||
| 184 | + } | ||
| 185 | + .alignItems(HorizontalAlign.Start) | ||
| 186 | + .backgroundColor('#FFFFFF') | ||
| 187 | + .borderRadius('8lpx') | ||
| 188 | + .padding({ left: '29lpx', right: '29lpx' }) | ||
| 189 | + } | ||
| 190 | +} |
| @@ -2,28 +2,53 @@ const TAG = 'AboutPageUI'; | @@ -2,28 +2,53 @@ const TAG = 'AboutPageUI'; | ||
| 2 | 2 | ||
| 3 | @Component | 3 | @Component |
| 4 | export struct AboutPageUI { | 4 | export struct AboutPageUI { |
| 5 | + @State listData: Array<string | Array<string>> = ['隐私授权协议', '软件许可及用户协议']; | ||
| 5 | @State message: string = '京ICP备16066560号-6A Copyright © 人民日报客户端\nall rights reserved.' | 6 | @State message: string = '京ICP备16066560号-6A Copyright © 人民日报客户端\nall rights reserved.' |
| 6 | @State version: string = '版本号:v8.0.1.1' | 7 | @State version: string = '版本号:v8.0.1.1' |
| 7 | 8 | ||
| 8 | 9 | ||
| 9 | build() { | 10 | build() { |
| 11 | + Navigation() { | ||
| 12 | + //滑动区域 | ||
| 13 | + this.aboutUi() | ||
| 14 | + }.titleMode(NavigationTitleMode.Mini) | ||
| 15 | + .title('关于') | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + @Builder aboutUi() { | ||
| 10 | Column() { | 19 | Column() { |
| 11 | Image($r('app.media.setting_about_logo')) | 20 | Image($r('app.media.setting_about_logo')) |
| 12 | .width('278lpx') | 21 | .width('278lpx') |
| 13 | .height('154lpx') | 22 | .height('154lpx') |
| 14 | .margin({top:'173lpx',bottom:'154lpx'}) | 23 | .margin({top:'173lpx',bottom:'154lpx'}) |
| 15 | 24 | ||
| 16 | - Row(){ | 25 | + // Row(){ |
| 26 | + // | ||
| 27 | + // }.backgroundColor(Color.Yellow) | ||
| 28 | + // .width('100%') | ||
| 29 | + // .height('97lpx') | ||
| 17 | 30 | ||
| 18 | - }.backgroundColor(Color.Yellow) | ||
| 19 | - .width('100%') | ||
| 20 | - .height('97lpx') | 31 | + // Row(){ |
| 32 | + // | ||
| 33 | + // }.backgroundColor(Color.Yellow) | ||
| 34 | + // .width('100%') | ||
| 35 | + // .height('97lpx') | ||
| 21 | 36 | ||
| 22 | - Row(){ | ||
| 23 | 37 | ||
| 24 | - }.backgroundColor(Color.Yellow) | ||
| 25 | - .width('100%') | ||
| 26 | - .height('97lpx') | 38 | + |
| 39 | + | ||
| 40 | + List(){ | ||
| 41 | + ForEach(this.listData, (item, index) =>{ | ||
| 42 | + ListItem() { | ||
| 43 | + this.getArrowCell(item, index) | ||
| 44 | + } | ||
| 45 | + }, item => item) | ||
| 46 | + }.divider({ | ||
| 47 | + strokeWidth: 1, | ||
| 48 | + startMargin: '29lpx', | ||
| 49 | + endMargin: '29lpx', | ||
| 50 | + color: '#EDEDED' | ||
| 51 | + }) | ||
| 27 | 52 | ||
| 28 | Blank() | 53 | Blank() |
| 29 | 54 | ||
| @@ -46,4 +71,31 @@ export struct AboutPageUI { | @@ -46,4 +71,31 @@ export struct AboutPageUI { | ||
| 46 | .width('100%') | 71 | .width('100%') |
| 47 | .height('100%') | 72 | .height('100%') |
| 48 | } | 73 | } |
| 74 | + | ||
| 75 | + | ||
| 76 | + | ||
| 77 | + // 右文字+箭头cell | ||
| 78 | + @Builder getArrowCell(item, index) { | ||
| 79 | + | ||
| 80 | + Row() { | ||
| 81 | + // 左侧标题 | ||
| 82 | + Text(`${item}`) | ||
| 83 | + .fontColor('#666666') | ||
| 84 | + .fontSize('31lpx') | ||
| 85 | + | ||
| 86 | + Image($r('app.media.mine_user_arrow')) | ||
| 87 | + .width('27lpx') | ||
| 88 | + .height('27lpx') | ||
| 89 | + .objectFit(ImageFit.Auto) | ||
| 90 | + } | ||
| 91 | + .alignItems(VerticalAlign.Center) | ||
| 92 | + .justifyContent(FlexAlign.SpaceBetween) | ||
| 93 | + .height('97lpx') | ||
| 94 | + .width('100%') | ||
| 95 | + .padding({left:'29lpx',right:'29lpx'}) | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + | ||
| 49 | } | 99 | } |
| 100 | + | ||
| 101 | + |
| @@ -67,18 +67,19 @@ export default struct MinePageMoreFunctionUI{ | @@ -67,18 +67,19 @@ export default struct MinePageMoreFunctionUI{ | ||
| 67 | console.log(index+"") | 67 | console.log(index+"") |
| 68 | if (index == 3) { | 68 | if (index == 3) { |
| 69 | RouteManager.jumpNewPage("pages/SettingPage") | 69 | RouteManager.jumpNewPage("pages/SettingPage") |
| 70 | - } else { | ||
| 71 | - | 70 | + } else if (index == 2) { |
| 71 | + RouteManager.jumpNewPage("pages/PrivacySettingPage") | ||
| 72 | + } else if (index == 4) { | ||
| 73 | + RouteManager.jumpNewPage("pages/SettingAboutPage") | ||
| 74 | + }else { | ||
| 72 | // 在Home页面中 | 75 | // 在Home页面中 |
| 73 | let paramsInfo: object = { | 76 | let paramsInfo: object = { |
| 74 | pageId: 123, | 77 | pageId: 123, |
| 75 | pageType:'mainSetting' | 78 | pageType:'mainSetting' |
| 76 | }; | 79 | }; |
| 77 | RouteManager.jumpNewPage("pages/PrivacySettingPage",paramsInfo) | 80 | RouteManager.jumpNewPage("pages/PrivacySettingPage",paramsInfo) |
| 78 | - | ||
| 79 | - // RouteManager.jumpNewPage("pages/PrivacySettingPage") | ||
| 80 | - | ||
| 81 | } | 81 | } |
| 82 | + | ||
| 82 | }) | 83 | }) |
| 83 | .height('117lpx') | 84 | .height('117lpx') |
| 84 | }, item => item) | 85 | }, item => item) |
| 1 | +import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; | ||
| 2 | +@Observed | ||
| 3 | +export class PrivacySettingModel{ | ||
| 4 | + privacyName: string | ||
| 5 | + permission: boolean | ||
| 6 | + permissionKey: Permissions | ||
| 7 | + | ||
| 8 | + constructor(privacyName: string, permission: boolean, permissionKey: Permissions) { | ||
| 9 | + this.privacyName = privacyName; | ||
| 10 | + this.permission = permission; | ||
| 11 | + this.permissionKey = permissionKey; | ||
| 12 | + } | ||
| 13 | +} |
| @@ -14,3 +14,6 @@ export { DateTimeUtils } from './utils/DateTimeUtils' | @@ -14,3 +14,6 @@ export { DateTimeUtils } from './utils/DateTimeUtils' | ||
| 14 | 14 | ||
| 15 | export { AppContext } from './utils/AppContext' | 15 | export { AppContext } from './utils/AppContext' |
| 16 | 16 | ||
| 17 | +export { PermissionUtil } from './utils/PermissionUtil' | ||
| 18 | + | ||
| 19 | +export { SPHelper } from './utils/SPHelper' |
| 1 | +import bundleManager from '@ohos.bundle.bundleManager'; | ||
| 2 | +import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; | ||
| 3 | +import common from '@ohos.app.ability.common'; | ||
| 4 | +import featureAbility from '@ohos.ability.featureAbility'; | ||
| 5 | +import wantConstant from '@ohos.ability.wantConstant'; | ||
| 6 | + | ||
| 7 | +export class PermissionUtil { | ||
| 8 | + async checkAccessToken(permission: Permissions): Promise<abilityAccessCtrl.GrantStatus> { | ||
| 9 | + let atManager = abilityAccessCtrl.createAtManager(); | ||
| 10 | + let grantStatus: abilityAccessCtrl.GrantStatus; | ||
| 11 | + | ||
| 12 | + // 获取应用程序的accessTokenID | ||
| 13 | + let tokenId: number; | ||
| 14 | + try { | ||
| 15 | + let bundleInfo: bundleManager.BundleInfo = await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION); | ||
| 16 | + let appInfo: bundleManager.ApplicationInfo = bundleInfo.appInfo; | ||
| 17 | + tokenId = appInfo.accessTokenId; | ||
| 18 | + } catch (err) { | ||
| 19 | + console.error(`getBundleInfoForSelf failed, code is ${err.code}, message is ${err.message}`); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + // 校验应用是否被授予权限 | ||
| 23 | + try { | ||
| 24 | + grantStatus = await atManager.checkAccessToken(tokenId, permission); | ||
| 25 | + } catch (err) { | ||
| 26 | + console.error(`checkAccessToken failed, code is ${err.code}, message is ${err.message}`); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + return grantStatus; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + async checkPermissions(permission: Permissions): Promise<boolean> { | ||
| 33 | + let hasPermissions = false; | ||
| 34 | + let grantStatus: abilityAccessCtrl.GrantStatus = await this.checkAccessToken(permission); | ||
| 35 | + | ||
| 36 | + if (grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) { | ||
| 37 | + // 已经授权,可以继续访问目标操作 | ||
| 38 | + hasPermissions = true; | ||
| 39 | + } else { | ||
| 40 | + hasPermissions = false; | ||
| 41 | + // 申请日历权限 | ||
| 42 | + } | ||
| 43 | + return hasPermissions; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + static reqPermissionsFromUser(permissions: Array<Permissions>): void { | ||
| 47 | + let context = getContext(this) as common.UIAbilityContext; | ||
| 48 | + let atManager = abilityAccessCtrl.createAtManager(); | ||
| 49 | + // requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗 | ||
| 50 | + atManager.requestPermissionsFromUser(context, permissions).then((data) => { | ||
| 51 | + let grantStatus: Array<number> = data.authResults; | ||
| 52 | + let length: number = grantStatus.length; | ||
| 53 | + for (let i = 0; i < length; i++) { | ||
| 54 | + if (grantStatus[i] === 0) { | ||
| 55 | + // 用户授权,可以继续访问目标操作 | ||
| 56 | + | ||
| 57 | + } else { | ||
| 58 | + | ||
| 59 | + this.jumpSetting(); | ||
| 60 | + // 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限 | ||
| 61 | + AlertDialog.show({ | ||
| 62 | + title: '权限设置', | ||
| 63 | + message: '到系统设置中打开相应的权限', | ||
| 64 | + confirm: { | ||
| 65 | + value: "OK", | ||
| 66 | + action: () => { | ||
| 67 | + | ||
| 68 | + }, | ||
| 69 | + } | ||
| 70 | + }) | ||
| 71 | + return; | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + // 授权成功 | ||
| 75 | + }).catch((err) => { | ||
| 76 | + console.error(`requestPermissionsFromUser failed, code is ${err.code}, message is ${err.message}`); | ||
| 77 | + }) | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + | ||
| 81 | + static jumpSetting() { | ||
| 82 | + | ||
| 83 | + } | ||
| 84 | +} |
| @@ -87,7 +87,7 @@ export class HttpUrlUtils { | @@ -87,7 +87,7 @@ export class HttpUrlUtils { | ||
| 87 | 87 | ||
| 88 | static readonly MORNING_EVENING_COMP_INFO_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/compInfo"; | 88 | static readonly MORNING_EVENING_COMP_INFO_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/compInfo"; |
| 89 | 89 | ||
| 90 | - private static hostUrl: string = HttpUrlUtils.HOST_UAT; | 90 | + private static hostUrl: string = HttpUrlUtils.HOST_PRODUCT; |
| 91 | private static userId='' | 91 | private static userId='' |
| 92 | private static userType='' | 92 | private static userType='' |
| 93 | private static token='' | 93 | private static token='' |
| @@ -70,3 +70,19 @@ export { ResponseBean } from './src/main/ets/bean/h5/ResponseBean'; | @@ -70,3 +70,19 @@ export { ResponseBean } from './src/main/ets/bean/h5/ResponseBean'; | ||
| 70 | export { MorningEveningPaperDTO } from './src/main/ets/bean/component/MorningEveningPaperDTO'; | 70 | export { MorningEveningPaperDTO } from './src/main/ets/bean/component/MorningEveningPaperDTO'; |
| 71 | 71 | ||
| 72 | export { FrontLinkObject } from './src/main/ets/bean/component/FrontLinkObject'; | 72 | export { FrontLinkObject } from './src/main/ets/bean/component/FrontLinkObject'; |
| 73 | + | ||
| 74 | +export { PageInfoBean } from './src/main/ets/bean/morningevening/PageInfoBean'; | ||
| 75 | + | ||
| 76 | +export { Group } from './src/main/ets/bean/morningevening/Group'; | ||
| 77 | + | ||
| 78 | +export { TopicInfo } from './src/main/ets/bean/morningevening/TopicInfo'; | ||
| 79 | + | ||
| 80 | +export { CompInfoBean } from './src/main/ets/bean/morningevening/CompInfoBean'; | ||
| 81 | + | ||
| 82 | +export { CompList } from './src/main/ets/bean/morningevening/CompList'; | ||
| 83 | + | ||
| 84 | +export { OperDataList } from './src/main/ets/bean/morningevening/OperDataList'; | ||
| 85 | + | ||
| 86 | +export { ShareInfo } from './src/main/ets/bean/morningevening/ShareInfo'; | ||
| 87 | + | ||
| 88 | + |
| 1 | +import { CompList } from './CompList'; | ||
| 2 | + | ||
| 3 | +export interface CompInfoBean { | ||
| 4 | + blockDesc: string; | ||
| 5 | + // compAdList: any[]; | ||
| 6 | + compList: CompList[]; | ||
| 7 | + id: number; | ||
| 8 | + name: string; | ||
| 9 | + pageId: string; | ||
| 10 | + pageNum: number; | ||
| 11 | + pageSize: number; | ||
| 12 | + recommend: number; | ||
| 13 | + totalCount: number; | ||
| 14 | +} |
| 1 | +import { OperDataList } from './OperDataList'; | ||
| 2 | + | ||
| 3 | +export interface CompList { | ||
| 4 | + // audioDataList: any[]; | ||
| 5 | + backgroundImgUrl: string; | ||
| 6 | + // bottomNavId?: any; | ||
| 7 | + cardItemId: string; | ||
| 8 | + // cardUpdateStrategy?: any; | ||
| 9 | + compStyle: string; | ||
| 10 | + compType: string; | ||
| 11 | + dataSourceType: string; | ||
| 12 | + expIds: string; | ||
| 13 | + extraData: string; | ||
| 14 | + // fullColumnImgUrls: any[]; | ||
| 15 | + hasMore: number; | ||
| 16 | + id: number; | ||
| 17 | + // imageScale?: any; | ||
| 18 | + imgSize: string; | ||
| 19 | + itemId: string; | ||
| 20 | + itemType: string; | ||
| 21 | + itemTypeCode: string; | ||
| 22 | + linkUrl: string; | ||
| 23 | + // localGovernance?: any; | ||
| 24 | + name: string; | ||
| 25 | + objectId: string; | ||
| 26 | + objectLevel: string; | ||
| 27 | + objectSummary: string; | ||
| 28 | + objectTitle: string; | ||
| 29 | + objectType: string; | ||
| 30 | + // openComment?: any; | ||
| 31 | + // openLikes?: any; | ||
| 32 | + operDataList: OperDataList[]; | ||
| 33 | + pageId: string; | ||
| 34 | + // position?: any; | ||
| 35 | + posterSize: string; | ||
| 36 | + posterUrl: string; | ||
| 37 | + // questionSection?: any; | ||
| 38 | + recommend: number; | ||
| 39 | + relId: number; | ||
| 40 | + sceneId: string; | ||
| 41 | + sortValue: number; | ||
| 42 | + subSceneId: string; | ||
| 43 | + summaryName: string; | ||
| 44 | + // tabOperDataList: any[]; | ||
| 45 | + titleShowPolicy: number; | ||
| 46 | + // topicTemplate?: any; | ||
| 47 | + traceId: string; | ||
| 48 | + traceInfo: string; | ||
| 49 | + viewTime: string; | ||
| 50 | + // viewTimeBlurred?: any; | ||
| 51 | +} |
| 1 | +import { ShareInfo } from './ShareInfo'; | ||
| 2 | + | ||
| 3 | +export interface OperDataList { | ||
| 4 | + // activityExt?: any; | ||
| 5 | + appStyle: string; | ||
| 6 | + // askInfo?: any; | ||
| 7 | + axisColor: string; | ||
| 8 | + // bestNoticer?: any; | ||
| 9 | + // bottomNavId?: any; | ||
| 10 | + cardItemId: string; | ||
| 11 | + channelId: number; | ||
| 12 | + // commentInfo?: any; | ||
| 13 | + corner: string; | ||
| 14 | + coverSize: string; | ||
| 15 | + coverType: number; | ||
| 16 | + coverUrl: string; | ||
| 17 | + expIds: string; | ||
| 18 | + extra: string; | ||
| 19 | + // fullColumnImgUrls: any[]; | ||
| 20 | + // hasMore?: any; | ||
| 21 | + itemId: string; | ||
| 22 | + itemType: string; | ||
| 23 | + itemTypeCode: string; | ||
| 24 | + keyArticle: number; | ||
| 25 | + // landscape?: any; | ||
| 26 | + // likeStyle?: any; | ||
| 27 | + linkUrl: string; | ||
| 28 | + // liveInfo?: any; | ||
| 29 | + menuShow: number; | ||
| 30 | + newTags: string; | ||
| 31 | + newsAuthor: string; | ||
| 32 | + newsSubTitle: string; | ||
| 33 | + newsSummary: string; | ||
| 34 | + newsTitle: string; | ||
| 35 | + newsTitleColor: string; | ||
| 36 | + objectId: string; | ||
| 37 | + objectLevel: string; | ||
| 38 | + objectType: string; | ||
| 39 | + // openComment?: any; | ||
| 40 | + // openLikes?: any; | ||
| 41 | + pageId: string; | ||
| 42 | + // photoNum?: any; | ||
| 43 | + // position?: any; | ||
| 44 | + publishTime: string; | ||
| 45 | + // pushTime?: any; | ||
| 46 | + // pushUnqueId?: any; | ||
| 47 | + readFlag: number; | ||
| 48 | + // recommend?: any; | ||
| 49 | + relId: number; | ||
| 50 | + relObjectId: string; | ||
| 51 | + relType: number; | ||
| 52 | + // rmhInfo?: any; | ||
| 53 | + rmhPlatform: number; | ||
| 54 | + sceneId: string; | ||
| 55 | + shareInfo: ShareInfo; | ||
| 56 | + // slideShows: any[]; | ||
| 57 | + sortValue: number; | ||
| 58 | + source: string; | ||
| 59 | + subSceneId: string; | ||
| 60 | + // tagIds: any[]; | ||
| 61 | + // tagWord?: any; | ||
| 62 | + // titleShow?: any; | ||
| 63 | + // titleShowPolicy?: any; | ||
| 64 | + // topicTemplate?: any; | ||
| 65 | + traceId: string; | ||
| 66 | + traceInfo: string; | ||
| 67 | + // userInfo?: any; | ||
| 68 | + // videoInfo?: any; | ||
| 69 | + visitorComment: number; | ||
| 70 | + // voiceInfo?: any; | ||
| 71 | +} |
| 1 | -// export interface Group { | ||
| 2 | -// blockDesc: string; | ||
| 3 | -// groupStrategy: number; | ||
| 4 | -// id: number; | ||
| 5 | -// itemNum?: any; | ||
| 6 | -// showType: number; | ||
| 7 | -// sortValue: number; | ||
| 8 | -// } | ||
| 9 | -// | ||
| 10 | -// export interface TopicInfo { | ||
| 11 | -// axisColor: string; | ||
| 12 | -// channelId?: any; | ||
| 13 | -// commentFlag: number; | ||
| 14 | -// commentPreviewFlag: number; | ||
| 15 | -// commentShowFlag: number; | ||
| 16 | -// frontFlag?: any; | ||
| 17 | -// frontLinkObject?: any; | ||
| 18 | -// posterFlag: number; | ||
| 19 | -// posterUrl: string; | ||
| 20 | -// relId?: any; | ||
| 21 | -// relObjectId?: any; | ||
| 22 | -// relType?: any; | ||
| 23 | -// shareCoverUrl: string; | ||
| 24 | -// shareOpen: number; | ||
| 25 | -// sharePosterCoverUrl: string; | ||
| 26 | -// sharePosterOpen?: any; | ||
| 27 | -// shareSummary: string; | ||
| 28 | -// shareTitle: string; | ||
| 29 | -// shareUrl: string; | ||
| 30 | -// slideColor: string; | ||
| 31 | -// summary: string; | ||
| 32 | -// title: string; | ||
| 33 | -// titleShow: number; | ||
| 34 | -// topicDate: string; | ||
| 35 | -// topicId: string; | ||
| 36 | -// topicPattern: number; | ||
| 37 | -// topicTemplate?: any; | ||
| 38 | -// topicType: number; | ||
| 39 | -// transluceImgUrl: string; | ||
| 40 | -// visitorComment: number; | ||
| 41 | -// voteInfo?: any; | ||
| 42 | -// } | ||
| 43 | -// | ||
| 44 | -// export interface PageInfoBean { | ||
| 45 | -// backIconUrl: string; | ||
| 46 | -// backgroundColor: string; | ||
| 47 | -// backgroundImgUrl: string; | ||
| 48 | -// baselineColor: string; | ||
| 49 | -// baselineCopywriting: string; | ||
| 50 | -// baselineShow: number; | ||
| 51 | -// description: string; | ||
| 52 | -// groups: Group[]; | ||
| 53 | -// hasAdInfo: number; | ||
| 54 | -// hasPopUp: number; | ||
| 55 | -// id: number; | ||
| 56 | -// mainLogoImgUrl: string; | ||
| 57 | -// name: string; | ||
| 58 | -// pageTopParams?: any; | ||
| 59 | -// pageTopType: number; | ||
| 60 | -// pageType: number; | ||
| 61 | -// popUps: any[]; | ||
| 62 | -// pushupLogoImgUrl: string; | ||
| 63 | -// shareCoverUrl: string; | ||
| 64 | -// shareIconUrl: string; | ||
| 65 | -// shareName: string; | ||
| 66 | -// shareSummary: string; | ||
| 67 | -// shareUrl: string; | ||
| 68 | -// statusBarColor: string; | ||
| 69 | -// templateType: number; | ||
| 70 | -// titleColor: string; | ||
| 71 | -// topicInfo: TopicInfo; | ||
| 72 | -// } | ||
| 73 | -// | ||
| 74 | -// export interface Meta { | ||
| 75 | -// md5: string; | ||
| 76 | -// } | ||
| 77 | -// | ||
| 78 | -// export interface RootObject { | ||
| 79 | -// code: string; | ||
| 80 | -// data: Data; | ||
| 81 | -// message: string; | ||
| 82 | -// meta: Meta; | ||
| 83 | -// requestId: string; | ||
| 84 | -// success: boolean; | ||
| 85 | -// timestamp: number; | ||
| 86 | -// } | ||
| 1 | +import { Group } from './Group'; | ||
| 2 | +import { TopicInfo } from './TopicInfo'; | ||
| 3 | + | ||
| 4 | +export interface PageInfoBean { | ||
| 5 | + backIconUrl: string; | ||
| 6 | + backgroundColor: string; | ||
| 7 | + backgroundImgUrl: string; | ||
| 8 | + baselineColor: string; | ||
| 9 | + baselineCopywriting: string; | ||
| 10 | + baselineShow: number; | ||
| 11 | + description: string; | ||
| 12 | + groups: Group[]; | ||
| 13 | + hasAdInfo: number; | ||
| 14 | + hasPopUp: number; | ||
| 15 | + id: number; | ||
| 16 | + mainLogoImgUrl: string; | ||
| 17 | + name: string; | ||
| 18 | + pageTopType: number; | ||
| 19 | + pageType: number; | ||
| 20 | + pushupLogoImgUrl: string; | ||
| 21 | + shareCoverUrl: string; | ||
| 22 | + shareIconUrl: string; | ||
| 23 | + shareName: string; | ||
| 24 | + shareSummary: string; | ||
| 25 | + shareUrl: string; | ||
| 26 | + statusBarColor: string; | ||
| 27 | + templateType: number; | ||
| 28 | + titleColor: string; | ||
| 29 | + topicInfo: TopicInfo; | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | + | ||
| 33 | + |
| 1 | +export interface TopicInfo { | ||
| 2 | + axisColor: string; | ||
| 3 | + commentFlag: number; | ||
| 4 | + commentPreviewFlag: number; | ||
| 5 | + commentShowFlag: number; | ||
| 6 | + posterFlag: number; | ||
| 7 | + posterUrl: string; | ||
| 8 | + shareCoverUrl: string; | ||
| 9 | + shareOpen: number; | ||
| 10 | + sharePosterCoverUrl: string; | ||
| 11 | + shareSummary: string; | ||
| 12 | + shareTitle: string; | ||
| 13 | + shareUrl: string; | ||
| 14 | + slideColor: string; | ||
| 15 | + summary: string; | ||
| 16 | + title: string; | ||
| 17 | + titleShow: number; | ||
| 18 | + topicDate: string; | ||
| 19 | + topicId: string; | ||
| 20 | + topicPattern: number; | ||
| 21 | + topicType: number; | ||
| 22 | + transluceImgUrl: string; | ||
| 23 | + visitorComment: number; | ||
| 24 | +} |
| @@ -5,15 +5,25 @@ import { Logger } from 'wdKit'; | @@ -5,15 +5,25 @@ import { Logger } from 'wdKit'; | ||
| 5 | import { ENewspaperItemComponent } from './ENewspaperItemComponent'; | 5 | import { ENewspaperItemComponent } from './ENewspaperItemComponent'; |
| 6 | import { ENewspaperListDialog } from '../dialog/ENewspaperListDialog'; | 6 | import { ENewspaperListDialog } from '../dialog/ENewspaperListDialog'; |
| 7 | import display from '@ohos.display'; | 7 | import display from '@ohos.display'; |
| 8 | +import { ENewspaperCalendarDialog } from '../dialog/ENewspaperCalendarDialog'; | ||
| 9 | +import font from '@ohos.font'; | ||
| 8 | 10 | ||
| 9 | @Component | 11 | @Component |
| 10 | export struct ENewspaperPageComponent { | 12 | export struct ENewspaperPageComponent { |
| 11 | @State newspaperListBean: NewspaperListBean = {} as NewspaperListBean | 13 | @State newspaperListBean: NewspaperListBean = {} as NewspaperListBean |
| 12 | @State currentPageNum: string = '01' | 14 | @State currentPageNum: string = '01' |
| 13 | @State pageNumPopup: boolean = false | 15 | @State pageNumPopup: boolean = false |
| 14 | - @State date: string = '2024-01-26' | 16 | + @State calendarPopup: boolean = false |
| 17 | + @State calendarDateTitle: string = '' | ||
| 15 | @State picHeight: number = 0 | 18 | @State picHeight: number = 0 |
| 16 | private swiperController: SwiperController = new SwiperController() | 19 | private swiperController: SwiperController = new SwiperController() |
| 20 | + calendarDialogController: CustomDialogController = new CustomDialogController({ | ||
| 21 | + builder: ENewspaperCalendarDialog(), | ||
| 22 | + alignment: DialogAlignment.Top, | ||
| 23 | + offset: { dx: 0, dy: 80 }, | ||
| 24 | + customStyle: true, | ||
| 25 | + // cornerRadius: 4 | ||
| 26 | + }) | ||
| 17 | listDialogController: CustomDialogController = new CustomDialogController({ | 27 | listDialogController: CustomDialogController = new CustomDialogController({ |
| 18 | builder: ENewspaperListDialog({ newspaperListBean: this.newspaperListBean, | 28 | builder: ENewspaperListDialog({ newspaperListBean: this.newspaperListBean, |
| 19 | currentPageNum: this.currentPageNum, | 29 | currentPageNum: this.currentPageNum, |
| @@ -64,9 +74,10 @@ export struct ENewspaperPageComponent { | @@ -64,9 +74,10 @@ export struct ENewspaperPageComponent { | ||
| 64 | }) | 74 | }) |
| 65 | 75 | ||
| 66 | Row() { | 76 | Row() { |
| 67 | - Text(this.date) | 77 | + Text(this.calendarDateTitle) |
| 68 | .fontSize($r('app.float.font_size_20')) | 78 | .fontSize($r('app.float.font_size_20')) |
| 69 | .fontColor($r('app.color.white')) | 79 | .fontColor($r('app.color.white')) |
| 80 | + .fontFamily('BebasNeue_Regular') | ||
| 70 | 81 | ||
| 71 | Image($r('app.media.icon_triangle')) | 82 | Image($r('app.media.icon_triangle')) |
| 72 | .width($r('app.float.border_radius_6')) | 83 | .width($r('app.float.border_radius_6')) |
| @@ -77,6 +88,14 @@ export struct ENewspaperPageComponent { | @@ -77,6 +88,14 @@ export struct ENewspaperPageComponent { | ||
| 77 | .alignRules({ middle: { anchor: "__container__", align: HorizontalAlign.Center }, | 88 | .alignRules({ middle: { anchor: "__container__", align: HorizontalAlign.Center }, |
| 78 | center: { anchor: "__container__", align: VerticalAlign.Center } }) | 89 | center: { anchor: "__container__", align: VerticalAlign.Center } }) |
| 79 | .id('e_newspaper_date') | 90 | .id('e_newspaper_date') |
| 91 | + .onClick(() => { | ||
| 92 | + this.calendarPopup = !this.calendarPopup | ||
| 93 | + if (this.calendarPopup) { | ||
| 94 | + this.calendarDialogController.open() | ||
| 95 | + } else { | ||
| 96 | + this.calendarDialogController.close() | ||
| 97 | + } | ||
| 98 | + }) | ||
| 80 | 99 | ||
| 81 | Image($r('app.media.icon_share')) | 100 | Image($r('app.media.icon_share')) |
| 82 | .height($r('app.float.top_arrow_size')) | 101 | .height($r('app.float.top_arrow_size')) |
| @@ -193,25 +212,25 @@ export struct ENewspaperPageComponent { | @@ -193,25 +212,25 @@ export struct ENewspaperPageComponent { | ||
| 193 | } | 212 | } |
| 194 | 213 | ||
| 195 | async aboutToAppear() { | 214 | async aboutToAppear() { |
| 215 | + //注册字体 | ||
| 216 | + font.registerFont({ | ||
| 217 | + familyName: 'BebasNeue_Regular', | ||
| 218 | + // familySrc: '/font/roboto_medium_numbers.ttf' // font文件夹与pages目录同级 | ||
| 219 | + familySrc: $rawfile('font/BebasNeue_Regular.otf') | ||
| 220 | + }) | ||
| 196 | let newspaperTimes = await NewspaperViewModel.getNewspaperTime() | 221 | let newspaperTimes = await NewspaperViewModel.getNewspaperTime() |
| 197 | if (newspaperTimes && newspaperTimes.length > 0) { | 222 | if (newspaperTimes && newspaperTimes.length > 0) { |
| 198 | - this.date = newspaperTimes[0].date | 223 | + this.calendarDateTitle = newspaperTimes[0].date |
| 199 | } | 224 | } |
| 200 | try { | 225 | try { |
| 201 | let displayTool = display.getDefaultDisplaySync() | 226 | let displayTool = display.getDefaultDisplaySync() |
| 202 | let screenWidth = displayTool.width | 227 | let screenWidth = displayTool.width |
| 203 | let picWidth = screenWidth - vp2px(52) | 228 | let picWidth = screenWidth - vp2px(52) |
| 204 | this.picHeight = picWidth * 566 / 378 | 229 | this.picHeight = picWidth * 566 / 378 |
| 205 | - let listBean = await NewspaperViewModel.getNewspaperList(this.date, picWidth + 'x' + this.picHeight) | 230 | + let listBean = await NewspaperViewModel.getNewspaperList(this.calendarDateTitle, picWidth + 'x' + this.picHeight) |
| 206 | this.newspaperListBean = listBean; | 231 | this.newspaperListBean = listBean; |
| 207 | } catch (exception) { | 232 | } catch (exception) { |
| 208 | 233 | ||
| 209 | } | 234 | } |
| 210 | - | ||
| 211 | - | ||
| 212 | - } | ||
| 213 | - | ||
| 214 | - aboutToDisappear() { | ||
| 215 | - | ||
| 216 | } | 235 | } |
| 217 | } | 236 | } |
| 1 | -import { MorningEveningPaperDTO } from 'wdBean' | 1 | +import { MorningEveningPaperDTO, PageInfoBean } from 'wdBean' |
| 2 | +import { Logger } from 'wdKit/Index'; | ||
| 2 | import { DateTimeUtils } from 'wdKit/src/main/ets/utils/DateTimeUtils'; | 3 | import { DateTimeUtils } from 'wdKit/src/main/ets/utils/DateTimeUtils'; |
| 4 | +import { MorningEveningViewModel } from '../../viewmodel/MorningEveningViewModel'; | ||
| 3 | import { AudioBarView } from './AudioBarView'; | 5 | import { AudioBarView } from './AudioBarView'; |
| 4 | import { PaperTitleComponent } from './PaperTitleComponent'; | 6 | import { PaperTitleComponent } from './PaperTitleComponent'; |
| 5 | import { SingleColumn999Component } from './SingleColumn999Component'; | 7 | import { SingleColumn999Component } from './SingleColumn999Component'; |
| @@ -12,6 +14,8 @@ const PATTERN_DATE_CN_RN: string = 'yyyy年\nMM月dd日'; // 日期中包含包 | @@ -12,6 +14,8 @@ const PATTERN_DATE_CN_RN: string = 'yyyy年\nMM月dd日'; // 日期中包含包 | ||
| 12 | @Entry | 14 | @Entry |
| 13 | @Component | 15 | @Component |
| 14 | export struct MorningEveningPaperComponent { | 16 | export struct MorningEveningPaperComponent { |
| 17 | + @State pageInfoBean: PageInfoBean = {} as PageInfoBean | ||
| 18 | + | ||
| 15 | @State morningEveningPaperDTO: MorningEveningPaperDTO = { | 19 | @State morningEveningPaperDTO: MorningEveningPaperDTO = { |
| 16 | name: "新闻夜读", | 20 | name: "新闻夜读", |
| 17 | topicInfo: { | 21 | topicInfo: { |
| @@ -30,10 +34,21 @@ export struct MorningEveningPaperComponent { | @@ -30,10 +34,21 @@ export struct MorningEveningPaperComponent { | ||
| 30 | } as MorningEveningPaperDTO | 34 | } as MorningEveningPaperDTO |
| 31 | @State subTitle: string = '' | 35 | @State subTitle: string = '' |
| 32 | 36 | ||
| 33 | - aboutToAppear() { | 37 | + async aboutToAppear() { |
| 34 | console.info(TAG, `aboutToAppear`); | 38 | console.info(TAG, `aboutToAppear`); |
| 35 | let dateTime = DateTimeUtils.parseDate(this.morningEveningPaperDTO?.topicInfo?.topicDate ?? '', DateTimeUtils.PATTERN_DATE_HYPHEN); | 39 | let dateTime = DateTimeUtils.parseDate(this.morningEveningPaperDTO?.topicInfo?.topicDate ?? '', DateTimeUtils.PATTERN_DATE_HYPHEN); |
| 36 | this.subTitle = DateTimeUtils.formatDate(dateTime, PATTERN_DATE_CN_RN) | 40 | this.subTitle = DateTimeUtils.formatDate(dateTime, PATTERN_DATE_CN_RN) |
| 41 | + | ||
| 42 | + try { | ||
| 43 | + let listBean = await MorningEveningViewModel.getMorningEveningPageInfo("28927") | ||
| 44 | + Logger.info(TAG,"listBean title = "+listBean.topicInfo.title) | ||
| 45 | + Logger.info(TAG,"listBean topicDate = "+listBean.topicInfo.topicDate) | ||
| 46 | + this.pageInfoBean = listBean; | ||
| 47 | + let compInfoBean = await MorningEveningViewModel.getMorningEveningCompInfo("28927") | ||
| 48 | + Logger.info(TAG,"compInfoBean compStyle = "+compInfoBean.compList[0].compStyle) | ||
| 49 | + } catch (exception) { | ||
| 50 | + | ||
| 51 | + } | ||
| 37 | } | 52 | } |
| 38 | 53 | ||
| 39 | build() { | 54 | build() { |
| 1 | +import { RMCalendarBean } from './RMCalendarBean' | ||
| 2 | +import { RMCalenderCell } from './RMCalendarCell' | ||
| 3 | + | ||
| 4 | +const TAG = "RMCalendar" | ||
| 5 | + | ||
| 6 | +@Component | ||
| 7 | +export struct RMCalendar { | ||
| 8 | + @State selectItem: RMCalendarBean = new RMCalendarBean() | ||
| 9 | + private today: Date = new Date() // 当天 | ||
| 10 | + // 开始日期 | ||
| 11 | + startDate: Date = new Date() | ||
| 12 | + // 截止日期 | ||
| 13 | + endDate: Date = new Date() | ||
| 14 | + //当前日期-当前显示的月份的第一天 | ||
| 15 | + private startDay: Date = new Date( | ||
| 16 | + this.today.getFullYear(), | ||
| 17 | + this.today.getMonth(), | ||
| 18 | + 1 | ||
| 19 | + ) | ||
| 20 | + // 是否有上一个月 | ||
| 21 | + @State private hasPre: boolean = true | ||
| 22 | + // 是否有下一个月 | ||
| 23 | + @State private hasNext: boolean = true | ||
| 24 | + // 标题栏高度 | ||
| 25 | + titleHeight: Length = '50vp' | ||
| 26 | + // 星期标题 | ||
| 27 | + weeks: string[] = ["日", "一", "二", "三", "四", "五", "六",] | ||
| 28 | + // 星期标题字体大小 | ||
| 29 | + weekTitleFontSize: number | string | Resource = 12 | ||
| 30 | + // 星期标题字体颜色 | ||
| 31 | + weekTitleFontColor: ResourceColor = "#999999" | ||
| 32 | + // 星期标栏高度 | ||
| 33 | + weekTitleHeight: Length = 30 | ||
| 34 | + weekFontWeight: FontWeight = FontWeight.Bold | ||
| 35 | + // 标题字体大小 | ||
| 36 | + titleFontSize: number | string | Resource = 16 | ||
| 37 | + // 标题字体颜色 | ||
| 38 | + titleFontColor: ResourceColor = "#333333" | ||
| 39 | + titleFontWeight: FontWeight = FontWeight.Bold | ||
| 40 | + // 日期每一项字体大小 | ||
| 41 | + itemFontSize: number | string | Resource = 14 | ||
| 42 | + itemFontColor: ResourceColor = "#333333" | ||
| 43 | + itemFontWeight: FontWeight = FontWeight.Bold | ||
| 44 | + // 今日字体颜色 | ||
| 45 | + todayFontColor: ResourceColor = "#ED2800" | ||
| 46 | + // 不能使用的日期字体颜色 | ||
| 47 | + disabledFontColor: ResourceColor = "#CCCCCC" | ||
| 48 | + // 选中日期字体颜色 | ||
| 49 | + selectFontColor: ResourceColor = "#FFFFFF" | ||
| 50 | + // 选中日期背景颜色, 默认与todayFontColor一致 | ||
| 51 | + selectItemBgColor: ResourceColor = "#ED2800" | ||
| 52 | + @State private title: string = '' | ||
| 53 | + // 计算的总加载 | ||
| 54 | + @State dates: Array<RMCalendarBean> = new Array() | ||
| 55 | + // 已选日期 | ||
| 56 | + @State selectedDates: Array<RMCalendarBean> = new Array() | ||
| 57 | + // 自定义每一项布局 | ||
| 58 | + public cellLayout?: (item: RMCalendarBean) => void | ||
| 59 | + // 仅自定义 今日 样式,当使用cellLayout时,tadayLayout无效 | ||
| 60 | + todayLayout?: (item: RMCalendarBean) => void | ||
| 61 | + // 计算item时,如需添加更多自定义属性时使用 | ||
| 62 | + reBuildDateItem?: (item: RMCalendarBean) => RMCalendarBean | ||
| 63 | + // 选择变化监听, | ||
| 64 | + onDateChange?: (date1: RMCalendarBean) => void | ||
| 65 | + onMonthChange?: (after: Date, befor: Date) => void | ||
| 66 | + // 不可选中项的点击事件 | ||
| 67 | + disableCellClick?: (item: RMCalendarBean) => void | ||
| 68 | + | ||
| 69 | + @Builder | ||
| 70 | + createWeekTitle(item: string) { | ||
| 71 | + Text(item) | ||
| 72 | + .textAlign(TextAlign.Center) | ||
| 73 | + .fontColor(this.weekTitleFontColor) | ||
| 74 | + .fontSize(this.weekTitleFontSize) | ||
| 75 | + .fontWeight(this.weekFontWeight) | ||
| 76 | + .layoutWeight(1) | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + @Builder | ||
| 80 | + createCell() { | ||
| 81 | + ForEach(this.dates, (item: RMCalendarBean) => { | ||
| 82 | + RMCalenderCell({ | ||
| 83 | + item: item, | ||
| 84 | + cellLayout: this.cellLayout, | ||
| 85 | + itemFontSize: this.itemFontSize, | ||
| 86 | + itemFontColor: this.itemFontColor, | ||
| 87 | + today: this.today.getTime(), | ||
| 88 | + itemFontWeight: this.itemFontWeight, | ||
| 89 | + todayFontColor: this.todayFontColor, | ||
| 90 | + todayLayout: this.todayLayout, | ||
| 91 | + selectItem: $selectItem, | ||
| 92 | + selectFontColor: this.selectFontColor, | ||
| 93 | + selectItemBgColor: this.selectItemBgColor, | ||
| 94 | + selectedDates: $selectedDates, | ||
| 95 | + disabledFontColor: this.disabledFontColor, | ||
| 96 | + hasPre: this.hasPre, | ||
| 97 | + hasNext: this.hasNext, | ||
| 98 | + disableClick: (item: RMCalendarBean) => { | ||
| 99 | + if (this.disableCellClick) { | ||
| 100 | + this.disableCellClick(item) | ||
| 101 | + } | ||
| 102 | + }, | ||
| 103 | + cellClick: (item: RMCalendarBean) => { | ||
| 104 | + if (item.isPre) { | ||
| 105 | + this.preMonth() | ||
| 106 | + } else if (item.isNext) { | ||
| 107 | + this.nextMonth() | ||
| 108 | + } | ||
| 109 | + if (this.onDateChange) { | ||
| 110 | + this.onDateChange(item) | ||
| 111 | + if (item.fullYear && item.month) { | ||
| 112 | + this.title = `${item.fullYear}年${item.month + 1}月` | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + } | ||
| 116 | + }) | ||
| 117 | + .width(`14.28%`) | ||
| 118 | + }, (item: RMCalendarBean) => JSON.stringify(item)) | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + /** | ||
| 122 | + * 属性初始化 | ||
| 123 | + */ | ||
| 124 | + initAttr() { | ||
| 125 | + if (!this.selectItemBgColor) { | ||
| 126 | + this.selectItemBgColor = this.todayFontColor | ||
| 127 | + } | ||
| 128 | + this.today = new Date( | ||
| 129 | + this.today.getFullYear(), | ||
| 130 | + this.today.getMonth(), | ||
| 131 | + this.today.getDate(), | ||
| 132 | + ) | ||
| 133 | + | ||
| 134 | + // 开始日期 | ||
| 135 | + if (!this.startDate) { | ||
| 136 | + this.startDate = new Date(1970, 0, 1) | ||
| 137 | + } | ||
| 138 | + // 截止日期 | ||
| 139 | + if (!this.endDate) { | ||
| 140 | + this.endDate = new Date(this.today.getFullYear() + 10, 11, 31) | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + if (this.today.getTime() < this.startDate.getTime()) { | ||
| 144 | + this.startDay.setTime(this.startDate.getTime()) | ||
| 145 | + } else if (this.today.getTime() > this.endDate.getTime()) { | ||
| 146 | + this.startDay.setTime(this.endDate.getTime()) | ||
| 147 | + } else { | ||
| 148 | + this.startDay.setTime(this.today.getTime()) | ||
| 149 | + } | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + aboutToAppear() { | ||
| 153 | + this.initAttr() | ||
| 154 | + let temp = new RMCalendarBean() | ||
| 155 | + temp.time = this.today.getTime() | ||
| 156 | + this.selectItem = temp | ||
| 157 | + this.calcDatas() | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + /** | ||
| 161 | + * 下一个月 | ||
| 162 | + */ | ||
| 163 | + private nextMonth() { | ||
| 164 | + // this.dates.slice(0, this.dates.length) | ||
| 165 | + this.dates = [] | ||
| 166 | + const beforDate = new Date(this.startDay.getFullYear(), this.startDay.getMonth()) | ||
| 167 | + this.startDay.setMonth(this.startDay.getMonth() + 1) | ||
| 168 | + if (this.onMonthChange) { | ||
| 169 | + this.onMonthChange(new Date(this.startDay.getFullYear(), this.startDay.getMonth()), beforDate) | ||
| 170 | + } | ||
| 171 | + this.calcDatas() | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + /** | ||
| 175 | + * 上一个月 | ||
| 176 | + */ | ||
| 177 | + private preMonth() { | ||
| 178 | + // this.dates.slice(0, this.dates.length) | ||
| 179 | + this.dates = [] | ||
| 180 | + const beforDate = new Date(this.startDay.getFullYear(), this.startDay.getMonth()) | ||
| 181 | + this.startDay.setMonth(this.startDay.getMonth() - 1) | ||
| 182 | + if (this.onMonthChange) { | ||
| 183 | + this.onMonthChange(new Date(this.startDay.getFullYear(), this.startDay.getMonth()), beforDate) | ||
| 184 | + } | ||
| 185 | + this.calcDatas() | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + /** | ||
| 189 | + * 具体计算 | ||
| 190 | + */ | ||
| 191 | + private calcDatas() { | ||
| 192 | + const startDay = this.startDay | ||
| 193 | + this.title = `${startDay.getFullYear()}年${startDay.getMonth() + 1}月` | ||
| 194 | + startDay.setDate(1) | ||
| 195 | + | ||
| 196 | + if (startDay.getFullYear() < this.startDate.getFullYear() | ||
| 197 | + || (startDay.getFullYear() == this.startDate.getFullYear() && startDay.getMonth() <= this.startDate.getMonth())) { | ||
| 198 | + this.hasPre = false | ||
| 199 | + } else { | ||
| 200 | + this.hasPre = true | ||
| 201 | + } | ||
| 202 | + | ||
| 203 | + if (startDay.getFullYear() > this.endDate.getFullYear() | ||
| 204 | + || (startDay.getFullYear() == this.endDate.getFullYear() && startDay.getMonth() >= this.endDate.getMonth())) { | ||
| 205 | + this.hasNext = false | ||
| 206 | + } else { | ||
| 207 | + this.hasNext = true | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + // 计算第一个月 | ||
| 211 | + // 获取第一个月总天数 | ||
| 212 | + let endDay: Date = new Date( | ||
| 213 | + startDay.getFullYear(), | ||
| 214 | + startDay.getMonth() + 1, | ||
| 215 | + 0, 23, 59, 59) | ||
| 216 | + | ||
| 217 | + let tempDate: Date = new Date( | ||
| 218 | + startDay.getFullYear(), | ||
| 219 | + startDay.getMonth(), | ||
| 220 | + startDay.getDate() | ||
| 221 | + ) | ||
| 222 | + | ||
| 223 | + const count = endDay.getDate() | ||
| 224 | + const preCount = startDay.getDay() | ||
| 225 | + // const nextCount = 6 - endDay.getDay() | ||
| 226 | + const nextCount = 0 | ||
| 227 | + const finilCount = count + preCount + nextCount | ||
| 228 | + | ||
| 229 | + // 补齐上一个月 | ||
| 230 | + tempDate.setDate(tempDate.getDate() - preCount) | ||
| 231 | + | ||
| 232 | + // 添加日期 | ||
| 233 | + for (let index = 0; index < finilCount; index++) { | ||
| 234 | + let item = new RMCalendarBean( | ||
| 235 | + tempDate.getFullYear(), | ||
| 236 | + tempDate.getMonth(), | ||
| 237 | + tempDate.getDate(), | ||
| 238 | + tempDate.getDay(), | ||
| 239 | + tempDate.getTime(), | ||
| 240 | + // @ ts-ignore | ||
| 241 | + // LunarCalendar.convertSolarToLunar(tempDate), | ||
| 242 | + (index < preCount ? true : false) || this.startDate.getTime() > tempDate.getTime(), | ||
| 243 | + (index >= preCount + count ? true : false) || this.endDate.getTime() < tempDate.getTime(), | ||
| 244 | + ) | ||
| 245 | + if (this.reBuildDateItem) { | ||
| 246 | + this.reBuildDateItem(item) | ||
| 247 | + } | ||
| 248 | + this.dates.push(item) | ||
| 249 | + tempDate.setDate(tempDate.getDate() + 1) | ||
| 250 | + } | ||
| 251 | + } | ||
| 252 | + | ||
| 253 | + build() { | ||
| 254 | + Column() { | ||
| 255 | + Image($r("app.media.iv_e_news_pager_calendar_arrow_up")) | ||
| 256 | + .width(18).height(8.5) | ||
| 257 | + Column() { | ||
| 258 | + Row() { | ||
| 259 | + Column() { | ||
| 260 | + Image(this.hasPre ? $r("app.media.iv_e_news_pager_calendar_arrow_pre") | ||
| 261 | + : $r("app.media.iv_e_news_pager_calendar_arrow_pre_gray")) | ||
| 262 | + .width(22) | ||
| 263 | + .aspectRatio(1) | ||
| 264 | + } | ||
| 265 | + .justifyContent(FlexAlign.Center) | ||
| 266 | + .height("100%") | ||
| 267 | + .aspectRatio(1) | ||
| 268 | + .onClick(() => { | ||
| 269 | + if (this.hasPre) { | ||
| 270 | + this.preMonth() | ||
| 271 | + } | ||
| 272 | + }) | ||
| 273 | + | ||
| 274 | + Blank() | ||
| 275 | + Row() { | ||
| 276 | + Text(this.title) | ||
| 277 | + .fontSize(this.titleFontSize) | ||
| 278 | + .fontColor(this.titleFontColor) | ||
| 279 | + .fontWeight(this.titleFontWeight) | ||
| 280 | + } | ||
| 281 | + | ||
| 282 | + Blank() | ||
| 283 | + Column() { | ||
| 284 | + Image(this.hasNext ? $r("app.media.iv_e_news_pager_calendar_arrow_next") | ||
| 285 | + : $r("app.media.iv_e_news_pager_calendar_arrow_next_gray")) | ||
| 286 | + .width(22) | ||
| 287 | + .aspectRatio(1) | ||
| 288 | + } | ||
| 289 | + .justifyContent(FlexAlign.Center) | ||
| 290 | + .height("100%") | ||
| 291 | + .aspectRatio(1) | ||
| 292 | + .onClick(() => { | ||
| 293 | + if (this.hasNext) { | ||
| 294 | + this.nextMonth() | ||
| 295 | + } | ||
| 296 | + }) | ||
| 297 | + } | ||
| 298 | + .alignItems(VerticalAlign.Center) | ||
| 299 | + .width("100%") | ||
| 300 | + .height(this.titleHeight) | ||
| 301 | + | ||
| 302 | + // 星期title | ||
| 303 | + Row() { | ||
| 304 | + ForEach(this.weeks, (item: string) => { | ||
| 305 | + this.createWeekTitle(item) | ||
| 306 | + }, (item: string) => { | ||
| 307 | + return item | ||
| 308 | + }) | ||
| 309 | + } | ||
| 310 | + .alignItems(VerticalAlign.Center) | ||
| 311 | + .height(this.weekTitleHeight) | ||
| 312 | + | ||
| 313 | + Flex({ wrap: FlexWrap.Wrap }) { | ||
| 314 | + this.createCell() | ||
| 315 | + } | ||
| 316 | + .width("100%") | ||
| 317 | + } | ||
| 318 | + .backgroundColor(Color.White) | ||
| 319 | + .margin({ | ||
| 320 | + left: 35, | ||
| 321 | + right: 35 | ||
| 322 | + }) | ||
| 323 | + .border({ radius: 4 }) | ||
| 324 | + } | ||
| 325 | + } | ||
| 326 | +} |
| 1 | +@Observed | ||
| 2 | +export class RMCalendarBean { | ||
| 3 | + fullYear?: number | ||
| 4 | + month?: number | ||
| 5 | + date?: number | ||
| 6 | + week?: number | ||
| 7 | + time?: number | ||
| 8 | + isPre?: boolean // 是否是上一个月的 / 在startDate 之前 | ||
| 9 | + isNext?: boolean // 是否是下一个月的 / 在endDate 之后 | ||
| 10 | + | ||
| 11 | + constructor(fullYear?: number, month?: number, | ||
| 12 | + date?: number, day?: number, | ||
| 13 | + time?: number, | ||
| 14 | + isPre?: boolean, | ||
| 15 | + isNext?: boolean) { | ||
| 16 | + this.fullYear = fullYear | ||
| 17 | + this.month = month | ||
| 18 | + this.date = date | ||
| 19 | + this.week = day | ||
| 20 | + this.time = time | ||
| 21 | + this.isPre = isPre | ||
| 22 | + this.isNext = isNext | ||
| 23 | + } | ||
| 24 | +} |
| 1 | +import { RMCalendarBean } from './RMCalendarBean'; | ||
| 2 | +import font from '@ohos.font'; | ||
| 3 | + | ||
| 4 | +@Component | ||
| 5 | +export struct RMCalenderCell { | ||
| 6 | + private selectOpacity: number = 0.15 | ||
| 7 | + itemFontSize: Length = 0 | ||
| 8 | + itemFontColor: ResourceColor = {} as ResourceColor | ||
| 9 | + itemFontWeight: FontWeight = FontWeight.Normal | ||
| 10 | + todayFontColor: ResourceColor = {} as ResourceColor | ||
| 11 | + selectFontColor: ResourceColor = {} as ResourceColor | ||
| 12 | + selectItemBgColor: ResourceColor = {} as ResourceColor | ||
| 13 | + disabledFontColor: ResourceColor = {} as ResourceColor | ||
| 14 | + // 今日时间戳 | ||
| 15 | + today: number = 0 | ||
| 16 | + @Link selectItem: RMCalendarBean | ||
| 17 | + @Link selectedDates: Array<RMCalendarBean> | ||
| 18 | + @Prop hasPre: boolean | ||
| 19 | + @Prop hasNext: boolean | ||
| 20 | + @ObjectLink item: RMCalendarBean | ||
| 21 | + // 自定义每一项布局 | ||
| 22 | + cellLayout?: (item: RMCalendarBean) => void | ||
| 23 | + todayLayout?: (item: RMCalendarBean) => void | ||
| 24 | + cellClick?: (item: RMCalendarBean) => void | ||
| 25 | + disableClick?: (item: RMCalendarBean) => void | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * 检测是否包含在数组中 | ||
| 29 | + */ | ||
| 30 | + checkInArrays() { | ||
| 31 | + for (let index = 0; index < this.selectedDates.length; index++) { | ||
| 32 | + if (this.item.time == this.selectedDates[index].time) { | ||
| 33 | + return index | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | + return -1 | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + getItemColor() { | ||
| 40 | + if (this.item.isPre) { | ||
| 41 | + return this.disabledFontColor | ||
| 42 | + } else if (this.item.isNext) { | ||
| 43 | + return this.disabledFontColor | ||
| 44 | + } else if (this.selectItem && this.selectItem.time == this.item.time) { | ||
| 45 | + return this.selectFontColor | ||
| 46 | + } else if (this.item.time == this.today) { | ||
| 47 | + return this.todayFontColor | ||
| 48 | + } | ||
| 49 | + return this.itemFontColor | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + getBorder() { | ||
| 53 | + if (this.selectItem && this.selectItem.time == this.item.time) { | ||
| 54 | + return this.border({ | ||
| 55 | + width: 1, | ||
| 56 | + color: this.getItemColor() | ||
| 57 | + }) | ||
| 58 | + } else { | ||
| 59 | + return this.border({ | ||
| 60 | + width: 0, | ||
| 61 | + } | ||
| 62 | + ) | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * 获取选中项背景颜色 | ||
| 68 | + */ | ||
| 69 | + getSelectItemBg() { | ||
| 70 | + return this.selectItemBgColor | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + /** | ||
| 74 | + * 获取选中项背景透明度 | ||
| 75 | + * @returns | ||
| 76 | + */ | ||
| 77 | + getSelectItemBgOpa() { | ||
| 78 | + return this.item.isPre || this.item.isNext ? this.selectOpacity : 1 | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + /** | ||
| 82 | + * 是否需要显示选项背景 | ||
| 83 | + */ | ||
| 84 | + isShowSelectBg() { | ||
| 85 | + return this.selectItem && this.selectItem.time == this.item.time | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + build() { | ||
| 89 | + Column() { | ||
| 90 | + Stack() { | ||
| 91 | + if (!this.item.isPre) { | ||
| 92 | + if (this.isShowSelectBg()) { | ||
| 93 | + Column()// .position({ x: "10%", y: "10%" }) | ||
| 94 | + .height("80%") | ||
| 95 | + .aspectRatio(1)// .borderRadius(999) | ||
| 96 | + .backgroundColor(this.getSelectItemBg()) | ||
| 97 | + .opacity(this.getSelectItemBgOpa()) | ||
| 98 | + .transition({ type: TransitionType.Insert, opacity: 1 }) | ||
| 99 | + .transition({ type: TransitionType.Delete, opacity: 0 }) | ||
| 100 | + } | ||
| 101 | + Text(this.item.date + '') | ||
| 102 | + .fontSize(this.itemFontSize) | ||
| 103 | + .fontColor(this.getItemColor()) | ||
| 104 | + .fontWeight(this.itemFontWeight) | ||
| 105 | + .fontFamily('BebasNeue_Regular') | ||
| 106 | + } | ||
| 107 | + } | ||
| 108 | + // .justifyContent(FlexAlign.Center) | ||
| 109 | + .aspectRatio(1) | ||
| 110 | + // .border(this.getBorder()) | ||
| 111 | + .width("80%") | ||
| 112 | + } | ||
| 113 | + .justifyContent(FlexAlign.Center) | ||
| 114 | + // .width("100%") | ||
| 115 | + // .aspectRatio(1) | ||
| 116 | + .onClick(() => { | ||
| 117 | + // animateTo({ duration: 200 }, () => { | ||
| 118 | + // | ||
| 119 | + // }) | ||
| 120 | + | ||
| 121 | + if (this.item.isNext) { | ||
| 122 | + if (!this.hasNext) { | ||
| 123 | + if (this.disableClick) { | ||
| 124 | + this.disableClick(this.item) | ||
| 125 | + } | ||
| 126 | + return | ||
| 127 | + } | ||
| 128 | + } | ||
| 129 | + if (this.item.isPre) { | ||
| 130 | + // if (!this.hasPre) { | ||
| 131 | + if (this.disableClick) { | ||
| 132 | + this.disableClick(this.item) | ||
| 133 | + } | ||
| 134 | + return | ||
| 135 | + // } | ||
| 136 | + } | ||
| 137 | + this.selectItem = this.item | ||
| 138 | + if (this.cellClick) { | ||
| 139 | + this.cellClick(this.item) | ||
| 140 | + } | ||
| 141 | + }) | ||
| 142 | + } | ||
| 143 | +} |
| @@ -98,7 +98,7 @@ export struct TopNavigationComponent { | @@ -98,7 +98,7 @@ export struct TopNavigationComponent { | ||
| 98 | } | 98 | } |
| 99 | .width('100%') | 99 | .width('100%') |
| 100 | .height(40) | 100 | .height(40) |
| 101 | - .visibility(this._currentNavIndex != 2 ? Visibility.Visible : Visibility.None) | 101 | + .visibility(this._currentNavIndex == 0 ? Visibility.Visible : Visibility.None) |
| 102 | 102 | ||
| 103 | Tabs() { | 103 | Tabs() { |
| 104 | ForEach(this.topNavList, (navItem: TopNavDTO, index: number) => { | 104 | ForEach(this.topNavList, (navItem: TopNavDTO, index: number) => { |
| 1 | +import { RMCalendar } from '../components/calendar/RMCalendar' | ||
| 2 | +import { RMCalendarBean } from '../components/calendar/RMCalendarBean' | ||
| 3 | + | ||
| 4 | +@CustomDialog | ||
| 5 | +export struct ENewspaperCalendarDialog { | ||
| 6 | + calendarDialogController?: CustomDialogController | ||
| 7 | + | ||
| 8 | + build() { | ||
| 9 | + RMCalendar({ | ||
| 10 | + // 开始日期 | ||
| 11 | + startDate: new Date(2023, 8, 1), | ||
| 12 | + // 截止日期 | ||
| 13 | + endDate: new Date(2024, 2, 20), | ||
| 14 | + // 日期选择变化监听 | ||
| 15 | + onDateChange: (date1: RMCalendarBean) => { | ||
| 16 | + console.log("onDateChange", "date1:", JSON.stringify(date1)) | ||
| 17 | + if (this.calendarDialogController) { | ||
| 18 | + this.calendarDialogController.close() | ||
| 19 | + } | ||
| 20 | + } | ||
| 21 | + }) | ||
| 22 | + } | ||
| 23 | +} |
| 1 | import HashMap from '@ohos.util.HashMap'; | 1 | import HashMap from '@ohos.util.HashMap'; |
| 2 | import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork'; | 2 | import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork'; |
| 3 | -import { DateTimeUtils } from 'wdKit'; | 3 | +import { DateTimeUtils, Logger } from 'wdKit'; |
| 4 | import { ContentDetailDTO, NavigationBodyDTO, PageDTO,InteractDataDTO, MorningEveningPaperDTO, | 4 | import { ContentDetailDTO, NavigationBodyDTO, PageDTO,InteractDataDTO, MorningEveningPaperDTO, |
| 5 | NewspaperTimeInfoBean, | 5 | NewspaperTimeInfoBean, |
| 6 | - NewspaperListBean | 6 | + NewspaperListBean, |
| 7 | + PageInfoBean, | ||
| 8 | + CompInfoBean | ||
| 7 | } from 'wdBean'; | 9 | } from 'wdBean'; |
| 8 | - | 10 | +const TAG = 'HttpRequest'; |
| 9 | export class PageRepository { | 11 | export class PageRepository { |
| 10 | static getBottomNavGroupUrl() { | 12 | static getBottomNavGroupUrl() { |
| 11 | // https: //pd-apis-uat.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup | 13 | // https: //pd-apis-uat.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup |
| @@ -22,6 +24,7 @@ export class PageRepository { | @@ -22,6 +24,7 @@ export class PageRepository { | ||
| 22 | + "&refreshTime=" + DateTimeUtils.getTimeStamp() | 24 | + "&refreshTime=" + DateTimeUtils.getTimeStamp() |
| 23 | + "&pageId=" + pageId | 25 | + "&pageId=" + pageId |
| 24 | // Logger.debug("TAG", 'getCompInfoUrl url: '+url); | 26 | // Logger.debug("TAG", 'getCompInfoUrl url: '+url); |
| 27 | + Logger.info(TAG,"getPageInfoUrl url = "+url) | ||
| 25 | return url; | 28 | return url; |
| 26 | } | 29 | } |
| 27 | 30 | ||
| @@ -39,6 +42,7 @@ export class PageRepository { | @@ -39,6 +42,7 @@ export class PageRepository { | ||
| 39 | + "&pageSize=" + pageSize | 42 | + "&pageSize=" + pageSize |
| 40 | + "&pageNum=" + currentPage; | 43 | + "&pageNum=" + currentPage; |
| 41 | // Logger.debug("TAG", 'getCompInfoUrl url: '+url); | 44 | // Logger.debug("TAG", 'getCompInfoUrl url: '+url); |
| 45 | + Logger.info(TAG,"getCompInfoUrl url = "+url) | ||
| 42 | return url; | 46 | return url; |
| 43 | } | 47 | } |
| 44 | 48 | ||
| @@ -48,16 +52,19 @@ export class PageRepository { | @@ -48,16 +52,19 @@ export class PageRepository { | ||
| 48 | + "&contentId=" + contentId | 52 | + "&contentId=" + contentId |
| 49 | + "&relType=" + relType; | 53 | + "&relType=" + relType; |
| 50 | // Logger.debug("TAG", 'getCompInfoUrl url: '+url); | 54 | // Logger.debug("TAG", 'getCompInfoUrl url: '+url); |
| 55 | + Logger.info(TAG,"getDetailInfoUrl url = "+url) | ||
| 51 | return url; | 56 | return url; |
| 52 | } | 57 | } |
| 53 | 58 | ||
| 54 | static getInteractDataUrl() { | 59 | static getInteractDataUrl() { |
| 55 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH; | 60 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH; |
| 61 | + Logger.info(TAG,"getInteractDataUrl url = "+url) | ||
| 56 | return url; | 62 | return url; |
| 57 | } | 63 | } |
| 58 | 64 | ||
| 59 | static getNewspaperInfoUrl() { | 65 | static getNewspaperInfoUrl() { |
| 60 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.E_NEWSPAPER_INFO_PATH; | 66 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.E_NEWSPAPER_INFO_PATH; |
| 67 | + Logger.info(TAG,"getNewspaperInfoUrl url = "+url) | ||
| 61 | return url; | 68 | return url; |
| 62 | } | 69 | } |
| 63 | 70 | ||
| @@ -65,6 +72,28 @@ export class PageRepository { | @@ -65,6 +72,28 @@ export class PageRepository { | ||
| 65 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.E_NEWSPAPER_LIST_PATH; | 72 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.E_NEWSPAPER_LIST_PATH; |
| 66 | url = url + "?date=" + date | 73 | url = url + "?date=" + date |
| 67 | + "&pagesSize=" + pageSize; | 74 | + "&pagesSize=" + pageSize; |
| 75 | + Logger.info(TAG,"getNewspaperListUrl url = "+url) | ||
| 76 | + return url; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + /** | ||
| 80 | + * 早晚报pageInfo请求 | ||
| 81 | + * */ | ||
| 82 | + static getMorningEveningPageInfoUrl(pageId: string) { | ||
| 83 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.MORNING_EVENING_PAGE_INFO_PATH; | ||
| 84 | + url = url + "?pageId=" + pageId; | ||
| 85 | + Logger.info(TAG,"getMorningEveningPageInfoUrl url = "+url) | ||
| 86 | + return url; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + /** | ||
| 90 | + * 早晚报compInfo请求 | ||
| 91 | + * */ | ||
| 92 | + static getMorningEveningCompInfoUrl(pageId: string) { | ||
| 93 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.MORNING_EVENING_COMP_INFO_PATH; | ||
| 94 | + url = url + "?loadStrategy=first_load&pageNum=1&refreshTime=1710853254592&pageId=" | ||
| 95 | + +pageId+"&channelStrategy=2&groupId=40621&topicId=10000009445&pageSize=20"; | ||
| 96 | + Logger.info(TAG,"getMorningEveningCompInfoUrl url = "+url) | ||
| 68 | return url; | 97 | return url; |
| 69 | } | 98 | } |
| 70 | 99 | ||
| @@ -118,4 +147,22 @@ export class PageRepository { | @@ -118,4 +147,22 @@ export class PageRepository { | ||
| 118 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 147 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 119 | return WDHttp.get<ResponseDTO<NewspaperListBean>>(url, headers) | 148 | return WDHttp.get<ResponseDTO<NewspaperListBean>>(url, headers) |
| 120 | }; | 149 | }; |
| 150 | + | ||
| 151 | + /** | ||
| 152 | + * 获取早晚报pageInfo | ||
| 153 | + * */ | ||
| 154 | + static fetchMorningEveningPageInfo(pageId: string) { | ||
| 155 | + let url = PageRepository.getMorningEveningPageInfoUrl(pageId) | ||
| 156 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 157 | + return WDHttp.get<ResponseDTO<PageInfoBean>>(url, headers) | ||
| 158 | + }; | ||
| 159 | + | ||
| 160 | + /** | ||
| 161 | + * 获取早晚报compInfo | ||
| 162 | + * */ | ||
| 163 | + static fetchMorningEveningCompInfo(pageId: string) { | ||
| 164 | + let url = PageRepository.getMorningEveningCompInfoUrl(pageId) | ||
| 165 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 166 | + return WDHttp.get<ResponseDTO<CompInfoBean>>(url, headers) | ||
| 167 | + }; | ||
| 121 | } | 168 | } |
| 1 | - | 1 | +import { CompInfoBean, PageInfoBean } from 'wdBean/Index'; |
| 2 | +import { Logger } from 'wdKit/Index'; | ||
| 3 | +import { ResponseDTO } from 'wdNetwork/Index'; | ||
| 4 | +import { PageRepository } from '../repository/PageRepository'; | ||
| 2 | 5 | ||
| 3 | const TAG = 'MorningEveningViewModel' | 6 | const TAG = 'MorningEveningViewModel' |
| 4 | 7 | ||
| 5 | export class MorningEveningViewModel { | 8 | export class MorningEveningViewModel { |
| 6 | 9 | ||
| 7 | - static async getNewspaperList(date: string, pageSize: string): Promise<NewspaperListBean> { | ||
| 8 | - return new Promise<NewspaperListBean>((success, error) => { | ||
| 9 | - Logger.info(TAG, `getNavData start`); | ||
| 10 | - PageRepository.fetchNewspaperList(date, pageSize).then((resDTO: ResponseDTO<NewspaperListBean>) => { | 10 | + static async getMorningEveningPageInfo(pageId: string): Promise<PageInfoBean> { |
| 11 | + return new Promise<PageInfoBean>((success, error) => { | ||
| 12 | + Logger.info(TAG, `getMorningEveningPageInfo pageInfo start`); | ||
| 13 | + PageRepository.fetchMorningEveningPageInfo(pageId).then((resDTO: ResponseDTO<PageInfoBean>) => { | ||
| 14 | + if (!resDTO || !resDTO.data) { | ||
| 15 | + Logger.error(TAG, 'getMorningEveningPageInfo then navResDTO is empty'); | ||
| 16 | + error('resDTO is empty'); | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + if (resDTO.code != 0) { | ||
| 20 | + Logger.error(TAG, `getMorningEveningPageInfo then code:${resDTO.code}, message:${resDTO.message}`); | ||
| 21 | + error('resDTO Response Code is failure'); | ||
| 22 | + return | ||
| 23 | + } | ||
| 24 | + // let navResStr = JSON.stringify(navResDTO); | ||
| 25 | + Logger.info(TAG, "getMorningEveningPageInfo then,navResDTO.timestamp:" + resDTO.timestamp); | ||
| 26 | + success(resDTO.data); | ||
| 27 | + }).catch((err: Error) => { | ||
| 28 | + Logger.error(TAG, `getMorningEveningPageInfo catch, error.name : ${err.name}, error.message:${err.message}`); | ||
| 29 | + error(err); | ||
| 30 | + }) | ||
| 31 | + }) | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + static async getMorningEveningCompInfo(pageId: string): Promise<CompInfoBean> { | ||
| 35 | + return new Promise<CompInfoBean>((success, error) => { | ||
| 36 | + Logger.info(TAG, `getMorningEveningCompInfo pageInfo start`); | ||
| 37 | + PageRepository.fetchMorningEveningCompInfo(pageId).then((resDTO: ResponseDTO<CompInfoBean>) => { | ||
| 11 | if (!resDTO || !resDTO.data) { | 38 | if (!resDTO || !resDTO.data) { |
| 12 | - Logger.error(TAG, 'getNewspaperList then navResDTO is empty'); | 39 | + Logger.error(TAG, 'getMorningEveningCompInfo then navResDTO is empty'); |
| 13 | error('resDTO is empty'); | 40 | error('resDTO is empty'); |
| 14 | return | 41 | return |
| 15 | } | 42 | } |
| 16 | if (resDTO.code != 0) { | 43 | if (resDTO.code != 0) { |
| 17 | - Logger.error(TAG, `getNewspaperList then code:${resDTO.code}, message:${resDTO.message}`); | 44 | + Logger.error(TAG, `getMorningEveningCompInfo then code:${resDTO.code}, message:${resDTO.message}`); |
| 18 | error('resDTO Response Code is failure'); | 45 | error('resDTO Response Code is failure'); |
| 19 | return | 46 | return |
| 20 | } | 47 | } |
| 21 | // let navResStr = JSON.stringify(navResDTO); | 48 | // let navResStr = JSON.stringify(navResDTO); |
| 22 | - Logger.info(TAG, "getNewspaperList then,navResDTO.timestamp:" + resDTO.timestamp); | 49 | + Logger.info(TAG, "getMorningEveningCompInfo then,navResDTO.timestamp:" + resDTO.timestamp); |
| 23 | success(resDTO.data); | 50 | success(resDTO.data); |
| 24 | }).catch((err: Error) => { | 51 | }).catch((err: Error) => { |
| 25 | - Logger.error(TAG, `getNewspaperList catch, error.name : ${err.name}, error.message:${err.message}`); | 52 | + Logger.error(TAG, `getMorningEveningCompInfo catch, error.name : ${err.name}, error.message:${err.message}`); |
| 26 | error(err); | 53 | error(err); |
| 27 | }) | 54 | }) |
| 28 | }) | 55 | }) |
434 Bytes
441 Bytes
462 Bytes
486 Bytes
532 Bytes
| @@ -26,11 +26,13 @@ export struct CustomProtocolDialog { | @@ -26,11 +26,13 @@ export struct CustomProtocolDialog { | ||
| 26 | Span("《用户协议》").fontSize(14).fontColor("#ED2800").onClick(()=>{ | 26 | Span("《用户协议》").fontSize(14).fontColor("#ED2800").onClick(()=>{ |
| 27 | let bean={contentId:"1",pageID:""} as Params | 27 | let bean={contentId:"1",pageID:""} as Params |
| 28 | WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean) | 28 | WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean) |
| 29 | + this.controller.close() | ||
| 29 | }) | 30 | }) |
| 30 | Span("及").fontSize(14).fontColor("#666666") | 31 | Span("及").fontSize(14).fontColor("#666666") |
| 31 | Span("《隐私政策》").fontSize(14).fontColor("#ED2800").onClick(()=>{ | 32 | Span("《隐私政策》").fontSize(14).fontColor("#ED2800").onClick(()=>{ |
| 32 | let bean={contentId:"2",pageID:""} as Params | 33 | let bean={contentId:"2",pageID:""} as Params |
| 33 | WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean) | 34 | WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean) |
| 35 | + this.controller.close() | ||
| 34 | }) | 36 | }) |
| 35 | Span("后进行登录").fontSize(14).fontColor("#666666") | 37 | Span("后进行登录").fontSize(14).fontColor("#666666") |
| 36 | }.margin({ top: 12, left: 16, right: 16 }) | 38 | }.margin({ top: 12, left: 16, right: 16 }) |
| @@ -8,6 +8,7 @@ export struct LoginInputComponent { | @@ -8,6 +8,7 @@ export struct LoginInputComponent { | ||
| 8 | @State codeBtnState: boolean = false //发送验证码控件是否可以 默认不可用 | 8 | @State codeBtnState: boolean = false //发送验证码控件是否可以 默认不可用 |
| 9 | @Link isCodeSend: boolean //验证码控件是否点击 默认没有 发送接口 | 9 | @Link isCodeSend: boolean //验证码控件是否点击 默认没有 发送接口 |
| 10 | @Link isSubmit: boolean //是否可以提交 | 10 | @Link isSubmit: boolean //是否可以提交 |
| 11 | + isFirst:boolean=true//是否第一次获取验证码 | ||
| 11 | 12 | ||
| 12 | build() { | 13 | build() { |
| 13 | Column() { | 14 | Column() { |
| @@ -50,7 +51,7 @@ export struct LoginInputComponent { | @@ -50,7 +51,7 @@ export struct LoginInputComponent { | ||
| 50 | this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 6) | 51 | this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 6) |
| 51 | }) | 52 | }) |
| 52 | 53 | ||
| 53 | - Text(this.isCodeSend ? this.timeCount + "s" : "发送验证码") | 54 | + Text(this.isCodeSend ? this.timeCount + "s" : this.isFirst?"发送验证码":'重新发送') |
| 54 | .backgroundImage($r('app.media.login_code_bg'), ImageRepeat.NoRepeat) | 55 | .backgroundImage($r('app.media.login_code_bg'), ImageRepeat.NoRepeat) |
| 55 | .backgroundImageSize(ImageSize.Cover) | 56 | .backgroundImageSize(ImageSize.Cover) |
| 56 | .fontColor('#ED2800') | 57 | .fontColor('#ED2800') |
| @@ -65,6 +66,7 @@ export struct LoginInputComponent { | @@ -65,6 +66,7 @@ export struct LoginInputComponent { | ||
| 65 | return | 66 | return |
| 66 | } | 67 | } |
| 67 | this.isCodeSend = true | 68 | this.isCodeSend = true |
| 69 | + this.isFirst=false | ||
| 68 | let time = setInterval(() => { | 70 | let time = setInterval(() => { |
| 69 | Logger.debug("倒计时:" + this.timeCount) | 71 | Logger.debug("倒计时:" + this.timeCount) |
| 70 | this.timeCount-- | 72 | this.timeCount-- |
No preview for this file type
-
Please register or login to post a comment