Showing
41 changed files
with
655 additions
and
241 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) { |
| @@ -157,7 +157,7 @@ export class ProcessUtils { | @@ -157,7 +157,7 @@ export class ProcessUtils { | ||
| 157 | * 图集详情页 | 157 | * 图集详情页 |
| 158 | * @param content | 158 | * @param content |
| 159 | * */ | 159 | * */ |
| 160 | - public static gotoMultiPictureListPage(photoList: PhotoListBean[], swiperIndex?:number) { | 160 | + public static gotoMultiPictureListPage(photoList: PhotoListBean[], swiperIndex?: number) { |
| 161 | let taskAction: Action = { | 161 | let taskAction: Action = { |
| 162 | type: 'JUMP_DETAIL_PAGE', | 162 | type: 'JUMP_DETAIL_PAGE', |
| 163 | params: { | 163 | params: { |
| @@ -187,8 +187,14 @@ export class ProcessUtils { | @@ -187,8 +187,14 @@ export class ProcessUtils { | ||
| 187 | let taskAction: Action = { | 187 | let taskAction: Action = { |
| 188 | type: 'JUMP_INNER_NEW_PAGE', | 188 | type: 'JUMP_INNER_NEW_PAGE', |
| 189 | params: { | 189 | params: { |
| 190 | + contentID: content?.objectId, | ||
| 190 | url: content.linkUrl, | 191 | url: content.linkUrl, |
| 191 | pageID: 'SPACIAL_TOPIC_PAGE', | 192 | pageID: 'SPACIAL_TOPIC_PAGE', |
| 193 | + extra: { | ||
| 194 | + relType: content?.relType, | ||
| 195 | + relId: content?.relId, | ||
| 196 | + channelId: content?.channelId, | ||
| 197 | + } as ExtraDTO | ||
| 192 | } as Params, | 198 | } as Params, |
| 193 | }; | 199 | }; |
| 194 | WDRouterRule.jumpWithAction(taskAction) | 200 | WDRouterRule.jumpWithAction(taskAction) |
| @@ -423,11 +429,10 @@ export class ProcessUtils { | @@ -423,11 +429,10 @@ export class ProcessUtils { | ||
| 423 | 429 | ||
| 424 | /** | 430 | /** |
| 425 | * 跳转人民号主页 | 431 | * 跳转人民号主页 |
| 426 | - *@params creatorId 创作者id | 432 | + * @params creatorId 创作者id |
| 427 | */ | 433 | */ |
| 428 | public static gotoPeopleShipHomePage(creatorId: string) { | 434 | public static gotoPeopleShipHomePage(creatorId: string) { |
| 429 | - let params = {'creatorId': creatorId} as Record<string, string>; | 435 | + let params = { 'creatorId': creatorId } as Record<string, string>; |
| 430 | WDRouterRule.jumpWithPage(WDRouterPage.peopleShipHomePage, params) | 436 | WDRouterRule.jumpWithPage(WDRouterPage.peopleShipHomePage, params) |
| 431 | } | 437 | } |
| 432 | - | ||
| 433 | } | 438 | } |
| 1 | -import HashMap from '@ohos.util.HashMap'; | ||
| 2 | import { Callback } from 'wdJsBridge'; | 1 | import { Callback } from 'wdJsBridge'; |
| 3 | import { Message, IImgListData } from 'wdJsBridge/src/main/ets/bean/Message'; | 2 | import { Message, IImgListData } from 'wdJsBridge/src/main/ets/bean/Message'; |
| 4 | -import { Logger } from 'wdKit'; | 3 | +import { Logger, SPHelper } from 'wdKit'; |
| 5 | import { H5CallNativeType } from './H5CallNativeType'; | 4 | import { H5CallNativeType } from './H5CallNativeType'; |
| 6 | import { H5OperateType } from './H5OperateType'; | 5 | import { H5OperateType } from './H5OperateType'; |
| 7 | -import { ContentConstants } from 'wdConstant'; | 6 | +import { ContentConstants, SpConstants } from 'wdConstant'; |
| 8 | import { ProcessUtils } from 'wdRouter'; | 7 | import { ProcessUtils } from 'wdRouter'; |
| 9 | import router from '@ohos.router'; | 8 | import router from '@ohos.router'; |
| 10 | import Url from '@ohos.url' | 9 | import Url from '@ohos.url' |
| 11 | import { ContentDTO, PhotoListBean } from 'wdBean'; | 10 | import { ContentDTO, PhotoListBean } from 'wdBean'; |
| 12 | -import { ResponseDTO, WDHttp, HttpUrlUtils } from 'wdNetwork'; | 11 | +import { handleJsCallAppService } from './JsCallAppService' |
| 13 | 12 | ||
| 14 | const TAG = 'JsBridgeBiz' | 13 | const TAG = 'JsBridgeBiz' |
| 15 | 14 | ||
| @@ -20,6 +19,19 @@ class AppInfo { | @@ -20,6 +19,19 @@ class AppInfo { | ||
| 20 | // TODO 完善 | 19 | // TODO 完善 |
| 21 | } | 20 | } |
| 22 | 21 | ||
| 22 | +class AppLoginAuthInfo { | ||
| 23 | + "X-Ca-Stage": string = '' | ||
| 24 | + userType: number = SPHelper.default.getSync(SpConstants.USER_Type, '') as number | ||
| 25 | + userName: string = SPHelper.default.getSync(SpConstants.USER_NAME, '') as string | ||
| 26 | + userID: string = SPHelper.default.getSync(SpConstants.USER_ID, '') as string | ||
| 27 | + "RMRB-X-TOKEN": string = SPHelper.default.getSync(SpConstants.USER_TEMP_TOKEN, '') as string | ||
| 28 | + phoneNumber: string = SPHelper.default.getSync(SpConstants.USER_PHONE, '') as string | ||
| 29 | + nickName: string = '' | ||
| 30 | + isLogined: string = SPHelper.default.getSync(SpConstants.USER_STATUS, '') as string | ||
| 31 | + creatorID: string = SPHelper.default.getSync(SpConstants.USER_CREATOR_ID, '') as string | ||
| 32 | + Authorization: string = '' | ||
| 33 | +} | ||
| 34 | + | ||
| 23 | /** | 35 | /** |
| 24 | * h5调用native代码 | 36 | * h5调用native代码 |
| 25 | * @param data | 37 | * @param data |
| @@ -39,7 +51,7 @@ export function performJSCallNative(data: Message, call: Callback) { | @@ -39,7 +51,7 @@ export function performJSCallNative(data: Message, call: Callback) { | ||
| 39 | case H5CallNativeType.jsCall_getArticleDetailBussinessData: | 51 | case H5CallNativeType.jsCall_getArticleDetailBussinessData: |
| 40 | break; | 52 | break; |
| 41 | case H5CallNativeType.jsCall_callAppService: | 53 | case H5CallNativeType.jsCall_callAppService: |
| 42 | - handleJsCallCallAppService(data, (res: string) => { | 54 | + handleJsCallAppService(data, (res: string) => { |
| 43 | call(res) | 55 | call(res) |
| 44 | }) | 56 | }) |
| 45 | break; | 57 | break; |
| @@ -49,6 +61,9 @@ export function performJSCallNative(data: Message, call: Callback) { | @@ -49,6 +61,9 @@ export function performJSCallNative(data: Message, call: Callback) { | ||
| 49 | case H5CallNativeType.jsCall_appInnerLinkMethod: | 61 | case H5CallNativeType.jsCall_appInnerLinkMethod: |
| 50 | handleJsCallAppInnerLinkMethod(data) | 62 | handleJsCallAppInnerLinkMethod(data) |
| 51 | break; | 63 | break; |
| 64 | + case H5CallNativeType.jsCall_getAppLoginAuthInfo: | ||
| 65 | + call(handleJsCallGetAppLoginAuthInfo()) | ||
| 66 | + break; | ||
| 52 | default: | 67 | default: |
| 53 | break; | 68 | break; |
| 54 | } | 69 | } |
| @@ -64,21 +79,6 @@ function handleJsCallCurrentPageOperate(data: Message) { | @@ -64,21 +79,6 @@ function handleJsCallCurrentPageOperate(data: Message) { | ||
| 64 | } | 79 | } |
| 65 | } | 80 | } |
| 66 | 81 | ||
| 67 | -function handleJsCallCallAppService(data: Message, callback: (res: string) => void) { | ||
| 68 | - let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 69 | - let url: string = HttpUrlUtils.getHost() + data?.data?.url | ||
| 70 | - if (data?.data?.method === 'get') { | ||
| 71 | - WDHttp.get<ResponseDTO<string>>(url, headers).then((res: ResponseDTO<string>) => { | ||
| 72 | - callback(JSON.stringify(res)) | ||
| 73 | - }) | ||
| 74 | - } | ||
| 75 | - if (data?.data?.method === 'post') { | ||
| 76 | - WDHttp.post<ResponseDTO<string>>(url, data?.data?.parameters, headers).then(res => { | ||
| 77 | - callback(JSON.stringify(res)) | ||
| 78 | - }) | ||
| 79 | - } | ||
| 80 | -} | ||
| 81 | - | ||
| 82 | /** | 82 | /** |
| 83 | * 获取App公共信息 | 83 | * 获取App公共信息 |
| 84 | */ | 84 | */ |
| @@ -90,12 +90,11 @@ function getAppPublicInfo(): string { | @@ -90,12 +90,11 @@ function getAppPublicInfo(): string { | ||
| 90 | info.networkStatus = 1 | 90 | info.networkStatus = 1 |
| 91 | let result = JSON.stringify(info) | 91 | let result = JSON.stringify(info) |
| 92 | Logger.debug(TAG, 'getAppPublicInfo: ' + JSON.stringify(info)) | 92 | Logger.debug(TAG, 'getAppPublicInfo: ' + JSON.stringify(info)) |
| 93 | - | ||
| 94 | return result; | 93 | return result; |
| 95 | } | 94 | } |
| 96 | 95 | ||
| 97 | function handleJsCallReceiveH5Data(data: Message) { | 96 | function handleJsCallReceiveH5Data(data: Message) { |
| 98 | - switch (data?.data?.dataSource) { | 97 | + switch (String(data?.data?.dataSource)) { |
| 99 | case '3': | 98 | case '3': |
| 100 | let imgListData: IImgListData = JSON.parse(data?.data?.imgListData || "{}") | 99 | let imgListData: IImgListData = JSON.parse(data?.data?.imgListData || "{}") |
| 101 | let imgArr = imgListData?.imgArr || [] | 100 | let imgArr = imgListData?.imgArr || [] |
| @@ -110,7 +109,7 @@ function handleJsCallReceiveH5Data(data: Message) { | @@ -110,7 +109,7 @@ function handleJsCallReceiveH5Data(data: Message) { | ||
| 110 | } | 109 | } |
| 111 | return photo | 110 | return photo |
| 112 | }) | 111 | }) |
| 113 | - ProcessUtils.gotoMultiPictureListPage(photoList,swiperIndex) | 112 | + ProcessUtils.gotoMultiPictureListPage(photoList, swiperIndex) |
| 114 | } | 113 | } |
| 115 | break; | 114 | break; |
| 116 | case '5': | 115 | case '5': |
| @@ -183,3 +182,9 @@ function handleJsCallAppInnerLinkMethod(data: Message) { | @@ -183,3 +182,9 @@ function handleJsCallAppInnerLinkMethod(data: Message) { | ||
| 183 | } | 182 | } |
| 184 | } | 183 | } |
| 185 | } | 184 | } |
| 185 | + | ||
| 186 | +function handleJsCallGetAppLoginAuthInfo() { | ||
| 187 | + let appLoginAuthInfo = new AppLoginAuthInfo() | ||
| 188 | + let result = JSON.stringify(appLoginAuthInfo) | ||
| 189 | + return result; | ||
| 190 | +} |
| 1 | +import HashMap from '@ohos.util.HashMap'; | ||
| 2 | +import { Message } from 'wdJsBridge/src/main/ets/bean/Message'; | ||
| 3 | +import { H5ReceiveDataJsonBean, postBatchAttentionStatusResult } from 'wdBean'; | ||
| 4 | +import { ResponseDTO, WDHttp, HttpUrlUtils } from 'wdNetwork'; | ||
| 5 | + | ||
| 6 | +const TAG = 'JsCallAppService' | ||
| 7 | + | ||
| 8 | + | ||
| 9 | +export function handleJsCallAppService(data: Message, callback: (res: string) => void) { | ||
| 10 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 11 | + let url: string = HttpUrlUtils.getHost() + data?.data?.url | ||
| 12 | + | ||
| 13 | + let responseMap: ResponseDTO<postBatchAttentionStatusResult> = {} as ResponseDTO<postBatchAttentionStatusResult> | ||
| 14 | + | ||
| 15 | + let h5ReceiveDataJson: H5ReceiveDataJsonBean<ResponseDTO<postBatchAttentionStatusResult>> = { | ||
| 16 | + netError: '0', | ||
| 17 | + responseMap | ||
| 18 | + } as H5ReceiveDataJsonBean<ResponseDTO<postBatchAttentionStatusResult>> | ||
| 19 | + | ||
| 20 | + // if (data?.data?.method === 'get') { | ||
| 21 | + // WDHttp.get<ResponseDTO<postBatchAttentionStatusResult>>(url, headers).then((res: ResponseDTO<postBatchAttentionStatusResult>) => { | ||
| 22 | + // callback(JSON.stringify(res)) | ||
| 23 | + // }) | ||
| 24 | + // } | ||
| 25 | + if (data?.data?.method === 'post' && data?.data?.url === '/api/rmrb-interact/interact/zh/c/batchAttention/status') { | ||
| 26 | + WDHttp.post<ResponseDTO<postBatchAttentionStatusResult>>(url, data?.data?.parameters, headers).then((res: ResponseDTO<postBatchAttentionStatusResult>) => { | ||
| 27 | + h5ReceiveDataJson.responseMap = res | ||
| 28 | + callback(JSON.stringify(h5ReceiveDataJson)) | ||
| 29 | + }) | ||
| 30 | + } | ||
| 31 | +} |
| 1 | export interface H5ReceiveDataExtraBean { | 1 | export interface H5ReceiveDataExtraBean { |
| 2 | creatorId: string; | 2 | creatorId: string; |
| 3 | + cnsTraceId: string; | ||
| 3 | isLogin: string; | 4 | isLogin: string; |
| 5 | + loadImageOnlyWifiSwitch: string; | ||
| 4 | networkStatus: number; | 6 | networkStatus: number; |
| 5 | - loadImageOnlyWifiSwitch: string | 7 | + darkMode: string; |
| 8 | + fontSizes: string; | ||
| 6 | } | 9 | } |
| 1 | import { ResponseBean } from './ResponseBean'; | 1 | import { ResponseBean } from './ResponseBean'; |
| 2 | 2 | ||
| 3 | -export interface H5ReceiveDataJsonBean { | ||
| 4 | - contentId: string; | ||
| 5 | - contentType: string; | ||
| 6 | - topicId: string; | ||
| 7 | - channelId: string; | ||
| 8 | - compId: string; | ||
| 9 | - sourcePage: string; | 3 | +export interface H5ReceiveDataJsonBean<T = ResponseBean> { |
| 4 | + contentId?: string; | ||
| 5 | + contentType?: string; | ||
| 6 | + topicId?: string; | ||
| 7 | + channelId?: string; | ||
| 8 | + compId?: string; | ||
| 9 | + sourcePage?: string; | ||
| 10 | netError: string; | 10 | netError: string; |
| 11 | - responseMap: ResponseBean; | 11 | + responseMap: T; |
| 12 | 12 | ||
| 13 | } | 13 | } |
| 1 | import { ContentDetailDTO } from '../detail/ContentDetailDTO'; | 1 | import { ContentDetailDTO } from '../detail/ContentDetailDTO'; |
| 2 | 2 | ||
| 3 | -export interface ResponseBean{ | ||
| 4 | - success:boolean; | 3 | +export interface ResponseBean<T = ContentDetailDTO[]> { |
| 4 | + success: boolean; | ||
| 5 | 5 | ||
| 6 | // 服务请求响应值/微服务响应状态码” | 6 | // 服务请求响应值/微服务响应状态码” |
| 7 | code: number; | 7 | code: number; |
| @@ -10,8 +10,7 @@ export interface ResponseBean{ | @@ -10,8 +10,7 @@ export interface ResponseBean{ | ||
| 10 | message: string; | 10 | message: string; |
| 11 | 11 | ||
| 12 | // 响应结果 | 12 | // 响应结果 |
| 13 | - data:ContentDetailDTO[]; | ||
| 14 | - | 13 | + data: T |
| 15 | // 请求响应时间戳(unix格式) | 14 | // 请求响应时间戳(unix格式) |
| 16 | timestamp?: number; | 15 | timestamp?: number; |
| 17 | } | 16 | } |
| @@ -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 | /** |
| @@ -13,7 +13,6 @@ import { | @@ -13,7 +13,6 @@ import { | ||
| 13 | import DetailViewModel from '../viewmodel/DetailViewModel'; | 13 | import DetailViewModel from '../viewmodel/DetailViewModel'; |
| 14 | import { ImageAndTextWebComponent } from './ImageAndTextWebComponent'; | 14 | import { ImageAndTextWebComponent } from './ImageAndTextWebComponent'; |
| 15 | import { OperRowListView } from './view/OperRowListView'; | 15 | import { OperRowListView } from './view/OperRowListView'; |
| 16 | -import router from '@ohos.router'; | ||
| 17 | import { RecommendList } from '../components/view/RecommendList' | 16 | import { RecommendList } from '../components/view/RecommendList' |
| 18 | import { CommonConstants } from 'wdConstant'; | 17 | import { CommonConstants } from 'wdConstant'; |
| 19 | import { HttpUrlUtils } from 'wdNetwork/Index'; | 18 | import { HttpUrlUtils } from 'wdNetwork/Index'; |
| @@ -21,10 +20,11 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | @@ -21,10 +20,11 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | ||
| 21 | import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel'; | 20 | import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel'; |
| 22 | import { PageRepository } from '../repository/PageRepository'; | 21 | import { PageRepository } from '../repository/PageRepository'; |
| 23 | import { detailedSkeleton } from './skeleton/detailSkeleton'; | 22 | import { detailedSkeleton } from './skeleton/detailSkeleton'; |
| 23 | +import { CommentComponent } from '../components/comment/view/CommentComponent' | ||
| 24 | 24 | ||
| 25 | const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm'; | 25 | const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm'; |
| 26 | 26 | ||
| 27 | -const TAG = 'ImageAndTextPageComponent' | 27 | +const TAG: string = 'ImageAndTextPageComponent' |
| 28 | 28 | ||
| 29 | @Component | 29 | @Component |
| 30 | export struct ImageAndTextPageComponent { | 30 | export struct ImageAndTextPageComponent { |
| @@ -75,9 +75,55 @@ export struct ImageAndTextPageComponent { | @@ -75,9 +75,55 @@ export struct ImageAndTextPageComponent { | ||
| 75 | isPageEnd: $isPageEnd | 75 | isPageEnd: $isPageEnd |
| 76 | }) | 76 | }) |
| 77 | Column() { | 77 | Column() { |
| 78 | + // 点赞 | ||
| 79 | + if (this.contentDetailData[0]?.openLikes) { | ||
| 80 | + Row() { | ||
| 81 | + Row() { | ||
| 82 | + if (this.newsStatusOfUser?.likeStatus === '1') { | ||
| 83 | + Image(this.contentDetailData[0]?.likesStyle === 1 ? $r('app.media.ic_like_check') : (this.contentDetailData[0]?.likesStyle === 2 ? $r('app.media.icon_prayer_active') : $r('app.media.icon_candle_active'))) | ||
| 84 | + .width(24) | ||
| 85 | + .height(24) | ||
| 86 | + .margin({ right: 5 }) | ||
| 87 | + } else { | ||
| 88 | + Image(this.contentDetailData[0]?.likesStyle === 1 ? $r('app.media.icon_like') : (this.contentDetailData[0]?.likesStyle === 2 ? $r('app.media.icon_prayer') : $r('app.media.icon_candle'))) | ||
| 89 | + .width(24) | ||
| 90 | + .height(24) | ||
| 91 | + .margin({ right: 5 }) | ||
| 92 | + } | ||
| 93 | + if(this.interactData?.likeNum !== '0'){ | ||
| 94 | + Text(`${this.interactData?.likeNum}`) | ||
| 95 | + .fontSize(16) | ||
| 96 | + .fontColor(this.newsStatusOfUser?.likeStatus === '1' ? '#ED2800' : '#999999') | ||
| 97 | + .fontWeight(500) | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | + .width(140) | ||
| 101 | + .height(36) | ||
| 102 | + .justifyContent(FlexAlign.Center) | ||
| 103 | + .alignItems(VerticalAlign.Center) | ||
| 104 | + .borderRadius(20) | ||
| 105 | + .border({ | ||
| 106 | + width: 1, | ||
| 107 | + color: '#EDEDED', | ||
| 108 | + }) | ||
| 109 | + .onClick(() => { | ||
| 110 | + this.toggleLikeStatus() | ||
| 111 | + }) | ||
| 112 | + | ||
| 113 | + }.width(CommonConstants.FULL_WIDTH).height(80) | ||
| 114 | + .justifyContent(FlexAlign.Center) | ||
| 115 | + | ||
| 116 | + Divider().strokeWidth(6).color('#f5f5f5') | ||
| 117 | + } | ||
| 78 | if (this.recommendList.length > 0) { | 118 | if (this.recommendList.length > 0) { |
| 79 | RecommendList({ recommendList: this.recommendList }) | 119 | RecommendList({ recommendList: this.recommendList }) |
| 80 | } | 120 | } |
| 121 | + // 评论 | ||
| 122 | + if(this.contentDetailData[0]?.openComment){ | ||
| 123 | + // CommentComponent({ | ||
| 124 | + // | ||
| 125 | + // }) | ||
| 126 | + } | ||
| 81 | } | 127 | } |
| 82 | } | 128 | } |
| 83 | 129 | ||
| @@ -95,42 +141,6 @@ export struct ImageAndTextPageComponent { | @@ -95,42 +141,6 @@ export struct ImageAndTextPageComponent { | ||
| 95 | if (this.contentDetailData?.length) { | 141 | if (this.contentDetailData?.length) { |
| 96 | OperRowListView({contentDetailData: this.contentDetailData[0]}) | 142 | OperRowListView({contentDetailData: this.contentDetailData[0]}) |
| 97 | } | 143 | } |
| 98 | - /* Row() { | ||
| 99 | - Image($r('app.media.icon_arrow_left')) | ||
| 100 | - .width(24) | ||
| 101 | - .height(24) | ||
| 102 | - .onClick((event: ClickEvent) => { | ||
| 103 | - router.back() | ||
| 104 | - }) | ||
| 105 | - | ||
| 106 | - Row() { | ||
| 107 | - Image($r('app.media.icon_comment')) | ||
| 108 | - .width(24) | ||
| 109 | - .height(24) | ||
| 110 | - .margin({ right: 24 }) | ||
| 111 | - .id('comment') | ||
| 112 | - | ||
| 113 | - Image($r('app.media.icon_star')) | ||
| 114 | - .width(24) | ||
| 115 | - .height(24) | ||
| 116 | - .margin({ right: 24 }) | ||
| 117 | - | ||
| 118 | - Image($r('app.media.icon_listen')) | ||
| 119 | - .width(24) | ||
| 120 | - .height(24) | ||
| 121 | - .margin({ right: 24 }) | ||
| 122 | - | ||
| 123 | - Image($r('app.media.icon_forward')) | ||
| 124 | - .width(24) | ||
| 125 | - .height(24) | ||
| 126 | - | ||
| 127 | - } | ||
| 128 | - } | ||
| 129 | - .width(CommonConstants.FULL_WIDTH) | ||
| 130 | - .height(56) | ||
| 131 | - .padding({ left: 15, right: 15, bottom: 50, top: 20 }) | ||
| 132 | - .justifyContent(FlexAlign.SpaceBetween) | ||
| 133 | - .backgroundColor(Color.White)*/ | ||
| 134 | } | 144 | } |
| 135 | 145 | ||
| 136 | } | 146 | } |
| @@ -12,6 +12,7 @@ import { WdWebLocalComponent } from 'wdWebComponent'; | @@ -12,6 +12,7 @@ import { WdWebLocalComponent } from 'wdWebComponent'; | ||
| 12 | import { NativeCallH5Type } from 'wdWebComponent/src/main/ets/pages/NativeCallH5Type'; | 12 | import { NativeCallH5Type } from 'wdWebComponent/src/main/ets/pages/NativeCallH5Type'; |
| 13 | import { BridgeWebViewControl } from 'wdJsBridge/Index'; | 13 | import { BridgeWebViewControl } from 'wdJsBridge/Index'; |
| 14 | 14 | ||
| 15 | +const TAG: string = 'ImageAndTextWebComponent' | ||
| 15 | @Component | 16 | @Component |
| 16 | export struct ImageAndTextWebComponent { | 17 | export struct ImageAndTextWebComponent { |
| 17 | action: Action = {} as Action | 18 | action: Action = {} as Action |
| @@ -60,9 +61,12 @@ export struct ImageAndTextWebComponent { | @@ -60,9 +61,12 @@ export struct ImageAndTextWebComponent { | ||
| 60 | // TODO 对接user信息、登录情况 | 61 | // TODO 对接user信息、登录情况 |
| 61 | let h5ReceiveDataExtraBean: H5ReceiveDataExtraBean = { | 62 | let h5ReceiveDataExtraBean: H5ReceiveDataExtraBean = { |
| 62 | creatorId: creatorId, | 63 | creatorId: creatorId, |
| 64 | + cnsTraceId: '', | ||
| 63 | isLogin: isLogin, | 65 | isLogin: isLogin, |
| 64 | - networkStatus: Number(NetworkUtil.isNetConnected()), | ||
| 65 | loadImageOnlyWifiSwitch: '2', | 66 | loadImageOnlyWifiSwitch: '2', |
| 67 | + networkStatus: Number(NetworkUtil.isNetConnected()), | ||
| 68 | + darkMode: 'light', | ||
| 69 | + fontSizes: 'normalsize' | ||
| 66 | 70 | ||
| 67 | } as H5ReceiveDataExtraBean | 71 | } as H5ReceiveDataExtraBean |
| 68 | let h5ReceiveDataJsonBean: H5ReceiveDataJsonBean = { | 72 | let h5ReceiveDataJsonBean: H5ReceiveDataJsonBean = { |
| @@ -83,7 +87,6 @@ export struct ImageAndTextWebComponent { | @@ -83,7 +87,6 @@ export struct ImageAndTextWebComponent { | ||
| 83 | this.h5ReceiveAppData.dataExt = h5ReceiveDataExtraBean | 87 | this.h5ReceiveAppData.dataExt = h5ReceiveDataExtraBean |
| 84 | this.dataPrepared = true | 88 | this.dataPrepared = true |
| 85 | this.trySendData2H5() | 89 | this.trySendData2H5() |
| 86 | - | ||
| 87 | } | 90 | } |
| 88 | 91 | ||
| 89 | } | 92 | } |
| 1 | -import { Action, H5ReceiveDetailBean } from 'wdBean'; | 1 | +import { Action, H5ReceiveDetailBean, ContentDetailDTO } from 'wdBean'; |
| 2 | import { WdWebComponent } from 'wdWebComponent'; | 2 | import { WdWebComponent } from 'wdWebComponent'; |
| 3 | import router from '@ohos.router'; | 3 | import router from '@ohos.router'; |
| 4 | import { CommonConstants } from 'wdConstant' | 4 | import { CommonConstants } from 'wdConstant' |
| 5 | import { BridgeWebViewControl } from 'wdJsBridge/Index'; | 5 | import { BridgeWebViewControl } from 'wdJsBridge/Index'; |
| 6 | import { detailedSkeleton } from './skeleton/detailSkeleton' | 6 | import { detailedSkeleton } from './skeleton/detailSkeleton' |
| 7 | import { NativeCallH5Type } from 'wdWebComponent/src/main/ets/pages/NativeCallH5Type'; | 7 | import { NativeCallH5Type } from 'wdWebComponent/src/main/ets/pages/NativeCallH5Type'; |
| 8 | -const TAG = 'SpacialTopicPageComponent' | 8 | +import { OperRowListView } from './view/OperRowListView'; |
| 9 | +import DetailViewModel from '../viewmodel/DetailViewModel'; | ||
| 10 | + | ||
| 11 | +const TAG: string = 'SpacialTopicPageComponent' | ||
| 9 | 12 | ||
| 10 | @Component | 13 | @Component |
| 11 | export struct SpacialTopicPageComponent { | 14 | export struct SpacialTopicPageComponent { |
| @@ -14,6 +17,7 @@ export struct SpacialTopicPageComponent { | @@ -14,6 +17,7 @@ export struct SpacialTopicPageComponent { | ||
| 14 | action: Action = {} as Action | 17 | action: Action = {} as Action |
| 15 | @State webUrl: string = ''; | 18 | @State webUrl: string = ''; |
| 16 | @State isPageEnd: boolean = false | 19 | @State isPageEnd: boolean = false |
| 20 | + @State contentDetailData: ContentDetailDTO [] = [] as ContentDetailDTO [] | ||
| 17 | private h5ReceiveAppData: H5ReceiveDetailBean = { dataSource: '2' } as H5ReceiveDetailBean | 21 | private h5ReceiveAppData: H5ReceiveDetailBean = { dataSource: '2' } as H5ReceiveDetailBean |
| 18 | private webPrepared = false; | 22 | private webPrepared = false; |
| 19 | private dataPrepared = false; | 23 | private dataPrepared = false; |
| @@ -37,11 +41,33 @@ export struct SpacialTopicPageComponent { | @@ -37,11 +41,33 @@ export struct SpacialTopicPageComponent { | ||
| 37 | }) | 41 | }) |
| 38 | } | 42 | } |
| 39 | 43 | ||
| 44 | + private async getDetail() { | ||
| 45 | + let contentId: string = '' | ||
| 46 | + let relId: string = '' | ||
| 47 | + let relType: string = '' | ||
| 48 | + if (this.action && this.action.params) { | ||
| 49 | + if (this.action.params.contentID) { | ||
| 50 | + contentId = this.action.params.contentID; | ||
| 51 | + } | ||
| 52 | + if (this.action && this.action.params && this.action.params.extra) { | ||
| 53 | + if (this.action.params.extra.relId) { | ||
| 54 | + relId = this.action.params.extra.relId; | ||
| 55 | + } | ||
| 56 | + if (this.action.params.extra.relType) { | ||
| 57 | + relType = this.action.params.extra.relType | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + } | ||
| 61 | + let detailBeans = await DetailViewModel.getDetailPageData(relId, contentId, relType) | ||
| 62 | + if (detailBeans && detailBeans.length > 0) { | ||
| 63 | + this.contentDetailData = detailBeans; | ||
| 64 | + this.trySendData2H5() | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | + | ||
| 40 | build() { | 69 | build() { |
| 41 | Column() { | 70 | Column() { |
| 42 | - if (!this.isPageEnd) { | ||
| 43 | - detailedSkeleton() | ||
| 44 | - } | ||
| 45 | Stack({ alignContent: Alignment.Bottom }) { | 71 | Stack({ alignContent: Alignment.Bottom }) { |
| 46 | Column() { | 72 | Column() { |
| 47 | WdWebComponent({ | 73 | WdWebComponent({ |
| @@ -52,62 +78,23 @@ export struct SpacialTopicPageComponent { | @@ -52,62 +78,23 @@ export struct SpacialTopicPageComponent { | ||
| 52 | isPageEnd: $isPageEnd | 78 | isPageEnd: $isPageEnd |
| 53 | }) | 79 | }) |
| 54 | } | 80 | } |
| 55 | - .padding({ bottom: 56 }) | ||
| 56 | .width(CommonConstants.FULL_WIDTH) | 81 | .width(CommonConstants.FULL_WIDTH) |
| 57 | .height(CommonConstants.FULL_HEIGHT) | 82 | .height(CommonConstants.FULL_HEIGHT) |
| 83 | + .padding({ bottom: 126 }) | ||
| 58 | 84 | ||
| 59 | - //底部交互区 | ||
| 60 | - Row() { | ||
| 61 | - Image($r('app.media.icon_arrow_left')) | ||
| 62 | - .width(24) | ||
| 63 | - .height(24) | ||
| 64 | - .onClick((event: ClickEvent) => { | ||
| 65 | - router.back() | ||
| 66 | - }) | ||
| 67 | - | ||
| 68 | - Row() { | ||
| 69 | - Image($r('app.media.icon_comment')) | ||
| 70 | - .width(24) | ||
| 71 | - .height(24) | ||
| 72 | - .margin({ right: 24 }) | ||
| 73 | - .id('comment') | ||
| 74 | - | ||
| 75 | - Image($r('app.media.icon_star')) | ||
| 76 | - .width(24) | ||
| 77 | - .height(24) | ||
| 78 | - .margin({ right: 24 }) | ||
| 79 | - | ||
| 80 | - Image($r('app.media.icon_listen')) | ||
| 81 | - .width(24) | ||
| 82 | - .height(24) | ||
| 83 | - .margin({ right: 24 }) | ||
| 84 | - | ||
| 85 | - Image($r('app.media.icon_forward')) | ||
| 86 | - .width(24) | ||
| 87 | - .height(24) | ||
| 88 | - | ||
| 89 | - } | 85 | + if (!this.isPageEnd) { |
| 86 | + detailedSkeleton() | ||
| 90 | } | 87 | } |
| 91 | - .width(CommonConstants.FULL_WIDTH) | ||
| 92 | - .height(56) | ||
| 93 | - .padding({ left: 15, right: 15, bottom: 20, top: 20 }) | ||
| 94 | - .justifyContent(FlexAlign.SpaceBetween) | ||
| 95 | - .backgroundColor(Color.White) | ||
| 96 | - | 88 | + //底部交互区 |
| 89 | + OperRowListView({ contentDetailData: this.contentDetailData[0] }) | ||
| 97 | } | 90 | } |
| 98 | }.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT) | 91 | }.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT) |
| 99 | - .backgroundColor(Color.White) | ||
| 100 | } | 92 | } |
| 101 | 93 | ||
| 102 | aboutToAppear() { | 94 | aboutToAppear() { |
| 103 | - let action: Action = router.getParams() as Action | ||
| 104 | - if (action) { | ||
| 105 | - this.webUrl = action.params?.url || '' | 95 | + if (this.action) { |
| 96 | + this.webUrl = this.action.params?.url || '' | ||
| 106 | } | 97 | } |
| 107 | - this.trySendData2H5() | ||
| 108 | - } | ||
| 109 | - | ||
| 110 | - aboutToDisappear() { | ||
| 111 | - | 98 | + this.getDetail() |
| 112 | } | 99 | } |
| 113 | } | 100 | } |
| 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 | 4 | ||
| 8 | -const TAG: string = 'Card2Component'; | 5 | +import measure from '@ohos.measure'; |
| 6 | +import { DisplayUtils } from 'wdKit/Index'; | ||
| 7 | + | ||
| 8 | +const TAG: string = 'CardAdvSmallImageComponent'; | ||
| 9 | 9 | ||
| 10 | /** | 10 | /** |
| 11 | * @Description: 广告---小图卡 | 11 | * @Description: 广告---小图卡 |
| @@ -17,30 +17,89 @@ const TAG: string = 'Card2Component'; | @@ -17,30 +17,89 @@ const TAG: string = 'Card2Component'; | ||
| 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 | + }) | ||
| 42 | } | 83 | } |
| 43 | - .width(CommonConstants.FULL_WIDTH) | 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 | + }) | ||
| 100 | + } | ||
| 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() { |
| @@ -11,6 +11,7 @@ const MY_CHANNEL_TIP2: string = '拖动调整频道顺序' | @@ -11,6 +11,7 @@ const MY_CHANNEL_TIP2: string = '拖动调整频道顺序' | ||
| 11 | const MORE_CHANNEL: string = '更多频道' | 11 | const MORE_CHANNEL: string = '更多频道' |
| 12 | const LOCAL_CHANNEL: string = '地方频道' | 12 | const LOCAL_CHANNEL: string = '地方频道' |
| 13 | 13 | ||
| 14 | +const TAG: string = 'ChannelSubscriptionLayout' | ||
| 14 | 15 | ||
| 15 | @CustomDialog | 16 | @CustomDialog |
| 16 | struct ChannelDialog { | 17 | struct ChannelDialog { |
335 Bytes
| @@ -107,7 +107,7 @@ export struct DetailPlayVLivePage { | @@ -107,7 +107,7 @@ export struct DetailPlayVLivePage { | ||
| 107 | (data) => { | 107 | (data) => { |
| 108 | if (data.length > 0) { | 108 | if (data.length > 0) { |
| 109 | this.liveDetailsBean = data[0] | 109 | this.liveDetailsBean = data[0] |
| 110 | - this.liveState = 'end' // this.liveDetailsBean.liveInfo?.liveState //直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停 | 110 | + this.liveState = this.liveDetailsBean.liveInfo?.liveState //直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停 |
| 111 | if (this.liveDetailsBean.fullColumnImgUrls && this.liveDetailsBean.fullColumnImgUrls.length > 0) { | 111 | if (this.liveDetailsBean.fullColumnImgUrls && this.liveDetailsBean.fullColumnImgUrls.length > 0) { |
| 112 | this.imgUrl = this.liveDetailsBean.fullColumnImgUrls[0].url | 112 | this.imgUrl = this.liveDetailsBean.fullColumnImgUrls[0].url |
| 113 | } | 113 | } |
| 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 | } |
| 1 | import { Action } from 'wdBean'; | 1 | import { Action } from 'wdBean'; |
| 2 | import { SpacialTopicPageComponent } from 'wdComponent' | 2 | import { SpacialTopicPageComponent } from 'wdComponent' |
| 3 | +import { CommonConstants } from 'wdConstant' | ||
| 3 | import { Logger } from 'wdKit' | 4 | import { Logger } from 'wdKit' |
| 4 | import router from '@ohos.router'; | 5 | import router from '@ohos.router'; |
| 5 | 6 | ||
| 6 | -const TAG = 'SpacialPage'; | 7 | +const TAG = 'SpacialTopicPage'; |
| 7 | 8 | ||
| 8 | @Entry | 9 | @Entry |
| 9 | @Component | 10 | @Component |
| @@ -12,11 +13,11 @@ struct SpacialTopicPage { | @@ -12,11 +13,11 @@ struct SpacialTopicPage { | ||
| 12 | 13 | ||
| 13 | build() { | 14 | build() { |
| 14 | Column() { | 15 | Column() { |
| 15 | - SpacialTopicPageComponent() | ||
| 16 | - } | 16 | + SpacialTopicPageComponent({ action: this.action }) |
| 17 | + }.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT) | ||
| 17 | } | 18 | } |
| 18 | 19 | ||
| 19 | - pageTransition(){ | 20 | + pageTransition() { |
| 20 | // 定义页面进入时的效果,从右边侧滑入 | 21 | // 定义页面进入时的效果,从右边侧滑入 |
| 21 | PageTransitionEnter({ type: RouteType.None, duration: 300 }) | 22 | PageTransitionEnter({ type: RouteType.None, duration: 300 }) |
| 22 | .slide(SlideEffect.Right) | 23 | .slide(SlideEffect.Right) |
| @@ -25,7 +26,6 @@ struct SpacialTopicPage { | @@ -25,7 +26,6 @@ struct SpacialTopicPage { | ||
| 25 | .slide(SlideEffect.Right) | 26 | .slide(SlideEffect.Right) |
| 26 | } | 27 | } |
| 27 | 28 | ||
| 28 | - | ||
| 29 | aboutToAppear() { | 29 | aboutToAppear() { |
| 30 | Logger.info(TAG, 'aboutToAppear'); | 30 | Logger.info(TAG, 'aboutToAppear'); |
| 31 | let action: Action = router.getParams() as Action | 31 | let action: Action = router.getParams() as Action |
| @@ -28,7 +28,6 @@ struct DefaultWebPage { | @@ -28,7 +28,6 @@ struct DefaultWebPage { | ||
| 28 | isPageEnd: $isPageEnd | 28 | isPageEnd: $isPageEnd |
| 29 | }) | 29 | }) |
| 30 | } | 30 | } |
| 31 | - .padding({ bottom: 56 }) | ||
| 32 | .width(CommonConstants.FULL_WIDTH) | 31 | .width(CommonConstants.FULL_WIDTH) |
| 33 | .height(CommonConstants.FULL_HEIGHT) | 32 | .height(CommonConstants.FULL_HEIGHT) |
| 34 | } | 33 | } |
| @@ -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