Merge branch 'main' of http://192.168.1.42/developOne/harmonyPool
Showing
29 changed files
with
484 additions
and
113 deletions
| @@ -67,15 +67,15 @@ export const enum CompStyle { | @@ -67,15 +67,15 @@ export const enum CompStyle { | ||
| 67 | 67 | ||
| 68 | 68 | ||
| 69 | 69 | ||
| 70 | - Card_Adv_4 = 4, //4:轮播图 5:三图广告 6:小图广告 7:长通栏广告 8:大图广告 9:视频广告 10:展会广告 11:冠名广告 12:顶部长通栏广告 | ||
| 71 | - Card_Adv_5 = 5, | ||
| 72 | - Card_Adv_6 = 5, | ||
| 73 | - Card_Adv_7 = 7, | ||
| 74 | - Card_Adv_8 = 8, | ||
| 75 | - Card_Adv_9 = 9, | ||
| 76 | - Card_Adv_10 = 10, | ||
| 77 | - Card_Adv_11 = 11, | ||
| 78 | - Card_Adv_12 = 12, | 70 | + Card_Adv_4 = 4, //4:轮播图 |
| 71 | + Card_Adv_5 = 5, // 5:三图广告 | ||
| 72 | + Card_Adv_6 = 6, // 6:小图广告 | ||
| 73 | + Card_Adv_7 = 7, // 7:长通栏广告 | ||
| 74 | + Card_Adv_8 = 8, // 8:大图广告 | ||
| 75 | + Card_Adv_9 = 9, // 9:视频广告 | ||
| 76 | + Card_Adv_10 = 10, // 10:展会广告 | ||
| 77 | + Card_Adv_11 = 11, // 11:冠名广告 | ||
| 78 | + Card_Adv_12 = 12, // 12:顶部长通栏广告 | ||
| 79 | 79 | ||
| 80 | /** | 80 | /** |
| 81 | * 本地稿件和组件样式 | 81 | * 本地稿件和组件样式 |
| @@ -11,6 +11,13 @@ export enum EmitterEventId { | @@ -11,6 +11,13 @@ export enum EmitterEventId { | ||
| 11 | // 跳转首页指定频道,事件id | 11 | // 跳转首页指定频道,事件id |
| 12 | JUMP_HOME_CHANNEL = 4, | 12 | JUMP_HOME_CHANNEL = 4, |
| 13 | 13 | ||
| 14 | - LOCATION = 5 | 14 | + LOCATION = 5, |
| 15 | + | ||
| 16 | + // App回到前台 | ||
| 17 | + APP_ENTER_FOREGROUD = 100, | ||
| 18 | + // App进入后台 | ||
| 19 | + APP_ENTER_BACKGROUD = 101, | ||
| 20 | + | ||
| 21 | + | ||
| 15 | } | 22 | } |
| 16 | 23 |
| @@ -5,3 +5,5 @@ export { WDRouterPage } from './src/main/ets/router/WDRouterPage' | @@ -5,3 +5,5 @@ export { WDRouterPage } from './src/main/ets/router/WDRouterPage' | ||
| 5 | export { registerRouter } from './src/main/ets/router/Action2Page' | 5 | export { registerRouter } from './src/main/ets/router/Action2Page' |
| 6 | 6 | ||
| 7 | export { ProcessUtils } from './src/main/ets/utils/ProcessUtils' | 7 | export { ProcessUtils } from './src/main/ets/utils/ProcessUtils' |
| 8 | + | ||
| 9 | +export { RouterJumpInterceptor, JumpInterceptorAction } from './src/main/ets/router/RouterJumpInterceptor' |
| 1 | +import { WDRouterPage } from './WDRouterPage'; | ||
| 2 | + | ||
| 3 | +export interface JumpInterceptorAction { | ||
| 4 | + on(params?: object, singleMode?: boolean): boolean | ||
| 5 | +} | ||
| 6 | + | ||
| 7 | +// TODO:待优化 | ||
| 8 | +// 临时解决跳转页面之前方法拦截,比如登录先走一键登录,直播请求接口等 | ||
| 9 | +// | ||
| 10 | +export class RouterJumpInterceptor { | ||
| 11 | + | ||
| 12 | + private static actions: Record<string, JumpInterceptorAction> = {} | ||
| 13 | + | ||
| 14 | + static getInterceptorAction(jumpPage: WDRouterPage): JumpInterceptorAction | undefined { | ||
| 15 | + return RouterJumpInterceptor.actions[jumpPage.url()] | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + static register(jumpPage: WDRouterPage, interceptorAction: JumpInterceptorAction) { | ||
| 19 | + RouterJumpInterceptor.actions[jumpPage.url()] = interceptorAction | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +} |
| @@ -66,6 +66,7 @@ export class WDRouterPage { | @@ -66,6 +66,7 @@ export class WDRouterPage { | ||
| 66 | // 动态详情页 | 66 | // 动态详情页 |
| 67 | static dynamicDetailPage = new WDRouterPage("phone", "ets/pages/detail/DynamicDetailPage"); | 67 | static dynamicDetailPage = new WDRouterPage("phone", "ets/pages/detail/DynamicDetailPage"); |
| 68 | static loginPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginPage"); | 68 | static loginPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginPage"); |
| 69 | + static oneKeyLoginPage = new WDRouterPage("wdLogin", "ets/pages/login/OneKeyLoginPage"); | ||
| 69 | static forgetPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/ForgetPasswordPage"); | 70 | static forgetPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/ForgetPasswordPage"); |
| 70 | //我的 预约 | 71 | //我的 预约 |
| 71 | static appointmentListPage = new WDRouterPage("wdComponent", "ets/components/page/AppointmentListPage"); | 72 | static appointmentListPage = new WDRouterPage("wdComponent", "ets/components/page/AppointmentListPage"); |
| @@ -3,6 +3,7 @@ import { Action } from 'wdBean' | @@ -3,6 +3,7 @@ import { Action } from 'wdBean' | ||
| 3 | import { ToastUtils } from 'wdKit' | 3 | import { ToastUtils } from 'wdKit' |
| 4 | import { Action2Page } from './Action2Page' | 4 | import { Action2Page } from './Action2Page' |
| 5 | import { WDRouterPage } from './WDRouterPage' | 5 | import { WDRouterPage } from './WDRouterPage' |
| 6 | +import { RouterJumpInterceptor } from './RouterJumpInterceptor' | ||
| 6 | 7 | ||
| 7 | export class WDRouterRule { | 8 | export class WDRouterRule { |
| 8 | static jumpWithAction(action?: Action) { | 9 | static jumpWithAction(action?: Action) { |
| @@ -16,6 +17,11 @@ export class WDRouterRule { | @@ -16,6 +17,11 @@ export class WDRouterRule { | ||
| 16 | 17 | ||
| 17 | static jumpWithPage(page?: WDRouterPage, params?: object, singleMode?: boolean) { | 18 | static jumpWithPage(page?: WDRouterPage, params?: object, singleMode?: boolean) { |
| 18 | if (page) { | 19 | if (page) { |
| 20 | + let action = RouterJumpInterceptor.getInterceptorAction(page) | ||
| 21 | + if (action && action.on(params, singleMode)) { | ||
| 22 | + return | ||
| 23 | + } | ||
| 24 | + | ||
| 19 | let mode = router.RouterMode.Standard | 25 | let mode = router.RouterMode.Standard |
| 20 | if (singleMode) { | 26 | if (singleMode) { |
| 21 | mode = router.RouterMode.Single | 27 | mode = router.RouterMode.Single |
| @@ -36,6 +42,10 @@ export class WDRouterRule { | @@ -36,6 +42,10 @@ export class WDRouterRule { | ||
| 36 | 42 | ||
| 37 | static jumpWithReplacePage(page?: WDRouterPage, params?: object) { | 43 | static jumpWithReplacePage(page?: WDRouterPage, params?: object) { |
| 38 | if (page) { | 44 | if (page) { |
| 45 | + let action = RouterJumpInterceptor.getInterceptorAction(page) | ||
| 46 | + if (action && action.on(params)) { | ||
| 47 | + return | ||
| 48 | + } | ||
| 39 | if (params) { | 49 | if (params) { |
| 40 | // router.pushUrl({ url: 'pages/routerpage2', , params: params }) | 50 | // router.pushUrl({ url: 'pages/routerpage2', , params: params }) |
| 41 | router.replaceUrl({ url: page.url(), params: params }) | 51 | router.replaceUrl({ url: page.url(), params: params }) |
| @@ -17,7 +17,7 @@ const TAG = 'ProcessUtils'; | @@ -17,7 +17,7 @@ const TAG = 'ProcessUtils'; | ||
| 17 | */ | 17 | */ |
| 18 | export class ProcessUtils { | 18 | export class ProcessUtils { |
| 19 | /** | 19 | /** |
| 20 | - * 广告中心的业务广告跳转方法( 现用在挂角广告) | 20 | + * 广告中心的业务广告跳转方法( 现用在挂角广告、信息流页面广告) |
| 21 | * @param advContent | 21 | * @param advContent |
| 22 | */ | 22 | */ |
| 23 | static openAdvDetail(matInfo: CompAdvMatInfoBean) { | 23 | static openAdvDetail(matInfo: CompAdvMatInfoBean) { |
| @@ -24,7 +24,6 @@ import { ZhGridLayout02 } from './compview/ZhGridLayout02'; | @@ -24,7 +24,6 @@ import { ZhGridLayout02 } from './compview/ZhGridLayout02'; | ||
| 24 | import { Card2Component } from './cardview/Card2Component'; | 24 | import { Card2Component } from './cardview/Card2Component'; |
| 25 | import { Card5Component } from './cardview/Card5Component'; | 25 | import { Card5Component } from './cardview/Card5Component'; |
| 26 | import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | 26 | import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; |
| 27 | -import { CardAdvComponent } from './cardViewAdv/CardAdvComponent'; | ||
| 28 | import { AdvCardParser } from './cardViewAdv/AdvCardParser'; | 27 | import { AdvCardParser } from './cardViewAdv/AdvCardParser'; |
| 29 | 28 | ||
| 30 | /** | 29 | /** |
| 1 | import { CompStyle } from 'wdConstant'; | 1 | import { CompStyle } from 'wdConstant'; |
| 2 | import { CompDTO } from 'wdBean'; | 2 | import { CompDTO } from 'wdBean'; |
| 3 | -import { CardAdvComponent } from './CardAdvComponent'; | ||
| 4 | import { CardAdvThreeImageComponent } from './CardAdvThreeImageComponent'; | 3 | import { CardAdvThreeImageComponent } from './CardAdvThreeImageComponent'; |
| 5 | import { CardAdvSmallImageComponent } from './CardAdvSmallImageComponent'; | 4 | import { CardAdvSmallImageComponent } from './CardAdvSmallImageComponent'; |
| 6 | import { CardAdvLongImageComponent } from './CardAdvLongImageComponent'; | 5 | import { CardAdvLongImageComponent } from './CardAdvLongImageComponent'; |
| @@ -22,12 +22,12 @@ export struct CardAdvBigImageComponent { | @@ -22,12 +22,12 @@ export struct CardAdvBigImageComponent { | ||
| 22 | 22 | ||
| 23 | aboutToAppear(): void { | 23 | aboutToAppear(): void { |
| 24 | 24 | ||
| 25 | - console.error('ZZZXXXXX', '--------aboutToAppear-----') | 25 | + console.error('ZZZXXXXX', '----大图卡----aboutToAppear-----') |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | aboutToDisappear(): void { | 28 | aboutToDisappear(): void { |
| 29 | 29 | ||
| 30 | - console.error('ZZZXXXXX', '--------aboutToDisappear-----') | 30 | + console.error('ZZZXXXXX', '---大图卡-----aboutToDisappear-----') |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | build() { | 33 | build() { |
sight_harmony/features/wdComponent/src/main/ets/components/cardViewAdv/CardAdvComponent.ets
deleted
100644 → 0
| 1 | -//全标题 "appStyle":"2", | ||
| 2 | -import { CompDTO, ContentDTO } from 'wdBean'; | ||
| 3 | -import { CommonConstants } from 'wdConstant/Index'; | ||
| 4 | -import { ProcessUtils } from 'wdRouter'; | ||
| 5 | -import { CardMediaInfo } from '../cardCommon/CardMediaInfo' | ||
| 6 | -import { CardSourceInfo } from '../cardCommon/CardSourceInfo' | ||
| 7 | - | ||
| 8 | -const TAG: string = 'Card2Component'; | ||
| 9 | - | ||
| 10 | -/** | ||
| 11 | - * @Description: 类描述 | ||
| 12 | - * @Author: | ||
| 13 | - * @Email: liyubing@wondertek.com.cn | ||
| 14 | - * @CreateDate: | ||
| 15 | - * @UpdateRemark: 更新说明 | ||
| 16 | - * @Version: 1.0 | ||
| 17 | - */ | ||
| 18 | -@Component | ||
| 19 | -export struct CardAdvComponent { | ||
| 20 | - | ||
| 21 | - @State compDTO: CompDTO = {} as CompDTO | ||
| 22 | - | ||
| 23 | - aboutToAppear(): void { | ||
| 24 | - | ||
| 25 | - console.error('ZZZXXXXX', '--------aboutToAppear-----') | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | - aboutToDisappear(): void { | ||
| 29 | - | ||
| 30 | - console.error('ZZZXXXXX', '--------aboutToDisappear-----') | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - build() { | ||
| 34 | - | ||
| 35 | - Column() { | ||
| 36 | - Text(this.compDTO.matInfo.advTitle) | ||
| 37 | - .fontSize($r('app.float.font_size_17')) | ||
| 38 | - .fontColor($r('app.color.color_222222')) | ||
| 39 | - .maxLines(3) | ||
| 40 | - .textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。 | ||
| 41 | - .align(Alignment.Start) | ||
| 42 | - } | ||
| 43 | - .width(CommonConstants.FULL_WIDTH) | ||
| 44 | - .padding({ | ||
| 45 | - left: $r('app.float.card_comp_pagePadding_lf'), | ||
| 46 | - right: $r('app.float.card_comp_pagePadding_lf'), | ||
| 47 | - top: $r('app.float.card_comp_pagePadding_tb'), | ||
| 48 | - bottom: $r('app.float.card_comp_pagePadding_tb') | ||
| 49 | - }) | ||
| 50 | - .onClick((event: ClickEvent) => { | ||
| 51 | - //ProcessUtils.processPage(this.contentDTO) | ||
| 52 | - }) | ||
| 53 | - } | ||
| 54 | -} | ||
| 55 | - | ||
| 56 | -@Extend(Text) | ||
| 57 | -function bottomTextStyle() { | ||
| 58 | - .fontSize(12) | ||
| 59 | - .fontColor('#B0B0B0') | ||
| 60 | -} |
| @@ -22,12 +22,12 @@ export struct CardAdvGanMiComponent { | @@ -22,12 +22,12 @@ export struct CardAdvGanMiComponent { | ||
| 22 | 22 | ||
| 23 | aboutToAppear(): void { | 23 | aboutToAppear(): void { |
| 24 | 24 | ||
| 25 | - console.error('ZZZXXXXX', '--------aboutToAppear-----') | 25 | + console.error('ZZZXXXXX', '--冠名广告------aboutToAppear-----') |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | aboutToDisappear(): void { | 28 | aboutToDisappear(): void { |
| 29 | 29 | ||
| 30 | - console.error('ZZZXXXXX', '--------aboutToDisappear-----') | 30 | + console.error('ZZZXXXXX', '--冠名广告------aboutToDisappear-----') |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | build() { | 33 | build() { |
sight_harmony/features/wdComponent/src/main/ets/components/cardViewAdv/CardAdvLongImageComponent.ets
| @@ -22,12 +22,12 @@ export struct CardAdvLongImageComponent { | @@ -22,12 +22,12 @@ export struct CardAdvLongImageComponent { | ||
| 22 | 22 | ||
| 23 | aboutToAppear(): void { | 23 | aboutToAppear(): void { |
| 24 | 24 | ||
| 25 | - console.error('ZZZXXXXX', '--------aboutToAppear-----') | 25 | + console.error('ZZZXXXXX', '--长通栏广告 和 顶部长通栏广告------aboutToAppear-----') |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | aboutToDisappear(): void { | 28 | aboutToDisappear(): void { |
| 29 | 29 | ||
| 30 | - console.error('ZZZXXXXX', '--------aboutToDisappear-----') | 30 | + console.error('ZZZXXXXX', '--长通栏广告 和 顶部长通栏广告------aboutToDisappear-----') |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | build() { | 33 | build() { |
| 1 | //全标题 "appStyle":"2", | 1 | //全标题 "appStyle":"2", |
| 2 | -import { CompDTO, ContentDTO } from 'wdBean'; | ||
| 3 | -import { CommonConstants } from 'wdConstant/Index'; | 2 | +import { CompDTO } from 'wdBean'; |
| 4 | import { ProcessUtils } from 'wdRouter'; | 3 | import { ProcessUtils } from 'wdRouter'; |
| 5 | -import { CardMediaInfo } from '../cardCommon/CardMediaInfo' | ||
| 6 | -import { CardSourceInfo } from '../cardCommon/CardSourceInfo' | ||
| 7 | - | ||
| 8 | -const TAG: string = 'Card2Component'; | ||
| 9 | - | ||
| 10 | -/** | ||
| 11 | - * @Description: 广告---小图卡 | ||
| 12 | - * @Author: | ||
| 13 | - * @Email: liyubing@wondertek.com.cn | ||
| 14 | - * @CreateDate: | ||
| 15 | - * @UpdateRemark: 更新说明 | ||
| 16 | - * @Version: 1.0 | 4 | + |
| 5 | +import measure from '@ohos.measure'; | ||
| 6 | +import { DisplayUtils } from 'wdKit/Index'; | ||
| 7 | + | ||
| 8 | +const TAG: string = 'CardAdvSmallImageComponent'; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * @Description: 广告---小图卡 | ||
| 12 | + * @Author: | ||
| 13 | + * @Email: liyubing@wondertek.com.cn | ||
| 14 | + * @CreateDate: | ||
| 15 | + * @UpdateRemark: 更新说明 | ||
| 16 | + * @Version: 1.0 | ||
| 17 | */ | 17 | */ |
| 18 | @Component | 18 | @Component |
| 19 | export struct CardAdvSmallImageComponent { | 19 | export struct CardAdvSmallImageComponent { |
| 20 | - | ||
| 21 | @State compDTO: CompDTO = {} as CompDTO | 20 | @State compDTO: CompDTO = {} as CompDTO |
| 21 | + @State isBigThreeLine: boolean = false // 标题的行数大于等于3行 是true | ||
| 22 | 22 | ||
| 23 | aboutToAppear(): void { | 23 | aboutToAppear(): void { |
| 24 | 24 | ||
| 25 | - console.error('ZZZXXXXX', '--------aboutToAppear-----') | 25 | + console.error('ZZZXXXXX', '----小图卡----aboutToAppear-----') |
| 26 | + // 计算标题文本行数 | ||
| 27 | + let screenWith = DisplayUtils.getDeviceWidth(); | ||
| 28 | + screenWith = screenWith * 0.62 | ||
| 29 | + let titleNameLineNum = this.getTextLineNum(this.compDTO.matInfo.advTitle, screenWith, 25, 18) | ||
| 30 | + this.isBigThreeLine = titleNameLineNum >= 3; | ||
| 26 | } | 31 | } |
| 27 | 32 | ||
| 28 | aboutToDisappear(): void { | 33 | aboutToDisappear(): void { |
| 29 | 34 | ||
| 30 | - console.error('ZZZXXXXX', '--------aboutToDisappear-----') | 35 | + console.error('ZZZXXXXX', '---小图卡-----aboutToDisappear-----') |
| 31 | } | 36 | } |
| 32 | 37 | ||
| 33 | build() { | 38 | build() { |
| 34 | 39 | ||
| 35 | - Column() { | 40 | + RelativeContainer() { |
| 41 | + | ||
| 42 | + // 广告标题 | ||
| 36 | Text(this.compDTO.matInfo.advTitle) | 43 | Text(this.compDTO.matInfo.advTitle) |
| 37 | - .fontSize($r('app.float.font_size_17')) | 44 | + .fontSize('18fp') |
| 38 | .fontColor($r('app.color.color_222222')) | 45 | .fontColor($r('app.color.color_222222')) |
| 39 | .maxLines(3) | 46 | .maxLines(3) |
| 47 | + .lineHeight(25) | ||
| 40 | .textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。 | 48 | .textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。 |
| 41 | - .align(Alignment.Start) | 49 | + .width('62%') |
| 50 | + .alignRules({ | ||
| 51 | + top: { anchor: '__container__', align: VerticalAlign.Top }, | ||
| 52 | + left: { anchor: '__container__', align: HorizontalAlign.Start }, | ||
| 53 | + }) | ||
| 54 | + .id("title_name") | ||
| 55 | + // 广告图 | ||
| 56 | + Image(this.compDTO.matInfo.matImageUrl[0]) | ||
| 57 | + .width('34%') | ||
| 58 | + .aspectRatio(3 / 2) | ||
| 59 | + .borderRadius(4) | ||
| 60 | + .id('adv_imag') | ||
| 61 | + .alignRules({ | ||
| 62 | + top: { anchor: 'title_name', align: VerticalAlign.Top }, | ||
| 63 | + left: { anchor: 'title_name', align: HorizontalAlign.End }, | ||
| 64 | + | ||
| 65 | + }) | ||
| 66 | + .margin({ left: 12 }) | ||
| 67 | + | ||
| 68 | + Row() { | ||
| 69 | + Text($r('app.string.comp_advertisement')).fontSize('12fp').fontColor($r('app.color.color_B0B0B0')) | ||
| 70 | + | ||
| 71 | + Blank() | ||
| 72 | + | ||
| 73 | + Stack() { | ||
| 74 | + Image($r('app.media.comp_adv_close')) | ||
| 75 | + .width(9) | ||
| 76 | + .height(9) | ||
| 77 | + .borderRadius({ | ||
| 78 | + topLeft: '4vp', | ||
| 79 | + topRight: '4vp', | ||
| 80 | + bottomLeft: '4vp', | ||
| 81 | + bottomRight: '4vp' | ||
| 82 | + }) | ||
| 83 | + } | ||
| 84 | + .width(18) | ||
| 85 | + .height(14) | ||
| 86 | + .borderWidth(0.5) | ||
| 87 | + .borderColor($r('app.color.color_EDEDED')) | ||
| 88 | + .borderRadius(4) | ||
| 89 | + | ||
| 90 | + }.width('62%').alignRules({ | ||
| 91 | + bottom: { anchor: this.isBigThreeLine ? '' : 'adv_imag', align: VerticalAlign.Bottom }, | ||
| 92 | + right: { anchor: this.isBigThreeLine ? '' : 'adv_imag', align: HorizontalAlign.Start }, | ||
| 93 | + | ||
| 94 | + top: { anchor: this.isBigThreeLine ? 'title_name' : '', align: VerticalAlign.Bottom }, | ||
| 95 | + left: { anchor: this.isBigThreeLine ? 'title_name' : '', align: HorizontalAlign.Start }, | ||
| 96 | + }).id('bottom_adv').margin({ | ||
| 97 | + right: this.isBigThreeLine ? 0 : 12, | ||
| 98 | + top: this.isBigThreeLine ? 8 : 0, | ||
| 99 | + }) | ||
| 42 | } | 100 | } |
| 43 | - .width(CommonConstants.FULL_WIDTH) | 101 | + .width("100%") |
| 102 | + .height(this.isBigThreeLine ? 127 : 106) | ||
| 44 | .padding({ | 103 | .padding({ |
| 45 | left: $r('app.float.card_comp_pagePadding_lf'), | 104 | left: $r('app.float.card_comp_pagePadding_lf'), |
| 46 | right: $r('app.float.card_comp_pagePadding_lf'), | 105 | right: $r('app.float.card_comp_pagePadding_lf'), |
| @@ -48,13 +107,31 @@ export struct CardAdvSmallImageComponent { | @@ -48,13 +107,31 @@ export struct CardAdvSmallImageComponent { | ||
| 48 | bottom: $r('app.float.card_comp_pagePadding_tb') | 107 | bottom: $r('app.float.card_comp_pagePadding_tb') |
| 49 | }) | 108 | }) |
| 50 | .onClick((event: ClickEvent) => { | 109 | .onClick((event: ClickEvent) => { |
| 51 | - //ProcessUtils.processPage(this.contentDTO) | 110 | + ProcessUtils.openAdvDetail(this.compDTO.matInfo) |
| 111 | + }) | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + // 获取文本几行 | ||
| 115 | + private getTextLineNum(text: string, constraintWidth: number, lineHeight: number, fontSize: number | string | Resource) { | ||
| 116 | + let size = this.topMeasureText(text, constraintWidth, lineHeight, fontSize) | ||
| 117 | + let height: number = Number(size.height) | ||
| 118 | + return Math.ceil(px2vp(height) / lineHeight) | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + private topMeasureText(text: string, constraintWidth: number, lineHeight: number, fontSize: number | string | Resource) { | ||
| 122 | + return measure.measureTextSize({ | ||
| 123 | + textContent: text, | ||
| 124 | + fontSize: fontSize, | ||
| 125 | + lineHeight: lineHeight, | ||
| 126 | + constraintWidth: constraintWidth, | ||
| 52 | }) | 127 | }) |
| 53 | } | 128 | } |
| 54 | } | 129 | } |
| 55 | 130 | ||
| 131 | + | ||
| 56 | @Extend(Text) | 132 | @Extend(Text) |
| 57 | function bottomTextStyle() { | 133 | function bottomTextStyle() { |
| 58 | .fontSize(12) | 134 | .fontSize(12) |
| 59 | .fontColor('#B0B0B0') | 135 | .fontColor('#B0B0B0') |
| 60 | -} | ||
| 136 | +} | ||
| 137 | + |
| @@ -22,12 +22,12 @@ export struct CardAdvThreeImageComponent { | @@ -22,12 +22,12 @@ export struct CardAdvThreeImageComponent { | ||
| 22 | 22 | ||
| 23 | aboutToAppear(): void { | 23 | aboutToAppear(): void { |
| 24 | 24 | ||
| 25 | - console.error('ZZZXXXXX', '--------aboutToAppear-----') | 25 | + console.error('ZZZXXXXX', '---三图卡-----aboutToAppear-----') |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | aboutToDisappear(): void { | 28 | aboutToDisappear(): void { |
| 29 | 29 | ||
| 30 | - console.error('ZZZXXXXX', '--------aboutToDisappear-----') | 30 | + console.error('ZZZXXXXX', '----三图卡----aboutToDisappear-----') |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | build() { | 33 | build() { |
| @@ -22,12 +22,12 @@ export struct CardAdvVideoComponent { | @@ -22,12 +22,12 @@ export struct CardAdvVideoComponent { | ||
| 22 | 22 | ||
| 23 | aboutToAppear(): void { | 23 | aboutToAppear(): void { |
| 24 | 24 | ||
| 25 | - console.error('ZZZXXXXX', '--------aboutToAppear-----') | 25 | + console.error('ZZZXXXXX', '--视频广告------aboutToAppear-----') |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | aboutToDisappear(): void { | 28 | aboutToDisappear(): void { |
| 29 | 29 | ||
| 30 | - console.error('ZZZXXXXX', '--------aboutToDisappear-----') | 30 | + console.error('ZZZXXXXX', '---视频广告-----aboutToDisappear-----') |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | build() { | 33 | build() { |
| @@ -22,12 +22,12 @@ export struct CardAdvVideoExComponent { | @@ -22,12 +22,12 @@ export struct CardAdvVideoExComponent { | ||
| 22 | 22 | ||
| 23 | aboutToAppear(): void { | 23 | aboutToAppear(): void { |
| 24 | 24 | ||
| 25 | - console.error('ZZZXXXXX', '--------aboutToAppear-----') | 25 | + console.error('ZZZXXXXX', '--冠名广告------aboutToAppear-----') |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | aboutToDisappear(): void { | 28 | aboutToDisappear(): void { |
| 29 | 29 | ||
| 30 | - console.error('ZZZXXXXX', '--------aboutToDisappear-----') | 30 | + console.error('ZZZXXXXX', '----冠名广告----aboutToDisappear-----') |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | build() { | 33 | build() { |
335 Bytes
| 1 | export { add } from "./src/main/ets/utils/Calc" | 1 | export { add } from "./src/main/ets/utils/Calc" |
| 2 | -export { SettingPasswordParams } from "./src/main/ets/pages/login/SettingPasswordLayout" | ||
| 2 | +export { SettingPasswordParams } from "./src/main/ets/pages/login/SettingPasswordLayout" | ||
| 3 | + | ||
| 4 | +export { LoginModule } from './src/main/ets/LoginModule' |
| 1 | +import HuaweiAuth from './utils/HuaweiAuth' | ||
| 2 | +import { JumpInterceptorAction, RouterJumpInterceptor, WDRouterPage } from 'wdRouter' | ||
| 3 | +import { BusinessError } from '@kit.BasicServicesKit' | ||
| 4 | +import { router } from '@kit.ArkUI' | ||
| 5 | +import { AccountManagerUtils } from 'wdKit/Index' | ||
| 6 | + | ||
| 7 | +class LoginJumpHandler implements JumpInterceptorAction { | ||
| 8 | + | ||
| 9 | + /// 说明是调用了跳转 WDRouterPage.loginPage 页面的行为 | ||
| 10 | + on(params?: object | undefined, singleMode?: boolean | undefined): boolean { | ||
| 11 | + | ||
| 12 | + HuaweiAuth.sharedInstance().fetchAnonymousPhone().then((anonymousPhone) => { | ||
| 13 | + | ||
| 14 | + router.pushUrl({url: WDRouterPage.oneKeyLoginPage.url()}) | ||
| 15 | + }).catch((error: string) => { | ||
| 16 | + router.pushUrl({url: WDRouterPage.loginPage.url()}) | ||
| 17 | + }) | ||
| 18 | + return true | ||
| 19 | + } | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +export class LoginModule { | ||
| 23 | + | ||
| 24 | + static startup() { | ||
| 25 | + | ||
| 26 | + /// 初始化华为一键登录相关 | ||
| 27 | + if (HuaweiAuth.enable) { | ||
| 28 | + | ||
| 29 | + HuaweiAuth.sharedInstance().registerEvents() | ||
| 30 | + | ||
| 31 | + AccountManagerUtils.isLogin().then((login) => { | ||
| 32 | + if (!login) { | ||
| 33 | + HuaweiAuth.sharedInstance().rePrefetchAnonymousPhone() | ||
| 34 | + } | ||
| 35 | + }) | ||
| 36 | + RouterJumpInterceptor.register(WDRouterPage.loginPage, new LoginJumpHandler()) | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + } | ||
| 40 | +} |
| @@ -9,6 +9,10 @@ import { WDRouterPage } from 'wdRouter/src/main/ets/router/WDRouterPage'; | @@ -9,6 +9,10 @@ import { WDRouterPage } from 'wdRouter/src/main/ets/router/WDRouterPage'; | ||
| 9 | import { WDRouterRule } from 'wdRouter/src/main/ets/router/WDRouterRule'; | 9 | import { WDRouterRule } from 'wdRouter/src/main/ets/router/WDRouterRule'; |
| 10 | import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/src/main/ets/bean/content/Params' | 10 | import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/src/main/ets/bean/content/Params' |
| 11 | import {InterestsHobbiesModel} from '../../../../../../../products/phone/src/main/ets/pages/viewModel/InterestsHobbiesModel' | 11 | import {InterestsHobbiesModel} from '../../../../../../../products/phone/src/main/ets/pages/viewModel/InterestsHobbiesModel' |
| 12 | +import HuaweiAuth from '../../utils/HuaweiAuth' | ||
| 13 | +import { loginComponentManager, LoginWithHuaweiIDButton } from '@hms.core.account.LoginComponent' | ||
| 14 | +import { BusinessError } from '@ohos.base' | ||
| 15 | + | ||
| 12 | @Extend(Row) | 16 | @Extend(Row) |
| 13 | function otherStyle() { | 17 | function otherStyle() { |
| 14 | .backgroundImageSize(ImageSize.Cover) | 18 | .backgroundImageSize(ImageSize.Cover) |
| @@ -56,7 +60,6 @@ struct LoginPage { | @@ -56,7 +60,6 @@ struct LoginPage { | ||
| 56 | }) | 60 | }) |
| 57 | loginViewModel = new LoginViewModel() | 61 | loginViewModel = new LoginViewModel() |
| 58 | @State isProtocol:boolean=false | 62 | @State isProtocol:boolean=false |
| 59 | - | ||
| 60 | onCodeSend() { | 63 | onCodeSend() { |
| 61 | Logger.debug(TAG, "isCodeSend:" + this.isCodeSend + "") | 64 | Logger.debug(TAG, "isCodeSend:" + this.isCodeSend + "") |
| 62 | if (this.isCodeSend) { | 65 | if (this.isCodeSend) { |
| @@ -15,6 +15,7 @@ struct LoginProtocolWebview { | @@ -15,6 +15,7 @@ struct LoginProtocolWebview { | ||
| 15 | userProtocol = "https://cdnpeoplefrontuat.aikan.pdnews.cn/rmrb/rmrb-protocol-zh-web/0.0.1/app/protocol-1005.html" | 15 | userProtocol = "https://cdnpeoplefrontuat.aikan.pdnews.cn/rmrb/rmrb-protocol-zh-web/0.0.1/app/protocol-1005.html" |
| 16 | privateProtocol = 'https://cdnpeoplefrontuat.aikan.pdnews.cn/rmrb/rmrb-protocol-zh-web/0.0.1/app/protocol-1001.html' | 16 | privateProtocol = 'https://cdnpeoplefrontuat.aikan.pdnews.cn/rmrb/rmrb-protocol-zh-web/0.0.1/app/protocol-1001.html' |
| 17 | logoutProtocol = 'https://cdnpeoplefrontuat.aikan.pdnews.cn/rmrb/rmrb-protocol-zh-web/0.0.1/app/protocol-1003.html' | 17 | logoutProtocol = 'https://cdnpeoplefrontuat.aikan.pdnews.cn/rmrb/rmrb-protocol-zh-web/0.0.1/app/protocol-1003.html' |
| 18 | + huaweiAuthProtocol = 'https://privacy.consumer.huawei.com/legal/id/authentication-terms.htm?code=CN&language=zh-CN' | ||
| 18 | 19 | ||
| 19 | async aboutToAppear() { | 20 | async aboutToAppear() { |
| 20 | if (router.getParams()) { | 21 | if (router.getParams()) { |
| @@ -30,6 +31,9 @@ struct LoginProtocolWebview { | @@ -30,6 +31,9 @@ struct LoginProtocolWebview { | ||
| 30 | }else if(params.contentID == "3"){ //注销协议 | 31 | }else if(params.contentID == "3"){ //注销协议 |
| 31 | this.webUrl = await SPHelper.default.get(SpConstants.LOGOUT_PROTOCOL, this.logoutProtocol) as string | 32 | this.webUrl = await SPHelper.default.get(SpConstants.LOGOUT_PROTOCOL, this.logoutProtocol) as string |
| 32 | this.webviewController.loadUrl(this.webUrl) | 33 | this.webviewController.loadUrl(this.webUrl) |
| 34 | + } else if(params.contentID == "4"){ //华为用户认证协议 | ||
| 35 | + this.webUrl = this.huaweiAuthProtocol | ||
| 36 | + this.webviewController.loadUrl(this.webUrl) | ||
| 33 | } | 37 | } |
| 34 | } | 38 | } |
| 35 | 39 |
| 1 | +import { router } from '@kit.ArkUI' | ||
| 2 | +import { Params } from 'wdBean/Index' | ||
| 3 | +import { WDRouterPage, WDRouterRule } from 'wdRouter/Index' | ||
| 4 | +import HuaweiAuth from '../../utils/HuaweiAuth' | ||
| 5 | +import { BusinessError } from '@kit.BasicServicesKit' | ||
| 6 | + | ||
| 7 | +@Entry | ||
| 8 | +@Component | ||
| 9 | +struct OneKeyLoginPage { | ||
| 10 | + anonymousPhone: string = '' | ||
| 11 | + @State agreeProtocol: boolean = false | ||
| 12 | + | ||
| 13 | + aboutToAppear(): void { | ||
| 14 | + this.anonymousPhone = HuaweiAuth.sharedInstance().anonymousPhone||"" | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + build() { | ||
| 18 | + Column() { | ||
| 19 | + this.CloseRow() | ||
| 20 | + | ||
| 21 | + Image($r("app.media.login_logo")) | ||
| 22 | + .width(120) | ||
| 23 | + .height(66) | ||
| 24 | + .margin({ top: 78, bottom: 74}) | ||
| 25 | + .align(Alignment.Center) | ||
| 26 | + | ||
| 27 | + Text(this.anonymousPhone) | ||
| 28 | + .fontSize(30) | ||
| 29 | + .fontWeight(600) | ||
| 30 | + .fontColor("#222222") | ||
| 31 | + .margin({bottom: 10}) | ||
| 32 | + .align(Alignment.Center) | ||
| 33 | + | ||
| 34 | + this.ProtocolRow() | ||
| 35 | + | ||
| 36 | + Row() { | ||
| 37 | + Button("华为账号一键登录") | ||
| 38 | + .type(ButtonType.Normal) | ||
| 39 | + .height(48) | ||
| 40 | + .backgroundColor(!this.agreeProtocol ? Color.Grey : Color.Red) | ||
| 41 | + .width("100%") | ||
| 42 | + .onClick((event) => { | ||
| 43 | + if (!this.agreeProtocol) { | ||
| 44 | + return | ||
| 45 | + } | ||
| 46 | + HuaweiAuth.sharedInstance().oneKeyLogin().then((authorizeCode) => { | ||
| 47 | + | ||
| 48 | + //TODO: 调用服务端接口登录 | ||
| 49 | + }).catch((error: BusinessError) => { | ||
| 50 | + | ||
| 51 | + }) | ||
| 52 | + }) | ||
| 53 | + } | ||
| 54 | + .padding({ left: 25, right: 25 }) | ||
| 55 | + .margin({top: 15}) | ||
| 56 | + | ||
| 57 | + Button("其他手机号登录") | ||
| 58 | + .type(ButtonType.Normal) | ||
| 59 | + .align(Alignment.Center) | ||
| 60 | + .foregroundColor("#666666") | ||
| 61 | + .backgroundColor(Color.White) | ||
| 62 | + .onClick((event) => { | ||
| 63 | + router.replaceUrl({url: WDRouterPage.loginPage.url()}) | ||
| 64 | + }) | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + @Builder ProtocolRow() { | ||
| 69 | + Row({space: 4}) { | ||
| 70 | + Image(this.agreeProtocol ? $r('app.media.login_checkbox_select') : $r('app.media.login_checkbox_unselected')) | ||
| 71 | + .width(15) | ||
| 72 | + .height(15) | ||
| 73 | + .onClick(() => { | ||
| 74 | + this.agreeProtocol = !this.agreeProtocol | ||
| 75 | + }) | ||
| 76 | + Text() { | ||
| 77 | + Span("我已阅读并同意").fontColor("#999999").fontSize(12) | ||
| 78 | + Span("《用户协议》").fontColor("#ED2800").fontSize(12).onClick(() => { | ||
| 79 | + let bean = { contentID: "1", pageID: "" } as Params | ||
| 80 | + WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean) | ||
| 81 | + }) | ||
| 82 | + Span("、").fontColor("#999999").fontSize(12) | ||
| 83 | + Span("《隐私政策》").fontColor("#ED2800").fontSize(12).onClick(() => { | ||
| 84 | + let bean = { contentID: "2", pageID: "" } as Params | ||
| 85 | + WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean) | ||
| 86 | + }) | ||
| 87 | + Span("和").fontColor("#999999").fontSize(12) | ||
| 88 | + Span("《华为账号用户认证协议》").fontColor("#ED2800").fontSize(12).onClick(() => { | ||
| 89 | + let bean = { contentID: "4", pageID: "" } as Params | ||
| 90 | + WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean) | ||
| 91 | + }) | ||
| 92 | + } | ||
| 93 | + .layoutWeight(1) | ||
| 94 | + } | ||
| 95 | + .margin({top: 15}) | ||
| 96 | + .padding({ left: 25, right: 25 }) | ||
| 97 | + .width('100%') | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + @Builder CloseRow() { | ||
| 101 | + Row() { | ||
| 102 | + Blank() | ||
| 103 | + Image($r('app.media.login_closed')) | ||
| 104 | + .width(24) | ||
| 105 | + .height(24) | ||
| 106 | + .onClick(() => router.back()) | ||
| 107 | + }.margin({ top: 15, right: 15 }) | ||
| 108 | + .width("100%") | ||
| 109 | + } | ||
| 110 | +} |
| 1 | +import { authentication, extendService } from '@kit.AccountKit'; | ||
| 2 | +import { AccountManagerUtils, EmitterEventId, EmitterUtils, Logger } from 'wdKit/Index'; | ||
| 3 | +import { util } from '@kit.ArkTS'; | ||
| 4 | +import { DEFAULT } from '@ohos/hypium'; | ||
| 5 | +import { BusinessError } from '@kit.BasicServicesKit'; | ||
| 6 | + | ||
| 7 | +const TAG = "HuaweiOneKeyAuth" | ||
| 8 | + | ||
| 9 | +export default class HuaweiAuth { | ||
| 10 | + | ||
| 11 | + // 是否开启 | ||
| 12 | + static enable = false | ||
| 13 | + // 匿名手机号 | ||
| 14 | + private _anonymousPhone?: string | ||
| 15 | + get anonymousPhone() { | ||
| 16 | + return this._anonymousPhone | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + private static instance: HuaweiAuth | ||
| 20 | + static sharedInstance(): HuaweiAuth { | ||
| 21 | + if (!HuaweiAuth.instance) { | ||
| 22 | + HuaweiAuth.instance = new HuaweiAuth() | ||
| 23 | + } | ||
| 24 | + return HuaweiAuth.instance | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + registerEvents() { | ||
| 28 | + // 注册用户退出登录,取一次用来下次使用 | ||
| 29 | + EmitterUtils.receiveEvent(EmitterEventId.FORCE_USER_LOGIN_OUT, ((str?: string) => { | ||
| 30 | + HuaweiAuth.sharedInstance().rePrefetchAnonymousPhone() | ||
| 31 | + })) | ||
| 32 | + EmitterUtils.receiveEvent(EmitterEventId.APP_ENTER_FOREGROUD, ((str?: string) => { | ||
| 33 | + AccountManagerUtils.isLogin().then((login) => { | ||
| 34 | + if (!login) { | ||
| 35 | + HuaweiAuth.sharedInstance().rePrefetchAnonymousPhone() | ||
| 36 | + } | ||
| 37 | + }) | ||
| 38 | + })) | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + // 重新预取手机号(App启动未登录、回前台未登录、和退出登录 时调用提前取号) | ||
| 42 | + rePrefetchAnonymousPhone() { | ||
| 43 | + this._anonymousPhone = undefined | ||
| 44 | + this.fetchAnonymousPhone() | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + // 要登录时,先调用。如果获取到手机号了 则弹起一键登录页面 | ||
| 48 | + fetchAnonymousPhone() : Promise<string> { | ||
| 49 | + | ||
| 50 | + return new Promise((resolve, fail) => { | ||
| 51 | + if (this.anonymousPhone) { | ||
| 52 | + resolve(this.anonymousPhone) | ||
| 53 | + return | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + let authRequest = new authentication.HuaweiIDProvider().createAuthorizationWithHuaweiIDRequest(); | ||
| 57 | + // 权限有 phone 、email、realTimePhone、quickLoginMobilePhone,这里用获取匿名手机号 | ||
| 58 | + authRequest.scopes = ['quickLoginAnonymousPhone']; | ||
| 59 | + authRequest.state = util.generateRandomUUID(); | ||
| 60 | + authRequest.forceAuthorization = false; | ||
| 61 | + let controller = new authentication.AuthenticationController(getContext(this)); | ||
| 62 | + try { | ||
| 63 | + controller.executeRequest(authRequest).then((response: authentication.AuthorizationWithHuaweiIDResponse) => { | ||
| 64 | + let anonymousPhone = response.data?.extraInfo?.quickLoginAnonymousPhone; | ||
| 65 | + if (anonymousPhone) { | ||
| 66 | + Logger.info(TAG, 'get anonymousPhone, ' + JSON.stringify(response)); | ||
| 67 | + this._anonymousPhone = anonymousPhone as string | ||
| 68 | + resolve(this._anonymousPhone) | ||
| 69 | + return; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + Logger.info(TAG, 'get anonymousPhone is empty. ' + JSON.stringify(response)); | ||
| 73 | + fail("获取匿名手机号为空") | ||
| 74 | + }).catch((err: BusinessError) => { | ||
| 75 | + Logger.error(TAG, 'get anonymousPhone failed. ' + JSON.stringify(err)); | ||
| 76 | + fail("获取匿名手机号失败") | ||
| 77 | + }) | ||
| 78 | + } catch (err) { | ||
| 79 | + Logger.error(TAG, 'get anonymousPhone fail. ' + JSON.stringify(err)); | ||
| 80 | + fail("获取匿名手机号失败") | ||
| 81 | + } | ||
| 82 | + }) | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + // 华为账号一键登录授权 | ||
| 86 | + // 返回结果为 Authorization Code | ||
| 87 | + oneKeyLogin() : Promise<string> { | ||
| 88 | + | ||
| 89 | + let loginRequest = new authentication.HuaweiIDProvider().createLoginWithHuaweiIDRequest(); | ||
| 90 | + // 当用户未登录华为帐号时,是否强制拉起华为帐号登录界面 | ||
| 91 | + loginRequest.forceLogin = true; | ||
| 92 | + loginRequest.state = util.generateRandomUUID(); | ||
| 93 | + | ||
| 94 | + return new Promise((resolve, fail) => { | ||
| 95 | + | ||
| 96 | + try { | ||
| 97 | + let controller = new authentication.AuthenticationController(getContext(this)); | ||
| 98 | + controller.executeRequest(loginRequest, (err, data) => { | ||
| 99 | + if (err) { | ||
| 100 | + Logger.error(TAG, 'login fail, ' + JSON.stringify(err)) | ||
| 101 | + fail(err) | ||
| 102 | + return; | ||
| 103 | + } | ||
| 104 | + let loginWithHuaweiIDResponse = data as authentication.LoginWithHuaweiIDResponse; | ||
| 105 | + let state = loginWithHuaweiIDResponse.state; | ||
| 106 | + if (state != undefined && loginRequest.state != state) { | ||
| 107 | + Logger.error(TAG, 'login fail, The state is different' + JSON.stringify(loginWithHuaweiIDResponse)) | ||
| 108 | + fail({ | ||
| 109 | + code: 99999, | ||
| 110 | + name: "一键登录", | ||
| 111 | + message:"状态错误:" + `请求状态 ${loginRequest.state}, 结果状态 ${state}` | ||
| 112 | + } as BusinessError) | ||
| 113 | + return; | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + Logger.info(TAG, 'login success, ' + JSON.stringify(loginWithHuaweiIDResponse)); | ||
| 117 | + let loginWithHuaweiIDCredential = loginWithHuaweiIDResponse.data!; | ||
| 118 | + let authorizationCode = loginWithHuaweiIDCredential.authorizationCode; | ||
| 119 | + resolve(authorizationCode!) | ||
| 120 | + }); | ||
| 121 | + } catch (error) { | ||
| 122 | + Logger.error(TAG, 'login fail, ' + JSON.stringify(error)) | ||
| 123 | + fail(error) | ||
| 124 | + } | ||
| 125 | + }); | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + // 打开账户中心 | ||
| 129 | + openAccountCenter() { | ||
| 130 | + try { | ||
| 131 | + extendService.startAccountCenter(getContext(this), (err, data) => { | ||
| 132 | + if (err) { | ||
| 133 | + Logger.info(TAG, 'startAccountCenterWithCallback fail,error: ' + JSON.stringify(err)); | ||
| 134 | + return; | ||
| 135 | + } | ||
| 136 | + Logger.info(TAG, 'startAccountCenterWithCallback success'); | ||
| 137 | + }); | ||
| 138 | + } catch (error) { | ||
| 139 | + Logger.error(TAG, 'startAccountCenterWithCallback fail,error: ' + JSON.stringify(error)); | ||
| 140 | + } | ||
| 141 | + } | ||
| 142 | +} |
1.31 KB
| @@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
| 6 | "pages/login/LoginProtocolWebview", | 6 | "pages/login/LoginProtocolWebview", |
| 7 | "pages/login/SettingPasswordPage", | 7 | "pages/login/SettingPasswordPage", |
| 8 | "pages/login/SettingPasswordLayout", | 8 | "pages/login/SettingPasswordLayout", |
| 9 | - "pages/guide/GuidePages" | 9 | + "pages/guide/GuidePages", |
| 10 | + "pages/login/OneKeyLoginPage" | ||
| 10 | ] | 11 | ] |
| 11 | } | 12 | } |
| @@ -16,6 +16,7 @@ | @@ -16,6 +16,7 @@ | ||
| 16 | "wdRouter": "file:../../commons/wdRouter", | 16 | "wdRouter": "file:../../commons/wdRouter", |
| 17 | "wdNetwork": "file:../../commons/wdNetwork", | 17 | "wdNetwork": "file:../../commons/wdNetwork", |
| 18 | "wdHwAbility": "file:../../features/wdHwAbility", | 18 | "wdHwAbility": "file:../../features/wdHwAbility", |
| 19 | - "wdJsBridge": "file:../../commons/wdJsBridge" | 19 | + "wdJsBridge": "file:../../commons/wdJsBridge", |
| 20 | + "wdLogin": "file:../../features/wdLogin" | ||
| 20 | } | 21 | } |
| 21 | } | 22 | } |
| @@ -15,12 +15,14 @@ import { | @@ -15,12 +15,14 @@ import { | ||
| 15 | WindowModel | 15 | WindowModel |
| 16 | } from 'wdKit'; | 16 | } from 'wdKit'; |
| 17 | import { HostEnum, HostManager, WDHttp } from 'wdNetwork'; | 17 | import { HostEnum, HostManager, WDHttp } from 'wdNetwork'; |
| 18 | +import { LoginModule } from 'wdLogin/src/main/ets/LoginModule'; | ||
| 18 | 19 | ||
| 19 | export default class EntryAbility extends UIAbility { | 20 | export default class EntryAbility extends UIAbility { |
| 20 | onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { | 21 | onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { |
| 21 | SPHelper.init(this.context); | 22 | SPHelper.init(this.context); |
| 22 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); | 23 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); |
| 23 | registerRouter(); | 24 | registerRouter(); |
| 25 | + LoginModule.startup() | ||
| 24 | NetworkManager.getInstance().init() | 26 | NetworkManager.getInstance().init() |
| 25 | WDHttp.initHttpHeader() | 27 | WDHttp.initHttpHeader() |
| 26 | const spHostUrl = SPHelper.default.getSync('hostUrl', '') as string | 28 | const spHostUrl = SPHelper.default.getSync('hostUrl', '') as string |
| @@ -94,10 +96,14 @@ export default class EntryAbility extends UIAbility { | @@ -94,10 +96,14 @@ export default class EntryAbility extends UIAbility { | ||
| 94 | onForeground(): void { | 96 | onForeground(): void { |
| 95 | // Ability has brought to foreground | 97 | // Ability has brought to foreground |
| 96 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); | 98 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); |
| 99 | + | ||
| 100 | + EmitterUtils.sendEmptyEvent(EmitterEventId.APP_ENTER_FOREGROUD) | ||
| 97 | } | 101 | } |
| 98 | 102 | ||
| 99 | onBackground(): void { | 103 | onBackground(): void { |
| 100 | // Ability has back to background | 104 | // Ability has back to background |
| 101 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); | 105 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); |
| 106 | + | ||
| 107 | + EmitterUtils.sendEmptyEvent(EmitterEventId.APP_ENTER_BACKGROUD) | ||
| 102 | } | 108 | } |
| 103 | } | 109 | } |
| @@ -34,6 +34,10 @@ | @@ -34,6 +34,10 @@ | ||
| 34 | ] | 34 | ] |
| 35 | } | 35 | } |
| 36 | ], | 36 | ], |
| 37 | + "metadata": [{ | ||
| 38 | + "name": "client_id", | ||
| 39 | + "value": "220837707901830144" | ||
| 40 | + }], | ||
| 37 | "requestPermissions": [ | 41 | "requestPermissions": [ |
| 38 | { | 42 | { |
| 39 | "name": "ohos.permission.CAMERA", | 43 | "name": "ohos.permission.CAMERA", |
| @@ -88,6 +92,6 @@ | @@ -88,6 +92,6 @@ | ||
| 88 | { | 92 | { |
| 89 | "name": "ohos.permission.INTERNET" | 93 | "name": "ohos.permission.INTERNET" |
| 90 | } | 94 | } |
| 91 | - ], | 95 | + ] |
| 92 | } | 96 | } |
| 93 | } | 97 | } |
-
Please register or login to post a comment