Showing
91 changed files
with
2567 additions
and
1269 deletions
| 1 | import { Action } from './Action'; | 1 | import { Action } from './Action'; |
| 2 | 2 | ||
| 3 | +interface IImgItem { | ||
| 4 | + pic: string | ||
| 5 | + width: number | ||
| 6 | + height: number | ||
| 7 | +} | ||
| 8 | + | ||
| 9 | +export interface IImgListData { | ||
| 10 | + imgIndex: number | ||
| 11 | + imgArr: IImgItem[] | ||
| 12 | +} | ||
| 13 | + | ||
| 3 | interface dataObject { | 14 | interface dataObject { |
| 4 | // dataSource: | 15 | // dataSource: |
| 5 | // 1、图文详情数据 | 16 | // 1、图文详情数据 |
| @@ -13,7 +24,7 @@ interface dataObject { | @@ -13,7 +24,7 @@ interface dataObject { | ||
| 13 | // 9、活动投稿 视频跳转 | 24 | // 9、活动投稿 视频跳转 |
| 14 | // 10、活动投稿 动态跳转 | 25 | // 10、活动投稿 动态跳转 |
| 15 | // 11、活动投稿 图集跳转 | 26 | // 11、活动投稿 图集跳转 |
| 16 | - dataSource: number | 27 | + dataSource: string |
| 17 | operateType?: string | 28 | operateType?: string |
| 18 | webViewHeight?: string | 29 | webViewHeight?: string |
| 19 | dataJson?: string | 30 | dataJson?: string |
| @@ -21,6 +32,13 @@ interface dataObject { | @@ -21,6 +32,13 @@ interface dataObject { | ||
| 21 | method?: string | 32 | method?: string |
| 22 | url?: string | 33 | url?: string |
| 23 | parameters?: object | 34 | parameters?: object |
| 35 | + videoUrl?: string | ||
| 36 | + positionWidth?: string | ||
| 37 | + positionHeight?: string | ||
| 38 | + positionLeft?: string | ||
| 39 | + positionTop?: string | ||
| 40 | + videoLandscape?: string | ||
| 41 | + imgListData?: string | ||
| 24 | } | 42 | } |
| 25 | 43 | ||
| 26 | /** | 44 | /** |
| @@ -6,41 +6,34 @@ import { SPHelper } from './SPHelper' | @@ -6,41 +6,34 @@ import { SPHelper } from './SPHelper' | ||
| 6 | import { StringUtils } from './StringUtils' | 6 | import { StringUtils } from './StringUtils' |
| 7 | 7 | ||
| 8 | export class UserDataLocal { | 8 | export class UserDataLocal { |
| 9 | - public static userId='' | ||
| 10 | - public static userType='' | ||
| 11 | - public static token='' | ||
| 12 | - public static userName='' | ||
| 13 | - | ||
| 14 | - public static userHeaderUrl='' | ||
| 15 | - public static userLevel = -1 | ||
| 16 | - public static userLevelHeaderUrl='' | 9 | + private static userId='' |
| 10 | + private static userType='' | ||
| 11 | + private static userName='' | ||
| 12 | + private static userHeaderUrl='' | ||
| 13 | + private static userLevel = -1 | ||
| 14 | + private static userLevelHeaderUrl='' | ||
| 17 | 15 | ||
| 18 | //先写死 | 16 | //先写死 |
| 19 | static USER_ID="userId" | 17 | static USER_ID="userId" |
| 20 | static USER_Type="userType" | 18 | static USER_Type="userType" |
| 21 | - static USER_JWT_TOKEN="jwtToken" | ||
| 22 | static USER_NAME="userName" | 19 | static USER_NAME="userName" |
| 23 | - | ||
| 24 | static USER_HEADER_URL="userHeaderUrl" | 20 | static USER_HEADER_URL="userHeaderUrl" |
| 25 | static USER_LEVEL="userLevel" | 21 | static USER_LEVEL="userLevel" |
| 26 | static USER_LEVEL_HEADER_URL="userLevelHeaderUrl" | 22 | static USER_LEVEL_HEADER_URL="userLevelHeaderUrl" |
| 27 | - static USER_FOLLOW_OPERATION="user_follow_operation" | ||
| 28 | - | ||
| 29 | - //刷新token 用到 | ||
| 30 | - static USER_REFRESH_TOKEN="refreshToken" | ||
| 31 | 23 | ||
| 24 | + static USER_FOLLOW_OPERATION="user_follow_operation" | ||
| 32 | 25 | ||
| 33 | /** | 26 | /** |
| 34 | * 清除 本地用户数据 | 27 | * 清除 本地用户数据 |
| 35 | */ | 28 | */ |
| 36 | public static clearUserData(){ | 29 | public static clearUserData(){ |
| 37 | - SPHelper.default.deleteSync(UserDataLocal.USER_ID) | ||
| 38 | - SPHelper.default.deleteSync(UserDataLocal.USER_Type) | ||
| 39 | - SPHelper.default.deleteSync(UserDataLocal.USER_JWT_TOKEN) //待确认 | ||
| 40 | - SPHelper.default.deleteSync(UserDataLocal.USER_NAME) | ||
| 41 | - SPHelper.default.deleteSync(UserDataLocal.USER_HEADER_URL) | ||
| 42 | - SPHelper.default.deleteSync(UserDataLocal.USER_LEVEL) | ||
| 43 | - SPHelper.default.deleteSync(UserDataLocal.USER_LEVEL_HEADER_URL) | 30 | + UserDataLocal.userId='' |
| 31 | + UserDataLocal.userType='' | ||
| 32 | + UserDataLocal.userName='' | ||
| 33 | + | ||
| 34 | + UserDataLocal.userHeaderUrl='' | ||
| 35 | + UserDataLocal.userLevel = -1 | ||
| 36 | + UserDataLocal.userLevelHeaderUrl='' | ||
| 44 | } | 37 | } |
| 45 | 38 | ||
| 46 | public static getUserId() { | 39 | public static getUserId() { |
| @@ -59,17 +52,6 @@ export class UserDataLocal { | @@ -59,17 +52,6 @@ export class UserDataLocal { | ||
| 59 | return UserDataLocal.userType; | 52 | return UserDataLocal.userType; |
| 60 | } | 53 | } |
| 61 | 54 | ||
| 62 | - private static getXToken() { | ||
| 63 | - if(StringUtils.isNotEmpty(UserDataLocal.token)){ | ||
| 64 | - return UserDataLocal.token | ||
| 65 | - } | ||
| 66 | - UserDataLocal.token = SPHelper.default.getSync(UserDataLocal.USER_JWT_TOKEN,"") as string | ||
| 67 | - if(StringUtils.isNotEmpty(UserDataLocal.token)) { | ||
| 68 | - return UserDataLocal.token | ||
| 69 | - } | ||
| 70 | - return 'eyJhbGciOiJIUzI1NiIsImtpZCI6ImQ4WkI2QkhxSEZrdjJ2U25BNlRwZEdKRjBHcjItVzBvS2FaYzdLOUUycmcifQ.eyJpc3MiOiJwZW9wbGVzLWRhaWx5LWZvdXJhIiwic3ViIjoicGVvcGxlcy1kYWlseS1mb3VyYSIsImV4cCI6MTcwMzY0OTYwNiwidXNlcklkIjo0NTk3NzYyOTc0NzQ5NDksInVzZXJWZXJzaW9uIjoiNDU5Nzc2Mjk3NDc0OTQ5XzIiLCJ1c2VyTmFtZSI6IkJ1bGlraWtpMTgxIiwidXNlclR5cGUiOjIsImNyZWF0b3JJZCI6NDI2NTM5MH0.jhQ9kylcm3FxWf0-lBMZuLkdtIQ6XpFnAi0AFZJNwfc'; | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | public static getUserName() { | 55 | public static getUserName() { |
| 74 | if(StringUtils.isNotEmpty(UserDataLocal.userName)){ | 56 | if(StringUtils.isNotEmpty(UserDataLocal.userName)){ |
| 75 | return UserDataLocal.userName | 57 | return UserDataLocal.userName |
| @@ -118,4 +100,5 @@ export class UserDataLocal { | @@ -118,4 +100,5 @@ export class UserDataLocal { | ||
| 118 | public static setUserLevelHeaderUrl(url:string) { | 100 | public static setUserLevelHeaderUrl(url:string) { |
| 119 | SPHelper.default.save(UserDataLocal.USER_LEVEL_HEADER_URL, url) | 101 | SPHelper.default.save(UserDataLocal.USER_LEVEL_HEADER_URL, url) |
| 120 | } | 102 | } |
| 103 | + | ||
| 121 | } | 104 | } |
| @@ -8,3 +8,5 @@ export { HttpUrlUtils } from "./src/main/ets/http/HttpUrlUtils" | @@ -8,3 +8,5 @@ export { HttpUrlUtils } from "./src/main/ets/http/HttpUrlUtils" | ||
| 8 | 8 | ||
| 9 | export { HttpBizUtil } from "./src/main/ets/http/HttpBizUtil" | 9 | export { HttpBizUtil } from "./src/main/ets/http/HttpBizUtil" |
| 10 | 10 | ||
| 11 | +export { HostEnum, HostManager } from "./src/main/ets/http/HttpHostManager" | ||
| 12 | + |
| 1 | +import { SpConstants } from 'wdConstant'; | ||
| 2 | +import { SPHelper, StringUtils } from 'wdKit'; | ||
| 3 | +import { HostEnum, HostManager } from './HttpHostManager'; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 网络请求参数工具类 | ||
| 7 | + */ | ||
| 8 | +export class HttpParams { | ||
| 9 | + private static userId = '' | ||
| 10 | + private static userType = '' | ||
| 11 | + private static token = '' | ||
| 12 | + | ||
| 13 | + static buildHeaders(): Record<string, string> { | ||
| 14 | + let headers: Record<string, string> = {}; | ||
| 15 | + // 通用请求头 | ||
| 16 | + headers['User-Agent'] = 'Dalvik/2.1.0 (Linux; U; Android 13; 22101317C Build/TKQ1.221013.002)' | ||
| 17 | + headers['channel'] = HttpParams.getChannel() | ||
| 18 | + headers['plat'] = HttpParams.getPlat() | ||
| 19 | + headers['Content-Type'] = 'application/json; charset=utf-8' | ||
| 20 | + headers['timestamp'] = HttpParams.getTimestamp() | ||
| 21 | + headers['RMRB-X-TOKEN'] = HttpParams.getXToken() | ||
| 22 | + headers['device_id'] = HttpParams.getDeviceId() | ||
| 23 | + if (HttpParams.getXToken() != '') { | ||
| 24 | + headers['cookie'] = 'RMRB-X-TOKEN=' + HttpParams.getXToken() | ||
| 25 | + } | ||
| 26 | + headers['build_version'] = HttpParams.getVersion() | ||
| 27 | + headers['adcode'] = HttpParams.getAdCode() | ||
| 28 | + headers['os_version'] = HttpParams.getOsVersion() | ||
| 29 | + headers['versionCode'] = HttpParams.getVersionCode() | ||
| 30 | + headers['system'] = HttpParams.getTerminalId() | ||
| 31 | + headers['version_name'] = HttpParams.getVersionName() | ||
| 32 | + headers['EagleEye-TraceID'] = 'D539562E48554A60977AF4BECB6D6C7A' | ||
| 33 | + headers['imei'] = HttpParams.getImei() | ||
| 34 | + headers['Accept-Language'] = 'zh' | ||
| 35 | + HttpParams.setLocationHeader(headers) | ||
| 36 | + // // TODO 判断是否登录 | ||
| 37 | + headers['userId'] = HttpParams.getUserId() | ||
| 38 | + headers['userType'] = HttpParams.getUserType() | ||
| 39 | + // | ||
| 40 | + headers['mpassid'] = 'ZbHTMeTsfaYDAHqt8ZHIzcPs' | ||
| 41 | + HttpParams.addSpecialHeaders(headers); | ||
| 42 | + return headers; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + static addSpecialHeaders(headers: Record<string, string>) { | ||
| 46 | + switch (HostManager.getHost()) { | ||
| 47 | + case HostEnum.HOST_UAT: | ||
| 48 | + headers['X-Ca-Stage'] = 'PRE' | ||
| 49 | + headers['Authorization'] = 'APPCODE 83092caa603a421aa0222308b3f6b27a' | ||
| 50 | + headers['appCode'] = '83092caa603a421aa0222308b3f6b27a' | ||
| 51 | + break | ||
| 52 | + case HostEnum.HOST_SIT: | ||
| 53 | + headers['X-Ca-Stage'] = 'TEST' | ||
| 54 | + headers['Authorization'] = 'APPCODE 0af1f9085e484c97b2a44704bae72c07' | ||
| 55 | + headers['appCode'] = '0af1f9085e484c97b2a44704bae72c07' | ||
| 56 | + break | ||
| 57 | + case HostEnum.HOST_PRODUCT: | ||
| 58 | + headers['X-Ca-Stage'] = 'RELEASE' | ||
| 59 | + headers['Authorization'] = 'APPCODE 3d4181bceeb94d9780e10dbb6c67bbf6' | ||
| 60 | + headers['appCode'] = '3d4181bceeb94d9780e10dbb6c67bbf6' | ||
| 61 | + break | ||
| 62 | + case HostEnum.HOST_DEV: | ||
| 63 | + headers['X-Ca-Stage'] = 'TEST' | ||
| 64 | + headers['Authorization'] = 'APPCODE ff33172859e14f9a8299e3bd769e79f9' | ||
| 65 | + headers['appCode'] = 'ff33172859e14f9a8299e3bd769e79f9' | ||
| 66 | + break | ||
| 67 | + default: | ||
| 68 | + break | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + static setLocationHeader(headers: Record<string, string>) { | ||
| 73 | + let cityName = SPHelper.default.getSync(SpConstants.LOCATION_CITY_NAME, '') as string | ||
| 74 | + if (StringUtils.isNotEmpty(cityName)) { | ||
| 75 | + headers['city'] = encodeURI(cityName) | ||
| 76 | + } | ||
| 77 | + let cityCode = SPHelper.default.getSync(SpConstants.LOCATION_CITY_CODE, '') as string | ||
| 78 | + if (StringUtils.isNotEmpty(cityCode)) { | ||
| 79 | + headers['city_dode'] = encodeURI(cityCode) | ||
| 80 | + } | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + private static getCity() { | ||
| 84 | + // TODO 对接定位 | ||
| 85 | + return '%E5%90%88%E8%82%A5%E5%B8%82'; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + private static getChannel() { | ||
| 89 | + // TODO 对接配置 | ||
| 90 | + return 'rmrb_china_0000'; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + private static getPlat() { | ||
| 94 | + return 'Phone'; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + private static getTimestamp() { | ||
| 98 | + // return DateTimeUtils.getCurrentTime() + ''; | ||
| 99 | + // TODO 暂时写死,有些page 真实时间戳 返回数据为空 | ||
| 100 | + return '155203523'; | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + private static getXToken() { | ||
| 104 | + if (StringUtils.isNotEmpty(HttpParams.token)) { | ||
| 105 | + return HttpParams.token | ||
| 106 | + } | ||
| 107 | + HttpParams.token = SPHelper.default.getSync(SpConstants.USER_JWT_TOKEN, "") as string | ||
| 108 | + if (StringUtils.isNotEmpty(HttpParams.token)) { | ||
| 109 | + return HttpParams.token | ||
| 110 | + } | ||
| 111 | + // return 'eyJhbGciOiJIUzI1NiIsImtpZCI6ImQ4WkI2QkhxSEZrdjJ2U25BNlRwZEdKRjBHcjItVzBvS2FaYzdLOUUycmcifQ.eyJpc3MiOiJwZW9wbGVzLWRhaWx5LWZvdXJhIiwic3ViIjoicGVvcGxlcy1kYWlseS1mb3VyYSIsImV4cCI6MTcwMzY0OTYwNiwidXNlcklkIjo0NTk3NzYyOTc0NzQ5NDksInVzZXJWZXJzaW9uIjoiNDU5Nzc2Mjk3NDc0OTQ5XzIiLCJ1c2VyTmFtZSI6IkJ1bGlraWtpMTgxIiwidXNlclR5cGUiOjIsImNyZWF0b3JJZCI6NDI2NTM5MH0.jhQ9kylcm3FxWf0-lBMZuLkdtIQ6XpFnAi0AFZJNwfc'; | ||
| 112 | + return '' | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + static getRefreshToken(): string { | ||
| 116 | + let refreshToken = SPHelper.default.getSync(SpConstants.USER_REFRESH_TOKEN, "") | ||
| 117 | + if (StringUtils.isNotEmpty(refreshToken)) { | ||
| 118 | + return refreshToken as string; | ||
| 119 | + } | ||
| 120 | + return ''; | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + public static getDeviceId() { | ||
| 124 | + // TODO | ||
| 125 | + return '8a81226a-cabd-3e1b-b630-b51db4a720ed'; | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + private static getVersion() { | ||
| 129 | + // TODO | ||
| 130 | + return '202401242103'; | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + private static getVersionCode() { | ||
| 134 | + // TODO | ||
| 135 | + return '7301'; | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + private static getVersionName() { | ||
| 139 | + // TODO | ||
| 140 | + return '7.3.0.1'; | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + private static getAdCode() { | ||
| 144 | + return '340000'; | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + private static getOsVersion() { | ||
| 148 | + // TODO | ||
| 149 | + return '12'; | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + public static getCityCode() { | ||
| 153 | + // TODO | ||
| 154 | + return '340100'; | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + public static getProvinceCode() { | ||
| 158 | + // TODO | ||
| 159 | + return '340000'; | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + /** | ||
| 163 | + * 地区code | ||
| 164 | + */ | ||
| 165 | + public static getDistrictCode() { | ||
| 166 | + // TODO | ||
| 167 | + return '340103'; | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + private static getTerminalId() { | ||
| 171 | + return 'Android'; | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + public static getImei() { | ||
| 175 | + // TODO | ||
| 176 | + return '8a81226a-cabd-3e1b-b630-b51db4a720ed'; | ||
| 177 | + } | ||
| 178 | + | ||
| 179 | + public static getUserId(): string { | ||
| 180 | + // TODO 对接登录 | ||
| 181 | + if (StringUtils.isNotEmpty(HttpParams.userId)) { | ||
| 182 | + return HttpParams.userId | ||
| 183 | + } | ||
| 184 | + HttpParams.userId = SPHelper.default.getSync(SpConstants.USER_ID, "") as string | ||
| 185 | + return HttpParams.userId; | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + public static getUserType() { | ||
| 189 | + if (StringUtils.isNotEmpty(HttpParams.userType)) { | ||
| 190 | + return HttpParams.userType | ||
| 191 | + } | ||
| 192 | + HttpParams.userType = SPHelper.default.getSync(SpConstants.USER_Type, "") as string | ||
| 193 | + return HttpParams.userType; | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + public static setUserId(userId: string) { | ||
| 197 | + HttpParams.userId = userId; | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + public static setUserType(userType: string) { | ||
| 201 | + HttpParams.userType = userType; | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + public static setUserToken(token: string) { | ||
| 205 | + HttpParams.token = token; | ||
| 206 | + } | ||
| 207 | +} |
| 1 | +export enum HostEnum { | ||
| 2 | + /** | ||
| 3 | + * uat环境url | ||
| 4 | + */ | ||
| 5 | + HOST_UAT = 'https://pd-apis-uat.pdnews.cn', | ||
| 6 | + /** | ||
| 7 | + * 中文端sit环境 | ||
| 8 | + */ | ||
| 9 | + HOST_SIT = 'https://pd-apis-sit.pdnews.cn', | ||
| 10 | + /** | ||
| 11 | + * dev环境url | ||
| 12 | + */ | ||
| 13 | + HOST_DEV = 'https://pd-apis-dev.pdnews.cn', | ||
| 14 | + /** | ||
| 15 | + * 正式环境url | ||
| 16 | + */ | ||
| 17 | + HOST_PRODUCT = 'https://pdapis.pdnews.cn', | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * 环境host管理工具类 | ||
| 22 | + */ | ||
| 23 | +export class HostManager { | ||
| 24 | + private static _hostUrl: HostEnum = HostEnum.HOST_PRODUCT; | ||
| 25 | + | ||
| 26 | + static changeHost(host: HostEnum) { | ||
| 27 | + HostManager._hostUrl = host; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + static getHost(): string { | ||
| 31 | + return HostManager._hostUrl; | ||
| 32 | + } | ||
| 33 | +} |
| 1 | import ArrayList from '@ohos.util.ArrayList'; | 1 | import ArrayList from '@ohos.util.ArrayList'; |
| 2 | import service from './AxiosRequest'; | 2 | import service from './AxiosRequest'; |
| 3 | -import { HttpUtils } from '../utils/HttpUtils'; | ||
| 4 | import { AxiosError, AxiosHeaders, AxiosRequestConfig, RawAxiosRequestHeaders } from '@ohos/axios'; | 3 | import { AxiosError, AxiosHeaders, AxiosRequestConfig, RawAxiosRequestHeaders } from '@ohos/axios'; |
| 5 | import { ResponseDTO } from '../bean/ResponseDTO'; | 4 | import { ResponseDTO } from '../bean/ResponseDTO'; |
| 6 | import HashMap from '@ohos.util.HashMap'; | 5 | import HashMap from '@ohos.util.HashMap'; |
| 6 | +import { HttpParams } from './HttpCommonParams'; | ||
| 7 | 7 | ||
| 8 | export class HttpRequest { | 8 | export class HttpRequest { |
| 9 | private static globalHeaderProviders: ArrayList<() => Record<string, string>> = new ArrayList(); | 9 | private static globalHeaderProviders: ArrayList<() => Record<string, string>> = new ArrayList(); |
| @@ -14,7 +14,7 @@ export class HttpRequest { | @@ -14,7 +14,7 @@ export class HttpRequest { | ||
| 14 | 14 | ||
| 15 | static initHttpHeader() { | 15 | static initHttpHeader() { |
| 16 | HttpRequest.addGlobalHeaderProvider(() => { | 16 | HttpRequest.addGlobalHeaderProvider(() => { |
| 17 | - return HttpUtils.buildHeaders(); | 17 | + return HttpParams.buildHeaders(); |
| 18 | }) | 18 | }) |
| 19 | } | 19 | } |
| 20 | 20 | ||
| @@ -34,15 +34,17 @@ export class HttpRequest { | @@ -34,15 +34,17 @@ export class HttpRequest { | ||
| 34 | 34 | ||
| 35 | static buildHeaderWithGlobalHeader(headers?: HashMap<string, string>): AxiosHeaders { | 35 | static buildHeaderWithGlobalHeader(headers?: HashMap<string, string>): AxiosHeaders { |
| 36 | let commonHeader: AxiosHeaders = new AxiosHeaders() | 36 | let commonHeader: AxiosHeaders = new AxiosHeaders() |
| 37 | - headers?.forEach((v, k) => { | ||
| 38 | - commonHeader.set(k, v); | ||
| 39 | - }); | 37 | + |
| 40 | HttpRequest.globalHeaderProviders.forEach((func) => { | 38 | HttpRequest.globalHeaderProviders.forEach((func) => { |
| 41 | let headers = func(); | 39 | let headers = func(); |
| 42 | for (const obj of Object.entries(headers)) { | 40 | for (const obj of Object.entries(headers)) { |
| 43 | commonHeader.set(obj[0], obj[1]); | 41 | commonHeader.set(obj[0], obj[1]); |
| 44 | } | 42 | } |
| 45 | }) | 43 | }) |
| 44 | + // 业务headers,覆盖common(如果有冲突的话,取业务) | ||
| 45 | + headers?.forEach((v, k) => { | ||
| 46 | + commonHeader.set(k, v); | ||
| 47 | + }); | ||
| 46 | if (!commonHeader.get('Content-Type')) { | 48 | if (!commonHeader.get('Content-Type')) { |
| 47 | commonHeader.set('Content-Type', 'application/json;charset=utf-8'); | 49 | commonHeader.set('Content-Type', 'application/json;charset=utf-8'); |
| 48 | } | 50 | } |
| @@ -56,24 +58,13 @@ export class HttpRequest { | @@ -56,24 +58,13 @@ export class HttpRequest { | ||
| 56 | return service.get(url, config) | 58 | return service.get(url, config) |
| 57 | } | 59 | } |
| 58 | 60 | ||
| 59 | - static post0<T = ResponseDTO<string>>(url: string, data?: object, headers?: HashMap<string, string>): Promise<T> { | 61 | + static post<T = ResponseDTO<string>>(url: string, data?: object, headers?: HashMap<string, string>): Promise<T> { |
| 60 | let config: AxiosRequestConfig = { | 62 | let config: AxiosRequestConfig = { |
| 61 | headers: HttpRequest.buildHeaderWithGlobalHeader(headers) | 63 | headers: HttpRequest.buildHeaderWithGlobalHeader(headers) |
| 62 | } | 64 | } |
| 63 | return service.post(url, data, config) | 65 | return service.post(url, data, config) |
| 64 | } | 66 | } |
| 65 | 67 | ||
| 66 | - static post<T = object>(url: string, data1?: object, headers?: HashMap<string, string>): Promise<T> { | ||
| 67 | - let requestHeaders: AxiosHeaders = new AxiosHeaders() | ||
| 68 | - headers?.forEach((v, k) => { | ||
| 69 | - requestHeaders.set(k, v); | ||
| 70 | - }); | ||
| 71 | - let config: AxiosRequestConfig = { | ||
| 72 | - headers: requestHeaders as RawAxiosRequestHeaders, | ||
| 73 | - } | ||
| 74 | - return service.post(url, data1, config) | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | static put<T = ResponseDTO<string>>(url: string, data?: object, headers?: HashMap<string, string>): Promise<T> { | 68 | static put<T = ResponseDTO<string>>(url: string, data?: object, headers?: HashMap<string, string>): Promise<T> { |
| 78 | let config: AxiosRequestConfig = { | 69 | let config: AxiosRequestConfig = { |
| 79 | headers: HttpRequest.buildHeaderWithGlobalHeader(headers) | 70 | headers: HttpRequest.buildHeaderWithGlobalHeader(headers) |
| 1 | import HashMap from '@ohos.util.HashMap'; | 1 | import HashMap from '@ohos.util.HashMap'; |
| 2 | import { SpConstants } from 'wdConstant'; | 2 | import { SpConstants } from 'wdConstant'; |
| 3 | import { SPHelper, StringUtils } from 'wdKit'; | 3 | import { SPHelper, StringUtils } from 'wdKit'; |
| 4 | +import { HostEnum, HostManager } from './HttpHostManager'; | ||
| 4 | 5 | ||
| 5 | /** | 6 | /** |
| 6 | * 网络请求业务侧工具类 | 7 | * 网络请求业务侧工具类 |
| 7 | */ | 8 | */ |
| 8 | export class HttpUrlUtils { | 9 | export class HttpUrlUtils { |
| 9 | /** | 10 | /** |
| 10 | - * uat环境url | ||
| 11 | - */ | ||
| 12 | - static readonly HOST_UAT: string = "https://pd-apis-uat.pdnews.cn"; | ||
| 13 | - /** | ||
| 14 | - * 中文端sit环境 | ||
| 15 | - */ | ||
| 16 | - static readonly HOST_SIT: string = "https://pd-apis-sit.pdnews.cn"; | ||
| 17 | - /** | ||
| 18 | - * 正式环境url | ||
| 19 | - */ | ||
| 20 | - static readonly HOST_PRODUCT: string = "https://pdapis.pdnews.cn"; | ||
| 21 | - /** | ||
| 22 | - * dev环境url | ||
| 23 | - */ | ||
| 24 | - static readonly HOST_DEV: string = "https://pd-apis-dev.pdnews.cn"; | ||
| 25 | - /** | ||
| 26 | * 启动接口(底导接口) | 11 | * 启动接口(底导接口) |
| 27 | */ | 12 | */ |
| 28 | static readonly BOTTOM_NAV_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup"; | 13 | static readonly BOTTOM_NAV_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup"; |
| @@ -293,21 +278,14 @@ export class HttpUrlUtils { | @@ -293,21 +278,14 @@ export class HttpUrlUtils { | ||
| 293 | * 获取启动页相关数据 | 278 | * 获取启动页相关数据 |
| 294 | */ | 279 | */ |
| 295 | static readonly LAUNCH_PAGE_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/launchPage"; | 280 | static readonly LAUNCH_PAGE_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/launchPage"; |
| 296 | - private static _hostUrl: string = HttpUrlUtils.HOST_PRODUCT; | ||
| 297 | /** | 281 | /** |
| 298 | * 推荐列表 | 282 | * 推荐列表 |
| 299 | */ | 283 | */ |
| 300 | static readonly RECOMMEND_LIST: string = "/api/rmrb-bff-display-zh/recommend/zh/c/list"; | 284 | static readonly RECOMMEND_LIST: string = "/api/rmrb-bff-display-zh/recommend/zh/c/list"; |
| 301 | - | ||
| 302 | /** | 285 | /** |
| 303 | * 搜索推荐 | 286 | * 搜索推荐 |
| 304 | */ | 287 | */ |
| 305 | static readonly SEARCH_SUGGEST_DATA_PATH: string = "/api/rmrb-bff-display-zh/recommend/zh/c/list"; | 288 | static readonly SEARCH_SUGGEST_DATA_PATH: string = "/api/rmrb-bff-display-zh/recommend/zh/c/list"; |
| 306 | - | ||
| 307 | - public static set hostUrl(value: string) { | ||
| 308 | - HttpUrlUtils._hostUrl = value; | ||
| 309 | - } | ||
| 310 | - | ||
| 311 | private static userId = '' | 289 | private static userId = '' |
| 312 | private static userType = '' | 290 | private static userType = '' |
| 313 | private static token = '' | 291 | private static token = '' |
| @@ -354,24 +332,24 @@ export class HttpUrlUtils { | @@ -354,24 +332,24 @@ export class HttpUrlUtils { | ||
| 354 | } | 332 | } |
| 355 | 333 | ||
| 356 | static addSpecialHeaders(headers: HashMap<string, string>) { | 334 | static addSpecialHeaders(headers: HashMap<string, string>) { |
| 357 | - switch (HttpUrlUtils._hostUrl) { | ||
| 358 | - case HttpUrlUtils.HOST_UAT: | 335 | + switch (HostManager.getHost()) { |
| 336 | + case HostEnum.HOST_UAT: | ||
| 359 | // TODO 待优化到常量类里 | 337 | // TODO 待优化到常量类里 |
| 360 | headers.set('X-Ca-Stage', 'PRE'); | 338 | headers.set('X-Ca-Stage', 'PRE'); |
| 361 | headers.set('Authorization', 'APPCODE 83092caa603a421aa0222308b3f6b27a'); | 339 | headers.set('Authorization', 'APPCODE 83092caa603a421aa0222308b3f6b27a'); |
| 362 | headers.set('appCode', '83092caa603a421aa0222308b3f6b27a'); | 340 | headers.set('appCode', '83092caa603a421aa0222308b3f6b27a'); |
| 363 | break | 341 | break |
| 364 | - case HttpUrlUtils.HOST_SIT: | 342 | + case HostEnum.HOST_SIT: |
| 365 | headers.set('X-Ca-Stage', 'TEST'); | 343 | headers.set('X-Ca-Stage', 'TEST'); |
| 366 | headers.set('Authorization', 'APPCODE 0af1f9085e484c97b2a44704bae72c07'); | 344 | headers.set('Authorization', 'APPCODE 0af1f9085e484c97b2a44704bae72c07'); |
| 367 | headers.set('appCode', '0af1f9085e484c97b2a44704bae72c07'); | 345 | headers.set('appCode', '0af1f9085e484c97b2a44704bae72c07'); |
| 368 | break | 346 | break |
| 369 | - case HttpUrlUtils.HOST_PRODUCT: | 347 | + case HostEnum.HOST_PRODUCT: |
| 370 | headers.set('X-Ca-Stage', 'RELEASE'); | 348 | headers.set('X-Ca-Stage', 'RELEASE'); |
| 371 | headers.set('Authorization', 'APPCODE 3d4181bceeb94d9780e10dbb6c67bbf6'); | 349 | headers.set('Authorization', 'APPCODE 3d4181bceeb94d9780e10dbb6c67bbf6'); |
| 372 | headers.set('appCode', '3d4181bceeb94d9780e10dbb6c67bbf6'); | 350 | headers.set('appCode', '3d4181bceeb94d9780e10dbb6c67bbf6'); |
| 373 | break | 351 | break |
| 374 | - case HttpUrlUtils.HOST_DEV: | 352 | + case HostEnum.HOST_DEV: |
| 375 | headers.set('X-Ca-Stage', 'TEST'); | 353 | headers.set('X-Ca-Stage', 'TEST'); |
| 376 | headers.set('Authorization', 'APPCODE ff33172859e14f9a8299e3bd769e79f9'); | 354 | headers.set('Authorization', 'APPCODE ff33172859e14f9a8299e3bd769e79f9'); |
| 377 | headers.set('appCode', 'ff33172859e14f9a8299e3bd769e79f9'); | 355 | headers.set('appCode', 'ff33172859e14f9a8299e3bd769e79f9'); |
| @@ -392,8 +370,8 @@ export class HttpUrlUtils { | @@ -392,8 +370,8 @@ export class HttpUrlUtils { | ||
| 392 | } | 370 | } |
| 393 | } | 371 | } |
| 394 | 372 | ||
| 395 | - static getHost() { | ||
| 396 | - return HttpUrlUtils._hostUrl; | 373 | + static getHost(): string { |
| 374 | + return HostManager.getHost(); | ||
| 397 | } | 375 | } |
| 398 | 376 | ||
| 399 | private static getCity() { | 377 | private static getCity() { |
| @@ -487,7 +465,7 @@ export class HttpUrlUtils { | @@ -487,7 +465,7 @@ export class HttpUrlUtils { | ||
| 487 | return 'Android'; | 465 | return 'Android'; |
| 488 | } | 466 | } |
| 489 | 467 | ||
| 490 | - public static getImei() { | 468 | + public static getImei() { |
| 491 | // TODO | 469 | // TODO |
| 492 | return '8a81226a-cabd-3e1b-b630-b51db4a720ed'; | 470 | return '8a81226a-cabd-3e1b-b630-b51db4a720ed'; |
| 493 | } | 471 | } |
| @@ -510,48 +488,48 @@ export class HttpUrlUtils { | @@ -510,48 +488,48 @@ export class HttpUrlUtils { | ||
| 510 | } | 488 | } |
| 511 | 489 | ||
| 512 | static getVerifyCodeUrl() { | 490 | static getVerifyCodeUrl() { |
| 513 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/auth/zh/c/sendVerifyCode"; | 491 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/auth/zh/c/sendVerifyCode"; |
| 514 | return url; | 492 | return url; |
| 515 | } | 493 | } |
| 516 | 494 | ||
| 517 | static getVerifyCodeByTokenUrl() { | 495 | static getVerifyCodeByTokenUrl() { |
| 518 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/sendVerifyCodeByToken"; | 496 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/user/zh/c/sendVerifyCodeByToken"; |
| 519 | return url; | 497 | return url; |
| 520 | } | 498 | } |
| 521 | 499 | ||
| 522 | static getCheckVerifyCodeByToken() { | 500 | static getCheckVerifyCodeByToken() { |
| 523 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/checkVerifyCodeByToken"; | 501 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/user/zh/c/checkVerifyCodeByToken"; |
| 524 | return url; | 502 | return url; |
| 525 | } | 503 | } |
| 526 | 504 | ||
| 527 | 505 | ||
| 528 | static getForgetPasswordUrl() { | 506 | static getForgetPasswordUrl() { |
| 529 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/forgotPassword"; | 507 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/user/zh/c/forgotPassword"; |
| 530 | return url; | 508 | return url; |
| 531 | } | 509 | } |
| 532 | 510 | ||
| 533 | static getLogoutUrl() { | 511 | static getLogoutUrl() { |
| 534 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/appLogout"; | 512 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/user/zh/c/appLogout"; |
| 535 | return url; | 513 | return url; |
| 536 | } | 514 | } |
| 537 | 515 | ||
| 538 | static getRefreshTokenUrl() { | 516 | static getRefreshTokenUrl() { |
| 539 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.REFRESH_TOKEN_PATH; | 517 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.REFRESH_TOKEN_PATH; |
| 540 | return url; | 518 | return url; |
| 541 | } | 519 | } |
| 542 | 520 | ||
| 543 | static getResetPassworddUrl() { | 521 | static getResetPassworddUrl() { |
| 544 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/resetPassword"; | 522 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/user/zh/c/resetPassword"; |
| 545 | return url; | 523 | return url; |
| 546 | } | 524 | } |
| 547 | 525 | ||
| 548 | static queryUserDetail() { | 526 | static queryUserDetail() { |
| 549 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/queryUserDetail"; | 527 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/user/zh/c/queryUserDetail"; |
| 550 | return url; | 528 | return url; |
| 551 | } | 529 | } |
| 552 | 530 | ||
| 553 | static editUserDetail() { | 531 | static editUserDetail() { |
| 554 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/editUserDetail"; | 532 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/user/zh/c/editUserDetail"; |
| 555 | return url; | 533 | return url; |
| 556 | } | 534 | } |
| 557 | 535 | ||
| @@ -561,308 +539,315 @@ export class HttpUrlUtils { | @@ -561,308 +539,315 @@ export class HttpUrlUtils { | ||
| 561 | } | 539 | } |
| 562 | 540 | ||
| 563 | static getCheckVerifyCodeUrl() { | 541 | static getCheckVerifyCodeUrl() { |
| 564 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/auth/zh/c/checkVerifyCode"; | 542 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/auth/zh/c/checkVerifyCode"; |
| 565 | return url; | 543 | return url; |
| 566 | } | 544 | } |
| 567 | 545 | ||
| 568 | static getAgreement() { | 546 | static getAgreement() { |
| 569 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-bff-display-zh/display/zh/c/agreement"; | 547 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-bff-display-zh/display/zh/c/agreement"; |
| 570 | return url; | 548 | return url; |
| 571 | } | 549 | } |
| 572 | 550 | ||
| 573 | static getCheckVerifyByTokenCodeUrl() { | 551 | static getCheckVerifyByTokenCodeUrl() { |
| 574 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/auth/zh/c/checkVerifyCodeByToken"; | 552 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/auth/zh/c/checkVerifyCodeByToken"; |
| 575 | return url; | 553 | return url; |
| 576 | } | 554 | } |
| 577 | 555 | ||
| 578 | 556 | ||
| 579 | /*优质评论页*/ | 557 | /*优质评论页*/ |
| 580 | static getQualityCommentUrl() { | 558 | static getQualityCommentUrl() { |
| 581 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-comment/comment/zh/c/highQuality"; | 559 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-comment/comment/zh/c/highQuality"; |
| 582 | 560 | ||
| 583 | return url | 561 | return url |
| 584 | } | 562 | } |
| 585 | 563 | ||
| 586 | /*获取详情页评论列表*/ | 564 | /*获取详情页评论列表*/ |
| 587 | static getContentCommentListDataUrl() { | 565 | static getContentCommentListDataUrl() { |
| 588 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-comment/comment/zh/c/contentCommentList" | 566 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-comment/comment/zh/c/contentCommentList" |
| 589 | return url | 567 | return url |
| 590 | } | 568 | } |
| 591 | 569 | ||
| 592 | /*获取子评论列表*/ | 570 | /*获取子评论列表*/ |
| 593 | static getChildContentCommentListDataUrl() { | 571 | static getChildContentCommentListDataUrl() { |
| 594 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-comment/comment/zh/c/childCommentList" | 572 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-comment/comment/zh/c/childCommentList" |
| 595 | return url | 573 | return url |
| 596 | } | 574 | } |
| 597 | 575 | ||
| 598 | /*评论状态*/ | 576 | /*评论状态*/ |
| 599 | static getBatchCommentStatusUrl() { | 577 | static getBatchCommentStatusUrl() { |
| 600 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-comment/comment/zh/c/batchCommentStatus" | 578 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-comment/comment/zh/c/batchCommentStatus" |
| 601 | return url | 579 | return url |
| 602 | } | 580 | } |
| 603 | 581 | ||
| 604 | /*评论点赞*/ | 582 | /*评论点赞*/ |
| 605 | static getCommentLikeUrl() { | 583 | static getCommentLikeUrl() { |
| 606 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-comment/comment/zh/c/commentLike" | 584 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-comment/comment/zh/c/commentLike" |
| 607 | return url | 585 | return url |
| 608 | } | 586 | } |
| 609 | 587 | ||
| 610 | /*发布评论*/ | 588 | /*发布评论*/ |
| 611 | static getPublishCommentUrl() { | 589 | static getPublishCommentUrl() { |
| 612 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-comment/comment/zh/c/publish" | 590 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-comment/comment/zh/c/publish" |
| 613 | return url | 591 | return url |
| 614 | } | 592 | } |
| 615 | 593 | ||
| 616 | /*游客发布评论*/ | 594 | /*游客发布评论*/ |
| 617 | static getNoUserPublishCommentUrl() { | 595 | static getNoUserPublishCommentUrl() { |
| 618 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-comment/comment/zh/c/commentLike" | 596 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-comment/comment/zh/c/commentLike" |
| 619 | return url | 597 | return url |
| 620 | } | 598 | } |
| 621 | 599 | ||
| 622 | /*levleIcon*/ | 600 | /*levleIcon*/ |
| 623 | static getBatchUserUrl() { | 601 | static getBatchUserUrl() { |
| 624 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-point/auth/level/zh/c/batchUser" | 602 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-user-point/auth/level/zh/c/batchUser" |
| 625 | return url | 603 | return url |
| 626 | } | 604 | } |
| 627 | 605 | ||
| 628 | /*authIcon 20个一次上限*/ | 606 | /*authIcon 20个一次上限*/ |
| 629 | static getDetailListUrl() { | 607 | static getDetailListUrl() { |
| 630 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-contact/contact/zh/c/master/detailList" | 608 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-contact/contact/zh/c/master/detailList" |
| 631 | return url | 609 | return url |
| 632 | } | 610 | } |
| 633 | 611 | ||
| 634 | 612 | ||
| 635 | //账户注销 | 613 | //账户注销 |
| 636 | static accountLogoutUrl() { | 614 | static accountLogoutUrl() { |
| 637 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/logoff"; | 615 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/user/zh/c/logoff"; |
| 638 | return url; | 616 | return url; |
| 639 | } | 617 | } |
| 640 | 618 | ||
| 641 | //更换手机号绑定 | 619 | //更换手机号绑定 |
| 642 | static changeBindPhone() { | 620 | static changeBindPhone() { |
| 643 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/userPhoneChange"; | 621 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/user/zh/c/userPhoneChange"; |
| 644 | return url; | 622 | return url; |
| 645 | } | 623 | } |
| 646 | 624 | ||
| 647 | //获取用户安全页信息 | 625 | //获取用户安全页信息 |
| 648 | static querySecurity() { | 626 | static querySecurity() { |
| 649 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/security/query"; | 627 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/user/zh/c/security/query"; |
| 650 | return url; | 628 | return url; |
| 651 | } | 629 | } |
| 652 | 630 | ||
| 653 | static getAppointmentListDataUrl() { | 631 | static getAppointmentListDataUrl() { |
| 654 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.APPOINTMENT_LIST_DATA_PATH | 632 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.APPOINTMENT_LIST_DATA_PATH |
| 655 | return url | 633 | return url |
| 656 | } | 634 | } |
| 657 | 635 | ||
| 658 | static getMyCollectionListDataUrl() { | 636 | static getMyCollectionListDataUrl() { |
| 659 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.APPOINTMENT_MyCollectionList_PATH | 637 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.APPOINTMENT_MyCollectionList_PATH |
| 660 | return url | 638 | return url |
| 661 | } | 639 | } |
| 662 | 640 | ||
| 663 | static getExecuteCollcetUrl() { | 641 | static getExecuteCollcetUrl() { |
| 664 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.APPOINTMENT_ExecuteCollcet_PATH | 642 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.APPOINTMENT_ExecuteCollcet_PATH |
| 665 | return url | 643 | return url |
| 666 | } | 644 | } |
| 667 | 645 | ||
| 668 | static getFollowListDetailDataUrl() { | 646 | static getFollowListDetailDataUrl() { |
| 669 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.FOLLOW_LIST_DETAIL_DATA_PATH | 647 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.FOLLOW_LIST_DETAIL_DATA_PATH |
| 670 | return url | 648 | return url |
| 671 | } | 649 | } |
| 672 | 650 | ||
| 673 | static getFollowListDataUrl() { | 651 | static getFollowListDataUrl() { |
| 674 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.FOLLOW_LIST_DATA_PATH | 652 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.FOLLOW_LIST_DATA_PATH |
| 675 | return url | 653 | return url |
| 676 | } | 654 | } |
| 677 | 655 | ||
| 678 | static getMineFollowListDataUrl() { | 656 | static getMineFollowListDataUrl() { |
| 679 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.MINE_FOLLOW_LIST_DATA_PATH | 657 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.MINE_FOLLOW_LIST_DATA_PATH |
| 680 | return url | 658 | return url |
| 681 | } | 659 | } |
| 682 | 660 | ||
| 683 | static getFollowListStatusDataUrl() { | 661 | static getFollowListStatusDataUrl() { |
| 684 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.FOLLOW_LIST_STATUS_DATA_PATH | 662 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.FOLLOW_LIST_STATUS_DATA_PATH |
| 685 | return url | 663 | return url |
| 686 | } | 664 | } |
| 687 | 665 | ||
| 688 | static getCommentListStatusDataUrl() { | 666 | static getCommentListStatusDataUrl() { |
| 689 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.COMMENT_LIST_STATUS_DATA_PATH | 667 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMMENT_LIST_STATUS_DATA_PATH |
| 690 | return url | 668 | return url |
| 691 | } | 669 | } |
| 692 | 670 | ||
| 693 | static getMineCommentListDataUrl() { | 671 | static getMineCommentListDataUrl() { |
| 694 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.MINE_COMMENT_LIST_DATA_PATH | 672 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.MINE_COMMENT_LIST_DATA_PATH |
| 695 | return url | 673 | return url |
| 696 | } | 674 | } |
| 697 | 675 | ||
| 698 | static getMineUserLevelDataUrl() { | 676 | static getMineUserLevelDataUrl() { |
| 699 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.MINE_USER_LEVEL_DATA_PATH | 677 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.MINE_USER_LEVEL_DATA_PATH |
| 700 | return url | 678 | return url |
| 701 | } | 679 | } |
| 702 | 680 | ||
| 703 | static getOtherUserLevelDataUrl() { | 681 | static getOtherUserLevelDataUrl() { |
| 704 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.OTHER_USER_LEVEL_DATA_PATH | 682 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.OTHER_USER_LEVEL_DATA_PATH |
| 705 | return url | 683 | return url |
| 706 | } | 684 | } |
| 707 | 685 | ||
| 708 | static getMineUserDetailDataUrl() { | 686 | static getMineUserDetailDataUrl() { |
| 709 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.MINE_USER_DETAIL_DATA_PATH | 687 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.MINE_USER_DETAIL_DATA_PATH |
| 710 | return url | 688 | return url |
| 711 | } | 689 | } |
| 712 | 690 | ||
| 713 | static getOtherUserDetailDataUrl() { | 691 | static getOtherUserDetailDataUrl() { |
| 714 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.OTHER_USER_DETAIL_DATA_PATH | 692 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.OTHER_USER_DETAIL_DATA_PATH |
| 715 | return url | 693 | return url |
| 716 | } | 694 | } |
| 717 | 695 | ||
| 718 | static getOtherCommentListDataUrl() { | 696 | static getOtherCommentListDataUrl() { |
| 719 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.OTHER_COMMENT_LIST_DATA_PATH | 697 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.OTHER_COMMENT_LIST_DATA_PATH |
| 720 | return url | 698 | return url |
| 721 | } | 699 | } |
| 722 | 700 | ||
| 723 | static getOtherUserFollowListDataUrl() { | 701 | static getOtherUserFollowListDataUrl() { |
| 724 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.OTHER_USER_FOLLOW_LIST_DATA_PATH | 702 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.OTHER_USER_FOLLOW_LIST_DATA_PATH |
| 725 | return url | 703 | return url |
| 726 | } | 704 | } |
| 727 | 705 | ||
| 728 | static getAppointmentOperationUrl() { | 706 | static getAppointmentOperationUrl() { |
| 729 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.APPOINTMENT_OPERATION_STATUS_PATH | 707 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.APPOINTMENT_OPERATION_STATUS_PATH |
| 730 | return url | 708 | return url |
| 731 | } | 709 | } |
| 732 | 710 | ||
| 733 | static getCommentLikeOperationUrl() { | 711 | static getCommentLikeOperationUrl() { |
| 734 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.COMMENT_LIKE_OPERATION_PATH | 712 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMMENT_LIKE_OPERATION_PATH |
| 735 | return url | 713 | return url |
| 736 | } | 714 | } |
| 737 | 715 | ||
| 738 | static getFollowOperationUrl() { | 716 | static getFollowOperationUrl() { |
| 739 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.FOLLOW_OPERATION_PATH | 717 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.FOLLOW_OPERATION_PATH |
| 740 | return url | 718 | return url |
| 741 | } | 719 | } |
| 742 | 720 | ||
| 743 | static getSearchHintDataUrl() { | 721 | static getSearchHintDataUrl() { |
| 744 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_HINT_DATA_PATH | 722 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.SEARCH_HINT_DATA_PATH |
| 745 | return url | 723 | return url |
| 746 | } | 724 | } |
| 747 | 725 | ||
| 748 | static getSearchHotsDataUrl() { | 726 | static getSearchHotsDataUrl() { |
| 749 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_HOTS_DATA_PATH | 727 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.SEARCH_HOTS_DATA_PATH |
| 750 | return url | 728 | return url |
| 751 | } | 729 | } |
| 752 | 730 | ||
| 753 | static getRelatedSearchContentDataUrl() { | 731 | static getRelatedSearchContentDataUrl() { |
| 754 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.RELATED_SEARCH_CONTENT_DATA_PATH | 732 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.RELATED_SEARCH_CONTENT_DATA_PATH |
| 755 | return url | 733 | return url |
| 756 | } | 734 | } |
| 757 | 735 | ||
| 758 | static getInterestsUrl() { | 736 | static getInterestsUrl() { |
| 759 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.INTERESTS_HOTS_DATA_PATH; | 737 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERESTS_HOTS_DATA_PATH; |
| 760 | return url; | 738 | return url; |
| 761 | 739 | ||
| 762 | } | 740 | } |
| 763 | 741 | ||
| 764 | static getUpdateInterestsUrl() { | 742 | static getUpdateInterestsUrl() { |
| 765 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.INTERESTS_UPDATETAG_PATH; | 743 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERESTS_UPDATETAG_PATH; |
| 766 | return url; | 744 | return url; |
| 767 | } | 745 | } |
| 768 | 746 | ||
| 769 | static getLaunchPageDataUrl() { | 747 | static getLaunchPageDataUrl() { |
| 770 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LAUNCH_PAGE_PATH; | 748 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.LAUNCH_PAGE_PATH; |
| 771 | return url; | 749 | return url; |
| 772 | 750 | ||
| 773 | } | 751 | } |
| 774 | 752 | ||
| 775 | static getLiveDetailsUrl() { | 753 | static getLiveDetailsUrl() { |
| 776 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_DETAILS_PATH | 754 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_DETAILS_PATH |
| 777 | return url | 755 | return url |
| 778 | } | 756 | } |
| 779 | 757 | ||
| 780 | static getLiveListUrl() { | 758 | static getLiveListUrl() { |
| 781 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_LIST_PATH | 759 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_LIST_PATH |
| 782 | return url | 760 | return url |
| 783 | } | 761 | } |
| 784 | 762 | ||
| 785 | static getLiveChatListUrl() { | 763 | static getLiveChatListUrl() { |
| 786 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_CHAT_LIST_PATH | 764 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_CHAT_LIST_PATH |
| 787 | return url | 765 | return url |
| 788 | } | 766 | } |
| 789 | 767 | ||
| 790 | static getLiveRoomDataUrl() { | 768 | static getLiveRoomDataUrl() { |
| 791 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_ROOM_DATA_PATH | 769 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_ROOM_DATA_PATH |
| 792 | return url | 770 | return url |
| 793 | } | 771 | } |
| 794 | 772 | ||
| 795 | static getLiveAppointmentStatusUrl() { | 773 | static getLiveAppointmentStatusUrl() { |
| 796 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_APPOINTMENT_STATUS_PATH | 774 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_APPOINTMENT_STATUS_PATH |
| 797 | return url | 775 | return url |
| 798 | } | 776 | } |
| 799 | 777 | ||
| 800 | static getLiveAppointmentUrl() { | 778 | static getLiveAppointmentUrl() { |
| 801 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_APPOINTMENT_PATH | 779 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_APPOINTMENT_PATH |
| 802 | return url | 780 | return url |
| 803 | } | 781 | } |
| 804 | 782 | ||
| 805 | static getAppointmentStatusUrl() { | 783 | static getAppointmentStatusUrl() { |
| 806 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_APPOINTMENT_BATCH_PATH | 784 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_APPOINTMENT_BATCH_PATH |
| 807 | return url | 785 | return url |
| 808 | } | 786 | } |
| 809 | 787 | ||
| 810 | static getSearchResultCountDataUrl() { | 788 | static getSearchResultCountDataUrl() { |
| 811 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_RESULT_COUNT_DATA_PATH | 789 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.SEARCH_RESULT_COUNT_DATA_PATH |
| 812 | return url | 790 | return url |
| 813 | } | 791 | } |
| 814 | 792 | ||
| 815 | static getSearchResultListDataUrl() { | 793 | static getSearchResultListDataUrl() { |
| 816 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_RESULT_LIST_DATA_PATH | 794 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.SEARCH_RESULT_LIST_DATA_PATH |
| 817 | return url | 795 | return url |
| 818 | } | 796 | } |
| 819 | 797 | ||
| 820 | static getInteractListDataUrl() { | 798 | static getInteractListDataUrl() { |
| 821 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.INTERACT_DATA_PATH | 799 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH |
| 822 | return url | 800 | return url |
| 823 | } | 801 | } |
| 824 | 802 | ||
| 825 | static getCreatorDetailListDataUrl() { | 803 | static getCreatorDetailListDataUrl() { |
| 826 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.CREATOR_DETAIL_LIST_DATA_PATH | 804 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.CREATOR_DETAIL_LIST_DATA_PATH |
| 827 | return url | 805 | return url |
| 828 | } | 806 | } |
| 829 | 807 | ||
| 830 | static getArticleCountHotsDataUrl() { | 808 | static getArticleCountHotsDataUrl() { |
| 831 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.ARTICLE_COUNT_HOTS_DATA_PATH | 809 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.ARTICLE_COUNT_HOTS_DATA_PATH |
| 832 | return url | 810 | return url |
| 833 | } | 811 | } |
| 834 | 812 | ||
| 835 | static getArticleListHotsDataUrl() { | 813 | static getArticleListHotsDataUrl() { |
| 836 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.ARTICLE_LIST_HOTS_DATA_PATH | 814 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.ARTICLE_LIST_HOTS_DATA_PATH |
| 837 | return url | 815 | return url |
| 838 | } | 816 | } |
| 839 | 817 | ||
| 840 | static getCreatorInfluenceInfoHotsDataUrl() { | 818 | static getCreatorInfluenceInfoHotsDataUrl() { |
| 841 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.CREATOR_INFLUENCE_HOTS_DATA_PATH | 819 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.CREATOR_INFLUENCE_HOTS_DATA_PATH |
| 842 | return url | 820 | return url |
| 843 | } | 821 | } |
| 844 | 822 | ||
| 845 | //点赞 | 823 | //点赞 |
| 846 | static executeLike() { | 824 | static executeLike() { |
| 847 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-interact/interact/zh/c/like/executeLike"; | 825 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-interact/interact/zh/c/like/executeLike"; |
| 848 | return url; | 826 | return url; |
| 849 | } | 827 | } |
| 850 | 828 | ||
| 851 | //获取点赞状态 | 829 | //获取点赞状态 |
| 852 | static getLikeStatus() { | 830 | static getLikeStatus() { |
| 853 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-interact/interact/zh/c/batchLikeAndCollect/status"; | 831 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-interact/interact/zh/c/batchLikeAndCollect/status"; |
| 854 | return url; | 832 | return url; |
| 855 | } | 833 | } |
| 856 | 834 | ||
| 835 | + //获取点赞数 | ||
| 836 | + static getLikeCount() { | ||
| 837 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-contact/contact/zh/c/v2/content/interactData"; | ||
| 838 | + return url; | ||
| 839 | + } | ||
| 840 | + | ||
| 841 | + | ||
| 857 | //搜索推荐 | 842 | //搜索推荐 |
| 858 | static getSearchSuggestDataUrl() { | 843 | static getSearchSuggestDataUrl() { |
| 859 | - let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_SUGGEST_DATA_PATH | 844 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.SEARCH_SUGGEST_DATA_PATH |
| 860 | return url | 845 | return url |
| 861 | } | 846 | } |
| 862 | 847 | ||
| 863 | //金刚位聚合页 | 848 | //金刚位聚合页 |
| 864 | static getThemeListUrl() { | 849 | static getThemeListUrl() { |
| 865 | - let url = HttpUrlUtils._hostUrl + "/api/rmrb-bff-display-zh/display/zh/c/themeList"; | 850 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-bff-display-zh/display/zh/c/themeList"; |
| 866 | return url; | 851 | return url; |
| 867 | } | 852 | } |
| 868 | 853 |
| 1 | -// import { ResponseLogin } from '../bean/account/ResponseLogin'; | ||
| 2 | -import { Logger } from 'wdKit'; | ||
| 3 | - | ||
| 4 | -// import { UserInfo } from '../bean/account/UserInfo'; | ||
| 5 | -// import { ConfigConstants } from '../constants/ConfigConstants'; | ||
| 6 | -// import { AccountManagerUtils } from './AccountManagerUtils'; | ||
| 7 | -// import { AppUtils } from './AppUtils'; | ||
| 8 | -// import { DeviceUtil } from './DeviceUtil'; | ||
| 9 | -// import { Logger } from './Logger'; | ||
| 10 | -// import { StringUtils } from './StringUtils'; | 1 | +import { HttpRequest } from '../http/HttpRequest'; |
| 11 | 2 | ||
| 12 | const TAG: string = '[HttpUtils]' | 3 | const TAG: string = '[HttpUtils]' |
| 13 | 4 | ||
| 14 | export class HttpUtils { | 5 | export class HttpUtils { |
| 15 | - static buildHeaders(): Record<string, string> { | ||
| 16 | - let timestamp: number = new Date().getTime(); // 单位毫秒 | ||
| 17 | - // let clientId = DeviceUtil.clientId() | ||
| 18 | - | ||
| 19 | - let headers: Record<string, string> = {}; | ||
| 20 | - // 通用请求头 | ||
| 21 | - headers["version"] = 'V3'; | ||
| 22 | - // headers["appId"] = ConfigConstants.appId; // 应用id | ||
| 23 | - // headers["terminalId"] = ConfigConstants.terminalId; // 终端ID | ||
| 24 | - // headers["sourceId"] = ConfigConstants.sourceId; // 咪咕视频 | ||
| 25 | - // headers["appType"] = ConfigConstants.appType; // 手机客户端App(安卓) | ||
| 26 | - // headers["clientType"] = ConfigConstants.clientType; // 客户端类型 | ||
| 27 | - // headers["appVersion"] = AppUtils.getAppVersionCode() + ''; // 客户端版本号:2600010500 | ||
| 28 | - // headers["APP-VERSION-CODE"] = AppUtils.getAppVersionCode() + ''; // APP版本号:250006577 | ||
| 29 | - // headers["appVersionName"] = AppUtils.getAppVersionName() // app对外显示版本: '6.1.5.00' | ||
| 30 | - // headers["appCode"] = ConfigConstants.appCode; // 应用编码:产品_渠道_应用的拼接串,用下划线_ 拼接而成 | ||
| 31 | - // headers["ptvCode"] = ConfigConstants.ptvCode; // 基线版本号_应用版本号 todo: | ||
| 32 | - // headers["clientProvinceCode"] = ''; // 客户端分省号 // 02 | ||
| 33 | - // headers["provinceCode"] = ''; // 客户端分省号 // 02 | ||
| 34 | - // headers["clientCityId"] = ''; // 客户端城市ID // 0210 | ||
| 35 | - // headers["carrierCode"] = ''; // 运营商信息 | ||
| 36 | - | ||
| 37 | - // 设备信息请求头 | ||
| 38 | - // headers["User-Agent"] = ''; // 终端UA,自动获取 | ||
| 39 | - headers["Content-Type"] = 'application/json;charset=UTF-8'; // 返回/响应的HTTP内容类型 | ||
| 40 | - headers["os"] = 'android'; // 操作系统类型:鸿蒙、安卓或iOS | ||
| 41 | - // headers["osInfo"] = 'AD'; // 操作系统信息 | ||
| 42 | - headers["Phone-Info"] = 'HUAWEI'; // 手机信息: todo | ||
| 43 | - // headers["oaid"] = ''; // 开放匿名设备ID,是中国移动安全联盟(MSA)发起并制定标准用户识别ID | ||
| 44 | - headers["networkInfo"] = 'WIFI'; // 网络类型: todo | ||
| 45 | - headers["cache-control"] = 'no-cache'; // 请求和响应遵循的缓存机制 | ||
| 46 | - // headers["clientId"] = clientId; // 客户端编号:客户端初始化时生成的客户端ID,保证唯一性 | ||
| 47 | - headers["imei"] = 'd1de6d3ae0db44bea1b3f0e20a14d90a'; // 终端手机序列号: todo | ||
| 48 | - headers["X-UP-CLIENT-CHANNEL-ID"] = '2600010500-99000-101700010130012'; // 客户端渠道ID: todo | ||
| 49 | - headers["channelCode"] = 'VIDEO_APPMAIL'; // 渠道编码 | ||
| 50 | - // headers["l_c"] = clientId; // 客户端id,同clientId | ||
| 51 | - // headers["l_t"] = timestamp + ''; // 本机时间戳 | ||
| 52 | - // headers["l_s"] = ''; // l_c和l_t拼接后的MD5校验 | ||
| 53 | - | ||
| 54 | - // 签名相关请求头 | ||
| 55 | - headers["timeStamp"] = timestamp + ''; // 服务端时间戳(毫秒):1701667763664 | ||
| 56 | - headers["signType"] = 'RSA'; // 签名类型,固定RSA | 6 | + /** |
| 7 | + * 添加公共参数,如登录后,添加登录信息 | ||
| 8 | + */ | ||
| 9 | + static addCommonHeader() { | ||
| 10 | + HttpRequest.addGlobalHeaderProvider(() => { | ||
| 11 | + let headers: Record<string, string> = {}; | ||
| 12 | + return headers; | ||
| 13 | + }) | ||
| 14 | + } | ||
| 57 | 15 | ||
| 58 | - // 业务请求头 | ||
| 59 | - // headers["promotionID"] = '54b0f421-a6df-41d3-9be2-92820b2c5d8c'; // 促销Id todo | ||
| 60 | - // headers["tenantId"] = ''; // 租户Id | 16 | + /** |
| 17 | + * 添加公共参数,如登出后,移除登录信息 | ||
| 18 | + */ | ||
| 19 | + static removeCommonHeader() { | ||
| 61 | 20 | ||
| 62 | - // 添加其他header | ||
| 63 | - // headers["sdkCeId"] = '27fb3129-5a54-45bc-8af1-7dc8f1155501'; // 用户中台老接口定义的ID,保持不变,现网:咪咕视频Android版,27fb3129-5a54-45bc-8af1-7dc8f1155501 todo | ||
| 64 | - headers["support-pendant"] = '1'; // 挂件标识, "1":客户端支持挂件节目结构;非"1":不支持挂件节目结构-展示通用对象 | ||
| 65 | - Logger.info(TAG, "buildHeader headers:" + JSON.stringify(headers)); | ||
| 66 | - return headers; | ||
| 67 | } | 21 | } |
| 68 | -} | ||
| 69 | - | ||
| 70 | -// export default new HttpUtils() | 22 | +} |
| @@ -124,4 +124,6 @@ export class WDRouterPage { | @@ -124,4 +124,6 @@ export class WDRouterPage { | ||
| 124 | static themeListPage = new WDRouterPage("wdComponent", "ets/components/page/ThemeListPage"); | 124 | static themeListPage = new WDRouterPage("wdComponent", "ets/components/page/ThemeListPage"); |
| 125 | // 栏目页面、频道详情 | 125 | // 栏目页面、频道详情 |
| 126 | static columnPage = new WDRouterPage("phone", "ets/pages/column/ColumnPage"); | 126 | static columnPage = new WDRouterPage("phone", "ets/pages/column/ColumnPage"); |
| 127 | + //展示头像 | ||
| 128 | + static showUserHeaderPage = new WDRouterPage("wdComponent", "ets/pages/ShowUserHeaderPage"); | ||
| 127 | } | 129 | } |
| @@ -157,13 +157,14 @@ export class ProcessUtils { | @@ -157,13 +157,14 @@ export class ProcessUtils { | ||
| 157 | * 图集详情页 | 157 | * 图集详情页 |
| 158 | * @param content | 158 | * @param content |
| 159 | * */ | 159 | * */ |
| 160 | - public static gotoMultiPictureListPage(photoList: PhotoListBean[]) { | 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: { |
| 164 | detailPageType: 18, | 164 | detailPageType: 18, |
| 165 | extra: { | 165 | extra: { |
| 166 | - photoList | 166 | + photoList, |
| 167 | + swiperIndex | ||
| 167 | } as ExtraDTO | 168 | } as ExtraDTO |
| 168 | } as Params, | 169 | } as Params, |
| 169 | }; | 170 | }; |
| @@ -186,8 +187,14 @@ export class ProcessUtils { | @@ -186,8 +187,14 @@ export class ProcessUtils { | ||
| 186 | let taskAction: Action = { | 187 | let taskAction: Action = { |
| 187 | type: 'JUMP_INNER_NEW_PAGE', | 188 | type: 'JUMP_INNER_NEW_PAGE', |
| 188 | params: { | 189 | params: { |
| 190 | + contentID: content?.objectId, | ||
| 189 | url: content.linkUrl, | 191 | url: content.linkUrl, |
| 190 | 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 | ||
| 191 | } as Params, | 198 | } as Params, |
| 192 | }; | 199 | }; |
| 193 | WDRouterRule.jumpWithAction(taskAction) | 200 | WDRouterRule.jumpWithAction(taskAction) |
| @@ -422,11 +429,10 @@ export class ProcessUtils { | @@ -422,11 +429,10 @@ export class ProcessUtils { | ||
| 422 | 429 | ||
| 423 | /** | 430 | /** |
| 424 | * 跳转人民号主页 | 431 | * 跳转人民号主页 |
| 425 | - *@params creatorId 创作者id | 432 | + * @params creatorId 创作者id |
| 426 | */ | 433 | */ |
| 427 | public static gotoPeopleShipHomePage(creatorId: string) { | 434 | public static gotoPeopleShipHomePage(creatorId: string) { |
| 428 | - let params = {'creatorId': creatorId} as Record<string, string>; | 435 | + let params = { 'creatorId': creatorId } as Record<string, string>; |
| 429 | WDRouterRule.jumpWithPage(WDRouterPage.peopleShipHomePage, params) | 436 | WDRouterRule.jumpWithPage(WDRouterPage.peopleShipHomePage, params) |
| 430 | } | 437 | } |
| 431 | - | ||
| 432 | } | 438 | } |
| 1 | -import HashMap from '@ohos.util.HashMap'; | ||
| 2 | import { Callback } from 'wdJsBridge'; | 1 | import { Callback } from 'wdJsBridge'; |
| 3 | -import { Message } from 'wdJsBridge/src/main/ets/bean/Message'; | ||
| 4 | -import { Logger } from 'wdKit'; | 2 | +import { Message, IImgListData } from 'wdJsBridge/src/main/ets/bean/Message'; |
| 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 } from 'wdBean/Index'; | ||
| 12 | -import { ResponseDTO, WDHttp, HttpUrlUtils } from 'wdNetwork'; | 10 | +import { ContentDTO, PhotoListBean } from 'wdBean'; |
| 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,17 +90,31 @@ function getAppPublicInfo(): string { | @@ -90,17 +90,31 @@ 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) { | ||
| 99 | - case 5: | ||
| 100 | - if (data?.data?.dataSource === 5) { | ||
| 101 | - ProcessUtils.processPage(JSON.parse(data?.data?.dataJson || '{}')) | 97 | + switch (String(data?.data?.dataSource)) { |
| 98 | + case '3': | ||
| 99 | + let imgListData: IImgListData = JSON.parse(data?.data?.imgListData || "{}") | ||
| 100 | + let imgArr = imgListData?.imgArr || [] | ||
| 101 | + let swiperIndex = imgListData?.imgIndex | ||
| 102 | + if (imgArr.length > 0) { | ||
| 103 | + const photoList: PhotoListBean[] = imgArr.map(item => { | ||
| 104 | + const photo: PhotoListBean = { | ||
| 105 | + width: item.width, | ||
| 106 | + height: item.height, | ||
| 107 | + picPath: item.pic, | ||
| 108 | + picDesc: '' | ||
| 109 | + } | ||
| 110 | + return photo | ||
| 111 | + }) | ||
| 112 | + ProcessUtils.gotoMultiPictureListPage(photoList, swiperIndex) | ||
| 102 | } | 113 | } |
| 103 | break; | 114 | break; |
| 115 | + case '5': | ||
| 116 | + ProcessUtils.processPage(JSON.parse(data?.data?.dataJson || '{}')) | ||
| 117 | + break; | ||
| 104 | default: | 118 | default: |
| 105 | break; | 119 | break; |
| 106 | } | 120 | } |
| @@ -168,3 +182,9 @@ function handleJsCallAppInnerLinkMethod(data: Message) { | @@ -168,3 +182,9 @@ function handleJsCallAppInnerLinkMethod(data: Message) { | ||
| 168 | } | 182 | } |
| 169 | } | 183 | } |
| 170 | } | 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 | import router from '@ohos.router'; | 1 | import router from '@ohos.router'; |
| 2 | -import { BridgeHandler, BridgeUtil, BridgeWebViewControl, Callback } from 'wdJsBridge'; | 2 | +import { BridgeUtil, BridgeWebViewControl, Callback } from 'wdJsBridge'; |
| 3 | import { Logger } from 'wdKit/Index'; | 3 | import { Logger } from 'wdKit/Index'; |
| 4 | -import { setDefaultNativeWebSettings } from './WebComponentUtil'; | ||
| 5 | -import { Action } from 'wdBean'; | ||
| 6 | import { performJSCallNative } from './JsBridgeBiz'; | 4 | import { performJSCallNative } from './JsBridgeBiz'; |
| 7 | import { H5CallNativeType } from './H5CallNativeType'; | 5 | import { H5CallNativeType } from './H5CallNativeType'; |
| 8 | import { Message } from 'wdJsBridge/src/main/ets/bean/Message'; | 6 | import { Message } from 'wdJsBridge/src/main/ets/bean/Message'; |
| @@ -12,11 +10,18 @@ const TAG = 'WdWebLocalComponent'; | @@ -12,11 +10,18 @@ const TAG = 'WdWebLocalComponent'; | ||
| 12 | @Component | 10 | @Component |
| 13 | export struct WdWebLocalComponent { | 11 | export struct WdWebLocalComponent { |
| 14 | webviewControl: BridgeWebViewControl = new BridgeWebViewControl() | 12 | webviewControl: BridgeWebViewControl = new BridgeWebViewControl() |
| 15 | - onWebPrepared: () => void = () => {} | 13 | + onWebPrepared: () => void = () => { |
| 14 | + } | ||
| 16 | @Prop backVisibility: boolean = false | 15 | @Prop backVisibility: boolean = false |
| 17 | @Prop webResource: Resource = {} as Resource | 16 | @Prop webResource: Resource = {} as Resource |
| 18 | @State webHeight: string | number = '100%' | 17 | @State webHeight: string | number = '100%' |
| 19 | @Link isPageEnd: boolean | 18 | @Link isPageEnd: boolean |
| 19 | + @State videoUrl: string = '' | ||
| 20 | + @State positionWidth: number = 0 | ||
| 21 | + @State positionHeight: number = 0 | ||
| 22 | + @State positionLeft: number = 0 | ||
| 23 | + @State positionTop: number = 0 | ||
| 24 | + @State videoLandscape: string = '1' | ||
| 20 | 25 | ||
| 21 | build() { | 26 | build() { |
| 22 | Column() { | 27 | Column() { |
| @@ -33,37 +38,64 @@ export struct WdWebLocalComponent { | @@ -33,37 +38,64 @@ export struct WdWebLocalComponent { | ||
| 33 | .height(44) | 38 | .height(44) |
| 34 | .visibility(this.backVisibility ? Visibility.Visible : Visibility.None) | 39 | .visibility(this.backVisibility ? Visibility.Visible : Visibility.None) |
| 35 | 40 | ||
| 36 | - Web({ src: this.webResource, controller: this.webviewControl }) | ||
| 37 | - .domStorageAccess(true) | ||
| 38 | - .databaseAccess(true) | ||
| 39 | - .javaScriptAccess(true) | ||
| 40 | - .imageAccess(true) | ||
| 41 | - .mixedMode(MixedMode.All) | ||
| 42 | - .onlineImageAccess(true) | ||
| 43 | - .enableNativeEmbedMode(true) | ||
| 44 | - .height(this.webHeight) | ||
| 45 | - .onPageBegin((event) => { | ||
| 46 | - this.onPageBegin(event?.url); | ||
| 47 | - }) | ||
| 48 | - .onPageEnd((event) => { | ||
| 49 | - this.onPageEnd(event?.url) | ||
| 50 | - }) | ||
| 51 | - .onLoadIntercept((event) => { | ||
| 52 | - let url: string = event.data.getRequestUrl().toString() | ||
| 53 | - url = url.replace("%(?![0-9a-fA-F]{2})", "%25") | ||
| 54 | - .replace("\\+", "%2B"); | ||
| 55 | - url = decodeURIComponent(url) | ||
| 56 | - if (url.startsWith(BridgeUtil.YY_RETURN_DATA)) { | ||
| 57 | - this.webviewControl.handlerReturnData(url) | ||
| 58 | - return true | ||
| 59 | - } | ||
| 60 | - if (url.startsWith(BridgeUtil.YY_OVERRIDE_SCHEMA)) { | ||
| 61 | - Logger.debug(TAG, 'flushMessageQueue'); | ||
| 62 | - this.webviewControl.flushMessageQueue() | ||
| 63 | - return true | 41 | + Row() { |
| 42 | + RelativeContainer() { | ||
| 43 | + Web({ src: this.webResource, controller: this.webviewControl }) | ||
| 44 | + .domStorageAccess(true) | ||
| 45 | + .databaseAccess(true) | ||
| 46 | + .javaScriptAccess(true) | ||
| 47 | + .imageAccess(true) | ||
| 48 | + .mixedMode(MixedMode.All) | ||
| 49 | + .onlineImageAccess(true) | ||
| 50 | + .enableNativeEmbedMode(true) | ||
| 51 | + .height(this.webHeight) | ||
| 52 | + .onPageBegin((event) => { | ||
| 53 | + this.onPageBegin(event?.url); | ||
| 54 | + }) | ||
| 55 | + .onPageEnd((event) => { | ||
| 56 | + this.onPageEnd(event?.url) | ||
| 57 | + }) | ||
| 58 | + .onLoadIntercept((event) => { | ||
| 59 | + let url: string = event.data.getRequestUrl().toString() | ||
| 60 | + url = url.replace("%(?![0-9a-fA-F]{2})", "%25") | ||
| 61 | + .replace("\\+", "%2B"); | ||
| 62 | + url = decodeURIComponent(url) | ||
| 63 | + if (url.startsWith(BridgeUtil.YY_RETURN_DATA)) { | ||
| 64 | + this.webviewControl.handlerReturnData(url) | ||
| 65 | + return true | ||
| 66 | + } | ||
| 67 | + if (url.startsWith(BridgeUtil.YY_OVERRIDE_SCHEMA)) { | ||
| 68 | + Logger.debug(TAG, 'flushMessageQueue'); | ||
| 69 | + this.webviewControl.flushMessageQueue() | ||
| 70 | + return true | ||
| 71 | + } | ||
| 72 | + return this.onLoadIntercept(event.data.getRequestUrl().toString()); | ||
| 73 | + }) | ||
| 74 | + .id('web') | ||
| 75 | + .alignRules({ | ||
| 76 | + top: { anchor: "__container__", align: VerticalAlign.Top }, | ||
| 77 | + }) | ||
| 78 | + | ||
| 79 | + if (this.videoUrl) { | ||
| 80 | + Video({ src: this.videoUrl }) | ||
| 81 | + .autoPlay(true) | ||
| 82 | + .objectFit(ImageFit.Contain) | ||
| 83 | + .width(this.positionWidth) | ||
| 84 | + .height(this.positionHeight) | ||
| 85 | + .borderRadius(5) | ||
| 86 | + .alignRules({ | ||
| 87 | + top: { anchor: "__container__", align: VerticalAlign.Top }, | ||
| 88 | + }) | ||
| 89 | + .offset({ | ||
| 90 | + x: this.positionLeft, | ||
| 91 | + y: this.positionTop | ||
| 92 | + }) | ||
| 93 | + .id("video") | ||
| 64 | } | 94 | } |
| 65 | - return this.onLoadIntercept(event.data.getRequestUrl().toString()); | ||
| 66 | - }) | 95 | + |
| 96 | + } | ||
| 97 | + }.width('100%') | ||
| 98 | + .height(this.webHeight) | ||
| 67 | } | 99 | } |
| 68 | } | 100 | } |
| 69 | 101 | ||
| @@ -73,7 +105,8 @@ export struct WdWebLocalComponent { | @@ -73,7 +105,8 @@ export struct WdWebLocalComponent { | ||
| 73 | let handleName = H5CallNativeType.JsCallTypeList[i]; | 105 | let handleName = H5CallNativeType.JsCallTypeList[i]; |
| 74 | let handle = (data: Message, f: Callback) => { | 106 | let handle = (data: Message, f: Callback) => { |
| 75 | Logger.debug('registerHandlers handlerName: ' + JSON.stringify(data.data)) | 107 | Logger.debug('registerHandlers handlerName: ' + JSON.stringify(data.data)) |
| 76 | - this.setCurrentPageOperate(data) | 108 | + this.setCurrentPageOperate8(data) |
| 109 | + this.setCurrentPageOperate9(data) | ||
| 77 | this.defaultPerformJSCallNative(data, f) | 110 | this.defaultPerformJSCallNative(data, f) |
| 78 | }; | 111 | }; |
| 79 | this.webviewControl.registerHandler(handleName, { handle: handle }); | 112 | this.webviewControl.registerHandler(handleName, { handle: handle }); |
| @@ -81,7 +114,7 @@ export struct WdWebLocalComponent { | @@ -81,7 +114,7 @@ export struct WdWebLocalComponent { | ||
| 81 | } | 114 | } |
| 82 | 115 | ||
| 83 | //webview 高度设置 | 116 | //webview 高度设置 |
| 84 | - private setCurrentPageOperate: (data: Message) => void = (data) => { | 117 | + private setCurrentPageOperate8: (data: Message) => void = (data) => { |
| 85 | if (data.handlerName === H5CallNativeType.jsCall_currentPageOperate && data?.data?.operateType === '8') { | 118 | if (data.handlerName === H5CallNativeType.jsCall_currentPageOperate && data?.data?.operateType === '8') { |
| 86 | if (typeof this.webHeight === 'number') { | 119 | if (typeof this.webHeight === 'number') { |
| 87 | if (Number(data?.data?.webViewHeight) > this.webHeight) { | 120 | if (Number(data?.data?.webViewHeight) > this.webHeight) { |
| @@ -93,6 +126,17 @@ export struct WdWebLocalComponent { | @@ -93,6 +126,17 @@ export struct WdWebLocalComponent { | ||
| 93 | } | 126 | } |
| 94 | } | 127 | } |
| 95 | } | 128 | } |
| 129 | + //播放视频 | ||
| 130 | + private setCurrentPageOperate9: (data: Message) => void = (data) => { | ||
| 131 | + if (data.handlerName === H5CallNativeType.jsCall_currentPageOperate && data?.data?.operateType === '9') { | ||
| 132 | + this.videoUrl = data?.data?.videoUrl || '' | ||
| 133 | + this.positionWidth = Number(data?.data?.positionWidth) || 0 | ||
| 134 | + this.positionHeight = Number(data?.data?.positionHeight) || 0 | ||
| 135 | + this.positionLeft = Number(data?.data?.positionLeft) || 0 | ||
| 136 | + this.positionTop = Number(data?.data?.positionTop) || 0 | ||
| 137 | + this.videoLandscape = data?.data?.videoLandscape || '1' | ||
| 138 | + } | ||
| 139 | + } | ||
| 96 | /** | 140 | /** |
| 97 | * 默认【CallNative】逻辑处理 | 141 | * 默认【CallNative】逻辑处理 |
| 98 | */ | 142 | */ |
| @@ -15,5 +15,6 @@ export interface ExtraDTO extends ItemDTO { | @@ -15,5 +15,6 @@ export interface ExtraDTO extends ItemDTO { | ||
| 15 | relType: string; | 15 | relType: string; |
| 16 | liveStreamType?: number; | 16 | liveStreamType?: number; |
| 17 | photoList: PhotoListBean[]; | 17 | photoList: PhotoListBean[]; |
| 18 | + swiperIndex?: number | ||
| 18 | commentId?: string; | 19 | commentId?: string; |
| 19 | } | 20 | } |
| 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 | } |
| @@ -172,9 +172,10 @@ export interface LiveDetailsBean { | @@ -172,9 +172,10 @@ export interface LiveDetailsBean { | ||
| 172 | export interface LiveInfo { | 172 | export interface LiveInfo { |
| 173 | //直播新闻-直播状态 wait 待开播 running 直播中 end 已结束cancel已取消paused暂停 | 173 | //直播新闻-直播状态 wait 待开播 running 直播中 end 已结束cancel已取消paused暂停 |
| 174 | liveState: string | 174 | liveState: string |
| 175 | - | ||
| 176 | //2024-04-12 15:00:00 直播开始时间 | 175 | //2024-04-12 15:00:00 直播开始时间 |
| 177 | planStartTime: string | 176 | planStartTime: string |
| 177 | + startTime: string | ||
| 178 | + endTime: string | ||
| 178 | //直播样式 0-正常模式 , 1-隐藏直播间,2-隐藏大家聊 【人民号发布是竖屏的,为空】 | 179 | //直播样式 0-正常模式 , 1-隐藏直播间,2-隐藏大家聊 【人民号发布是竖屏的,为空】 |
| 179 | liveStyle: number; | 180 | liveStyle: number; |
| 180 | vlive: Array<Vlive> | 181 | vlive: Array<Vlive> |
| @@ -4,37 +4,39 @@ import { TopNavDTO } from './TopNavDTO'; | @@ -4,37 +4,39 @@ import { TopNavDTO } from './TopNavDTO'; | ||
| 4 | * 底导(包含顶导列表)数据 | 4 | * 底导(包含顶导列表)数据 |
| 5 | */ | 5 | */ |
| 6 | export interface BottomNavDTO { | 6 | export interface BottomNavDTO { |
| 7 | - backgroundUrl: string; | ||
| 8 | - channelChooseActionUrl: string; | ||
| 9 | - channelChooseCColor: string; | ||
| 10 | - channelChooseColor: string; | ||
| 11 | - channelMoreColor: string; | 7 | + backgroundUrl: string; // 迭代四:页面背景图 |
| 8 | + channelChooseActionUrl: string; // 迭代四:频道选中下划线动画 | ||
| 9 | + channelChooseCColor: string; // 迭代四:频道未选中颜色 | ||
| 10 | + channelChooseColor: string; // 迭代四:频道选中颜色 | ||
| 11 | + channelMoreColor: string; // 迭代四:更多频道颜色 | ||
| 12 | extraData: string; | 12 | extraData: string; |
| 13 | - homePageColor: string; | ||
| 14 | - icon: string; | ||
| 15 | - iconC: string; | 13 | + homePageColor: string; // 迭代四:主页图标/文字颜色 |
| 14 | + icon: string; // 未选中图标 | ||
| 15 | + iconC: string; // 选中图标 | ||
| 16 | id: number; | 16 | id: number; |
| 17 | - immersiveIconCUrl: string; | ||
| 18 | - immersiveIconUrl: string; | ||
| 19 | - immersiveNameCColor: string; | ||
| 20 | - immersiveNameColor: string; | ||
| 21 | - logoUrl: string; | 17 | + immersiveIconCUrl: string; // 迭代二新增-图标颜色-选中(沉浸式频道) |
| 18 | + immersiveIconUrl: string; // 迭代二新增-图标颜色-未选中(沉浸式频道) | ||
| 19 | + immersiveNameCColor: string; // 迭代二新增-文字颜色-选中(沉浸式频道) | ||
| 20 | + immersiveNameColor: string; // 迭代二新增-文字颜色-未选中(沉浸式频道) | ||
| 21 | + logoUrl: string; // 迭代四:logo图片 | ||
| 22 | morningAndEveningUrl: string; | 22 | morningAndEveningUrl: string; |
| 23 | name: string; | 23 | name: string; |
| 24 | - nameCColor: string; | ||
| 25 | - nameColor: string; | ||
| 26 | - nightIconCUrl: string; | ||
| 27 | - nightIconUrl: string; | ||
| 28 | - nightNameCColor: string; | ||
| 29 | - nightNameColor: string; | ||
| 30 | - noticeColor: string; | 24 | + nameCColor: string; // 名字选中颜色 |
| 25 | + nameColor: string; // 名字颜色 | ||
| 26 | + nightIconCUrl: string; // 迭代三新增-图标颜色-选中(夜间模式) | ||
| 27 | + nightIconUrl: string; // 迭代三新增-图标颜色-未选中(夜间模式) | ||
| 28 | + nightNameCColor: string; // 迭代三新增-文字颜色-选中(夜间模式) | ||
| 29 | + nightNameColor: string; // 迭代三新增-文字颜色-未选中(夜间模式) | ||
| 30 | + noticeColor: string; // 迭代四:消息通知提醒颜色 | ||
| 31 | pageId?: string; | 31 | pageId?: string; |
| 32 | pageType?: string; | 32 | pageType?: string; |
| 33 | - searchBothColor: string; | ||
| 34 | - searchUrl: string; | 33 | + searchBothColor: string; // 迭代四:两侧文字图标颜色,搜索图标颜色 |
| 34 | + searchUrl: string; // 迭代四:搜索背景框 | ||
| 35 | sortValue: number; | 35 | sortValue: number; |
| 36 | - statusBarColor: number; | 36 | + statusBarColor: number; // 迭代四:状态栏图标颜色,0:白色,1:黑色 |
| 37 | topNavChannelList: TopNavDTO[]; | 37 | topNavChannelList: TopNavDTO[]; |
| 38 | - topStyle: string; | ||
| 39 | - type: string; | 38 | + topStyle: string; // 顶部样式:中文的(11-新闻;12-人民号;13-视频;14-服务) |
| 39 | + type: string; // 底部导航类型,1普通 2我的;【rmrb需要扩展】 | ||
| 40 | + fmorningAndEveningUrl: string; // 迭代四:早晚报背景框 | ||
| 41 | + dropDownAnimationColor: string; // 下拉加载动画颜色,1白色,2灰色。未配置值是null | ||
| 40 | } | 42 | } |
| @@ -4,9 +4,10 @@ import { BottomNavDTO } from './BottomNavDTO'; | @@ -4,9 +4,10 @@ import { BottomNavDTO } from './BottomNavDTO'; | ||
| 4 | * 导航Body数据 | 4 | * 导航Body数据 |
| 5 | */ | 5 | */ |
| 6 | export interface NavigationBodyDTO { | 6 | export interface NavigationBodyDTO { |
| 7 | - backgroundColor: string; | 7 | + backgroundColor: string; // 迭代二新增-底部导航背景色(信息流频道) |
| 8 | bottomNavList: BottomNavDTO[]; | 8 | bottomNavList: BottomNavDTO[]; |
| 9 | - // greyBottomNav: GreyBottomNav; | ||
| 10 | - immersiveBackgroundColor: string; | ||
| 11 | - nightBackgroundColor: string; | 9 | + |
| 10 | + // greyBottomNav: GreyBottomNav; // 灰度皮肤 | ||
| 11 | + immersiveBackgroundColor: string; // 迭代二新增-底部导航背景色(沉浸式频道) | ||
| 12 | + nightBackgroundColor: string; // 迭代三新增-底部导航背景色(夜间模式) | ||
| 12 | } | 13 | } |
| @@ -7,14 +7,14 @@ export interface TopNavDTO { | @@ -7,14 +7,14 @@ export interface TopNavDTO { | ||
| 7 | channelType: number; | 7 | channelType: number; |
| 8 | defaultPermitted: number; | 8 | defaultPermitted: number; |
| 9 | delPermitted: number; | 9 | delPermitted: number; |
| 10 | - fontCColor: string; | ||
| 11 | - fontColor: string; | 10 | + fontCColor: string; // 频道展示样式颜色(选中状态) |
| 11 | + fontColor: string; // 频道展示样式颜色(未选中状态) | ||
| 12 | headlinesOn: number; | 12 | headlinesOn: number; |
| 13 | homeChannel: string; | 13 | homeChannel: string; |
| 14 | - iconCUrl: string; | ||
| 15 | - iconCUrlSize: string; | ||
| 16 | - iconUrl: string; | ||
| 17 | iconUrlSize: string; | 14 | iconUrlSize: string; |
| 15 | + iconCUrlSize: string; | ||
| 16 | + iconUrl: string; // 频道图片展示样式图片相对地址(未选中状态) | ||
| 17 | + iconCUrl: string; //频道图片展示样式图片相对地址(选中状态 | ||
| 18 | localChannel: string; | 18 | localChannel: string; |
| 19 | moreChannel: string; | 19 | moreChannel: string; |
| 20 | movePermitted: number; | 20 | movePermitted: number; |
| @@ -23,5 +23,5 @@ export interface TopNavDTO { | @@ -23,5 +23,5 @@ export interface TopNavDTO { | ||
| 23 | num: number; | 23 | num: number; |
| 24 | pageId: number; | 24 | pageId: number; |
| 25 | pageType: string; | 25 | pageType: string; |
| 26 | - underlineCColor: string; | 26 | + underlineCColor: string; // 选中下划线颜色 |
| 27 | } | 27 | } |
| @@ -71,8 +71,6 @@ export { SpacialTopicPageComponent } from './src/main/ets/components/SpacialTopi | @@ -71,8 +71,6 @@ export { SpacialTopicPageComponent } from './src/main/ets/components/SpacialTopi | ||
| 71 | 71 | ||
| 72 | export { LogoutViewModel } from "./src/main/ets/viewmodel/LogoutViewModel" | 72 | export { LogoutViewModel } from "./src/main/ets/viewmodel/LogoutViewModel" |
| 73 | 73 | ||
| 74 | -export { ImageSwiperComponent } from "./src/main/ets/components/ImageSwiperComponent" | ||
| 75 | - | ||
| 76 | export { newsSkeleton } from "./src/main/ets/components/skeleton/newsSkeleton" | 74 | export { newsSkeleton } from "./src/main/ets/components/skeleton/newsSkeleton" |
| 77 | 75 | ||
| 78 | export { LiveCommentComponent } from "./src/main/ets/components/comment/view/LiveCommentComponent" | 76 | export { LiveCommentComponent } from "./src/main/ets/components/comment/view/LiveCommentComponent" |
| @@ -9,6 +9,7 @@ import { | @@ -9,6 +9,7 @@ import { | ||
| 9 | HorizontalStrokeCardThreeTwoRadioForOneComponent | 9 | HorizontalStrokeCardThreeTwoRadioForOneComponent |
| 10 | } from './view/HorizontalStrokeCardThreeTwoRadioForOneComponent'; | 10 | } from './view/HorizontalStrokeCardThreeTwoRadioForOneComponent'; |
| 11 | import { ZhSingleRow02 } from './compview/ZhSingleRow02'; | 11 | import { ZhSingleRow02 } from './compview/ZhSingleRow02'; |
| 12 | +import { ZhSingleRow03 } from './compview/ZhSingleRow03'; | ||
| 12 | import { ZhSingleRow04 } from './compview/ZhSingleRow04'; | 13 | import { ZhSingleRow04 } from './compview/ZhSingleRow04'; |
| 13 | import { ZhSingleRow05 } from './compview/ZhSingleRow05'; | 14 | import { ZhSingleRow05 } from './compview/ZhSingleRow05'; |
| 14 | import { ZhSingleRow06 } from './compview/ZhSingleRow06'; | 15 | import { ZhSingleRow06 } from './compview/ZhSingleRow06'; |
| @@ -59,7 +60,7 @@ export struct CompParser { | @@ -59,7 +60,7 @@ export struct CompParser { | ||
| 59 | } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_02) { | 60 | } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_02) { |
| 60 | ZhSingleRow02({ compDTO }) | 61 | ZhSingleRow02({ compDTO }) |
| 61 | } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_03) { | 62 | } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_03) { |
| 62 | - LiveHorizontalReservationComponent({ compDTO: compDTO }) | 63 | + ZhSingleRow03({ compDTO: compDTO }) |
| 63 | } else if (compDTO.compStyle === CompStyle.Zh_Grid_Layout_02) { | 64 | } else if (compDTO.compStyle === CompStyle.Zh_Grid_Layout_02) { |
| 64 | ZhGridLayout02({ compDTO: compDTO }) | 65 | ZhGridLayout02({ compDTO: compDTO }) |
| 65 | } else if (compDTO.compStyle === CompStyle.Zh_Grid_Layout_03) { | 66 | } else if (compDTO.compStyle === CompStyle.Zh_Grid_Layout_03) { |
| @@ -44,9 +44,9 @@ export struct DynamicDetailComponent { | @@ -44,9 +44,9 @@ export struct DynamicDetailComponent { | ||
| 44 | /** | 44 | /** |
| 45 | * 关注状态:默认未关注 点击去关注 | 45 | * 关注状态:默认未关注 点击去关注 |
| 46 | */ | 46 | */ |
| 47 | - @State followStatus: String = '0'; | 47 | + @State followStatus: String = ''; |
| 48 | 48 | ||
| 49 | - @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined// 点赞、收藏状态 | 49 | + @State newsStatusOfUser: batchLikeAndCollectResult = {} as batchLikeAndCollectResult// 点赞、收藏状态 |
| 50 | //跳转 | 50 | //跳转 |
| 51 | private mJumpInfo: ContentDTO = {} as ContentDTO; | 51 | private mJumpInfo: ContentDTO = {} as ContentDTO; |
| 52 | 52 | ||
| @@ -121,31 +121,33 @@ export struct DynamicDetailComponent { | @@ -121,31 +121,33 @@ export struct DynamicDetailComponent { | ||
| 121 | } | 121 | } |
| 122 | .width('63%') | 122 | .width('63%') |
| 123 | .margin({right: $r('app.float.margin_6')}) | 123 | .margin({right: $r('app.float.margin_6')}) |
| 124 | - if (this.followStatus == '0') { | ||
| 125 | - Text('关注') | ||
| 126 | - .width($r('app.float.margin_54')) | ||
| 127 | - .height($r('app.float.margin_24')) | ||
| 128 | - .textAlign(TextAlign.Center) | ||
| 129 | - .fontSize($r('app.float.font_size_12')) | ||
| 130 | - .borderRadius($r('app.float.vp_3')) | ||
| 131 | - .backgroundColor($r('app.color.color_ED2800')) | ||
| 132 | - .fontColor($r('app.color.color_fff')) | ||
| 133 | - .onClick(() => { | ||
| 134 | - this.handleAccention() | ||
| 135 | - }) | ||
| 136 | - } else { | ||
| 137 | - Text('已关注') | ||
| 138 | - .width($r('app.float.margin_54')) | ||
| 139 | - .height($r('app.float.margin_24')) | ||
| 140 | - .borderWidth(1) | ||
| 141 | - .textAlign(TextAlign.Center) | ||
| 142 | - .fontSize($r('app.float.font_size_12')) | ||
| 143 | - .borderRadius($r('app.float.vp_3')) | ||
| 144 | - .borderColor($r('app.color.color_CCCCCC')) | ||
| 145 | - .fontColor($r('app.color.color_CCCCCC')) | ||
| 146 | - .onClick(() => { | ||
| 147 | - this.handleAccention() | ||
| 148 | - }) | 124 | + if(!StringUtils.isEmpty(this.followStatus)){ |
| 125 | + if (this.followStatus == '0') { | ||
| 126 | + Text('关注') | ||
| 127 | + .width($r('app.float.margin_54')) | ||
| 128 | + .height($r('app.float.margin_24')) | ||
| 129 | + .textAlign(TextAlign.Center) | ||
| 130 | + .fontSize($r('app.float.font_size_12')) | ||
| 131 | + .borderRadius($r('app.float.vp_3')) | ||
| 132 | + .backgroundColor($r('app.color.color_ED2800')) | ||
| 133 | + .fontColor($r('app.color.color_fff')) | ||
| 134 | + .onClick(() => { | ||
| 135 | + this.handleAccention() | ||
| 136 | + }) | ||
| 137 | + } else { | ||
| 138 | + Text('已关注') | ||
| 139 | + .width($r('app.float.margin_54')) | ||
| 140 | + .height($r('app.float.margin_24')) | ||
| 141 | + .borderWidth(1) | ||
| 142 | + .textAlign(TextAlign.Center) | ||
| 143 | + .fontSize($r('app.float.font_size_12')) | ||
| 144 | + .borderRadius($r('app.float.vp_3')) | ||
| 145 | + .borderColor($r('app.color.color_CCCCCC')) | ||
| 146 | + .fontColor($r('app.color.color_CCCCCC')) | ||
| 147 | + .onClick(() => { | ||
| 148 | + this.handleAccention() | ||
| 149 | + }) | ||
| 150 | + } | ||
| 149 | } | 151 | } |
| 150 | } | 152 | } |
| 151 | .width('100%') | 153 | .width('100%') |
| @@ -209,7 +211,7 @@ export struct DynamicDetailComponent { | @@ -209,7 +211,7 @@ export struct DynamicDetailComponent { | ||
| 209 | } | 211 | } |
| 210 | } | 212 | } |
| 211 | .onClick((event: ClickEvent) => { | 213 | .onClick((event: ClickEvent) => { |
| 212 | - ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList) | 214 | + ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList,index) |
| 213 | }) | 215 | }) |
| 214 | } else { | 216 | } else { |
| 215 | GridCol({ | 217 | GridCol({ |
| @@ -226,7 +228,7 @@ export struct DynamicDetailComponent { | @@ -226,7 +228,7 @@ export struct DynamicDetailComponent { | ||
| 226 | }) | 228 | }) |
| 227 | } | 229 | } |
| 228 | .onClick((event: ClickEvent) => { | 230 | .onClick((event: ClickEvent) => { |
| 229 | - ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList) | 231 | + ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList,index) |
| 230 | }) | 232 | }) |
| 231 | } | 233 | } |
| 232 | } else if (this.contentDetailData.photoList.length === 4) { | 234 | } else if (this.contentDetailData.photoList.length === 4) { |
| @@ -238,7 +240,7 @@ export struct DynamicDetailComponent { | @@ -238,7 +240,7 @@ export struct DynamicDetailComponent { | ||
| 238 | .borderRadius(this.caclImageRadius(index)) | 240 | .borderRadius(this.caclImageRadius(index)) |
| 239 | } | 241 | } |
| 240 | .onClick((event: ClickEvent) => { | 242 | .onClick((event: ClickEvent) => { |
| 241 | - ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList) | 243 | + ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList,index) |
| 242 | }) | 244 | }) |
| 243 | } else { | 245 | } else { |
| 244 | GridCol({ | 246 | GridCol({ |
| @@ -249,7 +251,7 @@ export struct DynamicDetailComponent { | @@ -249,7 +251,7 @@ export struct DynamicDetailComponent { | ||
| 249 | .borderRadius(this.caclImageRadius(index)) | 251 | .borderRadius(this.caclImageRadius(index)) |
| 250 | } | 252 | } |
| 251 | .onClick((event: ClickEvent) => { | 253 | .onClick((event: ClickEvent) => { |
| 252 | - ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList) | 254 | + ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList,index) |
| 253 | }) | 255 | }) |
| 254 | } | 256 | } |
| 255 | }) | 257 | }) |
| @@ -330,8 +332,8 @@ export struct DynamicDetailComponent { | @@ -330,8 +332,8 @@ export struct DynamicDetailComponent { | ||
| 330 | Image(this.newsStatusOfUser?.likeStatus == '1'? | 332 | Image(this.newsStatusOfUser?.likeStatus == '1'? |
| 331 | $r('app.media.icon_like_selected_redheart') | 333 | $r('app.media.icon_like_selected_redheart') |
| 332 | :$r('app.media.icon_like_unselect_grey_redheart')) | 334 | :$r('app.media.icon_like_unselect_grey_redheart')) |
| 333 | - .width($r('app.float.margin_24')) | ||
| 334 | - .height($r('app.float.margin_24')) | 335 | + .width($r('app.float.margin_36')) |
| 336 | + .height($r('app.float.margin_36')) | ||
| 335 | .objectFit(ImageFit.Cover) | 337 | .objectFit(ImageFit.Cover) |
| 336 | if(this.interactDataDTO?.likeNum != 0){ | 338 | if(this.interactDataDTO?.likeNum != 0){ |
| 337 | Text(NumberFormatterUtils.formatNumberWithWan(this.interactDataDTO?.likeNum)) | 339 | Text(NumberFormatterUtils.formatNumberWithWan(this.interactDataDTO?.likeNum)) |
| @@ -430,12 +432,18 @@ export struct DynamicDetailComponent { | @@ -430,12 +432,18 @@ export struct DynamicDetailComponent { | ||
| 430 | 432 | ||
| 431 | // 已登录->查询用户对作品点赞、收藏状态 | 433 | // 已登录->查询用户对作品点赞、收藏状态 |
| 432 | private async getInteractDataStatus() { | 434 | private async getInteractDataStatus() { |
| 435 | + // 未登录,跳转登录 | ||
| 436 | + const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') | ||
| 437 | + if (!user_id) { | ||
| 438 | + WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 439 | + return | ||
| 440 | + } | ||
| 433 | try { | 441 | try { |
| 434 | const params: batchLikeAndCollectParams = { | 442 | const params: batchLikeAndCollectParams = { |
| 435 | contentList: [ | 443 | contentList: [ |
| 436 | { | 444 | { |
| 437 | - contentId: this.contentDetailData[0]?.newsId + '', | ||
| 438 | - contentType: this.contentDetailData[0]?.newsType + '', | 445 | + contentId: this.contentDetailData?.newsId + '', |
| 446 | + contentType: this.contentDetailData?.newsType + '', | ||
| 439 | } | 447 | } |
| 440 | ] | 448 | ] |
| 441 | } | 449 | } |
| @@ -453,16 +461,23 @@ export struct DynamicDetailComponent { | @@ -453,16 +461,23 @@ export struct DynamicDetailComponent { | ||
| 453 | * 查询当前登录用户是否关注作品号主 | 461 | * 查询当前登录用户是否关注作品号主 |
| 454 | * */ | 462 | * */ |
| 455 | private async getBatchAttentionStatus() { | 463 | private async getBatchAttentionStatus() { |
| 464 | + // 未登录,跳转登录 | ||
| 465 | + const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') | ||
| 466 | + if (!user_id) { | ||
| 467 | + WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 468 | + this.followStatus = '0'; | ||
| 469 | + return | ||
| 470 | + } | ||
| 456 | try { | 471 | try { |
| 457 | - const params: postBatchAttentionStatusParams = { | ||
| 458 | - creatorIds: [{ creatorId: this.contentDetailData?.rmhInfo?.rmhId ?? '' }] | 472 | + const params: postBatchAttentionStatusParams = { |
| 473 | + creatorIds: [{ creatorId: this.contentDetailData?.rmhInfo?.rmhId ?? '' }] | ||
| 474 | + } | ||
| 475 | + let data = await MultiPictureDetailViewModel.getBatchAttentionStatus(params) | ||
| 476 | + this.followStatus = data[0]?.status; | ||
| 477 | + Logger.info(TAG, `followStatus:${JSON.stringify(this.followStatus)}`) | ||
| 478 | + } catch (exception) { | ||
| 479 | + this.followStatus = '0'; | ||
| 459 | } | 480 | } |
| 460 | - let data = await MultiPictureDetailViewModel.getBatchAttentionStatus(params) | ||
| 461 | - this.followStatus = data[0]?.status; | ||
| 462 | - Logger.info(TAG, `followStatus:${JSON.stringify(this.followStatus)}`) | ||
| 463 | - } catch (exception) { | ||
| 464 | - | ||
| 465 | - } | ||
| 466 | } | 481 | } |
| 467 | 482 | ||
| 468 | //创建跳转信息 | 483 | //创建跳转信息 |
| @@ -558,18 +573,13 @@ export struct DynamicDetailComponent { | @@ -558,18 +573,13 @@ export struct DynamicDetailComponent { | ||
| 558 | contentType: this.contentDetailData?.newsType + '', | 573 | contentType: this.contentDetailData?.newsType + '', |
| 559 | } | 574 | } |
| 560 | ContentDetailRequest.postExecuteLike(params).then(res => { | 575 | ContentDetailRequest.postExecuteLike(params).then(res => { |
| 561 | - | ||
| 562 | - if (this.newsStatusOfUser) { | ||
| 563 | - this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1' | ||
| 564 | - if (this.newsStatusOfUser.likeStatus === '1') { | ||
| 565 | - this.interactDataDTO.likeNum = Number(this.interactDataDTO.likeNum) + 1 | ||
| 566 | - } else { | ||
| 567 | - this.interactDataDTO.likeNum = Number(this.interactDataDTO.likeNum) - 1 | ||
| 568 | - } | ||
| 569 | - console.log('点赞、取消点赞==', this.newsStatusOfUser?.likeStatus, this.interactDataDTO?.likeNum) | ||
| 570 | - // this.queryContentInteractCount() | 576 | + this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1' |
| 577 | + if (this.newsStatusOfUser.likeStatus === '1') { | ||
| 578 | + this.interactDataDTO.likeNum = Number(this.interactDataDTO.likeNum) + 1 | ||
| 579 | + } else { | ||
| 580 | + this.interactDataDTO.likeNum = Number(this.interactDataDTO.likeNum) - 1 | ||
| 571 | } | 581 | } |
| 572 | - | 582 | + console.log('点赞、取消点赞==', this.newsStatusOfUser?.likeStatus, this.interactDataDTO?.likeNum) |
| 573 | }) | 583 | }) |
| 574 | } | 584 | } |
| 575 | } | 585 | } |
| @@ -20,10 +20,11 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | @@ -20,10 +20,11 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | ||
| 20 | import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel'; | 20 | import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel'; |
| 21 | import { PageRepository } from '../repository/PageRepository'; | 21 | import { PageRepository } from '../repository/PageRepository'; |
| 22 | import { detailedSkeleton } from './skeleton/detailSkeleton'; | 22 | import { detailedSkeleton } from './skeleton/detailSkeleton'; |
| 23 | +import { CommentComponent } from '../components/comment/view/CommentComponent' | ||
| 23 | 24 | ||
| 24 | const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm'; | 25 | const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm'; |
| 25 | 26 | ||
| 26 | -const TAG = 'ImageAndTextPageComponent' | 27 | +const TAG: string = 'ImageAndTextPageComponent' |
| 27 | 28 | ||
| 28 | @Component | 29 | @Component |
| 29 | export struct ImageAndTextPageComponent { | 30 | export struct ImageAndTextPageComponent { |
| @@ -76,7 +77,6 @@ export struct ImageAndTextPageComponent { | @@ -76,7 +77,6 @@ export struct ImageAndTextPageComponent { | ||
| 76 | Column() { | 77 | Column() { |
| 77 | // 点赞 | 78 | // 点赞 |
| 78 | if (this.contentDetailData[0]?.openLikes) { | 79 | if (this.contentDetailData[0]?.openLikes) { |
| 79 | - // 点赞 | ||
| 80 | Row() { | 80 | Row() { |
| 81 | Row() { | 81 | Row() { |
| 82 | if (this.newsStatusOfUser?.likeStatus === '1') { | 82 | if (this.newsStatusOfUser?.likeStatus === '1') { |
| @@ -90,10 +90,12 @@ export struct ImageAndTextPageComponent { | @@ -90,10 +90,12 @@ export struct ImageAndTextPageComponent { | ||
| 90 | .height(24) | 90 | .height(24) |
| 91 | .margin({ right: 5 }) | 91 | .margin({ right: 5 }) |
| 92 | } | 92 | } |
| 93 | - Text(`${this.interactData?.likeNum || 0}`) | ||
| 94 | - .fontSize(16) | ||
| 95 | - .fontColor(this.newsStatusOfUser?.likeStatus === '1' ? '#ED2800' : '#999999') | ||
| 96 | - .fontWeight(500) | 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 | + } | ||
| 97 | } | 99 | } |
| 98 | .width(140) | 100 | .width(140) |
| 99 | .height(36) | 101 | .height(36) |
| @@ -116,6 +118,12 @@ export struct ImageAndTextPageComponent { | @@ -116,6 +118,12 @@ export struct ImageAndTextPageComponent { | ||
| 116 | if (this.recommendList.length > 0) { | 118 | if (this.recommendList.length > 0) { |
| 117 | RecommendList({ recommendList: this.recommendList }) | 119 | RecommendList({ recommendList: this.recommendList }) |
| 118 | } | 120 | } |
| 121 | + // 评论 | ||
| 122 | + if(this.contentDetailData[0]?.openComment){ | ||
| 123 | + // CommentComponent({ | ||
| 124 | + // | ||
| 125 | + // }) | ||
| 126 | + } | ||
| 119 | } | 127 | } |
| 120 | } | 128 | } |
| 121 | 129 | ||
| @@ -130,7 +138,9 @@ export struct ImageAndTextPageComponent { | @@ -130,7 +138,9 @@ export struct ImageAndTextPageComponent { | ||
| 130 | } | 138 | } |
| 131 | 139 | ||
| 132 | //底部交互区 | 140 | //底部交互区 |
| 133 | - OperRowListView({ contentDetailData: this.contentDetailData[0] }) | 141 | + if (this.contentDetailData?.length) { |
| 142 | + OperRowListView({contentDetailData: this.contentDetailData[0]}) | ||
| 143 | + } | ||
| 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 | } |
| @@ -96,7 +99,6 @@ export struct ImageAndTextWebComponent { | @@ -96,7 +99,6 @@ export struct ImageAndTextWebComponent { | ||
| 96 | backVisibility: false, | 99 | backVisibility: false, |
| 97 | onWebPrepared: this.onWebPrepared.bind(this), | 100 | onWebPrepared: this.onWebPrepared.bind(this), |
| 98 | isPageEnd: $isPageEnd | 101 | isPageEnd: $isPageEnd |
| 99 | - | ||
| 100 | }) | 102 | }) |
| 101 | } | 103 | } |
| 102 | } | 104 | } |
| @@ -20,7 +20,7 @@ export struct ImageDownloadComponent { | @@ -20,7 +20,7 @@ export struct ImageDownloadComponent { | ||
| 20 | @State image: PixelMap | undefined = undefined; | 20 | @State image: PixelMap | undefined = undefined; |
| 21 | @State photoAccessHelper: photoAccessHelper.PhotoAccessHelper | undefined = undefined; // 相册模块管理实例 | 21 | @State photoAccessHelper: photoAccessHelper.PhotoAccessHelper | undefined = undefined; // 相册模块管理实例 |
| 22 | @State imageBuffer: ArrayBuffer | undefined = undefined; // 图片ArrayBuffer | 22 | @State imageBuffer: ArrayBuffer | undefined = undefined; // 图片ArrayBuffer |
| 23 | - url: string = '' | 23 | + @Prop @Watch('onChangeUrl') url: string = '' |
| 24 | 24 | ||
| 25 | build() { | 25 | build() { |
| 26 | Column() { | 26 | Column() { |
| @@ -40,7 +40,11 @@ export struct ImageDownloadComponent { | @@ -40,7 +40,11 @@ export struct ImageDownloadComponent { | ||
| 40 | 40 | ||
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | - async aboutToAppear(): Promise<void> { | 43 | + aboutToAppear(): void { |
| 44 | + this.onChangeUrl() | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + async onChangeUrl(): Promise<void> { | ||
| 44 | console.info(`cj2024 图片下载 ${this.url}`) | 48 | console.info(`cj2024 图片下载 ${this.url}`) |
| 45 | const context = getContext(this) as common.UIAbilityContext; | 49 | const context = getContext(this) as common.UIAbilityContext; |
| 46 | const atManager = abilityAccessCtrl.createAtManager(); | 50 | const atManager = abilityAccessCtrl.createAtManager(); |
sight_harmony/features/wdComponent/src/main/ets/components/ImageSwiperComponent.ets
deleted
100644 → 0
| 1 | -import { PhotoListBean } from 'wdBean/Index'; | ||
| 2 | -import { Logger } from 'wdKit/Index'; | ||
| 3 | -import { display, router } from '@kit.ArkUI'; | ||
| 4 | -import { ImageDownloadComponent } from './ImageDownloadComponent'; | ||
| 5 | -import { ImageItemView } from './view/ImageItemView'; | ||
| 6 | - | ||
| 7 | -const TAG = 'ImageSwiperComponent'; | ||
| 8 | - | ||
| 9 | -@Component | ||
| 10 | -export struct ImageSwiperComponent { | ||
| 11 | - @Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01' | ||
| 12 | - private scroller: Scroller = new Scroller() | ||
| 13 | - @State swiperIndex: number = 0; | ||
| 14 | - photoList: PhotoListBean[] = []; | ||
| 15 | - private swiperController: SwiperController = new SwiperController() | ||
| 16 | - private displayTool = display.getDefaultDisplaySync() | ||
| 17 | - private screenWidth: number = 0 | ||
| 18 | - private picWidth: number = 0 | ||
| 19 | - @State picHeight: number = 0 | ||
| 20 | - @State isEnableSwipe: boolean = true; | ||
| 21 | - | ||
| 22 | - // @Provide bgc: Color = Color.White; | ||
| 23 | - | ||
| 24 | - //watch监听页码回调 | ||
| 25 | - onCurrentPageNumUpdated(): void { | ||
| 26 | - Logger.info(TAG, `currentPageNum:${this.currentPageNum}`,) | ||
| 27 | - let _swiperIndex = Number.parseInt(this.currentPageNum) | ||
| 28 | - Logger.info(TAG, `_swiperIndex:${_swiperIndex}`) | ||
| 29 | - this.swiperIndex = _swiperIndex > 0 ? _swiperIndex - 1 : _swiperIndex | ||
| 30 | - } | ||
| 31 | - | ||
| 32 | - aboutToAppear(): void { | ||
| 33 | - //获取宽高尺寸 | ||
| 34 | - this.screenWidth = this.displayTool.width | ||
| 35 | - // this.picWidth = this.screenWidth - vp2px(52) | ||
| 36 | - this.picWidth = this.screenWidth | ||
| 37 | - this.picHeight = this.picWidth * 578 / 375 | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - build() { | ||
| 41 | - RelativeContainer() { | ||
| 42 | - Image($r('app.media.icon_arrow_left_white')) | ||
| 43 | - .width(24) | ||
| 44 | - .height(24) | ||
| 45 | - .aspectRatio(1) | ||
| 46 | - .interpolation(ImageInterpolation.High) | ||
| 47 | - .alignRules({ | ||
| 48 | - top: { anchor: "__container__", align: VerticalAlign.Top }, | ||
| 49 | - left: { anchor: "__container__", align: HorizontalAlign.Start } | ||
| 50 | - }) | ||
| 51 | - .onClick(() => { | ||
| 52 | - router.back(); | ||
| 53 | - }) | ||
| 54 | - .id("backImg") | ||
| 55 | - | ||
| 56 | - if (this.photoList && this.photoList?.length > 0) { | ||
| 57 | - Swiper(this.swiperController) { | ||
| 58 | - ForEach(this.photoList, (item: PhotoListBean) => { | ||
| 59 | - // MultiPictureDetailItemComponent({ MultiPictureDetailItem: item }) | ||
| 60 | - ImageItemView({ MultiPictureDetailItem: item, isEnableSwipe: this.isEnableSwipe }) | ||
| 61 | - }) | ||
| 62 | - } | ||
| 63 | - .index(this.swiperIndex) | ||
| 64 | - .width('100%') | ||
| 65 | - .height(px2vp(this.picHeight) + 32) | ||
| 66 | - .vertical(false) | ||
| 67 | - .autoPlay(false) | ||
| 68 | - .cachedCount(3) | ||
| 69 | - .indicator(false) | ||
| 70 | - .displayCount(1) | ||
| 71 | - .id('e_swiper_content') | ||
| 72 | - .alignRules({ | ||
| 73 | - center: { anchor: "__container__", align: VerticalAlign.Center }, | ||
| 74 | - middle: { anchor: "__container__", align: HorizontalAlign.Center } | ||
| 75 | - }) | ||
| 76 | - .onChange((index: number) => { | ||
| 77 | - this.swiperIndex = index | ||
| 78 | - }) | ||
| 79 | - | ||
| 80 | - Row() { | ||
| 81 | - Scroll(this.scroller) { | ||
| 82 | - Row() { | ||
| 83 | - Flex({ | ||
| 84 | - direction: FlexDirection.Column, | ||
| 85 | - justifyContent: FlexAlign.Start | ||
| 86 | - }) { | ||
| 87 | - Text() { | ||
| 88 | - Span(`${this.swiperIndex + 1}`) | ||
| 89 | - .fontSize(24) | ||
| 90 | - .fontFamily('PingFang SC-Medium') | ||
| 91 | - .fontWeight(500) | ||
| 92 | - .lineHeight(28) | ||
| 93 | - Span(`/${this.photoList.length}`) | ||
| 94 | - .fontSize(14) | ||
| 95 | - .fontFamily('PingFang SC-Medium') | ||
| 96 | - .fontWeight(500) | ||
| 97 | - .lineHeight(19) | ||
| 98 | - }.fontColor(Color.White).margin(4) | ||
| 99 | - } | ||
| 100 | - } | ||
| 101 | - .width('100%') | ||
| 102 | - .margin({ | ||
| 103 | - top: 8, | ||
| 104 | - left: 18, | ||
| 105 | - bottom: 24, | ||
| 106 | - right: 18 | ||
| 107 | - }) | ||
| 108 | - } | ||
| 109 | - .scrollable(ScrollDirection.Vertical) | ||
| 110 | - .scrollBarWidth(0) | ||
| 111 | - } | ||
| 112 | - .id('e_swiper_titles') | ||
| 113 | - .alignRules({ | ||
| 114 | - bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, | ||
| 115 | - middle: { anchor: "__container__", align: HorizontalAlign.Center } | ||
| 116 | - }) | ||
| 117 | - } | ||
| 118 | - | ||
| 119 | - ImageDownloadComponent({ url: this.photoList[this.swiperIndex].picPath }) | ||
| 120 | - .alignRules({ | ||
| 121 | - bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, | ||
| 122 | - right: { anchor: "__container__", align: HorizontalAlign.End } | ||
| 123 | - }) | ||
| 124 | - .margin({ | ||
| 125 | - top: 8, | ||
| 126 | - left: 18, | ||
| 127 | - bottom: 24, | ||
| 128 | - right: 18 | ||
| 129 | - }) | ||
| 130 | - .id("downloadImg") | ||
| 131 | - } | ||
| 132 | - .width('100%') | ||
| 133 | - .height('100%') | ||
| 134 | - .backgroundColor(Color.Black) | ||
| 135 | - .id('e_picture_container') | ||
| 136 | - // 设置顶部绘制延伸到状态栏 | ||
| 137 | - // 设置底部绘制延伸到导航条 | ||
| 138 | - .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) | ||
| 139 | - } | ||
| 140 | -} |
| @@ -9,6 +9,10 @@ import { SingleColumn999Component } from './SingleColumn999Component'; | @@ -9,6 +9,10 @@ import { SingleColumn999Component } from './SingleColumn999Component'; | ||
| 9 | import { topicInfoView } from './topicInfoView'; | 9 | import { topicInfoView } from './topicInfoView'; |
| 10 | import { DateFormatUtil, PlayerConstants, WDPlayerController } from 'wdPlayer'; | 10 | import { DateFormatUtil, PlayerConstants, WDPlayerController } from 'wdPlayer'; |
| 11 | import { AudioDataList } from 'wdBean/src/main/ets/bean/morningevening/AudioDataList'; | 11 | import { AudioDataList } from 'wdBean/src/main/ets/bean/morningevening/AudioDataList'; |
| 12 | +import { image } from '@kit.ImageKit'; | ||
| 13 | +import { getPicture, imageNet2PixelMap } from '../../utils/ImageUtils'; | ||
| 14 | +import { effectKit } from '@kit.ArkGraphics2D'; | ||
| 15 | +import { window } from '@kit.ArkUI'; | ||
| 12 | 16 | ||
| 13 | const TAG = 'MorningEveningPaperComponent'; | 17 | const TAG = 'MorningEveningPaperComponent'; |
| 14 | 18 | ||
| @@ -47,6 +51,9 @@ export struct MorningEveningPaperComponent { | @@ -47,6 +51,9 @@ export struct MorningEveningPaperComponent { | ||
| 47 | @Provide currentTime: string = "00:00"; | 51 | @Provide currentTime: string = "00:00"; |
| 48 | @Provide totalTime: string = "00:00"; | 52 | @Provide totalTime: string = "00:00"; |
| 49 | @Provide progressVal: number = 0; | 53 | @Provide progressVal: number = 0; |
| 54 | + @State mixedBgColor: string = '' | ||
| 55 | + // 顶部安全高度赋值 | ||
| 56 | + @State topSafeHeight: number = 0; | ||
| 50 | private audioDataList: AudioDataList[] = [] | 57 | private audioDataList: AudioDataList[] = [] |
| 51 | private playerController: WDPlayerController = new WDPlayerController(); | 58 | private playerController: WDPlayerController = new WDPlayerController(); |
| 52 | simpleAudioDialog: CustomDialogController = new CustomDialogController({ | 59 | simpleAudioDialog: CustomDialogController = new CustomDialogController({ |
| @@ -93,6 +100,10 @@ export struct MorningEveningPaperComponent { | @@ -93,6 +100,10 @@ export struct MorningEveningPaperComponent { | ||
| 93 | } | 100 | } |
| 94 | 101 | ||
| 95 | async aboutToAppear() { | 102 | async aboutToAppear() { |
| 103 | + let windowHight: window.Window = await window.getLastWindow(getContext(this)); | ||
| 104 | + await windowHight.setWindowLayoutFullScreen(true); | ||
| 105 | + this.topSafeHeight = px2vp(windowHight.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM).topRect.height) | ||
| 106 | + | ||
| 96 | let dailyPaperTopicPageId = await SPHelper.default.getSync('dailyPaperTopicPageId', "") as String | 107 | let dailyPaperTopicPageId = await SPHelper.default.getSync('dailyPaperTopicPageId', "") as String |
| 97 | console.info(TAG, `aboutToAppear = ` + dailyPaperTopicPageId) | 108 | console.info(TAG, `aboutToAppear = ` + dailyPaperTopicPageId) |
| 98 | const currentTime = new Date().getTime() | 109 | const currentTime = new Date().getTime() |
| @@ -110,6 +121,7 @@ export struct MorningEveningPaperComponent { | @@ -110,6 +121,7 @@ export struct MorningEveningPaperComponent { | ||
| 110 | 121 | ||
| 111 | Logger.info(TAG, "pageInfoBean dateTime = " + dateTime) | 122 | Logger.info(TAG, "pageInfoBean dateTime = " + dateTime) |
| 112 | Logger.info(TAG, "pageInfoBean subTitle = " + this.subTitle) | 123 | Logger.info(TAG, "pageInfoBean subTitle = " + this.subTitle) |
| 124 | + this.setComponentBgColor(pageInfoBean.backgroundImgUrl) | ||
| 113 | 125 | ||
| 114 | let compInfoBean = await MorningEveningViewModel.getMorningEveningCompInfo(pageInfoBean?.id, pageInfoBean?.groups[0]?.id, currentTime + "", pageInfoBean?.topicInfo?.topicId) | 126 | let compInfoBean = await MorningEveningViewModel.getMorningEveningCompInfo(pageInfoBean?.id, pageInfoBean?.groups[0]?.id, currentTime + "", pageInfoBean?.topicInfo?.topicId) |
| 115 | // this.compInfoBean = compInfoBean | 127 | // this.compInfoBean = compInfoBean |
| @@ -130,6 +142,35 @@ export struct MorningEveningPaperComponent { | @@ -130,6 +142,35 @@ export struct MorningEveningPaperComponent { | ||
| 130 | } catch (exception) { | 142 | } catch (exception) { |
| 131 | 143 | ||
| 132 | } | 144 | } |
| 145 | + | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + async setComponentBgColor(imageUrl: string) { | ||
| 149 | + // 图片转换为PixelMap对象 | ||
| 150 | + // const pixelMap: image.PixelMap = await image2PixelMap(item.icon); | ||
| 151 | + const imageSource: image.ImageSource | undefined = await getPicture(imageUrl); | ||
| 152 | + if (imageSource) { | ||
| 153 | + this.pickColor(imageSource) | ||
| 154 | + | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | + private async pickColor(imageSource: image.ImageSource | undefined) { | ||
| 160 | + if (imageSource) { | ||
| 161 | + const pixelMap: image.PixelMap = await imageNet2PixelMap(imageSource); | ||
| 162 | + effectKit.createColorPicker(pixelMap, (err, colorPicker) => { | ||
| 163 | + let color = colorPicker.getMainColorSync(); | ||
| 164 | + // 将取色器选取的color示例转换为十六进制颜色代码 | ||
| 165 | + this.mixedBgColor = "#" + color.alpha.toString(16) + color.red.toString(16) + color.green.toString(16) + color.blue.toString(16); | ||
| 166 | + }); | ||
| 167 | + | ||
| 168 | + } | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + async aboutToDisappear() { | ||
| 172 | + let windowHight: window.Window = await window.getLastWindow(getContext(this)); | ||
| 173 | + await windowHight.setWindowLayoutFullScreen(false); | ||
| 133 | } | 174 | } |
| 134 | 175 | ||
| 135 | onPageHide() { | 176 | onPageHide() { |
| @@ -175,7 +216,9 @@ export struct MorningEveningPaperComponent { | @@ -175,7 +216,9 @@ export struct MorningEveningPaperComponent { | ||
| 175 | .width('100%') | 216 | .width('100%') |
| 176 | // .backgroundColor('#000080') | 217 | // .backgroundColor('#000080') |
| 177 | // .backgroundColor(Color.Black) | 218 | // .backgroundColor(Color.Black) |
| 178 | - .backgroundColor(this.pageInfoBean?.backgroundColor ?? Color.Black) | 219 | + // .backgroundColor(this.pageInfoBean?.backgroundColor ?? Color.Black) |
| 220 | + .backgroundColor(this.mixedBgColor ?? Color.Black) | ||
| 221 | + .padding({ top: this.topSafeHeight }) | ||
| 179 | } | 222 | } |
| 180 | 223 | ||
| 181 | @Builder | 224 | @Builder |
| 1 | -import { NetworkUtil, Logger, NetworkType, SPHelper, } from 'wdKit'; | 1 | +import { NetworkUtil, Logger, NetworkType, SPHelper, WindowModel} from 'wdKit'; |
| 2 | import { ResponseDTO } from 'wdNetwork'; | 2 | import { ResponseDTO } from 'wdNetwork'; |
| 3 | import { | 3 | import { |
| 4 | ContentDetailDTO, | 4 | ContentDetailDTO, |
| @@ -78,230 +78,236 @@ export struct MultiPictureDetailPageComponent { | @@ -78,230 +78,236 @@ export struct MultiPictureDetailPageComponent { | ||
| 78 | 78 | ||
| 79 | build() { | 79 | build() { |
| 80 | RelativeContainer() { | 80 | RelativeContainer() { |
| 81 | - if (this.contentDetailData?.photoList && this.contentDetailData?.photoList?.length > 0) { | ||
| 82 | - Swiper(this.swiperController) { | ||
| 83 | - ForEach(this.contentDetailData.photoList, (item: PhotoListBean) => { | ||
| 84 | - Swiper(this.swiperControllerItem) { | ||
| 85 | - MultiPictureDetailItemComponent({ MultiPictureDetailItem: item }) | 81 | + this.init() |
| 82 | + } | ||
| 83 | + .width('100%') | ||
| 84 | + .height('100%') | ||
| 85 | + .backgroundColor(Color.Black) | ||
| 86 | + .id('e_picture_container') | ||
| 87 | + // 设置顶部绘制延伸到状态栏 | ||
| 88 | + // 设置底部绘制延伸到导航条 | ||
| 89 | + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + @Builder | ||
| 93 | + init() { | ||
| 94 | + if (this.contentDetailData.rmhPlatform == 1) { | ||
| 95 | + Row() { | ||
| 96 | + Row({ space: 8 }) { | ||
| 97 | + Row() { | ||
| 98 | + Image(this.contentDetailData?.rmhInfo?.rmhHeadUrl) | ||
| 99 | + .borderRadius(24) | ||
| 100 | + .aspectRatio(1) | ||
| 101 | + .border({ width: 1, color: Color.White, style: BorderStyle.Solid }) | ||
| 102 | + .alt($r('app.media.picture_loading')) | ||
| 103 | + .width(36) | ||
| 104 | + .height(36) | ||
| 105 | + .objectFit(ImageFit.Fill) | ||
| 106 | + .interpolation(ImageInterpolation.High) | ||
| 107 | + } | ||
| 108 | + .width('13%') | ||
| 109 | + .height('100%') | ||
| 110 | + | ||
| 111 | + Row() { | ||
| 112 | + Flex({ | ||
| 113 | + direction: FlexDirection.Column, | ||
| 114 | + justifyContent: FlexAlign.SpaceAround, | ||
| 115 | + alignItems: ItemAlign.Start | ||
| 116 | + }) { | ||
| 117 | + Text(`${this.contentDetailData?.rmhInfo?.rmhName}`) | ||
| 118 | + .fontColor(Color.White) | ||
| 119 | + .fontSize(14) | ||
| 120 | + .fontFamily('PingFang PingFang SC-Medium') | ||
| 121 | + .fontWeight(500) | ||
| 122 | + .lineHeight(17) | ||
| 123 | + .margin(0) | ||
| 124 | + .height(17) | ||
| 125 | + Text(`${this.contentDetailData?.rmhInfo?.rmhDesc}`) | ||
| 126 | + .fontColor('#676767') | ||
| 127 | + .fontSize(12) | ||
| 128 | + .fontFamily('PingFang SC-Regular') | ||
| 129 | + .fontWeight(400) | ||
| 130 | + .lineHeight(14) | ||
| 131 | + .height(14) | ||
| 132 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 133 | + .margin(0) | ||
| 134 | + .maxLines(1) | ||
| 86 | } | 135 | } |
| 87 | - .width('100%') | ||
| 88 | - .height('100%') | ||
| 89 | - .vertical(true) | ||
| 90 | - .autoPlay(false) | ||
| 91 | - .cachedCount(1) | ||
| 92 | - .indicator(false) | ||
| 93 | - .displayCount(1) | ||
| 94 | - .onAnimationEnd(event => { | ||
| 95 | - router.back() | ||
| 96 | - }) | ||
| 97 | - }) | 136 | + } |
| 137 | + .width('81%') | ||
| 138 | + .height('100%') | ||
| 98 | } | 139 | } |
| 99 | - .index(this.swiperIndex) | ||
| 100 | - .width('100%') | ||
| 101 | - .height(px2vp(this.picHeight) + 32) | ||
| 102 | - .vertical(false) | ||
| 103 | - .autoPlay(false) | ||
| 104 | - .cachedCount(3) | ||
| 105 | - .indicator(false) | ||
| 106 | - .displayCount(1) | ||
| 107 | - .loop(false) | ||
| 108 | - .id('e_swiper_content') | ||
| 109 | - .alignRules({ | ||
| 110 | - center: { anchor: "__container__", align: VerticalAlign.Center }, | ||
| 111 | - middle: { anchor: "__container__", align: HorizontalAlign.Center } | ||
| 112 | - }) | ||
| 113 | - .onChange((index: number) => { | ||
| 114 | - this.swiperIndex = index | 140 | + .width('74.4%') |
| 141 | + .height('100%') | ||
| 142 | + .margin({ | ||
| 143 | + top: 0, | ||
| 144 | + bottom: 0, | ||
| 145 | + left: 16, | ||
| 146 | + right: 0 | ||
| 115 | }) | 147 | }) |
| 116 | 148 | ||
| 117 | - if (this.contentDetailData.rmhPlatform == 1) { | 149 | + if (this.followStatus == '0') { |
| 118 | Row() { | 150 | Row() { |
| 119 | - Row({ space: 8 }) { | 151 | + Button({ type: ButtonType.Normal, stateEffect: true }) { |
| 120 | Row() { | 152 | Row() { |
| 121 | - Image(this.contentDetailData?.rmhInfo?.rmhHeadUrl) | ||
| 122 | - .borderRadius(24) | ||
| 123 | - .aspectRatio(1) | ||
| 124 | - .border({ width: 1, color: Color.White, style: BorderStyle.Solid }) | ||
| 125 | - .alt($r('app.media.picture_loading')) | ||
| 126 | - .width(36) | ||
| 127 | - .height(36) | ||
| 128 | - .objectFit(ImageFit.Fill) | ||
| 129 | - .interpolation(ImageInterpolation.High) | ||
| 130 | - } | ||
| 131 | - .width('13%') | ||
| 132 | - .height('100%') | ||
| 133 | - | ||
| 134 | - Row() { | ||
| 135 | - Flex({ | ||
| 136 | - direction: FlexDirection.Column, | ||
| 137 | - justifyContent: FlexAlign.SpaceAround, | ||
| 138 | - alignItems: ItemAlign.Start | ||
| 139 | - }) { | ||
| 140 | - Text(`${this.contentDetailData?.rmhInfo?.rmhName}`) | ||
| 141 | - .fontColor(Color.White) | ||
| 142 | - .fontSize(14) | ||
| 143 | - .fontFamily('PingFang PingFang SC-Medium') | ||
| 144 | - .fontWeight(500) | ||
| 145 | - .lineHeight(17) | ||
| 146 | - .margin(0) | ||
| 147 | - .height(17) | ||
| 148 | - Text(`${this.contentDetailData?.rmhInfo?.rmhDesc}`) | ||
| 149 | - .fontColor('#676767') | ||
| 150 | - .fontSize(12) | ||
| 151 | - .fontFamily('PingFang SC-Regular') | ||
| 152 | - .fontWeight(400) | ||
| 153 | - .lineHeight(14) | ||
| 154 | - .height(14) | ||
| 155 | - .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 156 | - .margin(0) | ||
| 157 | - } | ||
| 158 | - } | ||
| 159 | - .width('81%') | ||
| 160 | - .height('100%') | 153 | + Text('+关注').fontSize(12).fontColor(0xffffff) |
| 154 | + }.alignItems(VerticalAlign.Center) | ||
| 161 | } | 155 | } |
| 162 | - .width('74.4%') | ||
| 163 | - .height('100%') | ||
| 164 | - .margin({ | ||
| 165 | - top: 0, | ||
| 166 | - bottom: 0, | ||
| 167 | - left: 16, | ||
| 168 | - right: 0 | 156 | + .borderRadius(4) |
| 157 | + .backgroundColor('#ED2800') | ||
| 158 | + .width(48) | ||
| 159 | + .height(24) | ||
| 160 | + .onClick(() => { | ||
| 161 | + this.handleAccention() | ||
| 169 | }) | 162 | }) |
| 170 | - | ||
| 171 | - if (this.followStatus == '0') { | ||
| 172 | - Row() { | ||
| 173 | - Button({ type: ButtonType.Normal, stateEffect: true }) { | ||
| 174 | - Row() { | ||
| 175 | - Text('+关注').fontSize(12).fontColor(0xffffff) | ||
| 176 | - }.alignItems(VerticalAlign.Center) | ||
| 177 | - } | ||
| 178 | - .borderRadius(4) | ||
| 179 | - .backgroundColor('#ED2800') | ||
| 180 | - .width(48) | ||
| 181 | - .height(24) | ||
| 182 | - .onClick(() => { | ||
| 183 | - this.handleAccention() | ||
| 184 | - }) | ||
| 185 | - } | ||
| 186 | - .justifyContent(FlexAlign.Center) | ||
| 187 | - .alignItems(VerticalAlign.Center) | ||
| 188 | - .width('21.6%') | ||
| 189 | - .height('100%') | ||
| 190 | - } | 163 | + } |
| 164 | + .justifyContent(FlexAlign.Center) | ||
| 165 | + .alignItems(VerticalAlign.Center) | ||
| 166 | + .width('21.6%') | ||
| 167 | + .height('100%') | ||
| 168 | + } | ||
| 169 | + } | ||
| 170 | + .width('100%') | ||
| 171 | + .height(44) | ||
| 172 | + .alignRules({ | ||
| 173 | + top: { anchor: "__container__", align: VerticalAlign.Top }, | ||
| 174 | + middle: { anchor: "__container__", align: HorizontalAlign.Center } | ||
| 175 | + }) | ||
| 176 | + .id('e_attention') | ||
| 177 | + } | ||
| 178 | + if (this.contentDetailData?.photoList && this.contentDetailData?.photoList?.length > 0) { | ||
| 179 | + Swiper(this.swiperController) { | ||
| 180 | + ForEach(this.contentDetailData.photoList, (item: PhotoListBean) => { | ||
| 181 | + Swiper(this.swiperControllerItem) { | ||
| 182 | + MultiPictureDetailItemComponent({ MultiPictureDetailItem: item }) | ||
| 191 | } | 183 | } |
| 192 | .width('100%') | 184 | .width('100%') |
| 193 | - .height(44) | ||
| 194 | - .alignRules({ | ||
| 195 | - top: { anchor: "e_swiper_content", align: VerticalAlign.Top }, | ||
| 196 | - middle: { anchor: "e_swiper_content", align: HorizontalAlign.Center } | 185 | + .height('100%') |
| 186 | + .vertical(true) | ||
| 187 | + .autoPlay(false) | ||
| 188 | + .cachedCount(1) | ||
| 189 | + .indicator(false) | ||
| 190 | + .displayCount(1) | ||
| 191 | + .onAnimationEnd(event => { | ||
| 192 | + router.back() | ||
| 197 | }) | 193 | }) |
| 198 | - .id('e_attention') | ||
| 199 | - } | ||
| 200 | - Row() { | ||
| 201 | - Scroll(this.scroller) { | ||
| 202 | - Row() { | ||
| 203 | - Flex({ | ||
| 204 | - direction: FlexDirection.Column, | ||
| 205 | - justifyContent: FlexAlign.Start | ||
| 206 | - }) { | ||
| 207 | - Text() { | ||
| 208 | - Span(`${this.swiperIndex + 1}`) | ||
| 209 | - .fontSize(24) | ||
| 210 | - .fontFamily('PingFang SC-Medium') | ||
| 211 | - .fontWeight(500) | ||
| 212 | - .lineHeight(28) | ||
| 213 | - Span(`/${this.contentDetailData.photoList.length}`) | ||
| 214 | - .fontSize(14) | ||
| 215 | - .fontFamily('PingFang SC-Medium') | ||
| 216 | - .fontWeight(500) | ||
| 217 | - .lineHeight(19) | ||
| 218 | - }.fontColor(Color.White).margin(4) | 194 | + }) |
| 195 | + } | ||
| 196 | + .index(this.swiperIndex) | ||
| 197 | + .width('100%') | ||
| 198 | + .height(px2vp(this.picHeight) + 32) | ||
| 199 | + .vertical(false) | ||
| 200 | + .autoPlay(false) | ||
| 201 | + .cachedCount(3) | ||
| 202 | + .indicator(false) | ||
| 203 | + .displayCount(1) | ||
| 204 | + .loop(false) | ||
| 205 | + .id('e_swiper_content') | ||
| 206 | + .alignRules({ | ||
| 207 | + center: { anchor: "__container__", align: VerticalAlign.Center }, | ||
| 208 | + middle: { anchor: "__container__", align: HorizontalAlign.Center } | ||
| 209 | + }) | ||
| 210 | + .onChange((index: number) => { | ||
| 211 | + this.swiperIndex = index | ||
| 212 | + }) | ||
| 219 | 213 | ||
| 220 | - Text(`${this.contentDetailData.newsTitle}`) | ||
| 221 | - .fontColor(Color.White) | ||
| 222 | - .fontSize(16) | ||
| 223 | - .fontFamily('PingFang SC-Semibold') | ||
| 224 | - .fontWeight(600) | ||
| 225 | - .lineHeight(24) | ||
| 226 | - .margin({ | ||
| 227 | - top: 4, | ||
| 228 | - left: 0, | ||
| 229 | - bottom: 4, | ||
| 230 | - right: 0 | ||
| 231 | - }) | ||
| 232 | - Text(`${this.contentDetailData.photoList?.[this.swiperIndex].picDesc}`) | ||
| 233 | - .fontColor(Color.White) | 214 | + Row() { |
| 215 | + Scroll(this.scroller) { | ||
| 216 | + Row() { | ||
| 217 | + Flex({ | ||
| 218 | + direction: FlexDirection.Column, | ||
| 219 | + justifyContent: FlexAlign.Start | ||
| 220 | + }) { | ||
| 221 | + Text() { | ||
| 222 | + Span(`${this.swiperIndex + 1}`) | ||
| 223 | + .fontSize(24) | ||
| 224 | + .fontFamily('PingFang SC-Medium') | ||
| 225 | + .fontWeight(500) | ||
| 226 | + .lineHeight(28) | ||
| 227 | + Span(`/${this.contentDetailData.photoList.length}`) | ||
| 234 | .fontSize(14) | 228 | .fontSize(14) |
| 235 | - .fontFamily('PingFang SC-Regular') | ||
| 236 | - .fontWeight(400) | ||
| 237 | - .lineHeight(22) | ||
| 238 | - .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 239 | - .margin({ | ||
| 240 | - top: 4, | ||
| 241 | - left: 0, | ||
| 242 | - bottom: 4, | ||
| 243 | - right: 18 | ||
| 244 | - }) | ||
| 245 | - .maxLines(16) | ||
| 246 | - } | ||
| 247 | - } | ||
| 248 | - .width('100%') | ||
| 249 | - .margin({ | ||
| 250 | - top: 8, | ||
| 251 | - left: 18, | ||
| 252 | - bottom: 24, | ||
| 253 | - right: 18 | ||
| 254 | - }) | ||
| 255 | - } | ||
| 256 | - .scrollable(ScrollDirection.Vertical) | ||
| 257 | - .scrollBarWidth(0) | ||
| 258 | - .height(px2vp(this.titleHeight)) | ||
| 259 | - } | ||
| 260 | - .id('e_swiper_titles') | ||
| 261 | - .alignRules({ | ||
| 262 | - bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, | ||
| 263 | - middle: { anchor: "__container__", align: HorizontalAlign.Center } | ||
| 264 | - }) | ||
| 265 | - .height(px2vp(this.titleHeight) + 64) | 229 | + .fontFamily('PingFang SC-Medium') |
| 230 | + .fontWeight(500) | ||
| 231 | + .lineHeight(19) | ||
| 232 | + }.fontColor(Color.White).margin(4) | ||
| 266 | 233 | ||
| 267 | - } | ||
| 268 | - if (this.netStatus !== undefined) { | ||
| 269 | - EmptyComponent({ | ||
| 270 | - emptyType: this.netStatus, emptyButton: true, retry: () => { | ||
| 271 | - this.getContentDetailData() | 234 | + Text(`${this.contentDetailData.newsTitle}`) |
| 235 | + .fontColor(Color.White) | ||
| 236 | + .fontSize(16) | ||
| 237 | + .fontFamily('PingFang SC-Semibold') | ||
| 238 | + .fontWeight(600) | ||
| 239 | + .lineHeight(24) | ||
| 240 | + .margin({ | ||
| 241 | + top: 4, | ||
| 242 | + left: 0, | ||
| 243 | + bottom: 4, | ||
| 244 | + right: 0 | ||
| 245 | + }) | ||
| 246 | + Text(`${this.contentDetailData.photoList?.[this.swiperIndex].picDesc}`) | ||
| 247 | + .fontColor(Color.White) | ||
| 248 | + .fontSize(14) | ||
| 249 | + .fontFamily('PingFang SC-Regular') | ||
| 250 | + .fontWeight(400) | ||
| 251 | + .lineHeight(22) | ||
| 252 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 253 | + .margin({ | ||
| 254 | + top: 4, | ||
| 255 | + left: 0, | ||
| 256 | + bottom: 4, | ||
| 257 | + right: 18 | ||
| 258 | + }) | ||
| 259 | + .maxLines(16) | ||
| 260 | + } | ||
| 272 | } | 261 | } |
| 273 | - }) | ||
| 274 | - .id('e_empty_content') | ||
| 275 | - .alignRules({ | ||
| 276 | - center: { anchor: "__container__", align: VerticalAlign.Center }, | ||
| 277 | - middle: { anchor: "__container__", align: HorizontalAlign.Center } | 262 | + .width('100%') |
| 263 | + .margin({ | ||
| 264 | + top: 8, | ||
| 265 | + left: 18, | ||
| 266 | + bottom: 24, | ||
| 267 | + right: 18 | ||
| 278 | }) | 268 | }) |
| 269 | + } | ||
| 270 | + .scrollable(ScrollDirection.Vertical) | ||
| 271 | + .scrollBarWidth(0) | ||
| 272 | + .height(px2vp(this.titleHeight)) | ||
| 279 | } | 273 | } |
| 280 | - OperRowListView({ | ||
| 281 | - contentDetailData: this.contentDetailData, | 274 | + .id('e_swiper_titles') |
| 275 | + .alignRules({ | ||
| 276 | + bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, | ||
| 277 | + middle: { anchor: "__container__", align: HorizontalAlign.Center } | ||
| 282 | }) | 278 | }) |
| 279 | + .height(px2vp(this.titleHeight) + 64) | ||
| 280 | + | ||
| 281 | + } | ||
| 282 | + if (this.netStatus !== undefined) { | ||
| 283 | + EmptyComponent({ | ||
| 284 | + emptyType: this.netStatus, emptyButton: true, retry: () => { | ||
| 285 | + this.getContentDetailData() | ||
| 286 | + } | ||
| 287 | + }) | ||
| 288 | + .id('e_empty_content') | ||
| 283 | .alignRules({ | 289 | .alignRules({ |
| 284 | - bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, | 290 | + center: { anchor: "__container__", align: VerticalAlign.Center }, |
| 285 | middle: { anchor: "__container__", align: HorizontalAlign.Center } | 291 | middle: { anchor: "__container__", align: HorizontalAlign.Center } |
| 286 | }) | 292 | }) |
| 287 | - .width('100%') | ||
| 288 | - .height(56) | ||
| 289 | - .margin({ | ||
| 290 | - top: 16, | ||
| 291 | - left: 16, | ||
| 292 | - right: 16, | ||
| 293 | - bottom: 0 | ||
| 294 | - }) | ||
| 295 | - .border({ width: { top: 0.5 }, color: '#FFFFFF' }) | ||
| 296 | - .id('e_oper_row') | ||
| 297 | } | 293 | } |
| 298 | - .width('100%') | ||
| 299 | - .height('100%') | ||
| 300 | - .backgroundColor(Color.Black) | ||
| 301 | - .id('e_picture_container') | ||
| 302 | - // 设置顶部绘制延伸到状态栏 | ||
| 303 | - // 设置底部绘制延伸到导航条 | ||
| 304 | - .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) | 294 | + OperRowListView({ |
| 295 | + contentDetailData: this.contentDetailData, | ||
| 296 | + }) | ||
| 297 | + .alignRules({ | ||
| 298 | + bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, | ||
| 299 | + middle: { anchor: "__container__", align: HorizontalAlign.Center } | ||
| 300 | + }) | ||
| 301 | + .width('100%') | ||
| 302 | + .height(56) | ||
| 303 | + .margin({ | ||
| 304 | + top: 16, | ||
| 305 | + left: 16, | ||
| 306 | + right: 16, | ||
| 307 | + bottom: 0 | ||
| 308 | + }) | ||
| 309 | + .border({ width: { top: 0.5 }, color: '#FFFFFF' }) | ||
| 310 | + .id('e_oper_row') | ||
| 305 | } | 311 | } |
| 306 | 312 | ||
| 307 | getContentDetailData() { | 313 | getContentDetailData() { |
| @@ -318,6 +324,11 @@ export struct MultiPictureDetailPageComponent { | @@ -318,6 +324,11 @@ export struct MultiPictureDetailPageComponent { | ||
| 318 | } | 324 | } |
| 319 | this.netStatus = undefined | 325 | this.netStatus = undefined |
| 320 | this.contentDetailData = resDTO.data?.[0]; | 326 | this.contentDetailData = resDTO.data?.[0]; |
| 327 | + if (this.contentDetailData.rmhPlatform == 1) { | ||
| 328 | + WindowModel.shared.setWindowSystemBarProperties({ | ||
| 329 | + statusBarContentColor: '#ffffff', | ||
| 330 | + }) | ||
| 331 | + } | ||
| 321 | // this.contentDetailData.photoList = [] | 332 | // this.contentDetailData.photoList = [] |
| 322 | if (this.contentDetailData?.photoList && this.contentDetailData?.photoList?.length === 0) { | 333 | if (this.contentDetailData?.photoList && this.contentDetailData?.photoList?.length === 0) { |
| 323 | // 暂无内容 | 334 | // 暂无内容 |
| 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 | } |
| @@ -102,7 +102,7 @@ export struct Card19Component { | @@ -102,7 +102,7 @@ export struct Card19Component { | ||
| 102 | } | 102 | } |
| 103 | return photo | 103 | return photo |
| 104 | }) | 104 | }) |
| 105 | - ProcessUtils.gotoMultiPictureListPage(photoList) | 105 | + ProcessUtils.gotoMultiPictureListPage(photoList,0) |
| 106 | }) | 106 | }) |
| 107 | //TODO 底部的:分享、评论、点赞 功能;需要引用一个公共组件 | 107 | //TODO 底部的:分享、评论、点赞 功能;需要引用一个公共组件 |
| 108 | } | 108 | } |
| @@ -104,6 +104,9 @@ struct createImg { | @@ -104,6 +104,9 @@ struct createImg { | ||
| 104 | } | 104 | } |
| 105 | .align(Alignment.BottomEnd) | 105 | .align(Alignment.BottomEnd) |
| 106 | } | 106 | } |
| 107 | + .onClick((event: ClickEvent) => { | ||
| 108 | + ProcessUtils.gotoVod(this.contentDTO) | ||
| 109 | + }) | ||
| 107 | } else { | 110 | } else { |
| 108 | // 竖图显示,宽度占50%,高度自适应 | 111 | // 竖图显示,宽度占50%,高度自适应 |
| 109 | GridCol({ | 112 | GridCol({ |
| @@ -17,7 +17,7 @@ export class publishCommentModel { | @@ -17,7 +17,7 @@ export class publishCommentModel { | ||
| 17 | /*内容类别, 1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,8:图文,9:组图,10:H5新闻,11:频道,12:组件,13:音频,14:动态(13和14为中文版新增) 页面必传*/ | 17 | /*内容类别, 1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,8:图文,9:组图,10:H5新闻,11:频道,12:组件,13:音频,14:动态(13和14为中文版新增) 页面必传*/ |
| 18 | targetType: string = '' | 18 | targetType: string = '' |
| 19 | /*评论总数*/ | 19 | /*评论总数*/ |
| 20 | - totalCommentNumer: string = '' | 20 | + totalCommentNumer: string = '0' |
| 21 | 21 | ||
| 22 | //评论传参 | 22 | //评论传参 |
| 23 | /*评论图片url,多个逗号隔开*/ | 23 | /*评论图片url,多个逗号隔开*/ |
| 1 | - | ||
| 2 | import { publishCommentModel } from '../model/PublishCommentModel' | 1 | import { publishCommentModel } from '../model/PublishCommentModel' |
| 3 | 2 | ||
| 4 | @Preview | 3 | @Preview |
| 5 | @Component | 4 | @Component |
| 6 | export struct CommentTabComponent { | 5 | export struct CommentTabComponent { |
| 7 | @ObjectLink publishCommentModel: publishCommentModel | 6 | @ObjectLink publishCommentModel: publishCommentModel |
| 7 | + /*展示类型*/ | ||
| 8 | + @State type:number = 1 | ||
| 9 | + @State placeHolder: string = '说两句...' | ||
| 8 | 10 | ||
| 9 | build() { | 11 | build() { |
| 12 | + Row(){ | ||
| 13 | + Stack({alignContent:Alignment.Start}){ | ||
| 14 | + Image($r('app.media.comment_img_input_hui')).width(151).height(30) | ||
| 15 | + Text(this.placeHolder).fontSize(12).fontColor('#999999').margin({left:10}) | ||
| 16 | + } | ||
| 17 | + }.width(151).height(30) | ||
| 18 | + } | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +@Preview | ||
| 22 | +@Component | ||
| 23 | +export struct CommentIconComponent { | ||
| 24 | + @ObjectLink publishCommentModel: publishCommentModel | ||
| 25 | + /*展示类型*/ | ||
| 26 | + @State type:number = 1 | ||
| 27 | + | ||
| 28 | + build() { | ||
| 29 | + Row(){ | ||
| 30 | + Stack({alignContent:Alignment.TopEnd}){ | ||
| 31 | + Image($r('app.media.comment_icon')).width(24).height(24) | ||
| 32 | + // Stack({alignContent:Alignment.Start}) { | ||
| 33 | + // Image($r('app.media.comment_icon_number')).objectFit(ImageFit.Fill).width(12).height(12) | ||
| 34 | + Text(this.publishCommentModel.totalCommentNumer + '12345' +' ') | ||
| 35 | + .fontSize(8) | ||
| 36 | + .fontColor('#ffffff') | ||
| 37 | + // .backgroundColor('#ED2800') | ||
| 38 | + .height(12) | ||
| 39 | + .margin({ left: 6 }) | ||
| 40 | + .backgroundImage($r('app.media.comment_icon_number')) | ||
| 41 | + // }.width(25) | ||
| 42 | + | ||
| 43 | + .offset({ | ||
| 44 | + x:12 | ||
| 45 | + }) | ||
| 46 | + } | ||
| 47 | + }.width(24).height(24) | ||
| 10 | } | 48 | } |
| 11 | } | 49 | } |
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/QualityCommentsComponent.ets
| @@ -5,7 +5,6 @@ import commentViewModel from '../viewmodel/CommentViewModel' | @@ -5,7 +5,6 @@ import commentViewModel from '../viewmodel/CommentViewModel' | ||
| 5 | import { router, window } from '@kit.ArkUI' | 5 | import { router, window } from '@kit.ArkUI' |
| 6 | import { CustomTitleUI } from '../../reusable/CustomTitleUI' | 6 | import { CustomTitleUI } from '../../reusable/CustomTitleUI' |
| 7 | import { MyCommentDataSource } from '../model/MyCommentDataSource' | 7 | import { MyCommentDataSource } from '../model/MyCommentDataSource' |
| 8 | -import { HttpUtils } from 'wdNetwork/src/main/ets/utils/HttpUtils' | ||
| 9 | import { HttpUrlUtils } from 'wdNetwork/Index' | 8 | import { HttpUrlUtils } from 'wdNetwork/Index' |
| 10 | import PageModel from '../../../viewmodel/PageModel' | 9 | import PageModel from '../../../viewmodel/PageModel' |
| 11 | import { ErrorComponent } from '../../view/ErrorComponent' | 10 | import { ErrorComponent } from '../../view/ErrorComponent' |
| @@ -196,8 +195,8 @@ export struct QualityCommentsComponent { | @@ -196,8 +195,8 @@ export struct QualityCommentsComponent { | ||
| 196 | // alldata:[], | 195 | // alldata:[], |
| 197 | // scroller:this.scroller, | 196 | // scroller:this.scroller, |
| 198 | // customList:()=>{ | 197 | // customList:()=>{ |
| 199 | - // // this.listLayout() | ||
| 200 | - // this.testLayout() | 198 | + // this.listLayout() |
| 199 | + // // this.testLayout() | ||
| 201 | // }, | 200 | // }, |
| 202 | // onRefresh:(resolve)=>{ | 201 | // onRefresh:(resolve)=>{ |
| 203 | // this.currentPage = 1 | 202 | // this.currentPage = 1 |
| @@ -269,7 +268,7 @@ export struct QualityCommentsComponent { | @@ -269,7 +268,7 @@ export struct QualityCommentsComponent { | ||
| 269 | List({ space: 12, scroller:this.scroller }){ | 268 | List({ space: 12, scroller:this.scroller }){ |
| 270 | LazyForEach(this.allDatas, (item: commentItemModel, index: number) => { | 269 | LazyForEach(this.allDatas, (item: commentItemModel, index: number) => { |
| 271 | ListItem() { | 270 | ListItem() { |
| 272 | - // QualityCommentItem({ item: item, index: index }).margin({ left: 12, right: 12 }) | 271 | + QualityCommentItem({ item: item, index: index }).margin({ left: 12, right: 12 }) |
| 273 | } | 272 | } |
| 274 | }) | 273 | }) |
| 275 | } | 274 | } |
| @@ -77,6 +77,7 @@ export struct ZhSingleRow02 { | @@ -77,6 +77,7 @@ export struct ZhSingleRow02 { | ||
| 77 | .padding({ | 77 | .padding({ |
| 78 | right: $r('app.float.card_comp_pagePadding_lf'), | 78 | right: $r('app.float.card_comp_pagePadding_lf'), |
| 79 | }) | 79 | }) |
| 80 | + .visibility(this.compDTO?.objectType === '0' || this.compDTO?.objectType === '' ? Visibility.None : Visibility.Visible) | ||
| 80 | .onClick(() => { | 81 | .onClick(() => { |
| 81 | if (this.compDTO?.objectType === '11') { | 82 | if (this.compDTO?.objectType === '11') { |
| 82 | ProcessUtils.jumpChannelTab(this.compDTO.objectId, this.compDTO.pageId as string) | 83 | ProcessUtils.jumpChannelTab(this.compDTO.objectId, this.compDTO.pageId as string) |
| 1 | +import { CompDTO, ContentDTO, Params } from 'wdBean'; | ||
| 2 | +import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | ||
| 3 | +import { HttpUrlUtils } from 'wdNetwork/Index'; | ||
| 4 | +import { postInteractAccentionOperateParams } from 'wdBean'; | ||
| 5 | +import { PageRepository } from '../../repository/PageRepository'; | ||
| 6 | +import { CommonConstants } from 'wdConstant/Index'; | ||
| 7 | +import { ProcessUtils } from 'wdRouter'; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 小视频横划卡 | ||
| 11 | + * Zh_Single_Row-02 | ||
| 12 | + */ | ||
| 13 | +const TAG = 'Zh_Single_Row-03' | ||
| 14 | + | ||
| 15 | +@Entry | ||
| 16 | +@Component | ||
| 17 | +export struct ZhSingleRow03 { | ||
| 18 | + @State compDTO: CompDTO = {} as CompDTO | ||
| 19 | + scroller: Scroller = new Scroller() | ||
| 20 | + | ||
| 21 | + build() { | ||
| 22 | + Column() { | ||
| 23 | + //顶部 | ||
| 24 | + this.CompHeader(this.compDTO) | ||
| 25 | + | ||
| 26 | + Scroll(this.scroller){ | ||
| 27 | + Row() { | ||
| 28 | + ForEach(this.compDTO.operDataList, (item: ContentDTO) => { | ||
| 29 | + Column() { | ||
| 30 | + Row() { | ||
| 31 | + Image(item.coverUrl) | ||
| 32 | + .width(106) | ||
| 33 | + .height(60) | ||
| 34 | + .margin({right: 12}) | ||
| 35 | + Text(item.newsTitle) | ||
| 36 | + .width(154) | ||
| 37 | + .height(60) | ||
| 38 | + .maxLines(3) | ||
| 39 | + .textOverflow({overflow: TextOverflow.Ellipsis}) | ||
| 40 | + } | ||
| 41 | + .margin({bottom: 16}) | ||
| 42 | + | ||
| 43 | + Row() { | ||
| 44 | + Flex({justifyContent: FlexAlign.SpaceBetween}){ | ||
| 45 | + Row() { | ||
| 46 | + Text(item.liveInfo.liveStartTime.split(' ')[0].slice(5)) | ||
| 47 | + .margin({right: 6}) | ||
| 48 | + .fontColor(0x000000) | ||
| 49 | + .fontSize(13) | ||
| 50 | + .textAlign(TextAlign.Start) | ||
| 51 | + Image($r('app.media.timeline_rect')) | ||
| 52 | + .width(4) | ||
| 53 | + .height(3) | ||
| 54 | + .margin({right: 6}) | ||
| 55 | + Text(item.liveInfo.liveStartTime.split(' ')[1].slice(0, 5)) | ||
| 56 | + .margin({right: 6}) | ||
| 57 | + .fontColor(0x000000) | ||
| 58 | + .fontSize(13) | ||
| 59 | + Text('开始直播') | ||
| 60 | + .fontColor(0xC8C8C8) | ||
| 61 | + .fontSize(13) | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + Row() { | ||
| 65 | + Text('预约') | ||
| 66 | + .width(48) | ||
| 67 | + .height(24) | ||
| 68 | + .backgroundColor(0xED2800) | ||
| 69 | + .fontColor(0xffffff) | ||
| 70 | + .fontSize(12) | ||
| 71 | + .textAlign(TextAlign.Center) | ||
| 72 | + .borderRadius(3) | ||
| 73 | + } | ||
| 74 | + .margin({top: -5}) | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + } | ||
| 78 | + } | ||
| 79 | + .width(298) | ||
| 80 | + .height(116) | ||
| 81 | + .padding({top: 12, bottom: 12, left: 12, right: 12}) | ||
| 82 | + .backgroundColor(0xf9f9f9) | ||
| 83 | + .margin({right: 8}) | ||
| 84 | + .onClick(() => { | ||
| 85 | + ProcessUtils.processPage(item) | ||
| 86 | + }) | ||
| 87 | + }) | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | + .scrollable(ScrollDirection.Horizontal) | ||
| 91 | + .scrollBar(BarState.Off) | ||
| 92 | + } | ||
| 93 | + .padding({ | ||
| 94 | + left: $r('app.float.card_comp_pagePadding_lf'), | ||
| 95 | + right: $r('app.float.card_comp_pagePadding_lf'), | ||
| 96 | + top: $r('app.float.card_comp_pagePadding_tb'), | ||
| 97 | + bottom: $r('app.float.card_comp_pagePadding_tb') | ||
| 98 | + }) | ||
| 99 | + .backgroundColor($r('app.color.white')) | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + @Builder | ||
| 103 | + CompHeader(item: CompDTO) { | ||
| 104 | + Row() { | ||
| 105 | + Row() { | ||
| 106 | + Image($r("app.media.redLine")) | ||
| 107 | + .width(3) | ||
| 108 | + .height(16) | ||
| 109 | + .margin({ right: 4 }) | ||
| 110 | + Text('直播预约') | ||
| 111 | + .fontSize($r("app.float.font_size_17")) | ||
| 112 | + .fontColor($r("app.color.color_222222")) | ||
| 113 | + .fontWeight(600) | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + Row() { | ||
| 117 | + Text("更多") | ||
| 118 | + .fontSize($r("app.float.font_size_14")) | ||
| 119 | + .fontColor($r("app.color.color_999999")) | ||
| 120 | + .margin({ right: 1 }) | ||
| 121 | + Image($r("app.media.more")) | ||
| 122 | + .width(14) | ||
| 123 | + .height(14) | ||
| 124 | + .onClick(() => { | ||
| 125 | + // TODO 跳转的页面,定义的入参可能不合理。推荐id: 41 | ||
| 126 | + let params = {'index': "1"} as Record<string, string> | ||
| 127 | + WDRouterRule.jumpWithPage(WDRouterPage.followListPage, params) | ||
| 128 | + }) | ||
| 129 | + } | ||
| 130 | + .padding({ | ||
| 131 | + right: $r('app.float.card_comp_pagePadding_lf'), | ||
| 132 | + }) | ||
| 133 | + .visibility(this.compDTO?.objectType === '0' || this.compDTO?.objectType === '' ? Visibility.None : Visibility.Visible) | ||
| 134 | + .onClick(() => { | ||
| 135 | + if (this.compDTO?.objectType === '11') { | ||
| 136 | + ProcessUtils.jumpChannelTab(this.compDTO.objectId, this.compDTO.pageId as string) | ||
| 137 | + } else if (this.compDTO?.objectType === '5') { | ||
| 138 | + ProcessUtils._gotoSpecialTopic(this.compDTO.linkUrl) | ||
| 139 | + } else if (this.compDTO?.objectType === '6') { | ||
| 140 | + ProcessUtils._gotoDefaultWeb(this.compDTO.linkUrl) | ||
| 141 | + } | ||
| 142 | + }) | ||
| 143 | + } | ||
| 144 | + .justifyContent(FlexAlign.SpaceBetween) | ||
| 145 | + .margin({ top: 8, bottom: 8 }) | ||
| 146 | + .width('100%') | ||
| 147 | + } | ||
| 148 | +} | ||
| 149 | + | ||
| 150 | +@Extend(Text) | ||
| 151 | +function textOverflowStyle(maxLine: number) { | ||
| 152 | + .maxLines(maxLine) | ||
| 153 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 154 | +} | ||
| 155 | + | ||
| 156 | +@Component | ||
| 157 | +struct CreatorItem { | ||
| 158 | + @Prop item: ContentDTO | ||
| 159 | + @State rmhIsAttention: number = 0 | ||
| 160 | + build() { | ||
| 161 | + ListItem() { | ||
| 162 | + Column() { | ||
| 163 | + Stack({ alignContent: Alignment.Bottom }) { | ||
| 164 | + Image(this.item.coverUrl) | ||
| 165 | + .width(156) | ||
| 166 | + .height(208) | ||
| 167 | + Row() | ||
| 168 | + .width(156) | ||
| 169 | + .height(80) | ||
| 170 | + .linearGradient({ | ||
| 171 | + direction: GradientDirection.Bottom, | ||
| 172 | + colors: [['rgba(0, 0, 0, 0.0)', 0.0], ['rgba(0, 0, 0, 0.3)', 1.0]] | ||
| 173 | + }) | ||
| 174 | + Text(this.item.newsTitle) | ||
| 175 | + .fontColor(0xffffff) | ||
| 176 | + .fontSize(14) | ||
| 177 | + .maxLines(2) | ||
| 178 | + .textOverflow({overflow: TextOverflow.Ellipsis}) | ||
| 179 | + .width(140) | ||
| 180 | + .margin({bottom: 8}) | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | + .width(156) | ||
| 184 | + .height(208) | ||
| 185 | + .margin({ right: 11 }) | ||
| 186 | + .borderColor($r('app.color.color_EDEDED')) | ||
| 187 | + .borderRadius($r('app.float.image_border_radius')) | ||
| 188 | + } | ||
| 189 | + .onClick((event: ClickEvent) => { | ||
| 190 | + ProcessUtils.processPage(this.item) | ||
| 191 | + }) | ||
| 192 | + } | ||
| 193 | + | ||
| 194 | + /** | ||
| 195 | + * 关注号主 TODO 这里后面需要抽离 | ||
| 196 | + */ | ||
| 197 | + handleAccention(item: ContentDTO, status: number) { | ||
| 198 | + this.rmhIsAttention = this.rmhIsAttention ? 0 : 1 | ||
| 199 | + return | ||
| 200 | + // 未登录,跳转登录 | ||
| 201 | + if (!HttpUrlUtils.getUserId()) { | ||
| 202 | + WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 203 | + return | ||
| 204 | + } | ||
| 205 | + | ||
| 206 | + const params: postInteractAccentionOperateParams = { | ||
| 207 | + attentionUserType: item.rmhInfo?.userType || '', //被关注用户类型(1 普通用户 2 视频号 3 矩阵号) | ||
| 208 | + attentionUserId: item.rmhInfo?.userId || '', // 被关注用户号主id | ||
| 209 | + attentionCreatorId: item.rmhInfo?.rmhId || '', // 被关注用户号主id | ||
| 210 | + // userType: 1, | ||
| 211 | + // userId: '1', // TODO 用户id需要从本地获取 | ||
| 212 | + status: status, | ||
| 213 | + } | ||
| 214 | + PageRepository.postInteractAccentionOperate(params).then(res => { | ||
| 215 | + console.log(TAG, '关注号主==', JSON.stringify(res.data)) | ||
| 216 | + if (status === 1) { | ||
| 217 | + this.rmhIsAttention = 0 | ||
| 218 | + } else { | ||
| 219 | + this.rmhIsAttention = 1 | ||
| 220 | + } | ||
| 221 | + }) | ||
| 222 | + } | ||
| 223 | +} |
| @@ -36,6 +36,7 @@ export struct ZhSingleRow04 { | @@ -36,6 +36,7 @@ export struct ZhSingleRow04 { | ||
| 36 | .width(14) | 36 | .width(14) |
| 37 | .height(14) | 37 | .height(14) |
| 38 | } | 38 | } |
| 39 | + .visibility(this.compDTO?.objectType === '0' || this.compDTO?.objectType === '' ? Visibility.None : Visibility.Visible) | ||
| 39 | .onClick(() => { | 40 | .onClick(() => { |
| 40 | if (this.compDTO?.objectType === '11') { | 41 | if (this.compDTO?.objectType === '11') { |
| 41 | ProcessUtils.jumpChannelTab(this.compDTO.objectId, this.compDTO.pageId as string) | 42 | ProcessUtils.jumpChannelTab(this.compDTO.objectId, this.compDTO.pageId as string) |
| @@ -120,6 +120,9 @@ export struct ZhSingleRow06 { | @@ -120,6 +120,9 @@ export struct ZhSingleRow06 { | ||
| 120 | .maxLines(1) | 120 | .maxLines(1) |
| 121 | .textOverflow({overflow: TextOverflow.Ellipsis}) | 121 | .textOverflow({overflow: TextOverflow.Ellipsis}) |
| 122 | } | 122 | } |
| 123 | + .onClick(() => { | ||
| 124 | + ProcessUtils.commentGotoWeb(item.operDataList[0]?.commentInfo as commentInfo) | ||
| 125 | + }) | ||
| 123 | 126 | ||
| 124 | Row() { | 127 | Row() { |
| 125 | Image($r("app.media.icon_elite_comment")) | 128 | Image($r("app.media.icon_elite_comment")) |
| @@ -9,12 +9,13 @@ import { EmptyComponent } from '../../view/EmptyComponent'; | @@ -9,12 +9,13 @@ import { EmptyComponent } from '../../view/EmptyComponent'; | ||
| 9 | const TAG = "AppointmentListUI" | 9 | const TAG = "AppointmentListUI" |
| 10 | 10 | ||
| 11 | @Component | 11 | @Component |
| 12 | -export struct AppointmentListUI{ | 12 | +export struct AppointmentListUI { |
| 13 | @State data: LazyDataSource<MineAppointmentItem> = new LazyDataSource(); | 13 | @State data: LazyDataSource<MineAppointmentItem> = new LazyDataSource(); |
| 14 | - @State count:number = 0; | ||
| 15 | - @State isLoading:boolean = false | ||
| 16 | - @State hasMore:boolean = true | ||
| 17 | - curPageNum:number = 1; | 14 | + @State count: number = 0; |
| 15 | + @State isLoading: boolean = false | ||
| 16 | + @State hasMore: boolean = true | ||
| 17 | + curPageNum: number = 1; | ||
| 18 | + @State isGetRequest: boolean = false | ||
| 18 | 19 | ||
| 19 | aboutToAppear() { | 20 | aboutToAppear() { |
| 20 | this.getNewPageData() | 21 | this.getNewPageData() |
| @@ -23,37 +24,41 @@ export struct AppointmentListUI{ | @@ -23,37 +24,41 @@ export struct AppointmentListUI{ | ||
| 23 | build() { | 24 | build() { |
| 24 | Column() { | 25 | Column() { |
| 25 | //标题栏目 | 26 | //标题栏目 |
| 26 | - CustomTitleUI({titleName:"预约列表"}) | ||
| 27 | - if(this.count == 0){ | ||
| 28 | - EmptyComponent({emptyType:10}) | ||
| 29 | - .height('100%') | ||
| 30 | - .width('100%') | ||
| 31 | - }else{ | 27 | + CustomTitleUI({ titleName: "预约列表" }) |
| 28 | + if (this.count == 0) { | ||
| 29 | + if (this.isGetRequest == true) { | ||
| 30 | + EmptyComponent({ emptyType: 10 }) | ||
| 31 | + .height('100%') | ||
| 32 | + .width('100%') | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + } else { | ||
| 32 | //刷新控件 TODO | 36 | //刷新控件 TODO |
| 33 | //List | 37 | //List |
| 34 | List({ space: '6lpx' }) { | 38 | List({ space: '6lpx' }) { |
| 35 | LazyForEach(this.data, (item: MineAppointmentItem, index: number) => { | 39 | LazyForEach(this.data, (item: MineAppointmentItem, index: number) => { |
| 36 | ListItem() { | 40 | ListItem() { |
| 37 | - AppointmentListChildComponent({item:item}) | 41 | + AppointmentListChildComponent({ item: item }) |
| 38 | } | 42 | } |
| 39 | - .onClick(()=>{ | 43 | + .onClick(() => { |
| 40 | //TODO 跳转 | 44 | //TODO 跳转 |
| 41 | }) | 45 | }) |
| 42 | }, (item: MineAppointmentItem, index: number) => index.toString()) | 46 | }, (item: MineAppointmentItem, index: number) => index.toString()) |
| 43 | 47 | ||
| 44 | //没有更多数据 显示提示 | 48 | //没有更多数据 显示提示 |
| 45 | - if(!this.hasMore){ | ||
| 46 | - ListItem(){ | 49 | + if (!this.hasMore) { |
| 50 | + ListItem() { | ||
| 47 | ListHasNoMoreDataUI() | 51 | ListHasNoMoreDataUI() |
| 48 | } | 52 | } |
| 49 | } | 53 | } |
| 50 | - }.cachedCount(4) | 54 | + } |
| 55 | + .cachedCount(4) | ||
| 51 | .scrollBar(BarState.Off) | 56 | .scrollBar(BarState.Off) |
| 52 | - .margin({top:'23lpx',left:'23lpx',right:'23lpx'}) | 57 | + .margin({ top: '23lpx', left: '23lpx', right: '23lpx' }) |
| 53 | .layoutWeight(1) | 58 | .layoutWeight(1) |
| 54 | - .onReachEnd(()=>{ | ||
| 55 | - console.log(TAG,"触底了"); | ||
| 56 | - if(!this.isLoading){ | 59 | + .onReachEnd(() => { |
| 60 | + console.log(TAG, "触底了"); | ||
| 61 | + if (!this.isLoading) { | ||
| 57 | //加载分页数据 | 62 | //加载分页数据 |
| 58 | this.getNewPageData() | 63 | this.getNewPageData() |
| 59 | } | 64 | } |
| @@ -65,70 +70,73 @@ export struct AppointmentListUI{ | @@ -65,70 +70,73 @@ export struct AppointmentListUI{ | ||
| 65 | .width('100%') | 70 | .width('100%') |
| 66 | } | 71 | } |
| 67 | 72 | ||
| 68 | - getNewPageData(){ | 73 | + getNewPageData() { |
| 69 | this.isLoading = true | 74 | this.isLoading = true |
| 70 | - if(this.hasMore){ | ||
| 71 | - MinePageDatasModel.getAppointmentListData("20",`${this.curPageNum}`,getContext(this)).then((value)=>{ | ||
| 72 | - if (!this.data || value.list.length == 0){ | ||
| 73 | - this.hasMore = false | ||
| 74 | - }else{ | ||
| 75 | - value.list.forEach((value)=>{ | ||
| 76 | - let dealTime = this.DealStartTime(value.planStartTime) | ||
| 77 | - if(dealTime!=null && dealTime.length === 2){ | ||
| 78 | - this.data.push(new MineAppointmentItem(value.imageUrl,value.status,value.title,true,dealTime[0],dealTime[1],value.relType,value.liveId,value.relId)) | ||
| 79 | - }else { | ||
| 80 | - this.data.push(new MineAppointmentItem(value.imageUrl,value.status,value.title,true,"","",value.relType,value.liveId,value.relId)) | ||
| 81 | - } | ||
| 82 | - }) | ||
| 83 | - this.data.notifyDataReload() | ||
| 84 | - this.count = this.data.totalCount() | ||
| 85 | - if (this.data.totalCount() < value.totalCount) { | ||
| 86 | - this.curPageNum++ | ||
| 87 | - }else { | ||
| 88 | - this.hasMore = false | 75 | + if (this.hasMore) { |
| 76 | + MinePageDatasModel.getAppointmentListData("20", `${this.curPageNum}`, getContext(this)).then((value) => { | ||
| 77 | + if (!this.data || value.list.length == 0) { | ||
| 78 | + this.hasMore = false | ||
| 79 | + } else { | ||
| 80 | + value.list.forEach((value) => { | ||
| 81 | + let dealTime = this.DealStartTime(value.planStartTime) | ||
| 82 | + if (dealTime != null && dealTime.length === 2) { | ||
| 83 | + this.data.push(new MineAppointmentItem(value.imageUrl, value.status, value.title, true, dealTime[0], dealTime[1], value.relType, value.liveId, value.relId)) | ||
| 84 | + } else { | ||
| 85 | + this.data.push(new MineAppointmentItem(value.imageUrl, value.status, value.title, true, "", "", value.relType, value.liveId, value.relId)) | ||
| 89 | } | 86 | } |
| 87 | + }) | ||
| 88 | + this.data.notifyDataReload() | ||
| 89 | + this.count = this.data.totalCount() | ||
| 90 | + if (this.data.totalCount() < value.totalCount) { | ||
| 91 | + this.curPageNum++ | ||
| 92 | + } else { | ||
| 93 | + this.hasMore = false | ||
| 90 | } | 94 | } |
| 91 | - }).catch((err:Error)=>{ | ||
| 92 | - console.log(TAG,JSON.stringify(err)) | ||
| 93 | - }) | 95 | + } |
| 96 | + this.isGetRequest = true | ||
| 97 | + this.isLoading = false | ||
| 98 | + }).catch((err: Error) => { | ||
| 99 | + console.log(TAG, JSON.stringify(err)) | ||
| 100 | + this.isGetRequest = true | ||
| 101 | + this.isLoading = false | ||
| 102 | + }) | ||
| 94 | } | 103 | } |
| 95 | - this.isLoading = false | ||
| 96 | } | 104 | } |
| 97 | 105 | ||
| 98 | - DealStartTime(planStartTime:string):string[]{ | ||
| 99 | - let dealData:string[] = [] | 106 | + DealStartTime(planStartTime: string): string[] { |
| 107 | + let dealData: string[] = [] | ||
| 100 | 108 | ||
| 101 | - if(!StringUtils.isNotEmpty(planStartTime)){ | ||
| 102 | - console.log(TAG,"格式有误") | 109 | + if (!StringUtils.isNotEmpty(planStartTime)) { |
| 110 | + console.log(TAG, "格式有误") | ||
| 103 | return dealData | 111 | return dealData |
| 104 | } | 112 | } |
| 105 | 113 | ||
| 106 | - if(planStartTime.indexOf(" ") === -1){ | ||
| 107 | - console.log(TAG,"格式有误") | 114 | + if (planStartTime.indexOf(" ") === -1) { |
| 115 | + console.log(TAG, "格式有误") | ||
| 108 | return dealData | 116 | return dealData |
| 109 | } | 117 | } |
| 110 | let arr = planStartTime.split(" ") | 118 | let arr = planStartTime.split(" ") |
| 111 | - if(arr!=null && StringUtils.isNotEmpty(arr[0])){ //处理年月日 | 119 | + if (arr != null && StringUtils.isNotEmpty(arr[0])) { //处理年月日 |
| 112 | let time = arr[0].split("-"); | 120 | let time = arr[0].split("-"); |
| 113 | - if(time.length === 3){ | ||
| 114 | - let month = time[1].indexOf("0") === 0 ? time[1].substring(1):time[1] | 121 | + if (time.length === 3) { |
| 122 | + let month = time[1].indexOf("0") === 0 ? time[1].substring(1) : time[1] | ||
| 115 | let day = time[2] | 123 | let day = time[2] |
| 116 | 124 | ||
| 117 | dealData[0] = `${month}月${day}日` | 125 | dealData[0] = `${month}月${day}日` |
| 118 | - let today = `${new Date().getMonth()+1}月${new Date().getDate()}日` | ||
| 119 | - if(dealData[0] === today){ | 126 | + let today = `${new Date().getMonth() + 1}月${new Date().getDate()}日` |
| 127 | + if (dealData[0] === today) { | ||
| 120 | dealData[0] = "今日" | 128 | dealData[0] = "今日" |
| 121 | } | 129 | } |
| 122 | } | 130 | } |
| 123 | } | 131 | } |
| 124 | 132 | ||
| 125 | - if(arr!=null && StringUtils.isNotEmpty(arr[1])){ //处理时分 | 133 | + if (arr != null && StringUtils.isNotEmpty(arr[1])) { //处理时分 |
| 126 | let time = arr[1].split(":"); | 134 | let time = arr[1].split(":"); |
| 127 | - if(time.length === 3){ | ||
| 128 | - dealData[1] = `${time[0]}:${time[1]}` | 135 | + if (time.length === 3) { |
| 136 | + dealData[1] = `${time[0]}:${time[1]}` | ||
| 129 | } | 137 | } |
| 130 | } | 138 | } |
| 131 | - console.log(TAG,JSON.stringify(dealData)) | 139 | + console.log(TAG, JSON.stringify(dealData)) |
| 132 | return dealData | 140 | return dealData |
| 133 | } | 141 | } |
| 134 | } | 142 | } |
| @@ -256,11 +256,13 @@ export struct FollowChildComponent{ | @@ -256,11 +256,13 @@ export struct FollowChildComponent{ | ||
| 256 | if (value.code === 0 || value.code.toString() === "0") { | 256 | if (value.code === 0 || value.code.toString() === "0") { |
| 257 | this.data.status = this.data.status ==="0"?"1":"0" | 257 | this.data.status = this.data.status ==="0"?"1":"0" |
| 258 | 258 | ||
| 259 | - if(this.data.status === "1"){ | ||
| 260 | - UserDataLocal.setUserFollowOperation(DateTimeUtils.getTimeStamp()+"") | ||
| 261 | - }else{ | ||
| 262 | - UserDataLocal.setUserFollowOperation(DateTimeUtils.getTimeStamp()+","+this.data.creatorId) | ||
| 263 | - } | 259 | + UserDataLocal.setUserFollowOperation(this.data.creatorId+","+this.data.status) |
| 260 | + | ||
| 261 | + // if(this.data.status === "1"){ | ||
| 262 | + // UserDataLocal.setUserFollowOperation(DateTimeUtils.getTimeStamp()+"") | ||
| 263 | + // }else{ | ||
| 264 | + // UserDataLocal.setUserFollowOperation(DateTimeUtils.getTimeStamp()+","+this.data.creatorId) | ||
| 265 | + // } | ||
| 264 | } | 266 | } |
| 265 | } | 267 | } |
| 266 | }) | 268 | }) |
| @@ -24,6 +24,7 @@ export struct FollowListDetailUI { | @@ -24,6 +24,7 @@ export struct FollowListDetailUI { | ||
| 24 | @State hasMore: boolean = true | 24 | @State hasMore: boolean = true |
| 25 | curPageNum: number = 1; | 25 | curPageNum: number = 1; |
| 26 | preferences: dataPreferences.Preferences | null = null; | 26 | preferences: dataPreferences.Preferences | null = null; |
| 27 | + @State isGetRequest: boolean = false | ||
| 27 | 28 | ||
| 28 | aboutToAppear() { | 29 | aboutToAppear() { |
| 29 | this.getNewPageData() | 30 | this.getNewPageData() |
| @@ -33,9 +34,12 @@ export struct FollowListDetailUI { | @@ -33,9 +34,12 @@ export struct FollowListDetailUI { | ||
| 33 | build() { | 34 | build() { |
| 34 | Column() { | 35 | Column() { |
| 35 | if (this.count === 0) { | 36 | if (this.count === 0) { |
| 36 | - EmptyComponent({emptyType:14}) | ||
| 37 | - .layoutWeight(1) | ||
| 38 | - .width('100%') | 37 | + if (this.isGetRequest == true) { |
| 38 | + EmptyComponent({ emptyType: 14 }) | ||
| 39 | + .layoutWeight(1) | ||
| 40 | + .width('100%') | ||
| 41 | + } | ||
| 42 | + | ||
| 39 | } else { | 43 | } else { |
| 40 | List({ space: 3 }) { | 44 | List({ space: 3 }) { |
| 41 | LazyForEach(this.data, (item: FollowListDetailItem, index: number = 0) => { | 45 | LazyForEach(this.data, (item: FollowListDetailItem, index: number = 0) => { |
| @@ -47,7 +51,7 @@ export struct FollowListDetailUI { | @@ -47,7 +51,7 @@ export struct FollowListDetailUI { | ||
| 47 | }, (item: FollowListDetailItem) => item.creatorId) | 51 | }, (item: FollowListDetailItem) => item.creatorId) |
| 48 | 52 | ||
| 49 | //没有更多数据 显示提示 | 53 | //没有更多数据 显示提示 |
| 50 | - if (!this.hasMore) { | 54 | + if (!this.hasMore && this.count != 0) { |
| 51 | ListItem() { | 55 | ListItem() { |
| 52 | ListHasNoMoreDataUI() | 56 | ListHasNoMoreDataUI() |
| 53 | } | 57 | } |
| @@ -75,16 +79,17 @@ export struct FollowListDetailUI { | @@ -75,16 +79,17 @@ export struct FollowListDetailUI { | ||
| 75 | let observer = (key: string) => { | 79 | let observer = (key: string) => { |
| 76 | if (key == UserDataLocal.USER_FOLLOW_OPERATION) { | 80 | if (key == UserDataLocal.USER_FOLLOW_OPERATION) { |
| 77 | if (this.creatorDirectoryId === -1) { | 81 | if (this.creatorDirectoryId === -1) { |
| 78 | - let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION,"") as string | 82 | + let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION, "") as string |
| 79 | let arr = value.split(',') | 83 | let arr = value.split(',') |
| 80 | - if(arr!=null && arr.length === 2){ | ||
| 81 | - this.data.getDataArray().forEach((element,index) => { | ||
| 82 | - if (element.creatorId === arr[1]) { | 84 | + if (arr[1] == "0") { |
| 85 | + this.data.getDataArray().forEach((element, index) => { | ||
| 86 | + if (element.creatorId === arr[0]) { | ||
| 83 | this.data.deleteItem(index) | 87 | this.data.deleteItem(index) |
| 88 | + this.count = this.data.size() | ||
| 84 | } | 89 | } |
| 85 | }); | 90 | }); |
| 86 | - }else{ | ||
| 87 | - if(!this.isLoading){ | 91 | + } else { |
| 92 | + if (!this.isLoading) { | ||
| 88 | this.isLoading = true | 93 | this.isLoading = true |
| 89 | this.hasMore = true | 94 | this.hasMore = true |
| 90 | this.curPageNum = 1 | 95 | this.curPageNum = 1 |
| @@ -93,6 +98,16 @@ export struct FollowListDetailUI { | @@ -93,6 +98,16 @@ export struct FollowListDetailUI { | ||
| 93 | this.getMyFollowListDetail() | 98 | this.getMyFollowListDetail() |
| 94 | } | 99 | } |
| 95 | } | 100 | } |
| 101 | + }else{ | ||
| 102 | + let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION, "") as string | ||
| 103 | + let arr = value.split(',') | ||
| 104 | + if (arr[1] == "0"){ | ||
| 105 | + this.data.getDataArray().forEach((element, index) => { | ||
| 106 | + if (element.creatorId === arr[0]) { | ||
| 107 | + this.data.getData(index).status = "0" | ||
| 108 | + } | ||
| 109 | + }) | ||
| 110 | + } | ||
| 96 | } | 111 | } |
| 97 | } | 112 | } |
| 98 | } | 113 | } |
| @@ -109,7 +124,7 @@ export struct FollowListDetailUI { | @@ -109,7 +124,7 @@ export struct FollowListDetailUI { | ||
| 109 | this.isLoading = false | 124 | this.isLoading = false |
| 110 | } else { | 125 | } else { |
| 111 | value.list.forEach((value) => { | 126 | value.list.forEach((value) => { |
| 112 | - let fansNum:number = value.fansNum | 127 | + let fansNum: number = value.fansNum |
| 113 | let fansNumString = "" | 128 | let fansNumString = "" |
| 114 | if (fansNum > 10000) { | 129 | if (fansNum > 10000) { |
| 115 | let temp = (fansNum / 10000) + "" | 130 | let temp = (fansNum / 10000) + "" |
| @@ -123,7 +138,7 @@ export struct FollowListDetailUI { | @@ -123,7 +138,7 @@ export struct FollowListDetailUI { | ||
| 123 | } else { | 138 | } else { |
| 124 | fansNumString = fansNum + "" | 139 | fansNumString = fansNum + "" |
| 125 | } | 140 | } |
| 126 | - this.data.push(new FollowListDetailItem(value.attentionHeadPhotoUrl, value.attentionUserName, fansNumString, value.introduction, value.attentionCreatorId, "1", value.attentionUserId, value.attentionUserType, value.attentionUserId, value.mainControl, value.banControl,value.authIcon)) | 141 | + this.data.push(new FollowListDetailItem(value.attentionHeadPhotoUrl, value.attentionUserName, fansNumString, value.introduction, value.attentionCreatorId, "1", value.attentionUserId, value.attentionUserType, value.attentionUserId, value.mainControl, value.banControl, value.authIcon)) |
| 127 | }) | 142 | }) |
| 128 | this.data.notifyDataReload() | 143 | this.data.notifyDataReload() |
| 129 | this.count = this.data.totalCount() | 144 | this.count = this.data.totalCount() |
| @@ -134,12 +149,15 @@ export struct FollowListDetailUI { | @@ -134,12 +149,15 @@ export struct FollowListDetailUI { | ||
| 134 | } | 149 | } |
| 135 | } | 150 | } |
| 136 | this.isLoading = false | 151 | this.isLoading = false |
| 152 | + this.isGetRequest = true | ||
| 137 | }).catch((err: Error) => { | 153 | }).catch((err: Error) => { |
| 138 | console.log(TAG, "请求失败") | 154 | console.log(TAG, "请求失败") |
| 155 | + this.isGetRequest = true | ||
| 139 | this.isLoading = false | 156 | this.isLoading = false |
| 140 | }) | 157 | }) |
| 141 | - }else { | 158 | + } else { |
| 142 | this.isLoading = false | 159 | this.isLoading = false |
| 160 | + this.isGetRequest = true | ||
| 143 | } | 161 | } |
| 144 | } | 162 | } |
| 145 | 163 | ||
| @@ -161,6 +179,7 @@ export struct FollowListDetailUI { | @@ -161,6 +179,7 @@ export struct FollowListDetailUI { | ||
| 161 | }).catch((err: Error) => { | 179 | }).catch((err: Error) => { |
| 162 | console.log(TAG, "请求失败") | 180 | console.log(TAG, "请求失败") |
| 163 | this.isLoading = false | 181 | this.isLoading = false |
| 182 | + this.isGetRequest = true | ||
| 164 | }) | 183 | }) |
| 165 | } | 184 | } |
| 166 | } | 185 | } |
| @@ -169,7 +188,7 @@ export struct FollowListDetailUI { | @@ -169,7 +188,7 @@ export struct FollowListDetailUI { | ||
| 169 | getFollowListStatus(result: MineFollowListDetailItem) { | 188 | getFollowListStatus(result: MineFollowListDetailItem) { |
| 170 | let data_temp: FollowListDetailItem[] = [] | 189 | let data_temp: FollowListDetailItem[] = [] |
| 171 | result.list.forEach((item) => { | 190 | result.list.forEach((item) => { |
| 172 | - data_temp.push(new FollowListDetailItem(item.headPhotoUrl, item.cnUserName, item.cnFansNum, item.introduction, item.creatorId, "0", item.attentionUserId, item.cnUserType, item.cnUserId, item.cnMainControl, -1,item.authIcon)) | 191 | + data_temp.push(new FollowListDetailItem(item.headPhotoUrl, item.cnUserName, item.cnFansNum, item.introduction, item.creatorId, "0", item.attentionUserId, item.cnUserType, item.cnUserId, item.cnMainControl, -1, item.authIcon)) |
| 173 | }) | 192 | }) |
| 174 | let request = new CreatorDetailRequestItem() | 193 | let request = new CreatorDetailRequestItem() |
| 175 | 194 | ||
| @@ -206,6 +225,7 @@ export struct FollowListDetailUI { | @@ -206,6 +225,7 @@ export struct FollowListDetailUI { | ||
| 206 | console.log(TAG, JSON.stringify(err)) | 225 | console.log(TAG, JSON.stringify(err)) |
| 207 | this.isLoading = false | 226 | this.isLoading = false |
| 208 | this.count = this.count === -1 ? 0 : this.count | 227 | this.count = this.count === -1 ? 0 : this.count |
| 228 | + this.isGetRequest = true | ||
| 209 | }) | 229 | }) |
| 210 | } | 230 | } |
| 211 | 231 | ||
| @@ -225,7 +245,7 @@ export struct FollowListDetailUI { | @@ -225,7 +245,7 @@ export struct FollowListDetailUI { | ||
| 225 | }) | 245 | }) |
| 226 | 246 | ||
| 227 | result.forEach((item) => { | 247 | result.forEach((item) => { |
| 228 | - this.data.push(new FollowListDetailItem(item.headPhotoUrl, item.cnUserName, item.cnFansNum, item.introduction, item.creatorId, item.status, item.attentionUserId, item.cnUserType, item.cnUserId, item.mainControl, item.banControl,item.authIcon)) | 248 | + this.data.push(new FollowListDetailItem(item.headPhotoUrl, item.cnUserName, item.cnFansNum, item.introduction, item.creatorId, item.status, item.attentionUserId, item.cnUserType, item.cnUserId, item.mainControl, item.banControl, item.authIcon)) |
| 229 | }) | 249 | }) |
| 230 | 250 | ||
| 231 | this.data.notifyDataReload() | 251 | this.data.notifyDataReload() |
| @@ -238,9 +258,11 @@ export struct FollowListDetailUI { | @@ -238,9 +258,11 @@ export struct FollowListDetailUI { | ||
| 238 | } | 258 | } |
| 239 | 259 | ||
| 240 | this.isLoading = false | 260 | this.isLoading = false |
| 261 | + this.isGetRequest = true | ||
| 241 | }).catch((err: Error) => { | 262 | }).catch((err: Error) => { |
| 242 | console.log(TAG, "请求失败") | 263 | console.log(TAG, "请求失败") |
| 243 | this.isLoading = false | 264 | this.isLoading = false |
| 265 | + this.isGetRequest = true | ||
| 244 | }) | 266 | }) |
| 245 | } | 267 | } |
| 246 | } | 268 | } |
| @@ -27,6 +27,7 @@ export struct HomePageBottomComponent{ | @@ -27,6 +27,7 @@ export struct HomePageBottomComponent{ | ||
| 27 | @State userId:string = ""; | 27 | @State userId:string = ""; |
| 28 | @Link commentNum:number | 28 | @Link commentNum:number |
| 29 | preferences: dataPreferences.Preferences | null = null; | 29 | preferences: dataPreferences.Preferences | null = null; |
| 30 | + @State isGetRequest:boolean = false | ||
| 30 | 31 | ||
| 31 | aboutToAppear(){ | 32 | aboutToAppear(){ |
| 32 | this.getNewPageData() | 33 | this.getNewPageData() |
| @@ -39,10 +40,11 @@ export struct HomePageBottomComponent{ | @@ -39,10 +40,11 @@ export struct HomePageBottomComponent{ | ||
| 39 | if (key == UserDataLocal.USER_FOLLOW_OPERATION) { | 40 | if (key == UserDataLocal.USER_FOLLOW_OPERATION) { |
| 40 | let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION,"") as string | 41 | let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION,"") as string |
| 41 | let arr = value.split(',') | 42 | let arr = value.split(',') |
| 42 | - if(arr!=null && arr.length === 2){ | 43 | + if(arr[1] == "0"){ |
| 43 | this.data_follow.getDataArray().forEach((element,index) => { | 44 | this.data_follow.getDataArray().forEach((element,index) => { |
| 44 | - if (element.creatorId === arr[1]) { | 45 | + if (element.creatorId === arr[0]) { |
| 45 | this.data_follow.deleteItem(index) | 46 | this.data_follow.deleteItem(index) |
| 47 | + this.count = this.data_follow.size() | ||
| 46 | } | 48 | } |
| 47 | }); | 49 | }); |
| 48 | }else{ | 50 | }else{ |
| @@ -62,12 +64,14 @@ export struct HomePageBottomComponent{ | @@ -62,12 +64,14 @@ export struct HomePageBottomComponent{ | ||
| 62 | 64 | ||
| 63 | build(){ | 65 | build(){ |
| 64 | Column(){ | 66 | Column(){ |
| 65 | - Divider().width('100%') | ||
| 66 | - .height('2lpx') | ||
| 67 | - .strokeWidth('1lpx') | ||
| 68 | - .backgroundColor($r('app.color.color_EDEDED')) | 67 | + if(this.isGetRequest == true){ |
| 68 | + Divider().width('100%') | ||
| 69 | + .height('2lpx') | ||
| 70 | + .strokeWidth('1lpx') | ||
| 71 | + .backgroundColor($r('app.color.color_EDEDED')) | ||
| 72 | + } | ||
| 69 | 73 | ||
| 70 | - if(this.count === 0){ | 74 | + if(this.count === 0 ){ |
| 71 | if(this.style === 1){ | 75 | if(this.style === 1){ |
| 72 | Column(){ | 76 | Column(){ |
| 73 | Row(){ | 77 | Row(){ |
| @@ -92,15 +96,19 @@ export struct HomePageBottomComponent{ | @@ -92,15 +96,19 @@ export struct HomePageBottomComponent{ | ||
| 92 | let params = {'index': "1"} as Record<string, string> | 96 | let params = {'index': "1"} as Record<string, string> |
| 93 | WDRouterRule.jumpWithPage(WDRouterPage.followListPage,params) | 97 | WDRouterRule.jumpWithPage(WDRouterPage.followListPage,params) |
| 94 | }) | 98 | }) |
| 95 | - | ||
| 96 | - EmptyComponent({emptyType:14}) | ||
| 97 | - .layoutWeight(1) | ||
| 98 | - .width('100%') | 99 | + if(this.isGetRequest == true){ |
| 100 | + EmptyComponent({emptyType:14}) | ||
| 101 | + .layoutWeight(1) | ||
| 102 | + .width('100%') | ||
| 103 | + } | ||
| 99 | }.layoutWeight(1) | 104 | }.layoutWeight(1) |
| 100 | .justifyContent(FlexAlign.Start) | 105 | .justifyContent(FlexAlign.Start) |
| 101 | }else{ | 106 | }else{ |
| 102 | - ListHasNoMoreDataUI({style:2}) | ||
| 103 | - .layoutWeight(1) | 107 | + if(this.isGetRequest == true){ |
| 108 | + EmptyComponent({emptyType:11}) | ||
| 109 | + .layoutWeight(1) | ||
| 110 | + .width('100%') | ||
| 111 | + } | ||
| 104 | } | 112 | } |
| 105 | }else{ | 113 | }else{ |
| 106 | if(this.style === 1){ | 114 | if(this.style === 1){ |
| @@ -244,12 +252,15 @@ export struct HomePageBottomComponent{ | @@ -244,12 +252,15 @@ export struct HomePageBottomComponent{ | ||
| 244 | } | 252 | } |
| 245 | } | 253 | } |
| 246 | this.isLoading = false | 254 | this.isLoading = false |
| 255 | + this.isGetRequest = true | ||
| 247 | }).catch((err:Error)=>{ | 256 | }).catch((err:Error)=>{ |
| 248 | console.log(TAG,"请求失败") | 257 | console.log(TAG,"请求失败") |
| 249 | this.isLoading = false | 258 | this.isLoading = false |
| 259 | + this.isGetRequest = true | ||
| 250 | }) | 260 | }) |
| 251 | }else{ | 261 | }else{ |
| 252 | this.isLoading = false | 262 | this.isLoading = false |
| 263 | + this.isGetRequest = true | ||
| 253 | } | 264 | } |
| 254 | } | 265 | } |
| 255 | 266 | ||
| @@ -266,17 +277,18 @@ export struct HomePageBottomComponent{ | @@ -266,17 +277,18 @@ export struct HomePageBottomComponent{ | ||
| 266 | MinePageDatasModel.getMineCommentListData(time,object,getContext(this)).then((value)=>{ | 277 | MinePageDatasModel.getMineCommentListData(time,object,getContext(this)).then((value)=>{ |
| 267 | if (!this.data_comment || value.list.length == 0){ | 278 | if (!this.data_comment || value.list.length == 0){ |
| 268 | this.hasMore = false | 279 | this.hasMore = false |
| 280 | + this.isLoading = false | ||
| 269 | }else{ | 281 | }else{ |
| 270 | this.getCommentListStatus(value) | 282 | this.getCommentListStatus(value) |
| 271 | } | 283 | } |
| 272 | - this.isLoading = false | ||
| 273 | - this.commentNum = value.totalCount | ||
| 274 | }).catch((err:Error)=>{ | 284 | }).catch((err:Error)=>{ |
| 275 | console.log(TAG,"请求失败") | 285 | console.log(TAG,"请求失败") |
| 276 | this.isLoading = false | 286 | this.isLoading = false |
| 287 | + this.isGetRequest = true | ||
| 277 | }) | 288 | }) |
| 278 | }else{ | 289 | }else{ |
| 279 | this.isLoading = false | 290 | this.isLoading = false |
| 291 | + this.isGetRequest = true | ||
| 280 | } | 292 | } |
| 281 | } | 293 | } |
| 282 | } | 294 | } |
| @@ -329,9 +341,11 @@ export struct HomePageBottomComponent{ | @@ -329,9 +341,11 @@ export struct HomePageBottomComponent{ | ||
| 329 | } | 341 | } |
| 330 | 342 | ||
| 331 | this.isLoading = false | 343 | this.isLoading = false |
| 344 | + this.isGetRequest = true | ||
| 332 | }).catch((err:Error)=>{ | 345 | }).catch((err:Error)=>{ |
| 333 | console.log(TAG,"请求失败") | 346 | console.log(TAG,"请求失败") |
| 334 | this.isLoading = false | 347 | this.isLoading = false |
| 348 | + this.isGetRequest = true | ||
| 335 | }) | 349 | }) |
| 336 | } | 350 | } |
| 337 | 351 |
| @@ -6,50 +6,61 @@ import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI'; | @@ -6,50 +6,61 @@ import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI'; | ||
| 6 | import { MineCommentListDetailItem } from '../../../viewmodel/MineCommentListDetailItem'; | 6 | import { MineCommentListDetailItem } from '../../../viewmodel/MineCommentListDetailItem'; |
| 7 | import { OtherUserCommentLikeStatusRequestItem } from '../../../viewmodel/OtherUserCommentLikeStatusRequestItem'; | 7 | import { OtherUserCommentLikeStatusRequestItem } from '../../../viewmodel/OtherUserCommentLikeStatusRequestItem'; |
| 8 | import { ChildCommentComponent } from './ChildCommentComponent'; | 8 | import { ChildCommentComponent } from './ChildCommentComponent'; |
| 9 | +import { EmptyComponent } from '../../view/EmptyComponent'; | ||
| 9 | 10 | ||
| 10 | const TAG = "HomePageBottomComponent" | 11 | const TAG = "HomePageBottomComponent" |
| 12 | + | ||
| 11 | @Component | 13 | @Component |
| 12 | -export struct OtherHomePageBottomCommentComponent{ | 14 | +export struct OtherHomePageBottomCommentComponent { |
| 13 | @Prop curUserId: string | 15 | @Prop curUserId: string |
| 14 | @State data_comment: LazyDataSource<CommentListItem> = new LazyDataSource(); | 16 | @State data_comment: LazyDataSource<CommentListItem> = new LazyDataSource(); |
| 15 | - @State isLoading:boolean = false | ||
| 16 | - @State hasMore:boolean = true | ||
| 17 | - curPageNum:number = 1; | ||
| 18 | - @State count:number = 0; | ||
| 19 | - @Prop levelHead:string | ||
| 20 | - @Link commentNum:number | ||
| 21 | - | ||
| 22 | - aboutToAppear(){ | 17 | + @State isLoading: boolean = false |
| 18 | + @State hasMore: boolean = true | ||
| 19 | + curPageNum: number = 1; | ||
| 20 | + @State count: number = 0; | ||
| 21 | + @Prop levelHead: string | ||
| 22 | + @Link commentNum: number | ||
| 23 | + @State isGetRequest: boolean = false | ||
| 24 | + | ||
| 25 | + aboutToAppear() { | ||
| 23 | this.getNewPageData() | 26 | this.getNewPageData() |
| 24 | } | 27 | } |
| 25 | 28 | ||
| 26 | - build(){ | ||
| 27 | - Column(){ | 29 | + build() { |
| 30 | + Column() { | ||
| 28 | Divider().width('100%') | 31 | Divider().width('100%') |
| 29 | .height('2lpx') | 32 | .height('2lpx') |
| 30 | .strokeWidth('1lpx') | 33 | .strokeWidth('1lpx') |
| 31 | .backgroundColor($r('app.color.color_EDEDED')) | 34 | .backgroundColor($r('app.color.color_EDEDED')) |
| 32 | 35 | ||
| 33 | - if(this.count === 0){ | ||
| 34 | - ListHasNoMoreDataUI({style:2}) | ||
| 35 | - .height('100%') | ||
| 36 | - }else{ | 36 | + if (this.count === 0) { |
| 37 | + if (this.isGetRequest == true) { | ||
| 38 | + EmptyComponent({emptyType:11}) | ||
| 39 | + .height('100%') | ||
| 40 | + .layoutWeight(1) | ||
| 41 | + } | ||
| 42 | + } else { | ||
| 37 | List({ space: 3 }) { | 43 | List({ space: 3 }) { |
| 38 | LazyForEach(this.data_comment, (item: CommentListItem, index: number = 0) => { | 44 | LazyForEach(this.data_comment, (item: CommentListItem, index: number = 0) => { |
| 39 | ListItem() { | 45 | ListItem() { |
| 40 | - ChildCommentComponent({data: item,levelHead:this.levelHead,isLastItem:index===this.data_comment.totalCount()-1}) | 46 | + ChildCommentComponent({ |
| 47 | + data: item, | ||
| 48 | + levelHead: this.levelHead, | ||
| 49 | + isLastItem: index === this.data_comment.totalCount() - 1 | ||
| 50 | + }) | ||
| 41 | } | 51 | } |
| 42 | .onClick(() => { | 52 | .onClick(() => { |
| 43 | }) | 53 | }) |
| 44 | }, (item: CommentListItem, index: number) => index.toString()) | 54 | }, (item: CommentListItem, index: number) => index.toString()) |
| 45 | 55 | ||
| 46 | //没有更多数据 显示提示 | 56 | //没有更多数据 显示提示 |
| 47 | - if(!this.hasMore){ | ||
| 48 | - ListItem(){ | 57 | + if (!this.hasMore) { |
| 58 | + ListItem() { | ||
| 49 | ListHasNoMoreDataUI() | 59 | ListHasNoMoreDataUI() |
| 50 | } | 60 | } |
| 51 | } | 61 | } |
| 52 | - }.cachedCount(15) | 62 | + } |
| 63 | + .cachedCount(15) | ||
| 53 | .layoutWeight(1) | 64 | .layoutWeight(1) |
| 54 | .scrollBar(BarState.Off) | 65 | .scrollBar(BarState.Off) |
| 55 | .edgeEffect(EdgeEffect.None) | 66 | .edgeEffect(EdgeEffect.None) |
| @@ -57,9 +68,9 @@ export struct OtherHomePageBottomCommentComponent{ | @@ -57,9 +68,9 @@ export struct OtherHomePageBottomCommentComponent{ | ||
| 57 | scrollForward: NestedScrollMode.PARENT_FIRST, | 68 | scrollForward: NestedScrollMode.PARENT_FIRST, |
| 58 | scrollBackward: NestedScrollMode.SELF_FIRST | 69 | scrollBackward: NestedScrollMode.SELF_FIRST |
| 59 | }) | 70 | }) |
| 60 | - .onReachEnd(()=>{ | ||
| 61 | - console.log(TAG,"触底了"); | ||
| 62 | - if(!this.isLoading){ | 71 | + .onReachEnd(() => { |
| 72 | + console.log(TAG, "触底了"); | ||
| 73 | + if (!this.isLoading) { | ||
| 63 | this.isLoading = true | 74 | this.isLoading = true |
| 64 | //加载分页数据 | 75 | //加载分页数据 |
| 65 | this.getNewPageData() | 76 | this.getNewPageData() |
| @@ -72,7 +83,6 @@ export struct OtherHomePageBottomCommentComponent{ | @@ -72,7 +83,6 @@ export struct OtherHomePageBottomCommentComponent{ | ||
| 72 | .justifyContent(FlexAlign.Start) | 83 | .justifyContent(FlexAlign.Start) |
| 73 | } | 84 | } |
| 74 | 85 | ||
| 75 | - | ||
| 76 | @Styles | 86 | @Styles |
| 77 | listStyle() { | 87 | listStyle() { |
| 78 | .backgroundColor(Color.White) | 88 | .backgroundColor(Color.White) |
| @@ -81,60 +91,64 @@ export struct OtherHomePageBottomCommentComponent{ | @@ -81,60 +91,64 @@ export struct OtherHomePageBottomCommentComponent{ | ||
| 81 | .borderRadius(12) | 91 | .borderRadius(12) |
| 82 | } | 92 | } |
| 83 | 93 | ||
| 84 | - getNewPageData(){ | 94 | + getNewPageData() { |
| 85 | this.isLoading = true | 95 | this.isLoading = true |
| 86 | - if(this.hasMore){ | 96 | + if (this.hasMore) { |
| 87 | let time = encodeURI(DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN)) | 97 | let time = encodeURI(DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN)) |
| 88 | - let object = new OtherUserCommentListRequestItem("",20,this.curPageNum,time,"1",this.curUserId) | 98 | + let object = new OtherUserCommentListRequestItem("", 20, this.curPageNum, time, "1", this.curUserId) |
| 89 | 99 | ||
| 90 | - MinePageDatasModel.getOtherCommentListData(object,getContext(this)).then((value)=>{ | ||
| 91 | - if (!this.data_comment || value.list.length == 0){ | 100 | + MinePageDatasModel.getOtherCommentListData(object, getContext(this)).then((value) => { |
| 101 | + if (!this.data_comment || value.list.length == 0) { | ||
| 92 | this.hasMore = false | 102 | this.hasMore = false |
| 93 | this.isLoading = false | 103 | this.isLoading = false |
| 94 | - }else{ | 104 | + } else { |
| 95 | this.getCommentListStatus(value) | 105 | this.getCommentListStatus(value) |
| 96 | } | 106 | } |
| 97 | - }).catch((err:Error)=>{ | ||
| 98 | - console.log(TAG,"请求失败") | 107 | + }).catch((err: Error) => { |
| 108 | + console.log(TAG, "请求失败") | ||
| 99 | this.isLoading = false | 109 | this.isLoading = false |
| 110 | + this.isGetRequest = true | ||
| 100 | }) | 111 | }) |
| 112 | + } else { | ||
| 113 | + this.isGetRequest = true | ||
| 114 | + this.isLoading = false | ||
| 101 | } | 115 | } |
| 102 | } | 116 | } |
| 103 | 117 | ||
| 104 | - getCommentListStatus(value:MineCommentListDetailItem){ | 118 | + getCommentListStatus(value: MineCommentListDetailItem) { |
| 105 | 119 | ||
| 106 | let status = new OtherUserCommentLikeStatusRequestItem() | 120 | let status = new OtherUserCommentLikeStatusRequestItem() |
| 107 | - let data : CommentListItem[] = [] | ||
| 108 | - value.list.forEach((item)=>{ | ||
| 109 | - if(item.checkStatus === 2){ | 121 | + let data: CommentListItem[] = [] |
| 122 | + value.list.forEach((item) => { | ||
| 123 | + if (item.checkStatus === 2) { | ||
| 110 | status.commentIdList.push(item.id) | 124 | status.commentIdList.push(item.id) |
| 111 | } | 125 | } |
| 112 | let commentContent = item.commentContent | 126 | let commentContent = item.commentContent |
| 113 | - if(item.sensitiveShow === 0 && item.sensitiveExist === 1){ | 127 | + if (item.sensitiveShow === 0 && item.sensitiveExist === 1) { |
| 114 | commentContent = item.commentContentSensitive | 128 | commentContent = item.commentContentSensitive |
| 115 | } | 129 | } |
| 116 | let parentCommentContent = "" | 130 | let parentCommentContent = "" |
| 117 | - if(item.parentCommentVo!=null ){ | 131 | + if (item.parentCommentVo != null) { |
| 118 | parentCommentContent = item.parentCommentVo.commentContent | 132 | parentCommentContent = item.parentCommentVo.commentContent |
| 119 | } | 133 | } |
| 120 | let parentCommentUserName = "" | 134 | let parentCommentUserName = "" |
| 121 | - if(item.parentCommentVo!=null ){ | 135 | + if (item.parentCommentVo != null) { |
| 122 | parentCommentUserName = item.parentCommentVo.fromUserName | 136 | parentCommentUserName = item.parentCommentVo.fromUserName |
| 123 | } | 137 | } |
| 124 | - data.push(new CommentListItem(item.fromUserHeader,item.fromUserName,item.targetTitle,item.createTime,commentContent,item.likeNum,0,item.id,item.targetId,item.targetType,item.targetRelId,item.targetRelObjectId,item.targetRelType,item.targetStatus,item.checkStatus,parentCommentContent,parentCommentUserName)) | 138 | + data.push(new CommentListItem(item.fromUserHeader, item.fromUserName, item.targetTitle, item.createTime, commentContent, item.likeNum, 0, item.id, item.targetId, item.targetType, item.targetRelId, item.targetRelObjectId, item.targetRelType, item.targetStatus, item.checkStatus, parentCommentContent, parentCommentUserName)) |
| 125 | }) | 139 | }) |
| 126 | 140 | ||
| 127 | - MinePageDatasModel.getOtherUserCommentLikeStatusData(status,getContext(this)).then((newValue)=>{ | ||
| 128 | - newValue.forEach((item)=>{ | ||
| 129 | - data.forEach((list)=>{ | 141 | + MinePageDatasModel.getOtherUserCommentLikeStatusData(status, getContext(this)).then((newValue) => { |
| 142 | + newValue.forEach((item) => { | ||
| 143 | + data.forEach((list) => { | ||
| 130 | if (item.commentId == list.id) { | 144 | if (item.commentId == list.id) { |
| 131 | list.like_status = item.status | 145 | list.like_status = item.status |
| 132 | } | 146 | } |
| 133 | }) | 147 | }) |
| 134 | }) | 148 | }) |
| 135 | 149 | ||
| 136 | - data.forEach((item)=>{ | ||
| 137 | - this.data_comment.push(new CommentListItem(item.fromUserHeader,item.fromUserName,item.targetTitle,item.createTime,item.commentContent,item.likeNum,item.like_status,item.id,item.targetId,item.targetType,item.targetRelId,item.targetRelObjectId,item.targetRelType,item.targetStatus,item.checkStatus,item.parentCommentContent,item.parentCommentUserName)) | 150 | + data.forEach((item) => { |
| 151 | + this.data_comment.push(new CommentListItem(item.fromUserHeader, item.fromUserName, item.targetTitle, item.createTime, item.commentContent, item.likeNum, item.like_status, item.id, item.targetId, item.targetType, item.targetRelId, item.targetRelObjectId, item.targetRelType, item.targetStatus, item.checkStatus, item.parentCommentContent, item.parentCommentUserName)) | ||
| 138 | }) | 152 | }) |
| 139 | 153 | ||
| 140 | this.data_comment.notifyDataReload() | 154 | this.data_comment.notifyDataReload() |
| @@ -143,14 +157,16 @@ export struct OtherHomePageBottomCommentComponent{ | @@ -143,14 +157,16 @@ export struct OtherHomePageBottomCommentComponent{ | ||
| 143 | this.commentNum = value.totalCount | 157 | this.commentNum = value.totalCount |
| 144 | if (this.data_comment.totalCount() < value.totalCount) { | 158 | if (this.data_comment.totalCount() < value.totalCount) { |
| 145 | this.curPageNum++ | 159 | this.curPageNum++ |
| 146 | - }else { | 160 | + } else { |
| 147 | this.hasMore = false | 161 | this.hasMore = false |
| 148 | } | 162 | } |
| 149 | 163 | ||
| 150 | this.isLoading = false | 164 | this.isLoading = false |
| 151 | - }).catch((err:Error)=>{ | ||
| 152 | - console.log(TAG,"请求失败") | 165 | + this.isGetRequest = true |
| 166 | + }).catch((err: Error) => { | ||
| 167 | + console.log(TAG, "请求失败") | ||
| 153 | this.isLoading = false | 168 | this.isLoading = false |
| 169 | + this.isGetRequest = true | ||
| 154 | }) | 170 | }) |
| 155 | } | 171 | } |
| 156 | } | 172 | } |
| @@ -17,6 +17,7 @@ export struct OtherHomePageBottomFollowComponent{ | @@ -17,6 +17,7 @@ export struct OtherHomePageBottomFollowComponent{ | ||
| 17 | curPageNum:number = 1; | 17 | curPageNum:number = 1; |
| 18 | @State count:number = 0; | 18 | @State count:number = 0; |
| 19 | @Prop curUserId: string | 19 | @Prop curUserId: string |
| 20 | + @State isGetRequest:boolean = false | ||
| 20 | 21 | ||
| 21 | 22 | ||
| 22 | aboutToAppear(){ | 23 | aboutToAppear(){ |
| @@ -54,10 +55,11 @@ export struct OtherHomePageBottomFollowComponent{ | @@ -54,10 +55,11 @@ export struct OtherHomePageBottomFollowComponent{ | ||
| 54 | let params = {'index': "1"} as Record<string, string> | 55 | let params = {'index': "1"} as Record<string, string> |
| 55 | WDRouterRule.jumpWithPage(WDRouterPage.followListPage,params) | 56 | WDRouterRule.jumpWithPage(WDRouterPage.followListPage,params) |
| 56 | }) | 57 | }) |
| 57 | - | ||
| 58 | - EmptyComponent({emptyType:14}) | ||
| 59 | - .layoutWeight(1) | ||
| 60 | - .width('100%') | 58 | + if(this.isGetRequest == true){ |
| 59 | + EmptyComponent({emptyType:14}) | ||
| 60 | + .layoutWeight(1) | ||
| 61 | + .width('100%') | ||
| 62 | + } | ||
| 61 | }.layoutWeight(1) | 63 | }.layoutWeight(1) |
| 62 | .justifyContent(FlexAlign.Start) | 64 | .justifyContent(FlexAlign.Start) |
| 63 | }else{ | 65 | }else{ |
| @@ -155,10 +157,15 @@ export struct OtherHomePageBottomFollowComponent{ | @@ -155,10 +157,15 @@ export struct OtherHomePageBottomFollowComponent{ | ||
| 155 | } | 157 | } |
| 156 | } | 158 | } |
| 157 | this.isLoading = false | 159 | this.isLoading = false |
| 160 | + this.isGetRequest = true | ||
| 158 | }).catch((err:Error)=>{ | 161 | }).catch((err:Error)=>{ |
| 159 | console.log(TAG,"请求失败") | 162 | console.log(TAG,"请求失败") |
| 160 | this.isLoading = false | 163 | this.isLoading = false |
| 164 | + this.isGetRequest = true | ||
| 161 | }) | 165 | }) |
| 166 | + }else{ | ||
| 167 | + this.isGetRequest = true | ||
| 168 | + this.isLoading = false | ||
| 162 | } | 169 | } |
| 163 | } | 170 | } |
| 164 | } | 171 | } |
| 1 | import { BottomNavi, CommonConstants } from 'wdConstant'; | 1 | import { BottomNavi, CommonConstants } from 'wdConstant'; |
| 2 | -import { BottomNavDTO } from 'wdBean'; | 2 | +import { BottomNavDTO, TopNavDTO } from 'wdBean'; |
| 3 | import { DateTimeUtils, EmitterEventId, EmitterUtils, Logger } from 'wdKit'; | 3 | import { DateTimeUtils, EmitterEventId, EmitterUtils, Logger } from 'wdKit'; |
| 4 | import { TopNavigationComponent } from './TopNavigationComponent'; | 4 | import { TopNavigationComponent } from './TopNavigationComponent'; |
| 5 | import { MinePageComponent } from './MinePageComponent'; | 5 | import { MinePageComponent } from './MinePageComponent'; |
| 6 | import { CompUtils } from '../../utils/CompUtils'; | 6 | import { CompUtils } from '../../utils/CompUtils'; |
| 7 | import PageViewModel from '../../viewmodel/PageViewModel'; | 7 | import PageViewModel from '../../viewmodel/PageViewModel'; |
| 8 | import HomeChannelUtils, { AssignChannelParam } from 'wdRouter/src/main/ets/utils/HomeChannelUtils'; | 8 | import HomeChannelUtils, { AssignChannelParam } from 'wdRouter/src/main/ets/utils/HomeChannelUtils'; |
| 9 | +import { Message } from 'wdJsBridge/src/main/ets/bean/Message'; | ||
| 9 | 10 | ||
| 10 | const TAG = 'BottomNavigationComponent'; | 11 | const TAG = 'BottomNavigationComponent'; |
| 11 | let storage = LocalStorage.getShared(); | 12 | let storage = LocalStorage.getShared(); |
| @@ -21,14 +22,13 @@ export struct BottomNavigationComponent { | @@ -21,14 +22,13 @@ export struct BottomNavigationComponent { | ||
| 21 | @Provide isLayoutFullScreen: boolean = false | 22 | @Provide isLayoutFullScreen: boolean = false |
| 22 | @Provide isImmersive: boolean = false // 是否开启沉浸式模式 http://192.168.1.3:3300/project/3802/interface/api/189229 | 23 | @Provide isImmersive: boolean = false // 是否开启沉浸式模式 http://192.168.1.3:3300/project/3802/interface/api/189229 |
| 23 | @Provide isNight: boolean = false // 是否开启夜间模式 | 24 | @Provide isNight: boolean = false // 是否开启夜间模式 |
| 25 | + @Provide currentBottomNavInfo: BottomNavDTO = {} as BottomNavDTO; // 当前底导信息 | ||
| 26 | + @Provide currentTopNavInfo: TopNavDTO = {} as TopNavDTO; // 当前顶导信息 | ||
| 27 | + @Provide barBackgroundColor: Color = Color.Transparent | ||
| 24 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | 28 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 |
| 25 | @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 | 29 | @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 |
| 26 | - // 底导/顶导全部数据 | ||
| 27 | - @State @Watch('onBottomNavigationDataUpdated') bottomNavList: BottomNavDTO[] = [] | ||
| 28 | - // 底导当前选中/焦点下标 | ||
| 29 | - @State currentNavIndex: number = BottomNavi.NEWS; | ||
| 30 | - // @State currentTopNavSelectedIndex: number = 0; // | ||
| 31 | - @State barBackgroundColor: Color = Color.Transparent | 30 | + @State @Watch('onBottomNavigationDataUpdated') bottomNavList: BottomNavDTO[] = [] // 底导/顶导全部数据 |
| 31 | + @State currentNavIndex: number = BottomNavi.NEWS; // 底导当前选中/焦点下标 | ||
| 32 | // 底导TabsController | 32 | // 底导TabsController |
| 33 | private navController: TabsController = new TabsController(); | 33 | private navController: TabsController = new TabsController(); |
| 34 | readonly ASPECT_RATIO_1_1: number = 1 / 1; // 底导图片宽高比 | 34 | readonly ASPECT_RATIO_1_1: number = 1 / 1; // 底导图片宽高比 |
| @@ -44,6 +44,7 @@ export struct BottomNavigationComponent { | @@ -44,6 +44,7 @@ export struct BottomNavigationComponent { | ||
| 44 | @State assignChannel: AssignChannelParam = new AssignChannelParam() | 44 | @State assignChannel: AssignChannelParam = new AssignChannelParam() |
| 45 | // 自动刷新触发(双击tab自动刷新) | 45 | // 自动刷新触发(双击tab自动刷新) |
| 46 | @State autoRefresh: number = 0 | 46 | @State autoRefresh: number = 0 |
| 47 | + | ||
| 47 | async aboutToAppear() { | 48 | async aboutToAppear() { |
| 48 | Logger.info(TAG, `aboutToAppear currentNavIndex: ${this.currentNavIndex}`); | 49 | Logger.info(TAG, `aboutToAppear currentNavIndex: ${this.currentNavIndex}`); |
| 49 | let bottomNav = await PageViewModel.getBottomNavData(getContext(this)) | 50 | let bottomNav = await PageViewModel.getBottomNavData(getContext(this)) |
| @@ -84,7 +85,6 @@ export struct BottomNavigationComponent { | @@ -84,7 +85,6 @@ export struct BottomNavigationComponent { | ||
| 84 | _currentNavIndex: $currentNavIndex, | 85 | _currentNavIndex: $currentNavIndex, |
| 85 | navIndex: index, | 86 | navIndex: index, |
| 86 | currentBottomNavName: navItem.name, | 87 | currentBottomNavName: navItem.name, |
| 87 | - barBackgroundColor: $barBackgroundColor, | ||
| 88 | assignChannel: this.assignChannel, | 88 | assignChannel: this.assignChannel, |
| 89 | autoRefresh: this.autoRefresh | 89 | autoRefresh: this.autoRefresh |
| 90 | }) | 90 | }) |
| @@ -99,8 +99,8 @@ export struct BottomNavigationComponent { | @@ -99,8 +99,8 @@ export struct BottomNavigationComponent { | ||
| 99 | .animationDuration(0) | 99 | .animationDuration(0) |
| 100 | .barHeight($r('app.float.bottom_navigation_barHeight')) | 100 | .barHeight($r('app.float.bottom_navigation_barHeight')) |
| 101 | .barMode(BarMode.Fixed) | 101 | .barMode(BarMode.Fixed) |
| 102 | - // TODO:更详细的判断是视频频道 | ||
| 103 | .barBackgroundColor(this.barBackgroundColor) | 102 | .barBackgroundColor(this.barBackgroundColor) |
| 103 | + // 备注:鸿蒙目前只有修改三线导航背景方法,对于全面屏导航条手机需要设置背景色并使其扩散到导航区域 | ||
| 104 | .backgroundColor(this.barBackgroundColor) | 104 | .backgroundColor(this.barBackgroundColor) |
| 105 | .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) | 105 | .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) |
| 106 | 106 | ||
| @@ -108,17 +108,6 @@ export struct BottomNavigationComponent { | @@ -108,17 +108,6 @@ export struct BottomNavigationComponent { | ||
| 108 | 108 | ||
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | - /** | ||
| 112 | - * TODO:更详细的判断视频频道 | ||
| 113 | - */ | ||
| 114 | - getFontColor(index: number): Color { | ||
| 115 | - if (this.currentNavIndex === 2 && this.barBackgroundColor === Color.Black) { | ||
| 116 | - return Color.White | ||
| 117 | - } else { | ||
| 118 | - return this.currentNavIndex === index ? Color.Red : Color.Gray | ||
| 119 | - } | ||
| 120 | - } | ||
| 121 | - | ||
| 122 | @Builder | 111 | @Builder |
| 123 | tabBarBuilder(navItem: BottomNavDTO, index: number) { | 112 | tabBarBuilder(navItem: BottomNavDTO, index: number) { |
| 124 | Stack({ alignContent: Alignment.Bottom }) { | 113 | Stack({ alignContent: Alignment.Bottom }) { |
| @@ -126,37 +115,39 @@ export struct BottomNavigationComponent { | @@ -126,37 +115,39 @@ export struct BottomNavigationComponent { | ||
| 126 | .height(CommonConstants.FULL_PARENT) | 115 | .height(CommonConstants.FULL_PARENT) |
| 127 | .padding({ bottom: 15, left: 10, right: 10, top: 2 }) | 116 | .padding({ bottom: 15, left: 10, right: 10, top: 2 }) |
| 128 | .aspectRatio(this.ASPECT_RATIO_1_1) | 117 | .aspectRatio(this.ASPECT_RATIO_1_1) |
| 118 | + .gesture( | ||
| 119 | + TapGesture({ count: 2 }) | ||
| 120 | + .onAction((event: GestureEvent) => { | ||
| 121 | + if (this.currentNavIndex === index) { | ||
| 122 | + // 当前tab,双击事件 | ||
| 123 | + this.autoRefresh++ | ||
| 124 | + } | ||
| 125 | + }) | ||
| 126 | + ) | ||
| 129 | 127 | ||
| 130 | Text(navItem.name) | 128 | Text(navItem.name) |
| 131 | .margin({ bottom: $r('app.float.bottom_navigation_margin_bottom') }) | 129 | .margin({ bottom: $r('app.float.bottom_navigation_margin_bottom') }) |
| 132 | .fontWeight(this.currentNavIndex === index ? FontWeight.Bold : FontWeight.Normal) | 130 | .fontWeight(this.currentNavIndex === index ? FontWeight.Bold : FontWeight.Normal) |
| 133 | .textAlign(TextAlign.Center) | 131 | .textAlign(TextAlign.Center) |
| 134 | .fontSize($r('app.float.font_size_10'))// .fontColor(this.currentNavIndex === index ? Color.Red : Color.Gray) | 132 | .fontSize($r('app.float.font_size_10'))// .fontColor(this.currentNavIndex === index ? Color.Red : Color.Gray) |
| 135 | - .fontColor(this.getFontColor(index)) | 133 | + .fontColor(this.currentNavIndex === index ? navItem.nameCColor : navItem.nameColor) |
| 136 | .opacity(this.currentNavIndex === index ? this.FULL_OPACITY : this.SIXTY_OPACITY) | 134 | .opacity(this.currentNavIndex === index ? this.FULL_OPACITY : this.SIXTY_OPACITY) |
| 137 | } | 135 | } |
| 138 | .height($r('app.float.bottom_navigation_barHeight')) | 136 | .height($r('app.float.bottom_navigation_barHeight')) |
| 139 | .hoverEffect(HoverEffect.Highlight) | 137 | .hoverEffect(HoverEffect.Highlight) |
| 140 | .onClick(() => { | 138 | .onClick(() => { |
| 141 | - if (this.currentNavIndex === index) { | ||
| 142 | - // 当前tab,双击事件 | ||
| 143 | - this.doubleClick(() => { | ||
| 144 | - Logger.info(TAG, 'tab double click ') | ||
| 145 | - this.autoRefresh++ | ||
| 146 | - }) | 139 | + if (navItem.name === '我的') { |
| 140 | + this.barBackgroundColor = Color.White | ||
| 141 | + this.currentBottomNavInfo = {} as BottomNavDTO | ||
| 147 | } else { | 142 | } else { |
| 148 | - // 切换tab | ||
| 149 | - this.currentNavIndex = index; | ||
| 150 | - Logger.info(TAG, `onChange, index: ${index}`); | 143 | + this.currentBottomNavInfo = navItem |
| 151 | } | 144 | } |
| 145 | + | ||
| 146 | + this.currentNavIndex = index; | ||
| 147 | + Logger.info(TAG, `onChange, index: ${index}`); | ||
| 148 | + | ||
| 152 | }) | 149 | }) |
| 153 | 150 | ||
| 154 | - // .justifyContent(FlexAlign.Center) | ||
| 155 | - // .onClick(() => { | ||
| 156 | - // Logger.info(TAG, `onClick, index: ${index}`); | ||
| 157 | - // this.currentNavIndex = index ?? 0; | ||
| 158 | - // this.navController.changeIndex(this.currentNavIndex); | ||
| 159 | - // }) | ||
| 160 | } | 151 | } |
| 161 | 152 | ||
| 162 | // 底导切换函数 | 153 | // 底导切换函数 |
| @@ -199,17 +190,17 @@ export struct BottomNavigationComponent { | @@ -199,17 +190,17 @@ export struct BottomNavigationComponent { | ||
| 199 | /** | 190 | /** |
| 200 | * 双击实现 | 191 | * 双击实现 |
| 201 | */ | 192 | */ |
| 202 | - doubleClickTime: number = 0 | 193 | + // doubleClickTime: number = 0 |
| 203 | 194 | ||
| 204 | /** | 195 | /** |
| 205 | * 双击实现 | 196 | * 双击实现 |
| 206 | */ | 197 | */ |
| 207 | - private doubleClick(fun: () => void) { | ||
| 208 | - let now = DateTimeUtils.getTimeStamp() | ||
| 209 | - if (now - this.doubleClickTime < 200) { | ||
| 210 | - fun() | ||
| 211 | - } else { | ||
| 212 | - this.doubleClickTime = now | ||
| 213 | - } | ||
| 214 | - } | 198 | + // private doubleClick(fun: () => void) { |
| 199 | + // let now = DateTimeUtils.getTimeStamp() | ||
| 200 | + // if (now - this.doubleClickTime < 200) { | ||
| 201 | + // fun() | ||
| 202 | + // } else { | ||
| 203 | + // this.doubleClickTime = now | ||
| 204 | + // } | ||
| 205 | + // } | ||
| 215 | } | 206 | } |
| @@ -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 { |
| @@ -27,6 +27,7 @@ export struct PageComponent { | @@ -27,6 +27,7 @@ export struct PageComponent { | ||
| 27 | @Link @Watch('onChange') currentTopNavSelectedIndex: number | 27 | @Link @Watch('onChange') currentTopNavSelectedIndex: number |
| 28 | // 自动刷新通知 | 28 | // 自动刷新通知 |
| 29 | @Prop @Watch('onAutoRefresh') autoRefresh: number = 0 | 29 | @Prop @Watch('onAutoRefresh') autoRefresh: number = 0 |
| 30 | + private listScroller: Scroller = new Scroller(); | ||
| 30 | 31 | ||
| 31 | build() { | 32 | build() { |
| 32 | Column() { | 33 | Column() { |
| @@ -61,7 +62,7 @@ export struct PageComponent { | @@ -61,7 +62,7 @@ export struct PageComponent { | ||
| 61 | ListLayout() { | 62 | ListLayout() { |
| 62 | 63 | ||
| 63 | RelativeContainer() { | 64 | RelativeContainer() { |
| 64 | - List() { | 65 | + List({ scroller: this.listScroller }) { |
| 65 | // 下拉刷新 | 66 | // 下拉刷新 |
| 66 | ListItem() { | 67 | ListItem() { |
| 67 | RefreshLayout({ | 68 | RefreshLayout({ |
| @@ -235,6 +236,7 @@ export struct PageComponent { | @@ -235,6 +236,7 @@ export struct PageComponent { | ||
| 235 | } | 236 | } |
| 236 | // 当前页面,自动刷新数据 | 237 | // 当前页面,自动刷新数据 |
| 237 | Logger.debug(TAG, 'page onAutoRefresh ' + this.autoRefresh) | 238 | Logger.debug(TAG, 'page onAutoRefresh ' + this.autoRefresh) |
| 239 | + this.listScroller.scrollToIndex(0) | ||
| 238 | autoRefresh(this.pageModel, this.pageAdvModel) | 240 | autoRefresh(this.pageModel, this.pageAdvModel) |
| 239 | } | 241 | } |
| 240 | 242 |
| 1 | -import { CompDTO, TopNavDTO } from 'wdBean'; | 1 | +import { BottomNavDTO, CompDTO, TopNavDTO } from 'wdBean'; |
| 2 | import { LazyDataSource, Logger } from 'wdKit'; | 2 | import { LazyDataSource, Logger } from 'wdKit'; |
| 3 | import { ProcessUtils } from 'wdRouter'; | 3 | import { ProcessUtils } from 'wdRouter'; |
| 4 | import { PageComponent } from './PageComponent'; | 4 | import { PageComponent } from './PageComponent'; |
| @@ -26,12 +26,14 @@ export struct TopNavigationComponent { | @@ -26,12 +26,14 @@ export struct TopNavigationComponent { | ||
| 26 | @Consume isLayoutFullScreen: boolean | 26 | @Consume isLayoutFullScreen: boolean |
| 27 | @Consume bottomRectHeight: number | 27 | @Consume bottomRectHeight: number |
| 28 | @Consume topRectHeight: number | 28 | @Consume topRectHeight: number |
| 29 | + @Consume @Watch('topOrBottomNavChange') currentBottomNavInfo: BottomNavDTO // 当前底导信息 | ||
| 30 | + @Consume barBackgroundColor: Color | ||
| 29 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | 31 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 |
| 30 | @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 | 32 | @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 |
| 31 | - @Link barBackgroundColor: Color | ||
| 32 | @Link _currentNavIndex?: number; | 33 | @Link _currentNavIndex?: number; |
| 33 | // 顶导当前选中/焦点下标 | 34 | // 顶导当前选中/焦点下标 |
| 34 | - @State currentTopNavSelectedIndex: number = 0; | 35 | + @State @Watch('topOrBottomNavChange') currentTopNavSelectedIndex: number = 0; |
| 36 | + @State currentTopNavName: string = ''; | ||
| 35 | // 顶导数据 | 37 | // 顶导数据 |
| 36 | @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = [] | 38 | @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = [] |
| 37 | @State compList: LazyDataSource<CompDTO> = new LazyDataSource(); | 39 | @State compList: LazyDataSource<CompDTO> = new LazyDataSource(); |
| @@ -56,6 +58,21 @@ export struct TopNavigationComponent { | @@ -56,6 +58,21 @@ export struct TopNavigationComponent { | ||
| 56 | // 当前底导index | 58 | // 当前底导index |
| 57 | @State navIndex: number = 0 | 59 | @State navIndex: number = 0 |
| 58 | 60 | ||
| 61 | + topOrBottomNavChange() { | ||
| 62 | + if (this.currentBottomNavName === this.currentBottomNavInfo?.name) { | ||
| 63 | + this.setBarBackgroundColor() | ||
| 64 | + } | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + setBarBackgroundColor() { | ||
| 68 | + console.error('setBarBackgroundColor', this.currentTopNavName, this.currentBottomNavInfo?.name) | ||
| 69 | + if (this.currentTopNavName === '视频' && this.currentBottomNavInfo?.name === '视频') { | ||
| 70 | + this.barBackgroundColor = Color.Black | ||
| 71 | + } else { | ||
| 72 | + this.barBackgroundColor = Color.White | ||
| 73 | + } | ||
| 74 | + } | ||
| 75 | + | ||
| 59 | //处理新闻tab顶导频道数据 | 76 | //处理新闻tab顶导频道数据 |
| 60 | topNavListHandle() { | 77 | topNavListHandle() { |
| 61 | let _channelIds: number [] = [] | 78 | let _channelIds: number [] = [] |
| @@ -126,10 +143,14 @@ export struct TopNavigationComponent { | @@ -126,10 +143,14 @@ export struct TopNavigationComponent { | ||
| 126 | this.channelIds = _channelIds | 143 | this.channelIds = _channelIds |
| 127 | this.myChannelList = _myChannelList | 144 | this.myChannelList = _myChannelList |
| 128 | 145 | ||
| 146 | + this.currentTopNavName = this._currentNavIndex === 0 ? this.myChannelList[0].name : this.topNavList[0].name | ||
| 147 | + | ||
| 148 | + | ||
| 129 | //缓存首页频道 | 149 | //缓存首页频道 |
| 130 | let index = this.myChannelList.findIndex(_item => _item.channelId === this.indexSettingChannelId) | 150 | let index = this.myChannelList.findIndex(_item => _item.channelId === this.indexSettingChannelId) |
| 131 | if (index > -1) { | 151 | if (index > -1) { |
| 132 | this.currentTopNavSelectedIndex = index | 152 | this.currentTopNavSelectedIndex = index |
| 153 | + this.currentTopNavName = this.myChannelList[index].name | ||
| 133 | } | 154 | } |
| 134 | } | 155 | } |
| 135 | 156 | ||
| @@ -196,7 +217,6 @@ export struct TopNavigationComponent { | @@ -196,7 +217,6 @@ export struct TopNavigationComponent { | ||
| 196 | groupId: this.groupId + '', | 217 | groupId: this.groupId + '', |
| 197 | pageId: navItem.pageId + '', | 218 | pageId: navItem.pageId + '', |
| 198 | channelId: navItem.channelId + '', | 219 | channelId: navItem.channelId + '', |
| 199 | - barBackgroundColor: $barBackgroundColor | ||
| 200 | }) | 220 | }) |
| 201 | } else | 221 | } else |
| 202 | if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) { | 222 | if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) { |
| @@ -216,9 +236,10 @@ export struct TopNavigationComponent { | @@ -216,9 +236,10 @@ export struct TopNavigationComponent { | ||
| 216 | .barHeight($r('app.float.top_tab_bar_height')) | 236 | .barHeight($r('app.float.top_tab_bar_height')) |
| 217 | .barMode(BarMode.Scrollable) | 237 | .barMode(BarMode.Scrollable) |
| 218 | .vertical(false) | 238 | .vertical(false) |
| 219 | - // item.name === '视频' && this.currentTopNavSelectedIndex === 0 ? | ||
| 220 | .barBackgroundColor(this.barBackgroundColor) | 239 | .barBackgroundColor(this.barBackgroundColor) |
| 221 | .onChange((index: number) => { | 240 | .onChange((index: number) => { |
| 241 | + this.currentTopNavName = this._currentNavIndex === 0 ? this.myChannelList[index].name : this.topNavList[index].name | ||
| 242 | + | ||
| 222 | Logger.info(TAG, `onChange index : ${index}`); | 243 | Logger.info(TAG, `onChange index : ${index}`); |
| 223 | if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) && | 244 | if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) && |
| 224 | !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) | 245 | !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) |
| @@ -256,15 +277,11 @@ export struct TopNavigationComponent { | @@ -256,15 +277,11 @@ export struct TopNavigationComponent { | ||
| 256 | } | 277 | } |
| 257 | 278 | ||
| 258 | /** | 279 | /** |
| 259 | - * TODO:更详细的判断视频频道 | 280 | + * TODO:根据顶导配置获取颜色展示效果不对,待确认 |
| 260 | */ | 281 | */ |
| 261 | - getFontColor(item: TopNavDTO, index: number): Color | string { | ||
| 262 | - if (this._currentNavIndex === 2) { | ||
| 263 | - if (this.currentTopNavSelectedIndex == 0) { | ||
| 264 | - return item.name === '视频' ? Color.White : '#e5e0e0' | ||
| 265 | - } else { | ||
| 266 | - return this.currentTopNavSelectedIndex === index ? Color.Black : "#999999" | ||
| 267 | - } | 282 | + getTopNavFontColor(item: TopNavDTO, index: number): Color | string { |
| 283 | + if (item.name === '视频' && this.currentBottomNavInfo.name === '视频') { | ||
| 284 | + return this.currentTopNavSelectedIndex === index ? Color.White : '#e5e0e0' | ||
| 268 | } else { | 285 | } else { |
| 269 | return this.currentTopNavSelectedIndex === index ? Color.Black : "#999999" | 286 | return this.currentTopNavSelectedIndex === index ? Color.Black : "#999999" |
| 270 | } | 287 | } |
| @@ -276,9 +293,10 @@ export struct TopNavigationComponent { | @@ -276,9 +293,10 @@ export struct TopNavigationComponent { | ||
| 276 | Text(item.name) | 293 | Text(item.name) |
| 277 | .fontSize($r('app.float.selected_text_size')) | 294 | .fontSize($r('app.float.selected_text_size')) |
| 278 | .fontWeight(this.currentTopNavSelectedIndex === index ? FontWeight.Bold : FontWeight.Normal) | 295 | .fontWeight(this.currentTopNavSelectedIndex === index ? FontWeight.Bold : FontWeight.Normal) |
| 279 | - .fontColor(this.getFontColor(item, index)) | ||
| 280 | - .padding({ top: $r('app.float.top_tab_item_padding_top') , bottom: $r('app.float.top_tab_item_padding_bottom')}) | 296 | + .fontColor(this.getTopNavFontColor(item, index)) |
| 297 | + .padding({ top: $r('app.float.top_tab_item_padding_top'), bottom: $r('app.float.top_tab_item_padding_bottom') }) | ||
| 281 | .maxLines(this.MAX_LINE) | 298 | .maxLines(this.MAX_LINE) |
| 299 | + // .backgroundImage(this.currentTopNavSelectedIndex === index ? item.iconCUrl : item.iconUrl) | ||
| 282 | if (this.currentTopNavSelectedIndex === index) { | 300 | if (this.currentTopNavSelectedIndex === index) { |
| 283 | Row() | 301 | Row() |
| 284 | .width(20) | 302 | .width(20) |
| @@ -292,18 +310,20 @@ export struct TopNavigationComponent { | @@ -292,18 +310,20 @@ export struct TopNavigationComponent { | ||
| 292 | minWidth: $r('app.float.top_tab_item_min_width'), | 310 | minWidth: $r('app.float.top_tab_item_min_width'), |
| 293 | maxWidth: $r('app.float.top_tab_item_max_width') | 311 | maxWidth: $r('app.float.top_tab_item_max_width') |
| 294 | }) | 312 | }) |
| 295 | - .backgroundColor(Color.Transparent) | 313 | + // .backgroundColor(Color.Transparent) |
| 296 | .padding({ | 314 | .padding({ |
| 297 | left: $r('app.float.top_tab_item_padding_horizontal'), | 315 | left: $r('app.float.top_tab_item_padding_horizontal'), |
| 298 | right: $r('app.float.top_tab_item_padding_horizontal'), | 316 | right: $r('app.float.top_tab_item_padding_horizontal'), |
| 299 | }) | 317 | }) |
| 300 | .id(`col_tabBar${index}`) | 318 | .id(`col_tabBar${index}`) |
| 301 | .margin({ right: this.myChannelList.length === index + 1 ? 36 : 0 }) | 319 | .margin({ right: this.myChannelList.length === index + 1 ? 36 : 0 }) |
| 320 | + | ||
| 302 | } | 321 | } |
| 303 | 322 | ||
| 304 | aboutToAppear() { | 323 | aboutToAppear() { |
| 305 | //处理新闻tab顶导频道数据 | 324 | //处理新闻tab顶导频道数据 |
| 306 | this.topNavListHandle() | 325 | this.topNavListHandle() |
| 326 | + this.setBarBackgroundColor() | ||
| 307 | } | 327 | } |
| 308 | 328 | ||
| 309 | aboutToDisappear() { | 329 | aboutToDisappear() { |
| @@ -36,7 +36,7 @@ export struct SearchResultComponent { | @@ -36,7 +36,7 @@ export struct SearchResultComponent { | ||
| 36 | getSuggestData() { | 36 | getSuggestData() { |
| 37 | this.isLoading = true | 37 | this.isLoading = true |
| 38 | 38 | ||
| 39 | - let request: SearchSuggestRequestItem = new SearchSuggestRequestItem(2, "", "", HttpUrlUtils.getImei(), UserDataLocal.userId, 8, "") | 39 | + let request: SearchSuggestRequestItem = new SearchSuggestRequestItem(2, "", "", HttpUrlUtils.getImei(), UserDataLocal.getUserId(), 8, "") |
| 40 | 40 | ||
| 41 | SearcherAboutDataModel.getSearchSuggestData(request, getContext(this)).then((value) => { | 41 | SearcherAboutDataModel.getSearchSuggestData(request, getContext(this)).then((value) => { |
| 42 | value.forEach((item) => { | 42 | value.forEach((item) => { |
| @@ -9,7 +9,6 @@ export struct AboutPageUI { | @@ -9,7 +9,6 @@ export struct AboutPageUI { | ||
| 9 | @State listData: Array<string | Array<string>> = ['隐私授权协议', '软件许可及用户协议']; | 9 | @State listData: Array<string | Array<string>> = ['隐私授权协议', '软件许可及用户协议']; |
| 10 | @State message: string = '京ICP备16066560号-6A Copyright © 人民日报客户端\nall rights reserved.' | 10 | @State message: string = '京ICP备16066560号-6A Copyright © 人民日报客户端\nall rights reserved.' |
| 11 | @State version: string = '版本号:v' | 11 | @State version: string = '版本号:v' |
| 12 | - clickTimes: number = 0 | ||
| 13 | dialogController: CustomDialogController = new CustomDialogController({ | 12 | dialogController: CustomDialogController = new CustomDialogController({ |
| 14 | builder: EnvironmentCustomDialog({ | 13 | builder: EnvironmentCustomDialog({ |
| 15 | cancel: () => { | 14 | cancel: () => { |
| @@ -42,12 +41,12 @@ export struct AboutPageUI { | @@ -42,12 +41,12 @@ export struct AboutPageUI { | ||
| 42 | .width('278lpx') | 41 | .width('278lpx') |
| 43 | .height('154lpx') | 42 | .height('154lpx') |
| 44 | .margin({ top: '173lpx', bottom: '154lpx' }) | 43 | .margin({ top: '173lpx', bottom: '154lpx' }) |
| 45 | - .onClick(() => { | ||
| 46 | - this.clickTimes++ | ||
| 47 | - if (this.clickTimes > 2) { | ||
| 48 | - this.dialogController.open() | ||
| 49 | - } | ||
| 50 | - }) | 44 | + .gesture( |
| 45 | + TapGesture({ count: 2 }) | ||
| 46 | + .onAction((event: GestureEvent) => { | ||
| 47 | + this.dialogController.open() | ||
| 48 | + }) | ||
| 49 | + ) | ||
| 51 | // Row(){ | 50 | // Row(){ |
| 52 | // | 51 | // |
| 53 | // }.backgroundColor(Color.Yellow) | 52 | // }.backgroundColor(Color.Yellow) |
| 1 | import { SPHelper } from 'wdKit/Index'; | 1 | import { SPHelper } from 'wdKit/Index'; |
| 2 | -import { HttpUrlUtils } from 'wdNetwork/Index'; | 2 | +import { HostEnum, HostManager, HttpUrlUtils } from 'wdNetwork/Index'; |
| 3 | 3 | ||
| 4 | @CustomDialog | 4 | @CustomDialog |
| 5 | export struct EnvironmentCustomDialog { | 5 | export struct EnvironmentCustomDialog { |
| 6 | - currentEnvironment: string = HttpUrlUtils.HOST_PRODUCT; | 6 | + @State currentEnvironment: string = HostManager.getHost(); |
| 7 | controller: CustomDialogController | 7 | controller: CustomDialogController |
| 8 | cancel: () => void = () => { | 8 | cancel: () => void = () => { |
| 9 | } | 9 | } |
| @@ -21,12 +21,12 @@ export struct EnvironmentCustomDialog { | @@ -21,12 +21,12 @@ export struct EnvironmentCustomDialog { | ||
| 21 | .margin({ top: 20 }) | 21 | .margin({ top: 20 }) |
| 22 | Row() { | 22 | Row() { |
| 23 | Radio({ value: 'Radio1', group: 'radioGroup' }) | 23 | Radio({ value: 'Radio1', group: 'radioGroup' }) |
| 24 | - .checked(true) | 24 | + .checked(this.currentEnvironment == HostEnum.HOST_SIT) |
| 25 | .height(20) | 25 | .height(20) |
| 26 | .width(20) | 26 | .width(20) |
| 27 | .onChange((isChecked: boolean) => { | 27 | .onChange((isChecked: boolean) => { |
| 28 | if (isChecked) { | 28 | if (isChecked) { |
| 29 | - this.currentEnvironment = HttpUrlUtils.HOST_SIT; | 29 | + this.currentEnvironment = HostEnum.HOST_SIT; |
| 30 | } | 30 | } |
| 31 | }) | 31 | }) |
| 32 | Text('切换到SIT(测试)环境,重启应用生效') | 32 | Text('切换到SIT(测试)环境,重启应用生效') |
| @@ -37,12 +37,12 @@ export struct EnvironmentCustomDialog { | @@ -37,12 +37,12 @@ export struct EnvironmentCustomDialog { | ||
| 37 | 37 | ||
| 38 | Row() { | 38 | Row() { |
| 39 | Radio({ value: 'Radio1', group: 'radioGroup' }) | 39 | Radio({ value: 'Radio1', group: 'radioGroup' }) |
| 40 | - .checked(true) | 40 | + .checked(this.currentEnvironment == HostEnum.HOST_UAT) |
| 41 | .height(20) | 41 | .height(20) |
| 42 | .width(20) | 42 | .width(20) |
| 43 | .onChange((isChecked: boolean) => { | 43 | .onChange((isChecked: boolean) => { |
| 44 | if (isChecked) { | 44 | if (isChecked) { |
| 45 | - this.currentEnvironment = HttpUrlUtils.HOST_UAT; | 45 | + this.currentEnvironment = HostEnum.HOST_UAT; |
| 46 | } | 46 | } |
| 47 | }) | 47 | }) |
| 48 | Text('切换到UAT(预发布)环境,重启应用生效') | 48 | Text('切换到UAT(预发布)环境,重启应用生效') |
| @@ -53,12 +53,12 @@ export struct EnvironmentCustomDialog { | @@ -53,12 +53,12 @@ export struct EnvironmentCustomDialog { | ||
| 53 | 53 | ||
| 54 | Row() { | 54 | Row() { |
| 55 | Radio({ value: 'Radio1', group: 'radioGroup' }) | 55 | Radio({ value: 'Radio1', group: 'radioGroup' }) |
| 56 | - .checked(true) | 56 | + .checked(this.currentEnvironment == HostEnum.HOST_PRODUCT) |
| 57 | .height(20) | 57 | .height(20) |
| 58 | .width(20) | 58 | .width(20) |
| 59 | .onChange((isChecked: boolean) => { | 59 | .onChange((isChecked: boolean) => { |
| 60 | if (isChecked) { | 60 | if (isChecked) { |
| 61 | - this.currentEnvironment = HttpUrlUtils.HOST_PRODUCT; | 61 | + this.currentEnvironment = HostEnum.HOST_PRODUCT; |
| 62 | } | 62 | } |
| 63 | }) | 63 | }) |
| 64 | Text('切换到PROD(现网)环境,重启应用生效') | 64 | Text('切换到PROD(现网)环境,重启应用生效') |
| @@ -69,12 +69,12 @@ export struct EnvironmentCustomDialog { | @@ -69,12 +69,12 @@ export struct EnvironmentCustomDialog { | ||
| 69 | 69 | ||
| 70 | Row() { | 70 | Row() { |
| 71 | Radio({ value: 'Radio1', group: 'radioGroup' }) | 71 | Radio({ value: 'Radio1', group: 'radioGroup' }) |
| 72 | - .checked(true) | 72 | + .checked(this.currentEnvironment == HostEnum.HOST_DEV) |
| 73 | .height(20) | 73 | .height(20) |
| 74 | .width(20) | 74 | .width(20) |
| 75 | .onChange((isChecked: boolean) => { | 75 | .onChange((isChecked: boolean) => { |
| 76 | if (isChecked) { | 76 | if (isChecked) { |
| 77 | - this.currentEnvironment = HttpUrlUtils.HOST_DEV; | 77 | + this.currentEnvironment = HostEnum.HOST_DEV; |
| 78 | } | 78 | } |
| 79 | }) | 79 | }) |
| 80 | Text('切换到DEV(开发)环境,重启应用生效') | 80 | Text('切换到DEV(开发)环境,重启应用生效') |
| @@ -29,7 +29,7 @@ export struct HorizontalStrokeCardThreeTwoRadioForMoreComponent { | @@ -29,7 +29,7 @@ export struct HorizontalStrokeCardThreeTwoRadioForMoreComponent { | ||
| 29 | .width(14) | 29 | .width(14) |
| 30 | .height(14) | 30 | .height(14) |
| 31 | } | 31 | } |
| 32 | - .visibility(this.compDTO?.objectType === '0' ? Visibility.None : Visibility.Visible) | 32 | + .visibility(this.compDTO?.objectType === '0' || this.compDTO?.objectType === '' ? Visibility.None : Visibility.Visible) |
| 33 | .onClick(() => { | 33 | .onClick(() => { |
| 34 | if (this.compDTO?.objectType === '11') { | 34 | if (this.compDTO?.objectType === '11') { |
| 35 | ProcessUtils.jumpChannelTab(this.compDTO.objectId, this.compDTO.pageId as string) | 35 | ProcessUtils.jumpChannelTab(this.compDTO.objectId, this.compDTO.pageId as string) |
| 1 | import { Logger } from 'wdKit/Index' | 1 | import { Logger } from 'wdKit/Index' |
| 2 | import { LikeViewModel } from '../../viewmodel/LikeViewModel' | 2 | import { LikeViewModel } from '../../viewmodel/LikeViewModel' |
| 3 | +import { SPHelper } from 'wdKit'; | ||
| 4 | +import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | ||
| 5 | +import { SpConstants } from 'wdConstant/Index'; | ||
| 6 | + | ||
| 3 | 7 | ||
| 4 | const TAG = 'LikeComponent'; | 8 | const TAG = 'LikeComponent'; |
| 5 | 9 | ||
| @@ -9,6 +13,8 @@ export struct LikeComponent { | @@ -9,6 +13,8 @@ export struct LikeComponent { | ||
| 9 | viewModel: LikeViewModel = new LikeViewModel() | 13 | viewModel: LikeViewModel = new LikeViewModel() |
| 10 | @Prop data: Record<string, string> | 14 | @Prop data: Record<string, string> |
| 11 | enableBtn = true | 15 | enableBtn = true |
| 16 | + componentType : number = 1 //1: 底部栏目样式 2: 新闻页中间位置样式 | ||
| 17 | + @State likeCount: number = 0 //点赞数 | ||
| 12 | 18 | ||
| 13 | //上层传值 样例 | 19 | //上层传值 样例 |
| 14 | // this.data['contentId'] = '30035444649' //必须 | 20 | // this.data['contentId'] = '30035444649' //必须 |
| @@ -23,34 +29,100 @@ export struct LikeComponent { | @@ -23,34 +29,100 @@ export struct LikeComponent { | ||
| 23 | if (this.data) { | 29 | if (this.data) { |
| 24 | //获取点赞状态 | 30 | //获取点赞状态 |
| 25 | this.getLikeStatus() | 31 | this.getLikeStatus() |
| 32 | + //获取点赞数 | ||
| 33 | + this.getLikeCount() | ||
| 26 | } | 34 | } |
| 27 | 35 | ||
| 28 | } | 36 | } |
| 29 | 37 | ||
| 30 | build() { | 38 | build() { |
| 31 | - Column() { | ||
| 32 | - Image(this.likeStatus ? $r('app.media.icon_like_select') : $r('app.media.icon_like_default')) | ||
| 33 | - .width(24) | ||
| 34 | - .height(24) | ||
| 35 | - .onClick(() => { | ||
| 36 | - if (!this.enableBtn) { | ||
| 37 | - return | ||
| 38 | - } | ||
| 39 | - if (this.likeStatus) { | ||
| 40 | - //1 | ||
| 41 | - this.executeLike('0') | ||
| 42 | - } else { | ||
| 43 | - //0 | ||
| 44 | - this.executeLike('1') | 39 | + if (this.componentType == 2){ |
| 40 | + //2: 新闻页中间位置样式 | ||
| 41 | + Column() { | ||
| 42 | + | ||
| 43 | + Button(){ | ||
| 44 | + | ||
| 45 | + Row(){ | ||
| 46 | + Image(this.likeStatus ? $r('app.media.icon_like_select') : $r('app.media.icon_like_default')) | ||
| 47 | + .width(20) | ||
| 48 | + .height(20) | ||
| 49 | + Text(this.likeCount.toString()) | ||
| 50 | + .height(20) | ||
| 51 | + .margin({ | ||
| 52 | + right: 0, | ||
| 53 | + left: 4 | ||
| 54 | + }) | ||
| 55 | + .fontColor(this.likeStatus ? '#ED2800' : '#222222') | ||
| 56 | + .fontSize('16') | ||
| 45 | } | 57 | } |
| 58 | + .justifyContent(FlexAlign.Center) | ||
| 59 | + .width('100%') | ||
| 60 | + .height('100%') | ||
| 61 | + | ||
| 62 | + } | ||
| 63 | + .width('100%') | ||
| 64 | + .height('100%') | ||
| 65 | + .backgroundColor(Color.White) | ||
| 66 | + .type(ButtonType.Capsule) | ||
| 67 | + .borderColor('#EDEDED') | ||
| 68 | + .borderRadius(20) | ||
| 69 | + .borderWidth(1) | ||
| 70 | + .onClick(()=>{ | ||
| 71 | + | ||
| 72 | + this.clickButtonEvent() | ||
| 73 | + | ||
| 46 | }) | 74 | }) |
| 47 | - }.width(24).height(24) | 75 | + |
| 76 | + } | ||
| 77 | + .width(154) | ||
| 78 | + .height(40) | ||
| 79 | + | ||
| 80 | + | ||
| 81 | + }else { | ||
| 82 | + //1: 底部栏目样式 默认样式 | ||
| 83 | + Column() { | ||
| 84 | + Image(this.likeStatus ? $r('app.media.icon_like_select') : $r('app.media.icon_like_default')) | ||
| 85 | + .width(24) | ||
| 86 | + .height(24) | ||
| 87 | + .onClick(() => { | ||
| 88 | + this.clickButtonEvent() | ||
| 89 | + }) | ||
| 90 | + }.width(24).height(24) | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + async clickButtonEvent(){ | ||
| 96 | + // 未登录,跳转登录 | ||
| 97 | + const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') | ||
| 98 | + if (!user_id) { | ||
| 99 | + WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 100 | + return | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + if (!this.enableBtn) { | ||
| 104 | + return | ||
| 105 | + } | ||
| 106 | + if (this.likeStatus) { | ||
| 107 | + //1 | ||
| 108 | + this.executeLike('0') | ||
| 109 | + } else { | ||
| 110 | + //0 | ||
| 111 | + this.executeLike('1') | ||
| 112 | + } | ||
| 113 | + | ||
| 48 | } | 114 | } |
| 49 | 115 | ||
| 50 | executeLike(status: string) { | 116 | executeLike(status: string) { |
| 51 | this.data['status'] = status | 117 | this.data['status'] = status |
| 52 | this.viewModel.executeLike2(this.data).then(() => { | 118 | this.viewModel.executeLike2(this.data).then(() => { |
| 53 | this.likeStatus = !this.likeStatus | 119 | this.likeStatus = !this.likeStatus |
| 120 | + //点赞和取消点赞成功后更新点赞数 | ||
| 121 | + if(this.likeStatus){ | ||
| 122 | + this.likeCount ++ | ||
| 123 | + }else { | ||
| 124 | + this.likeCount -- | ||
| 125 | + } | ||
| 54 | this.enableBtn = true | 126 | this.enableBtn = true |
| 55 | }).catch(() => { | 127 | }).catch(() => { |
| 56 | this.enableBtn = true | 128 | this.enableBtn = true |
| @@ -69,5 +141,19 @@ export struct LikeComponent { | @@ -69,5 +141,19 @@ export struct LikeComponent { | ||
| 69 | }) | 141 | }) |
| 70 | } | 142 | } |
| 71 | 143 | ||
| 144 | + //获取点赞数 | ||
| 145 | + getLikeCount() { | ||
| 146 | + this.viewModel.getLikeCount(this.data).then((data) => { | ||
| 147 | + if (data && data['data']) { | ||
| 148 | + this.likeCount = data['data']['likeNum'] | ||
| 149 | + }else { | ||
| 150 | + this.likeCount = 0 | ||
| 151 | + } | ||
| 152 | + }).catch(() => { | ||
| 153 | + this.likeCount = 0 | ||
| 154 | + }) | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + | ||
| 72 | 158 | ||
| 73 | } | 159 | } |
| @@ -13,6 +13,7 @@ import router from '@ohos.router'; | @@ -13,6 +13,7 @@ import router from '@ohos.router'; | ||
| 13 | import inputMethod from '@ohos.inputMethod'; | 13 | import inputMethod from '@ohos.inputMethod'; |
| 14 | import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailViewModel'; | 14 | import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailViewModel'; |
| 15 | import { LikeComponent } from './LikeComponent'; | 15 | import { LikeComponent } from './LikeComponent'; |
| 16 | +import { CommentCustomDialog } from '../comment/view/CommentCustomDialog'; | ||
| 16 | import { HttpUrlUtils } from 'wdNetwork/Index'; | 17 | import { HttpUrlUtils } from 'wdNetwork/Index'; |
| 17 | import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | 18 | import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; |
| 18 | import { PageRepository } from '../../repository/PageRepository'; | 19 | import { PageRepository } from '../../repository/PageRepository'; |
| @@ -27,11 +28,13 @@ export interface OperationItem { | @@ -27,11 +28,13 @@ export interface OperationItem { | ||
| 27 | 28 | ||
| 28 | const TAG = 'OperRowListView'; | 29 | const TAG = 'OperRowListView'; |
| 29 | 30 | ||
| 30 | -@Preview | 31 | +// @Preview |
| 32 | +@Entry | ||
| 31 | @Component | 33 | @Component |
| 32 | export struct OperRowListView { | 34 | export struct OperRowListView { |
| 33 | // private contentDetailData: ContentDetailDTO = {} as ContentDetailDTO | 35 | // private contentDetailData: ContentDetailDTO = {} as ContentDetailDTO |
| 34 | - @Prop contentDetailData: ContentDetailDTO | 36 | + // @Prop contentDetailData: ContentDetailDTO |
| 37 | + @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO | ||
| 35 | @State interactData: InteractDataDTO = {} as InteractDataDTO | 38 | @State interactData: InteractDataDTO = {} as InteractDataDTO |
| 36 | @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 | 39 | @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 |
| 37 | @State likeBean: Record<string, string> = {} | 40 | @State likeBean: Record<string, string> = {} |
| @@ -71,12 +74,13 @@ export struct OperRowListView { | @@ -71,12 +74,13 @@ export struct OperRowListView { | ||
| 71 | // this.data['channelId'] = "2059" //必须 | 74 | // this.data['channelId'] = "2059" //必须 |
| 72 | // this.data['status'] = "1" //必须 | 75 | // this.data['status'] = "1" //必须 |
| 73 | this.likeBean['contentId'] = this.contentDetailData.newsId + '' | 76 | this.likeBean['contentId'] = this.contentDetailData.newsId + '' |
| 74 | - this.likeBean['userName'] = this.contentDetailData.editorName + '' | 77 | + this.likeBean['userName'] = this.contentDetailData.userInfo?.userName + '' |
| 75 | this.likeBean['contentType'] = this.contentDetailData.newsType + '' | 78 | this.likeBean['contentType'] = this.contentDetailData.newsType + '' |
| 76 | this.likeBean['title'] = this.contentDetailData.newsTitle + '' | 79 | this.likeBean['title'] = this.contentDetailData.newsTitle + '' |
| 77 | - this.likeBean['userHeaderUrl'] = '' | 80 | + this.likeBean['userHeaderUrl'] = this.contentDetailData.userInfo?.headPhotoUrl + '' |
| 78 | this.likeBean['channelId'] = this.contentDetailData.reLInfo?.channelId + '' | 81 | this.likeBean['channelId'] = this.contentDetailData.reLInfo?.channelId + '' |
| 79 | - this.likeBean['status'] = '' | 82 | + console.info(TAG, 'contentDetailData----', JSON.stringify(this.contentDetailData)) |
| 83 | + console.info(TAG, 'likeBean----', JSON.stringify(this.likeBean)) | ||
| 80 | } | 84 | } |
| 81 | 85 | ||
| 82 | build() { | 86 | build() { |
| @@ -100,7 +104,13 @@ export struct OperRowListView { | @@ -100,7 +104,13 @@ export struct OperRowListView { | ||
| 100 | .onClick(() => { | 104 | .onClick(() => { |
| 101 | router.back(); | 105 | router.back(); |
| 102 | }) | 106 | }) |
| 103 | - TextInput({placeholder:'说两句11...'}) | 107 | + Column() { |
| 108 | + /*评论组件*/ | ||
| 109 | + /* CommentCustomDialog({ | ||
| 110 | + placeHolderText: '说两句' | ||
| 111 | + })*/ | ||
| 112 | + } | ||
| 113 | + /*TextInput({placeholder:'说两句...'}) | ||
| 104 | .placeholderColor('#999999') | 114 | .placeholderColor('#999999') |
| 105 | .placeholderFont( | 115 | .placeholderFont( |
| 106 | { | 116 | { |
| @@ -116,9 +126,9 @@ export struct OperRowListView { | @@ -116,9 +126,9 @@ export struct OperRowListView { | ||
| 116 | .borderRadius(0) | 126 | .borderRadius(0) |
| 117 | .onClick(() => { | 127 | .onClick(() => { |
| 118 | this.buildInputMethod() | 128 | this.buildInputMethod() |
| 119 | - }) | 129 | + })*/ |
| 120 | } | 130 | } |
| 121 | - .width('45.5%') | 131 | + // .width('45.5%') |
| 122 | .alignItems(VerticalAlign.Center) | 132 | .alignItems(VerticalAlign.Center) |
| 123 | .justifyContent(FlexAlign.Start) | 133 | .justifyContent(FlexAlign.Start) |
| 124 | Flex({ justifyContent: FlexAlign.SpaceAround, alignItems:ItemAlign.Center }) { | 134 | Flex({ justifyContent: FlexAlign.SpaceAround, alignItems:ItemAlign.Center }) { |
| @@ -129,8 +139,11 @@ export struct OperRowListView { | @@ -129,8 +139,11 @@ export struct OperRowListView { | ||
| 129 | .width('54.5%') | 139 | .width('54.5%') |
| 130 | } | 140 | } |
| 131 | .width('100%') | 141 | .width('100%') |
| 132 | - .height(126) | 142 | + .height(50) |
| 133 | .backgroundColor(Color.Black) | 143 | .backgroundColor(Color.Black) |
| 144 | + .margin({ | ||
| 145 | + bottom: 20 | ||
| 146 | + }) | ||
| 134 | } | 147 | } |
| 135 | /** | 148 | /** |
| 136 | * 组件项 | 149 | * 组件项 |
| @@ -141,9 +154,12 @@ export struct OperRowListView { | @@ -141,9 +154,12 @@ export struct OperRowListView { | ||
| 141 | buildOperationItem(item: OperationItem, index: number) { | 154 | buildOperationItem(item: OperationItem, index: number) { |
| 142 | Column() { | 155 | Column() { |
| 143 | if (item.text === '点赞') { | 156 | if (item.text === '点赞') { |
| 144 | - LikeComponent({ | ||
| 145 | - data: this.likeBean | ||
| 146 | - }) | 157 | + /*点赞组件*/ |
| 158 | + if (this.likeBean?.contentId) { | ||
| 159 | + LikeComponent({ | ||
| 160 | + data: this.likeBean | ||
| 161 | + }) | ||
| 162 | + } | ||
| 147 | 163 | ||
| 148 | /* RelativeContainer() { | 164 | /* RelativeContainer() { |
| 149 | Row() { | 165 | Row() { |
| @@ -191,6 +207,7 @@ export struct OperRowListView { | @@ -191,6 +207,7 @@ export struct OperRowListView { | ||
| 191 | } | 207 | } |
| 192 | .id(`e_icon_${index}`)*/ | 208 | .id(`e_icon_${index}`)*/ |
| 193 | } else if (item.text === '收藏') { | 209 | } else if (item.text === '收藏') { |
| 210 | + | ||
| 194 | RelativeContainer() { | 211 | RelativeContainer() { |
| 195 | Row() { | 212 | Row() { |
| 196 | Image(this.newsStatusOfUser?.collectStatus == 1 ? item.icon_check : item.icon) | 213 | Image(this.newsStatusOfUser?.collectStatus == 1 ? item.icon_check : item.icon) |
| @@ -236,7 +253,7 @@ export struct OperRowListView { | @@ -236,7 +253,7 @@ export struct OperRowListView { | ||
| 236 | } | 253 | } |
| 237 | .id(`e_icon_${index}`) | 254 | .id(`e_icon_${index}`) |
| 238 | } else if (item.text === '评论') { | 255 | } else if (item.text === '评论') { |
| 239 | - RelativeContainer() { | 256 | + /* RelativeContainer() { |
| 240 | Row() { | 257 | Row() { |
| 241 | Image(item.icon) | 258 | Image(item.icon) |
| 242 | .width(24) | 259 | .width(24) |
| @@ -279,7 +296,7 @@ export struct OperRowListView { | @@ -279,7 +296,7 @@ export struct OperRowListView { | ||
| 279 | .id(`e_row3_${index}`) | 296 | .id(`e_row3_${index}`) |
| 280 | } | 297 | } |
| 281 | } | 298 | } |
| 282 | - .id(`e_icon_${index}`) | 299 | + .id(`e_icon_${index}`)*/ |
| 283 | } else { | 300 | } else { |
| 284 | RelativeContainer() { | 301 | RelativeContainer() { |
| 285 | Row() { | 302 | Row() { |
| @@ -43,5 +43,27 @@ export class LikeModel { | @@ -43,5 +43,27 @@ export class LikeModel { | ||
| 43 | 43 | ||
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | + getLikeCount(data: Record<string, string>) { | ||
| 47 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 48 | + let channelId : string = data['channelId'] | ||
| 49 | + let contentId : string = data['contentId'] | ||
| 50 | + let contentType : string = data['contentType'] | ||
| 51 | + let detail : string = '1' | ||
| 52 | + let url = HttpUrlUtils.getLikeCount() + `?channelId=${channelId}&contentId=${contentId}&contentType=${contentType}&detail=${detail}` | ||
| 53 | + return new Promise<object>((success, fail) => { | ||
| 54 | + HttpBizUtil.get<ResponseDTO<object>>(url, headers).then((data: ResponseDTO<object>) => { | ||
| 55 | + if (data.code != 0) { | ||
| 56 | + fail(data.message) | ||
| 57 | + return | ||
| 58 | + } | ||
| 59 | + success(data) | ||
| 60 | + }, (error: Error) => { | ||
| 61 | + fail(error.message) | ||
| 62 | + Logger.debug("LoginViewModel:error ", error.toString()) | ||
| 63 | + }) | ||
| 64 | + }) | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + | ||
| 46 | 68 | ||
| 47 | } | 69 | } |
| 1 | import HashMap from '@ohos.util.HashMap'; | 1 | import HashMap from '@ohos.util.HashMap'; |
| 2 | -import { UserDataLocal } from 'wdKit/Index'; | ||
| 3 | -import { HttpUrlUtils, ResponseDTO } from 'wdNetwork'; | ||
| 4 | -import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; | 2 | +import { HttpBizUtil, HttpUrlUtils, ResponseDTO } from 'wdNetwork'; |
| 5 | 3 | ||
| 6 | export class LogoutModel{ | 4 | export class LogoutModel{ |
| 7 | 5 | ||
| 8 | requestLogout(){ | 6 | requestLogout(){ |
| 9 | let bean: Record<string, string> = {}; | 7 | let bean: Record<string, string> = {}; |
| 10 | - bean['refreshToken'] = UserDataLocal.USER_REFRESH_TOKEN | ||
| 11 | - bean['refreshToken'] = 'ddrqreeee' | 8 | + bean['refreshToken'] = HttpUrlUtils.getRefreshToken() |
| 12 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 9 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 13 | return new Promise<string>((success, fail) => { | 10 | return new Promise<string>((success, fail) => { |
| 14 | - HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.accountLogoutUrl(), bean, headers).then((data: ResponseDTO<string>) => { | 11 | + HttpBizUtil.post<ResponseDTO<string>>(HttpUrlUtils.accountLogoutUrl(), bean, headers).then((data: ResponseDTO<string>) => { |
| 15 | if (!data) { | 12 | if (!data) { |
| 16 | fail("数据为空") | 13 | fail("数据为空") |
| 17 | return | 14 | return |
| @@ -23,7 +20,6 @@ export class LogoutModel{ | @@ -23,7 +20,6 @@ export class LogoutModel{ | ||
| 23 | success(data.message) | 20 | success(data.message) |
| 24 | }, (error: Error) => { | 21 | }, (error: Error) => { |
| 25 | fail(error.message) | 22 | fail(error.message) |
| 26 | - // Logger.debug("LoginViewModel:error ", error.toString()) | ||
| 27 | }) | 23 | }) |
| 28 | }) | 24 | }) |
| 29 | } | 25 | } |
| @@ -19,7 +19,7 @@ const TAG = "SearcherAboutDataModel" | @@ -19,7 +19,7 @@ const TAG = "SearcherAboutDataModel" | ||
| 19 | class SearcherAboutDataModel{ | 19 | class SearcherAboutDataModel{ |
| 20 | private static instance: SearcherAboutDataModel; | 20 | private static instance: SearcherAboutDataModel; |
| 21 | public searchHistoryData:SearchHistoryItem[] = [] | 21 | public searchHistoryData:SearchHistoryItem[] = [] |
| 22 | - public SEARCH_HISTORY_KEY:string = "SEARCH_HISTORY_KEY" + UserDataLocal.userId | 22 | + public SEARCH_HISTORY_KEY:string = "SEARCH_HISTORY_KEY" + UserDataLocal.getUserId() |
| 23 | 23 | ||
| 24 | private constructor() { } | 24 | private constructor() { } |
| 25 | 25 |
| @@ -29,13 +29,11 @@ struct MineHomePage { | @@ -29,13 +29,11 @@ struct MineHomePage { | ||
| 29 | registTime:number = 0//账号注册时间 | 29 | registTime:number = 0//账号注册时间 |
| 30 | @State registerTimeForDay:number = 0 | 30 | @State registerTimeForDay:number = 0 |
| 31 | 31 | ||
| 32 | - aboutToAppear(){ | 32 | + onPageShow(): void { |
| 33 | this.getUserInfo() | 33 | this.getUserInfo() |
| 34 | this.getUserLevel() | 34 | this.getUserLevel() |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | - | ||
| 38 | - | ||
| 39 | build() { | 37 | build() { |
| 40 | Stack({ alignContent: Alignment.Top }){ | 38 | Stack({ alignContent: Alignment.Top }){ |
| 41 | Image($r('app.media.title_bg')) | 39 | Image($r('app.media.title_bg')) |
| @@ -65,9 +63,8 @@ struct MineHomePage { | @@ -65,9 +63,8 @@ struct MineHomePage { | ||
| 65 | .height('130lpx') | 63 | .height('130lpx') |
| 66 | .objectFit(ImageFit.Cover) | 64 | .objectFit(ImageFit.Cover) |
| 67 | }.onClick(()=>{ | 65 | }.onClick(()=>{ |
| 68 | - //TODO 显示头像 | ||
| 69 | - let params = {'userId': "531267787833221"} as Record<string, string>; | ||
| 70 | - WDRouterRule.jumpWithPage(WDRouterPage.otherNormalUserHomePagePage,params) | 66 | + let params = {'headPhotoUrl': this.headPhotoUrl} as Record<string, string>; |
| 67 | + WDRouterRule.jumpWithPage(WDRouterPage.showUserHeaderPage,params) | ||
| 71 | }).width('135lpx') | 68 | }).width('135lpx') |
| 72 | .height('135lpx') | 69 | .height('135lpx') |
| 73 | 70 | ||
| @@ -370,6 +367,9 @@ struct MineHomePage { | @@ -370,6 +367,9 @@ struct MineHomePage { | ||
| 370 | if(StringUtils.isNotEmpty(value.introduction)){ | 367 | if(StringUtils.isNotEmpty(value.introduction)){ |
| 371 | this.desc = value.introduction | 368 | this.desc = value.introduction |
| 372 | this.isHasIntroduction = true | 369 | this.isHasIntroduction = true |
| 370 | + }else{ | ||
| 371 | + this.desc = "点击添加简介,让大家认识你" | ||
| 372 | + this.isHasIntroduction = false | ||
| 373 | } | 373 | } |
| 374 | this.browseNum = value.browseNum | 374 | this.browseNum = value.browseNum |
| 375 | this.commentNum = value.commentNum | 375 | this.commentNum = value.commentNum |
| 1 | import { PhotoListBean } from 'wdBean/Index'; | 1 | import { PhotoListBean } from 'wdBean/Index'; |
| 2 | import { display, router } from '@kit.ArkUI'; | 2 | import { display, router } from '@kit.ArkUI'; |
| 3 | -import { Logger } from 'wdKit/Index'; | ||
| 4 | import { ImageItemView } from '../components/view/ImageItemView'; | 3 | import { ImageItemView } from '../components/view/ImageItemView'; |
| 5 | import { ImageDownloadComponent } from '../components/ImageDownloadComponent'; | 4 | import { ImageDownloadComponent } from '../components/ImageDownloadComponent'; |
| 6 | import { Action } from 'wdBean'; | 5 | import { Action } from 'wdBean'; |
| @@ -10,7 +9,6 @@ const TAG = 'MultiPictureListPage'; | @@ -10,7 +9,6 @@ const TAG = 'MultiPictureListPage'; | ||
| 10 | @Entry | 9 | @Entry |
| 11 | @Component | 10 | @Component |
| 12 | export struct MultiPictureListPage { | 11 | export struct MultiPictureListPage { |
| 13 | - @Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01' | ||
| 14 | private scroller: Scroller = new Scroller() | 12 | private scroller: Scroller = new Scroller() |
| 15 | @State swiperIndex: number = 0; | 13 | @State swiperIndex: number = 0; |
| 16 | photoList: PhotoListBean[] = []; | 14 | photoList: PhotoListBean[] = []; |
| @@ -20,17 +18,10 @@ export struct MultiPictureListPage { | @@ -20,17 +18,10 @@ export struct MultiPictureListPage { | ||
| 20 | private picWidth: number = 0 | 18 | private picWidth: number = 0 |
| 21 | @State picHeight: number = 0 | 19 | @State picHeight: number = 0 |
| 22 | @State isEnableSwipe: boolean = true; | 20 | @State isEnableSwipe: boolean = true; |
| 21 | + @State currentUrl: string = '' | ||
| 23 | 22 | ||
| 24 | // @Provide bgc: Color = Color.White; | 23 | // @Provide bgc: Color = Color.White; |
| 25 | 24 | ||
| 26 | - //watch监听页码回调 | ||
| 27 | - onCurrentPageNumUpdated(): void { | ||
| 28 | - Logger.info(TAG, `currentPageNum:${this.currentPageNum}`,) | ||
| 29 | - let _swiperIndex = Number.parseInt(this.currentPageNum) | ||
| 30 | - Logger.info(TAG, `_swiperIndex:${_swiperIndex}`) | ||
| 31 | - this.swiperIndex = _swiperIndex > 0 ? _swiperIndex - 1 : _swiperIndex | ||
| 32 | - } | ||
| 33 | - | ||
| 34 | aboutToAppear(): void { | 25 | aboutToAppear(): void { |
| 35 | //获取宽高尺寸 | 26 | //获取宽高尺寸 |
| 36 | this.screenWidth = this.displayTool.width | 27 | this.screenWidth = this.displayTool.width |
| @@ -40,6 +31,8 @@ export struct MultiPictureListPage { | @@ -40,6 +31,8 @@ export struct MultiPictureListPage { | ||
| 40 | let par: Action = router.getParams() as Action; | 31 | let par: Action = router.getParams() as Action; |
| 41 | let params = par?.params; | 32 | let params = par?.params; |
| 42 | this.photoList = params?.extra?.photoList || []; | 33 | this.photoList = params?.extra?.photoList || []; |
| 34 | + this.swiperIndex = params?.extra?.swiperIndex || 0; | ||
| 35 | + this.currentUrl = this.photoList[this.swiperIndex]?.picPath | ||
| 43 | } | 36 | } |
| 44 | 37 | ||
| 45 | build() { | 38 | build() { |
| @@ -80,6 +73,7 @@ export struct MultiPictureListPage { | @@ -80,6 +73,7 @@ export struct MultiPictureListPage { | ||
| 80 | }) | 73 | }) |
| 81 | .onChange((index: number) => { | 74 | .onChange((index: number) => { |
| 82 | this.swiperIndex = index | 75 | this.swiperIndex = index |
| 76 | + this.currentUrl = this.photoList[index]?.picPath | ||
| 83 | }) | 77 | }) |
| 84 | 78 | ||
| 85 | Row() { | 79 | Row() { |
| @@ -121,7 +115,7 @@ export struct MultiPictureListPage { | @@ -121,7 +115,7 @@ export struct MultiPictureListPage { | ||
| 121 | }) | 115 | }) |
| 122 | } | 116 | } |
| 123 | 117 | ||
| 124 | - ImageDownloadComponent({ url: this.photoList[this.swiperIndex].picPath }) | 118 | + ImageDownloadComponent({ url: this.currentUrl }) |
| 125 | .alignRules({ | 119 | .alignRules({ |
| 126 | bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, | 120 | bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, |
| 127 | right: { anchor: "__container__", align: HorizontalAlign.End } | 121 | right: { anchor: "__container__", align: HorizontalAlign.End } |
| 1 | +import { router } from '@kit.ArkUI'; | ||
| 2 | + | ||
| 3 | +@Entry | ||
| 4 | +@Component | ||
| 5 | +struct ShowUserHeaderPage { | ||
| 6 | + @State headPhotoUrl: string = ''; | ||
| 7 | + @State params:Record<string, string> = router.getParams() as Record<string, string>; | ||
| 8 | + | ||
| 9 | + onPageShow() { | ||
| 10 | + this.headPhotoUrl = this.params?.['headPhotoUrl']; | ||
| 11 | + } | ||
| 12 | + | ||
| 13 | + build() { | ||
| 14 | + Row() { | ||
| 15 | + Image(this.headPhotoUrl) | ||
| 16 | + .alt($r('app.media.default_head')) | ||
| 17 | + .width('720lpx') | ||
| 18 | + .height('720lpx') | ||
| 19 | + .objectFit(ImageFit.Auto) | ||
| 20 | + .clip(new Circle({ width: '720lpx', height: '720lpx' })) | ||
| 21 | + } | ||
| 22 | + .width('100%') | ||
| 23 | + .height('100%') | ||
| 24 | + .alignItems(VerticalAlign.Center) | ||
| 25 | + .backgroundColor($r('app.color.color_000000')) | ||
| 26 | + .onClick(()=>{ | ||
| 27 | + router.back() | ||
| 28 | + }) | ||
| 29 | + } | ||
| 30 | +} |
| @@ -35,16 +35,8 @@ export class PageRepository { | @@ -35,16 +35,8 @@ export class PageRepository { | ||
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | static getPageInfoUrl(pageId: string) { | 37 | static getPageInfoUrl(pageId: string) { |
| 38 | - let url = HttpUrlUtils.getHost() + HttpUrlUtils.PAGE_INFO_PATH; | ||
| 39 | - // TODO 暂定只请求第一页,后续对接分页加载,参数再调整 first_load? | ||
| 40 | - url = url + "?channelStrategy=2&loadStrategy=first_load" | ||
| 41 | - + "&districtCode=" + HttpUrlUtils.getDistrictCode() | ||
| 42 | - + "&provinceCode=" + HttpUrlUtils.getProvinceCode() | ||
| 43 | - + "&cityCode=" + HttpUrlUtils.getCityCode() | ||
| 44 | - + "&refreshTime=" + DateTimeUtils.getTimeStamp() | ||
| 45 | - + "&pageId=" + pageId | ||
| 46 | - // Logger.debug("TAG", 'getCompInfoUrl url: '+url); | ||
| 47 | - Logger.info(TAG, "getPageInfoUrl url = " + url) | 38 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.PAGE_INFO_PATH + "?pageId=" + pageId; |
| 39 | + // Logger.info(TAG, "getPageInfoUrl url = " + url) | ||
| 48 | return url; | 40 | return url; |
| 49 | } | 41 | } |
| 50 | 42 | ||
| @@ -293,7 +285,7 @@ export class PageRepository { | @@ -293,7 +285,7 @@ export class PageRepository { | ||
| 293 | static postExecuteLike(params: postExecuteLikeParams): Promise<ResponseDTO> { | 285 | static postExecuteLike(params: postExecuteLikeParams): Promise<ResponseDTO> { |
| 294 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTELIKE | 286 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTELIKE |
| 295 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 287 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 296 | - return WDHttp.post0(url, params, headers) | 288 | + return WDHttp.post(url, params, headers) |
| 297 | } | 289 | } |
| 298 | 290 | ||
| 299 | /** | 291 | /** |
| @@ -304,7 +296,7 @@ export class PageRepository { | @@ -304,7 +296,7 @@ export class PageRepository { | ||
| 304 | static postExecuteCollectRecord(params: postExecuteCollectRecordParams): Promise<ResponseDTO> { | 296 | static postExecuteCollectRecord(params: postExecuteCollectRecordParams): Promise<ResponseDTO> { |
| 305 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTECOLLECTRECORD | 297 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTECOLLECTRECORD |
| 306 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 298 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 307 | - return WDHttp.post0(url, params, headers) | 299 | + return WDHttp.post(url, params, headers) |
| 308 | } | 300 | } |
| 309 | 301 | ||
| 310 | /** | 302 | /** |
| @@ -314,7 +306,7 @@ export class PageRepository { | @@ -314,7 +306,7 @@ export class PageRepository { | ||
| 314 | static getContentInteract(params: contentListParams): Promise<ResponseDTO<InteractDataDTO[]>> { | 306 | static getContentInteract(params: contentListParams): Promise<ResponseDTO<InteractDataDTO[]>> { |
| 315 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH | 307 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH |
| 316 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 308 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 317 | - return WDHttp.post0(url, params, headers) | 309 | + return WDHttp.post(url, params, headers) |
| 318 | } | 310 | } |
| 319 | 311 | ||
| 320 | // 浏览历史新增、删除接口 | 312 | // 浏览历史新增、删除接口 |
| @@ -331,7 +323,7 @@ export class PageRepository { | @@ -331,7 +323,7 @@ export class PageRepository { | ||
| 331 | static fetchBatchAttentionStatus(params: postBatchAttentionStatusParams): Promise<ResponseDTO<postBatchAttentionStatusResult[]>> { | 323 | static fetchBatchAttentionStatus(params: postBatchAttentionStatusParams): Promise<ResponseDTO<postBatchAttentionStatusResult[]>> { |
| 332 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.FOLLOW_LIST_STATUS_DATA_PATH | 324 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.FOLLOW_LIST_STATUS_DATA_PATH |
| 333 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 325 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 334 | - return WDHttp.post0(url, params, headers) | 326 | + return WDHttp.post(url, params, headers) |
| 335 | } | 327 | } |
| 336 | 328 | ||
| 337 | /** | 329 | /** |
| @@ -340,7 +332,7 @@ export class PageRepository { | @@ -340,7 +332,7 @@ export class PageRepository { | ||
| 340 | static postInteractAccentionOperate(params: postInteractAccentionOperateParams): Promise<ResponseDTO> { | 332 | static postInteractAccentionOperate(params: postInteractAccentionOperateParams): Promise<ResponseDTO> { |
| 341 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_ACCENTION_OPERATION | 333 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_ACCENTION_OPERATION |
| 342 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 334 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 343 | - return WDHttp.post0(url, params, headers) | 335 | + return WDHttp.post(url, params, headers) |
| 344 | } | 336 | } |
| 345 | 337 | ||
| 346 | static fetchNewspaperInfo(date: string) { | 338 | static fetchNewspaperInfo(date: string) { |
| 1 | +/* | ||
| 2 | + * Copyright (c) 2024 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * RGB颜色类型 | ||
| 18 | + */ | ||
| 19 | +export interface ColorRgb { | ||
| 20 | + // 红色(Red) | ||
| 21 | + red: number; | ||
| 22 | + | ||
| 23 | + // 绿色(Green) | ||
| 24 | + green: number; | ||
| 25 | + | ||
| 26 | + // 蓝色(Blue) | ||
| 27 | + blue: number; | ||
| 28 | + | ||
| 29 | + // 透明度 | ||
| 30 | + alpha: number; | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +/** | ||
| 34 | + * HSV颜色类型 | ||
| 35 | + */ | ||
| 36 | +export interface ColorHsv { | ||
| 37 | + // 色调 | ||
| 38 | + hue: number; | ||
| 39 | + | ||
| 40 | + // 饱和度 | ||
| 41 | + saturation: number; | ||
| 42 | + | ||
| 43 | + // 明度 | ||
| 44 | + value: number; | ||
| 45 | + | ||
| 46 | + // 透明度 | ||
| 47 | + alpha: number; | ||
| 48 | +} | ||
| 49 | + | ||
| 50 | +// RGB颜色最大值 | ||
| 51 | +const MAX_RGB_VALUE: number = 255.0; | ||
| 52 | + | ||
| 53 | +export class ColorUtils { | ||
| 54 | + /** | ||
| 55 | + * RGB格式转换为HSV格式,公式参考resources/base/media/rgb_to_hsv.png | ||
| 56 | + * @param color RGB像素值 | ||
| 57 | + * @returns HSV像素值 | ||
| 58 | + */ | ||
| 59 | + public static rgb2hsv(color: ColorRgb): ColorHsv { | ||
| 60 | + // RGB颜色取值范围是0~255,需要转换为0~1的浮点数 | ||
| 61 | + const red: number = color.red / MAX_RGB_VALUE; | ||
| 62 | + const green: number = color.green / MAX_RGB_VALUE; | ||
| 63 | + const blue: number = color.blue / MAX_RGB_VALUE; | ||
| 64 | + | ||
| 65 | + const max: number = Math.max(red, green, blue); | ||
| 66 | + const min: number = Math.min(red, green, blue); | ||
| 67 | + const delta: number = max - min; | ||
| 68 | + | ||
| 69 | + // 色调 | ||
| 70 | + let hue: number = 0; | ||
| 71 | + // 饱和度 | ||
| 72 | + let saturation: number = 0; | ||
| 73 | + // 明度 | ||
| 74 | + let value: number = 0; | ||
| 75 | + // 计算hue值 | ||
| 76 | + if (max === min) { | ||
| 77 | + hue = 0; | ||
| 78 | + } else if (Math.abs(max - red) < Number.EPSILON) { | ||
| 79 | + hue = (green >= blue ? ((green - blue) / delta) * 60 : ((green - blue) / delta) * 60 + 360); | ||
| 80 | + } else if (Math.abs(max - green) < Number.EPSILON) { | ||
| 81 | + hue = (((blue - red) / delta) + 2) * 60; | ||
| 82 | + } else if (Math.abs(max - blue) < Number.EPSILON) { | ||
| 83 | + hue = (((red - green) / delta) + 4) * 60; | ||
| 84 | + } | ||
| 85 | + // 计算saturation值 | ||
| 86 | + saturation = (max === 0 ? 0 : delta / max); | ||
| 87 | + // 计算value值 | ||
| 88 | + value = max; | ||
| 89 | + | ||
| 90 | + return { | ||
| 91 | + hue: hue, | ||
| 92 | + saturation: saturation, | ||
| 93 | + value: value, | ||
| 94 | + alpha: color.alpha | ||
| 95 | + } | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + /** | ||
| 99 | + * HSV格式转换为RGB格式,公式可参考resources/base/media/hsv_to_rgb.png | ||
| 100 | + * @param color HSV像素值 | ||
| 101 | + * @returns RGB像素值 | ||
| 102 | + */ | ||
| 103 | + public static hsv2rgb(color: ColorHsv): ColorRgb { | ||
| 104 | + // hue取值范围是0~360°,每60°为一个区间,每个区间中RGB计算方式不同 | ||
| 105 | + const h60: number = color.hue / 60; | ||
| 106 | + // 向下取整 | ||
| 107 | + const h60f: number = Math.floor(h60); | ||
| 108 | + const hi: number = h60f % 6; | ||
| 109 | + const f: number = h60 - h60f; | ||
| 110 | + // 计算不同hue区间里面的RGB值 | ||
| 111 | + const p: number = color.value * (1 - color.saturation); | ||
| 112 | + const q: number = color.value * (1 - f * color.saturation); | ||
| 113 | + const t: number = color.value * (1 - (1 - f) * color.saturation); | ||
| 114 | + | ||
| 115 | + let red: number = 0.0; | ||
| 116 | + let green: number = 0.0; | ||
| 117 | + let blue: number = 0.0; | ||
| 118 | + // 根据区间,计算RGB的值 | ||
| 119 | + if (hi === 0) { | ||
| 120 | + red = color.value; | ||
| 121 | + green = t; | ||
| 122 | + blue = p; | ||
| 123 | + } else if (hi === 1) { | ||
| 124 | + red = q; | ||
| 125 | + green = color.value; | ||
| 126 | + blue = p; | ||
| 127 | + } else if (hi === 2) { | ||
| 128 | + red = p; | ||
| 129 | + green = color.value; | ||
| 130 | + blue = t; | ||
| 131 | + } else if (hi === 3) { | ||
| 132 | + red = p; | ||
| 133 | + green = q; | ||
| 134 | + blue = color.value; | ||
| 135 | + } else if (hi === 4) { | ||
| 136 | + red = t; | ||
| 137 | + green = p; | ||
| 138 | + blue = color.value; | ||
| 139 | + } else if (hi === 5) { | ||
| 140 | + red = color.value; | ||
| 141 | + green = p; | ||
| 142 | + blue = q; | ||
| 143 | + } | ||
| 144 | + // RGB取值范围是0~255,需要通过计算 | ||
| 145 | + return { | ||
| 146 | + red: Math.floor(red * MAX_RGB_VALUE), | ||
| 147 | + green: Math.floor(green * MAX_RGB_VALUE), | ||
| 148 | + blue: Math.floor(blue * MAX_RGB_VALUE), | ||
| 149 | + alpha: color.alpha | ||
| 150 | + } | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + /** | ||
| 154 | + * RGB颜色转为整数值 | ||
| 155 | + * @param color RGB像素值 | ||
| 156 | + * @returns 整数 | ||
| 157 | + */ | ||
| 158 | + public static rgbToNumber(color: ColorRgb): number { | ||
| 159 | + const tmpColor = ((color.alpha << 24) | (color.red << 16) | (color.green << 8) | color.blue) | ||
| 160 | + return tmpColor; | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + /** | ||
| 164 | + * 整数值转为RGB颜色值 | ||
| 165 | + * @param color 整数 | ||
| 166 | + * @returns RGB格式像素 | ||
| 167 | + */ | ||
| 168 | + public static numberToRgb(color: number): ColorRgb { | ||
| 169 | + return { | ||
| 170 | + red: (color & 0xFF0000) >> 16, | ||
| 171 | + green: (color & 0xFF00) >> 8, | ||
| 172 | + blue: (color & 0xFF), | ||
| 173 | + alpha: (color & 0xFF000000) >> 24 | ||
| 174 | + } | ||
| 175 | + } | ||
| 176 | +} |
| 1 | +/* | ||
| 2 | + * Copyright (c) 2024 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +import { resourceManager } from '@kit.LocalizationKit'; | ||
| 17 | +import { image } from '@kit.ImageKit'; | ||
| 18 | +import { ColorHsv, ColorRgb, ColorUtils } from './ColorUtils'; | ||
| 19 | +import { http } from '@kit.NetworkKit'; | ||
| 20 | +import { BusinessError } from '@kit.BasicServicesKit'; | ||
| 21 | +import ResponseCode from '@ohos.net.http'; | ||
| 22 | + | ||
| 23 | +const resourceMgs: resourceManager.ResourceManager = getContext(this).resourceManager; | ||
| 24 | +const PIXEL_MAP_SIZE_WIDTH: number = 40; | ||
| 25 | +const PIXEL_MAP_SIZE_HEIGHT: number = 40; | ||
| 26 | + | ||
| 27 | +/** | ||
| 28 | + * 图片转换为PixelMap对象 | ||
| 29 | + * @param icon 图片地址,模拟数据存放于rawfile文件夹中 | ||
| 30 | + * @returns 图片转换的PixelMap对象 | ||
| 31 | + */ | ||
| 32 | +export async function image2PixelMap(icon: string): Promise<image.PixelMap> { | ||
| 33 | + // 读取rawfile文件夹下的文件 | ||
| 34 | + const rawFileDescriptor: resourceManager.RawFileDescriptor = resourceMgs.getRawFdSync(icon); | ||
| 35 | + const imageSource: image.ImageSource = image.createImageSource(rawFileDescriptor); | ||
| 36 | + // 通过ImageSource对象创建PixelMap对象,使用BGRA_8888格式,由4个字节表示一个像素 | ||
| 37 | + const pixelMap: Promise<PixelMap> = imageSource.createPixelMap({ | ||
| 38 | + editable: false, | ||
| 39 | + desiredPixelFormat: image.PixelMapFormat.BGRA_8888, | ||
| 40 | + // 高性能知识点:经测试,将图片的宽和高设置为40像素时,既可以保证提取颜色的准确性,也可以保证计算颜色的速度。 | ||
| 41 | + desiredSize: { width: PIXEL_MAP_SIZE_WIDTH, height: PIXEL_MAP_SIZE_HEIGHT } | ||
| 42 | + }) | ||
| 43 | + return pixelMap; | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | +/** | ||
| 47 | + * 通过http的request方法从网络下载图片资源 | ||
| 48 | + */ | ||
| 49 | +// export async function getPicture() { | ||
| 50 | +// const url:string='https://rmrbcmsonline.peopleapp.com/upload/image/202312/rmrb_86691703594454.png' | ||
| 51 | +// http.createHttp() | ||
| 52 | +// .request(url, | ||
| 53 | +// (error: BusinessError, data: http.HttpResponse) => { | ||
| 54 | +// // if (error) { | ||
| 55 | +// // // 下载失败时弹窗提示检查网络,不执行后续逻辑 | ||
| 56 | +// // promptAction.showToast({ | ||
| 57 | +// // message: $r('app.string.image_request_fail'), | ||
| 58 | +// // duration: 2000 | ||
| 59 | +// // }) | ||
| 60 | +// // return; | ||
| 61 | +// // } | ||
| 62 | +// // transcodePixelMap(data); | ||
| 63 | +// // 判断网络获取到的资源是否为ArrayBuffer类型 | ||
| 64 | +// // if (data.result instanceof ArrayBuffer) { | ||
| 65 | +// // this.imageBuffer = data.result as ArrayBuffer; | ||
| 66 | +// // } | ||
| 67 | +// if (ResponseCode.ResponseCode.OK === data.responseCode) { | ||
| 68 | +// const imageData: ArrayBuffer = data.result as ArrayBuffer; | ||
| 69 | +// // 通过ArrayBuffer创建图片源实例。 | ||
| 70 | +// const imageSource: image.ImageSource = image.createImageSource(imageData); | ||
| 71 | +// return imageSource | ||
| 72 | +// // const options: image.InitializationOptions = { | ||
| 73 | +// // 'alphaType': 0, // 透明度 | ||
| 74 | +// // 'editable': false, // 是否可编辑 | ||
| 75 | +// // 'pixelFormat': 3, // 像素格式 | ||
| 76 | +// // 'scaleMode': 1, // 缩略值 | ||
| 77 | +// // 'size': { height: 100, width: 100 } | ||
| 78 | +// // }; // 创建图片大小 | ||
| 79 | +// | ||
| 80 | +// // 通过属性创建PixelMap | ||
| 81 | +// // imageSource.createPixelMap(options).then((pixelMap: PixelMap) => { | ||
| 82 | +// // // this.image = pixelMap; | ||
| 83 | +// // }); | ||
| 84 | +// // imageNet2PixelMap(imageSource) | ||
| 85 | +// } | ||
| 86 | +// } | ||
| 87 | +// ) | ||
| 88 | +// } | ||
| 89 | + | ||
| 90 | +// 假设http和image是之前正确导入或定义的模块 | ||
| 91 | +export async function getPicture(imageUrl: string): Promise<image.ImageSource | undefined> { | ||
| 92 | + // const url: string = 'https://rmrbcmsonline.peopleapp.com/upload/image/202312/rmrb_86691703594454.png'; | ||
| 93 | + const url: string = 'https://rmrbcmsonline.peopleapp.com/upload/image/201912/rmrb_24141576767688.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg'; | ||
| 94 | + | ||
| 95 | + return new Promise((resolve, reject) => { | ||
| 96 | + http.createHttp().request(url, (error: BusinessError, data: http.HttpResponse) => { | ||
| 97 | + if (error) { | ||
| 98 | + // 处理错误情况,比如网络错误 | ||
| 99 | + console.error("Download error", error); | ||
| 100 | + // 你可以选择reject(error)或者根据需要调整 | ||
| 101 | + reject(error); | ||
| 102 | + return; | ||
| 103 | + } | ||
| 104 | + if (ResponseCode.ResponseCode.OK === data.responseCode) { | ||
| 105 | + const imageData: ArrayBuffer = data.result as ArrayBuffer; | ||
| 106 | + // 通过ArrayBuffer创建图片源实例 | ||
| 107 | + const imageSource: image.ImageSource = image.createImageSource(imageData); | ||
| 108 | + resolve(imageSource); // 成功时解析Promise | ||
| 109 | + } else { | ||
| 110 | + // 处理其他响应码 | ||
| 111 | + reject(new Error('Invalid response code')); | ||
| 112 | + } | ||
| 113 | + }); | ||
| 114 | + }); | ||
| 115 | +} | ||
| 116 | + | ||
| 117 | + | ||
| 118 | +/** | ||
| 119 | + * 使用createPixelMap将ArrayBuffer类型的图片装换为PixelMap类型 | ||
| 120 | + * @param data:网络获取到的资源 | ||
| 121 | + */ | ||
| 122 | +function transcodePixelMap(data: http.HttpResponse) { | ||
| 123 | + if (ResponseCode.ResponseCode.OK === data.responseCode) { | ||
| 124 | + const imageData: ArrayBuffer = data.result as ArrayBuffer; | ||
| 125 | + // 通过ArrayBuffer创建图片源实例。 | ||
| 126 | + const imageSource: image.ImageSource = image.createImageSource(imageData); | ||
| 127 | + // const options: image.InitializationOptions = { | ||
| 128 | + // 'alphaType': 0, // 透明度 | ||
| 129 | + // 'editable': false, // 是否可编辑 | ||
| 130 | + // 'pixelFormat': 3, // 像素格式 | ||
| 131 | + // 'scaleMode': 1, // 缩略值 | ||
| 132 | + // 'size': { height: 100, width: 100 } | ||
| 133 | + // }; // 创建图片大小 | ||
| 134 | + | ||
| 135 | + // 通过属性创建PixelMap | ||
| 136 | + // imageSource.createPixelMap(options).then((pixelMap: PixelMap) => { | ||
| 137 | + // // this.image = pixelMap; | ||
| 138 | + // }); | ||
| 139 | + // imageNet2PixelMap(imageSource) | ||
| 140 | + } | ||
| 141 | +} | ||
| 142 | + | ||
| 143 | +/** | ||
| 144 | + * 图片转换为PixelMap对象 | ||
| 145 | + * @param icon 图片地址,模拟数据存放于rawfile文件夹中 | ||
| 146 | + * @returns 图片转换的PixelMap对象 | ||
| 147 | + */ | ||
| 148 | +export async function imageNet2PixelMap(imageSource: image.ImageSource): Promise<image.PixelMap> { | ||
| 149 | + // 读取rawfile文件夹下的文件 | ||
| 150 | + // const rawFileDescriptor: resourceManager.RawFileDescriptor = resourceMgs.getRawFdSync(icon); | ||
| 151 | + // const imageSource: image.ImageSource = image.createImageSource(rawFileDescriptor); | ||
| 152 | + // 通过ImageSource对象创建PixelMap对象,使用BGRA_8888格式,由4个字节表示一个像素 | ||
| 153 | + const pixelMap: Promise<PixelMap> = imageSource.createPixelMap({ | ||
| 154 | + editable: false, | ||
| 155 | + desiredPixelFormat: image.PixelMapFormat.BGRA_8888, | ||
| 156 | + // 高性能知识点:经测试,将图片的宽和高设置为40像素时,既可以保证提取颜色的准确性,也可以保证计算颜色的速度。 | ||
| 157 | + desiredSize: { width: PIXEL_MAP_SIZE_WIDTH, height: PIXEL_MAP_SIZE_HEIGHT } | ||
| 158 | + }) | ||
| 159 | + return pixelMap; | ||
| 160 | +} | ||
| 161 | + | ||
| 162 | +/** | ||
| 163 | + * 查找数组中出现次数最多的像素 | ||
| 164 | + * @param allPixels 像素数组 | ||
| 165 | + * @returns 出现次数最多的像素 | ||
| 166 | + */ | ||
| 167 | +export function findMaxPixel(allPixels: number[]): number { | ||
| 168 | + // 遍历数组,将像素放到一个Map中,key是像素值,value是该像素值出现的次数 | ||
| 169 | + const map: Map<number, number> = new Map(); | ||
| 170 | + allPixels.forEach((pixel: number) => { | ||
| 171 | + if (map.has(pixel)) { | ||
| 172 | + map.set(pixel, map.get(pixel)! + 1); | ||
| 173 | + } else { | ||
| 174 | + map.set(pixel, 1); | ||
| 175 | + } | ||
| 176 | + }) | ||
| 177 | + // 查找出现次数最多的像素 | ||
| 178 | + let maxPixel: number = 0; | ||
| 179 | + let maxTimes: number = 0; | ||
| 180 | + map.forEach((value: number, key: number) => { | ||
| 181 | + if (value >= maxTimes) { | ||
| 182 | + maxTimes = value; | ||
| 183 | + maxPixel = key; | ||
| 184 | + } | ||
| 185 | + }) | ||
| 186 | + return maxPixel; | ||
| 187 | +} | ||
| 188 | + | ||
| 189 | +/** | ||
| 190 | + * 修改HSV格式的颜色值,可根据业务需求或者UI设计自行修改S和V的值,此处只举例进行说明 | ||
| 191 | + * @param color HSV格式的颜色 | ||
| 192 | + */ | ||
| 193 | +export function modifySVValue(color: ColorHsv): void { | ||
| 194 | + if (color.hue > 0 && color.hue <= 60) { | ||
| 195 | + color.saturation = 0.12; | ||
| 196 | + color.value = 0.93; | ||
| 197 | + } else if (color.hue > 60 && color.hue <= 190) { | ||
| 198 | + color.saturation = 0.08; | ||
| 199 | + color.value = 0.91; | ||
| 200 | + } else if (color.hue > 190 && color.hue <= 270) { | ||
| 201 | + color.saturation = 0.1; | ||
| 202 | + color.value = 0.93; | ||
| 203 | + } else { | ||
| 204 | + color.saturation = 0.08; | ||
| 205 | + color.value = 0.93; | ||
| 206 | + } | ||
| 207 | +} | ||
| 208 | + | ||
| 209 | +/** | ||
| 210 | + * 遍历所有像素,并放到一个数组中 | ||
| 211 | + * @param pixelMap 图片的PixelMap对象 | ||
| 212 | + * @returns 包含图片所有像素的数组 | ||
| 213 | + */ | ||
| 214 | +export async function traverseAllPixel(pixelMap: image.PixelMap): Promise<number[]> { | ||
| 215 | + // PixelMap对象使用BGRA_8888格式,由4个字节表示一个像素,并且宽和高都设置为40,所以此处ArrayBuffer的length就是40*40*4 | ||
| 216 | + const pixelArrayBuffer: ArrayBuffer = new ArrayBuffer(40 * 40 * 4); | ||
| 217 | + // 将PixelMap对象读入ArrayBuffer中 | ||
| 218 | + await pixelMap.readPixelsToBuffer(pixelArrayBuffer); | ||
| 219 | + const allPixels: number[] = []; | ||
| 220 | + // ArrayBuffer是一个二进制的数组,无法直接读取内容,需要转换为整型数组才可以正常使用,此处使用Uint8Array(8 位无符号整型数组) | ||
| 221 | + const unit8Pixels: Uint8Array = new Uint8Array(pixelArrayBuffer); | ||
| 222 | + // 遍历unit8Pixels,取出每个像素的red、green、blue、alpha颜色值,放到一个ColorRgb对象中,然后将ColorRgb转换为数字,放入数组中 | ||
| 223 | + for (let i = 0; i < unit8Pixels.length; i += 4) { | ||
| 224 | + // 如果是透明色,则不放入数组中,否则可能导致计算出来的出现次数最多的像素是透明色 | ||
| 225 | + if (unit8Pixels[i] === 0 && unit8Pixels[i+1] === 0 && unit8Pixels[i+2] === 0 && unit8Pixels[i+3] === 0) { | ||
| 226 | + continue; | ||
| 227 | + } | ||
| 228 | + // BGRA_8888格式,B表示Blue,G表示Green,R表示Red,A表示透明度,此处根据顺序提取B、R、G、A | ||
| 229 | + const rgb: ColorRgb = { | ||
| 230 | + red: unit8Pixels[i+2], | ||
| 231 | + green: unit8Pixels[i+1], | ||
| 232 | + blue: unit8Pixels[i], | ||
| 233 | + alpha: unit8Pixels[i+3] | ||
| 234 | + } | ||
| 235 | + // 高性能知识点:直接将ColorRgb放入数组或者Map中会影响计算出现次数最多的像素的速度,所以需要使用rgbToNumber方法转换为整数 | ||
| 236 | + allPixels.push(ColorUtils.rgbToNumber(rgb)); | ||
| 237 | + } | ||
| 238 | + return allPixels; | ||
| 239 | +} |
| @@ -48,5 +48,19 @@ export class LikeViewModel { | @@ -48,5 +48,19 @@ export class LikeViewModel { | ||
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | + //点赞数 | ||
| 52 | + getLikeCount(bean: Record<string, string>) { | ||
| 53 | + | ||
| 54 | + return new Promise<object>((success, fail) => { | ||
| 55 | + this.likeModel.getLikeCount(bean).then((data) => { | ||
| 56 | + success(data) | ||
| 57 | + }).catch((error: string) => { | ||
| 58 | + fail(error) | ||
| 59 | + }) | ||
| 60 | + }) | ||
| 61 | + | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + | ||
| 51 | 65 | ||
| 52 | } | 66 | } |
| 1 | import { SpConstants } from 'wdConstant/Index' | 1 | import { SpConstants } from 'wdConstant/Index' |
| 2 | -import { SPHelper } from 'wdKit/Index' | 2 | +import { SPHelper, UserDataLocal } from 'wdKit/Index' |
| 3 | import { HttpUrlUtils } from 'wdNetwork/Index' | 3 | import { HttpUrlUtils } from 'wdNetwork/Index' |
| 4 | import { LogoutModel } from '../model/LogoutModel' | 4 | import { LogoutModel } from '../model/LogoutModel' |
| 5 | 5 | ||
| @@ -20,17 +20,18 @@ export class LogoutViewModel{ | @@ -20,17 +20,18 @@ export class LogoutViewModel{ | ||
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | static clearLoginInfo() { | 22 | static clearLoginInfo() { |
| 23 | - SPHelper.default.save(SpConstants.USER_FIRST_MARK, '') | ||
| 24 | - SPHelper.default.save(SpConstants.USER_ID, '') | ||
| 25 | - SPHelper.default.save(SpConstants.USER_JWT_TOKEN, '') | ||
| 26 | - SPHelper.default.save(SpConstants.USER_LONG_TIME_NO_LOGIN_MARK, '') | ||
| 27 | - SPHelper.default.save(SpConstants.USER_REFRESH_TOKEN, '') | ||
| 28 | - SPHelper.default.save(SpConstants.USER_STATUS, '') | ||
| 29 | - SPHelper.default.save(SpConstants.USER_Type, '') | ||
| 30 | - SPHelper.default.save(SpConstants.USER_NAME, '') | ||
| 31 | - SPHelper.default.save(SpConstants.USER_PHONE, '') | 23 | + SPHelper.default.saveSync(SpConstants.USER_FIRST_MARK, '') |
| 24 | + SPHelper.default.saveSync(SpConstants.USER_ID, '') | ||
| 25 | + SPHelper.default.saveSync(SpConstants.USER_JWT_TOKEN, '') | ||
| 26 | + SPHelper.default.saveSync(SpConstants.USER_LONG_TIME_NO_LOGIN_MARK, '') | ||
| 27 | + SPHelper.default.saveSync(SpConstants.USER_REFRESH_TOKEN, '') | ||
| 28 | + SPHelper.default.saveSync(SpConstants.USER_STATUS, '') | ||
| 29 | + SPHelper.default.saveSync(SpConstants.USER_Type, '') | ||
| 30 | + SPHelper.default.saveSync(SpConstants.USER_NAME, '') | ||
| 31 | + SPHelper.default.saveSync(SpConstants.USER_PHONE, '') | ||
| 32 | HttpUrlUtils.setUserId("") | 32 | HttpUrlUtils.setUserId("") |
| 33 | HttpUrlUtils.setUserType("") | 33 | HttpUrlUtils.setUserType("") |
| 34 | HttpUrlUtils.setUserToken('') | 34 | HttpUrlUtils.setUserToken('') |
| 35 | + UserDataLocal.clearUserData() | ||
| 35 | } | 36 | } |
| 36 | } | 37 | } |
| 1 | -import { PageDTO, CompDTO, PageInfoDTO, ContentDTO } from 'wdBean'; | 1 | +import { CompDTO, ContentDTO, PageDTO, PageInfoDTO } from 'wdBean'; |
| 2 | import { CompStyle, ViewType } from 'wdConstant/Index'; | 2 | import { CompStyle, ViewType } from 'wdConstant/Index'; |
| 3 | import { CollectionUtils, DateTimeUtils, Logger, NetworkUtil } from 'wdKit'; | 3 | import { CollectionUtils, DateTimeUtils, Logger, NetworkUtil } from 'wdKit'; |
| 4 | import { closeRefresh } from '../utils/PullDownRefresh'; | 4 | import { closeRefresh } from '../utils/PullDownRefresh'; |
| 5 | import PageModel from './PageModel'; | 5 | import PageModel from './PageModel'; |
| 6 | import PageViewModel from './PageViewModel'; | 6 | import PageViewModel from './PageViewModel'; |
| 7 | import { promptAction } from '@kit.ArkUI'; | 7 | import { promptAction } from '@kit.ArkUI'; |
| 8 | -import { AdvRuleBean, CompAdvBean } from 'wdBean/src/main/ets/bean/adv/AdvsRuleBean'; | 8 | +import { CompAdvBean } from 'wdBean/src/main/ets/bean/adv/AdvsRuleBean'; |
| 9 | import PageAdModel from './PageAdvModel'; | 9 | import PageAdModel from './PageAdvModel'; |
| 10 | import { ArrayList } from '@kit.ArkTS'; | 10 | import { ArrayList } from '@kit.ArkTS'; |
| 11 | import { WDViewDefaultType } from '../components/view/EmptyComponent'; | 11 | import { WDViewDefaultType } from '../components/view/EmptyComponent'; |
| @@ -104,12 +104,12 @@ export class PageHelper { | @@ -104,12 +104,12 @@ export class PageHelper { | ||
| 104 | if (pageDto && pageDto.compList && pageDto.compList.length > 0) { | 104 | if (pageDto && pageDto.compList && pageDto.compList.length > 0) { |
| 105 | pageModel.viewType = ViewType.LOADED; | 105 | pageModel.viewType = ViewType.LOADED; |
| 106 | let sizeBefore: number = pageModel.compList.size(); | 106 | let sizeBefore: number = pageModel.compList.size(); |
| 107 | - if (pageDto.compList.length === pageModel.pageSize) { | 107 | + if (isLastGroup) { |
| 108 | + // 认为分页只会在最后一个group里 | ||
| 108 | pageModel.currentPage++; | 109 | pageModel.currentPage++; |
| 109 | - pageModel.hasMore = true; | ||
| 110 | - } else { | ||
| 111 | - pageModel.hasMore = false; | ||
| 112 | } | 110 | } |
| 111 | + // pageModel.currentPage++; | ||
| 112 | + pageModel.hasMore = true; | ||
| 113 | 113 | ||
| 114 | //移除音频 和 活动 | 114 | //移除音频 和 活动 |
| 115 | this.collectPageComp(pageModel, pageDto) | 115 | this.collectPageComp(pageModel, pageDto) |
| @@ -221,12 +221,9 @@ export class PageHelper { | @@ -221,12 +221,9 @@ export class PageHelper { | ||
| 221 | if (data == null || data.compList == null || data.compList.length == 0) { | 221 | if (data == null || data.compList == null || data.compList.length == 0) { |
| 222 | pageModel.hasMore = false; | 222 | pageModel.hasMore = false; |
| 223 | } else { | 223 | } else { |
| 224 | - if (data.compList.length == pageModel.pageSize) { | ||
| 225 | - pageModel.currentPage++; | ||
| 226 | - pageModel.hasMore = true; | ||
| 227 | - } else { | ||
| 228 | - pageModel.hasMore = false; | ||
| 229 | - } | 224 | + // 直接认为有分页,一直加载分页。直到没有数据,再停止 |
| 225 | + pageModel.currentPage++; | ||
| 226 | + pageModel.hasMore = true; | ||
| 230 | let sizeBefore: number = pageModel.compList.size(); | 227 | let sizeBefore: number = pageModel.compList.size(); |
| 231 | 228 | ||
| 232 | //移除音频 和 活动 | 229 | //移除音频 和 活动 |
1.05 KB
934 Bytes
| @@ -21,6 +21,7 @@ | @@ -21,6 +21,7 @@ | ||
| 21 | "components/page/LiveMorePage", | 21 | "components/page/LiveMorePage", |
| 22 | "components/page/ReserveMorePage", | 22 | "components/page/ReserveMorePage", |
| 23 | "pages/VideoPlayPage", | 23 | "pages/VideoPlayPage", |
| 24 | - "components/page/ThemeListPage" | 24 | + "components/page/ThemeListPage", |
| 25 | + "pages/ShowUserHeaderPage" | ||
| 25 | ] | 26 | ] |
| 26 | } | 27 | } |
| @@ -7,5 +7,7 @@ export { PlayError } from './src/main/ets/view/PlayError' | @@ -7,5 +7,7 @@ export { PlayError } from './src/main/ets/view/PlayError' | ||
| 7 | 7 | ||
| 8 | export { devicePLSensorManager } from './src/main/ets/utils/devicePortLandSensor' | 8 | export { devicePLSensorManager } from './src/main/ets/utils/devicePortLandSensor' |
| 9 | 9 | ||
| 10 | +export { postInteractAccentionOperateParams } from './src/main/ets/request/ContentDetailRequest' | ||
| 11 | + | ||
| 10 | 12 | ||
| 11 | 13 |
| @@ -245,7 +245,7 @@ export class ContentDetailRequest { | @@ -245,7 +245,7 @@ export class ContentDetailRequest { | ||
| 245 | static getContentInteract(params: contentListParams): Promise<ResponseDTO<InteractDataDTO[]>> { | 245 | static getContentInteract(params: contentListParams): Promise<ResponseDTO<InteractDataDTO[]>> { |
| 246 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH | 246 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH |
| 247 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 247 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 248 | - return WDHttp.post0(url, params, headers) | 248 | + return WDHttp.post(url, params, headers) |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | /** | 251 | /** |
| @@ -255,7 +255,7 @@ export class ContentDetailRequest { | @@ -255,7 +255,7 @@ export class ContentDetailRequest { | ||
| 255 | static postBatchLikeAndCollectStatus(params: batchLikeAndCollectParams): Promise<ResponseDTO<batchLikeAndCollectResult[]>> { | 255 | static postBatchLikeAndCollectStatus(params: batchLikeAndCollectParams): Promise<ResponseDTO<batchLikeAndCollectResult[]>> { |
| 256 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_STATUS | 256 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_STATUS |
| 257 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 257 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 258 | - return WDHttp.post0(url, params, headers) | 258 | + return WDHttp.post(url, params, headers) |
| 259 | } | 259 | } |
| 260 | 260 | ||
| 261 | /** | 261 | /** |
| @@ -265,7 +265,7 @@ export class ContentDetailRequest { | @@ -265,7 +265,7 @@ export class ContentDetailRequest { | ||
| 265 | static postBatchAttentionStatus(params: postBatchAttentionStatusParams): Promise<ResponseDTO<postBatchAttentionStatusResult[]>> { | 265 | static postBatchAttentionStatus(params: postBatchAttentionStatusParams): Promise<ResponseDTO<postBatchAttentionStatusResult[]>> { |
| 266 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.FOLLOW_LIST_STATUS_DATA_PATH | 266 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.FOLLOW_LIST_STATUS_DATA_PATH |
| 267 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 267 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 268 | - return WDHttp.post0(url, params, headers) | 268 | + return WDHttp.post(url, params, headers) |
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | 271 | ||
| @@ -277,7 +277,7 @@ export class ContentDetailRequest { | @@ -277,7 +277,7 @@ export class ContentDetailRequest { | ||
| 277 | static postRecommendVideoList(params: recommentVideoListParams): Promise<ResponseDTO<ContentDetailDTO[]>> { | 277 | static postRecommendVideoList(params: recommentVideoListParams): Promise<ResponseDTO<ContentDetailDTO[]>> { |
| 278 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.RECOMMEND_VIDEOLIST | 278 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.RECOMMEND_VIDEOLIST |
| 279 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 279 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 280 | - return WDHttp.post0(url, params, headers) | 280 | + return WDHttp.post(url, params, headers) |
| 281 | } | 281 | } |
| 282 | 282 | ||
| 283 | /** | 283 | /** |
| @@ -288,7 +288,7 @@ export class ContentDetailRequest { | @@ -288,7 +288,7 @@ export class ContentDetailRequest { | ||
| 288 | static postExecuteLike(params: postExecuteLikeParams): Promise<ResponseDTO> { | 288 | static postExecuteLike(params: postExecuteLikeParams): Promise<ResponseDTO> { |
| 289 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTELIKE | 289 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTELIKE |
| 290 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 290 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 291 | - return WDHttp.post0(url, params, headers) | 291 | + return WDHttp.post(url, params, headers) |
| 292 | } | 292 | } |
| 293 | 293 | ||
| 294 | /** | 294 | /** |
| @@ -299,7 +299,7 @@ export class ContentDetailRequest { | @@ -299,7 +299,7 @@ export class ContentDetailRequest { | ||
| 299 | static postExecuteCollectRecord(params: postExecuteCollectRecordParams): Promise<ResponseDTO> { | 299 | static postExecuteCollectRecord(params: postExecuteCollectRecordParams): Promise<ResponseDTO> { |
| 300 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTECOLLECTRECORD | 300 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTECOLLECTRECORD |
| 301 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 301 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 302 | - return WDHttp.post0(url, params, headers) | 302 | + return WDHttp.post(url, params, headers) |
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | /** | 305 | /** |
| @@ -309,7 +309,7 @@ export class ContentDetailRequest { | @@ -309,7 +309,7 @@ export class ContentDetailRequest { | ||
| 309 | static postPointLevelOperate(params: postPointLevelOperateParams): Promise<ResponseDTO> { | 309 | static postPointLevelOperate(params: postPointLevelOperateParams): Promise<ResponseDTO> { |
| 310 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.USERPOINT_OPERATE | 310 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.USERPOINT_OPERATE |
| 311 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 311 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 312 | - return WDHttp.post0(url, params, headers) | 312 | + return WDHttp.post(url, params, headers) |
| 313 | } | 313 | } |
| 314 | 314 | ||
| 315 | /** | 315 | /** |
| @@ -318,7 +318,7 @@ export class ContentDetailRequest { | @@ -318,7 +318,7 @@ export class ContentDetailRequest { | ||
| 318 | static postCommentPublish(params: postCommentPublishParams): Promise<ResponseDTO> { | 318 | static postCommentPublish(params: postCommentPublishParams): Promise<ResponseDTO> { |
| 319 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMMENT_PUBLISH | 319 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMMENT_PUBLISH |
| 320 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 320 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 321 | - return WDHttp.post0(url, params, headers) | 321 | + return WDHttp.post(url, params, headers) |
| 322 | } | 322 | } |
| 323 | 323 | ||
| 324 | 324 | ||
| @@ -328,7 +328,7 @@ export class ContentDetailRequest { | @@ -328,7 +328,7 @@ export class ContentDetailRequest { | ||
| 328 | static postInteractBrowsOperate(params: postInteractBrowsOperateParams): Promise<ResponseDTO> { | 328 | static postInteractBrowsOperate(params: postInteractBrowsOperateParams): Promise<ResponseDTO> { |
| 329 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_BROWS_OPERATE | 329 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_BROWS_OPERATE |
| 330 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 330 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 331 | - return WDHttp.post0(url, params, headers) | 331 | + return WDHttp.post(url, params, headers) |
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | /** | 334 | /** |
| @@ -337,6 +337,6 @@ export class ContentDetailRequest { | @@ -337,6 +337,6 @@ export class ContentDetailRequest { | ||
| 337 | static postInteractAccentionOperate(params: postInteractAccentionOperateParams): Promise<ResponseDTO> { | 337 | static postInteractAccentionOperate(params: postInteractAccentionOperateParams): Promise<ResponseDTO> { |
| 338 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_ACCENTION_OPERATION | 338 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_ACCENTION_OPERATION |
| 339 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 339 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 340 | - return WDHttp.post0(url, params, headers) | 340 | + return WDHttp.post(url, params, headers) |
| 341 | } | 341 | } |
| 342 | } | 342 | } |
| @@ -67,14 +67,13 @@ export struct DetailPlayLivePage { | @@ -67,14 +67,13 @@ export struct DetailPlayLivePage { | ||
| 67 | 67 | ||
| 68 | onPageShowCus(): void { | 68 | onPageShowCus(): void { |
| 69 | Logger.info(TAG, `wyj-onPageShowCus`) | 69 | Logger.info(TAG, `wyj-onPageShowCus`) |
| 70 | - // WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); | 70 | + // WindowModel.shared.setPreferredOrientation(window.Orientation.LOCKED); |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | onPageHideCus(): void { | 73 | onPageHideCus(): void { |
| 74 | Logger.info(TAG, `wyj-onPageHideCus`) | 74 | Logger.info(TAG, `wyj-onPageHideCus`) |
| 75 | - devicePLSensorManager.devicePLSensorOff(); | ||
| 76 | - // WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); | ||
| 77 | - this.playerController?.pause() | 75 | + this.listener.off('change'); |
| 76 | + // devicePLSensorManager.devicePLSensorOff(); | ||
| 78 | } | 77 | } |
| 79 | 78 | ||
| 80 | onBackPressCus(): boolean | void { | 79 | onBackPressCus(): boolean | void { |
| @@ -86,9 +85,9 @@ export struct DetailPlayLivePage { | @@ -86,9 +85,9 @@ export struct DetailPlayLivePage { | ||
| 86 | WindowModel.shared.setPreferredOrientation(this.displayDirection == DisplayDirection.VERTICAL ? | 85 | WindowModel.shared.setPreferredOrientation(this.displayDirection == DisplayDirection.VERTICAL ? |
| 87 | window.Orientation.PORTRAIT : | 86 | window.Orientation.PORTRAIT : |
| 88 | window.Orientation.LANDSCAPE) | 87 | window.Orientation.LANDSCAPE) |
| 89 | - devicePLSensorManager.devicePLSensorOn(this.displayDirection == DisplayDirection.VERTICAL ? | ||
| 90 | - window.Orientation.PORTRAIT : | ||
| 91 | - window.Orientation.LANDSCAPE); | 88 | + // devicePLSensorManager.devicePLSensorOn(this.displayDirection == DisplayDirection.VERTICAL ? |
| 89 | + // window.Orientation.PORTRAIT : | ||
| 90 | + // window.Orientation.LANDSCAPE); | ||
| 92 | return true | 91 | return true |
| 93 | } | 92 | } |
| 94 | 93 |
| @@ -7,6 +7,7 @@ import { PlayerInfoComponent } from '../widgets/vertical/PlayerInfoComponent'; | @@ -7,6 +7,7 @@ import { PlayerInfoComponent } from '../widgets/vertical/PlayerInfoComponent'; | ||
| 7 | import { WDPlayerController } from 'wdPlayer/Index'; | 7 | import { WDPlayerController } from 'wdPlayer/Index'; |
| 8 | import { DisplayDirection } from 'wdConstant/Index'; | 8 | import { DisplayDirection } from 'wdConstant/Index'; |
| 9 | import { LiveEmptyComponent, WDLiveViewDefaultType } from 'wdComponent/Index'; | 9 | import { LiveEmptyComponent, WDLiveViewDefaultType } from 'wdComponent/Index'; |
| 10 | +import { PlayerEndView } from '../widgets/vertical/PlayerEndView'; | ||
| 10 | 11 | ||
| 11 | const storage = LocalStorage.getShared(); | 12 | const storage = LocalStorage.getShared(); |
| 12 | const TAG = 'DetailPlayVLivePage' | 13 | const TAG = 'DetailPlayVLivePage' |
| @@ -29,6 +30,7 @@ export struct DetailPlayVLivePage { | @@ -29,6 +30,7 @@ export struct DetailPlayVLivePage { | ||
| 29 | @State contentId: string = '' | 30 | @State contentId: string = '' |
| 30 | @State relType: string = '' | 31 | @State relType: string = '' |
| 31 | @State swiperIndex: number = 1 | 32 | @State swiperIndex: number = 1 |
| 33 | + @State imgUrl: string = '' | ||
| 32 | 34 | ||
| 33 | aboutToAppear(): void { | 35 | aboutToAppear(): void { |
| 34 | console.log(TAG, 'aboutToAppear') | 36 | console.log(TAG, 'aboutToAppear') |
| @@ -51,50 +53,52 @@ export struct DetailPlayVLivePage { | @@ -51,50 +53,52 @@ export struct DetailPlayVLivePage { | ||
| 51 | } | 53 | } |
| 52 | 54 | ||
| 53 | build() { | 55 | build() { |
| 54 | - Column() { | 56 | + |
| 57 | + Stack() { | ||
| 58 | + Image(this.imgUrl) | ||
| 59 | + .height('100%') | ||
| 60 | + .width('100%') | ||
| 61 | + .blur(100) | ||
| 62 | + .renderFit(RenderFit.RESIZE_COVER) | ||
| 55 | // 直播结束且无回看 | 63 | // 直播结束且无回看 |
| 56 | if (this.liveState === 'end' && !this.playUrl) { | 64 | if (this.liveState === 'end' && !this.playUrl) { |
| 57 | - LiveEmptyComponent({ | ||
| 58 | - emptyType: WDLiveViewDefaultType.WDViewDefaultType_NoLiveEnd | ||
| 59 | - }) | 65 | + PlayerEndView() |
| 60 | } else { | 66 | } else { |
| 61 | - Stack() { | ||
| 62 | - // 直播暂停,仍然可以评论 | ||
| 63 | - if (this.liveState === 'pause') { | ||
| 64 | - LiveEmptyComponent({ | ||
| 65 | - emptyType: WDLiveViewDefaultType.WDViewDefaultType_NoLiveSuspend | ||
| 66 | - }) | ||
| 67 | - } else { | ||
| 68 | - PlayerComponent({ | ||
| 69 | - playerController: this.playerController | ||
| 70 | - }) | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | - PlayerInfoComponent({ | ||
| 74 | - playerController: this.playerController, | ||
| 75 | - swiperController: this.swiperController, | ||
| 76 | - swiperIndex: $swiperIndex | 67 | + // 直播暂停,仍然可以评论 |
| 68 | + if (this.liveState === 'pause') { | ||
| 69 | + LiveEmptyComponent({ | ||
| 70 | + emptyType: WDLiveViewDefaultType.WDViewDefaultType_NoLiveSuspend | ||
| 71 | + }) | ||
| 72 | + .height('60%') | ||
| 73 | + } else { | ||
| 74 | + PlayerComponent({ | ||
| 75 | + playerController: this.playerController | ||
| 77 | }) | 76 | }) |
| 78 | - | ||
| 79 | - Image($r('app.media.icon_live_more')) | ||
| 80 | - .width(40) | ||
| 81 | - .aspectRatio(1) | ||
| 82 | - .visibility(this.swiperIndex === 0 ? Visibility.Visible : Visibility.Hidden) | ||
| 83 | - .animation({ duration: 500 }) | ||
| 84 | - .position({ x: '100%', y: '100%' }) | ||
| 85 | - .markAnchor({ x: 56, y: 56 }) | ||
| 86 | - .onClick(() => { | ||
| 87 | - this.swiperController.showNext() | ||
| 88 | - }) | ||
| 89 | } | 77 | } |
| 90 | - .height('100%') | ||
| 91 | - .width('100%') | 78 | + |
| 79 | + PlayerInfoComponent({ | ||
| 80 | + playerController: this.playerController, | ||
| 81 | + swiperController: this.swiperController, | ||
| 82 | + swiperIndex: $swiperIndex | ||
| 83 | + }) | ||
| 84 | + | ||
| 85 | + Image($r('app.media.icon_live_more')) | ||
| 86 | + .width(40) | ||
| 87 | + .aspectRatio(1) | ||
| 88 | + .visibility(this.swiperIndex === 0 ? Visibility.Visible : Visibility.Hidden) | ||
| 89 | + .animation({ duration: 500 }) | ||
| 90 | + .position({ x: '100%', y: '100%' }) | ||
| 91 | + .markAnchor({ x: 56, y: 56 }) | ||
| 92 | + .onClick(() => { | ||
| 93 | + this.swiperController.showNext() | ||
| 94 | + }) | ||
| 92 | } | 95 | } |
| 93 | 96 | ||
| 94 | 97 | ||
| 95 | } | 98 | } |
| 96 | .height('100%') | 99 | .height('100%') |
| 97 | .width('100%') | 100 | .width('100%') |
| 101 | + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) | ||
| 98 | } | 102 | } |
| 99 | 103 | ||
| 100 | getLiveDetails() { | 104 | getLiveDetails() { |
| @@ -103,7 +107,11 @@ export struct DetailPlayVLivePage { | @@ -103,7 +107,11 @@ export struct DetailPlayVLivePage { | ||
| 103 | (data) => { | 107 | (data) => { |
| 104 | if (data.length > 0) { | 108 | if (data.length > 0) { |
| 105 | this.liveDetailsBean = data[0] | 109 | this.liveDetailsBean = data[0] |
| 106 | - this.liveState = this.liveDetailsBean.liveInfo?.liveState //直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停 | 110 | + this.liveState = 'end' // this.liveDetailsBean.liveInfo?.liveState //直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停 |
| 111 | + if (this.liveDetailsBean.fullColumnImgUrls && this.liveDetailsBean.fullColumnImgUrls.length > 0) { | ||
| 112 | + this.imgUrl = this.liveDetailsBean.fullColumnImgUrls[0].url | ||
| 113 | + } | ||
| 114 | + | ||
| 107 | if (this.liveDetailsBean.liveInfo.liveState == 'end') { | 115 | if (this.liveDetailsBean.liveInfo.liveState == 'end') { |
| 108 | this.playUrl = this.liveDetailsBean.liveInfo.vlive[0].replayUri | 116 | this.playUrl = this.liveDetailsBean.liveInfo.vlive[0].replayUri |
| 109 | } | 117 | } |
| @@ -83,9 +83,9 @@ export struct TabLiveItemComponent { | @@ -83,9 +83,9 @@ export struct TabLiveItemComponent { | ||
| 83 | //图文 | 83 | //图文 |
| 84 | if (this.item.dataType === 'ZH_TEXT_AND_IMAGE_MSG') { | 84 | if (this.item.dataType === 'ZH_TEXT_AND_IMAGE_MSG') { |
| 85 | List({ space: this.item.pictureUrls.length == 1 ? 0 : 5 }) { | 85 | List({ space: this.item.pictureUrls.length == 1 ? 0 : 5 }) { |
| 86 | - ForEach(this.item.pictureUrls, (item: string, index: number) => { | 86 | + ForEach(this.item.pictureUrls, (itemSub: string, index: number) => { |
| 87 | ListItem() { | 87 | ListItem() { |
| 88 | - Image(item) | 88 | + Image(itemSub) |
| 89 | .width(`${100 / this.item.pictureUrls.length}%`) | 89 | .width(`${100 / this.item.pictureUrls.length}%`) |
| 90 | .height(this.item.pictureUrls.length > 1 ? 70 : 174) | 90 | .height(this.item.pictureUrls.length > 1 ? 70 : 174) |
| 91 | .objectFit(ImageFit.Auto) | 91 | .objectFit(ImageFit.Auto) |
| @@ -100,7 +100,7 @@ export struct TabLiveItemComponent { | @@ -100,7 +100,7 @@ export struct TabLiveItemComponent { | ||
| 100 | picDesc: '' | 100 | picDesc: '' |
| 101 | }) | 101 | }) |
| 102 | } | 102 | } |
| 103 | - this.gotoMultipleListImagePage() | 103 | + this.gotoMultipleListImagePage(index) |
| 104 | }) | 104 | }) |
| 105 | }) | 105 | }) |
| 106 | } | 106 | } |
| @@ -187,13 +187,14 @@ export struct TabLiveItemComponent { | @@ -187,13 +187,14 @@ export struct TabLiveItemComponent { | ||
| 187 | * 大图列表页 | 187 | * 大图列表页 |
| 188 | * @param content | 188 | * @param content |
| 189 | * */ | 189 | * */ |
| 190 | - gotoMultipleListImagePage() { | 190 | + gotoMultipleListImagePage(index: number) { |
| 191 | let taskAction: Action = { | 191 | let taskAction: Action = { |
| 192 | type: 'JUMP_DETAIL_PAGE', | 192 | type: 'JUMP_DETAIL_PAGE', |
| 193 | params: { | 193 | params: { |
| 194 | detailPageType: 18, | 194 | detailPageType: 18, |
| 195 | extra: { | 195 | extra: { |
| 196 | - photoList: this.photoList | 196 | + photoList: this.photoList, |
| 197 | + swiperIndex: index, | ||
| 197 | } as ExtraDTO | 198 | } as ExtraDTO |
| 198 | } as Params, | 199 | } as Params, |
| 199 | }; | 200 | }; |
| 1 | import { window } from '@kit.ArkUI' | 1 | import { window } from '@kit.ArkUI' |
| 2 | import { NumberFormatterUtils, WindowModel } from 'wdKit/Index' | 2 | import { NumberFormatterUtils, WindowModel } from 'wdKit/Index' |
| 3 | -import { devicePLSensorManager } from 'wdDetailPlayApi/Index' | ||
| 4 | import { DateFormatUtil, WDPlayerController } from 'wdPlayer/Index' | 3 | import { DateFormatUtil, WDPlayerController } from 'wdPlayer/Index' |
| 5 | import { LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Index' | 4 | import { LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Index' |
| 6 | import { DisplayDirection } from 'wdConstant/Index' | 5 | import { DisplayDirection } from 'wdConstant/Index' |
| @@ -69,9 +68,9 @@ export struct PlayUIComponent { | @@ -69,9 +68,9 @@ export struct PlayUIComponent { | ||
| 69 | WindowModel.shared.setPreferredOrientation(this.displayDirection == DisplayDirection.VERTICAL ? | 68 | WindowModel.shared.setPreferredOrientation(this.displayDirection == DisplayDirection.VERTICAL ? |
| 70 | window.Orientation.PORTRAIT : | 69 | window.Orientation.PORTRAIT : |
| 71 | window.Orientation.LANDSCAPE) | 70 | window.Orientation.LANDSCAPE) |
| 72 | - devicePLSensorManager.devicePLSensorOn(this.displayDirection == DisplayDirection.VERTICAL ? | ||
| 73 | - window.Orientation.PORTRAIT : | ||
| 74 | - window.Orientation.LANDSCAPE); | 71 | + // devicePLSensorManager.devicePLSensorOn(this.displayDirection == DisplayDirection.VERTICAL ? |
| 72 | + // window.Orientation.PORTRAIT : | ||
| 73 | + // window.Orientation.LANDSCAPE); | ||
| 75 | }) | 74 | }) |
| 76 | if (this.liveDetailsBean.liveInfo?.liveState != 'wait') { | 75 | if (this.liveDetailsBean.liveInfo?.liveState != 'wait') { |
| 77 | Text(this.liveDetailsBean.newsTitle) | 76 | Text(this.liveDetailsBean.newsTitle) |
| @@ -235,9 +234,9 @@ export struct PlayUIComponent { | @@ -235,9 +234,9 @@ export struct PlayUIComponent { | ||
| 235 | WindowModel.shared.setPreferredOrientation(this.displayDirection == DisplayDirection.VERTICAL ? | 234 | WindowModel.shared.setPreferredOrientation(this.displayDirection == DisplayDirection.VERTICAL ? |
| 236 | window.Orientation.PORTRAIT : | 235 | window.Orientation.PORTRAIT : |
| 237 | window.Orientation.LANDSCAPE) | 236 | window.Orientation.LANDSCAPE) |
| 238 | - devicePLSensorManager.devicePLSensorOn(this.displayDirection == DisplayDirection.VERTICAL ? | ||
| 239 | - window.Orientation.PORTRAIT : | ||
| 240 | - window.Orientation.LANDSCAPE); | 237 | + // devicePLSensorManager.devicePLSensorOn(this.displayDirection == DisplayDirection.VERTICAL ? |
| 238 | + // window.Orientation.PORTRAIT : | ||
| 239 | + // window.Orientation.LANDSCAPE); | ||
| 241 | }) | 240 | }) |
| 242 | } | 241 | } |
| 243 | } | 242 | } |
| @@ -11,7 +11,7 @@ export struct ChartItemCompereComponent { | @@ -11,7 +11,7 @@ export struct ChartItemCompereComponent { | ||
| 11 | ListItem() { | 11 | ListItem() { |
| 12 | Column() { | 12 | Column() { |
| 13 | Row() { | 13 | Row() { |
| 14 | - Image($r('app.media.icon_live_status_running')) | 14 | + Image($r('app.media.default_head')) |
| 15 | .borderRadius(10) | 15 | .borderRadius(10) |
| 16 | .width(20) | 16 | .width(20) |
| 17 | .height(20) | 17 | .height(20) |
| @@ -24,13 +24,15 @@ export struct ChartItemCompereComponent { | @@ -24,13 +24,15 @@ export struct ChartItemCompereComponent { | ||
| 24 | 24 | ||
| 25 | Text(' 主持人 ') | 25 | Text(' 主持人 ') |
| 26 | .fontSize(11) | 26 | .fontSize(11) |
| 27 | - .backgroundColor('808562') | 27 | + .backgroundColor('#FFFFC63F') |
| 28 | .fontColor('#FFFFFFFF') | 28 | .fontColor('#FFFFFFFF') |
| 29 | .padding({ top: 2, bottom: 2, left: 4, right: 4 }) | 29 | .padding({ top: 2, bottom: 2, left: 4, right: 4 }) |
| 30 | .borderRadius(4) | 30 | .borderRadius(4) |
| 31 | - }.margin({ bottom: 8 }) | 31 | + } |
| 32 | + .margin({ bottom: 8 }) | ||
| 33 | + .justifyContent(FlexAlign.Start) | ||
| 32 | 34 | ||
| 33 | - Text(this.liveDetailsBean.newIntroduction).lineHeight(22) | 35 | + Text(this.liveDetailsBean.newIntroduction).lineHeight(22).fontColor('#FFFFFFFF').fontSize(14) |
| 34 | } | 36 | } |
| 35 | .backgroundColor('#4D000000') | 37 | .backgroundColor('#4D000000') |
| 36 | .borderRadius(3) | 38 | .borderRadius(3) |
| @@ -41,6 +43,7 @@ export struct ChartItemCompereComponent { | @@ -41,6 +43,7 @@ export struct ChartItemCompereComponent { | ||
| 41 | right: 8 | 43 | right: 8 |
| 42 | }) | 44 | }) |
| 43 | .margin({ left: 16, bottom: 4 }) | 45 | .margin({ left: 16, bottom: 4 }) |
| 46 | + .alignItems(HorizontalAlign.Start) | ||
| 44 | } | 47 | } |
| 45 | 48 | ||
| 46 | } | 49 | } |
| @@ -66,12 +66,7 @@ export struct PlayerComponent { | @@ -66,12 +66,7 @@ export struct PlayerComponent { | ||
| 66 | build() { | 66 | build() { |
| 67 | Column() { | 67 | Column() { |
| 68 | Stack() { | 68 | Stack() { |
| 69 | - Image(this.imgUrl) | ||
| 70 | - .height('100%') | ||
| 71 | - .width('100%') | ||
| 72 | - .blur(100) | ||
| 73 | - .renderFit(RenderFit.RESIZE_COVER) | ||
| 74 | - | 69 | + |
| 75 | // TODO:判断横竖屏,liveStreamType=1竖屏铺满屏幕,裁剪不拉伸,liveStreamType=0横屏正常展示 | 70 | // TODO:判断横竖屏,liveStreamType=1竖屏铺满屏幕,裁剪不拉伸,liveStreamType=0横屏正常展示 |
| 76 | if (this.liveStreamType == null) { | 71 | if (this.liveStreamType == null) { |
| 77 | WDPlayerRenderVLiveView({ | 72 | WDPlayerRenderVLiveView({ |
| 1 | +import { LiveDetailsBean, LiveRoomDataBean, postBatchAttentionStatusParams, } from 'wdBean/Index' | ||
| 2 | +import { MultiPictureDetailViewModel } from 'wdComponent/src/main/ets/viewmodel/MultiPictureDetailViewModel' | ||
| 3 | +import { SpConstants } from 'wdConstant/Index' | ||
| 4 | +import { ContentDetailRequest, postInteractAccentionOperateParams } from 'wdDetailPlayApi/Index' | ||
| 5 | +import { NumberFormatterUtils, DateTimeUtils, SPHelper } from 'wdKit/Index' | ||
| 6 | +import { WDRouterPage, WDRouterRule } from 'wdRouter/Index' | ||
| 7 | + | ||
| 8 | +const TAG = 'PlayerEndView' | ||
| 9 | + | ||
| 10 | +@Preview | ||
| 11 | +@Component | ||
| 12 | +export struct PlayerEndView { | ||
| 13 | + @Consume liveDetailsBean: LiveDetailsBean | ||
| 14 | + @Consume liveRoomDataBean: LiveRoomDataBean | ||
| 15 | + @State duration: string = '' | ||
| 16 | + @State followStatus: String = '0'; | ||
| 17 | + | ||
| 18 | + aboutToAppear(): void { | ||
| 19 | + const sn = DateTimeUtils.parseDate(this.liveDetailsBean.liveInfo.startTime, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN) | ||
| 20 | + const en = DateTimeUtils.parseDate(this.liveDetailsBean.liveInfo.endTime, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN) | ||
| 21 | + const sd = DateTimeUtils.getDuration(sn, en) | ||
| 22 | + this.duration = DateTimeUtils.secondToTime(sd / 1000) | ||
| 23 | + this.getBatchAttentionStatus() | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 查询当前登录用户是否关注作品号主 | ||
| 28 | + * */ | ||
| 29 | + async getBatchAttentionStatus() { | ||
| 30 | + try { | ||
| 31 | + const params: postBatchAttentionStatusParams = { | ||
| 32 | + creatorIds: [{ creatorId: this.liveDetailsBean?.rmhInfo?.rmhId ?? '' }] | ||
| 33 | + } | ||
| 34 | + let data = await MultiPictureDetailViewModel.getBatchAttentionStatus(params) | ||
| 35 | + this.followStatus = data[0]?.status; | ||
| 36 | + console.log(TAG, `followStatus:${JSON.stringify(this.followStatus)}`) | ||
| 37 | + } catch (exception) { | ||
| 38 | + | ||
| 39 | + } | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * 关注号主 | ||
| 44 | + */ | ||
| 45 | + async handleAccention() { | ||
| 46 | + // 未登录,跳转登录 | ||
| 47 | + const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') | ||
| 48 | + if (!user_id) { | ||
| 49 | + WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 50 | + return | ||
| 51 | + } | ||
| 52 | + // TODO:直播间没有携带人民号信息 | ||
| 53 | + const params2: postInteractAccentionOperateParams = { | ||
| 54 | + attentionUserType: this.liveDetailsBean?.rmhInfo?.userType || '', //被关注用户类型(1 普通用户 2 视频号 3 矩阵号) | ||
| 55 | + attentionUserId: this.liveDetailsBean?.rmhInfo?.userId || '', // 被关注用户号主id | ||
| 56 | + attentionCreatorId: this.liveDetailsBean?.rmhInfo?.rmhId || '', // 被关注用户号主id | ||
| 57 | + status: this.followStatus == '0' ? 1 : 0, | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + | ||
| 61 | + ContentDetailRequest.postInteractAccentionOperate(params2).then(res => { | ||
| 62 | + console.log('关注号主==', JSON.stringify(res.data)) | ||
| 63 | + if (this.followStatus == '1') { | ||
| 64 | + this.followStatus = '0' | ||
| 65 | + } else { | ||
| 66 | + this.followStatus = '1' | ||
| 67 | + } | ||
| 68 | + }).catch(() => { | ||
| 69 | + AlertDialog.show({ message: '关注失败' }) | ||
| 70 | + }) | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + build() { | ||
| 74 | + Column() { | ||
| 75 | + Text('直播已结束').fontWeight(500) | ||
| 76 | + .fontSize(20) | ||
| 77 | + .fontColor(Color.White) | ||
| 78 | + .padding({ bottom: 40, top: 120 }) | ||
| 79 | + | ||
| 80 | + Stack() { | ||
| 81 | + Column() { | ||
| 82 | + Text(this.liveDetailsBean?.rmhInfo?.rmhName) | ||
| 83 | + .fontWeight(400) | ||
| 84 | + .fontSize(18) | ||
| 85 | + .fontColor(Color.White) | ||
| 86 | + .padding({ top: 52 }) | ||
| 87 | + Text(this.liveDetailsBean?.rmhInfo?.rmhDesc || '') | ||
| 88 | + .fontWeight(400) | ||
| 89 | + .fontSize(13) | ||
| 90 | + .fontColor('#B2FFFFFF') | ||
| 91 | + .padding({ top: 8 }) | ||
| 92 | + | ||
| 93 | + Row() { | ||
| 94 | + Column() { | ||
| 95 | + Text(this.duration).fontWeight(600).fontSize(24).fontColor(Color.White) | ||
| 96 | + Text('时长').fontWeight(400).fontSize(13).fontColor(Color.White) | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + Text('').width(1).height(32).margin({ left: 36, right: 36 }).backgroundColor('#33FFFFFF') | ||
| 100 | + Column() { | ||
| 101 | + Text(NumberFormatterUtils.formatNumberWithWan(this.liveRoomDataBean?.pv || '')) | ||
| 102 | + .fontWeight(600) | ||
| 103 | + .fontSize(24) | ||
| 104 | + .fontColor(Color.White) | ||
| 105 | + Text('观看人数').fontWeight(400).fontSize(13).fontColor(Color.White) | ||
| 106 | + } | ||
| 107 | + } | ||
| 108 | + .padding({ top: 16 }) | ||
| 109 | + | ||
| 110 | + Row() { | ||
| 111 | + Text(this.followStatus == '0' ? '关注' : '已关注') | ||
| 112 | + .fontWeight(400) | ||
| 113 | + .fontSize(16) | ||
| 114 | + .fontColor(Color.White) | ||
| 115 | + .padding({ top: 8, bottom: 8, left: 122, right: 122 }) | ||
| 116 | + .backgroundColor(this.followStatus == '0' ? '#FFED2800' : Color.Grey) | ||
| 117 | + .borderRadius(4) | ||
| 118 | + .onClick(() => { | ||
| 119 | + this.handleAccention() | ||
| 120 | + }) | ||
| 121 | + } | ||
| 122 | + .padding({ top: 24 }) | ||
| 123 | + | ||
| 124 | + } | ||
| 125 | + .width(307) | ||
| 126 | + .height(254) | ||
| 127 | + .backgroundColor('#999999') | ||
| 128 | + .borderRadius(4) | ||
| 129 | + | ||
| 130 | + Image(this.liveDetailsBean?.fullColumnImgUrls[0]?.url) | ||
| 131 | + .width(80) | ||
| 132 | + .height(80) | ||
| 133 | + .borderRadius(40) | ||
| 134 | + .borderWidth(1) | ||
| 135 | + .borderColor(Color.White) | ||
| 136 | + .borderStyle(BorderStyle.Solid) | ||
| 137 | + .position({ x: '50%', y: 0 }) | ||
| 138 | + .markAnchor({ x: '50%', y: '50%' }) | ||
| 139 | + } | ||
| 140 | + .width(307) | ||
| 141 | + .padding({ top: 40 }) | ||
| 142 | + } | ||
| 143 | + .height('100%') | ||
| 144 | + | ||
| 145 | + } | ||
| 146 | +} |
| @@ -44,29 +44,30 @@ export struct PlayerTitleComponent { | @@ -44,29 +44,30 @@ export struct PlayerTitleComponent { | ||
| 44 | 44 | ||
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | + if (this.liveRoomDataBean.liveId) { | ||
| 48 | + Row() { | ||
| 49 | + if (this.liveState == 'running') { | ||
| 50 | + Image($r('app.media.icon_live_status_running')) | ||
| 51 | + .width(22) | ||
| 52 | + .height(18) | ||
| 53 | + .margin({ right: 1 }) | ||
| 54 | + } | ||
| 47 | 55 | ||
| 48 | - Row() { | ||
| 49 | - if (this.liveState == 'running') { | ||
| 50 | - Image($r('app.media.icon_live_status_running')) | ||
| 51 | - .width(22) | ||
| 52 | - .height(18) | ||
| 53 | - .margin({ right: 1 }) | 56 | + Text(this.liveState == 'running' ? '直播中' : '回看') |
| 57 | + .fontSize(11) | ||
| 58 | + .fontWeight(400) | ||
| 59 | + .fontColor(Color.White) | ||
| 60 | + Image($r('app.media.icon_live_player_status_end')) | ||
| 61 | + .width(12) | ||
| 62 | + .height(12) | ||
| 63 | + Text(`${NumberFormatterUtils.formatNumberWithWan(this.liveRoomDataBean.pv)}人参与`) | ||
| 64 | + .fontSize('11fp') | ||
| 65 | + .fontWeight(400) | ||
| 66 | + .fontColor(Color.White) | ||
| 54 | } | 67 | } |
| 55 | - | ||
| 56 | - Text(this.liveState == 'running' ? '直播中' : '回看') | ||
| 57 | - .fontSize(11) | ||
| 58 | - .fontWeight(400) | ||
| 59 | - .fontColor(Color.White) | ||
| 60 | - Image($r('app.media.icon_live_player_status_end')) | ||
| 61 | - .width(12) | ||
| 62 | - .height(12) | ||
| 63 | - Text(`${NumberFormatterUtils.formatNumberWithWan(this.liveRoomDataBean.pv)}人参与`) | ||
| 64 | - .fontSize('11fp') | ||
| 65 | - .fontWeight(400) | ||
| 66 | - .fontColor(Color.White) | 68 | + .backgroundColor('#4D000000') |
| 69 | + .borderRadius(2) | ||
| 70 | + .padding(this.liveState == 'running' ? { left: 0, right: 4, top: 0, bottom: 0 } : 4) | ||
| 67 | } | 71 | } |
| 68 | - .backgroundColor('#4D000000') | ||
| 69 | - .borderRadius(2) | ||
| 70 | - .padding(this.liveState == 'running' ? { left: 0, right: 4, top: 0, bottom: 0 } : 4) | ||
| 71 | } | 72 | } |
| 72 | } | 73 | } |
| @@ -133,7 +133,7 @@ export struct DetailPlayShortVideoPage { | @@ -133,7 +133,7 @@ export struct DetailPlayShortVideoPage { | ||
| 133 | aboutToAppear() { | 133 | aboutToAppear() { |
| 134 | this.videoLandScape = this.contentDetailData?.videoInfo[0]?.videoLandScape | 134 | this.videoLandScape = this.contentDetailData?.videoInfo[0]?.videoLandScape |
| 135 | this.playerController.onCanplay = () => { | 135 | this.playerController.onCanplay = () => { |
| 136 | - if (this.index == 0 || this.currentIndex === this.index) { | 136 | + if ((this.index == 0 || this.currentIndex === this.index) && this.switchVideoStatus) { |
| 137 | this.playerController.play() | 137 | this.playerController.play() |
| 138 | } | 138 | } |
| 139 | } | 139 | } |
| @@ -38,7 +38,7 @@ export struct VideoChannelDetail { | @@ -38,7 +38,7 @@ export struct VideoChannelDetail { | ||
| 38 | // private recommend?: string = '' // 0.非推荐,1.推荐; | 38 | // private recommend?: string = '' // 0.非推荐,1.推荐; |
| 39 | @Link @Watch('navIndexChange') bottomNavIndex: number | 39 | @Link @Watch('navIndexChange') bottomNavIndex: number |
| 40 | @Link @Watch('navIndexChange') topNavIndex: number | 40 | @Link @Watch('navIndexChange') topNavIndex: number |
| 41 | - @Link barBackgroundColor: Color | 41 | + @Consume barBackgroundColor: Color |
| 42 | private swiperController: SwiperController = new SwiperController() | 42 | private swiperController: SwiperController = new SwiperController() |
| 43 | @Provide showComment: boolean = false | 43 | @Provide showComment: boolean = false |
| 44 | @Provide windowWidth: number = AppStorage.get<number>('windowWidth') || 0 | 44 | @Provide windowWidth: number = AppStorage.get<number>('windowWidth') || 0 |
| @@ -72,11 +72,11 @@ export struct VideoChannelDetail { | @@ -72,11 +72,11 @@ export struct VideoChannelDetail { | ||
| 72 | navIndexChange() { | 72 | navIndexChange() { |
| 73 | console.log('navIndexChange', this.bottomNavIndex, this.topNavIndex) | 73 | console.log('navIndexChange', this.bottomNavIndex, this.topNavIndex) |
| 74 | if (this.bottomNavIndex === 2 && this.topNavIndex === 0) { | 74 | if (this.bottomNavIndex === 2 && this.topNavIndex === 0) { |
| 75 | - this.barBackgroundColor = Color.Black | 75 | + // this.barBackgroundColor = Color.Black |
| 76 | this.switchVideoStatus = true | 76 | this.switchVideoStatus = true |
| 77 | this.openFullScreen() | 77 | this.openFullScreen() |
| 78 | } else { | 78 | } else { |
| 79 | - this.barBackgroundColor = Color.Transparent | 79 | + // this.barBackgroundColor = Color.Transparent |
| 80 | this.switchVideoStatus = false | 80 | this.switchVideoStatus = false |
| 81 | this.closeFullScreen() | 81 | this.closeFullScreen() |
| 82 | } | 82 | } |
| @@ -12,9 +12,14 @@ import { WDPlayerController } from 'wdPlayer/Index'; | @@ -12,9 +12,14 @@ import { WDPlayerController } from 'wdPlayer/Index'; | ||
| 12 | import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | 12 | import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; |
| 13 | import { SpConstants } from 'wdConstant/Index' | 13 | import { SpConstants } from 'wdConstant/Index' |
| 14 | 14 | ||
| 15 | +interface ILikeStyleResp { | ||
| 16 | + url: Resource; | ||
| 17 | + name: string; | ||
| 18 | +} | ||
| 15 | 19 | ||
| 16 | const TAG = 'PlayerRightView'; | 20 | const TAG = 'PlayerRightView'; |
| 17 | 21 | ||
| 22 | + | ||
| 18 | //视频点播页右侧操作栏:点赞/收藏/评论/分享 竖着排列 | 23 | //视频点播页右侧操作栏:点赞/收藏/评论/分享 竖着排列 |
| 19 | @Component | 24 | @Component |
| 20 | export struct PlayerRightView { | 25 | export struct PlayerRightView { |
| @@ -210,15 +215,26 @@ export struct PlayerRightView { | @@ -210,15 +215,26 @@ export struct PlayerRightView { | ||
| 210 | /** | 215 | /** |
| 211 | * 将点赞样式转换为icon | 216 | * 将点赞样式转换为icon |
| 212 | */ | 217 | */ |
| 213 | - transLikeStyle2Icon(): Resource { | 218 | + transLikeStyle(): ILikeStyleResp { |
| 214 | if (this.likesStyle === 1) { | 219 | if (this.likesStyle === 1) { |
| 215 | - return this.newsStatusOfUser.likeStatus === '1' ? $r(`app.media.ic_like_check`) : $r(`app.media.ic_like_uncheck`) | 220 | + return { |
| 221 | + url: this.newsStatusOfUser.likeStatus === '1' ? $r(`app.media.ic_like_check`) : $r(`app.media.ic_like_uncheck`), | ||
| 222 | + name: '点赞' | ||
| 223 | + } | ||
| 216 | } else if (this.likesStyle === 2) { | 224 | } else if (this.likesStyle === 2) { |
| 217 | - return this.newsStatusOfUser.likeStatus === '1' ? $r(`app.media.ic_thub_check`) : $r(`app.media.ic_thub_uncheck`) | 225 | + return { |
| 226 | + url: this.newsStatusOfUser.likeStatus === '1' ? $r(`app.media.ic_thub_check`) : $r(`app.media.ic_thub_uncheck`), | ||
| 227 | + name: '祈祷' | ||
| 228 | + } | ||
| 218 | } else if (this.likesStyle === 3) { | 229 | } else if (this.likesStyle === 3) { |
| 219 | - return this.newsStatusOfUser.likeStatus === '1' ? $r(`app.media.ic_candle_check`) : $r(`app.media.ic_candle_uncheck`) | 230 | + return { |
| 231 | + url: this.newsStatusOfUser.likeStatus === '1' ? $r(`app.media.ic_candle_check`) : $r(`app.media.ic_candle_uncheck`), | ||
| 232 | + name: '默哀' | ||
| 233 | + } | ||
| 234 | + } | ||
| 235 | + return { | ||
| 236 | + url: $r(`app.media.icon_like_ckeck`), name: '点赞' | ||
| 220 | } | 237 | } |
| 221 | - return $r(`app.media.icon_like_ckeck`) | ||
| 222 | } | 238 | } |
| 223 | 239 | ||
| 224 | transNum2String(name: 'likeNum' | 'collectNum' | 'commentNum') { | 240 | transNum2String(name: 'likeNum' | 'collectNum' | 'commentNum') { |
| @@ -238,14 +254,14 @@ export struct PlayerRightView { | @@ -238,14 +254,14 @@ export struct PlayerRightView { | ||
| 238 | @Builder | 254 | @Builder |
| 239 | likeBuilderView() { | 255 | likeBuilderView() { |
| 240 | Column() { | 256 | Column() { |
| 241 | - Image(this.transLikeStyle2Icon()) | 257 | + Image(this.transLikeStyle().url) |
| 242 | .width(32) | 258 | .width(32) |
| 243 | .aspectRatio(1) | 259 | .aspectRatio(1) |
| 244 | .onClick(() => { | 260 | .onClick(() => { |
| 245 | // TODO:点赞动画 | 261 | // TODO:点赞动画 |
| 246 | this.toggleLikeStatus() | 262 | this.toggleLikeStatus() |
| 247 | }) | 263 | }) |
| 248 | - Text(this.transNum2String('likeNum') || '赞') | 264 | + Text(this.transNum2String('likeNum') || this.transLikeStyle().name) |
| 249 | .width('100%') | 265 | .width('100%') |
| 250 | .fontWeight(500) | 266 | .fontWeight(500) |
| 251 | .textAlign(TextAlign.Center) | 267 | .textAlign(TextAlign.Center) |
| @@ -253,6 +269,7 @@ export struct PlayerRightView { | @@ -253,6 +269,7 @@ export struct PlayerRightView { | ||
| 253 | .fontColor('#FFFFFF') | 269 | .fontColor('#FFFFFF') |
| 254 | .maxLines(1) | 270 | .maxLines(1) |
| 255 | .textOverflow({ overflow: TextOverflow.Ellipsis }) | 271 | .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 272 | + .margin({ top: 2 }) | ||
| 256 | } | 273 | } |
| 257 | .margin({ bottom: 20 }) | 274 | .margin({ bottom: 20 }) |
| 258 | .visibility(this.likesStyle !== 4 ? Visibility.Visible : Visibility.None) | 275 | .visibility(this.likesStyle !== 4 ? Visibility.Visible : Visibility.None) |
| @@ -278,6 +295,7 @@ export struct PlayerRightView { | @@ -278,6 +295,7 @@ export struct PlayerRightView { | ||
| 278 | .fontColor('#FFFFFF') | 295 | .fontColor('#FFFFFF') |
| 279 | .maxLines(1) | 296 | .maxLines(1) |
| 280 | .textOverflow({ overflow: TextOverflow.Ellipsis }) | 297 | .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 298 | + .margin({ top: 2 }) | ||
| 281 | } | 299 | } |
| 282 | .margin({ bottom: 20 }) | 300 | .margin({ bottom: 20 }) |
| 283 | } | 301 | } |
| @@ -302,6 +320,7 @@ export struct PlayerRightView { | @@ -302,6 +320,7 @@ export struct PlayerRightView { | ||
| 302 | .fontColor('#FFFFFF') | 320 | .fontColor('#FFFFFF') |
| 303 | .maxLines(1) | 321 | .maxLines(1) |
| 304 | .textOverflow({ overflow: TextOverflow.Ellipsis }) | 322 | .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 323 | + .margin({ top: 2 }) | ||
| 305 | } | 324 | } |
| 306 | .margin({ bottom: 20 }) | 325 | .margin({ bottom: 20 }) |
| 307 | } | 326 | } |
| @@ -326,6 +345,7 @@ export struct PlayerRightView { | @@ -326,6 +345,7 @@ export struct PlayerRightView { | ||
| 326 | .fontColor('#FFFFFF') | 345 | .fontColor('#FFFFFF') |
| 327 | .maxLines(1) | 346 | .maxLines(1) |
| 328 | .textOverflow({ overflow: TextOverflow.Ellipsis }) | 347 | .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 348 | + .margin({ top: 2 }) | ||
| 329 | } | 349 | } |
| 330 | .margin({ bottom: 20 }) | 350 | .margin({ bottom: 20 }) |
| 331 | } | 351 | } |
| @@ -47,14 +47,14 @@ export class LoginViewModel { | @@ -47,14 +47,14 @@ export class LoginViewModel { | ||
| 47 | 47 | ||
| 48 | return new Promise<LoginBean>((success, fail) => { | 48 | return new Promise<LoginBean>((success, fail) => { |
| 49 | this.loginModel.appLogin(phone, loginType, verificationCode).then((data: LoginBean) => { | 49 | this.loginModel.appLogin(phone, loginType, verificationCode).then((data: LoginBean) => { |
| 50 | - SPHelper.default.save(SpConstants.USER_FIRST_MARK, data.firstMark) | ||
| 51 | - SPHelper.default.save(SpConstants.USER_ID, data.id) | ||
| 52 | - SPHelper.default.save(SpConstants.USER_JWT_TOKEN, data.jwtToken) | ||
| 53 | - SPHelper.default.save(SpConstants.USER_LONG_TIME_NO_LOGIN_MARK, data.longTimeNoLoginMark) | ||
| 54 | - SPHelper.default.save(SpConstants.USER_REFRESH_TOKEN, data.refreshToken) | ||
| 55 | - SPHelper.default.save(SpConstants.USER_STATUS, data.status) | ||
| 56 | - SPHelper.default.save(SpConstants.USER_Type, data.userType) | ||
| 57 | - SPHelper.default.save(SpConstants.USER_NAME, data.userName) | 50 | + SPHelper.default.saveSync(SpConstants.USER_FIRST_MARK, data.firstMark) |
| 51 | + SPHelper.default.saveSync(SpConstants.USER_ID, data.id) | ||
| 52 | + SPHelper.default.saveSync(SpConstants.USER_JWT_TOKEN, data.jwtToken) | ||
| 53 | + SPHelper.default.saveSync(SpConstants.USER_LONG_TIME_NO_LOGIN_MARK, data.longTimeNoLoginMark) | ||
| 54 | + SPHelper.default.saveSync(SpConstants.USER_REFRESH_TOKEN, data.refreshToken) | ||
| 55 | + SPHelper.default.saveSync(SpConstants.USER_STATUS, data.status) | ||
| 56 | + SPHelper.default.saveSync(SpConstants.USER_Type, data.userType) | ||
| 57 | + SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName) | ||
| 58 | HttpUrlUtils.setUserId(data.id+"") | 58 | HttpUrlUtils.setUserId(data.id+"") |
| 59 | HttpUrlUtils.setUserType(data.userType+"") | 59 | HttpUrlUtils.setUserType(data.userType+"") |
| 60 | HttpUrlUtils.setUserToken(data.jwtToken) | 60 | HttpUrlUtils.setUserToken(data.jwtToken) |
| @@ -71,14 +71,14 @@ export class LoginViewModel { | @@ -71,14 +71,14 @@ export class LoginViewModel { | ||
| 71 | let passwordNew = await this.doMd(password) | 71 | let passwordNew = await this.doMd(password) |
| 72 | Logger.debug(TAG, "PASSWORD:" + passwordNew) | 72 | Logger.debug(TAG, "PASSWORD:" + passwordNew) |
| 73 | this.loginModel.appLoginByPassword(phone, loginType, passwordNew, oldPassword).then((data: LoginBean) => { | 73 | this.loginModel.appLoginByPassword(phone, loginType, passwordNew, oldPassword).then((data: LoginBean) => { |
| 74 | - SPHelper.default.save(SpConstants.USER_FIRST_MARK, data.firstMark) | ||
| 75 | - SPHelper.default.save(SpConstants.USER_ID, data.id) | ||
| 76 | - SPHelper.default.save(SpConstants.USER_JWT_TOKEN, data.jwtToken) | ||
| 77 | - SPHelper.default.save(SpConstants.USER_LONG_TIME_NO_LOGIN_MARK, data.longTimeNoLoginMark) | ||
| 78 | - SPHelper.default.save(SpConstants.USER_REFRESH_TOKEN, data.refreshToken) | ||
| 79 | - SPHelper.default.save(SpConstants.USER_STATUS, data.status) | ||
| 80 | - SPHelper.default.save(SpConstants.USER_Type, data.userType) | ||
| 81 | - SPHelper.default.save(SpConstants.USER_NAME, data.userName) | 74 | + SPHelper.default.saveSync(SpConstants.USER_FIRST_MARK, data.firstMark) |
| 75 | + SPHelper.default.saveSync(SpConstants.USER_ID, data.id) | ||
| 76 | + SPHelper.default.saveSync(SpConstants.USER_JWT_TOKEN, data.jwtToken) | ||
| 77 | + SPHelper.default.saveSync(SpConstants.USER_LONG_TIME_NO_LOGIN_MARK, data.longTimeNoLoginMark) | ||
| 78 | + SPHelper.default.saveSync(SpConstants.USER_REFRESH_TOKEN, data.refreshToken) | ||
| 79 | + SPHelper.default.saveSync(SpConstants.USER_STATUS, data.status) | ||
| 80 | + SPHelper.default.saveSync(SpConstants.USER_Type, data.userType) | ||
| 81 | + SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName) | ||
| 82 | HttpUrlUtils.setUserId(data.id+"") | 82 | HttpUrlUtils.setUserId(data.id+"") |
| 83 | HttpUrlUtils.setUserType(data.userType+"") | 83 | HttpUrlUtils.setUserType(data.userType+"") |
| 84 | HttpUrlUtils.setUserToken(data.jwtToken) | 84 | HttpUrlUtils.setUserToken(data.jwtToken) |
| @@ -94,8 +94,8 @@ export class LoginViewModel { | @@ -94,8 +94,8 @@ export class LoginViewModel { | ||
| 94 | return new Promise<CheckVerifyBean>((success, reject) => { | 94 | return new Promise<CheckVerifyBean>((success, reject) => { |
| 95 | this.loginModel.checkVerifyCode(phone, verifyCode).then((data: CheckVerifyBean) => { | 95 | this.loginModel.checkVerifyCode(phone, verifyCode).then((data: CheckVerifyBean) => { |
| 96 | //todo 保存数据 | 96 | //todo 保存数据 |
| 97 | - SPHelper.default.save(SpConstants.USER_TEMP_TOKEN, data.tempToken) | ||
| 98 | - SPHelper.default.save(SpConstants.USER_JWT_TOKEN, data.jwtToken) | 97 | + SPHelper.default.saveSync(SpConstants.USER_TEMP_TOKEN, data.tempToken) |
| 98 | + SPHelper.default.saveSync(SpConstants.USER_JWT_TOKEN, data.jwtToken) | ||
| 99 | success(data) | 99 | success(data) |
| 100 | 100 | ||
| 101 | }, (value: string) => { | 101 | }, (value: string) => { |
| @@ -107,8 +107,8 @@ export class LoginViewModel { | @@ -107,8 +107,8 @@ export class LoginViewModel { | ||
| 107 | return new Promise<CheckVerifyBean>((success, reject) => { | 107 | return new Promise<CheckVerifyBean>((success, reject) => { |
| 108 | this.loginModel.checkVerifyCodeByToken(verifyCode).then((data: CheckVerifyBean) => { | 108 | this.loginModel.checkVerifyCodeByToken(verifyCode).then((data: CheckVerifyBean) => { |
| 109 | //todo 保存数据 | 109 | //todo 保存数据 |
| 110 | - SPHelper.default.save(SpConstants.USER_TEMP_TOKEN, data.tempToken) | ||
| 111 | - SPHelper.default.save(SpConstants.USER_JWT_TOKEN, data.jwtToken) | 110 | + SPHelper.default.saveSync(SpConstants.USER_TEMP_TOKEN, data.tempToken) |
| 111 | + SPHelper.default.saveSync(SpConstants.USER_JWT_TOKEN, data.jwtToken) | ||
| 112 | success(data) | 112 | success(data) |
| 113 | 113 | ||
| 114 | }, (value: string) => { | 114 | }, (value: string) => { |
| @@ -149,14 +149,14 @@ export class LoginViewModel { | @@ -149,14 +149,14 @@ export class LoginViewModel { | ||
| 149 | this.loginModel.logOut().then((data) => { | 149 | this.loginModel.logOut().then((data) => { |
| 150 | //清除登录状态以及token、userid等信息 | 150 | //清除登录状态以及token、userid等信息 |
| 151 | 151 | ||
| 152 | - SPHelper.default.save(SpConstants.USER_FIRST_MARK, '') | ||
| 153 | - SPHelper.default.save(SpConstants.USER_ID, '') | ||
| 154 | - SPHelper.default.save(SpConstants.USER_JWT_TOKEN, '') | ||
| 155 | - SPHelper.default.save(SpConstants.USER_LONG_TIME_NO_LOGIN_MARK, '') | ||
| 156 | - SPHelper.default.save(SpConstants.USER_REFRESH_TOKEN, '') | ||
| 157 | - SPHelper.default.save(SpConstants.USER_STATUS, '') | ||
| 158 | - SPHelper.default.save(SpConstants.USER_Type, '') | ||
| 159 | - SPHelper.default.save(SpConstants.USER_NAME, '') | 152 | + SPHelper.default.saveSync(SpConstants.USER_FIRST_MARK, '') |
| 153 | + SPHelper.default.saveSync(SpConstants.USER_ID, '') | ||
| 154 | + SPHelper.default.saveSync(SpConstants.USER_JWT_TOKEN, '') | ||
| 155 | + SPHelper.default.saveSync(SpConstants.USER_LONG_TIME_NO_LOGIN_MARK, '') | ||
| 156 | + SPHelper.default.saveSync(SpConstants.USER_REFRESH_TOKEN, '') | ||
| 157 | + SPHelper.default.saveSync(SpConstants.USER_STATUS, '') | ||
| 158 | + SPHelper.default.saveSync(SpConstants.USER_Type, '') | ||
| 159 | + SPHelper.default.saveSync(SpConstants.USER_NAME, '') | ||
| 160 | HttpUrlUtils.setUserId("") | 160 | HttpUrlUtils.setUserId("") |
| 161 | HttpUrlUtils.setUserType("") | 161 | HttpUrlUtils.setUserType("") |
| 162 | HttpUrlUtils.setUserToken('') | 162 | HttpUrlUtils.setUserToken('') |
| @@ -218,14 +218,14 @@ export class LoginViewModel { | @@ -218,14 +218,14 @@ export class LoginViewModel { | ||
| 218 | this.loginModel.queryUserDetail().then((data: UserDetail) => { | 218 | this.loginModel.queryUserDetail().then((data: UserDetail) => { |
| 219 | //保存sp | 219 | //保存sp |
| 220 | if(data){ | 220 | if(data){ |
| 221 | - SPHelper.default.save(SpConstants.USER_NAME, data.userName) | ||
| 222 | - SPHelper.default.save(SpConstants.USER_PHONE, data.phone) | 221 | + SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName) |
| 222 | + SPHelper.default.saveSync(SpConstants.USER_PHONE, data.phone) | ||
| 223 | } | 223 | } |
| 224 | if(data.userExtend){ | 224 | if(data.userExtend){ |
| 225 | - SPHelper.default.save(SpConstants.USER_SEX, data.userExtend.sex) | ||
| 226 | - SPHelper.default.save(SpConstants.USER_CREATOR_ID, data.userExtend.creatorId+"") | ||
| 227 | - SPHelper.default.save(SpConstants.USER_HEAD_PHOTO_URL, data.userExtend.headPhotoUrl) | ||
| 228 | - SPHelper.default.save(SpConstants.USER_BIRTHDAY, data.userExtend.birthday) | 225 | + SPHelper.default.saveSync(SpConstants.USER_SEX, data.userExtend.sex) |
| 226 | + SPHelper.default.saveSync(SpConstants.USER_CREATOR_ID, data.userExtend.creatorId+"") | ||
| 227 | + SPHelper.default.saveSync(SpConstants.USER_HEAD_PHOTO_URL, data.userExtend.headPhotoUrl) | ||
| 228 | + SPHelper.default.saveSync(SpConstants.USER_BIRTHDAY, data.userExtend.birthday) | ||
| 229 | } | 229 | } |
| 230 | 230 | ||
| 231 | success(data) | 231 | success(data) |
| @@ -14,7 +14,7 @@ import { | @@ -14,7 +14,7 @@ import { | ||
| 14 | StringUtils, | 14 | StringUtils, |
| 15 | WindowModel | 15 | WindowModel |
| 16 | } from 'wdKit'; | 16 | } from 'wdKit'; |
| 17 | -import { HttpUrlUtils, WDHttp } from 'wdNetwork'; | 17 | +import { HostEnum, HostManager, WDHttp } from 'wdNetwork'; |
| 18 | 18 | ||
| 19 | export default class EntryAbility extends UIAbility { | 19 | export default class EntryAbility extends UIAbility { |
| 20 | onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { | 20 | onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { |
| @@ -25,7 +25,7 @@ export default class EntryAbility extends UIAbility { | @@ -25,7 +25,7 @@ export default class EntryAbility extends UIAbility { | ||
| 25 | WDHttp.initHttpHeader() | 25 | WDHttp.initHttpHeader() |
| 26 | const spHostUrl = SPHelper.default.getSync('hostUrl', '') as string | 26 | const spHostUrl = SPHelper.default.getSync('hostUrl', '') as string |
| 27 | if (StringUtils.isNotEmpty(spHostUrl)) { | 27 | if (StringUtils.isNotEmpty(spHostUrl)) { |
| 28 | - HttpUrlUtils.hostUrl = spHostUrl | 28 | + HostManager.changeHost(spHostUrl as HostEnum) |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | // 注册监听网络连接 | 31 | // 注册监听网络连接 |
| 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 | } |
-
Please register or login to post a comment