yangsunyue_wd

Merge branch 'main' of http://192.168.1.42/developOne/harmonyPool

# Conflicts:
#	sight_harmony/commons/wdKit/src/main/ets/utils/EmitterEventId.ts
Showing 64 changed files with 950 additions and 554 deletions
... ... @@ -67,15 +67,15 @@ export const enum CompStyle {
Card_Adv_4 = 4, //4:轮播图 5:三图广告 6:小图广告 7:长通栏广告 8:大图广告 9:视频广告 10:展会广告 11:冠名广告 12:顶部长通栏广告
Card_Adv_5 = 5,
Card_Adv_6 = 5,
Card_Adv_7 = 7,
Card_Adv_8 = 8,
Card_Adv_9 = 9,
Card_Adv_10 = 10,
Card_Adv_11 = 11,
Card_Adv_12 = 12,
Card_Adv_4 = 4, //4:轮播图
Card_Adv_5 = 5, // 5:三图广告
Card_Adv_6 = 6, // 6:小图广告
Card_Adv_7 = 7, // 7:长通栏广告
Card_Adv_8 = 8, // 8:大图广告
Card_Adv_9 = 9, // 9:视频广告
Card_Adv_10 = 10, // 10:展会广告
Card_Adv_11 = 11, // 11:冠名广告
Card_Adv_12 = 12, // 12:顶部长通栏广告
/**
* 本地稿件和组件样式
... ...
... ... @@ -14,5 +14,12 @@ export enum EmitterEventId {
LOCATION = 5,
/*发布评论*/
COMMENT_PUBLISH = 6,
// App回到前台
APP_ENTER_FOREGROUD = 100,
// App进入后台
APP_ENTER_BACKGROUD = 101,
}
... ...
import HashMap from '@ohos.util.HashMap';
import { SpConstants } from 'wdConstant';
import { SPHelper, StringUtils } from 'wdKit';
import { HostEnum, HostManager } from './HttpHostManager';
... ... @@ -11,81 +10,73 @@ export class HttpParams {
private static userType = ''
private static token = ''
static getCommonHeaders(): HashMap<string, string> {
let headers: HashMap<string, string> = new HashMap<string, string>()
headers.set('User-Agent', 'Dalvik/2.1.0 (Linux; U; Android 13; 22101317C Build/TKQ1.221013.002)')
headers.set('channel', HttpParams.getChannel())
//headers.set('appCode', ConfigConstants.appCode)
headers.set('plat', HttpParams.getPlat())
//headers.set('Authorization', 'APPCODE 83092caa603a421aa0222308b3f6b27a')
headers.set('Content-Type', 'application/json; charset=utf-8')
headers.set('timestamp', HttpParams.getTimestamp())
headers.set('RMRB-X-TOKEN', HttpParams.getXToken())
headers.set('device_id', HttpParams.getDeviceId())
static buildHeaders(): Record<string, string> {
let headers: Record<string, string> = {};
// 通用请求头
headers['User-Agent'] = 'Dalvik/2.1.0 (Linux; U; Android 13; 22101317C Build/TKQ1.221013.002)'
headers['channel'] = HttpParams.getChannel()
headers['plat'] = HttpParams.getPlat()
headers['Content-Type'] = 'application/json; charset=utf-8'
headers['timestamp'] = HttpParams.getTimestamp()
headers['RMRB-X-TOKEN'] = HttpParams.getXToken()
headers['device_id'] = HttpParams.getDeviceId()
if (HttpParams.getXToken() != '') {
headers.set('cookie', 'RMRB-X-TOKEN=' + HttpParams.getXToken())
headers['cookie'] = 'RMRB-X-TOKEN=' + HttpParams.getXToken()
}
headers.set('build_version', HttpParams.getVersion())
headers.set('adcode', HttpParams.getAdCode())
headers.set('os_version', HttpParams.getOsVersion())
//headers.set('X-Ca-Stage', 'PRE')
headers.set('versionCode', HttpParams.getVersionCode())
headers.set('system', HttpParams.getTerminalId())
headers.set('version_name', HttpParams.getVersionName())
headers.set('EagleEye-TraceID', 'D539562E48554A60977AF4BECB6D6C7A')
headers.set('imei', HttpParams.getImei())
headers.set('Accept-Language', 'zh')
headers['build_version'] = HttpParams.getVersion()
headers['adcode'] = HttpParams.getAdCode()
headers['os_version'] = HttpParams.getOsVersion()
headers['versionCode'] = HttpParams.getVersionCode()
headers['system'] = HttpParams.getTerminalId()
headers['version_name'] = HttpParams.getVersionName()
headers['EagleEye-TraceID'] = 'D539562E48554A60977AF4BECB6D6C7A'
headers['imei'] = HttpParams.getImei()
headers['Accept-Language'] = 'zh'
HttpParams.setLocationHeader(headers)
// TODO 判断是否登录
headers.set('userId', HttpParams.getUserId())
headers.set('userType', HttpParams.getUserType())
headers.set('mpassid', 'ZbHTMeTsfaYDAHqt8ZHIzcPs')
// // TODO 判断是否登录
headers['userId'] = HttpParams.getUserId()
headers['userType'] = HttpParams.getUserType()
//
headers['mpassid'] = 'ZbHTMeTsfaYDAHqt8ZHIzcPs'
HttpParams.addSpecialHeaders(headers);
// Logger.debug("TAG", '******************* commonHeaders headers start ******************************** ');
// headers.forEach((v,k)=>{
// Logger.debug("TAG", 'getCommonHeaders header: ' + k + ': ' + v);
// })
// Logger.debug("TAG", '******************* commonHeaders headers end ******************************** ');
return headers;
}
static addSpecialHeaders(headers: HashMap<string, string>) {
static addSpecialHeaders(headers: Record<string, string>) {
switch (HostManager.getHost()) {
case HostEnum.HOST_UAT:
// TODO 待优化到常量类里
headers.set('X-Ca-Stage', 'PRE');
headers.set('Authorization', 'APPCODE 83092caa603a421aa0222308b3f6b27a');
headers.set('appCode', '83092caa603a421aa0222308b3f6b27a');
headers['X-Ca-Stage'] = 'PRE'
headers['Authorization'] = 'APPCODE 83092caa603a421aa0222308b3f6b27a'
headers['appCode'] = '83092caa603a421aa0222308b3f6b27a'
break
case HostEnum.HOST_SIT:
headers.set('X-Ca-Stage', 'TEST');
headers.set('Authorization', 'APPCODE 0af1f9085e484c97b2a44704bae72c07');
headers.set('appCode', '0af1f9085e484c97b2a44704bae72c07');
headers['X-Ca-Stage'] = 'TEST'
headers['Authorization'] = 'APPCODE 0af1f9085e484c97b2a44704bae72c07'
headers['appCode'] = '0af1f9085e484c97b2a44704bae72c07'
break
case HostEnum.HOST_PRODUCT:
headers.set('X-Ca-Stage', 'RELEASE');
headers.set('Authorization', 'APPCODE 3d4181bceeb94d9780e10dbb6c67bbf6');
headers.set('appCode', '3d4181bceeb94d9780e10dbb6c67bbf6');
headers['X-Ca-Stage'] = 'RELEASE'
headers['Authorization'] = 'APPCODE 3d4181bceeb94d9780e10dbb6c67bbf6'
headers['appCode'] = '3d4181bceeb94d9780e10dbb6c67bbf6'
break
case HostEnum.HOST_DEV:
headers.set('X-Ca-Stage', 'TEST');
headers.set('Authorization', 'APPCODE ff33172859e14f9a8299e3bd769e79f9');
headers.set('appCode', 'ff33172859e14f9a8299e3bd769e79f9');
headers['X-Ca-Stage'] = 'TEST'
headers['Authorization'] = 'APPCODE ff33172859e14f9a8299e3bd769e79f9'
headers['appCode'] = 'ff33172859e14f9a8299e3bd769e79f9'
break
default:
break
}
}
static setLocationHeader(headers: HashMap<string, string>) {
static setLocationHeader(headers: Record<string, string>) {
let cityName = SPHelper.default.getSync(SpConstants.LOCATION_CITY_NAME, '') as string
if (StringUtils.isNotEmpty(cityName)) {
headers.set('city', encodeURI(cityName))
headers['city'] = encodeURI(cityName)
}
let cityCode = SPHelper.default.getSync(SpConstants.LOCATION_CITY_CODE, '') as string
if (StringUtils.isNotEmpty(cityCode)) {
headers.set('city_dode', encodeURI(cityCode))
headers['city_dode'] = encodeURI(cityCode)
}
}
... ...
import ArrayList from '@ohos.util.ArrayList';
import service from './AxiosRequest';
import { HttpUtils } from '../utils/HttpUtils';
import { AxiosError, AxiosHeaders, AxiosRequestConfig, RawAxiosRequestHeaders } from '@ohos/axios';
import { ResponseDTO } from '../bean/ResponseDTO';
import HashMap from '@ohos.util.HashMap';
import { HttpParams } from './HttpCommonParams';
export class HttpRequest {
private static globalHeaderProviders: ArrayList<() => Record<string, string>> = new ArrayList();
... ... @@ -14,7 +14,7 @@ export class HttpRequest {
static initHttpHeader() {
HttpRequest.addGlobalHeaderProvider(() => {
return HttpUtils.buildHeaders();
return HttpParams.buildHeaders();
})
}
... ... @@ -34,15 +34,17 @@ export class HttpRequest {
static buildHeaderWithGlobalHeader(headers?: HashMap<string, string>): AxiosHeaders {
let commonHeader: AxiosHeaders = new AxiosHeaders()
headers?.forEach((v, k) => {
commonHeader.set(k, v);
});
HttpRequest.globalHeaderProviders.forEach((func) => {
let headers = func();
for (const obj of Object.entries(headers)) {
commonHeader.set(obj[0], obj[1]);
}
})
// 业务headers,覆盖common(如果有冲突的话,取业务)
headers?.forEach((v, k) => {
commonHeader.set(k, v);
});
if (!commonHeader.get('Content-Type')) {
commonHeader.set('Content-Type', 'application/json;charset=utf-8');
}
... ... @@ -56,24 +58,13 @@ export class HttpRequest {
return service.get(url, config)
}
static post0<T = ResponseDTO<string>>(url: string, data?: object, headers?: HashMap<string, string>): Promise<T> {
static post<T = ResponseDTO<string>>(url: string, data?: object, headers?: HashMap<string, string>): Promise<T> {
let config: AxiosRequestConfig = {
headers: HttpRequest.buildHeaderWithGlobalHeader(headers)
}
return service.post(url, data, config)
}
static post<T = object>(url: string, data1?: object, headers?: HashMap<string, string>): Promise<T> {
let requestHeaders: AxiosHeaders = new AxiosHeaders()
headers?.forEach((v, k) => {
requestHeaders.set(k, v);
});
let config: AxiosRequestConfig = {
headers: requestHeaders as RawAxiosRequestHeaders,
}
return service.post(url, data1, config)
}
static put<T = ResponseDTO<string>>(url: string, data?: object, headers?: HashMap<string, string>): Promise<T> {
let config: AxiosRequestConfig = {
headers: HttpRequest.buildHeaderWithGlobalHeader(headers)
... ...
// import { ResponseLogin } from '../bean/account/ResponseLogin';
import { Logger } from 'wdKit';
// import { UserInfo } from '../bean/account/UserInfo';
// import { ConfigConstants } from '../constants/ConfigConstants';
// import { AccountManagerUtils } from './AccountManagerUtils';
// import { AppUtils } from './AppUtils';
// import { DeviceUtil } from './DeviceUtil';
// import { Logger } from './Logger';
// import { StringUtils } from './StringUtils';
import { HttpRequest } from '../http/HttpRequest';
const TAG: string = '[HttpUtils]'
export class HttpUtils {
static buildHeaders(): Record<string, string> {
let timestamp: number = new Date().getTime(); // 单位毫秒
// let clientId = DeviceUtil.clientId()
let headers: Record<string, string> = {};
// 通用请求头
headers["version"] = 'V3';
// headers["appId"] = ConfigConstants.appId; // 应用id
// headers["terminalId"] = ConfigConstants.terminalId; // 终端ID
// headers["sourceId"] = ConfigConstants.sourceId; // 咪咕视频
// headers["appType"] = ConfigConstants.appType; // 手机客户端App(安卓)
// headers["clientType"] = ConfigConstants.clientType; // 客户端类型
// headers["appVersion"] = AppUtils.getAppVersionCode() + ''; // 客户端版本号:2600010500
// headers["APP-VERSION-CODE"] = AppUtils.getAppVersionCode() + ''; // APP版本号:250006577
// headers["appVersionName"] = AppUtils.getAppVersionName() // app对外显示版本: '6.1.5.00'
// headers["appCode"] = ConfigConstants.appCode; // 应用编码:产品_渠道_应用的拼接串,用下划线_ 拼接而成
// headers["ptvCode"] = ConfigConstants.ptvCode; // 基线版本号_应用版本号 todo:
// headers["clientProvinceCode"] = ''; // 客户端分省号 // 02
// headers["provinceCode"] = ''; // 客户端分省号 // 02
// headers["clientCityId"] = ''; // 客户端城市ID // 0210
// headers["carrierCode"] = ''; // 运营商信息
// 设备信息请求头
// headers["User-Agent"] = ''; // 终端UA,自动获取
headers["Content-Type"] = 'application/json;charset=UTF-8'; // 返回/响应的HTTP内容类型
headers["os"] = 'android'; // 操作系统类型:鸿蒙、安卓或iOS
// headers["osInfo"] = 'AD'; // 操作系统信息
headers["Phone-Info"] = 'HUAWEI'; // 手机信息: todo
// headers["oaid"] = ''; // 开放匿名设备ID,是中国移动安全联盟(MSA)发起并制定标准用户识别ID
headers["networkInfo"] = 'WIFI'; // 网络类型: todo
headers["cache-control"] = 'no-cache'; // 请求和响应遵循的缓存机制
// headers["clientId"] = clientId; // 客户端编号:客户端初始化时生成的客户端ID,保证唯一性
headers["imei"] = 'd1de6d3ae0db44bea1b3f0e20a14d90a'; // 终端手机序列号: todo
headers["X-UP-CLIENT-CHANNEL-ID"] = '2600010500-99000-101700010130012'; // 客户端渠道ID: todo
headers["channelCode"] = 'VIDEO_APPMAIL'; // 渠道编码
// headers["l_c"] = clientId; // 客户端id,同clientId
// headers["l_t"] = timestamp + ''; // 本机时间戳
// headers["l_s"] = ''; // l_c和l_t拼接后的MD5校验
// 签名相关请求头
headers["timeStamp"] = timestamp + ''; // 服务端时间戳(毫秒):1701667763664
headers["signType"] = 'RSA'; // 签名类型,固定RSA
/**
* 添加公共参数,如登录后,添加登录信息
*/
static addCommonHeader() {
HttpRequest.addGlobalHeaderProvider(() => {
let headers: Record<string, string> = {};
return headers;
})
}
// 业务请求头
// headers["promotionID"] = '54b0f421-a6df-41d3-9be2-92820b2c5d8c'; // 促销Id todo
// headers["tenantId"] = ''; // 租户Id
/**
* 添加公共参数,如登出后,移除登录信息
*/
static removeCommonHeader() {
// 添加其他header
// headers["sdkCeId"] = '27fb3129-5a54-45bc-8af1-7dc8f1155501'; // 用户中台老接口定义的ID,保持不变,现网:咪咕视频Android版,27fb3129-5a54-45bc-8af1-7dc8f1155501 todo
headers["support-pendant"] = '1'; // 挂件标识, "1":客户端支持挂件节目结构;非"1":不支持挂件节目结构-展示通用对象
Logger.info(TAG, "buildHeader headers:" + JSON.stringify(headers));
return headers;
}
}
// export default new HttpUtils()
}
\ No newline at end of file
... ...
... ... @@ -5,3 +5,5 @@ export { WDRouterPage } from './src/main/ets/router/WDRouterPage'
export { registerRouter } from './src/main/ets/router/Action2Page'
export { ProcessUtils } from './src/main/ets/utils/ProcessUtils'
export { RouterJumpInterceptor, JumpInterceptorAction } from './src/main/ets/router/RouterJumpInterceptor'
\ No newline at end of file
... ...
import { WDRouterPage } from './WDRouterPage';
export interface JumpInterceptorAction {
on(params?: object, singleMode?: boolean): boolean
}
// TODO:待优化
// 临时解决跳转页面之前方法拦截,比如登录先走一键登录,直播请求接口等
//
export class RouterJumpInterceptor {
private static actions: Record<string, JumpInterceptorAction> = {}
static getInterceptorAction(jumpPage: WDRouterPage): JumpInterceptorAction | undefined {
return RouterJumpInterceptor.actions[jumpPage.url()]
}
static register(jumpPage: WDRouterPage, interceptorAction: JumpInterceptorAction) {
RouterJumpInterceptor.actions[jumpPage.url()] = interceptorAction
}
}
... ...
... ... @@ -66,6 +66,7 @@ export class WDRouterPage {
// 动态详情页
static dynamicDetailPage = new WDRouterPage("phone", "ets/pages/detail/DynamicDetailPage");
static loginPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginPage");
static oneKeyLoginPage = new WDRouterPage("wdLogin", "ets/pages/login/OneKeyLoginPage");
static forgetPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/ForgetPasswordPage");
//我的 预约
static appointmentListPage = new WDRouterPage("wdComponent", "ets/components/page/AppointmentListPage");
... ...
... ... @@ -3,6 +3,7 @@ import { Action } from 'wdBean'
import { ToastUtils } from 'wdKit'
import { Action2Page } from './Action2Page'
import { WDRouterPage } from './WDRouterPage'
import { RouterJumpInterceptor } from './RouterJumpInterceptor'
export class WDRouterRule {
static jumpWithAction(action?: Action) {
... ... @@ -16,6 +17,11 @@ export class WDRouterRule {
static jumpWithPage(page?: WDRouterPage, params?: object, singleMode?: boolean) {
if (page) {
let action = RouterJumpInterceptor.getInterceptorAction(page)
if (action && action.on(params, singleMode)) {
return
}
let mode = router.RouterMode.Standard
if (singleMode) {
mode = router.RouterMode.Single
... ... @@ -36,6 +42,10 @@ export class WDRouterRule {
static jumpWithReplacePage(page?: WDRouterPage, params?: object) {
if (page) {
let action = RouterJumpInterceptor.getInterceptorAction(page)
if (action && action.on(params)) {
return
}
if (params) {
// router.pushUrl({ url: 'pages/routerpage2', , params: params })
router.replaceUrl({ url: page.url(), params: params })
... ...
... ... @@ -17,7 +17,7 @@ const TAG = 'ProcessUtils';
*/
export class ProcessUtils {
/**
* 广告中心的业务广告跳转方法( 现用在挂角广告)
* 广告中心的业务广告跳转方法( 现用在挂角广告、信息流页面广告
* @param advContent
*/
static openAdvDetail(matInfo: CompAdvMatInfoBean) {
... ... @@ -157,7 +157,7 @@ export class ProcessUtils {
* 图集详情页
* @param content
* */
public static gotoMultiPictureListPage(photoList: PhotoListBean[], swiperIndex?:number) {
public static gotoMultiPictureListPage(photoList: PhotoListBean[], swiperIndex?: number) {
let taskAction: Action = {
type: 'JUMP_DETAIL_PAGE',
params: {
... ... @@ -187,8 +187,14 @@ export class ProcessUtils {
let taskAction: Action = {
type: 'JUMP_INNER_NEW_PAGE',
params: {
contentID: content?.objectId,
url: content.linkUrl,
pageID: 'SPACIAL_TOPIC_PAGE',
extra: {
relType: content?.relType,
relId: content?.relId,
channelId: content?.channelId,
} as ExtraDTO
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
... ... @@ -423,11 +429,10 @@ export class ProcessUtils {
/**
* 跳转人民号主页
*@params creatorId 创作者id
* @params creatorId 创作者id
*/
public static gotoPeopleShipHomePage(creatorId: string) {
let params = {'creatorId': creatorId} as Record<string, string>;
let params = { 'creatorId': creatorId } as Record<string, string>;
WDRouterRule.jumpWithPage(WDRouterPage.peopleShipHomePage, params)
}
}
... ...
import HashMap from '@ohos.util.HashMap';
import { Callback } from 'wdJsBridge';
import { Message, IImgListData } from 'wdJsBridge/src/main/ets/bean/Message';
import { Logger } from 'wdKit';
import { Logger, SPHelper } from 'wdKit';
import { H5CallNativeType } from './H5CallNativeType';
import { H5OperateType } from './H5OperateType';
import { ContentConstants } from 'wdConstant';
import { ContentConstants, SpConstants } from 'wdConstant';
import { ProcessUtils } from 'wdRouter';
import router from '@ohos.router';
import Url from '@ohos.url'
import { ContentDTO, PhotoListBean } from 'wdBean';
import { ResponseDTO, WDHttp, HttpUrlUtils } from 'wdNetwork';
import { handleJsCallAppService } from './JsCallAppService'
const TAG = 'JsBridgeBiz'
... ... @@ -20,6 +19,19 @@ class AppInfo {
// TODO 完善
}
class AppLoginAuthInfo {
"X-Ca-Stage": string = ''
userType: number = SPHelper.default.getSync(SpConstants.USER_Type, '') as number
userName: string = SPHelper.default.getSync(SpConstants.USER_NAME, '') as string
userID: string = SPHelper.default.getSync(SpConstants.USER_ID, '') as string
"RMRB-X-TOKEN": string = SPHelper.default.getSync(SpConstants.USER_TEMP_TOKEN, '') as string
phoneNumber: string = SPHelper.default.getSync(SpConstants.USER_PHONE, '') as string
nickName: string = ''
isLogined: string = SPHelper.default.getSync(SpConstants.USER_STATUS, '') as string
creatorID: string = SPHelper.default.getSync(SpConstants.USER_CREATOR_ID, '') as string
Authorization: string = ''
}
/**
* h5调用native代码
* @param data
... ... @@ -39,7 +51,7 @@ export function performJSCallNative(data: Message, call: Callback) {
case H5CallNativeType.jsCall_getArticleDetailBussinessData:
break;
case H5CallNativeType.jsCall_callAppService:
handleJsCallCallAppService(data, (res: string) => {
handleJsCallAppService(data, (res: string) => {
call(res)
})
break;
... ... @@ -49,6 +61,9 @@ export function performJSCallNative(data: Message, call: Callback) {
case H5CallNativeType.jsCall_appInnerLinkMethod:
handleJsCallAppInnerLinkMethod(data)
break;
case H5CallNativeType.jsCall_getAppLoginAuthInfo:
call(handleJsCallGetAppLoginAuthInfo())
break;
default:
break;
}
... ... @@ -64,21 +79,6 @@ function handleJsCallCurrentPageOperate(data: Message) {
}
}
function handleJsCallCallAppService(data: Message, callback: (res: string) => void) {
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
let url: string = HttpUrlUtils.getHost() + data?.data?.url
if (data?.data?.method === 'get') {
WDHttp.get<ResponseDTO<string>>(url, headers).then((res: ResponseDTO<string>) => {
callback(JSON.stringify(res))
})
}
if (data?.data?.method === 'post') {
WDHttp.post<ResponseDTO<string>>(url, data?.data?.parameters, headers).then(res => {
callback(JSON.stringify(res))
})
}
}
/**
* 获取App公共信息
*/
... ... @@ -90,12 +90,11 @@ function getAppPublicInfo(): string {
info.networkStatus = 1
let result = JSON.stringify(info)
Logger.debug(TAG, 'getAppPublicInfo: ' + JSON.stringify(info))
return result;
}
function handleJsCallReceiveH5Data(data: Message) {
switch (data?.data?.dataSource) {
switch (String(data?.data?.dataSource)) {
case '3':
let imgListData: IImgListData = JSON.parse(data?.data?.imgListData || "{}")
let imgArr = imgListData?.imgArr || []
... ... @@ -110,7 +109,7 @@ function handleJsCallReceiveH5Data(data: Message) {
}
return photo
})
ProcessUtils.gotoMultiPictureListPage(photoList,swiperIndex)
ProcessUtils.gotoMultiPictureListPage(photoList, swiperIndex)
}
break;
case '5':
... ... @@ -183,3 +182,9 @@ function handleJsCallAppInnerLinkMethod(data: Message) {
}
}
}
function handleJsCallGetAppLoginAuthInfo() {
let appLoginAuthInfo = new AppLoginAuthInfo()
let result = JSON.stringify(appLoginAuthInfo)
return result;
}
\ No newline at end of file
... ...
import HashMap from '@ohos.util.HashMap';
import { Message } from 'wdJsBridge/src/main/ets/bean/Message';
import { H5ReceiveDataJsonBean, postBatchAttentionStatusResult } from 'wdBean';
import { ResponseDTO, WDHttp, HttpUrlUtils } from 'wdNetwork';
const TAG = 'JsCallAppService'
export function handleJsCallAppService(data: Message, callback: (res: string) => void) {
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
let url: string = HttpUrlUtils.getHost() + data?.data?.url
let responseMap: ResponseDTO<postBatchAttentionStatusResult> = {} as ResponseDTO<postBatchAttentionStatusResult>
let h5ReceiveDataJson: H5ReceiveDataJsonBean<ResponseDTO<postBatchAttentionStatusResult>> = {
netError: '0',
responseMap
} as H5ReceiveDataJsonBean<ResponseDTO<postBatchAttentionStatusResult>>
// if (data?.data?.method === 'get') {
// WDHttp.get<ResponseDTO<postBatchAttentionStatusResult>>(url, headers).then((res: ResponseDTO<postBatchAttentionStatusResult>) => {
// callback(JSON.stringify(res))
// })
// }
if (data?.data?.method === 'post' && data?.data?.url === '/api/rmrb-interact/interact/zh/c/batchAttention/status') {
WDHttp.post<ResponseDTO<postBatchAttentionStatusResult>>(url, data?.data?.parameters, headers).then((res: ResponseDTO<postBatchAttentionStatusResult>) => {
h5ReceiveDataJson.responseMap = res
callback(JSON.stringify(h5ReceiveDataJson))
})
}
}
... ...
... ... @@ -8,4 +8,5 @@ export interface commentInfo {
newsId: string,
relId: string;
relType: string;
userId: string;
}
\ No newline at end of file
... ...
export interface H5ReceiveDataExtraBean {
creatorId: string;
cnsTraceId: string;
isLogin: string;
loadImageOnlyWifiSwitch: string;
networkStatus: number;
loadImageOnlyWifiSwitch: string
darkMode: string;
fontSizes: string;
}
\ No newline at end of file
... ...
import { ResponseBean } from './ResponseBean';
export interface H5ReceiveDataJsonBean {
contentId: string;
contentType: string;
topicId: string;
channelId: string;
compId: string;
sourcePage: string;
export interface H5ReceiveDataJsonBean<T = ResponseBean> {
contentId?: string;
contentType?: string;
topicId?: string;
channelId?: string;
compId?: string;
sourcePage?: string;
netError: string;
responseMap: ResponseBean;
responseMap: T;
}
\ No newline at end of file
... ...
import { ContentDetailDTO } from '../detail/ContentDetailDTO';
export interface ResponseBean{
success:boolean;
export interface ResponseBean<T = ContentDetailDTO[]> {
success: boolean;
// 服务请求响应值/微服务响应状态码”
code: number;
... ... @@ -10,8 +10,7 @@ export interface ResponseBean{
message: string;
// 响应结果
data:ContentDetailDTO[];
data: T
// 请求响应时间戳(unix格式)
timestamp?: number;
}
\ No newline at end of file
... ...
... ... @@ -4,37 +4,39 @@ import { TopNavDTO } from './TopNavDTO';
* 底导(包含顶导列表)数据
*/
export interface BottomNavDTO {
backgroundUrl: string;
channelChooseActionUrl: string;
channelChooseCColor: string;
channelChooseColor: string;
channelMoreColor: string;
backgroundUrl: string; // 迭代四:页面背景图
channelChooseActionUrl: string; // 迭代四:频道选中下划线动画
channelChooseCColor: string; // 迭代四:频道未选中颜色
channelChooseColor: string; // 迭代四:频道选中颜色
channelMoreColor: string; // 迭代四:更多频道颜色
extraData: string;
homePageColor: string;
icon: string;
iconC: string;
homePageColor: string; // 迭代四:主页图标/文字颜色
icon: string; // 未选中图标
iconC: string; // 选中图标
id: number;
immersiveIconCUrl: string;
immersiveIconUrl: string;
immersiveNameCColor: string;
immersiveNameColor: string;
logoUrl: string;
immersiveIconCUrl: string; // 迭代二新增-图标颜色-选中(沉浸式频道)
immersiveIconUrl: string; // 迭代二新增-图标颜色-未选中(沉浸式频道)
immersiveNameCColor: string; // 迭代二新增-文字颜色-选中(沉浸式频道)
immersiveNameColor: string; // 迭代二新增-文字颜色-未选中(沉浸式频道)
logoUrl: string; // 迭代四:logo图片
morningAndEveningUrl: string;
name: string;
nameCColor: string;
nameColor: string;
nightIconCUrl: string;
nightIconUrl: string;
nightNameCColor: string;
nightNameColor: string;
noticeColor: string;
nameCColor: string; // 名字选中颜色
nameColor: string; // 名字颜色
nightIconCUrl: string; // 迭代三新增-图标颜色-选中(夜间模式)
nightIconUrl: string; // 迭代三新增-图标颜色-未选中(夜间模式)
nightNameCColor: string; // 迭代三新增-文字颜色-选中(夜间模式)
nightNameColor: string; // 迭代三新增-文字颜色-未选中(夜间模式)
noticeColor: string; // 迭代四:消息通知提醒颜色
pageId?: string;
pageType?: string;
searchBothColor: string;
searchUrl: string;
searchBothColor: string; // 迭代四:两侧文字图标颜色,搜索图标颜色
searchUrl: string; // 迭代四:搜索背景框
sortValue: number;
statusBarColor: number;
statusBarColor: number; // 迭代四:状态栏图标颜色,0:白色,1:黑色
topNavChannelList: TopNavDTO[];
topStyle: string;
type: string;
topStyle: string; // 顶部样式:中文的(11-新闻;12-人民号;13-视频;14-服务)
type: string; // 底部导航类型,1普通 2我的;【rmrb需要扩展】
fmorningAndEveningUrl: string; // 迭代四:早晚报背景框
dropDownAnimationColor: string; // 下拉加载动画颜色,1白色,2灰色。未配置值是null
}
\ No newline at end of file
... ...
... ... @@ -4,9 +4,10 @@ import { BottomNavDTO } from './BottomNavDTO';
* 导航Body数据
*/
export interface NavigationBodyDTO {
backgroundColor: string;
backgroundColor: string; // 迭代二新增-底部导航背景色(信息流频道)
bottomNavList: BottomNavDTO[];
// greyBottomNav: GreyBottomNav;
immersiveBackgroundColor: string;
nightBackgroundColor: string;
// greyBottomNav: GreyBottomNav; // 灰度皮肤
immersiveBackgroundColor: string; // 迭代二新增-底部导航背景色(沉浸式频道)
nightBackgroundColor: string; // 迭代三新增-底部导航背景色(夜间模式)
}
... ...
... ... @@ -7,14 +7,14 @@ export interface TopNavDTO {
channelType: number;
defaultPermitted: number;
delPermitted: number;
fontCColor: string;
fontColor: string;
fontCColor: string; // 频道展示样式颜色(选中状态)
fontColor: string; // 频道展示样式颜色(未选中状态)
headlinesOn: number;
homeChannel: string;
iconCUrl: string;
iconCUrlSize: string;
iconUrl: string;
iconUrlSize: string;
iconCUrlSize: string;
iconUrl: string; // 频道图片展示样式图片相对地址(未选中状态)
iconCUrl: string; //频道图片展示样式图片相对地址(选中状态
localChannel: string;
moreChannel: string;
movePermitted: number;
... ... @@ -23,5 +23,5 @@ export interface TopNavDTO {
num: number;
pageId: number;
pageType: string;
underlineCColor: string;
underlineCColor: string; // 选中下划线颜色
}
... ...
... ... @@ -24,7 +24,6 @@ import { ZhGridLayout02 } from './compview/ZhGridLayout02';
import { Card2Component } from './cardview/Card2Component';
import { Card5Component } from './cardview/Card5Component';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { CardAdvComponent } from './cardViewAdv/CardAdvComponent';
import { AdvCardParser } from './cardViewAdv/AdvCardParser';
/**
... ...
... ... @@ -13,7 +13,6 @@ import {
import DetailViewModel from '../viewmodel/DetailViewModel';
import { ImageAndTextWebComponent } from './ImageAndTextWebComponent';
import { OperRowListView } from './view/OperRowListView';
import router from '@ohos.router';
import { RecommendList } from '../components/view/RecommendList'
import { CommonConstants } from 'wdConstant';
import { HttpUrlUtils } from 'wdNetwork/Index';
... ... @@ -21,10 +20,11 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
import { PageRepository } from '../repository/PageRepository';
import { detailedSkeleton } from './skeleton/detailSkeleton';
import { CommentComponent } from '../components/comment/view/CommentComponent'
const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm';
const TAG = 'ImageAndTextPageComponent'
const TAG: string = 'ImageAndTextPageComponent'
@Component
export struct ImageAndTextPageComponent {
... ... @@ -75,9 +75,55 @@ export struct ImageAndTextPageComponent {
isPageEnd: $isPageEnd
})
Column() {
// 点赞
if (this.contentDetailData[0]?.openLikes) {
Row() {
Row() {
if (this.newsStatusOfUser?.likeStatus === '1') {
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')))
.width(24)
.height(24)
.margin({ right: 5 })
} else {
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')))
.width(24)
.height(24)
.margin({ right: 5 })
}
if(this.interactData?.likeNum !== '0'){
Text(`${this.interactData?.likeNum}`)
.fontSize(16)
.fontColor(this.newsStatusOfUser?.likeStatus === '1' ? '#ED2800' : '#999999')
.fontWeight(500)
}
}
.width(140)
.height(36)
.justifyContent(FlexAlign.Center)
.alignItems(VerticalAlign.Center)
.borderRadius(20)
.border({
width: 1,
color: '#EDEDED',
})
.onClick(() => {
this.toggleLikeStatus()
})
}.width(CommonConstants.FULL_WIDTH).height(80)
.justifyContent(FlexAlign.Center)
Divider().strokeWidth(6).color('#f5f5f5')
}
if (this.recommendList.length > 0) {
RecommendList({ recommendList: this.recommendList })
}
// 评论
if(this.contentDetailData[0]?.openComment){
// CommentComponent({
//
// })
}
}
}
... ... @@ -95,42 +141,6 @@ export struct ImageAndTextPageComponent {
if (this.contentDetailData?.length) {
OperRowListView({contentDetailData: this.contentDetailData[0]})
}
/* Row() {
Image($r('app.media.icon_arrow_left'))
.width(24)
.height(24)
.onClick((event: ClickEvent) => {
router.back()
})
Row() {
Image($r('app.media.icon_comment'))
.width(24)
.height(24)
.margin({ right: 24 })
.id('comment')
Image($r('app.media.icon_star'))
.width(24)
.height(24)
.margin({ right: 24 })
Image($r('app.media.icon_listen'))
.width(24)
.height(24)
.margin({ right: 24 })
Image($r('app.media.icon_forward'))
.width(24)
.height(24)
}
}
.width(CommonConstants.FULL_WIDTH)
.height(56)
.padding({ left: 15, right: 15, bottom: 50, top: 20 })
.justifyContent(FlexAlign.SpaceBetween)
.backgroundColor(Color.White)*/
}
}
... ...
... ... @@ -12,6 +12,7 @@ import { WdWebLocalComponent } from 'wdWebComponent';
import { NativeCallH5Type } from 'wdWebComponent/src/main/ets/pages/NativeCallH5Type';
import { BridgeWebViewControl } from 'wdJsBridge/Index';
const TAG: string = 'ImageAndTextWebComponent'
@Component
export struct ImageAndTextWebComponent {
action: Action = {} as Action
... ... @@ -60,9 +61,12 @@ export struct ImageAndTextWebComponent {
// TODO 对接user信息、登录情况
let h5ReceiveDataExtraBean: H5ReceiveDataExtraBean = {
creatorId: creatorId,
cnsTraceId: '',
isLogin: isLogin,
networkStatus: Number(NetworkUtil.isNetConnected()),
loadImageOnlyWifiSwitch: '2',
networkStatus: Number(NetworkUtil.isNetConnected()),
darkMode: 'light',
fontSizes: 'normalsize'
} as H5ReceiveDataExtraBean
let h5ReceiveDataJsonBean: H5ReceiveDataJsonBean = {
... ... @@ -83,7 +87,6 @@ export struct ImageAndTextWebComponent {
this.h5ReceiveAppData.dataExt = h5ReceiveDataExtraBean
this.dataPrepared = true
this.trySendData2H5()
}
}
... ...
... ... @@ -168,6 +168,11 @@ export struct MorningEveningPaperComponent {
}
}
async aboutToDisappear() {
let windowHight: window.Window = await window.getLastWindow(getContext(this));
await windowHight.setWindowLayoutFullScreen(false);
}
onPageHide() {
this.status = PlayerConstants.STATUS_PAUSE;
this.playerController?.pause();
... ...
import { Action, H5ReceiveDetailBean } from 'wdBean';
import { Action, H5ReceiveDetailBean, ContentDetailDTO } from 'wdBean';
import { WdWebComponent } from 'wdWebComponent';
import router from '@ohos.router';
import { CommonConstants } from 'wdConstant'
import { BridgeWebViewControl } from 'wdJsBridge/Index';
import { detailedSkeleton } from './skeleton/detailSkeleton'
import { NativeCallH5Type } from 'wdWebComponent/src/main/ets/pages/NativeCallH5Type';
const TAG = 'SpacialTopicPageComponent'
import { OperRowListView } from './view/OperRowListView';
import DetailViewModel from '../viewmodel/DetailViewModel';
const TAG: string = 'SpacialTopicPageComponent'
@Component
export struct SpacialTopicPageComponent {
... ... @@ -14,6 +17,7 @@ export struct SpacialTopicPageComponent {
action: Action = {} as Action
@State webUrl: string = '';
@State isPageEnd: boolean = false
@State contentDetailData: ContentDetailDTO [] = [] as ContentDetailDTO []
private h5ReceiveAppData: H5ReceiveDetailBean = { dataSource: '2' } as H5ReceiveDetailBean
private webPrepared = false;
private dataPrepared = false;
... ... @@ -37,11 +41,33 @@ export struct SpacialTopicPageComponent {
})
}
private async getDetail() {
let contentId: string = ''
let relId: string = ''
let relType: string = ''
if (this.action && this.action.params) {
if (this.action.params.contentID) {
contentId = this.action.params.contentID;
}
if (this.action && this.action.params && this.action.params.extra) {
if (this.action.params.extra.relId) {
relId = this.action.params.extra.relId;
}
if (this.action.params.extra.relType) {
relType = this.action.params.extra.relType
}
}
let detailBeans = await DetailViewModel.getDetailPageData(relId, contentId, relType)
if (detailBeans && detailBeans.length > 0) {
this.contentDetailData = detailBeans;
this.trySendData2H5()
}
}
}
build() {
Column() {
if (!this.isPageEnd) {
detailedSkeleton()
}
Stack({ alignContent: Alignment.Bottom }) {
Column() {
WdWebComponent({
... ... @@ -52,62 +78,23 @@ export struct SpacialTopicPageComponent {
isPageEnd: $isPageEnd
})
}
.padding({ bottom: 56 })
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
.padding({ bottom: 126 })
//底部交互区
Row() {
Image($r('app.media.icon_arrow_left'))
.width(24)
.height(24)
.onClick((event: ClickEvent) => {
router.back()
})
Row() {
Image($r('app.media.icon_comment'))
.width(24)
.height(24)
.margin({ right: 24 })
.id('comment')
Image($r('app.media.icon_star'))
.width(24)
.height(24)
.margin({ right: 24 })
Image($r('app.media.icon_listen'))
.width(24)
.height(24)
.margin({ right: 24 })
Image($r('app.media.icon_forward'))
.width(24)
.height(24)
}
if (!this.isPageEnd) {
detailedSkeleton()
}
.width(CommonConstants.FULL_WIDTH)
.height(56)
.padding({ left: 15, right: 15, bottom: 20, top: 20 })
.justifyContent(FlexAlign.SpaceBetween)
.backgroundColor(Color.White)
//底部交互区
OperRowListView({ contentDetailData: this.contentDetailData[0] })
}
}.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT)
.backgroundColor(Color.White)
}
aboutToAppear() {
let action: Action = router.getParams() as Action
if (action) {
this.webUrl = action.params?.url || ''
if (this.action) {
this.webUrl = this.action.params?.url || ''
}
this.trySendData2H5()
}
aboutToDisappear() {
this.getDetail()
}
}
\ No newline at end of file
... ...
import { CompStyle } from 'wdConstant';
import { CompDTO } from 'wdBean';
import { CardAdvComponent } from './CardAdvComponent';
import { CardAdvThreeImageComponent } from './CardAdvThreeImageComponent';
import { CardAdvSmallImageComponent } from './CardAdvSmallImageComponent';
import { CardAdvLongImageComponent } from './CardAdvLongImageComponent';
... ...
... ... @@ -22,12 +22,12 @@ export struct CardAdvBigImageComponent {
aboutToAppear(): void {
console.error('ZZZXXXXX', '--------aboutToAppear-----')
console.error('ZZZXXXXX', '----大图卡----aboutToAppear-----')
}
aboutToDisappear(): void {
console.error('ZZZXXXXX', '--------aboutToDisappear-----')
console.error('ZZZXXXXX', '---大图卡-----aboutToDisappear-----')
}
build() {
... ...
//全标题 "appStyle":"2",
import { CompDTO, ContentDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant/Index';
import { ProcessUtils } from 'wdRouter';
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
import { CardSourceInfo } from '../cardCommon/CardSourceInfo'
const TAG: string = 'Card2Component';
/**
* @Description: 类描述
* @Author:
* @Email: liyubing@wondertek.com.cn
* @CreateDate:
* @UpdateRemark: 更新说明
* @Version: 1.0
*/
@Component
export struct CardAdvComponent {
@State compDTO: CompDTO = {} as CompDTO
aboutToAppear(): void {
console.error('ZZZXXXXX', '--------aboutToAppear-----')
}
aboutToDisappear(): void {
console.error('ZZZXXXXX', '--------aboutToDisappear-----')
}
build() {
Column() {
Text(this.compDTO.matInfo.advTitle)
.fontSize($r('app.float.font_size_17'))
.fontColor($r('app.color.color_222222'))
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。
.align(Alignment.Start)
}
.width(CommonConstants.FULL_WIDTH)
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
top: $r('app.float.card_comp_pagePadding_tb'),
bottom: $r('app.float.card_comp_pagePadding_tb')
})
.onClick((event: ClickEvent) => {
//ProcessUtils.processPage(this.contentDTO)
})
}
}
@Extend(Text)
function bottomTextStyle() {
.fontSize(12)
.fontColor('#B0B0B0')
}
\ No newline at end of file
... ... @@ -22,12 +22,12 @@ export struct CardAdvGanMiComponent {
aboutToAppear(): void {
console.error('ZZZXXXXX', '--------aboutToAppear-----')
console.error('ZZZXXXXX', '--冠名广告------aboutToAppear-----')
}
aboutToDisappear(): void {
console.error('ZZZXXXXX', '--------aboutToDisappear-----')
console.error('ZZZXXXXX', '--冠名广告------aboutToDisappear-----')
}
build() {
... ...
... ... @@ -22,12 +22,12 @@ export struct CardAdvLongImageComponent {
aboutToAppear(): void {
console.error('ZZZXXXXX', '--------aboutToAppear-----')
console.error('ZZZXXXXX', '--长通栏广告 和 顶部长通栏广告------aboutToAppear-----')
}
aboutToDisappear(): void {
console.error('ZZZXXXXX', '--------aboutToDisappear-----')
console.error('ZZZXXXXX', '--长通栏广告 和 顶部长通栏广告------aboutToDisappear-----')
}
build() {
... ...
//全标题 "appStyle":"2",
import { CompDTO, ContentDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant/Index';
import { CompDTO } from 'wdBean';
import { ProcessUtils } from 'wdRouter';
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
import { CardSourceInfo } from '../cardCommon/CardSourceInfo'
const TAG: string = 'Card2Component';
/**
* @Description: 广告---小图卡
* @Author:
* @Email: liyubing@wondertek.com.cn
* @CreateDate:
* @UpdateRemark: 更新说明
* @Version: 1.0
import measure from '@ohos.measure';
import { DisplayUtils } from 'wdKit/Index';
const TAG: string = 'CardAdvSmallImageComponent';
/**
* @Description: 广告---小图卡
* @Author:
* @Email: liyubing@wondertek.com.cn
* @CreateDate:
* @UpdateRemark: 更新说明
* @Version: 1.0
*/
@Component
export struct CardAdvSmallImageComponent {
@State compDTO: CompDTO = {} as CompDTO
@State isBigThreeLine: boolean = false // 标题的行数大于等于3行 是true
aboutToAppear(): void {
console.error('ZZZXXXXX', '--------aboutToAppear-----')
console.error('ZZZXXXXX', '----小图卡----aboutToAppear-----')
// 计算标题文本行数
let screenWith = DisplayUtils.getDeviceWidth();
screenWith = screenWith * 0.62
let titleNameLineNum = this.getTextLineNum(this.compDTO.matInfo.advTitle, screenWith, 25, 18)
this.isBigThreeLine = titleNameLineNum >= 3;
}
aboutToDisappear(): void {
console.error('ZZZXXXXX', '--------aboutToDisappear-----')
console.error('ZZZXXXXX', '---小图卡-----aboutToDisappear-----')
}
build() {
Column() {
RelativeContainer() {
// 广告标题
Text(this.compDTO.matInfo.advTitle)
.fontSize($r('app.float.font_size_17'))
.fontSize('18fp')
.fontColor($r('app.color.color_222222'))
.maxLines(3)
.lineHeight(25)
.textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。
.align(Alignment.Start)
.width('62%')
.alignRules({
top: { anchor: '__container__', align: VerticalAlign.Top },
left: { anchor: '__container__', align: HorizontalAlign.Start },
})
.id("title_name")
// 广告图
Image(this.compDTO.matInfo.matImageUrl[0])
.width('34%')
.aspectRatio(3 / 2)
.borderRadius(4)
.id('adv_imag')
.alignRules({
top: { anchor: 'title_name', align: VerticalAlign.Top },
left: { anchor: 'title_name', align: HorizontalAlign.End },
})
.margin({ left: 12 })
Row() {
Text($r('app.string.comp_advertisement')).fontSize('12fp').fontColor($r('app.color.color_B0B0B0'))
Blank()
Stack() {
Image($r('app.media.comp_adv_close'))
.width(9)
.height(9)
.borderRadius({
topLeft: '4vp',
topRight: '4vp',
bottomLeft: '4vp',
bottomRight: '4vp'
})
}
.width(18)
.height(14)
.borderWidth(0.5)
.borderColor($r('app.color.color_EDEDED'))
.borderRadius(4)
}.width('62%').alignRules({
bottom: { anchor: this.isBigThreeLine ? '' : 'adv_imag', align: VerticalAlign.Bottom },
right: { anchor: this.isBigThreeLine ? '' : 'adv_imag', align: HorizontalAlign.Start },
top: { anchor: this.isBigThreeLine ? 'title_name' : '', align: VerticalAlign.Bottom },
left: { anchor: this.isBigThreeLine ? 'title_name' : '', align: HorizontalAlign.Start },
}).id('bottom_adv').margin({
right: this.isBigThreeLine ? 0 : 12,
top: this.isBigThreeLine ? 8 : 0,
})
}
.width(CommonConstants.FULL_WIDTH)
.width("100%")
.height(this.isBigThreeLine ? 127 : 106)
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
... ... @@ -48,13 +107,31 @@ export struct CardAdvSmallImageComponent {
bottom: $r('app.float.card_comp_pagePadding_tb')
})
.onClick((event: ClickEvent) => {
//ProcessUtils.processPage(this.contentDTO)
ProcessUtils.openAdvDetail(this.compDTO.matInfo)
})
}
// 获取文本几行
private getTextLineNum(text: string, constraintWidth: number, lineHeight: number, fontSize: number | string | Resource) {
let size = this.topMeasureText(text, constraintWidth, lineHeight, fontSize)
let height: number = Number(size.height)
return Math.ceil(px2vp(height) / lineHeight)
}
private topMeasureText(text: string, constraintWidth: number, lineHeight: number, fontSize: number | string | Resource) {
return measure.measureTextSize({
textContent: text,
fontSize: fontSize,
lineHeight: lineHeight,
constraintWidth: constraintWidth,
})
}
}
@Extend(Text)
function bottomTextStyle() {
.fontSize(12)
.fontColor('#B0B0B0')
}
\ No newline at end of file
}
... ...
... ... @@ -22,12 +22,12 @@ export struct CardAdvThreeImageComponent {
aboutToAppear(): void {
console.error('ZZZXXXXX', '--------aboutToAppear-----')
console.error('ZZZXXXXX', '---三图卡-----aboutToAppear-----')
}
aboutToDisappear(): void {
console.error('ZZZXXXXX', '--------aboutToDisappear-----')
console.error('ZZZXXXXX', '----三图卡----aboutToDisappear-----')
}
build() {
... ...
... ... @@ -22,12 +22,12 @@ export struct CardAdvVideoComponent {
aboutToAppear(): void {
console.error('ZZZXXXXX', '--------aboutToAppear-----')
console.error('ZZZXXXXX', '--视频广告------aboutToAppear-----')
}
aboutToDisappear(): void {
console.error('ZZZXXXXX', '--------aboutToDisappear-----')
console.error('ZZZXXXXX', '---视频广告-----aboutToDisappear-----')
}
build() {
... ...
... ... @@ -22,12 +22,12 @@ export struct CardAdvVideoExComponent {
aboutToAppear(): void {
console.error('ZZZXXXXX', '--------aboutToAppear-----')
console.error('ZZZXXXXX', '--冠名广告------aboutToAppear-----')
}
aboutToDisappear(): void {
console.error('ZZZXXXXX', '--------aboutToDisappear-----')
console.error('ZZZXXXXX', '----冠名广告----aboutToDisappear-----')
}
build() {
... ...
... ... @@ -5,7 +5,6 @@ import commentViewModel from '../viewmodel/CommentViewModel'
import { router, window } from '@kit.ArkUI'
import { CustomTitleUI } from '../../reusable/CustomTitleUI'
import { MyCommentDataSource } from '../model/MyCommentDataSource'
import { HttpUtils } from 'wdNetwork/src/main/ets/utils/HttpUtils'
import { HttpUrlUtils } from 'wdNetwork/Index'
import PageModel from '../../../viewmodel/PageModel'
import { ErrorComponent } from '../../view/ErrorComponent'
... ...
... ... @@ -120,6 +120,9 @@ export struct ZhSingleRow06 {
.maxLines(1)
.textOverflow({overflow: TextOverflow.Ellipsis})
}
.onClick(() => {
ProcessUtils.commentGotoWeb(item.operDataList[0]?.commentInfo as commentInfo)
})
Row() {
Image($r("app.media.icon_elite_comment"))
... ...
import { BottomNavi, CommonConstants } from 'wdConstant';
import { BottomNavDTO } from 'wdBean';
import { BottomNavDTO, TopNavDTO } from 'wdBean';
import { DateTimeUtils, EmitterEventId, EmitterUtils, Logger } from 'wdKit';
import { TopNavigationComponent } from './TopNavigationComponent';
import { MinePageComponent } from './MinePageComponent';
import { CompUtils } from '../../utils/CompUtils';
import PageViewModel from '../../viewmodel/PageViewModel';
import HomeChannelUtils, { AssignChannelParam } from 'wdRouter/src/main/ets/utils/HomeChannelUtils';
import { Message } from 'wdJsBridge/src/main/ets/bean/Message';
const TAG = 'BottomNavigationComponent';
let storage = LocalStorage.getShared();
... ... @@ -21,14 +22,13 @@ export struct BottomNavigationComponent {
@Provide isLayoutFullScreen: boolean = false
@Provide isImmersive: boolean = false // 是否开启沉浸式模式 http://192.168.1.3:3300/project/3802/interface/api/189229
@Provide isNight: boolean = false // 是否开启夜间模式
@Provide currentBottomNavInfo: BottomNavDTO = {} as BottomNavDTO; // 当前底导信息
@Provide currentTopNavInfo: TopNavDTO = {} as TopNavDTO; // 当前顶导信息
@Provide barBackgroundColor: Color = Color.Transparent
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
@State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
// 底导/顶导全部数据
@State @Watch('onBottomNavigationDataUpdated') bottomNavList: BottomNavDTO[] = []
// 底导当前选中/焦点下标
@State currentNavIndex: number = BottomNavi.NEWS;
// @State currentTopNavSelectedIndex: number = 0; //
@State barBackgroundColor: Color = Color.Transparent
@State @Watch('onBottomNavigationDataUpdated') bottomNavList: BottomNavDTO[] = [] // 底导/顶导全部数据
@State currentNavIndex: number = BottomNavi.NEWS; // 底导当前选中/焦点下标
// 底导TabsController
private navController: TabsController = new TabsController();
readonly ASPECT_RATIO_1_1: number = 1 / 1; // 底导图片宽高比
... ... @@ -44,6 +44,7 @@ export struct BottomNavigationComponent {
@State assignChannel: AssignChannelParam = new AssignChannelParam()
// 自动刷新触发(双击tab自动刷新)
@State autoRefresh: number = 0
async aboutToAppear() {
Logger.info(TAG, `aboutToAppear currentNavIndex: ${this.currentNavIndex}`);
let bottomNav = await PageViewModel.getBottomNavData(getContext(this))
... ... @@ -84,7 +85,6 @@ export struct BottomNavigationComponent {
_currentNavIndex: $currentNavIndex,
navIndex: index,
currentBottomNavName: navItem.name,
barBackgroundColor: $barBackgroundColor,
assignChannel: this.assignChannel,
autoRefresh: this.autoRefresh
})
... ... @@ -99,8 +99,8 @@ export struct BottomNavigationComponent {
.animationDuration(0)
.barHeight($r('app.float.bottom_navigation_barHeight'))
.barMode(BarMode.Fixed)
// TODO:更详细的判断是视频频道
.barBackgroundColor(this.barBackgroundColor)
// 备注:鸿蒙目前只有修改三线导航背景方法,对于全面屏导航条手机需要设置背景色并使其扩散到导航区域
.backgroundColor(this.barBackgroundColor)
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
... ... @@ -108,17 +108,6 @@ export struct BottomNavigationComponent {
}
/**
* TODO:更详细的判断视频频道
*/
getFontColor(index: number): Color {
if (this.currentNavIndex === 2 && this.barBackgroundColor === Color.Black) {
return Color.White
} else {
return this.currentNavIndex === index ? Color.Red : Color.Gray
}
}
@Builder
tabBarBuilder(navItem: BottomNavDTO, index: number) {
Stack({ alignContent: Alignment.Bottom }) {
... ... @@ -126,37 +115,39 @@ export struct BottomNavigationComponent {
.height(CommonConstants.FULL_PARENT)
.padding({ bottom: 15, left: 10, right: 10, top: 2 })
.aspectRatio(this.ASPECT_RATIO_1_1)
.gesture(
TapGesture({ count: 2 })
.onAction((event: GestureEvent) => {
if (this.currentNavIndex === index) {
// 当前tab,双击事件
this.autoRefresh++
}
})
)
Text(navItem.name)
.margin({ bottom: $r('app.float.bottom_navigation_margin_bottom') })
.fontWeight(this.currentNavIndex === index ? FontWeight.Bold : FontWeight.Normal)
.textAlign(TextAlign.Center)
.fontSize($r('app.float.font_size_10'))// .fontColor(this.currentNavIndex === index ? Color.Red : Color.Gray)
.fontColor(this.getFontColor(index))
.fontColor(this.currentNavIndex === index ? navItem.nameCColor : navItem.nameColor)
.opacity(this.currentNavIndex === index ? this.FULL_OPACITY : this.SIXTY_OPACITY)
}
.height($r('app.float.bottom_navigation_barHeight'))
.hoverEffect(HoverEffect.Highlight)
.onClick(() => {
if (this.currentNavIndex === index) {
// 当前tab,双击事件
this.doubleClick(() => {
Logger.info(TAG, 'tab double click ')
this.autoRefresh++
})
if (navItem.name === '我的') {
this.barBackgroundColor = Color.White
this.currentBottomNavInfo = {} as BottomNavDTO
} else {
// 切换tab
this.currentNavIndex = index;
Logger.info(TAG, `onChange, index: ${index}`);
this.currentBottomNavInfo = navItem
}
this.currentNavIndex = index;
Logger.info(TAG, `onChange, index: ${index}`);
})
// .justifyContent(FlexAlign.Center)
// .onClick(() => {
// Logger.info(TAG, `onClick, index: ${index}`);
// this.currentNavIndex = index ?? 0;
// this.navController.changeIndex(this.currentNavIndex);
// })
}
// 底导切换函数
... ... @@ -199,17 +190,17 @@ export struct BottomNavigationComponent {
/**
* 双击实现
*/
doubleClickTime: number = 0
// doubleClickTime: number = 0
/**
* 双击实现
*/
private doubleClick(fun: () => void) {
let now = DateTimeUtils.getTimeStamp()
if (now - this.doubleClickTime < 200) {
fun()
} else {
this.doubleClickTime = now
}
}
// private doubleClick(fun: () => void) {
// let now = DateTimeUtils.getTimeStamp()
// if (now - this.doubleClickTime < 200) {
// fun()
// } else {
// this.doubleClickTime = now
// }
// }
}
\ No newline at end of file
... ...
... ... @@ -11,6 +11,7 @@ const MY_CHANNEL_TIP2: string = '拖动调整频道顺序'
const MORE_CHANNEL: string = '更多频道'
const LOCAL_CHANNEL: string = '地方频道'
const TAG: string = 'ChannelSubscriptionLayout'
@CustomDialog
struct ChannelDialog {
... ...
import { CompDTO, TopNavDTO } from 'wdBean';
import { BottomNavDTO, CompDTO, TopNavDTO } from 'wdBean';
import { LazyDataSource, Logger } from 'wdKit';
import { ProcessUtils } from 'wdRouter';
import { PageComponent } from './PageComponent';
... ... @@ -26,12 +26,14 @@ export struct TopNavigationComponent {
@Consume isLayoutFullScreen: boolean
@Consume bottomRectHeight: number
@Consume topRectHeight: number
@Consume @Watch('topOrBottomNavChange') currentBottomNavInfo: BottomNavDTO // 当前底导信息
@Consume barBackgroundColor: Color
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
@State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
@Link barBackgroundColor: Color
@Link _currentNavIndex?: number;
// 顶导当前选中/焦点下标
@State currentTopNavSelectedIndex: number = 0;
@State @Watch('topOrBottomNavChange') currentTopNavSelectedIndex: number = 0;
@State currentTopNavName: string = '';
// 顶导数据
@State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = []
@State compList: LazyDataSource<CompDTO> = new LazyDataSource();
... ... @@ -56,6 +58,21 @@ export struct TopNavigationComponent {
// 当前底导index
@State navIndex: number = 0
topOrBottomNavChange() {
if (this.currentBottomNavName === this.currentBottomNavInfo?.name) {
this.setBarBackgroundColor()
}
}
setBarBackgroundColor() {
console.error('setBarBackgroundColor', this.currentTopNavName, this.currentBottomNavInfo?.name)
if (this.currentTopNavName === '视频' && this.currentBottomNavInfo?.name === '视频') {
this.barBackgroundColor = Color.Black
} else {
this.barBackgroundColor = Color.White
}
}
//处理新闻tab顶导频道数据
topNavListHandle() {
let _channelIds: number [] = []
... ... @@ -126,10 +143,14 @@ export struct TopNavigationComponent {
this.channelIds = _channelIds
this.myChannelList = _myChannelList
this.currentTopNavName = this._currentNavIndex === 0 ? this.myChannelList[0].name : this.topNavList[0].name
//缓存首页频道
let index = this.myChannelList.findIndex(_item => _item.channelId === this.indexSettingChannelId)
if (index > -1) {
this.currentTopNavSelectedIndex = index
this.currentTopNavName = this.myChannelList[index].name
}
}
... ... @@ -196,7 +217,6 @@ export struct TopNavigationComponent {
groupId: this.groupId + '',
pageId: navItem.pageId + '',
channelId: navItem.channelId + '',
barBackgroundColor: $barBackgroundColor
})
} else
if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) {
... ... @@ -216,9 +236,10 @@ export struct TopNavigationComponent {
.barHeight($r('app.float.top_tab_bar_height'))
.barMode(BarMode.Scrollable)
.vertical(false)
// item.name === '视频' && this.currentTopNavSelectedIndex === 0 ?
.barBackgroundColor(this.barBackgroundColor)
.onChange((index: number) => {
this.currentTopNavName = this._currentNavIndex === 0 ? this.myChannelList[index].name : this.topNavList[index].name
Logger.info(TAG, `onChange index : ${index}`);
if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) &&
!this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])
... ... @@ -256,15 +277,11 @@ export struct TopNavigationComponent {
}
/**
* TODO:更详细的判断视频频道
* TODO:根据顶导配置获取颜色展示效果不对,待确认
*/
getFontColor(item: TopNavDTO, index: number): Color | string {
if (this._currentNavIndex === 2) {
if (this.currentTopNavSelectedIndex == 0) {
return item.name === '视频' ? Color.White : '#e5e0e0'
} else {
return this.currentTopNavSelectedIndex === index ? Color.Black : "#999999"
}
getTopNavFontColor(item: TopNavDTO, index: number): Color | string {
if (item.name === '视频' && this.currentBottomNavInfo.name === '视频') {
return this.currentTopNavSelectedIndex === index ? Color.White : '#e5e0e0'
} else {
return this.currentTopNavSelectedIndex === index ? Color.Black : "#999999"
}
... ... @@ -276,9 +293,10 @@ export struct TopNavigationComponent {
Text(item.name)
.fontSize($r('app.float.selected_text_size'))
.fontWeight(this.currentTopNavSelectedIndex === index ? FontWeight.Bold : FontWeight.Normal)
.fontColor(this.getFontColor(item, index))
.padding({ top: $r('app.float.top_tab_item_padding_top') , bottom: $r('app.float.top_tab_item_padding_bottom')})
.fontColor(this.getTopNavFontColor(item, index))
.padding({ top: $r('app.float.top_tab_item_padding_top'), bottom: $r('app.float.top_tab_item_padding_bottom') })
.maxLines(this.MAX_LINE)
// .backgroundImage(this.currentTopNavSelectedIndex === index ? item.iconCUrl : item.iconUrl)
if (this.currentTopNavSelectedIndex === index) {
Row()
.width(20)
... ... @@ -292,18 +310,20 @@ export struct TopNavigationComponent {
minWidth: $r('app.float.top_tab_item_min_width'),
maxWidth: $r('app.float.top_tab_item_max_width')
})
.backgroundColor(Color.Transparent)
// .backgroundColor(Color.Transparent)
.padding({
left: $r('app.float.top_tab_item_padding_horizontal'),
right: $r('app.float.top_tab_item_padding_horizontal'),
})
.id(`col_tabBar${index}`)
.margin({ right: this.myChannelList.length === index + 1 ? 36 : 0 })
}
aboutToAppear() {
//处理新闻tab顶导频道数据
this.topNavListHandle()
this.setBarBackgroundColor()
}
aboutToDisappear() {
... ...
... ... @@ -13,7 +13,10 @@ import router from '@ohos.router';
import inputMethod from '@ohos.inputMethod';
import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailViewModel';
import { LikeComponent } from './LikeComponent';
import { CommentCustomDialog } from '../comment/view/CommentCustomDialog';
import { CommentTabComponent, CommentIconComponent, } from '../comment/view/CommentTabComponent';
import { publishCommentModel } from '../comment/model/PublishCommentModel'
// import { CommentCustomDialog } from '../comment/view/CommentCustomDialog';
import { HttpUrlUtils } from 'wdNetwork/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { PageRepository } from '../../repository/PageRepository';
... ... @@ -38,6 +41,7 @@ export struct OperRowListView {
@State interactData: InteractDataDTO = {} as InteractDataDTO
@State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@State likeBean: Record<string, string> = {}
@State publishCommentModel: publishCommentModel = new publishCommentModel()
@State operationList: OperationItem[] = [
{
... ... @@ -81,13 +85,23 @@ export struct OperRowListView {
this.likeBean['channelId'] = this.contentDetailData.reLInfo?.channelId + ''
console.info(TAG, 'contentDetailData----', JSON.stringify(this.contentDetailData))
console.info(TAG, 'likeBean----', JSON.stringify(this.likeBean))
// 评论需要数据
this.publishCommentModel.targetId = this.contentDetailData.newsId + ''
this.publishCommentModel.targetRelId = this.contentDetailData.reLInfo?.relId + ''
this.publishCommentModel.targetTitle = this.contentDetailData.newsTitle + ''
this.publishCommentModel.targetRelType = this.contentDetailData.reLInfo?.relType + ''
this.publishCommentModel.targetRelObjectId = this.contentDetailData.reLInfo?.relObjectId + ''
this.publishCommentModel.keyArticle = this.contentDetailData.keyArticle + ''
this.publishCommentModel.targetType = this.contentDetailData.newsType + ''
this.publishCommentModel.totalCommentNumer = '10'
}
build() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems:ItemAlign.Center }){
Row() {
Column() {
Image($r('app.media.icon_arrow_left_white'))
// Image($r('app.media.icon_arrow_left_white'))
Image($r('app.media.icon_arrow_left'))
.width(24)
.height(24)
.aspectRatio(1)
... ... @@ -109,6 +123,10 @@ export struct OperRowListView {
/* CommentCustomDialog({
placeHolderText: '说两句'
})*/
if (this.publishCommentModel?.targetId) {
CommentTabComponent({publishCommentModel: this.publishCommentModel})
CommentIconComponent({publishCommentModel: this.publishCommentModel})
}
}
/*TextInput({placeholder:'说两句...'})
.placeholderColor('#999999')
... ... @@ -140,7 +158,8 @@ export struct OperRowListView {
}
.width('100%')
.height(50)
.backgroundColor(Color.Black)
// .backgroundColor(Color.Black)
.backgroundColor(Color.White)
.margin({
bottom: 20
})
... ...
... ... @@ -35,16 +35,8 @@ export class PageRepository {
}
static getPageInfoUrl(pageId: string) {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.PAGE_INFO_PATH;
// TODO 暂定只请求第一页,后续对接分页加载,参数再调整 first_load?
url = url + "?channelStrategy=2&loadStrategy=first_load"
+ "&districtCode=" + HttpUrlUtils.getDistrictCode()
+ "&provinceCode=" + HttpUrlUtils.getProvinceCode()
+ "&cityCode=" + HttpUrlUtils.getCityCode()
+ "&refreshTime=" + DateTimeUtils.getTimeStamp()
+ "&pageId=" + pageId
// Logger.debug("TAG", 'getCompInfoUrl url: '+url);
Logger.info(TAG, "getPageInfoUrl url = " + url)
let url = HttpUrlUtils.getHost() + HttpUrlUtils.PAGE_INFO_PATH + "?pageId=" + pageId;
// Logger.info(TAG, "getPageInfoUrl url = " + url)
return url;
}
... ... @@ -293,7 +285,7 @@ export class PageRepository {
static postExecuteLike(params: postExecuteLikeParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTELIKE
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
return WDHttp.post(url, params, headers)
}
/**
... ... @@ -304,7 +296,7 @@ export class PageRepository {
static postExecuteCollectRecord(params: postExecuteCollectRecordParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTECOLLECTRECORD
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
return WDHttp.post(url, params, headers)
}
/**
... ... @@ -314,7 +306,7 @@ export class PageRepository {
static getContentInteract(params: contentListParams): Promise<ResponseDTO<InteractDataDTO[]>> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
return WDHttp.post(url, params, headers)
}
// 浏览历史新增、删除接口
... ... @@ -331,7 +323,7 @@ export class PageRepository {
static fetchBatchAttentionStatus(params: postBatchAttentionStatusParams): Promise<ResponseDTO<postBatchAttentionStatusResult[]>> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.FOLLOW_LIST_STATUS_DATA_PATH
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
return WDHttp.post(url, params, headers)
}
/**
... ... @@ -340,7 +332,7 @@ export class PageRepository {
static postInteractAccentionOperate(params: postInteractAccentionOperateParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_ACCENTION_OPERATION
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
return WDHttp.post(url, params, headers)
}
static fetchNewspaperInfo(date: string) {
... ...
... ... @@ -245,7 +245,7 @@ export class ContentDetailRequest {
static getContentInteract(params: contentListParams): Promise<ResponseDTO<InteractDataDTO[]>> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
return WDHttp.post(url, params, headers)
}
/**
... ... @@ -255,7 +255,7 @@ export class ContentDetailRequest {
static postBatchLikeAndCollectStatus(params: batchLikeAndCollectParams): Promise<ResponseDTO<batchLikeAndCollectResult[]>> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_STATUS
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
return WDHttp.post(url, params, headers)
}
/**
... ... @@ -265,7 +265,7 @@ export class ContentDetailRequest {
static postBatchAttentionStatus(params: postBatchAttentionStatusParams): Promise<ResponseDTO<postBatchAttentionStatusResult[]>> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.FOLLOW_LIST_STATUS_DATA_PATH
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
return WDHttp.post(url, params, headers)
}
... ... @@ -277,7 +277,7 @@ export class ContentDetailRequest {
static postRecommendVideoList(params: recommentVideoListParams): Promise<ResponseDTO<ContentDetailDTO[]>> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.RECOMMEND_VIDEOLIST
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
return WDHttp.post(url, params, headers)
}
/**
... ... @@ -288,7 +288,7 @@ export class ContentDetailRequest {
static postExecuteLike(params: postExecuteLikeParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTELIKE
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
return WDHttp.post(url, params, headers)
}
/**
... ... @@ -299,7 +299,7 @@ export class ContentDetailRequest {
static postExecuteCollectRecord(params: postExecuteCollectRecordParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTECOLLECTRECORD
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
return WDHttp.post(url, params, headers)
}
/**
... ... @@ -309,7 +309,7 @@ export class ContentDetailRequest {
static postPointLevelOperate(params: postPointLevelOperateParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.USERPOINT_OPERATE
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
return WDHttp.post(url, params, headers)
}
/**
... ... @@ -318,7 +318,7 @@ export class ContentDetailRequest {
static postCommentPublish(params: postCommentPublishParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMMENT_PUBLISH
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
return WDHttp.post(url, params, headers)
}
... ... @@ -328,7 +328,7 @@ export class ContentDetailRequest {
static postInteractBrowsOperate(params: postInteractBrowsOperateParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_BROWS_OPERATE
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
return WDHttp.post(url, params, headers)
}
/**
... ... @@ -337,6 +337,6 @@ export class ContentDetailRequest {
static postInteractAccentionOperate(params: postInteractAccentionOperateParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_ACCENTION_OPERATION
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
return WDHttp.post(url, params, headers)
}
}
\ No newline at end of file
... ...
... ... @@ -32,15 +32,15 @@ export struct DetailPlayLivePage {
aboutToAppear(): void {
Logger.info(TAG, `wyj-aboutToAppear`)
// this.listener?.on("change", (mediaQueryResult) => {
// Logger.info(TAG, `change;${mediaQueryResult.matches}`)
// if (mediaQueryResult?.matches) {
// this.displayDirection = DisplayDirection.VIDEO_HORIZONTAL
// } else {
// this.displayDirection = DisplayDirection.VERTICAL
// }
// WindowModel.shared.setMainWindowFullScreen(this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL)
// })
this.listener?.on("change", (mediaQueryResult) => {
Logger.info(TAG, `change;${mediaQueryResult.matches}`)
if (mediaQueryResult?.matches) {
this.displayDirection = DisplayDirection.VIDEO_HORIZONTAL
} else {
this.displayDirection = DisplayDirection.VERTICAL
}
WindowModel.shared.setMainWindowFullScreen(this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL)
})
this.getLiveDetails()
this.getLiveRoomData()
}
... ... @@ -72,9 +72,8 @@ export struct DetailPlayLivePage {
onPageHideCus(): void {
Logger.info(TAG, `wyj-onPageHideCus`)
devicePLSensorManager.devicePLSensorOff();
// WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED);
this.playerController?.pause()
this.listener.off('change');
// devicePLSensorManager.devicePLSensorOff();
}
onBackPressCus(): boolean | void {
... ... @@ -86,9 +85,9 @@ export struct DetailPlayLivePage {
WindowModel.shared.setPreferredOrientation(this.displayDirection == DisplayDirection.VERTICAL ?
window.Orientation.PORTRAIT :
window.Orientation.LANDSCAPE)
devicePLSensorManager.devicePLSensorOn(this.displayDirection == DisplayDirection.VERTICAL ?
window.Orientation.PORTRAIT :
window.Orientation.LANDSCAPE);
// devicePLSensorManager.devicePLSensorOn(this.displayDirection == DisplayDirection.VERTICAL ?
// window.Orientation.PORTRAIT :
// window.Orientation.LANDSCAPE);
return true
}
... ...
... ... @@ -107,7 +107,7 @@ export struct DetailPlayVLivePage {
(data) => {
if (data.length > 0) {
this.liveDetailsBean = data[0]
this.liveState = 'end' // this.liveDetailsBean.liveInfo?.liveState //直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停
this.liveState = this.liveDetailsBean.liveInfo?.liveState //直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停
if (this.liveDetailsBean.fullColumnImgUrls && this.liveDetailsBean.fullColumnImgUrls.length > 0) {
this.imgUrl = this.liveDetailsBean.fullColumnImgUrls[0].url
}
... ...
... ... @@ -83,9 +83,9 @@ export struct TabLiveItemComponent {
//图文
if (this.item.dataType === 'ZH_TEXT_AND_IMAGE_MSG') {
List({ space: this.item.pictureUrls.length == 1 ? 0 : 5 }) {
ForEach(this.item.pictureUrls, (item: string, index: number) => {
ForEach(this.item.pictureUrls, (itemSub: string, index: number) => {
ListItem() {
Image(item)
Image(itemSub)
.width(`${100 / this.item.pictureUrls.length}%`)
.height(this.item.pictureUrls.length > 1 ? 70 : 174)
.objectFit(ImageFit.Auto)
... ...
import { window } from '@kit.ArkUI'
import { NumberFormatterUtils, WindowModel } from 'wdKit/Index'
import { devicePLSensorManager } from 'wdDetailPlayApi/Index'
import { DateFormatUtil, WDPlayerController } from 'wdPlayer/Index'
import { LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Index'
import { DisplayDirection } from 'wdConstant/Index'
... ... @@ -69,9 +68,9 @@ export struct PlayUIComponent {
WindowModel.shared.setPreferredOrientation(this.displayDirection == DisplayDirection.VERTICAL ?
window.Orientation.PORTRAIT :
window.Orientation.LANDSCAPE)
devicePLSensorManager.devicePLSensorOn(this.displayDirection == DisplayDirection.VERTICAL ?
window.Orientation.PORTRAIT :
window.Orientation.LANDSCAPE);
// devicePLSensorManager.devicePLSensorOn(this.displayDirection == DisplayDirection.VERTICAL ?
// window.Orientation.PORTRAIT :
// window.Orientation.LANDSCAPE);
})
if (this.liveDetailsBean.liveInfo?.liveState != 'wait') {
Text(this.liveDetailsBean.newsTitle)
... ... @@ -191,15 +190,12 @@ export struct PlayUIComponent {
@Builder
getMiddleUIComponent() {
Stack() {
Text('播放功能暂时关闭')
.fontColor(Color.White)
}.alignContent(Alignment.Center)
.layoutWeight(1)
.width('100%')
.onClick(() => {
this.isMenuVisible = !this.isMenuVisible
})
Stack()
.layoutWeight(1)
.width('100%')
.onClick(() => {
this.isMenuVisible = !this.isMenuVisible
})
}
@Builder
... ... @@ -238,9 +234,9 @@ export struct PlayUIComponent {
WindowModel.shared.setPreferredOrientation(this.displayDirection == DisplayDirection.VERTICAL ?
window.Orientation.PORTRAIT :
window.Orientation.LANDSCAPE)
devicePLSensorManager.devicePLSensorOn(this.displayDirection == DisplayDirection.VERTICAL ?
window.Orientation.PORTRAIT :
window.Orientation.LANDSCAPE);
// devicePLSensorManager.devicePLSensorOn(this.displayDirection == DisplayDirection.VERTICAL ?
// window.Orientation.PORTRAIT :
// window.Orientation.LANDSCAPE);
})
}
}
... ...
... ... @@ -13,7 +13,7 @@ export struct TopPlayComponent {
aboutToAppear(): void {
if (this.playerController) {
this.playerController.onCanplay = () => {
// this.playerController?.play()
this.playerController?.play()
}
}
}
... ... @@ -31,7 +31,7 @@ export struct TopPlayComponent {
} else if (this.liveDetailsBean.liveInfo.liveState == 'end') {
playUrl = this.liveDetailsBean.liveInfo.vlive[0].replayUri
}
// this.playerController?.firstPlay(playUrl);
this.playerController?.firstPlay(playUrl);
}
}
... ...
... ... @@ -133,7 +133,7 @@ export struct DetailPlayShortVideoPage {
aboutToAppear() {
this.videoLandScape = this.contentDetailData?.videoInfo[0]?.videoLandScape
this.playerController.onCanplay = () => {
if (this.index == 0 || this.currentIndex === this.index) {
if ((this.index == 0 || this.currentIndex === this.index) && this.switchVideoStatus) {
this.playerController.play()
}
}
... ...
... ... @@ -22,7 +22,7 @@ export struct DetailVideoListPage {
@Provide showComment: boolean = true
@Provide pageShow: number = -1
@Provide pageHide: number = -1
@Provide switchVideoStatus: boolean = false
@Provide switchVideoStatus: boolean = true
@State data: ContentDetailDTO[] = []
@State currentIndex: number = 0
@State interactDataList: InteractDataDTO[] = []
... ...
... ... @@ -38,13 +38,13 @@ export struct VideoChannelDetail {
// private recommend?: string = '' // 0.非推荐,1.推荐;
@Link @Watch('navIndexChange') bottomNavIndex: number
@Link @Watch('navIndexChange') topNavIndex: number
@Link barBackgroundColor: Color
@Consume barBackgroundColor: Color
private swiperController: SwiperController = new SwiperController()
@Provide showComment: boolean = false
@Provide windowWidth: number = AppStorage.get<number>('windowWidth') || 0
@Consume @Watch('pageShowChange') pageShow: number
@Consume @Watch('pageHideChange') pageHide: number
@Provide switchVideoStatus: boolean = false
@Provide switchVideoStatus: boolean = true
@State data: ContentDetailDTO[] = []
@State currentIndex: number = 0
@State interactDataList: InteractDataDTO[] = []
... ... @@ -72,11 +72,11 @@ export struct VideoChannelDetail {
navIndexChange() {
console.log('navIndexChange', this.bottomNavIndex, this.topNavIndex)
if (this.bottomNavIndex === 2 && this.topNavIndex === 0) {
this.barBackgroundColor = Color.Black
// this.barBackgroundColor = Color.Black
this.switchVideoStatus = true
this.openFullScreen()
} else {
this.barBackgroundColor = Color.Transparent
// this.barBackgroundColor = Color.Transparent
this.switchVideoStatus = false
this.closeFullScreen()
}
... ...
... ... @@ -12,9 +12,14 @@ import { WDPlayerController } from 'wdPlayer/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { SpConstants } from 'wdConstant/Index'
interface ILikeStyleResp {
url: Resource;
name: string;
}
const TAG = 'PlayerRightView';
//视频点播页右侧操作栏:点赞/收藏/评论/分享 竖着排列
@Component
export struct PlayerRightView {
... ... @@ -210,15 +215,26 @@ export struct PlayerRightView {
/**
* 将点赞样式转换为icon
*/
transLikeStyle2Icon(): Resource {
transLikeStyle(): ILikeStyleResp {
if (this.likesStyle === 1) {
return this.newsStatusOfUser.likeStatus === '1' ? $r(`app.media.ic_like_check`) : $r(`app.media.ic_like_uncheck`)
return {
url: this.newsStatusOfUser.likeStatus === '1' ? $r(`app.media.ic_like_check`) : $r(`app.media.ic_like_uncheck`),
name: '点赞'
}
} else if (this.likesStyle === 2) {
return this.newsStatusOfUser.likeStatus === '1' ? $r(`app.media.ic_thub_check`) : $r(`app.media.ic_thub_uncheck`)
return {
url: this.newsStatusOfUser.likeStatus === '1' ? $r(`app.media.ic_thub_check`) : $r(`app.media.ic_thub_uncheck`),
name: '祈祷'
}
} else if (this.likesStyle === 3) {
return this.newsStatusOfUser.likeStatus === '1' ? $r(`app.media.ic_candle_check`) : $r(`app.media.ic_candle_uncheck`)
return {
url: this.newsStatusOfUser.likeStatus === '1' ? $r(`app.media.ic_candle_check`) : $r(`app.media.ic_candle_uncheck`),
name: '默哀'
}
}
return {
url: $r(`app.media.icon_like_ckeck`), name: '点赞'
}
return $r(`app.media.icon_like_ckeck`)
}
transNum2String(name: 'likeNum' | 'collectNum' | 'commentNum') {
... ... @@ -238,14 +254,14 @@ export struct PlayerRightView {
@Builder
likeBuilderView() {
Column() {
Image(this.transLikeStyle2Icon())
Image(this.transLikeStyle().url)
.width(32)
.aspectRatio(1)
.onClick(() => {
// TODO:点赞动画
this.toggleLikeStatus()
})
Text(this.transNum2String('likeNum') || '赞')
Text(this.transNum2String('likeNum') || this.transLikeStyle().name)
.width('100%')
.fontWeight(500)
.textAlign(TextAlign.Center)
... ... @@ -253,6 +269,7 @@ export struct PlayerRightView {
.fontColor('#FFFFFF')
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 2 })
}
.margin({ bottom: 20 })
.visibility(this.likesStyle !== 4 ? Visibility.Visible : Visibility.None)
... ... @@ -278,6 +295,7 @@ export struct PlayerRightView {
.fontColor('#FFFFFF')
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 2 })
}
.margin({ bottom: 20 })
}
... ... @@ -302,6 +320,7 @@ export struct PlayerRightView {
.fontColor('#FFFFFF')
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 2 })
}
.margin({ bottom: 20 })
}
... ... @@ -326,6 +345,7 @@ export struct PlayerRightView {
.fontColor('#FFFFFF')
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 2 })
}
.margin({ bottom: 20 })
}
... ...
export { add } from "./src/main/ets/utils/Calc"
export { SettingPasswordParams } from "./src/main/ets/pages/login/SettingPasswordLayout"
\ No newline at end of file
export { SettingPasswordParams } from "./src/main/ets/pages/login/SettingPasswordLayout"
export { LoginModule } from './src/main/ets/LoginModule'
\ No newline at end of file
... ...
import HuaweiAuth from './utils/HuaweiAuth'
import { JumpInterceptorAction, RouterJumpInterceptor, WDRouterPage } from 'wdRouter'
import { BusinessError } from '@kit.BasicServicesKit'
import { router } from '@kit.ArkUI'
import { AccountManagerUtils } from 'wdKit/Index'
class LoginJumpHandler implements JumpInterceptorAction {
/// 说明是调用了跳转 WDRouterPage.loginPage 页面的行为
on(params?: object | undefined, singleMode?: boolean | undefined): boolean {
HuaweiAuth.sharedInstance().fetchAnonymousPhone().then((anonymousPhone) => {
router.pushUrl({url: WDRouterPage.oneKeyLoginPage.url()})
}).catch((error: string) => {
router.pushUrl({url: WDRouterPage.loginPage.url()})
})
return true
}
}
export class LoginModule {
static startup() {
/// 初始化华为一键登录相关
if (HuaweiAuth.enable) {
HuaweiAuth.sharedInstance().registerEvents()
AccountManagerUtils.isLogin().then((login) => {
if (!login) {
HuaweiAuth.sharedInstance().rePrefetchAnonymousPhone()
}
})
RouterJumpInterceptor.register(WDRouterPage.loginPage, new LoginJumpHandler())
}
}
}
\ No newline at end of file
... ...
... ... @@ -9,6 +9,10 @@ import { WDRouterPage } from 'wdRouter/src/main/ets/router/WDRouterPage';
import { WDRouterRule } from 'wdRouter/src/main/ets/router/WDRouterRule';
import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/src/main/ets/bean/content/Params'
import {InterestsHobbiesModel} from '../../../../../../../products/phone/src/main/ets/pages/viewModel/InterestsHobbiesModel'
import HuaweiAuth from '../../utils/HuaweiAuth'
import { loginComponentManager, LoginWithHuaweiIDButton } from '@hms.core.account.LoginComponent'
import { BusinessError } from '@ohos.base'
@Extend(Row)
function otherStyle() {
.backgroundImageSize(ImageSize.Cover)
... ... @@ -56,7 +60,6 @@ struct LoginPage {
})
loginViewModel = new LoginViewModel()
@State isProtocol:boolean=false
onCodeSend() {
Logger.debug(TAG, "isCodeSend:" + this.isCodeSend + "")
if (this.isCodeSend) {
... ...
... ... @@ -15,6 +15,7 @@ struct LoginProtocolWebview {
userProtocol = "https://cdnpeoplefrontuat.aikan.pdnews.cn/rmrb/rmrb-protocol-zh-web/0.0.1/app/protocol-1005.html"
privateProtocol = 'https://cdnpeoplefrontuat.aikan.pdnews.cn/rmrb/rmrb-protocol-zh-web/0.0.1/app/protocol-1001.html'
logoutProtocol = 'https://cdnpeoplefrontuat.aikan.pdnews.cn/rmrb/rmrb-protocol-zh-web/0.0.1/app/protocol-1003.html'
huaweiAuthProtocol = 'https://privacy.consumer.huawei.com/legal/id/authentication-terms.htm?code=CN&language=zh-CN'
async aboutToAppear() {
if (router.getParams()) {
... ... @@ -30,6 +31,9 @@ struct LoginProtocolWebview {
}else if(params.contentID == "3"){ //注销协议
this.webUrl = await SPHelper.default.get(SpConstants.LOGOUT_PROTOCOL, this.logoutProtocol) as string
this.webviewController.loadUrl(this.webUrl)
} else if(params.contentID == "4"){ //华为用户认证协议
this.webUrl = this.huaweiAuthProtocol
this.webviewController.loadUrl(this.webUrl)
}
}
... ...
import { router } from '@kit.ArkUI'
import { Params } from 'wdBean/Index'
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
import HuaweiAuth from '../../utils/HuaweiAuth'
import { BusinessError } from '@kit.BasicServicesKit'
@Entry
@Component
struct OneKeyLoginPage {
anonymousPhone: string = ''
@State agreeProtocol: boolean = false
aboutToAppear(): void {
this.anonymousPhone = HuaweiAuth.sharedInstance().anonymousPhone||""
}
build() {
Column() {
this.CloseRow()
Image($r("app.media.login_logo"))
.width(120)
.height(66)
.margin({ top: 78, bottom: 74})
.align(Alignment.Center)
Text(this.anonymousPhone)
.fontSize(30)
.fontWeight(600)
.fontColor("#222222")
.margin({bottom: 10})
.align(Alignment.Center)
this.ProtocolRow()
Row() {
Button("华为账号一键登录")
.type(ButtonType.Normal)
.height(48)
.backgroundColor(!this.agreeProtocol ? Color.Grey : Color.Red)
.width("100%")
.onClick((event) => {
if (!this.agreeProtocol) {
return
}
HuaweiAuth.sharedInstance().oneKeyLogin().then((authorizeCode) => {
//TODO: 调用服务端接口登录
}).catch((error: BusinessError) => {
})
})
}
.padding({ left: 25, right: 25 })
.margin({top: 15})
Button("其他手机号登录")
.type(ButtonType.Normal)
.align(Alignment.Center)
.foregroundColor("#666666")
.backgroundColor(Color.White)
.onClick((event) => {
router.replaceUrl({url: WDRouterPage.loginPage.url()})
})
}
}
@Builder ProtocolRow() {
Row({space: 4}) {
Image(this.agreeProtocol ? $r('app.media.login_checkbox_select') : $r('app.media.login_checkbox_unselected'))
.width(15)
.height(15)
.onClick(() => {
this.agreeProtocol = !this.agreeProtocol
})
Text() {
Span("我已阅读并同意").fontColor("#999999").fontSize(12)
Span("《用户协议》").fontColor("#ED2800").fontSize(12).onClick(() => {
let bean = { contentID: "1", pageID: "" } as Params
WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean)
})
Span("、").fontColor("#999999").fontSize(12)
Span("《隐私政策》").fontColor("#ED2800").fontSize(12).onClick(() => {
let bean = { contentID: "2", pageID: "" } as Params
WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean)
})
Span("和").fontColor("#999999").fontSize(12)
Span("《华为账号用户认证协议》").fontColor("#ED2800").fontSize(12).onClick(() => {
let bean = { contentID: "4", pageID: "" } as Params
WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean)
})
}
.layoutWeight(1)
}
.margin({top: 15})
.padding({ left: 25, right: 25 })
.width('100%')
}
@Builder CloseRow() {
Row() {
Blank()
Image($r('app.media.login_closed'))
.width(24)
.height(24)
.onClick(() => router.back())
}.margin({ top: 15, right: 15 })
.width("100%")
}
}
\ No newline at end of file
... ...
import { authentication, extendService } from '@kit.AccountKit';
import { AccountManagerUtils, EmitterEventId, EmitterUtils, Logger } from 'wdKit/Index';
import { util } from '@kit.ArkTS';
import { DEFAULT } from '@ohos/hypium';
import { BusinessError } from '@kit.BasicServicesKit';
const TAG = "HuaweiOneKeyAuth"
export default class HuaweiAuth {
// 是否开启
static enable = false
// 匿名手机号
private _anonymousPhone?: string
get anonymousPhone() {
return this._anonymousPhone
}
private static instance: HuaweiAuth
static sharedInstance(): HuaweiAuth {
if (!HuaweiAuth.instance) {
HuaweiAuth.instance = new HuaweiAuth()
}
return HuaweiAuth.instance
}
registerEvents() {
// 注册用户退出登录,取一次用来下次使用
EmitterUtils.receiveEvent(EmitterEventId.FORCE_USER_LOGIN_OUT, ((str?: string) => {
HuaweiAuth.sharedInstance().rePrefetchAnonymousPhone()
}))
EmitterUtils.receiveEvent(EmitterEventId.APP_ENTER_FOREGROUD, ((str?: string) => {
AccountManagerUtils.isLogin().then((login) => {
if (!login) {
HuaweiAuth.sharedInstance().rePrefetchAnonymousPhone()
}
})
}))
}
// 重新预取手机号(App启动未登录、回前台未登录、和退出登录 时调用提前取号)
rePrefetchAnonymousPhone() {
this._anonymousPhone = undefined
this.fetchAnonymousPhone()
}
// 要登录时,先调用。如果获取到手机号了 则弹起一键登录页面
fetchAnonymousPhone() : Promise<string> {
return new Promise((resolve, fail) => {
if (this.anonymousPhone) {
resolve(this.anonymousPhone)
return
}
let authRequest = new authentication.HuaweiIDProvider().createAuthorizationWithHuaweiIDRequest();
// 权限有 phone 、email、realTimePhone、quickLoginMobilePhone,这里用获取匿名手机号
authRequest.scopes = ['quickLoginAnonymousPhone'];
authRequest.state = util.generateRandomUUID();
authRequest.forceAuthorization = false;
let controller = new authentication.AuthenticationController(getContext(this));
try {
controller.executeRequest(authRequest).then((response: authentication.AuthorizationWithHuaweiIDResponse) => {
let anonymousPhone = response.data?.extraInfo?.quickLoginAnonymousPhone;
if (anonymousPhone) {
Logger.info(TAG, 'get anonymousPhone, ' + JSON.stringify(response));
this._anonymousPhone = anonymousPhone as string
resolve(this._anonymousPhone)
return;
}
Logger.info(TAG, 'get anonymousPhone is empty. ' + JSON.stringify(response));
fail("获取匿名手机号为空")
}).catch((err: BusinessError) => {
Logger.error(TAG, 'get anonymousPhone failed. ' + JSON.stringify(err));
fail("获取匿名手机号失败")
})
} catch (err) {
Logger.error(TAG, 'get anonymousPhone fail. ' + JSON.stringify(err));
fail("获取匿名手机号失败")
}
})
}
// 华为账号一键登录授权
// 返回结果为 Authorization Code
oneKeyLogin() : Promise<string> {
let loginRequest = new authentication.HuaweiIDProvider().createLoginWithHuaweiIDRequest();
// 当用户未登录华为帐号时,是否强制拉起华为帐号登录界面
loginRequest.forceLogin = true;
loginRequest.state = util.generateRandomUUID();
return new Promise((resolve, fail) => {
try {
let controller = new authentication.AuthenticationController(getContext(this));
controller.executeRequest(loginRequest, (err, data) => {
if (err) {
Logger.error(TAG, 'login fail, ' + JSON.stringify(err))
fail(err)
return;
}
let loginWithHuaweiIDResponse = data as authentication.LoginWithHuaweiIDResponse;
let state = loginWithHuaweiIDResponse.state;
if (state != undefined && loginRequest.state != state) {
Logger.error(TAG, 'login fail, The state is different' + JSON.stringify(loginWithHuaweiIDResponse))
fail({
code: 99999,
name: "一键登录",
message:"状态错误:" + `请求状态 ${loginRequest.state}, 结果状态 ${state}`
} as BusinessError)
return;
}
Logger.info(TAG, 'login success, ' + JSON.stringify(loginWithHuaweiIDResponse));
let loginWithHuaweiIDCredential = loginWithHuaweiIDResponse.data!;
let authorizationCode = loginWithHuaweiIDCredential.authorizationCode;
resolve(authorizationCode!)
});
} catch (error) {
Logger.error(TAG, 'login fail, ' + JSON.stringify(error))
fail(error)
}
});
}
// 打开账户中心
openAccountCenter() {
try {
extendService.startAccountCenter(getContext(this), (err, data) => {
if (err) {
Logger.info(TAG, 'startAccountCenterWithCallback fail,error: ' + JSON.stringify(err));
return;
}
Logger.info(TAG, 'startAccountCenterWithCallback success');
});
} catch (error) {
Logger.error(TAG, 'startAccountCenterWithCallback fail,error: ' + JSON.stringify(error));
}
}
}
... ...
... ... @@ -6,6 +6,7 @@
"pages/login/LoginProtocolWebview",
"pages/login/SettingPasswordPage",
"pages/login/SettingPasswordLayout",
"pages/guide/GuidePages"
"pages/guide/GuidePages",
"pages/login/OneKeyLoginPage"
]
}
... ...
... ... @@ -16,6 +16,7 @@
"wdRouter": "file:../../commons/wdRouter",
"wdNetwork": "file:../../commons/wdNetwork",
"wdHwAbility": "file:../../features/wdHwAbility",
"wdJsBridge": "file:../../commons/wdJsBridge"
"wdJsBridge": "file:../../commons/wdJsBridge",
"wdLogin": "file:../../features/wdLogin"
}
}
... ...
... ... @@ -15,12 +15,14 @@ import {
WindowModel
} from 'wdKit';
import { HostEnum, HostManager, WDHttp } from 'wdNetwork';
import { LoginModule } from 'wdLogin/src/main/ets/LoginModule';
export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
SPHelper.init(this.context);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
registerRouter();
LoginModule.startup()
NetworkManager.getInstance().init()
WDHttp.initHttpHeader()
const spHostUrl = SPHelper.default.getSync('hostUrl', '') as string
... ... @@ -94,10 +96,14 @@ export default class EntryAbility extends UIAbility {
onForeground(): void {
// Ability has brought to foreground
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
EmitterUtils.sendEmptyEvent(EmitterEventId.APP_ENTER_FOREGROUD)
}
onBackground(): void {
// Ability has back to background
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
EmitterUtils.sendEmptyEvent(EmitterEventId.APP_ENTER_BACKGROUD)
}
}
... ...
import { Action } from 'wdBean';
import { SpacialTopicPageComponent } from 'wdComponent'
import { CommonConstants } from 'wdConstant'
import { Logger } from 'wdKit'
import router from '@ohos.router';
const TAG = 'SpacialPage';
const TAG = 'SpacialTopicPage';
@Entry
@Component
... ... @@ -12,11 +13,11 @@ struct SpacialTopicPage {
build() {
Column() {
SpacialTopicPageComponent()
}
SpacialTopicPageComponent({ action: this.action })
}.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT)
}
pageTransition(){
pageTransition() {
// 定义页面进入时的效果,从右边侧滑入
PageTransitionEnter({ type: RouteType.None, duration: 300 })
.slide(SlideEffect.Right)
... ... @@ -25,7 +26,6 @@ struct SpacialTopicPage {
.slide(SlideEffect.Right)
}
aboutToAppear() {
Logger.info(TAG, 'aboutToAppear');
let action: Action = router.getParams() as Action
... ...
... ... @@ -28,7 +28,6 @@ struct DefaultWebPage {
isPageEnd: $isPageEnd
})
}
.padding({ bottom: 56 })
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
}
... ...
... ... @@ -34,6 +34,10 @@
]
}
],
"metadata": [{
"name": "client_id",
"value": "220837707901830144"
}],
"requestPermissions": [
{
"name": "ohos.permission.CAMERA",
... ... @@ -88,6 +92,6 @@
{
"name": "ohos.permission.INTERNET"
}
],
]
}
}
\ No newline at end of file
... ...