Showing
49 changed files
with
1234 additions
and
644 deletions
| @@ -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 | +} |
| @@ -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 | }; |
| @@ -99,6 +99,7 @@ function handleJsCallReceiveH5Data(data: Message) { | @@ -99,6 +99,7 @@ function handleJsCallReceiveH5Data(data: Message) { | ||
| 99 | case '3': | 99 | case '3': |
| 100 | let imgListData: IImgListData = JSON.parse(data?.data?.imgListData || "{}") | 100 | let imgListData: IImgListData = JSON.parse(data?.data?.imgListData || "{}") |
| 101 | let imgArr = imgListData?.imgArr || [] | 101 | let imgArr = imgListData?.imgArr || [] |
| 102 | + let swiperIndex = imgListData?.imgIndex | ||
| 102 | if (imgArr.length > 0) { | 103 | if (imgArr.length > 0) { |
| 103 | const photoList: PhotoListBean[] = imgArr.map(item => { | 104 | const photoList: PhotoListBean[] = imgArr.map(item => { |
| 104 | const photo: PhotoListBean = { | 105 | const photo: PhotoListBean = { |
| @@ -109,7 +110,7 @@ function handleJsCallReceiveH5Data(data: Message) { | @@ -109,7 +110,7 @@ function handleJsCallReceiveH5Data(data: Message) { | ||
| 109 | } | 110 | } |
| 110 | return photo | 111 | return photo |
| 111 | }) | 112 | }) |
| 112 | - ProcessUtils.gotoMultiPictureListPage(photoList) | 113 | + ProcessUtils.gotoMultiPictureListPage(photoList,swiperIndex) |
| 113 | } | 114 | } |
| 114 | break; | 115 | break; |
| 115 | case '5': | 116 | case '5': |
| @@ -79,6 +79,7 @@ export struct WdWebLocalComponent { | @@ -79,6 +79,7 @@ export struct WdWebLocalComponent { | ||
| 79 | if (this.videoUrl) { | 79 | if (this.videoUrl) { |
| 80 | Video({ src: this.videoUrl }) | 80 | Video({ src: this.videoUrl }) |
| 81 | .autoPlay(true) | 81 | .autoPlay(true) |
| 82 | + .objectFit(ImageFit.Contain) | ||
| 82 | .width(this.positionWidth) | 83 | .width(this.positionWidth) |
| 83 | .height(this.positionHeight) | 84 | .height(this.positionHeight) |
| 84 | .borderRadius(5) | 85 | .borderRadius(5) |
| @@ -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 | } |
| @@ -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'; |
| @@ -60,7 +61,7 @@ export struct CompParser { | @@ -60,7 +61,7 @@ export struct CompParser { | ||
| 60 | } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_02) { | 61 | } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_02) { |
| 61 | ZhSingleRow02({ compDTO }) | 62 | ZhSingleRow02({ compDTO }) |
| 62 | } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_03) { | 63 | } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_03) { |
| 63 | - LiveHorizontalReservationComponent({ compDTO: compDTO }) | 64 | + ZhSingleRow03({ compDTO: compDTO }) |
| 64 | } else if (compDTO.compStyle === CompStyle.Zh_Grid_Layout_02) { | 65 | } else if (compDTO.compStyle === CompStyle.Zh_Grid_Layout_02) { |
| 65 | ZhGridLayout02({ compDTO: compDTO }) | 66 | ZhGridLayout02({ compDTO: compDTO }) |
| 66 | } else if (compDTO.compStyle === CompStyle.Zh_Grid_Layout_03) { | 67 | } else if (compDTO.compStyle === CompStyle.Zh_Grid_Layout_03) { |
| @@ -211,7 +211,7 @@ export struct DynamicDetailComponent { | @@ -211,7 +211,7 @@ export struct DynamicDetailComponent { | ||
| 211 | } | 211 | } |
| 212 | } | 212 | } |
| 213 | .onClick((event: ClickEvent) => { | 213 | .onClick((event: ClickEvent) => { |
| 214 | - ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList) | 214 | + ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList,index) |
| 215 | }) | 215 | }) |
| 216 | } else { | 216 | } else { |
| 217 | GridCol({ | 217 | GridCol({ |
| @@ -228,7 +228,7 @@ export struct DynamicDetailComponent { | @@ -228,7 +228,7 @@ export struct DynamicDetailComponent { | ||
| 228 | }) | 228 | }) |
| 229 | } | 229 | } |
| 230 | .onClick((event: ClickEvent) => { | 230 | .onClick((event: ClickEvent) => { |
| 231 | - ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList) | 231 | + ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList,index) |
| 232 | }) | 232 | }) |
| 233 | } | 233 | } |
| 234 | } else if (this.contentDetailData.photoList.length === 4) { | 234 | } else if (this.contentDetailData.photoList.length === 4) { |
| @@ -240,7 +240,7 @@ export struct DynamicDetailComponent { | @@ -240,7 +240,7 @@ export struct DynamicDetailComponent { | ||
| 240 | .borderRadius(this.caclImageRadius(index)) | 240 | .borderRadius(this.caclImageRadius(index)) |
| 241 | } | 241 | } |
| 242 | .onClick((event: ClickEvent) => { | 242 | .onClick((event: ClickEvent) => { |
| 243 | - ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList) | 243 | + ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList,index) |
| 244 | }) | 244 | }) |
| 245 | } else { | 245 | } else { |
| 246 | GridCol({ | 246 | GridCol({ |
| @@ -251,7 +251,7 @@ export struct DynamicDetailComponent { | @@ -251,7 +251,7 @@ export struct DynamicDetailComponent { | ||
| 251 | .borderRadius(this.caclImageRadius(index)) | 251 | .borderRadius(this.caclImageRadius(index)) |
| 252 | } | 252 | } |
| 253 | .onClick((event: ClickEvent) => { | 253 | .onClick((event: ClickEvent) => { |
| 254 | - ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList) | 254 | + ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList,index) |
| 255 | }) | 255 | }) |
| 256 | } | 256 | } |
| 257 | }) | 257 | }) |
| @@ -13,6 +13,7 @@ import { | @@ -13,6 +13,7 @@ import { | ||
| 13 | import DetailViewModel from '../viewmodel/DetailViewModel'; | 13 | import DetailViewModel from '../viewmodel/DetailViewModel'; |
| 14 | import { ImageAndTextWebComponent } from './ImageAndTextWebComponent'; | 14 | import { ImageAndTextWebComponent } from './ImageAndTextWebComponent'; |
| 15 | import { OperRowListView } from './view/OperRowListView'; | 15 | import { OperRowListView } from './view/OperRowListView'; |
| 16 | +import router from '@ohos.router'; | ||
| 16 | import { RecommendList } from '../components/view/RecommendList' | 17 | import { RecommendList } from '../components/view/RecommendList' |
| 17 | import { CommonConstants } from 'wdConstant'; | 18 | import { CommonConstants } from 'wdConstant'; |
| 18 | import { HttpUrlUtils } from 'wdNetwork/Index'; | 19 | import { HttpUrlUtils } from 'wdNetwork/Index'; |
| @@ -20,7 +21,6 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | @@ -20,7 +21,6 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | ||
| 20 | import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel'; | 21 | import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel'; |
| 21 | import { PageRepository } from '../repository/PageRepository'; | 22 | import { PageRepository } from '../repository/PageRepository'; |
| 22 | import { detailedSkeleton } from './skeleton/detailSkeleton'; | 23 | import { detailedSkeleton } from './skeleton/detailSkeleton'; |
| 23 | -import { CommentComponent } from '../components/comment/view/CommentComponent' | ||
| 24 | 24 | ||
| 25 | const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm'; | 25 | const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm'; |
| 26 | 26 | ||
| @@ -75,58 +75,16 @@ export struct ImageAndTextPageComponent { | @@ -75,58 +75,16 @@ export struct ImageAndTextPageComponent { | ||
| 75 | isPageEnd: $isPageEnd | 75 | isPageEnd: $isPageEnd |
| 76 | }) | 76 | }) |
| 77 | Column() { | 77 | Column() { |
| 78 | - // 点赞 | ||
| 79 | - if (this.contentDetailData[0]?.openLikes) { | ||
| 80 | - Row() { | ||
| 81 | - Row() { | ||
| 82 | - if (this.newsStatusOfUser?.likeStatus === '1') { | ||
| 83 | - Image(this.contentDetailData[0]?.likesStyle === 1 ? $r('app.media.ic_like_check') : (this.contentDetailData[0]?.likesStyle === 2 ? $r('app.media.icon_prayer_active') : $r('app.media.icon_candle_active'))) | ||
| 84 | - .width(24) | ||
| 85 | - .height(24) | ||
| 86 | - .margin({ right: 5 }) | ||
| 87 | - } else { | ||
| 88 | - Image(this.contentDetailData[0]?.likesStyle === 1 ? $r('app.media.icon_like') : (this.contentDetailData[0]?.likesStyle === 2 ? $r('app.media.icon_prayer') : $r('app.media.icon_candle'))) | ||
| 89 | - .width(24) | ||
| 90 | - .height(24) | ||
| 91 | - .margin({ right: 5 }) | ||
| 92 | - } | ||
| 93 | - Text(`${this.interactData?.likeNum || 0 }`) | ||
| 94 | - .fontSize(16) | ||
| 95 | - .fontColor(this.newsStatusOfUser?.likeStatus === '1' ? '#ED2800' : '#999999') | ||
| 96 | - .fontWeight(500) | ||
| 97 | - } | ||
| 98 | - .width(140) | ||
| 99 | - .height(36) | ||
| 100 | - .justifyContent(FlexAlign.Center) | ||
| 101 | - .alignItems(VerticalAlign.Center) | ||
| 102 | - .borderRadius(20) | ||
| 103 | - // .border({ | ||
| 104 | - // width: 1, | ||
| 105 | - // color: '#EDEDED', | ||
| 106 | - // }) | ||
| 107 | - .onClick(() => { | ||
| 108 | - this.toggleLikeStatus() | ||
| 109 | - }) | ||
| 110 | - | ||
| 111 | - }.width(CommonConstants.FULL_WIDTH).height(80) | ||
| 112 | - .justifyContent(FlexAlign.Center) | ||
| 113 | - | ||
| 114 | - Divider().strokeWidth(6).color('#f5f5f5') | ||
| 115 | - } | ||
| 116 | if (this.recommendList.length > 0) { | 78 | if (this.recommendList.length > 0) { |
| 117 | RecommendList({ recommendList: this.recommendList }) | 79 | RecommendList({ recommendList: this.recommendList }) |
| 118 | } | 80 | } |
| 119 | - // 评论 | ||
| 120 | - if(this.contentDetailData[0]?.openComment){ | ||
| 121 | - | ||
| 122 | - } | ||
| 123 | } | 81 | } |
| 124 | } | 82 | } |
| 125 | 83 | ||
| 126 | } | 84 | } |
| 127 | .width(CommonConstants.FULL_WIDTH) | 85 | .width(CommonConstants.FULL_WIDTH) |
| 128 | .height(CommonConstants.FULL_HEIGHT) | 86 | .height(CommonConstants.FULL_HEIGHT) |
| 129 | - .padding({ bottom: 126 }) | 87 | + .padding({ bottom: 76 }) |
| 130 | .scrollBar(BarState.Off) | 88 | .scrollBar(BarState.Off) |
| 131 | 89 | ||
| 132 | if (!this.isPageEnd) { | 90 | if (!this.isPageEnd) { |
| @@ -134,7 +92,45 @@ export struct ImageAndTextPageComponent { | @@ -134,7 +92,45 @@ export struct ImageAndTextPageComponent { | ||
| 134 | } | 92 | } |
| 135 | 93 | ||
| 136 | //底部交互区 | 94 | //底部交互区 |
| 137 | - OperRowListView({ contentDetailData: this.contentDetailData[0] }) | 95 | + if (this.contentDetailData?.length) { |
| 96 | + OperRowListView({contentDetailData: this.contentDetailData[0]}) | ||
| 97 | + } | ||
| 98 | + /* Row() { | ||
| 99 | + Image($r('app.media.icon_arrow_left')) | ||
| 100 | + .width(24) | ||
| 101 | + .height(24) | ||
| 102 | + .onClick((event: ClickEvent) => { | ||
| 103 | + router.back() | ||
| 104 | + }) | ||
| 105 | + | ||
| 106 | + Row() { | ||
| 107 | + Image($r('app.media.icon_comment')) | ||
| 108 | + .width(24) | ||
| 109 | + .height(24) | ||
| 110 | + .margin({ right: 24 }) | ||
| 111 | + .id('comment') | ||
| 112 | + | ||
| 113 | + Image($r('app.media.icon_star')) | ||
| 114 | + .width(24) | ||
| 115 | + .height(24) | ||
| 116 | + .margin({ right: 24 }) | ||
| 117 | + | ||
| 118 | + Image($r('app.media.icon_listen')) | ||
| 119 | + .width(24) | ||
| 120 | + .height(24) | ||
| 121 | + .margin({ right: 24 }) | ||
| 122 | + | ||
| 123 | + Image($r('app.media.icon_forward')) | ||
| 124 | + .width(24) | ||
| 125 | + .height(24) | ||
| 126 | + | ||
| 127 | + } | ||
| 128 | + } | ||
| 129 | + .width(CommonConstants.FULL_WIDTH) | ||
| 130 | + .height(56) | ||
| 131 | + .padding({ left: 15, right: 15, bottom: 50, top: 20 }) | ||
| 132 | + .justifyContent(FlexAlign.SpaceBetween) | ||
| 133 | + .backgroundColor(Color.White)*/ | ||
| 138 | } | 134 | } |
| 139 | 135 | ||
| 140 | } | 136 | } |
| @@ -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 | } |
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' |
| @@ -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) |
| @@ -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 }) { |
| @@ -132,31 +121,34 @@ export struct BottomNavigationComponent { | @@ -132,31 +121,34 @@ export struct BottomNavigationComponent { | ||
| 132 | .fontWeight(this.currentNavIndex === index ? FontWeight.Bold : FontWeight.Normal) | 121 | .fontWeight(this.currentNavIndex === index ? FontWeight.Bold : FontWeight.Normal) |
| 133 | .textAlign(TextAlign.Center) | 122 | .textAlign(TextAlign.Center) |
| 134 | .fontSize($r('app.float.font_size_10'))// .fontColor(this.currentNavIndex === index ? Color.Red : Color.Gray) | 123 | .fontSize($r('app.float.font_size_10'))// .fontColor(this.currentNavIndex === index ? Color.Red : Color.Gray) |
| 135 | - .fontColor(this.getFontColor(index)) | 124 | + .fontColor(this.currentNavIndex === index ? navItem.nameCColor : navItem.nameColor) |
| 136 | .opacity(this.currentNavIndex === index ? this.FULL_OPACITY : this.SIXTY_OPACITY) | 125 | .opacity(this.currentNavIndex === index ? this.FULL_OPACITY : this.SIXTY_OPACITY) |
| 137 | } | 126 | } |
| 138 | .height($r('app.float.bottom_navigation_barHeight')) | 127 | .height($r('app.float.bottom_navigation_barHeight')) |
| 139 | .hoverEffect(HoverEffect.Highlight) | 128 | .hoverEffect(HoverEffect.Highlight) |
| 140 | - .onClick(() => { | ||
| 141 | - if (this.currentNavIndex === index) { | ||
| 142 | - // 当前tab,双击事件 | ||
| 143 | - this.doubleClick(() => { | ||
| 144 | - Logger.info(TAG, 'tab double click ') | ||
| 145 | - this.autoRefresh++ | 129 | + .gesture( |
| 130 | + TapGesture({ count: 2 }) | ||
| 131 | + .onAction((event: GestureEvent) => { | ||
| 132 | + AlertDialog.show({ message: 'aa' }) | ||
| 133 | + if (this.currentNavIndex === index) { | ||
| 134 | + // 当前tab,双击事件 | ||
| 135 | + this.autoRefresh++ | ||
| 136 | + } | ||
| 146 | }) | 137 | }) |
| 138 | + ) | ||
| 139 | + .onClick(() => { | ||
| 140 | + if (navItem.name === '我的') { | ||
| 141 | + this.barBackgroundColor = Color.White | ||
| 142 | + this.currentBottomNavInfo = {} as BottomNavDTO | ||
| 147 | } else { | 143 | } else { |
| 148 | - // 切换tab | ||
| 149 | - this.currentNavIndex = index; | ||
| 150 | - Logger.info(TAG, `onChange, index: ${index}`); | 144 | + this.currentBottomNavInfo = navItem |
| 151 | } | 145 | } |
| 146 | + | ||
| 147 | + this.currentNavIndex = index; | ||
| 148 | + Logger.info(TAG, `onChange, index: ${index}`); | ||
| 149 | + | ||
| 152 | }) | 150 | }) |
| 153 | 151 | ||
| 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 | } | 152 | } |
| 161 | 153 | ||
| 162 | // 底导切换函数 | 154 | // 底导切换函数 |
| @@ -199,17 +191,17 @@ export struct BottomNavigationComponent { | @@ -199,17 +191,17 @@ export struct BottomNavigationComponent { | ||
| 199 | /** | 191 | /** |
| 200 | * 双击实现 | 192 | * 双击实现 |
| 201 | */ | 193 | */ |
| 202 | - doubleClickTime: number = 0 | 194 | + // doubleClickTime: number = 0 |
| 203 | 195 | ||
| 204 | /** | 196 | /** |
| 205 | * 双击实现 | 197 | * 双击实现 |
| 206 | */ | 198 | */ |
| 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 | - } | 199 | + // private doubleClick(fun: () => void) { |
| 200 | + // let now = DateTimeUtils.getTimeStamp() | ||
| 201 | + // if (now - this.doubleClickTime < 200) { | ||
| 202 | + // fun() | ||
| 203 | + // } else { | ||
| 204 | + // this.doubleClickTime = now | ||
| 205 | + // } | ||
| 206 | + // } | ||
| 215 | } | 207 | } |
| 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 |
| @@ -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) { |
| @@ -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,7 +104,11 @@ export class PageHelper { | @@ -104,7 +104,11 @@ 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 | - pageModel.currentPage++; | 107 | + if (isLastGroup) { |
| 108 | + // 认为分页只会在最后一个group里 | ||
| 109 | + pageModel.currentPage++; | ||
| 110 | + } | ||
| 111 | + // pageModel.currentPage++; | ||
| 108 | pageModel.hasMore = true; | 112 | pageModel.hasMore = true; |
| 109 | 113 | ||
| 110 | //移除音频 和 活动 | 114 | //移除音频 和 活动 |
| @@ -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 | } |
| @@ -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 | } |
| @@ -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 | // 注册监听网络连接 |
-
Please register or login to post a comment