yangchenggong1_wd
Showing 37 changed files with 1296 additions and 130 deletions
import { AboutPageUI} from 'wdComponent';
import { PrivacySettingComponents} from 'wdComponent';
@Entry
@Component
struct PrivacySettingPage {
build() {
Column(){
AboutPageUI()
PrivacySettingComponents()
}
}
}
\ No newline at end of file
... ...
... ... @@ -32,6 +32,58 @@
}
]
}
],
"requestPermissions": [
{
"name": "ohos.permission.CAMERA",
"reason": "$string:EntryAbility_desc",
"usedScene": {
"abilities": [
"FormAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.READ_MEDIA",
"reason": "$string:EntryAbility_desc",
"usedScene": {
"abilities": [
"FormAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.WRITE_MEDIA",
"reason": "$string:EntryAbility_desc",
"usedScene": {
"abilities": [
"FormAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.LOCATION",
"reason": "$string:EntryAbility_desc",
"usedScene": {
"abilities": [
"FormAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.MICROPHONE",
"reason": "$string:EntryAbility_desc",
"usedScene": {
"abilities": [
"FormAbility"
],
"when": "inuse"
}
}
]
}
}
\ No newline at end of file
... ...
... ... @@ -32,6 +32,8 @@ export { MineSettingComponent } from "./components/page/MineSettingComponent"
export { AboutPageUI } from "./components/page/about/AboutPageUI"
export { PrivacySettingComponents } from "./components/page/PrivacySettingComponents"
export { AppointmentListUI } from "./components/page/mine/AppointmentListUI"
export { AccountAndSecurityLayout } from "./components/page/AccountAndSecurityLayout"
... ...
... ... @@ -6,6 +6,7 @@ import { BottomNavDTO } from '../../repository/bean/BottomNavDTO';
import { UIUtils } from '../../repository/UIUtils';
import { MinePageComponent } from './MinePageComponent';
import PageViewModel from '../../viewmodel/PageViewModel';
import RouteManager from '../../utils/RouteManager'
import storageStatistics from "@ohos.file.storageStatistics";
import { BusinessError } from '@ohos.base';
... ... @@ -74,8 +75,9 @@ export struct MineSettingComponent {
RouteManager.jumpNewPage("pages/SettingPasswordPage") // 调用跳转方法,跳转新页面
console.log(subIndex + "")
if (subIndex == 4) {
if (subIndex == 2) {
// RouteManager.jumpNewPage("pages/SettingPage") // 调用跳转方法,跳转新页面
RouteManager.jumpNewPage("pages/PrivacySettingPage")
}
})
... ...
import dataPreferences from '@ohos.data.preferences';
import { PermissionUtil } from 'wdKit'
import { SPHelper } from 'wdKit'
import hilog from '@ohos.hilog';
import {PrivacySettingModel} from '../../viewmodel/PrivacySettingModel'
const TAG = 'PrivacySettingComponents';
@Component
export struct PrivacySettingComponents {
@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')];
@State tips: string = '设置前可查阅'
@State privacyTips: string = '《隐私政策》'
aboutToAppear() {
// 获取权限=
// SPHelper.default.save('sdf','sdf');
// this.initListData();
this.getPermissionStatus();
RefreshStatus;
}
// initListData(){
// let model1 = new PrivacySettingModel('开启个性推荐', false, null);
// let model2 = new PrivacySettingModel('相册权限', false, 'ohos.permission.READ_MEDIA');
// let model3 = new PrivacySettingModel('相机权限', false, 'ohos.permission.CAMERA');
// let model4 = new PrivacySettingModel('定位权限', false, 'ohos.permission.LOCATION');
// let model5 = new PrivacySettingModel('麦克风权限', false, 'ohos.permission.MICROPHONE');
//
// this.listData.push(model1, model2, model3, model4, model5);
// }
async getPermissionStatus(){
const permissionUtil = new PermissionUtil();
for (const element of this.listData) {
if (!element.permissionKey) {
continue;
}
const result = await permissionUtil.checkPermissions(element.permissionKey);
element.permission = result;
}
}
build() {
Navigation() {
//滑动区域
this.PrivacySettingComponentsUI()
}.titleMode(NavigationTitleMode.Mini)
.title('隐私设置')
.backgroundColor('#F8F8F8')
}
@Builder PrivacySettingComponentsUI() {
Column() {
List({space:'23lpx'}){
ForEach(this.listData, (item:PrivacySettingModel, index) =>{
ListItem() {
if (index == 0) {
getTuiJianCell({item, index});
}else{
getArrowCell({item, index});
}
}.onClick(()=>{
if (index != 0) {
if (!item.permission){
//跳转权限设置
const permissionUtil = new PermissionUtil();
PermissionUtil.reqPermissionsFromUser([item.permissionKey]);
}
}
})
}, item => item)
}
.padding({left:'29lpx', right:'29lpx'})
.margin({top:'38lpx'})
Row(){
Text(this.tips)
.fontSize('25lpx')
.textAlign(TextAlign.Start)
.fontColor($r("app.color.color_666666"))
.margin({left:'29lpx', top:'46lpx'})
// .backgroundColor(Color.Orange)
Text(this.privacyTips)
.fontSize('25lpx')
.textAlign(TextAlign.Start)
.fontColor('#ED2800')
.margin({top:'46lpx'})
.onClick(()=>{
//跳转隐私政策
})
}
}
.width('100%')
.height('100%')
.backgroundColor('#F8F8F8')
.alignItems(HorizontalAlign.Start)
}
}
@Component
struct getArrowCell {
@ObjectLink item: PrivacySettingModel;
index;
// 右文字+箭头cell
// @Builder getArrowCell(item:PrivacySettingModel, index) {
build() {
Row() {
// 左侧标题
Text(this.item.privacyName)
.fontColor('#666666')
.fontSize('31lpx')
Row() {
Text(this.item.permission ? '已开启' : '去设置')
.fontColor(this.item.permission ? '#666666' : '#CCCCCC')
.fontSize('31lpx')
.margin({ right: '8lpx' })
Image($r('app.media.mine_user_arrow'))
.width('27lpx')
.height('27lpx')
.objectFit(ImageFit.Auto)
}
}
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.SpaceBetween)
.height('97lpx')
.width('100%')
.padding({ left: '29lpx', right: '29lpx' })
.backgroundColor('#FFFFFF')
.borderRadius('8lpx')
}
}
@Component
struct getTuiJianCell{
@ObjectLink item :PrivacySettingModel;
index;
build() {
//@Builder getTuiJianCell(item:PrivacySettingModel, index)
Column() {
Row() {
// 左侧标题
Text(this.item.privacyName)
.fontColor('#666666')
.fontSize('31lpx')
Row() {
Toggle({ type: ToggleType.Switch, isOn: this.item.permission })
.height('58lpx')
.width('96lpx')
// .selectedColor(Color.Pink)
.onChange((isOn: boolean) => {
// this.privacySwitch = isOn;
})
}
}
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.SpaceBetween)
.height('97lpx')
.width('100%')
Blank()
.backgroundColor('#EDEDED')
.height('1lpx')
Text('关闭后,将无法看到个性化推荐的服务')
.fontColor('#999999')
.fontSize('23lpx')
.margin({ right: '8lpx' })
.height('69lpx')
}
.alignItems(HorizontalAlign.Start)
.backgroundColor('#FFFFFF')
.borderRadius('8lpx')
.padding({ left: '29lpx', right: '29lpx' })
}
}
... ...
... ... @@ -2,28 +2,53 @@ const TAG = 'AboutPageUI';
@Component
export struct AboutPageUI {
@State listData: Array<string | Array<string>> = ['隐私授权协议', '软件许可及用户协议'];
@State message: string = '京ICP备16066560号-6A Copyright © 人民日报客户端\nall rights reserved.'
@State version: string = '版本号:v8.0.1.1'
build() {
Navigation() {
//滑动区域
this.aboutUi()
}.titleMode(NavigationTitleMode.Mini)
.title('关于')
}
@Builder aboutUi() {
Column() {
Image($r('app.media.setting_about_logo'))
.width('278lpx')
.height('154lpx')
.margin({top:'173lpx',bottom:'154lpx'})
Row(){
// Row(){
//
// }.backgroundColor(Color.Yellow)
// .width('100%')
// .height('97lpx')
}.backgroundColor(Color.Yellow)
.width('100%')
.height('97lpx')
// Row(){
//
// }.backgroundColor(Color.Yellow)
// .width('100%')
// .height('97lpx')
Row(){
}.backgroundColor(Color.Yellow)
.width('100%')
.height('97lpx')
List(){
ForEach(this.listData, (item, index) =>{
ListItem() {
this.getArrowCell(item, index)
}
}, item => item)
}.divider({
strokeWidth: 1,
startMargin: '29lpx',
endMargin: '29lpx',
color: '#EDEDED'
})
Blank()
... ... @@ -46,4 +71,31 @@ export struct AboutPageUI {
.width('100%')
.height('100%')
}
}
\ No newline at end of file
// 右文字+箭头cell
@Builder getArrowCell(item, index) {
Row() {
// 左侧标题
Text(`${item}`)
.fontColor('#666666')
.fontSize('31lpx')
Image($r('app.media.mine_user_arrow'))
.width('27lpx')
.height('27lpx')
.objectFit(ImageFit.Auto)
}
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.SpaceBetween)
.height('97lpx')
.width('100%')
.padding({left:'29lpx',right:'29lpx'})
}
}
... ...
... ... @@ -67,18 +67,19 @@ export default struct MinePageMoreFunctionUI{
console.log(index+"")
if (index == 3) {
RouteManager.jumpNewPage("pages/SettingPage")
} else {
} else if (index == 2) {
RouteManager.jumpNewPage("pages/PrivacySettingPage")
} else if (index == 4) {
RouteManager.jumpNewPage("pages/SettingAboutPage")
}else {
// 在Home页面中
let paramsInfo: object = {
pageId: 123,
pageType:'mainSetting'
};
RouteManager.jumpNewPage("pages/PrivacySettingPage",paramsInfo)
// RouteManager.jumpNewPage("pages/PrivacySettingPage")
}
})
.height('117lpx')
}, item => item)
... ...
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
@Observed
export class PrivacySettingModel{
privacyName: string
permission: boolean
permissionKey: Permissions
constructor(privacyName: string, permission: boolean, permissionKey: Permissions) {
this.privacyName = privacyName;
this.permission = permission;
this.permissionKey = permissionKey;
}
}
\ No newline at end of file
... ...
... ... @@ -14,3 +14,6 @@ export { DateTimeUtils } from './utils/DateTimeUtils'
export { AppContext } from './utils/AppContext'
export { PermissionUtil } from './utils/PermissionUtil'
export { SPHelper } from './utils/SPHelper'
\ No newline at end of file
... ...
import bundleManager from '@ohos.bundle.bundleManager';
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
import common from '@ohos.app.ability.common';
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
export class PermissionUtil {
async checkAccessToken(permission: Permissions): Promise<abilityAccessCtrl.GrantStatus> {
let atManager = abilityAccessCtrl.createAtManager();
let grantStatus: abilityAccessCtrl.GrantStatus;
// 获取应用程序的accessTokenID
let tokenId: number;
try {
let bundleInfo: bundleManager.BundleInfo = await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
let appInfo: bundleManager.ApplicationInfo = bundleInfo.appInfo;
tokenId = appInfo.accessTokenId;
} catch (err) {
console.error(`getBundleInfoForSelf failed, code is ${err.code}, message is ${err.message}`);
}
// 校验应用是否被授予权限
try {
grantStatus = await atManager.checkAccessToken(tokenId, permission);
} catch (err) {
console.error(`checkAccessToken failed, code is ${err.code}, message is ${err.message}`);
}
return grantStatus;
}
async checkPermissions(permission: Permissions): Promise<boolean> {
let hasPermissions = false;
let grantStatus: abilityAccessCtrl.GrantStatus = await this.checkAccessToken(permission);
if (grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
// 已经授权,可以继续访问目标操作
hasPermissions = true;
} else {
hasPermissions = false;
// 申请日历权限
}
return hasPermissions;
}
static reqPermissionsFromUser(permissions: Array<Permissions>): void {
let context = getContext(this) as common.UIAbilityContext;
let atManager = abilityAccessCtrl.createAtManager();
// requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗
atManager.requestPermissionsFromUser(context, permissions).then((data) => {
let grantStatus: Array<number> = data.authResults;
let length: number = grantStatus.length;
for (let i = 0; i < length; i++) {
if (grantStatus[i] === 0) {
// 用户授权,可以继续访问目标操作
} else {
this.jumpSetting();
// 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限
AlertDialog.show({
title: '权限设置',
message: '到系统设置中打开相应的权限',
confirm: {
value: "OK",
action: () => {
},
}
})
return;
}
}
// 授权成功
}).catch((err) => {
console.error(`requestPermissionsFromUser failed, code is ${err.code}, message is ${err.message}`);
})
}
static jumpSetting() {
}
}
... ...
... ... @@ -87,7 +87,7 @@ export class HttpUrlUtils {
static readonly MORNING_EVENING_COMP_INFO_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/compInfo";
private static hostUrl: string = HttpUrlUtils.HOST_UAT;
private static hostUrl: string = HttpUrlUtils.HOST_PRODUCT;
private static userId=''
private static userType=''
private static token=''
... ...
... ... @@ -70,3 +70,19 @@ export { ResponseBean } from './src/main/ets/bean/h5/ResponseBean';
export { MorningEveningPaperDTO } from './src/main/ets/bean/component/MorningEveningPaperDTO';
export { FrontLinkObject } from './src/main/ets/bean/component/FrontLinkObject';
export { PageInfoBean } from './src/main/ets/bean/morningevening/PageInfoBean';
export { Group } from './src/main/ets/bean/morningevening/Group';
export { TopicInfo } from './src/main/ets/bean/morningevening/TopicInfo';
export { CompInfoBean } from './src/main/ets/bean/morningevening/CompInfoBean';
export { CompList } from './src/main/ets/bean/morningevening/CompList';
export { OperDataList } from './src/main/ets/bean/morningevening/OperDataList';
export { ShareInfo } from './src/main/ets/bean/morningevening/ShareInfo';
... ...
import { CompList } from './CompList';
export interface CompInfoBean {
blockDesc: string;
// compAdList: any[];
compList: CompList[];
id: number;
name: string;
pageId: string;
pageNum: number;
pageSize: number;
recommend: number;
totalCount: number;
}
\ No newline at end of file
... ...
import { OperDataList } from './OperDataList';
export interface CompList {
// audioDataList: any[];
backgroundImgUrl: string;
// bottomNavId?: any;
cardItemId: string;
// cardUpdateStrategy?: any;
compStyle: string;
compType: string;
dataSourceType: string;
expIds: string;
extraData: string;
// fullColumnImgUrls: any[];
hasMore: number;
id: number;
// imageScale?: any;
imgSize: string;
itemId: string;
itemType: string;
itemTypeCode: string;
linkUrl: string;
// localGovernance?: any;
name: string;
objectId: string;
objectLevel: string;
objectSummary: string;
objectTitle: string;
objectType: string;
// openComment?: any;
// openLikes?: any;
operDataList: OperDataList[];
pageId: string;
// position?: any;
posterSize: string;
posterUrl: string;
// questionSection?: any;
recommend: number;
relId: number;
sceneId: string;
sortValue: number;
subSceneId: string;
summaryName: string;
// tabOperDataList: any[];
titleShowPolicy: number;
// topicTemplate?: any;
traceId: string;
traceInfo: string;
viewTime: string;
// viewTimeBlurred?: any;
}
\ No newline at end of file
... ...
export interface Group {
blockDesc: string;
groupStrategy: number;
id: number;
showType: number;
sortValue: number;
}
\ No newline at end of file
... ...
import { ShareInfo } from './ShareInfo';
export interface OperDataList {
// activityExt?: any;
appStyle: string;
// askInfo?: any;
axisColor: string;
// bestNoticer?: any;
// bottomNavId?: any;
cardItemId: string;
channelId: number;
// commentInfo?: any;
corner: string;
coverSize: string;
coverType: number;
coverUrl: string;
expIds: string;
extra: string;
// fullColumnImgUrls: any[];
// hasMore?: any;
itemId: string;
itemType: string;
itemTypeCode: string;
keyArticle: number;
// landscape?: any;
// likeStyle?: any;
linkUrl: string;
// liveInfo?: any;
menuShow: number;
newTags: string;
newsAuthor: string;
newsSubTitle: string;
newsSummary: string;
newsTitle: string;
newsTitleColor: string;
objectId: string;
objectLevel: string;
objectType: string;
// openComment?: any;
// openLikes?: any;
pageId: string;
// photoNum?: any;
// position?: any;
publishTime: string;
// pushTime?: any;
// pushUnqueId?: any;
readFlag: number;
// recommend?: any;
relId: number;
relObjectId: string;
relType: number;
// rmhInfo?: any;
rmhPlatform: number;
sceneId: string;
shareInfo: ShareInfo;
// slideShows: any[];
sortValue: number;
source: string;
subSceneId: string;
// tagIds: any[];
// tagWord?: any;
// titleShow?: any;
// titleShowPolicy?: any;
// topicTemplate?: any;
traceId: string;
traceInfo: string;
// userInfo?: any;
// videoInfo?: any;
visitorComment: number;
// voiceInfo?: any;
}
\ No newline at end of file
... ...
// export interface Group {
// blockDesc: string;
// groupStrategy: number;
// id: number;
// itemNum?: any;
// showType: number;
// sortValue: number;
// }
//
// export interface TopicInfo {
// axisColor: string;
// channelId?: any;
// commentFlag: number;
// commentPreviewFlag: number;
// commentShowFlag: number;
// frontFlag?: any;
// frontLinkObject?: any;
// posterFlag: number;
// posterUrl: string;
// relId?: any;
// relObjectId?: any;
// relType?: any;
// shareCoverUrl: string;
// shareOpen: number;
// sharePosterCoverUrl: string;
// sharePosterOpen?: any;
// shareSummary: string;
// shareTitle: string;
// shareUrl: string;
// slideColor: string;
// summary: string;
// title: string;
// titleShow: number;
// topicDate: string;
// topicId: string;
// topicPattern: number;
// topicTemplate?: any;
// topicType: number;
// transluceImgUrl: string;
// visitorComment: number;
// voteInfo?: any;
// }
//
// export interface PageInfoBean {
// backIconUrl: string;
// backgroundColor: string;
// backgroundImgUrl: string;
// baselineColor: string;
// baselineCopywriting: string;
// baselineShow: number;
// description: string;
// groups: Group[];
// hasAdInfo: number;
// hasPopUp: number;
// id: number;
// mainLogoImgUrl: string;
// name: string;
// pageTopParams?: any;
// pageTopType: number;
// pageType: number;
// popUps: any[];
// pushupLogoImgUrl: string;
// shareCoverUrl: string;
// shareIconUrl: string;
// shareName: string;
// shareSummary: string;
// shareUrl: string;
// statusBarColor: string;
// templateType: number;
// titleColor: string;
// topicInfo: TopicInfo;
// }
//
// export interface Meta {
// md5: string;
// }
//
// export interface RootObject {
// code: string;
// data: Data;
// message: string;
// meta: Meta;
// requestId: string;
// success: boolean;
// timestamp: number;
// }
\ No newline at end of file
import { Group } from './Group';
import { TopicInfo } from './TopicInfo';
export interface PageInfoBean {
backIconUrl: string;
backgroundColor: string;
backgroundImgUrl: string;
baselineColor: string;
baselineCopywriting: string;
baselineShow: number;
description: string;
groups: Group[];
hasAdInfo: number;
hasPopUp: number;
id: number;
mainLogoImgUrl: string;
name: string;
pageTopType: number;
pageType: number;
pushupLogoImgUrl: string;
shareCoverUrl: string;
shareIconUrl: string;
shareName: string;
shareSummary: string;
shareUrl: string;
statusBarColor: string;
templateType: number;
titleColor: string;
topicInfo: TopicInfo;
}
... ...
export interface ShareInfo {
shareCoverUrl: string;
shareOpen: number;
sharePosterCoverUrl: string;
sharePosterOpen: number;
shareSummary: string;
shareTitle: string;
shareUrl: string;
}
\ No newline at end of file
... ...
export interface TopicInfo {
axisColor: string;
commentFlag: number;
commentPreviewFlag: number;
commentShowFlag: number;
posterFlag: number;
posterUrl: string;
shareCoverUrl: string;
shareOpen: number;
sharePosterCoverUrl: string;
shareSummary: string;
shareTitle: string;
shareUrl: string;
slideColor: string;
summary: string;
title: string;
titleShow: number;
topicDate: string;
topicId: string;
topicPattern: number;
topicType: number;
transluceImgUrl: string;
visitorComment: number;
}
\ No newline at end of file
... ...
... ... @@ -5,15 +5,25 @@ import { Logger } from 'wdKit';
import { ENewspaperItemComponent } from './ENewspaperItemComponent';
import { ENewspaperListDialog } from '../dialog/ENewspaperListDialog';
import display from '@ohos.display';
import { ENewspaperCalendarDialog } from '../dialog/ENewspaperCalendarDialog';
import font from '@ohos.font';
@Component
export struct ENewspaperPageComponent {
@State newspaperListBean: NewspaperListBean = {} as NewspaperListBean
@State currentPageNum: string = '01'
@State pageNumPopup: boolean = false
@State date: string = '2024-01-26'
@State calendarPopup: boolean = false
@State calendarDateTitle: string = ''
@State picHeight: number = 0
private swiperController: SwiperController = new SwiperController()
calendarDialogController: CustomDialogController = new CustomDialogController({
builder: ENewspaperCalendarDialog(),
alignment: DialogAlignment.Top,
offset: { dx: 0, dy: 80 },
customStyle: true,
// cornerRadius: 4
})
listDialogController: CustomDialogController = new CustomDialogController({
builder: ENewspaperListDialog({ newspaperListBean: this.newspaperListBean,
currentPageNum: this.currentPageNum,
... ... @@ -64,9 +74,10 @@ export struct ENewspaperPageComponent {
})
Row() {
Text(this.date)
Text(this.calendarDateTitle)
.fontSize($r('app.float.font_size_20'))
.fontColor($r('app.color.white'))
.fontFamily('BebasNeue_Regular')
Image($r('app.media.icon_triangle'))
.width($r('app.float.border_radius_6'))
... ... @@ -77,6 +88,14 @@ export struct ENewspaperPageComponent {
.alignRules({ middle: { anchor: "__container__", align: HorizontalAlign.Center },
center: { anchor: "__container__", align: VerticalAlign.Center } })
.id('e_newspaper_date')
.onClick(() => {
this.calendarPopup = !this.calendarPopup
if (this.calendarPopup) {
this.calendarDialogController.open()
} else {
this.calendarDialogController.close()
}
})
Image($r('app.media.icon_share'))
.height($r('app.float.top_arrow_size'))
... ... @@ -193,25 +212,25 @@ export struct ENewspaperPageComponent {
}
async aboutToAppear() {
//注册字体
font.registerFont({
familyName: 'BebasNeue_Regular',
// familySrc: '/font/roboto_medium_numbers.ttf' // font文件夹与pages目录同级
familySrc: $rawfile('font/BebasNeue_Regular.otf')
})
let newspaperTimes = await NewspaperViewModel.getNewspaperTime()
if (newspaperTimes && newspaperTimes.length > 0) {
this.date = newspaperTimes[0].date
this.calendarDateTitle = newspaperTimes[0].date
}
try {
let displayTool = display.getDefaultDisplaySync()
let screenWidth = displayTool.width
let picWidth = screenWidth - vp2px(52)
this.picHeight = picWidth * 566 / 378
let listBean = await NewspaperViewModel.getNewspaperList(this.date, picWidth + 'x' + this.picHeight)
let listBean = await NewspaperViewModel.getNewspaperList(this.calendarDateTitle, picWidth + 'x' + this.picHeight)
this.newspaperListBean = listBean;
} catch (exception) {
}
}
aboutToDisappear() {
}
}
\ No newline at end of file
... ...
import { MorningEveningPaperDTO } from 'wdBean'
import { MorningEveningPaperDTO, PageInfoBean } from 'wdBean'
import { Logger } from 'wdKit/Index';
import { DateTimeUtils } from 'wdKit/src/main/ets/utils/DateTimeUtils';
import { MorningEveningViewModel } from '../../viewmodel/MorningEveningViewModel';
import { AudioBarView } from './AudioBarView';
import { PaperTitleComponent } from './PaperTitleComponent';
import { SingleColumn999Component } from './SingleColumn999Component';
... ... @@ -12,6 +14,8 @@ const PATTERN_DATE_CN_RN: string = 'yyyy年\nMM月dd日'; // 日期中包含包
@Entry
@Component
export struct MorningEveningPaperComponent {
@State pageInfoBean: PageInfoBean = {} as PageInfoBean
@State morningEveningPaperDTO: MorningEveningPaperDTO = {
name: "新闻夜读",
topicInfo: {
... ... @@ -30,10 +34,21 @@ export struct MorningEveningPaperComponent {
} as MorningEveningPaperDTO
@State subTitle: string = ''
aboutToAppear() {
async aboutToAppear() {
console.info(TAG, `aboutToAppear`);
let dateTime = DateTimeUtils.parseDate(this.morningEveningPaperDTO?.topicInfo?.topicDate ?? '', DateTimeUtils.PATTERN_DATE_HYPHEN);
this.subTitle = DateTimeUtils.formatDate(dateTime, PATTERN_DATE_CN_RN)
try {
let listBean = await MorningEveningViewModel.getMorningEveningPageInfo("28927")
Logger.info(TAG,"listBean title = "+listBean.topicInfo.title)
Logger.info(TAG,"listBean topicDate = "+listBean.topicInfo.topicDate)
this.pageInfoBean = listBean;
let compInfoBean = await MorningEveningViewModel.getMorningEveningCompInfo("28927")
Logger.info(TAG,"compInfoBean compStyle = "+compInfoBean.compList[0].compStyle)
} catch (exception) {
}
}
build() {
... ...
import { RMCalendarBean } from './RMCalendarBean'
import { RMCalenderCell } from './RMCalendarCell'
const TAG = "RMCalendar"
@Component
export struct RMCalendar {
@State selectItem: RMCalendarBean = new RMCalendarBean()
private today: Date = new Date() // 当天
// 开始日期
startDate: Date = new Date()
// 截止日期
endDate: Date = new Date()
//当前日期-当前显示的月份的第一天
private startDay: Date = new Date(
this.today.getFullYear(),
this.today.getMonth(),
1
)
// 是否有上一个月
@State private hasPre: boolean = true
// 是否有下一个月
@State private hasNext: boolean = true
// 标题栏高度
titleHeight: Length = '50vp'
// 星期标题
weeks: string[] = ["日", "一", "二", "三", "四", "五", "六",]
// 星期标题字体大小
weekTitleFontSize: number | string | Resource = 12
// 星期标题字体颜色
weekTitleFontColor: ResourceColor = "#999999"
// 星期标栏高度
weekTitleHeight: Length = 30
weekFontWeight: FontWeight = FontWeight.Bold
// 标题字体大小
titleFontSize: number | string | Resource = 16
// 标题字体颜色
titleFontColor: ResourceColor = "#333333"
titleFontWeight: FontWeight = FontWeight.Bold
// 日期每一项字体大小
itemFontSize: number | string | Resource = 14
itemFontColor: ResourceColor = "#333333"
itemFontWeight: FontWeight = FontWeight.Bold
// 今日字体颜色
todayFontColor: ResourceColor = "#ED2800"
// 不能使用的日期字体颜色
disabledFontColor: ResourceColor = "#CCCCCC"
// 选中日期字体颜色
selectFontColor: ResourceColor = "#FFFFFF"
// 选中日期背景颜色, 默认与todayFontColor一致
selectItemBgColor: ResourceColor = "#ED2800"
@State private title: string = ''
// 计算的总加载
@State dates: Array<RMCalendarBean> = new Array()
// 已选日期
@State selectedDates: Array<RMCalendarBean> = new Array()
// 自定义每一项布局
public cellLayout?: (item: RMCalendarBean) => void
// 仅自定义 今日 样式,当使用cellLayout时,tadayLayout无效
todayLayout?: (item: RMCalendarBean) => void
// 计算item时,如需添加更多自定义属性时使用
reBuildDateItem?: (item: RMCalendarBean) => RMCalendarBean
// 选择变化监听,
onDateChange?: (date1: RMCalendarBean) => void
onMonthChange?: (after: Date, befor: Date) => void
// 不可选中项的点击事件
disableCellClick?: (item: RMCalendarBean) => void
@Builder
createWeekTitle(item: string) {
Text(item)
.textAlign(TextAlign.Center)
.fontColor(this.weekTitleFontColor)
.fontSize(this.weekTitleFontSize)
.fontWeight(this.weekFontWeight)
.layoutWeight(1)
}
@Builder
createCell() {
ForEach(this.dates, (item: RMCalendarBean) => {
RMCalenderCell({
item: item,
cellLayout: this.cellLayout,
itemFontSize: this.itemFontSize,
itemFontColor: this.itemFontColor,
today: this.today.getTime(),
itemFontWeight: this.itemFontWeight,
todayFontColor: this.todayFontColor,
todayLayout: this.todayLayout,
selectItem: $selectItem,
selectFontColor: this.selectFontColor,
selectItemBgColor: this.selectItemBgColor,
selectedDates: $selectedDates,
disabledFontColor: this.disabledFontColor,
hasPre: this.hasPre,
hasNext: this.hasNext,
disableClick: (item: RMCalendarBean) => {
if (this.disableCellClick) {
this.disableCellClick(item)
}
},
cellClick: (item: RMCalendarBean) => {
if (item.isPre) {
this.preMonth()
} else if (item.isNext) {
this.nextMonth()
}
if (this.onDateChange) {
this.onDateChange(item)
if (item.fullYear && item.month) {
this.title = `${item.fullYear}年${item.month + 1}月`
}
}
}
})
.width(`14.28%`)
}, (item: RMCalendarBean) => JSON.stringify(item))
}
/**
* 属性初始化
*/
initAttr() {
if (!this.selectItemBgColor) {
this.selectItemBgColor = this.todayFontColor
}
this.today = new Date(
this.today.getFullYear(),
this.today.getMonth(),
this.today.getDate(),
)
// 开始日期
if (!this.startDate) {
this.startDate = new Date(1970, 0, 1)
}
// 截止日期
if (!this.endDate) {
this.endDate = new Date(this.today.getFullYear() + 10, 11, 31)
}
if (this.today.getTime() < this.startDate.getTime()) {
this.startDay.setTime(this.startDate.getTime())
} else if (this.today.getTime() > this.endDate.getTime()) {
this.startDay.setTime(this.endDate.getTime())
} else {
this.startDay.setTime(this.today.getTime())
}
}
aboutToAppear() {
this.initAttr()
let temp = new RMCalendarBean()
temp.time = this.today.getTime()
this.selectItem = temp
this.calcDatas()
}
/**
* 下一个月
*/
private nextMonth() {
// this.dates.slice(0, this.dates.length)
this.dates = []
const beforDate = new Date(this.startDay.getFullYear(), this.startDay.getMonth())
this.startDay.setMonth(this.startDay.getMonth() + 1)
if (this.onMonthChange) {
this.onMonthChange(new Date(this.startDay.getFullYear(), this.startDay.getMonth()), beforDate)
}
this.calcDatas()
}
/**
* 上一个月
*/
private preMonth() {
// this.dates.slice(0, this.dates.length)
this.dates = []
const beforDate = new Date(this.startDay.getFullYear(), this.startDay.getMonth())
this.startDay.setMonth(this.startDay.getMonth() - 1)
if (this.onMonthChange) {
this.onMonthChange(new Date(this.startDay.getFullYear(), this.startDay.getMonth()), beforDate)
}
this.calcDatas()
}
/**
* 具体计算
*/
private calcDatas() {
const startDay = this.startDay
this.title = `${startDay.getFullYear()}年${startDay.getMonth() + 1}月`
startDay.setDate(1)
if (startDay.getFullYear() < this.startDate.getFullYear()
|| (startDay.getFullYear() == this.startDate.getFullYear() && startDay.getMonth() <= this.startDate.getMonth())) {
this.hasPre = false
} else {
this.hasPre = true
}
if (startDay.getFullYear() > this.endDate.getFullYear()
|| (startDay.getFullYear() == this.endDate.getFullYear() && startDay.getMonth() >= this.endDate.getMonth())) {
this.hasNext = false
} else {
this.hasNext = true
}
// 计算第一个月
// 获取第一个月总天数
let endDay: Date = new Date(
startDay.getFullYear(),
startDay.getMonth() + 1,
0, 23, 59, 59)
let tempDate: Date = new Date(
startDay.getFullYear(),
startDay.getMonth(),
startDay.getDate()
)
const count = endDay.getDate()
const preCount = startDay.getDay()
// const nextCount = 6 - endDay.getDay()
const nextCount = 0
const finilCount = count + preCount + nextCount
// 补齐上一个月
tempDate.setDate(tempDate.getDate() - preCount)
// 添加日期
for (let index = 0; index < finilCount; index++) {
let item = new RMCalendarBean(
tempDate.getFullYear(),
tempDate.getMonth(),
tempDate.getDate(),
tempDate.getDay(),
tempDate.getTime(),
// @ ts-ignore
// LunarCalendar.convertSolarToLunar(tempDate),
(index < preCount ? true : false) || this.startDate.getTime() > tempDate.getTime(),
(index >= preCount + count ? true : false) || this.endDate.getTime() < tempDate.getTime(),
)
if (this.reBuildDateItem) {
this.reBuildDateItem(item)
}
this.dates.push(item)
tempDate.setDate(tempDate.getDate() + 1)
}
}
build() {
Column() {
Image($r("app.media.iv_e_news_pager_calendar_arrow_up"))
.width(18).height(8.5)
Column() {
Row() {
Column() {
Image(this.hasPre ? $r("app.media.iv_e_news_pager_calendar_arrow_pre")
: $r("app.media.iv_e_news_pager_calendar_arrow_pre_gray"))
.width(22)
.aspectRatio(1)
}
.justifyContent(FlexAlign.Center)
.height("100%")
.aspectRatio(1)
.onClick(() => {
if (this.hasPre) {
this.preMonth()
}
})
Blank()
Row() {
Text(this.title)
.fontSize(this.titleFontSize)
.fontColor(this.titleFontColor)
.fontWeight(this.titleFontWeight)
}
Blank()
Column() {
Image(this.hasNext ? $r("app.media.iv_e_news_pager_calendar_arrow_next")
: $r("app.media.iv_e_news_pager_calendar_arrow_next_gray"))
.width(22)
.aspectRatio(1)
}
.justifyContent(FlexAlign.Center)
.height("100%")
.aspectRatio(1)
.onClick(() => {
if (this.hasNext) {
this.nextMonth()
}
})
}
.alignItems(VerticalAlign.Center)
.width("100%")
.height(this.titleHeight)
// 星期title
Row() {
ForEach(this.weeks, (item: string) => {
this.createWeekTitle(item)
}, (item: string) => {
return item
})
}
.alignItems(VerticalAlign.Center)
.height(this.weekTitleHeight)
Flex({ wrap: FlexWrap.Wrap }) {
this.createCell()
}
.width("100%")
}
.backgroundColor(Color.White)
.margin({
left: 35,
right: 35
})
.border({ radius: 4 })
}
}
}
\ No newline at end of file
... ...
@Observed
export class RMCalendarBean {
fullYear?: number
month?: number
date?: number
week?: number
time?: number
isPre?: boolean // 是否是上一个月的 / 在startDate 之前
isNext?: boolean // 是否是下一个月的 / 在endDate 之后
constructor(fullYear?: number, month?: number,
date?: number, day?: number,
time?: number,
isPre?: boolean,
isNext?: boolean) {
this.fullYear = fullYear
this.month = month
this.date = date
this.week = day
this.time = time
this.isPre = isPre
this.isNext = isNext
}
}
\ No newline at end of file
... ...
import { RMCalendarBean } from './RMCalendarBean';
import font from '@ohos.font';
@Component
export struct RMCalenderCell {
private selectOpacity: number = 0.15
itemFontSize: Length = 0
itemFontColor: ResourceColor = {} as ResourceColor
itemFontWeight: FontWeight = FontWeight.Normal
todayFontColor: ResourceColor = {} as ResourceColor
selectFontColor: ResourceColor = {} as ResourceColor
selectItemBgColor: ResourceColor = {} as ResourceColor
disabledFontColor: ResourceColor = {} as ResourceColor
// 今日时间戳
today: number = 0
@Link selectItem: RMCalendarBean
@Link selectedDates: Array<RMCalendarBean>
@Prop hasPre: boolean
@Prop hasNext: boolean
@ObjectLink item: RMCalendarBean
// 自定义每一项布局
cellLayout?: (item: RMCalendarBean) => void
todayLayout?: (item: RMCalendarBean) => void
cellClick?: (item: RMCalendarBean) => void
disableClick?: (item: RMCalendarBean) => void
/**
* 检测是否包含在数组中
*/
checkInArrays() {
for (let index = 0; index < this.selectedDates.length; index++) {
if (this.item.time == this.selectedDates[index].time) {
return index
}
}
return -1
}
getItemColor() {
if (this.item.isPre) {
return this.disabledFontColor
} else if (this.item.isNext) {
return this.disabledFontColor
} else if (this.selectItem && this.selectItem.time == this.item.time) {
return this.selectFontColor
} else if (this.item.time == this.today) {
return this.todayFontColor
}
return this.itemFontColor
}
getBorder() {
if (this.selectItem && this.selectItem.time == this.item.time) {
return this.border({
width: 1,
color: this.getItemColor()
})
} else {
return this.border({
width: 0,
}
)
}
}
/**
* 获取选中项背景颜色
*/
getSelectItemBg() {
return this.selectItemBgColor
}
/**
* 获取选中项背景透明度
* @returns
*/
getSelectItemBgOpa() {
return this.item.isPre || this.item.isNext ? this.selectOpacity : 1
}
/**
* 是否需要显示选项背景
*/
isShowSelectBg() {
return this.selectItem && this.selectItem.time == this.item.time
}
build() {
Column() {
Stack() {
if (!this.item.isPre) {
if (this.isShowSelectBg()) {
Column()// .position({ x: "10%", y: "10%" })
.height("80%")
.aspectRatio(1)// .borderRadius(999)
.backgroundColor(this.getSelectItemBg())
.opacity(this.getSelectItemBgOpa())
.transition({ type: TransitionType.Insert, opacity: 1 })
.transition({ type: TransitionType.Delete, opacity: 0 })
}
Text(this.item.date + '')
.fontSize(this.itemFontSize)
.fontColor(this.getItemColor())
.fontWeight(this.itemFontWeight)
.fontFamily('BebasNeue_Regular')
}
}
// .justifyContent(FlexAlign.Center)
.aspectRatio(1)
// .border(this.getBorder())
.width("80%")
}
.justifyContent(FlexAlign.Center)
// .width("100%")
// .aspectRatio(1)
.onClick(() => {
// animateTo({ duration: 200 }, () => {
//
// })
if (this.item.isNext) {
if (!this.hasNext) {
if (this.disableClick) {
this.disableClick(this.item)
}
return
}
}
if (this.item.isPre) {
// if (!this.hasPre) {
if (this.disableClick) {
this.disableClick(this.item)
}
return
// }
}
this.selectItem = this.item
if (this.cellClick) {
this.cellClick(this.item)
}
})
}
}
\ No newline at end of file
... ...
... ... @@ -98,7 +98,7 @@ export struct TopNavigationComponent {
}
.width('100%')
.height(40)
.visibility(this._currentNavIndex != 2 ? Visibility.Visible : Visibility.None)
.visibility(this._currentNavIndex == 0 ? Visibility.Visible : Visibility.None)
Tabs() {
ForEach(this.topNavList, (navItem: TopNavDTO, index: number) => {
... ...
import { RMCalendar } from '../components/calendar/RMCalendar'
import { RMCalendarBean } from '../components/calendar/RMCalendarBean'
@CustomDialog
export struct ENewspaperCalendarDialog {
calendarDialogController?: CustomDialogController
build() {
RMCalendar({
// 开始日期
startDate: new Date(2023, 8, 1),
// 截止日期
endDate: new Date(2024, 2, 20),
// 日期选择变化监听
onDateChange: (date1: RMCalendarBean) => {
console.log("onDateChange", "date1:", JSON.stringify(date1))
if (this.calendarDialogController) {
this.calendarDialogController.close()
}
}
})
}
}
\ No newline at end of file
... ...
import HashMap from '@ohos.util.HashMap';
import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { DateTimeUtils } from 'wdKit';
import { DateTimeUtils, Logger } from 'wdKit';
import { ContentDetailDTO, NavigationBodyDTO, PageDTO,InteractDataDTO, MorningEveningPaperDTO,
NewspaperTimeInfoBean,
NewspaperListBean
NewspaperListBean,
PageInfoBean,
CompInfoBean
} from 'wdBean';
const TAG = 'HttpRequest';
export class PageRepository {
static getBottomNavGroupUrl() {
// https: //pd-apis-uat.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup
... ... @@ -22,6 +24,7 @@ export class PageRepository {
+ "&refreshTime=" + DateTimeUtils.getTimeStamp()
+ "&pageId=" + pageId
// Logger.debug("TAG", 'getCompInfoUrl url: '+url);
Logger.info(TAG,"getPageInfoUrl url = "+url)
return url;
}
... ... @@ -39,6 +42,7 @@ export class PageRepository {
+ "&pageSize=" + pageSize
+ "&pageNum=" + currentPage;
// Logger.debug("TAG", 'getCompInfoUrl url: '+url);
Logger.info(TAG,"getCompInfoUrl url = "+url)
return url;
}
... ... @@ -48,16 +52,19 @@ export class PageRepository {
+ "&contentId=" + contentId
+ "&relType=" + relType;
// Logger.debug("TAG", 'getCompInfoUrl url: '+url);
Logger.info(TAG,"getDetailInfoUrl url = "+url)
return url;
}
static getInteractDataUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH;
Logger.info(TAG,"getInteractDataUrl url = "+url)
return url;
}
static getNewspaperInfoUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.E_NEWSPAPER_INFO_PATH;
Logger.info(TAG,"getNewspaperInfoUrl url = "+url)
return url;
}
... ... @@ -65,6 +72,28 @@ export class PageRepository {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.E_NEWSPAPER_LIST_PATH;
url = url + "?date=" + date
+ "&pagesSize=" + pageSize;
Logger.info(TAG,"getNewspaperListUrl url = "+url)
return url;
}
/**
* 早晚报pageInfo请求
* */
static getMorningEveningPageInfoUrl(pageId: string) {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.MORNING_EVENING_PAGE_INFO_PATH;
url = url + "?pageId=" + pageId;
Logger.info(TAG,"getMorningEveningPageInfoUrl url = "+url)
return url;
}
/**
* 早晚报compInfo请求
* */
static getMorningEveningCompInfoUrl(pageId: string) {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.MORNING_EVENING_COMP_INFO_PATH;
url = url + "?loadStrategy=first_load&pageNum=1&refreshTime=1710853254592&pageId="
+pageId+"&channelStrategy=2&groupId=40621&topicId=10000009445&pageSize=20";
Logger.info(TAG,"getMorningEveningCompInfoUrl url = "+url)
return url;
}
... ... @@ -118,4 +147,22 @@ export class PageRepository {
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.get<ResponseDTO<NewspaperListBean>>(url, headers)
};
/**
* 获取早晚报pageInfo
* */
static fetchMorningEveningPageInfo(pageId: string) {
let url = PageRepository.getMorningEveningPageInfoUrl(pageId)
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.get<ResponseDTO<PageInfoBean>>(url, headers)
};
/**
* 获取早晚报compInfo
* */
static fetchMorningEveningCompInfo(pageId: string) {
let url = PageRepository.getMorningEveningCompInfoUrl(pageId)
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.get<ResponseDTO<CompInfoBean>>(url, headers)
};
}
\ No newline at end of file
... ...
import { CompInfoBean, PageInfoBean } from 'wdBean/Index';
import { Logger } from 'wdKit/Index';
import { ResponseDTO } from 'wdNetwork/Index';
import { PageRepository } from '../repository/PageRepository';
const TAG = 'MorningEveningViewModel'
export class MorningEveningViewModel {
static async getNewspaperList(date: string, pageSize: string): Promise<NewspaperListBean> {
return new Promise<NewspaperListBean>((success, error) => {
Logger.info(TAG, `getNavData start`);
PageRepository.fetchNewspaperList(date, pageSize).then((resDTO: ResponseDTO<NewspaperListBean>) => {
static async getMorningEveningPageInfo(pageId: string): Promise<PageInfoBean> {
return new Promise<PageInfoBean>((success, error) => {
Logger.info(TAG, `getMorningEveningPageInfo pageInfo start`);
PageRepository.fetchMorningEveningPageInfo(pageId).then((resDTO: ResponseDTO<PageInfoBean>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'getMorningEveningPageInfo then navResDTO is empty');
error('resDTO is empty');
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `getMorningEveningPageInfo then code:${resDTO.code}, message:${resDTO.message}`);
error('resDTO Response Code is failure');
return
}
// let navResStr = JSON.stringify(navResDTO);
Logger.info(TAG, "getMorningEveningPageInfo then,navResDTO.timestamp:" + resDTO.timestamp);
success(resDTO.data);
}).catch((err: Error) => {
Logger.error(TAG, `getMorningEveningPageInfo catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
static async getMorningEveningCompInfo(pageId: string): Promise<CompInfoBean> {
return new Promise<CompInfoBean>((success, error) => {
Logger.info(TAG, `getMorningEveningCompInfo pageInfo start`);
PageRepository.fetchMorningEveningCompInfo(pageId).then((resDTO: ResponseDTO<CompInfoBean>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'getNewspaperList then navResDTO is empty');
Logger.error(TAG, 'getMorningEveningCompInfo then navResDTO is empty');
error('resDTO is empty');
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `getNewspaperList then code:${resDTO.code}, message:${resDTO.message}`);
Logger.error(TAG, `getMorningEveningCompInfo then code:${resDTO.code}, message:${resDTO.message}`);
error('resDTO Response Code is failure');
return
}
// let navResStr = JSON.stringify(navResDTO);
Logger.info(TAG, "getNewspaperList then,navResDTO.timestamp:" + resDTO.timestamp);
Logger.info(TAG, "getMorningEveningCompInfo then,navResDTO.timestamp:" + resDTO.timestamp);
success(resDTO.data);
}).catch((err: Error) => {
Logger.error(TAG, `getNewspaperList catch, error.name : ${err.name}, error.message:${err.message}`);
Logger.error(TAG, `getMorningEveningCompInfo catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
... ...
... ... @@ -26,11 +26,13 @@ export struct CustomProtocolDialog {
Span("《用户协议》").fontSize(14).fontColor("#ED2800").onClick(()=>{
let bean={contentId:"1",pageID:""} as Params
WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean)
this.controller.close()
})
Span("及").fontSize(14).fontColor("#666666")
Span("《隐私政策》").fontSize(14).fontColor("#ED2800").onClick(()=>{
let bean={contentId:"2",pageID:""} as Params
WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean)
this.controller.close()
})
Span("后进行登录").fontSize(14).fontColor("#666666")
}.margin({ top: 12, left: 16, right: 16 })
... ...
... ... @@ -8,6 +8,7 @@ export struct LoginInputComponent {
@State codeBtnState: boolean = false //发送验证码控件是否可以 默认不可用
@Link isCodeSend: boolean //验证码控件是否点击 默认没有 发送接口
@Link isSubmit: boolean //是否可以提交
isFirst:boolean=true//是否第一次获取验证码
build() {
Column() {
... ... @@ -50,7 +51,7 @@ export struct LoginInputComponent {
this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 6)
})
Text(this.isCodeSend ? this.timeCount + "s" : "发送验证码")
Text(this.isCodeSend ? this.timeCount + "s" : this.isFirst?"发送验证码":'重新发送')
.backgroundImage($r('app.media.login_code_bg'), ImageRepeat.NoRepeat)
.backgroundImageSize(ImageSize.Cover)
.fontColor('#ED2800')
... ... @@ -65,6 +66,7 @@ export struct LoginInputComponent {
return
}
this.isCodeSend = true
this.isFirst=false
let time = setInterval(() => {
Logger.debug("倒计时:" + this.timeCount)
this.timeCount--
... ...