陈剑华

Merge remote-tracking branch 'origin/main'

Showing 47 changed files with 1415 additions and 232 deletions
@@ -34,6 +34,8 @@ export class SpConstants{ @@ -34,6 +34,8 @@ export class SpConstants{
34 //定位相关 34 //定位相关
35 static LOCATION_CITY_NAME = "location_city_name" //定位 35 static LOCATION_CITY_NAME = "location_city_name" //定位
36 static LOCATION_CITY_CODE = "location_city_code" //定位 36 static LOCATION_CITY_CODE = "location_city_code" //定位
  37 + static LOCATION_PROVINCE_CODE = "location_province_code" //定位,省份code
  38 + static LOCATION_DISTRICT_CODE = "location_district_code" //定位,区县,返回9位,如:合肥-瑶海区-310115114
37 static LOCATION_PERMISSION_REFUSE = "location_permission_refuse" //定位 39 static LOCATION_PERMISSION_REFUSE = "location_permission_refuse" //定位
38 40
39 //启动页数据存储key 41 //启动页数据存储key
@@ -15,6 +15,9 @@ export enum EmitterEventId { @@ -15,6 +15,9 @@ export enum EmitterEventId {
15 /*发布评论*/ 15 /*发布评论*/
16 COMMENT_PUBLISH = 6, 16 COMMENT_PUBLISH = 6,
17 17
  18 + // 关注,取消关注
  19 + PEOPLE_SHIP_ATTENTION = 7,
  20 +
18 // App回到前台 21 // App回到前台
19 APP_ENTER_FOREGROUD = 100, 22 APP_ENTER_FOREGROUD = 100,
20 // App进入后台 23 // App进入后台
1 import data_preferences from '@ohos.data.preferences'; 1 import data_preferences from '@ohos.data.preferences';
  2 +import { Logger } from './Logger';
  3 +
  4 +const TAG = 'SPHelper'
2 5
3 /** 6 /**
4 * sp存储 7 * sp存储
5 - *  
6 - * 单例模式  
7 - * TODO 新增内存存储,避免频繁sp获取  
8 */ 8 */
9 -// SPHelper.default.get("key1", "defValue1").then((value1) => {  
10 -// this.message = value1.toString();  
11 -// })  
12 -  
13 -// let value2: string = await SPHelper.default.get("key2", "defValue2");  
14 -// this.message = result;  
15 export class SPHelper { 9 export class SPHelper {
16 private static context: Context; 10 private static context: Context;
17 private static spFilename: string = '__SPHelper'; 11 private static spFilename: string = '__SPHelper';
@@ -51,7 +45,11 @@ export class SPHelper { @@ -51,7 +45,11 @@ export class SPHelper {
51 saveSync(key: string, value: data_preferences.ValueType) { 45 saveSync(key: string, value: data_preferences.ValueType) {
52 const preferences: data_preferences.Preferences = this.getVideoPreferencesSync(); 46 const preferences: data_preferences.Preferences = this.getVideoPreferencesSync();
53 preferences.putSync(key, value) 47 preferences.putSync(key, value)
54 - preferences.flush() // todo:Asynchronously 48 + preferences.flush().then(() => {
  49 + Logger.debug(TAG, 'saveSync flush success')
  50 + }).catch((error: object) => {
  51 + Logger.debug(TAG, 'saveSync flush failed: ' + JSON.stringify(error))
  52 + });
55 } 53 }
56 54
57 async get(key: string, defValue: data_preferences.ValueType): Promise<data_preferences.ValueType> { 55 async get(key: string, defValue: data_preferences.ValueType): Promise<data_preferences.ValueType> {
@@ -86,7 +84,11 @@ export class SPHelper { @@ -86,7 +84,11 @@ export class SPHelper {
86 deleteSync(key: string) { 84 deleteSync(key: string) {
87 const preferences: data_preferences.Preferences = this.getVideoPreferencesSync(); 85 const preferences: data_preferences.Preferences = this.getVideoPreferencesSync();
88 preferences.deleteSync(key) 86 preferences.deleteSync(key)
89 - preferences.flush(); // todo:Asynchronously 87 + preferences.flush().then(() => {
  88 + Logger.debug(TAG, 'deleteSync flush success')
  89 + }).catch((error: object) => {
  90 + Logger.debug(TAG, 'deleteSync flush failed: ' + JSON.stringify(error))
  91 + });
90 } 92 }
91 93
92 async clearSync() { 94 async clearSync() {
@@ -98,12 +100,6 @@ export class SPHelper { @@ -98,12 +100,6 @@ export class SPHelper {
98 }); 100 });
99 } 101 }
100 102
101 - // clearSync() {  
102 - // let preferences: data_preferences.Preferences = this.getVideoPreferencesSync()  
103 - // preferences.clearSync()  
104 - // preferences.flush()  
105 - // }  
106 -  
107 public getPreferences() { 103 public getPreferences() {
108 let preferences = data_preferences.getPreferences(SPHelper.context, SPHelper.spFilename); 104 let preferences = data_preferences.getPreferences(SPHelper.context, SPHelper.spFilename);
109 return preferences; 105 return preferences;
@@ -25,15 +25,14 @@ export class HttpParams { @@ -25,15 +25,14 @@ export class HttpParams {
25 headers['imei'] = DeviceUtil.clientId() 25 headers['imei'] = DeviceUtil.clientId()
26 headers['Accept-Language'] = 'zh' 26 headers['Accept-Language'] = 'zh'
27 headers['timestamp'] = DateTimeUtils.getTimeStamp() + '' 27 headers['timestamp'] = DateTimeUtils.getTimeStamp() + ''
  28 + headers['mpassid'] = 'ZbHTMeTsfaYDAHqt8ZHIzcPs'
28 HttpParams.setLocationHeader(headers) 29 HttpParams.setLocationHeader(headers)
29 - // // TODO 判断是否登录  
30 - headers['RMRB-X-TOKEN'] = HttpUtils.getXToken()  
31 - if (HttpUtils.getXToken() != '') {  
32 - headers['cookie'] = 'RMRB-X-TOKEN=' + HttpUtils.getXToken()  
33 - } 30 + if (HttpUtils.isLogin()) {
  31 + headers['RMRB-X-TOKEN'] = HttpUtils.getUserToken()
  32 + headers['cookie'] = 'RMRB-X-TOKEN=' + HttpUtils.getUserToken()
34 headers['userId'] = HttpUtils.getUserId() 33 headers['userId'] = HttpUtils.getUserId()
35 headers['userType'] = HttpUtils.getUserType() 34 headers['userType'] = HttpUtils.getUserType()
36 - headers['mpassid'] = 'ZbHTMeTsfaYDAHqt8ZHIzcPs' 35 + }
37 HttpParams.addSpecialHeaders(headers); 36 HttpParams.addSpecialHeaders(headers);
38 return headers; 37 return headers;
39 } 38 }
@@ -284,6 +284,22 @@ export class HttpUrlUtils { @@ -284,6 +284,22 @@ export class HttpUrlUtils {
284 */ 284 */
285 static readonly SEARCH_SUGGEST_DATA_PATH: string = "/api/rmrb-bff-display-zh/recommend/zh/c/list"; 285 static readonly SEARCH_SUGGEST_DATA_PATH: string = "/api/rmrb-bff-display-zh/recommend/zh/c/list";
286 286
  287 + /**
  288 + * 人民号号主推荐
  289 + */
  290 + static readonly RMH_RECOMMEND_DATA_PATH: string = "/api/rmrb-bff-display-zh/recommend/zh/c/rmh";
  291 +
  292 + /**
  293 + * 关注号主发布内容接口
  294 + */
  295 + static readonly ATTENTION_CONTENT_LIST_DATA_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/attention/contentList";
  296 +
  297 + /**
  298 + * 一键关注接口
  299 + */
  300 + static readonly ATTENTION_BATCH_DATA_PATH: string = "/api/rmrb-interact/interact/zh/c/attention/batch";
  301 +
  302 +
287 static getHost(): string { 303 static getHost(): string {
288 return HostManager.getHost(); 304 return HostManager.getHost();
289 } 305 }
@@ -650,4 +666,23 @@ export class HttpUrlUtils { @@ -650,4 +666,23 @@ export class HttpUrlUtils {
650 let url = HttpUrlUtils.getHost() + "/api/rmrb-bff-display-zh/display/zh/c/themeList"; 666 let url = HttpUrlUtils.getHost() + "/api/rmrb-bff-display-zh/display/zh/c/themeList";
651 return url; 667 return url;
652 } 668 }
  669 +
  670 + // 人民号号主推荐
  671 + static getRmhRecommendUrl() {
  672 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.RMH_RECOMMEND_DATA_PATH;
  673 + return url;
  674 + }
  675 +
  676 + // 关注号主发布内容接口
  677 + static getAttentionContentListUrl() {
  678 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.ATTENTION_CONTENT_LIST_DATA_PATH;
  679 + return url;
  680 + }
  681 +
  682 + // 一键关注接口
  683 + static getAttentionBatchUrl() {
  684 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.ATTENTION_BATCH_DATA_PATH;
  685 + return url;
  686 + }
  687 +
653 } 688 }
1 import { SpConstants } from 'wdConstant/Index'; 1 import { SpConstants } from 'wdConstant/Index';
2 import { DeviceUtil, SPHelper, StringUtils } from 'wdKit/Index'; 2 import { DeviceUtil, SPHelper, StringUtils } from 'wdKit/Index';
3 -import { HttpParams } from '../http/HttpCommonParams';  
4 import { HttpRequest } from '../http/HttpRequest'; 3 import { HttpRequest } from '../http/HttpRequest';
5 4
6 const TAG: string = '[HttpUtils]' 5 const TAG: string = '[HttpUtils]'
@@ -9,27 +8,6 @@ const TAG: string = '[HttpUtils]' @@ -9,27 +8,6 @@ const TAG: string = '[HttpUtils]'
9 * http相关工具类,对外暴露 8 * http相关工具类,对外暴露
10 */ 9 */
11 export class HttpUtils { 10 export class HttpUtils {
12 - private static userId = ''  
13 - private static userType = ''  
14 - private static token = ''  
15 -  
16 - /**  
17 - * 添加公共参数,如登录后,添加登录信息  
18 - */  
19 - static addCommonHeader() {  
20 - HttpRequest.addGlobalHeaderProvider(() => {  
21 - let headers: Record<string, string> = {};  
22 - return headers;  
23 - })  
24 - }  
25 -  
26 - /**  
27 - * 添加公共参数,如登出后,移除登录信息  
28 - */  
29 - static removeCommonHeader() {  
30 -  
31 - }  
32 -  
33 static getRefreshToken() { 11 static getRefreshToken() {
34 let refreshToken = SPHelper.default.getSync(SpConstants.USER_REFRESH_TOKEN, "") 12 let refreshToken = SPHelper.default.getSync(SpConstants.USER_REFRESH_TOKEN, "")
35 if (StringUtils.isNotEmpty(refreshToken)) { 13 if (StringUtils.isNotEmpty(refreshToken)) {
@@ -49,25 +27,27 @@ export class HttpUtils { @@ -49,25 +27,27 @@ export class HttpUtils {
49 * 定位,城市code 27 * 定位,城市code
50 */ 28 */
51 public static getCityCode(): string { 29 public static getCityCode(): string {
52 - // TODO  
53 // 城市编码 30 // 城市编码
54 - return '340100'; 31 + return SPHelper.default.getSync(SpConstants.LOCATION_CITY_CODE, '') as string
55 } 32 }
56 33
57 /** 34 /**
58 * 定位,省份code 35 * 定位,省份code
59 */ 36 */
60 public static getProvinceCode(): string { 37 public static getProvinceCode(): string {
61 - // TODO  
62 - return '340000'; 38 + return SPHelper.default.getSync(SpConstants.LOCATION_PROVINCE_CODE, '') as string
63 } 39 }
64 40
65 /** 41 /**
66 * 定位,地区code 42 * 定位,地区code
67 */ 43 */
68 public static getDistrictCode(): string { 44 public static getDistrictCode(): string {
69 - // TODO  
70 - return '340103'; 45 + let districtCode = SPHelper.default.getSync(SpConstants.LOCATION_DISTRICT_CODE, '') as string
  46 + if (districtCode === '') {
  47 + return districtCode
  48 + }
  49 + // 截取前6位,如返回310115114,需要310115 (上海浦东)
  50 + return districtCode.substring(0, 6);
71 } 51 }
72 52
73 public static getImei(): string { 53 public static getImei(): string {
@@ -75,43 +55,22 @@ export class HttpUtils { @@ -75,43 +55,22 @@ export class HttpUtils {
75 } 55 }
76 56
77 public static getUserId(): string { 57 public static getUserId(): string {
78 - // TODO 对接登录  
79 - if (StringUtils.isNotEmpty(HttpUtils.userId)) {  
80 - return HttpUtils.userId  
81 - }  
82 - HttpUtils.userId = SPHelper.default.getSync(SpConstants.USER_ID, "") as string  
83 - return HttpUtils.userId; 58 + return SPHelper.default.getSync(SpConstants.USER_ID, "") as string
84 } 59 }
85 60
86 public static getUserType(): string { 61 public static getUserType(): string {
87 - if (StringUtils.isNotEmpty(HttpUtils.userType)) {  
88 - return HttpUtils.userType  
89 - }  
90 - HttpUtils.userType = SPHelper.default.getSync(SpConstants.USER_Type, "") as string  
91 - return HttpUtils.userType; 62 + return SPHelper.default.getSync(SpConstants.USER_Type, "") as string
92 } 63 }
93 64
94 - static getXToken(): string {  
95 - if (StringUtils.isNotEmpty(HttpUtils.token)) {  
96 - return HttpUtils.token  
97 - }  
98 - HttpUtils.token = SPHelper.default.getSync(SpConstants.USER_JWT_TOKEN, "") as string  
99 - if (StringUtils.isNotEmpty(HttpUtils.token)) {  
100 - return HttpUtils.token  
101 - }  
102 - return ''  
103 - }  
104 -  
105 - public static setUserId(userId: string) {  
106 - // TODO 优化赋值  
107 - HttpUtils.userId = userId; 65 + static getUserToken(): string {
  66 + return SPHelper.default.getSync(SpConstants.USER_JWT_TOKEN, "") as string
108 } 67 }
109 68
110 - public static setUserType(userType: string) {  
111 - HttpUtils.userType = userType; 69 + public static isLogin(): boolean {
  70 + let token = HttpUtils.getUserToken()
  71 + if (token == null || token == undefined || token.length <= 0) {
  72 + return false
112 } 73 }
113 -  
114 - public static setUserToken(token: string) {  
115 - HttpUtils.token = token; 74 + return true
116 } 75 }
117 } 76 }
@@ -153,3 +153,15 @@ export { @@ -153,3 +153,15 @@ export {
153 UserExtend 153 UserExtend
154 } from './src/main/ets/bean/user/UserDetail'; 154 } from './src/main/ets/bean/user/UserDetail';
155 155
  156 +export {
  157 + RmhRecommendDTO
  158 +} from './src/main/ets/bean/peoples/RmhRecommendDTO';
  159 +
  160 +export {
  161 + PeopleShipContentListDTO
  162 +} from './src/main/ets/bean/peoples/PeopleShipContentListDTO';
  163 +
  164 +export {
  165 + AttentionBatchDTO,
  166 + CreatorDTO
  167 +} from './src/main/ets/bean/peoples/AttentionBatchDTO';
  1 +export class AttentionBatchDTO{
  2 + creators: CreatorDTO[];
  3 +
  4 + constructor(creators: CreatorDTO[] = []) {
  5 + this.creators = creators
  6 + }
  7 +}
  8 +
  9 +export class CreatorDTO {
  10 + attentionUserType: string;
  11 + attentionUserId: string;
  12 + attentionCreatorId: string;
  13 +
  14 + constructor(attentionUserType: string, attentionUserId: string, attentionCreatorId: string) {
  15 + this.attentionUserType = attentionUserType
  16 + this.attentionUserId = attentionUserId
  17 + this.attentionCreatorId = attentionCreatorId
  18 + }
  19 +
  20 +}
  1 +import { ContentDTO } from '../content/ContentDTO'
  2 +
  3 +
  4 +export interface PeopleShipContentListDTO {
  5 + followCreators: boolean;
  6 + hasNext: number;
  7 + list: ContentDTO[];
  8 + pageNum: number;
  9 + pageSize: number;
  10 + totalCount: number;
  11 +}
  1 +export interface RmhRecommendDTO {
  2 + authIcon: string;
  3 + authTitle: string;
  4 + authTitle2: string;
  5 + cnAttention: number;
  6 + cnMainControl: number;
  7 + creatorId: string;
  8 + fansNum: number;
  9 + headPhotoUrl: string;
  10 + introduction: string;
  11 + itemId: string;
  12 + itemType: string;
  13 + itemTypeCode: string;
  14 + posterShareControl: number;
  15 + region: string;
  16 + sceneId: string;
  17 + subSceneId: string;
  18 + traceId: string;
  19 + traceInfo: string;
  20 + userId: string;
  21 + userName: string;
  22 + userType: string;
  23 +}
  24 +
@@ -47,46 +47,64 @@ export struct CompParser { @@ -47,46 +47,64 @@ export struct CompParser {
47 // if (compDTO.operDataList[0]?.objectType !== '3' && compDTO.operDataList[0]?.objectType !== '13') { //暂时屏蔽活动和音频详情入口 47 // if (compDTO.operDataList[0]?.objectType !== '3' && compDTO.operDataList[0]?.objectType !== '13') { //暂时屏蔽活动和音频详情入口
48 if (compDTO.compStyle === CompStyle.Label_03) { 48 if (compDTO.compStyle === CompStyle.Label_03) {
49 LabelComponent({ compDTO: compDTO }) 49 LabelComponent({ compDTO: compDTO })
  50 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
50 } else if (compDTO.compStyle === CompStyle.Zh_Carousel_Layout_01) { 51 } else if (compDTO.compStyle === CompStyle.Zh_Carousel_Layout_01) {
51 ZhCarouselLayout01({ compDTO: compDTO }) 52 ZhCarouselLayout01({ compDTO: compDTO })
  53 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
52 } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_01 && compDTO.imageScale === 2) { 54 } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_01 && compDTO.imageScale === 2) {
53 LiveHorizontalCardComponent({ compDTO: compDTO }) 55 LiveHorizontalCardComponent({ compDTO: compDTO })
  56 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
54 } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_01 && compDTO.imageScale === 3) { 57 } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_01 && compDTO.imageScale === 3) {
55 if (compDTO.operDataList.length > 1) { 58 if (compDTO.operDataList.length > 1) {
56 HorizontalStrokeCardThreeTwoRadioForMoreComponent({ compDTO: compDTO }) 59 HorizontalStrokeCardThreeTwoRadioForMoreComponent({ compDTO: compDTO })
57 } else { 60 } else {
58 HorizontalStrokeCardThreeTwoRadioForOneComponent({ compDTO: compDTO }) 61 HorizontalStrokeCardThreeTwoRadioForOneComponent({ compDTO: compDTO })
59 } 62 }
  63 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
60 } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_02) { 64 } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_02) {
61 ZhSingleRow02({ compDTO }) 65 ZhSingleRow02({ compDTO })
  66 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
62 } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_03) { 67 } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_03) {
63 ZhSingleRow03({ compDTO: compDTO }) 68 ZhSingleRow03({ compDTO: compDTO })
  69 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
64 } else if (compDTO.compStyle === CompStyle.Zh_Grid_Layout_02) { 70 } else if (compDTO.compStyle === CompStyle.Zh_Grid_Layout_02) {
65 ZhGridLayout02({ compDTO: compDTO }) 71 ZhGridLayout02({ compDTO: compDTO })
  72 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
66 } else if (compDTO.compStyle === CompStyle.Zh_Grid_Layout_03) { 73 } else if (compDTO.compStyle === CompStyle.Zh_Grid_Layout_03) {
67 ZhGridLayout03({ compDTO: compDTO }) 74 ZhGridLayout03({ compDTO: compDTO })
  75 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
68 } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_04) { 76 } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_04) {
69 ZhSingleRow04({ compDTO: compDTO }) 77 ZhSingleRow04({ compDTO: compDTO })
  78 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
70 } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_05) { 79 } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_05) {
71 ZhSingleRow05({ compDTO }) 80 ZhSingleRow05({ compDTO })
  81 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
72 } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_06) { 82 } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_06) {
73 ZhSingleRow06({ compDTO }) 83 ZhSingleRow06({ compDTO })
  84 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
74 } else if (compDTO.compStyle === CompStyle.Zh_Single_Column_02) { 85 } else if (compDTO.compStyle === CompStyle.Zh_Single_Column_02) {
75 //头图卡 和comStyle 2相同, 86 //头图卡 和comStyle 2相同,
76 Card5Component({ contentDTO: compDTO.operDataList[0] }) 87 Card5Component({ contentDTO: compDTO.operDataList[0] })
  88 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
77 } else if (compDTO.compStyle === CompStyle.Zh_Single_Column_03) { 89 } else if (compDTO.compStyle === CompStyle.Zh_Single_Column_03) {
78 // 大图卡 90 // 大图卡
79 Card2Component({ contentDTO: compDTO.operDataList[0] }) 91 Card2Component({ contentDTO: compDTO.operDataList[0] })
  92 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
80 } else if (compDTO.compStyle === CompStyle.Zh_Single_Column_04) { 93 } else if (compDTO.compStyle === CompStyle.Zh_Single_Column_04) {
81 ZhSingleColumn04({ compDTO: compDTO }) 94 ZhSingleColumn04({ compDTO: compDTO })
  95 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
82 } else if (compDTO.compStyle === CompStyle.Zh_Single_Column_05) { 96 } else if (compDTO.compStyle === CompStyle.Zh_Single_Column_05) {
83 - ZhSingleColumn05({ compDTO: compDTO }) 97 + // ZhSingleColumn05({ compDTO: compDTO })
  98 + // Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
84 } else if (compDTO.compStyle === CompStyle.Zh_Single_Column_09) { 99 } else if (compDTO.compStyle === CompStyle.Zh_Single_Column_09) {
85 ZhSingleColumn09({ compDTO }) 100 ZhSingleColumn09({ compDTO })
  101 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
86 } else if (compDTO.compStyle === CompStyle.Card_Comp_Adv) { // 广告 102 } else if (compDTO.compStyle === CompStyle.Card_Comp_Adv) { // 广告
87 AdvCardParser({compDTO}) 103 AdvCardParser({compDTO})
  104 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
88 } else if (!Number.isNaN(Number(compDTO.compStyle))) { 105 } else if (!Number.isNaN(Number(compDTO.compStyle))) {
89 CardParser({ contentDTO: compDTO.operDataList[0] }); 106 CardParser({ contentDTO: compDTO.operDataList[0] });
  107 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
90 } 108 }
91 else { 109 else {
92 Text(compDTO.compStyle) 110 Text(compDTO.compStyle)
@@ -97,9 +115,9 @@ export struct CompParser { @@ -97,9 +115,9 @@ export struct CompParser {
97 WDRouterRule.jumpWithPage(WDRouterPage.QualityCommentsPage) 115 WDRouterRule.jumpWithPage(WDRouterPage.QualityCommentsPage)
98 } 116 }
99 }) 117 })
100 - }  
101 Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 }) 118 Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
102 } 119 }
  120 + }
103 121
104 // } 122 // }
105 } 123 }
@@ -335,6 +335,7 @@ export struct DynamicDetailComponent { @@ -335,6 +335,7 @@ export struct DynamicDetailComponent {
335 .width($r('app.float.margin_36')) 335 .width($r('app.float.margin_36'))
336 .height($r('app.float.margin_36')) 336 .height($r('app.float.margin_36'))
337 .objectFit(ImageFit.Cover) 337 .objectFit(ImageFit.Cover)
  338 + .margin({ left: $r('app.float.margin_6_negative'),right: $r('app.float.margin_6_negative')})
338 if(this.interactDataDTO?.likeNum != 0){ 339 if(this.interactDataDTO?.likeNum != 0){
339 Text(NumberFormatterUtils.formatNumberWithWan(this.interactDataDTO?.likeNum)) 340 Text(NumberFormatterUtils.formatNumberWithWan(this.interactDataDTO?.likeNum))
340 .fontColor($r('app.color.color_999999')) 341 .fontColor($r('app.color.color_999999'))
@@ -435,7 +436,6 @@ export struct DynamicDetailComponent { @@ -435,7 +436,6 @@ export struct DynamicDetailComponent {
435 // 未登录,跳转登录 436 // 未登录,跳转登录
436 const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') 437 const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
437 if (!user_id) { 438 if (!user_id) {
438 - WDRouterRule.jumpWithPage(WDRouterPage.loginPage)  
439 return 439 return
440 } 440 }
441 try { 441 try {
@@ -464,7 +464,6 @@ export struct DynamicDetailComponent { @@ -464,7 +464,6 @@ export struct DynamicDetailComponent {
464 // 未登录,跳转登录 464 // 未登录,跳转登录
465 const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') 465 const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
466 if (!user_id) { 466 if (!user_id) {
467 - WDRouterRule.jumpWithPage(WDRouterPage.loginPage)  
468 this.followStatus = '0'; 467 this.followStatus = '0';
469 return 468 return
470 } 469 }
@@ -152,6 +152,8 @@ export struct MorningEveningPaperComponent { @@ -152,6 +152,8 @@ export struct MorningEveningPaperComponent {
152 if (imageSource) { 152 if (imageSource) {
153 this.pickColor(imageSource) 153 this.pickColor(imageSource)
154 154
  155 + } else {
  156 + this.mixedBgColor = this.pageInfoBean.backgroundColor
155 } 157 }
156 158
157 } 159 }
@@ -32,6 +32,7 @@ export class commentListModel extends PageModel { @@ -32,6 +32,7 @@ export class commentListModel extends PageModel {
32 pageNum: number = 1 32 pageNum: number = 1
33 pageSize: number = 10 33 pageSize: number = 10
34 totalCount: number = 0 34 totalCount: number = 0
  35 + totalCommentNum: string = '0'
35 hasNext: number = 0 36 hasNext: number = 0
36 list: commentItemModel[] = [] 37 list: commentItemModel[] = []
37 // constructor(pageNum:number, pageSize:number, totalCount: number, hasNext: number, list: commentItemModel[]) { 38 // constructor(pageNum:number, pageSize:number, totalCount: number, hasNext: number, list: commentItemModel[]) {
@@ -177,6 +177,7 @@ export struct CommentComponent { @@ -177,6 +177,7 @@ export struct CommentComponent {
177 async getData() { 177 async getData() {
178 commentViewModel.fetchContentCommentList('1', this.publishCommentModel.targetId, this.publishCommentModel.targetType) 178 commentViewModel.fetchContentCommentList('1', this.publishCommentModel.targetId, this.publishCommentModel.targetType)
179 .then(commentListModel => { 179 .then(commentListModel => {
  180 + this.publishCommentModel.totalCommentNumer = commentListModel.totalCount + ''
180 if (commentListModel && commentListModel.list && commentListModel.list.length > 0) { 181 if (commentListModel && commentListModel.list && commentListModel.list.length > 0) {
181 commentListModel.list.forEach(element => { 182 commentListModel.list.forEach(element => {
182 element.hasMore = Number.parseInt(element.childCommentNum) ? true : false 183 element.hasMore = Number.parseInt(element.childCommentNum) ? true : false
1 -import { EmitterEventId, EmitterUtils } from 'wdKit/Index' 1 +import { DisplayUtils, EmitterEventId, EmitterUtils } from 'wdKit/Index'
2 import { publishCommentModel } from '../model/PublishCommentModel' 2 import { publishCommentModel } from '../model/PublishCommentModel'
3 import { CommentCustomDialog } from './CommentCustomDialog' 3 import { CommentCustomDialog } from './CommentCustomDialog'
4 - 4 +import measure from '@ohos.measure'
5 5
6 @Preview 6 @Preview
7 @Component 7 @Component
8 export struct CommentTabComponent { 8 export struct CommentTabComponent {
9 @ObjectLink publishCommentModel: publishCommentModel 9 @ObjectLink publishCommentModel: publishCommentModel
10 /*展示类型*/ 10 /*展示类型*/
11 - @State type:number = 1 11 + @State type: number = 1
12 @State placeHolder: string = '说两句...' 12 @State placeHolder: string = '说两句...'
13 -  
14 @State dialogController: CustomDialogController | null = null; 13 @State dialogController: CustomDialogController | null = null;
15 -  
16 /*回调方法*/ 14 /*回调方法*/
17 - dialogControllerConfirm: () => void = () => {}  
18 -  
19 - 15 + dialogControllerConfirm: () => void = () => {
  16 + }
20 17
21 aboutToAppear() { 18 aboutToAppear() {
22 19
@@ -24,9 +21,9 @@ export struct CommentTabComponent { @@ -24,9 +21,9 @@ export struct CommentTabComponent {
24 builder: CommentCustomDialog({ 21 builder: CommentCustomDialog({
25 confirm: (value: Record<string, string>) => { 22 confirm: (value: Record<string, string>) => {
26 this.dialogControllerConfirm(); 23 this.dialogControllerConfirm();
27 - EmitterUtils.sendEvent(EmitterEventId.COMMENT_PUBLISH,this.publishCommentModel.targetId) 24 + EmitterUtils.sendEvent(EmitterEventId.COMMENT_PUBLISH, this.publishCommentModel.targetId)
28 }, 25 },
29 - publishCommentModel:this.publishCommentModel 26 + publishCommentModel: this.publishCommentModel
30 }), 27 }),
31 autoCancel: true, 28 autoCancel: true,
32 alignment: DialogAlignment.Bottom, 29 alignment: DialogAlignment.Bottom,
@@ -40,13 +37,13 @@ export struct CommentTabComponent { @@ -40,13 +37,13 @@ export struct CommentTabComponent {
40 } 37 }
41 38
42 build() { 39 build() {
43 - Row(){  
44 - Stack({alignContent:Alignment.Start}){ 40 + Row() {
  41 + Stack({ alignContent: Alignment.Start }) {
45 Image($r('app.media.comment_img_input_hui')).width(151).height(30) 42 Image($r('app.media.comment_img_input_hui')).width(151).height(30)
46 - Text(this.placeHolder).fontSize(12).fontColor('#999999').margin({left:10}) 43 + Text(this.placeHolder).fontSize(12).fontColor('#999999').margin({ left: 10 })
47 } 44 }
48 }.width(151).height(30) 45 }.width(151).height(30)
49 - .onClick(()=>{ 46 + .onClick(() => {
50 this.publishCommentModel.parentId = '-1'; 47 this.publishCommentModel.parentId = '-1';
51 this.dialogController?.open(); 48 this.dialogController?.open();
52 }) 49 })
@@ -58,54 +55,84 @@ export struct CommentTabComponent { @@ -58,54 +55,84 @@ export struct CommentTabComponent {
58 export struct CommentIconComponent { 55 export struct CommentIconComponent {
59 @ObjectLink publishCommentModel: publishCommentModel 56 @ObjectLink publishCommentModel: publishCommentModel
60 /*展示类型*/ 57 /*展示类型*/
61 - @State type:number = 1 58 + @State type: number = 1
  59 +
  60 + // aboutToAppear(): void {
  61 + // setTimeout(() => {
  62 + // this.publishCommentModel.totalCommentNumer = '444'
  63 + // }, 3000);
  64 + //
  65 + // setTimeout(() => {
  66 + // this.publishCommentModel.totalCommentNumer = '2'
  67 + // }, 4000);
  68 +
  69 + // }
62 70
63 /*回调方法*/ 71 /*回调方法*/
64 - onClickItem: () => void = () => {} 72 + onClickItem: () => void = () => {
  73 + }
65 74
66 build() { 75 build() {
67 - Row(){  
68 - Stack({alignContent:Alignment.TopEnd}){ 76 + Row() {
  77 + Stack({ alignContent: Alignment.TopEnd }) {
69 Image($r('app.media.comment_icon')).width(24).height(24) 78 Image($r('app.media.comment_icon')).width(24).height(24)
70 // Stack({alignContent:Alignment.Start}) { 79 // Stack({alignContent:Alignment.Start}) {
  80 + // if(Number.parseInt(this.publishCommentModel.totalCommentNumer) != 0){
71 RelativeContainer() { 81 RelativeContainer() {
72 Image($r('app.media.comment_icon_number_bg')) 82 Image($r('app.media.comment_icon_number_bg'))
73 .objectFit(ImageFit.Fill) 83 .objectFit(ImageFit.Fill)
74 - .resizable({ slice: {top:1, left: 20 , right:1, bottom:1} }) 84 + .resizable({ slice: { top: 1, left: 20, right: 1, bottom: 1 } })
75 .alignRules({ 85 .alignRules({
76 - top: {anchor: "Text", align: VerticalAlign.Top},  
77 - left: {anchor: "Text", align: HorizontalAlign.Start},  
78 - right: {anchor: "Text", align: HorizontalAlign.End},  
79 - bottom : {anchor: "Text", align: VerticalAlign.Bottom},  
80 - })  
81 - // .offset({ 86 + top: { anchor: "Text", align: VerticalAlign.Top },
  87 + left: { anchor: "Text", align: HorizontalAlign.Start },
  88 + right: { anchor: "Text", align: HorizontalAlign.End },
  89 + bottom: { anchor: "Text", align: VerticalAlign.Bottom },
  90 + })// .offset({
82 // x:-6 91 // x:-6
83 // }) 92 // })
84 .id("Image") 93 .id("Image")
85 94
86 - Text('123213123123123') 95 + Text(this.publishCommentModel.totalCommentNumer)// Text("44444444")
87 .fontSize(8) 96 .fontSize(8)
88 .fontColor('#ffffff')// .backgroundColor('#ED2800') 97 .fontColor('#ffffff')// .backgroundColor('#ED2800')
89 .height(12) 98 .height(12)
  99 + .textAlign(TextAlign.Center)
90 .alignRules({ 100 .alignRules({
91 - top: {anchor: "__container__", align: VerticalAlign.Top},  
92 - left: {anchor: "__container__", align: HorizontalAlign.Start}  
93 - })  
94 - // .margin({left: 4,right:4 101 + top: { anchor: "__container__", align: VerticalAlign.Top },
  102 + left: { anchor: "__container__", align: HorizontalAlign.Start }
  103 + })// .margin({left: 4,right:4
95 // }) 104 // })
96 /*动态计算文字宽度*/ 105 /*动态计算文字宽度*/
97 - .width(50)  
98 - // .backgroundColor(Color.Green) 106 + .width(this.getMeasureText(this.publishCommentModel.totalCommentNumer) + 12)// .backgroundColor(Color.Green)
99 .id("Text") 107 .id("Text")
  108 + // .offset({
  109 + // x: 3
  110 + // })
100 111
101 } 112 }
102 // } 113 // }
103 -  
104 .offset({ 114 .offset({
105 - x:12 115 + x: 12
106 }) 116 })
  117 +
  118 + // }
107 } 119 }
108 }.width(24).height(24) 120 }.width(24).height(24)
  121 +
109 // .backgroundColor(Color.Blue) 122 // .backgroundColor(Color.Blue)
110 } 123 }
  124 +
  125 + private getMeasureText(text: string) {
  126 +
  127 +
  128 + let width = measure.measureText({
  129 + textContent: text,
  130 + fontSize: 8,
  131 + lineHeight: 12,
  132 + constraintWidth: DisplayUtils.getDeviceWidth(),
  133 + })
  134 + width = px2vp(width)
  135 + return width
  136 + }
111 } 137 }
  138 +
@@ -25,6 +25,41 @@ export struct FollowListDetailUI { @@ -25,6 +25,41 @@ export struct FollowListDetailUI {
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 @State isGetRequest: boolean = false
  28 + observer = (key: string) => {
  29 + if (key == UserDataLocal.USER_FOLLOW_OPERATION) {
  30 + if (this.creatorDirectoryId === -1) {
  31 + let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION, "") as string
  32 + let arr = value.split(',')
  33 + if (arr[1] == "0") {
  34 + this.data.getDataArray().forEach((element, index) => {
  35 + if (element.creatorId === arr[0]) {
  36 + this.data.deleteItem(index)
  37 + this.count = this.data.size()
  38 + }
  39 + });
  40 + } else {
  41 + if (!this.isLoading) {
  42 + this.isLoading = true
  43 + this.hasMore = true
  44 + this.curPageNum = 1
  45 + this.data.clear()
  46 + this.data.notifyDataReload()
  47 + this.getMyFollowListDetail()
  48 + }
  49 + }
  50 + }else{
  51 + let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION, "") as string
  52 + let arr = value.split(',')
  53 + if (arr[1] == "0"){
  54 + this.data.getDataArray().forEach((element, index) => {
  55 + if (element.creatorId === arr[0]) {
  56 + this.data.getData(index).status = "0"
  57 + }
  58 + })
  59 + }
  60 + }
  61 + }
  62 + }
28 63
29 aboutToAppear() { 64 aboutToAppear() {
30 this.getNewPageData() 65 this.getNewPageData()
@@ -76,42 +111,13 @@ export struct FollowListDetailUI { @@ -76,42 +111,13 @@ export struct FollowListDetailUI {
76 111
77 async addFollowStatusObserver() { 112 async addFollowStatusObserver() {
78 this.preferences = await SPHelper.default.getPreferences(); 113 this.preferences = await SPHelper.default.getPreferences();
79 - let observer = (key: string) => {  
80 - if (key == UserDataLocal.USER_FOLLOW_OPERATION) {  
81 - if (this.creatorDirectoryId === -1) {  
82 - let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION, "") as string  
83 - let arr = value.split(',')  
84 - if (arr[1] == "0") {  
85 - this.data.getDataArray().forEach((element, index) => {  
86 - if (element.creatorId === arr[0]) {  
87 - this.data.deleteItem(index)  
88 - this.count = this.data.size()  
89 - }  
90 - });  
91 - } else {  
92 - if (!this.isLoading) {  
93 - this.isLoading = true  
94 - this.hasMore = true  
95 - this.curPageNum = 1  
96 - this.data.clear()  
97 - this.data.notifyDataReload()  
98 - this.getMyFollowListDetail()  
99 - }  
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 - }  
111 - } 114 + this.preferences.on('change', this.observer);
112 } 115 }
  116 +
  117 + aboutToDisappear(): void {
  118 + if(this.preferences){
  119 + this.preferences.off('change', this.observer);
113 } 120 }
114 - this.preferences.on('change', observer);  
115 } 121 }
116 122
117 getMyFollowListDetail() { 123 getMyFollowListDetail() {
@@ -28,15 +28,7 @@ export struct HomePageBottomComponent{ @@ -28,15 +28,7 @@ export struct HomePageBottomComponent{
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 @State isGetRequest:boolean = false
31 -  
32 - aboutToAppear(){  
33 - this.getNewPageData()  
34 - this.addFollowStatusObserver()  
35 - }  
36 -  
37 - async addFollowStatusObserver() {  
38 - this.preferences = await SPHelper.default.getPreferences();  
39 - let observer = (key: string) => { 31 + observer = (key: string) => {
40 if (key == UserDataLocal.USER_FOLLOW_OPERATION) { 32 if (key == UserDataLocal.USER_FOLLOW_OPERATION) {
41 let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION,"") as string 33 let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION,"") as string
42 let arr = value.split(',') 34 let arr = value.split(',')
@@ -59,7 +51,21 @@ export struct HomePageBottomComponent{ @@ -59,7 +51,21 @@ export struct HomePageBottomComponent{
59 } 51 }
60 } 52 }
61 } 53 }
62 - this.preferences.on('change', observer); 54 +
  55 + aboutToAppear(){
  56 + this.getNewPageData()
  57 + this.addFollowStatusObserver()
  58 + }
  59 +
  60 + async addFollowStatusObserver() {
  61 + this.preferences = await SPHelper.default.getPreferences();
  62 + this.preferences.on('change', this.observer);
  63 + }
  64 +
  65 + aboutToDisappear(): void {
  66 + if(this.preferences){
  67 + this.preferences.off('change', this.observer);
  68 + }
63 } 69 }
64 70
65 build(){ 71 build(){
@@ -390,6 +390,33 @@ export struct PaperSingleColumn999CardView { @@ -390,6 +390,33 @@ export struct PaperSingleColumn999CardView {
390 private item: ContentDTO = {} as ContentDTO; 390 private item: ContentDTO = {} as ContentDTO;
391 private index: number = -1; 391 private index: number = -1;
392 392
  393 + getPublishTime(): string {
  394 + const publishTimestamp = parseInt(this.item?.publishTime)
  395 + const currentTime = Date.now(); // 当前时间戳
  396 +
  397 + // 计算差异
  398 + const timeDifference = currentTime - publishTimestamp;
  399 +
  400 + // 转换为分钟、小时和天
  401 + const minutes = Math.floor(timeDifference / (1000 * 60));
  402 + const hours = Math.floor(timeDifference / (1000 * 60 * 60));
  403 + const days = Math.floor(timeDifference / (1000 * 60 * 60 * 24));
  404 +
  405 + // 根据时间差返回对应的字符串
  406 + let result: string;
  407 +
  408 + if (minutes < 60) {
  409 + result = `${minutes}分钟前`;
  410 + } else if (hours < 24) {
  411 + result = `${hours}小时前`;
  412 + } else {
  413 + result = `${days}天前`;
  414 + }
  415 +
  416 + console.log(result);
  417 + return result
  418 + }
  419 +
393 build() { 420 build() {
394 Column() { 421 Column() {
395 Text(this.item?.newsTitle) 422 Text(this.item?.newsTitle)
@@ -429,14 +456,33 @@ export struct PaperSingleColumn999CardView { @@ -429,14 +456,33 @@ export struct PaperSingleColumn999CardView {
429 } 456 }
430 if (this.item?.visitorComment) { 457 if (this.item?.visitorComment) {
431 Row() { 458 Row() {
432 - Text(this.item?.visitorComment + "评") 459 + Row() {
  460 + Text(this.item?.source)
433 .fontSize(12) 461 .fontSize(12)
434 .fontColor(Color.Gray) 462 .fontColor(Color.Gray)
435 .margin({ left: 22 }) 463 .margin({ left: 22 })
  464 + Image($r('app.media.point'))
  465 + .width(16)
  466 + .height(16)
  467 + .margin({ top: 10, bottom: 10 })
  468 + Text(this.getPublishTime())
  469 + .fontSize(12)
  470 + .fontColor(Color.Gray)
  471 + Text(this.item?.visitorComment + "评")
  472 + .fontSize(12)
  473 + .fontColor(Color.Gray)
  474 + .margin({ left: 6 })
  475 + }
  476 + .justifyContent(FlexAlign.Start)
  477 +
436 Image($r('app.media.icon_forward')) 478 Image($r('app.media.icon_forward'))
437 .width(16) 479 .width(16)
438 .height(16) 480 .height(16)
439 .margin({ left: 10, right: 22, top: 10, bottom: 10 }) 481 .margin({ left: 10, right: 22, top: 10, bottom: 10 })
  482 + .alignRules({
  483 + center: { anchor: '__container__', align: VerticalAlign.Center },
  484 + right: { anchor: '__container__', align: HorizontalAlign.End }
  485 + })
440 }.width(CommonConstants.FULL_PARENT) 486 }.width(CommonConstants.FULL_PARENT)
441 .justifyContent(FlexAlign.SpaceBetween) 487 .justifyContent(FlexAlign.SpaceBetween)
442 } 488 }
@@ -24,6 +24,15 @@ export struct MinePageComponent { @@ -24,6 +24,15 @@ export struct MinePageComponent {
24 @State moreData:MinePageMoreFunctionModel[] = [] 24 @State moreData:MinePageMoreFunctionModel[] = []
25 scroller: Scroller = new Scroller() 25 scroller: Scroller = new Scroller()
26 preferences: dataPreferences.Preferences | null = null; 26 preferences: dataPreferences.Preferences | null = null;
  27 + observer = (key: string) => {
  28 + if(key == SpConstants.USER_ID){
  29 + if(StringUtils.isEmpty(SPHelper.default.getSync(SpConstants.USER_ID,""))){
  30 + this.isLogin = false
  31 + }else {
  32 + this.isLogin = true
  33 + }
  34 + }
  35 + }
27 36
28 aboutToAppear(){ 37 aboutToAppear(){
29 this.getUserLogin() 38 this.getUserLogin()
@@ -33,16 +42,13 @@ export struct MinePageComponent { @@ -33,16 +42,13 @@ export struct MinePageComponent {
33 42
34 async addLoginStatusObserver(){ 43 async addLoginStatusObserver(){
35 this.preferences = await SPHelper.default.getPreferences(); 44 this.preferences = await SPHelper.default.getPreferences();
36 - let observer = (key: string) => {  
37 - if(key == SpConstants.USER_ID){  
38 - if(StringUtils.isEmpty(SPHelper.default.getSync(SpConstants.USER_ID,""))){  
39 - this.isLogin = false  
40 - }else {  
41 - this.isLogin = true  
42 - } 45 + this.preferences.on('change', this.observer);
43 } 46 }
  47 +
  48 + aboutToDisappear(): void {
  49 + if(this.preferences){
  50 + this.preferences.off('change', this.observer);
44 } 51 }
45 - this.preferences.on('change', observer);  
46 } 52 }
47 53
48 54
@@ -6,6 +6,8 @@ import { ChannelSubscriptionLayout } from './ChannelSubscriptionLayout'; @@ -6,6 +6,8 @@ import { ChannelSubscriptionLayout } from './ChannelSubscriptionLayout';
6 import { FirstTabTopSearchComponent } from '../search/FirstTabTopSearchComponent'; 6 import { FirstTabTopSearchComponent } from '../search/FirstTabTopSearchComponent';
7 import { VideoChannelDetail } from 'wdDetailPlayShortVideo/Index'; 7 import { VideoChannelDetail } from 'wdDetailPlayShortVideo/Index';
8 import { AssignChannelParam } from 'wdRouter/src/main/ets/utils/HomeChannelUtils'; 8 import { AssignChannelParam } from 'wdRouter/src/main/ets/utils/HomeChannelUtils';
  9 +import { PeopleShipMainComponent } from '../peopleShip/PeopleShipMainComponent';
  10 +
9 11
10 const TAG = 'TopNavigationComponent'; 12 const TAG = 'TopNavigationComponent';
11 13
@@ -58,6 +60,11 @@ export struct TopNavigationComponent { @@ -58,6 +60,11 @@ export struct TopNavigationComponent {
58 // 当前底导index 60 // 当前底导index
59 @State navIndex: number = 0 61 @State navIndex: number = 0
60 62
  63 + @State animationDuration: number = 0
  64 + @State indicatorLeftMargin: number = 0
  65 + @State indicatorWidth: number = 0
  66 + private tabsWidth: number = 0
  67 +
61 topOrBottomNavChange() { 68 topOrBottomNavChange() {
62 if (this.currentBottomNavName === this.currentBottomNavInfo?.name) { 69 if (this.currentBottomNavName === this.currentBottomNavInfo?.name) {
63 this.setBarBackgroundColor() 70 this.setBarBackgroundColor()
@@ -162,6 +169,7 @@ export struct TopNavigationComponent { @@ -162,6 +169,7 @@ export struct TopNavigationComponent {
162 return item.name === '版面' 169 return item.name === '版面'
163 } 170 }
164 171
  172 +
165 build() { 173 build() {
166 Column() { 174 Column() {
167 // 顶部搜索、日报logo、早晚报 175 // 顶部搜索、日报logo、早晚报
@@ -218,7 +226,16 @@ export struct TopNavigationComponent { @@ -218,7 +226,16 @@ export struct TopNavigationComponent {
218 pageId: navItem.pageId + '', 226 pageId: navItem.pageId + '',
219 channelId: navItem.channelId + '', 227 channelId: navItem.channelId + '',
220 }) 228 })
221 - } else 229 + }
  230 + else if (this.currentBottomNavName === '人民号' && navItem.name === '关注') {
  231 + PeopleShipMainComponent({
  232 + currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
  233 + navIndex: index,
  234 + pageId: navItem.pageId + '',
  235 + channelId: navItem.channelId + '',
  236 + })
  237 + }
  238 + else
222 if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) { 239 if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) {
223 PageComponent({ 240 PageComponent({
224 currentTopNavSelectedIndex: $currentTopNavSelectedIndex, 241 currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
@@ -237,9 +254,13 @@ export struct TopNavigationComponent { @@ -237,9 +254,13 @@ export struct TopNavigationComponent {
237 .barMode(BarMode.Scrollable) 254 .barMode(BarMode.Scrollable)
238 .vertical(false) 255 .vertical(false)
239 .barBackgroundColor(this.barBackgroundColor) 256 .barBackgroundColor(this.barBackgroundColor)
  257 + .onAreaChange((oldValue: Area,newValue: Area)=> {
  258 + let width = Number.parseFloat(newValue.width.toString())
  259 + this.tabsWidth = Number.isNaN(width) ? 0 : width
  260 + })
  261 + .animationDuration(this.animationDuration)
240 .onChange((index: number) => { 262 .onChange((index: number) => {
241 this.currentTopNavName = this._currentNavIndex === 0 ? this.myChannelList[index].name : this.topNavList[index].name 263 this.currentTopNavName = this._currentNavIndex === 0 ? this.myChannelList[index].name : this.topNavList[index].name
242 -  
243 Logger.info(TAG, `onChange index : ${index}`); 264 Logger.info(TAG, `onChange index : ${index}`);
244 if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) && 265 if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) &&
245 !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) 266 !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])
@@ -256,6 +277,39 @@ export struct TopNavigationComponent { @@ -256,6 +277,39 @@ export struct TopNavigationComponent {
256 this.tabsController.changeIndex(this.currentTopNavSelectedIndex) 277 this.tabsController.changeIndex(this.currentTopNavSelectedIndex)
257 } 278 }
258 }) 279 })
  280 + .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => {
  281 + if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) &&
  282 + !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])
  283 + ) {
  284 + return
  285 + }
  286 + this.currentTopNavSelectedIndex = targetIndex
  287 + // 切换动画开始时触发该回调。下划线跟着页面一起滑动,同时宽度渐变。
  288 + let targetIndexInfo = this.getTextInfo(targetIndex)
  289 + this.startAnimateTo(this.animationDuration, targetIndexInfo.left, targetIndexInfo.width)
  290 + })
  291 + .onAnimationEnd((index: number,event: TabsAnimationEvent) => {
  292 + if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) &&
  293 + !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])
  294 + ) {
  295 + return
  296 + }
  297 + // 切换动画结束时触发该回调。下划线动画停止。
  298 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index,event)
  299 + this.startAnimateTo(0,currentIndicatorInfo.left,currentIndicatorInfo.width)
  300 + })
  301 + .onGestureSwipe((index: number,event: TabsAnimationEvent) => {
  302 + if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) &&
  303 + !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])
  304 + ) {
  305 + return
  306 + }
  307 + // 在页面跟手滑动过程中,逐帧触发该回调。
  308 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index,event)
  309 + this.currentTopNavSelectedIndex = currentIndicatorInfo.index
  310 + this.indicatorLeftMargin = currentIndicatorInfo.left
  311 + this.indicatorWidth = currentIndicatorInfo.width
  312 + })
259 313
260 // 分类列表最右侧频道设置 314 // 分类列表最右侧频道设置
261 if (this._currentNavIndex === 0) { 315 if (this._currentNavIndex === 0) {
@@ -296,6 +350,17 @@ export struct TopNavigationComponent { @@ -296,6 +350,17 @@ export struct TopNavigationComponent {
296 .fontColor(this.getTopNavFontColor(item, index)) 350 .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') }) 351 .padding({ top: $r('app.float.top_tab_item_padding_top'), bottom: $r('app.float.top_tab_item_padding_bottom') })
298 .maxLines(this.MAX_LINE) 352 .maxLines(this.MAX_LINE)
  353 + .id(index.toString())
  354 + .onAreaChange((oldValue: Area,newValue: Area) => {
  355 + if (this.currentTopNavSelectedIndex === index && (this.indicatorLeftMargin === 0 || this.indicatorWidth === 0)){
  356 + if (newValue.position.x != undefined) {
  357 + let positionX = Number.parseFloat(newValue.position.x.toString())
  358 + this.indicatorLeftMargin = Number.isNaN(positionX) ? 0 : positionX
  359 + }
  360 + let width = Number.parseFloat(newValue.width.toString())
  361 + this.indicatorWidth = Number.isNaN(width) ? 0 : width
  362 + }
  363 + })
299 // .backgroundImage(this.currentTopNavSelectedIndex === index ? item.iconCUrl : item.iconUrl) 364 // .backgroundImage(this.currentTopNavSelectedIndex === index ? item.iconCUrl : item.iconUrl)
300 if (this.currentTopNavSelectedIndex === index) { 365 if (this.currentTopNavSelectedIndex === index) {
301 Row() 366 Row()
@@ -418,4 +483,46 @@ export struct TopNavigationComponent { @@ -418,4 +483,46 @@ export struct TopNavigationComponent {
418 } 483 }
419 return null 484 return null
420 } 485 }
  486 +
  487 + private getTextInfo(index: number): Record<string, number> {
  488 + let strJson = getInspectorByKey(index.toString())
  489 + try {
  490 + let obj: Record<string, string> = JSON.parse(strJson)
  491 + let rectInfo: number[][] = JSON.parse('[' + obj.$rect + ']')
  492 + return { 'left': px2vp(rectInfo[0][0]), 'width': px2vp(rectInfo[1][0] - rectInfo[0][0]) }
  493 + } catch (error) {
  494 + return { 'left': 0, 'width': 0 }
  495 + }
  496 + }
  497 +
  498 + private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record<string, number> {
  499 + let nextIndex = index
  500 + if (index > 0 && event.currentOffset > 0) {
  501 + nextIndex--
  502 + } else if (index < 3 && event.currentOffset < 0) {
  503 + nextIndex++
  504 + }
  505 + let indexInfo = this.getTextInfo(index)
  506 + let nextIndexInfo = this.getTextInfo(nextIndex)
  507 + let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth)
  508 + let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。
  509 + let currentLeft = indexInfo.left + (nextIndexInfo.left - indexInfo.left) * swipeRatio
  510 + let currentWidth = indexInfo.width + (nextIndexInfo.width - indexInfo.width) * swipeRatio
  511 + return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth }
  512 + }
  513 +
  514 + private startAnimateTo(duration: number, leftMargin: number, width: number) {
  515 + animateTo({
  516 + duration: duration, // 动画时长
  517 + curve: Curve.Linear, // 动画曲线
  518 + iterations: 1, // 播放次数
  519 + playMode: PlayMode.Normal, // 动画模式
  520 + onFinish: () => {
  521 + console.info('play end')
  522 + }
  523 + }, () => {
  524 + this.indicatorLeftMargin = leftMargin
  525 + this.indicatorWidth = width
  526 + })
  527 + }
421 } 528 }
  1 +import { PeopleShipAttentionContentListTopComponent } from './PeopleShipAttentionContentListTopComponent'
  2 +import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem';
  3 +import { ContentDTO } from 'wdBean'
  4 +import { CardParser } from '../CardParser'
  5 +
  6 +@Preview
  7 +@Component
  8 +export struct PeopleShipAttentionContentListComponent {
  9 +
  10 + @Prop followList: FollowListDetailItem[]
  11 +
  12 + @Prop attentionList: ContentDTO[]
  13 +
  14 + build() {
  15 + List(){
  16 + // 头部关注列表
  17 + ListItem(){
  18 + PeopleShipAttentionContentListTopComponent({
  19 + followList: this.followList
  20 + })
  21 + }
  22 + ForEach(this.attentionList, (item: ContentDTO) => {
  23 + ListItem() {
  24 + CardParser({ contentDTO: item })
  25 + }.width("100%")
  26 + .backgroundColor(Color.Transparent)
  27 +
  28 + }, (item: ContentDTO, index: number) => item.objectId + index.toString())
  29 + }
  30 + .scrollBar(BarState.Off)
  31 + .width('100%')
  32 + .height('100%')
  33 + }
  34 +}
  35 +
  1 +import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem';
  2 +import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
  3 +import { ProcessUtils } from 'wdRouter';
  4 +import { PeopleShipHomePageHeadComponent } from '../peopleShipHomePage/PeopleShipHomePageHeadComponent'
  5 +
  6 +
  7 +@Component
  8 +export struct PeopleShipAttentionContentListTopComponent {
  9 + @Prop followList: FollowListDetailItem[]
  10 + build() {
  11 + Column() {
  12 + List(){
  13 + ListItem() {
  14 + PeopleShipAttentionContentListHeadComponent({
  15 + index: 0,
  16 + item: this.followList[0]
  17 + })
  18 + }.onClick(() => {
  19 + // 跳转到关注列表-我的
  20 + WDRouterRule.jumpWithPage(WDRouterPage.followListPage)
  21 + })
  22 +
  23 +
  24 + ForEach(this.followList, (item: FollowListDetailItem, index: number) => {
  25 + ListItem() {
  26 + PeopleShipAttentionContentListHeadComponent({
  27 + index: index + 1,
  28 + item: item
  29 + })
  30 + }.onClick(() => {
  31 + let creatorId = item.attentionCreatorId || ''
  32 + ProcessUtils.gotoPeopleShipHomePage(creatorId)
  33 + })
  34 + }, (item: FollowListDetailItem) => item.attentionCreatorId)
  35 + }
  36 + .listDirection(Axis.Horizontal)
  37 + .scrollBar(BarState.Off)
  38 + .width('100%')
  39 + .height('102vp')
  40 + Divider().strokeWidth(1).color($r('app.color.color_F5F5F5'))
  41 + }
  42 + }
  43 +}
  44 +
  45 +@Component
  46 +struct PeopleShipAttentionContentListHeadComponent {
  47 +
  48 + @State index: number = 0
  49 + @ObjectLink item: FollowListDetailItem
  50 + build() {
  51 + Column(){
  52 + // 头像
  53 + PeopleShipHomePageHeadComponent({
  54 + diameter: 48,
  55 + iconDiameter: 16,
  56 + headPhotoUrl: this.index == 0 ? $r('app.media.attention_mine') :
  57 + ((this.item.attentionHeadPhotoUrl && this.item.attentionHeadPhotoUrl.length > 0) ?
  58 + this.item.attentionHeadPhotoUrl : $r('app.media.WDAccountOwnerHedaerDefaultIcon')),
  59 + authIcon: this.index == 0 ? '' : this.item.authIcon
  60 + }).margin({
  61 + bottom: '8vp'
  62 + })
  63 +
  64 + Text(this.index == 0 ? '我的关注' : this.item.attentionUserName)
  65 + .fontColor($r('app.color.color_666666'))
  66 + .fontSize($r('app.float.vp_13'))
  67 + .fontWeight(400)
  68 + .height('18vp')
  69 + .lineHeight('18vp')
  70 + .maxLines(1)
  71 + .textOverflow({overflow: TextOverflow.Ellipsis})
  72 + .padding({
  73 + left: '2vp',
  74 + right: '2vp'
  75 + })
  76 + }
  77 + .alignItems(HorizontalAlign.Center)
  78 + .width('78vp')
  79 + .margin({
  80 + left: this.index == 0 ? '8vp' : '4vp',
  81 + top: '14vp',
  82 + bottom: '14vp'
  83 + })
  84 + }
  85 +}
  1 +import { PeopleShipRecommendComponent } from './PeopleShipRecommendComponent';
  2 +import { PeopleShipMainViewModel } from '../../viewmodel/PeopleShipMainViewModel';
  3 +import { HttpUtils } from 'wdNetwork/Index';
  4 +import { Logger, DateTimeUtils, EmitterEventId, EmitterUtils } from 'wdKit';
  5 +import { RmhRecommendDTO, ContentDTO, AttentionBatchDTO, CreatorDTO } from 'wdBean';
  6 +import { ViewType } from 'wdConstant/src/main/ets/enum/ViewType';
  7 +import { channelSkeleton } from '../skeleton/channelSkeleton'
  8 +import { EmptyComponent } from '../view/EmptyComponent';
  9 +import { ErrorComponent } from '../view/ErrorComponent';
  10 +import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
  11 +import MinePageDatasModel from '../../model/MinePageDatasModel';
  12 +import { FollowListDetailRequestItem } from '../../viewmodel/FollowListDetailRequestItem';
  13 +import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem';
  14 +import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh';
  15 +import PageModel from '../../viewmodel/PageModel';
  16 +import PageAdModel from '../../viewmodel/PageAdvModel';
  17 +import PageHelper from '../../viewmodel/PageHelper';
  18 +import { PeopleShipAttentionContentListTopComponent } from './PeopleShipAttentionContentListTopComponent'
  19 +import { CardParser } from '../CardParser'
  20 +import NoMoreLayout from '../page/NoMoreLayout';
  21 +
  22 +@Preview
  23 +@Component
  24 +export struct PeopleShipMainComponent {
  25 + @State private pageModel: PageModel = new PageModel();
  26 + @State private pageAdvModel: PageAdModel = new PageAdModel();
  27 +
  28 + navIndex: number = 0;
  29 + pageId: string = "";
  30 + channelId: string = "";
  31 + @Link @Watch('onChange') currentTopNavSelectedIndex: number
  32 + private scroller: Scroller = new Scroller()
  33 + private listScroller: Scroller = new Scroller()
  34 +
  35 + @State rmhList: RmhRecommendDTO[] = []
  36 + @Provide rmhSelectedList: string[] = []
  37 + @State viewType: ViewType = ViewType.LOADING
  38 + // 一键关注处理
  39 + @State @Watch('onOneFollowChange') oneKeyFollow: boolean = false
  40 + // 已经关注的列表
  41 + @State followList: FollowListDetailItem[] = []
  42 + // 换一换
  43 + @State @Watch('onChangeButtonClick') changeButton: boolean = false
  44 + @State attentionList: ContentDTO[] = []
  45 + @State private hasMore: boolean = true
  46 + @State private currentPage: number = 1
  47 + @State private isLoading: boolean = false
  48 + @State private loadTime: string = ''
  49 +
  50 + // 页面展示监听
  51 + @Consume @Watch('onPageShowChange') pageShow: number
  52 + @State private pageAttentionChange: boolean = false
  53 +
  54 + build() {
  55 + if (this.viewType == ViewType.LOADING) {
  56 + this.LoadingLayout()
  57 + } else if (this.viewType == ViewType.ERROR) {
  58 + ErrorComponent()
  59 + } else if (this.viewType == ViewType.EMPTY) {
  60 + EmptyComponent()
  61 + } else {
  62 + if (this.followList.length == 0) {
  63 + CustomPullToRefresh({
  64 + alldata: this.rmhList,
  65 + scroller: this.scroller,
  66 + hasMore: false,
  67 + customList: () => {
  68 + this.ListLayout()
  69 + },
  70 + onRefresh: (resolve) => {
  71 + this.currentPage = 1
  72 + this.getData(resolve)
  73 + },
  74 + })
  75 + }else {
  76 + CustomPullToRefresh({
  77 + alldata: this.attentionList,
  78 + scroller: this.listScroller,
  79 + hasMore: this.hasMore,
  80 + customList: () => {
  81 + this.ListAttentionLayout()
  82 + },
  83 + onRefresh: (resolve) => {
  84 + this.currentPage = 1
  85 + this.getData(resolve)
  86 + },
  87 + onLoadMore:(resolve)=> {
  88 + if (this.hasMore === false) {
  89 + if(resolve) {
  90 + resolve('')
  91 + }
  92 + return
  93 + }
  94 + if(!this.isLoading && this.hasMore){
  95 + //加载分页数据
  96 + this.currentPage++;
  97 + this.getAttentionContentListData(resolve)
  98 + }else {
  99 + if(resolve) {
  100 + resolve('')
  101 + }
  102 + }
  103 + },
  104 + })
  105 + }
  106 + }
  107 + }
  108 +
  109 + @Builder
  110 + LoadingLayout() {
  111 + channelSkeleton()
  112 + }
  113 +
  114 + @Builder
  115 + ListLayout() {
  116 + Scroll(this.scroller) {
  117 + // 推荐人民号
  118 + PeopleShipRecommendComponent({
  119 + rmhList: this.rmhList,
  120 + oneKeyFollow: this.oneKeyFollow,
  121 + changeButton: this.changeButton
  122 + })
  123 + }
  124 + .edgeEffect(EdgeEffect.None)
  125 + .scrollBar(BarState.Off)
  126 + .width('100%')
  127 + .height('100%')
  128 + }
  129 +
  130 + @Builder
  131 + ListAttentionLayout() {
  132 + List({scroller: this.listScroller}){
  133 + // 头部关注列表
  134 + ListItem(){
  135 + PeopleShipAttentionContentListTopComponent({
  136 + followList: this.followList
  137 + })
  138 + }
  139 + ForEach(this.attentionList, (item: ContentDTO) => {
  140 + ListItem() {
  141 + CardParser({ contentDTO: item })
  142 + }.width("100%")
  143 + .backgroundColor(Color.Transparent)
  144 +
  145 + }, (item: ContentDTO, index: number) => item.objectId + index.toString())
  146 +
  147 + // 加载更多
  148 + ListItem() {
  149 + if (!this.hasMore && !this.isLoading) {
  150 + NoMoreLayout()
  151 + }
  152 + }
  153 + }
  154 + .edgeEffect(EdgeEffect.None)
  155 + .scrollBar(BarState.Off)
  156 + .width('100%')
  157 + .height('100%')
  158 +
  159 + // PeopleShipAttentionContentListComponent({
  160 + // followList: this.followList,
  161 + // attentionList: this.attentionList
  162 + // })
  163 + }
  164 +
  165 + aboutToAppear() {
  166 + if (this.navIndex == this.currentTopNavSelectedIndex && this.viewType == ViewType.LOADING) {
  167 + this.getData()
  168 + }
  169 + // 有登录-退出登录-关注接口等问题
  170 + EmitterUtils.receiveEvent(EmitterEventId.PEOPLE_SHIP_ATTENTION, () => {
  171 + Logger.debug('PeopleShipMainComponent', 'PEOPLE_SHIP_ATTENTION')
  172 + this.pageAttentionChange = true
  173 + })
  174 + }
  175 +
  176 + onChange() {
  177 + if (this.navIndex === this.currentTopNavSelectedIndex && (this.viewType == ViewType.LOADING || this.pageAttentionChange)) {
  178 + this.getData();
  179 + }
  180 + }
  181 +
  182 + private async getData(resolve?: (value: string | PromiseLike<string>) => void) {
  183 + if (this.isLoading) {
  184 + if (resolve) {
  185 + resolve('已更新至最新')
  186 + }
  187 + return
  188 + }
  189 + this.pageAttentionChange = false
  190 + this.isLoading = true
  191 + this.getInitData()
  192 + try {
  193 + // 登录后获取
  194 + if (HttpUtils.getUserId()) {
  195 + // 获取用户关注人数
  196 + let object = new FollowListDetailRequestItem(-1, 20, 1)
  197 + let followInfo = await MinePageDatasModel.getMineFollowListData(object, getContext(this))
  198 + Logger.debug('PeopleShipMainComponent', '获取页面信息' + `${JSON.stringify(followInfo)}`)
  199 +
  200 + if (followInfo.list.length == 0) {
  201 + this.followList = []
  202 + this.getRmhRecommendInfo(resolve)
  203 + } else {
  204 + this.followList = []
  205 + // this.followList = followInfo.list
  206 + this.followList.push(...followInfo.list)
  207 + this.attentionList = []
  208 + this.currentPage = 1
  209 + this.loadTime = DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN)
  210 + this.getAttentionContentListData(resolve)
  211 + }
  212 + } else {
  213 + this.followList = []
  214 + this.getRmhRecommendInfo(resolve)
  215 + }
  216 +
  217 + } catch (exception) {
  218 + this.viewType = ViewType.ERROR
  219 + this.isLoading = false
  220 + }
  221 + }
  222 +
  223 + // 获取人民号号主推荐
  224 + private async getRmhRecommendInfo(resolve?: (value: string | PromiseLike<string>) => void) {
  225 + try {
  226 + // 获取页面信息
  227 + this.rmhList = await PeopleShipMainViewModel.getPeopleRemRecommendInfo()
  228 + this.rmhSelectedList = []
  229 + this.rmhList.forEach((item: RmhRecommendDTO) => {
  230 + this.rmhSelectedList.push(item.creatorId)
  231 + })
  232 + this.viewType = ViewType.LOADED
  233 + this.changeButton = false
  234 + this.isLoading = false
  235 + Logger.debug('PeopleShipMainComponent', 'getRmhRecommendInfo' + `${JSON.stringify(this.rmhList)}`)
  236 + if (resolve) {
  237 + resolve('已更新至最新')
  238 + }
  239 + } catch (exception) {
  240 + if (resolve) {
  241 + resolve('')
  242 + }
  243 + this.viewType = ViewType.ERROR
  244 + this.changeButton = false
  245 + this.isLoading = false
  246 + }
  247 + }
  248 +
  249 + // 获取关注
  250 + private async getAttentionContentListData(resolve?: (value: string | PromiseLike<string>) => void) {
  251 + if (this.isLoading && this.currentPage != 1) {
  252 + if (resolve) {
  253 + resolve('')
  254 + }
  255 + return
  256 + }
  257 + this.isLoading = true
  258 + try {
  259 + // 获取列表数据
  260 + let listData = await PeopleShipMainViewModel.getAttentionContentListInfo(this.currentPage, 20, this.loadTime)
  261 + Logger.debug('PeopleShipMainComponent', '获取页面信息' + `${JSON.stringify(listData)}`)
  262 +
  263 + if (resolve ) {
  264 + if (this.currentPage == 1) {
  265 + resolve('已更新至最新')
  266 + }else {
  267 + resolve('')
  268 + }
  269 + }
  270 + if (listData && listData.list && listData.list.length > 0) {
  271 + if (listData.list.length === 20) {
  272 + this.hasMore = true;
  273 + } else {
  274 + this.hasMore = false;
  275 + }
  276 + if (this.currentPage == 1) {
  277 + this.attentionList = []
  278 + }
  279 + this.attentionList.push(...listData.list)
  280 + }
  281 + this.viewType = ViewType.LOADED
  282 + this.isLoading = false
  283 + } catch (exception) {
  284 + this.viewType = ViewType.ERROR
  285 + this.isLoading = false
  286 + }
  287 + }
  288 +
  289 + // 说是首页必须要调用
  290 + async getInitData() {
  291 + Logger.debug('PeopleShipMainComponent', `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`);
  292 + this.pageModel.pageId = this.pageId;
  293 + this.pageModel.groupId = this.pageId;
  294 + this.pageModel.channelId = this.channelId;
  295 + this.pageModel.currentPage = 1;
  296 + PageHelper.getInitData(this.pageModel, this.pageAdvModel)
  297 + }
  298 +
  299 + // 点击一键关注
  300 + onOneFollowChange() {
  301 + if (this.oneKeyFollow) {
  302 + if (this.rmhSelectedList.length > 0) {
  303 + if (!HttpUtils.getUserId()) {
  304 + this.oneKeyFollow = false
  305 + WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
  306 + return
  307 + }
  308 + //调用接口
  309 + this.attentionBatchPort()
  310 + } else {
  311 + this.oneKeyFollow = false
  312 + }
  313 + }
  314 + }
  315 +
  316 + // 一键关注接口
  317 + private async attentionBatchPort() {
  318 + try {
  319 + // 获取列表数据
  320 + let objects = new AttentionBatchDTO()
  321 + this.rmhList.forEach((element: RmhRecommendDTO) => {
  322 + if ( this.rmhSelectedList.indexOf(element.creatorId) != -1) {
  323 + const creator = new CreatorDTO(element.userType, element.userId, element.creatorId)
  324 + objects.creators.push(creator)
  325 + }
  326 + })
  327 + Logger.debug('PeopleShipMainComponent', `一键关注接口参数: ${JSON.stringify(objects)}`);
  328 + let batchInfo = await PeopleShipMainViewModel.getAttentionBatchInfo(objects)
  329 + if (batchInfo.code === 0 || batchInfo.code.toString() === "0") {
  330 + this.getData()
  331 + }
  332 + } catch (exception) {
  333 +
  334 + }
  335 + }
  336 +
  337 + // 点击换一换
  338 + onChangeButtonClick() {
  339 + if (this.changeButton) {
  340 + this.getRmhRecommendInfo()
  341 + }
  342 + }
  343 +
  344 + // 页面展示监听
  345 + onPageShowChange() {
  346 + if (this.navIndex === this.currentTopNavSelectedIndex && this.pageAttentionChange ) {
  347 + this.getData()
  348 + }
  349 + }
  350 +
  351 +}
  1 +import { PeopleShipRecommendHeadComponent } from './PeopleShipRecommendHeadComponent'
  2 +import { RmhRecommendDTO } from 'wdBean';
  3 +import { Logger } from 'wdKit/Index';
  4 +import NoMoreLayout from '../page/NoMoreLayout';
  5 +
  6 +@Component
  7 +export struct PeopleShipRecommendComponent {
  8 + @Prop rmhList: RmhRecommendDTO[] = []
  9 + @Consume rmhSelectedList: string[]
  10 + // 一键关注处理
  11 + @Link oneKeyFollow: boolean
  12 + // 换一换
  13 + @Link changeButton: boolean
  14 +
  15 +
  16 + build() {
  17 + Column({ space: 0 }) {
  18 + Row() {
  19 + Image($r('app.media.redLine'))
  20 + .width('3vp')
  21 + .height('16vp')
  22 + .objectFit(ImageFit.Cover)
  23 + .margin({
  24 + left: '16vp',
  25 + right: '4vp'
  26 + })
  27 + Text('为你推荐优质号主')
  28 + .height('30vp')
  29 + .fontColor($r('app.color.color_222222'))
  30 + .fontWeight(600)
  31 + .fontSize($r('app.float.vp_18'))
  32 +
  33 + Blank()
  34 + Button({ type: ButtonType.Normal, stateEffect: true }) {
  35 + Row() {
  36 + Text('换一换')
  37 + .height('30vp')
  38 + .fontColor($r('app.color.color_999999'))
  39 + .fontWeight(400)
  40 + .fontSize($r('app.float.vp_14'))
  41 + Image($r('app.media.ic_refresh'))
  42 + .width('14vp')
  43 + .height('14vp')
  44 + .objectFit(ImageFit.Cover)
  45 + }
  46 + }
  47 + .margin({
  48 + right: '16vp'
  49 + })
  50 + .backgroundColor(Color.Transparent)
  51 + .onClick(() => {
  52 + // 点击换一换
  53 + if (!this.changeButton) {
  54 + this.changeButton = true
  55 + }
  56 + })
  57 + }
  58 + .width('100%')
  59 + .alignSelf(ItemAlign.Start)
  60 + .margin({
  61 + top: '10vp',
  62 + bottom: '10vp'
  63 + })
  64 +
  65 + Grid() {
  66 + ForEach(this.rmhList, (item: RmhRecommendDTO) => {
  67 + GridItem() {
  68 + PeopleShipRecommendHeadComponent({
  69 + rmhInfo: item
  70 + })
  71 + .onClick(() => {
  72 + this.clickRecommendHeadSelected(item)
  73 + })
  74 + }
  75 + }, (item: RmhRecommendDTO) => item.creatorId)
  76 + }
  77 + .columnsTemplate('1fr 1fr 1fr')
  78 + .columnsGap(20)
  79 + .rowsGap(20)
  80 + .height(Math.ceil(this.rmhList.length / 3.0) * 136)
  81 + .backgroundColor(Color.Transparent)
  82 + .margin({
  83 + right: '20vp',
  84 + left: '20pv'
  85 + })
  86 +
  87 + // 为你推荐
  88 + Button(this.rmhSelectedList.length == 0 ? '一键关注' : `一键关注 (${this.rmhSelectedList.length})`, { type: ButtonType.Normal, stateEffect: this.rmhSelectedList.length != 0 })
  89 + .margin({
  90 + top: '24vp'
  91 + })
  92 + .width('120vp')
  93 + .height('36vp')
  94 + .backgroundColor(this.rmhSelectedList.length != 0 ? $r('app.color.color_ED2800') : $r('app.color.color_B0B0B0'))
  95 + .borderRadius('3vp')
  96 + .fontColor($r('app.color.color_999999'))
  97 + .fontWeight(500)
  98 + .fontSize($r('app.float.vp_14'))
  99 + .fontColor(Color.White)
  100 + .onClick(() => {
  101 + // 点击一键关注
  102 + if (!this.oneKeyFollow && this.rmhSelectedList.length > 0 ){
  103 + this.oneKeyFollow = true
  104 + }
  105 + })
  106 + // 没有更多
  107 + NoMoreLayout()
  108 + }
  109 + .width('100%')
  110 + }
  111 +
  112 + // 选中
  113 + private clickRecommendHeadSelected(rmhInfo: RmhRecommendDTO) {
  114 + if (this.rmhSelectedList.length > 0 && rmhInfo ) {
  115 + const num = this.rmhSelectedList.indexOf(rmhInfo.creatorId)
  116 + if ( num != -1) {
  117 + this.rmhSelectedList.splice(num, 1)
  118 + }else {
  119 + this.rmhSelectedList.push(rmhInfo.creatorId)
  120 + }
  121 + }else {
  122 + this.rmhSelectedList.push(rmhInfo.creatorId)
  123 + }
  124 + }
  125 +}
  1 +import { RmhRecommendDTO } from 'wdBean';
  2 +import { ToastUtils } from 'wdKit/Index';
  3 +
  4 +@Component
  5 +export struct PeopleShipRecommendHeadComponent {
  6 + @State isSelected: boolean = true
  7 + @Consume rmhSelectedList: string[]
  8 + @State rmhInfo: RmhRecommendDTO = {} as RmhRecommendDTO
  9 +
  10 + build() {
  11 + Column(){
  12 + Stack({ alignContent: Alignment.BottomEnd }) {
  13 + Image(this.rmhInfo.headPhotoUrl.length > 0 ? this.rmhInfo.headPhotoUrl : $r('app.media.WDAccountOwnerHedaerDefaultIcon'))
  14 + .width('44vp')
  15 + .height('44vp')
  16 + .borderRadius('22vp')
  17 + .objectFit(ImageFit.Cover)
  18 +
  19 + Image( this.isSelectedRmhInfo() ? $r('app.media.rmh_selected') : $r('app.media.rmh_unselected') )
  20 + .width('18vp')
  21 + .height('18vp')
  22 + .objectFit(ImageFit.Cover)
  23 + .margin({
  24 + right: '-3vp'
  25 + })
  26 + }.margin({ top: 12, bottom: 8 })
  27 +
  28 + Text(this.rmhInfo.userName)
  29 + .fontColor($r('app.color.color_222222'))
  30 + .fontSize($r('app.float.vp_14'))
  31 + .fontWeight(600)
  32 + .maxLines(1)
  33 + .textOverflow({overflow: TextOverflow.Ellipsis})
  34 +
  35 + Text(this.rmhInfo.introduction)
  36 + .fontColor($r('app.color.color_B0B0B0'))
  37 + .fontSize($r('app.float.vp_12'))
  38 + .margin({ top: 8, bottom: 14 })
  39 + .textOverflow({overflow: TextOverflow.Ellipsis})
  40 + .maxLines(2)
  41 + .height(34)
  42 + }
  43 + .width('100%')
  44 + .height('116vp')
  45 +
  46 + }
  47 +
  48 + private isSelectedRmhInfo() {
  49 + if (this.rmhSelectedList.length > 0 && this.rmhInfo ) {
  50 + if (this.rmhSelectedList.indexOf(this.rmhInfo.creatorId) != -1) {
  51 + return true
  52 + }
  53 + }
  54 + return false
  55 + }
  56 +}
@@ -20,7 +20,6 @@ import { RefreshLayoutBean } from '../page/RefreshLayoutBean' @@ -20,7 +20,6 @@ import { RefreshLayoutBean } from '../page/RefreshLayoutBean'
20 import CustomRefreshLoadLayout from '../page/CustomRefreshLoadLayout' 20 import CustomRefreshLoadLayout from '../page/CustomRefreshLoadLayout'
21 import { ErrorComponent } from '../view/ErrorComponent'; 21 import { ErrorComponent } from '../view/ErrorComponent';
22 import NoMoreLayout from '../page/NoMoreLayout'; 22 import NoMoreLayout from '../page/NoMoreLayout';
23 -// import { LazyDataSource } from 'wdKit';  
24 import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh' 23 import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh'
25 24
26 const TAG = 'PeopleShipHomeArticleListComponent'; 25 const TAG = 'PeopleShipHomeArticleListComponent';
@@ -36,7 +36,7 @@ export struct PeopleShipHomePageNavComponent { @@ -36,7 +36,7 @@ export struct PeopleShipHomePageNavComponent {
36 PeopleShipHomePageHeadComponent({ 36 PeopleShipHomePageHeadComponent({
37 diameter: 30, 37 diameter: 30,
38 iconDiameter: 10, 38 iconDiameter: 10,
39 - headPhotoUrl: this.detailModel.headPhotoUrl, 39 + headPhotoUrl: (this.detailModel.headPhotoUrl && this.detailModel.headPhotoUrl.length > 0 ) ? this.detailModel.headPhotoUrl : $r('app.media.WDAccountOwnerHedaerDefaultIcon'),
40 authIcon: this.detailModel.authIcon 40 authIcon: this.detailModel.authIcon
41 }) 41 })
42 .margin({ 42 .margin({
@@ -2,13 +2,13 @@ @@ -2,13 +2,13 @@
2 export struct PeopleShipHomePageHeadComponent { 2 export struct PeopleShipHomePageHeadComponent {
3 @State diameter: number = 30 3 @State diameter: number = 30
4 @State iconDiameter: number = 10 4 @State iconDiameter: number = 10
5 - @Prop headPhotoUrl: string = '' 5 + @Prop headPhotoUrl: string | ResourceStr = ''
6 @Prop authIcon: string = '' 6 @Prop authIcon: string = ''
7 7
8 build() { 8 build() {
9 Stack({ alignContent: Alignment.BottomEnd }) { 9 Stack({ alignContent: Alignment.BottomEnd }) {
10 // 头像 10 // 头像
11 - Image( this.headPhotoUrl.length > 0 ? this.headPhotoUrl : $r('app.media.home_page_header_authority') ) 11 + Image( this.headPhotoUrl )
12 .width(this.diameter) 12 .width(this.diameter)
13 .height(this.diameter) 13 .height(this.diameter)
14 .borderRadius(this.diameter/2) 14 .borderRadius(this.diameter/2)
@@ -16,6 +16,7 @@ export struct PeopleShipHomePageHeadComponent { @@ -16,6 +16,7 @@ export struct PeopleShipHomePageHeadComponent {
16 .borderStyle(BorderStyle.Solid) 16 .borderStyle(BorderStyle.Solid)
17 .borderColor(Color.White) 17 .borderColor(Color.White)
18 .objectFit(ImageFit.Cover) 18 .objectFit(ImageFit.Cover)
  19 + .backgroundColor(Color.White)
19 if(this.authIcon.length > 0 ) { 20 if(this.authIcon.length > 0 ) {
20 Image( this.authIcon ) 21 Image( this.authIcon )
21 .width(this.iconDiameter) 22 .width(this.iconDiameter)
@@ -46,7 +46,7 @@ export struct PeopleShipHomePageTopComponent { @@ -46,7 +46,7 @@ export struct PeopleShipHomePageTopComponent {
46 PeopleShipHomePageHeadComponent({ 46 PeopleShipHomePageHeadComponent({
47 diameter: 80, 47 diameter: 80,
48 iconDiameter: 20, 48 iconDiameter: 20,
49 - headPhotoUrl: this.detailModel.headPhotoUrl, 49 + headPhotoUrl:(this.detailModel.headPhotoUrl && this.detailModel.headPhotoUrl.length > 0) ? this.detailModel.headPhotoUrl : $r('app.media.WDAccountOwnerHedaerDefaultIcon') ,
50 authIcon: this.detailModel.authIcon 50 authIcon: this.detailModel.authIcon
51 }).margin({ 51 }).margin({
52 left: '10vp', 52 left: '10vp',
1 import { Params } from 'wdBean'; 1 import { Params } from 'wdBean';
  2 +import { AppUtils, StringUtils } from 'wdKit/Index';
2 import { WDRouterPage, WDRouterRule } from 'wdRouter'; 3 import { WDRouterPage, WDRouterRule } from 'wdRouter';
3 import { EnvironmentCustomDialog } from './EnvironmentCustomDialog'; 4 import { EnvironmentCustomDialog } from './EnvironmentCustomDialog';
4 5
@@ -32,6 +33,10 @@ export struct AboutPageUI { @@ -32,6 +33,10 @@ export struct AboutPageUI {
32 aboutToAppear() { 33 aboutToAppear() {
33 let context = getContext(); 34 let context = getContext();
34 context.getApplicationContext(); 35 context.getApplicationContext();
  36 + let appVerion = AppUtils.getAppVersionName()
  37 + if (StringUtils.isNotEmpty(appVerion)) {
  38 + this.version = "版本号:" + appVerion
  39 + }
35 } 40 }
36 41
37 @Builder 42 @Builder
1 1
2 import { BottomNavi, CommonConstants, SpConstants } from 'wdConstant'; 2 import { BottomNavi, CommonConstants, SpConstants } from 'wdConstant';
3 -import { Logger, SPHelper, ToastUtils, UserDataLocal } from 'wdKit'; 3 +import { Logger, SPHelper, ToastUtils, UserDataLocal, EmitterEventId, EmitterUtils } from 'wdKit';
4 import { TopNavigationComponent } from '../page/TopNavigationComponent'; 4 import { TopNavigationComponent } from '../page/TopNavigationComponent';
5 import PageViewModel from '../../viewmodel/PageViewModel'; 5 import PageViewModel from '../../viewmodel/PageViewModel';
6 import {MineMainSettingFunctionItem} from '../../viewmodel/MineMainSettingFunctionItem'; 6 import {MineMainSettingFunctionItem} from '../../viewmodel/MineMainSettingFunctionItem';
@@ -430,7 +430,7 @@ export struct AccountAndSecurityLayout { @@ -430,7 +430,7 @@ export struct AccountAndSecurityLayout {
430 let login = new LoginViewModel; 430 let login = new LoginViewModel;
431 login.logOut().then(()=>{ 431 login.logOut().then(()=>{
432 promptAction.showToast({ message: '退出登录' }) 432 promptAction.showToast({ message: '退出登录' })
433 - router.back(); 433 + EmitterUtils.sendEvent(EmitterEventId.PEOPLE_SHIP_ATTENTION)
434 router.back(); 434 router.back();
435 }).catch((error:string)=>{ 435 }).catch((error:string)=>{
436 promptAction.showToast({ message: error }) 436 promptAction.showToast({ message: error })
@@ -110,7 +110,7 @@ export struct ENewspaperListDialog { @@ -110,7 +110,7 @@ export struct ENewspaperListDialog {
110 ListItem() { 110 ListItem() {
111 Column() { 111 Column() {
112 if (itemIndex == 0) { 112 if (itemIndex == 0) {
113 - Text(item.pageNum + item.pageName) 113 + Text(item.pageNum + '版:' + item.pageName)
114 .fontSize($r('app.float.font_size_14')) 114 .fontSize($r('app.float.font_size_14'))
115 .fontColor($r('app.color.color_ED2800')) 115 .fontColor($r('app.color.color_ED2800'))
116 .fontWeight(600) 116 .fontWeight(600)
@@ -130,6 +130,7 @@ export struct ENewspaperListDialog { @@ -130,6 +130,7 @@ export struct ENewspaperListDialog {
130 Text(positionItem.title) 130 Text(positionItem.title)
131 .fontSize($r('app.float.font_size_17')) 131 .fontSize($r('app.float.font_size_17'))
132 .fontColor($r('app.color.color_222222')) 132 .fontColor($r('app.color.color_222222'))
  133 + .fontWeight(600)
133 .margin({ top: 8 }) 134 .margin({ top: 8 })
134 .maxLines(2) 135 .maxLines(2)
135 } 136 }
@@ -172,9 +173,12 @@ export struct ENewspaperListDialog { @@ -172,9 +173,12 @@ export struct ENewspaperListDialog {
172 // } 173 // }
173 }) 174 })
174 } 175 }
175 -  
176 }) 176 })
177 } 177 }
  178 + .divider({
  179 + strokeWidth: 0.5,
  180 + color: '#EDEDED'
  181 + })
178 } 182 }
179 }) 183 })
180 } 184 }
@@ -4,7 +4,7 @@ import MinePageCreatorFunctionsItem from '../viewmodel/MinePageCreatorFunctionsI @@ -4,7 +4,7 @@ import MinePageCreatorFunctionsItem from '../viewmodel/MinePageCreatorFunctionsI
4 import MinePageMoreFunctionModel from '../viewmodel/MinePageMoreFunctionModel'; 4 import MinePageMoreFunctionModel from '../viewmodel/MinePageMoreFunctionModel';
5 import { HttpBizUtil, HttpUrlUtils, HttpUtils, ResponseDTO, WDHttp } from 'wdNetwork'; 5 import { HttpBizUtil, HttpUrlUtils, HttpUtils, ResponseDTO, WDHttp } from 'wdNetwork';
6 import { MineAppointmentListItem } from '../viewmodel/MineAppointmentListItem'; 6 import { MineAppointmentListItem } from '../viewmodel/MineAppointmentListItem';
7 -import { Logger, StringUtils } from 'wdKit'; 7 +import { Logger, StringUtils, EmitterUtils, EmitterEventId } from 'wdKit';
8 import { MineFollowListDetailItem } from '../viewmodel/MineFollowListDetailItem'; 8 import { MineFollowListDetailItem } from '../viewmodel/MineFollowListDetailItem';
9 import { FollowListDetailRequestItem } from '../viewmodel/FollowListDetailRequestItem'; 9 import { FollowListDetailRequestItem } from '../viewmodel/FollowListDetailRequestItem';
10 import { FollowListItem } from '../viewmodel/FollowListItem'; 10 import { FollowListItem } from '../viewmodel/FollowListItem';
@@ -545,6 +545,7 @@ class MinePageDatasModel{ @@ -545,6 +545,7 @@ class MinePageDatasModel{
545 return 545 return
546 } 546 }
547 Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp); 547 Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
  548 + EmitterUtils.sendEvent(EmitterEventId.PEOPLE_SHIP_ATTENTION)
548 success(navResDTO); 549 success(navResDTO);
549 }).catch((err: Error) => { 550 }).catch((err: Error) => {
550 Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`); 551 Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
@@ -182,13 +182,14 @@ struct MineHomePage { @@ -182,13 +182,14 @@ struct MineHomePage {
182 Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx') 182 Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
183 183
184 //tab 页面 184 //tab 页面
  185 + Stack({ alignContent: Alignment.Top }){
185 Tabs({controller: this.controller}) { 186 Tabs({controller: this.controller}) {
186 TabContent() { 187 TabContent() {
187 HomePageBottomComponent({style:0,commentNum:$commentNum}) 188 HomePageBottomComponent({style:0,commentNum:$commentNum})
188 - }.tabBar(this.TabBuilder(0,"评论")) 189 + }
189 TabContent() { 190 TabContent() {
190 HomePageBottomComponent({style:1,commentNum:$commentNum}) 191 HomePageBottomComponent({style:1,commentNum:$commentNum})
191 - }.tabBar(this.TabBuilder(1,"关注")) 192 + }
192 } 193 }
193 .backgroundColor($r('app.color.white')) 194 .backgroundColor($r('app.color.white'))
194 .animationDuration(0) 195 .animationDuration(0)
@@ -196,6 +197,32 @@ struct MineHomePage { @@ -196,6 +197,32 @@ struct MineHomePage {
196 this.currentIndex = index 197 this.currentIndex = index
197 }) 198 })
198 .vertical(false) 199 .vertical(false)
  200 + .barHeight("77lpx")
  201 +
  202 + Column() {
  203 + // 页签
  204 + Row({ space: 7 }) {
  205 + Scroll() {
  206 + Row() {
  207 + this.TabBuilder(0,"评论")
  208 + this.TabBuilder(1,"关注")
  209 + }
  210 + .justifyContent(FlexAlign.Start)
  211 + }
  212 + .align(Alignment.Start)
  213 + .scrollable(ScrollDirection.Horizontal)
  214 + .scrollBar(BarState.Off)
  215 + .width('100%')
  216 + .padding({left:'31lpx'})
  217 + }
  218 + .alignItems(VerticalAlign.Bottom)
  219 + .width('100%')
  220 + }
  221 + .backgroundColor($r('app.color.white'))
  222 + .alignItems(HorizontalAlign.Start)
  223 + .width('100%')
  224 + .height('77lpx')
  225 + }
199 }.width("100%") 226 }.width("100%")
200 } 227 }
201 .edgeEffect(EdgeEffect.None) 228 .edgeEffect(EdgeEffect.None)
@@ -341,9 +368,9 @@ struct MineHomePage { @@ -341,9 +368,9 @@ struct MineHomePage {
341 this.currentIndex = index 368 this.currentIndex = index
342 this.controller.changeIndex(this.currentIndex) 369 this.controller.changeIndex(this.currentIndex)
343 }) 370 })
344 - .height('100%')  
345 - .width('100%')  
346 - .margin({right:'9lpx'}) 371 + .height('77lpx')
  372 + .width('70lpx')
  373 + .margin({right:'29lpx'})
347 } 374 }
348 375
349 /** 376 /**
@@ -176,13 +176,14 @@ struct OtherNormalUserHomePage { @@ -176,13 +176,14 @@ struct OtherNormalUserHomePage {
176 Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx') 176 Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
177 177
178 //tab 页面 178 //tab 页面
  179 + Stack({ alignContent: Alignment.Top }){
179 Tabs({controller: this.controller}) { 180 Tabs({controller: this.controller}) {
180 TabContent() { 181 TabContent() {
181 OtherHomePageBottomCommentComponent({curUserId:this.curUserId,levelHead:this.levelHead,commentNum:$commentNum}) 182 OtherHomePageBottomCommentComponent({curUserId:this.curUserId,levelHead:this.levelHead,commentNum:$commentNum})
182 - }.tabBar(this.TabBuilder(0,"评论")) 183 + }
183 TabContent() { 184 TabContent() {
184 OtherHomePageBottomFollowComponent({curUserId:this.curUserId}) 185 OtherHomePageBottomFollowComponent({curUserId:this.curUserId})
185 - }.tabBar(this.TabBuilder(1,"关注")) 186 + }
186 } 187 }
187 .backgroundColor($r('app.color.white')) 188 .backgroundColor($r('app.color.white'))
188 .animationDuration(0) 189 .animationDuration(0)
@@ -190,6 +191,32 @@ struct OtherNormalUserHomePage { @@ -190,6 +191,32 @@ struct OtherNormalUserHomePage {
190 this.currentIndex = index 191 this.currentIndex = index
191 }) 192 })
192 .vertical(false) 193 .vertical(false)
  194 + .barHeight('77lpx')
  195 +
  196 + Column() {
  197 + // 页签
  198 + Row({ space: 7 }) {
  199 + Scroll() {
  200 + Row() {
  201 + this.TabBuilder(0,"评论")
  202 + this.TabBuilder(1,"关注")
  203 + }
  204 + .justifyContent(FlexAlign.Start)
  205 + }
  206 + .align(Alignment.Start)
  207 + .scrollable(ScrollDirection.Horizontal)
  208 + .scrollBar(BarState.Off)
  209 + .width('90%')
  210 + .padding({left:'31lpx'})
  211 + }
  212 + .alignItems(VerticalAlign.Bottom)
  213 + .width('100%')
  214 + }
  215 + .backgroundColor($r('app.color.white'))
  216 + .alignItems(HorizontalAlign.Start)
  217 + .width('100%')
  218 + .height('77lpx')
  219 + }
193 }.width("100%") 220 }.width("100%")
194 } 221 }
195 .edgeEffect(EdgeEffect.None) 222 .edgeEffect(EdgeEffect.None)
@@ -300,9 +327,9 @@ struct OtherNormalUserHomePage { @@ -300,9 +327,9 @@ struct OtherNormalUserHomePage {
300 this.currentIndex = index 327 this.currentIndex = index
301 this.controller.changeIndex(this.currentIndex) 328 this.controller.changeIndex(this.currentIndex)
302 }) 329 })
303 - .height('100%')  
304 - .width('100%')  
305 - .margin({right:'9lpx'}) 330 + .height('77lpx')
  331 + .width('70lpx')
  332 + .margin({right:'29lpx'})
306 } 333 }
307 334
308 335
1 import { HttpUrlUtils, HttpUtils, ResponseDTO, WDHttp } from 'wdNetwork'; 1 import { HttpUrlUtils, HttpUtils, ResponseDTO, WDHttp } from 'wdNetwork';
2 -import { DateTimeUtils, Logger, StringUtils } from 'wdKit'; 2 +import { DateTimeUtils, Logger, StringUtils, EmitterUtils, EmitterEventId } from 'wdKit';
  3 +
3 import { 4 import {
4 batchLikeAndCollectResult, 5 batchLikeAndCollectResult,
5 CompInfoBean, 6 CompInfoBean,
@@ -313,10 +314,32 @@ export class PageRepository { @@ -313,10 +314,32 @@ export class PageRepository {
313 /** 314 /**
314 * 关注号主 315 * 关注号主
315 */ 316 */
316 - static postInteractAccentionOperate(params: postInteractAccentionOperateParams): Promise<ResponseDTO> { 317 + private static postInteractAccentionOperateInfo(params: postInteractAccentionOperateParams): Promise<ResponseDTO> {
317 let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_ACCENTION_OPERATION 318 let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_ACCENTION_OPERATION
318 return WDHttp.post(url, params) 319 return WDHttp.post(url, params)
319 } 320 }
  321 + /**
  322 + * 关注号主
  323 + */
  324 + static postInteractAccentionOperate(params: postInteractAccentionOperateParams): Promise<ResponseDTO> {
  325 + return new Promise<ResponseDTO>((success, error) => {
  326 + Logger.debug(TAG, `postInteractAccentionOperate pageInfo start`);
  327 + PageRepository.postInteractAccentionOperateInfo(params)
  328 + .then((resDTO: ResponseDTO) => {
  329 + if (!resDTO || resDTO.code != 0) {
  330 + error(null)
  331 + return
  332 + }
  333 + Logger.debug(TAG, "postInteractAccentionOperate then,navResDTO.timestamp:" + resDTO.timestamp);
  334 + EmitterUtils.sendEvent(EmitterEventId.PEOPLE_SHIP_ATTENTION)
  335 + success(resDTO);
  336 + })
  337 + .catch((err: Error) => {
  338 + Logger.error(TAG, `postInteractAccentionOperate catch, error.name : ${err.name}, error.message:${err.message}`);
  339 + error(err);
  340 + })
  341 + })
  342 + }
320 343
321 static fetchNewspaperInfo(date: string) { 344 static fetchNewspaperInfo(date: string) {
322 let url = PageRepository.getNewspaperInfoUrl(date) 345 let url = PageRepository.getNewspaperInfoUrl(date)
@@ -29,9 +29,6 @@ export class LogoutViewModel{ @@ -29,9 +29,6 @@ export class LogoutViewModel{
29 SPHelper.default.saveSync(SpConstants.USER_Type, '') 29 SPHelper.default.saveSync(SpConstants.USER_Type, '')
30 SPHelper.default.saveSync(SpConstants.USER_NAME, '') 30 SPHelper.default.saveSync(SpConstants.USER_NAME, '')
31 SPHelper.default.saveSync(SpConstants.USER_PHONE, '') 31 SPHelper.default.saveSync(SpConstants.USER_PHONE, '')
32 - HttpUtils.setUserId("")  
33 - HttpUtils.setUserType("")  
34 - HttpUtils.setUserToken('')  
35 UserDataLocal.clearUserData() 32 UserDataLocal.clearUserData()
36 } 33 }
37 } 34 }
  1 +import { Logger } from 'wdKit';
  2 +import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
  3 +import HashMap from '@ohos.util.HashMap';
  4 +import {
  5 + RmhRecommendDTO,
  6 + PeopleShipContentListDTO,
  7 + AttentionBatchDTO
  8 +} from 'wdBean';
  9 +
  10 +const TAG = 'PeopleShipMainViewModel'
  11 +
  12 +export class PeopleShipMainViewModel {
  13 +
  14 + /*人民号号主推荐*/
  15 + static fetchPeopleRemRecommendData() {
  16 + let url = HttpUrlUtils.getRmhRecommendUrl()
  17 + let bean: Record<string, string> = {};
  18 + return WDHttp.post<ResponseDTO<RmhRecommendDTO[]>>(url, bean)
  19 + }
  20 +
  21 + static async getPeopleRemRecommendInfo(): Promise<RmhRecommendDTO[]> {
  22 + return new Promise<RmhRecommendDTO[]>((success, error) => {
  23 + Logger.debug(TAG, `getMorningEveningCompInfo pageInfo start`);
  24 + PeopleShipMainViewModel.fetchPeopleRemRecommendData()
  25 + .then((resDTO: ResponseDTO<RmhRecommendDTO[]>) => {
  26 + if (!resDTO || !resDTO.data) {
  27 + Logger.error(TAG, 'getPeopleRemRecommendInfo then navResDTO is empty');
  28 + error('resDTO is empty');
  29 + return
  30 + }
  31 + if (resDTO.code != 0) {
  32 + Logger.error(TAG, `getPeopleRemRecommendInfo then code:${resDTO.code}, message:${resDTO.message}`);
  33 + error('resDTO Response Code is failure');
  34 + return
  35 + }
  36 + Logger.debug(TAG, "getPeopleRemRecommendInfo then,navResDTO.timestamp:" + resDTO.timestamp);
  37 + success(resDTO.data);
  38 + })
  39 + .catch((err: Error) => {
  40 + Logger.error(TAG, `getPeopleRemRecommendInfo catch, error.name : ${err.name}, error.message:${err.message}`);
  41 + error(err);
  42 + })
  43 + })
  44 + }
  45 +
  46 + /*关注号主发布内容接口*/
  47 + static fetchAttentionContentListData(pageNum: number, pageSize: number, time: string) {
  48 + let url = HttpUrlUtils.getAttentionContentListUrl()
  49 + let params: Record<string, Object> = {};
  50 + params['pageNum'] = pageNum
  51 + params['pageSize'] = pageSize
  52 + params['time'] = time
  53 + return WDHttp.post<ResponseDTO<PeopleShipContentListDTO>>(url, params)
  54 + }
  55 +
  56 + static async getAttentionContentListInfo(pageNum:number, pageSize: number, time: string): Promise<PeopleShipContentListDTO> {
  57 + return new Promise<PeopleShipContentListDTO>((success, error) => {
  58 + Logger.debug(TAG, `getAttentionContentListInfo pageInfo start`);
  59 + PeopleShipMainViewModel.fetchAttentionContentListData(pageNum, pageSize, time)
  60 + .then((resDTO: ResponseDTO<PeopleShipContentListDTO>) => {
  61 + if (!resDTO || !resDTO.data) {
  62 + Logger.error(TAG, 'getAttentionContentListInfo then navResDTO is empty');
  63 + error('resDTO is empty');
  64 + return
  65 + }
  66 + if (resDTO.code != 0) {
  67 + Logger.error(TAG, `getAttentionContentListInfo then code:${resDTO.code}, message:${resDTO.message}`);
  68 + error('resDTO Response Code is failure');
  69 + return
  70 + }
  71 + Logger.debug(TAG, "getAttentionContentListInfo then,navResDTO.timestamp:" + resDTO.timestamp);
  72 + success(resDTO.data);
  73 + })
  74 + .catch((err: Error) => {
  75 + Logger.error(TAG, `getAttentionContentListInfo catch, error.name : ${err.name}, error.message:${err.message}`);
  76 + error(err);
  77 + })
  78 + })
  79 + }
  80 +
  81 + /*一键关注接口*/
  82 + static fetchAttentionBatchData(params: AttentionBatchDTO) {
  83 + let url = HttpUrlUtils.getAttentionBatchUrl()
  84 + return WDHttp.post<ResponseDTO>(url, params)
  85 + }
  86 +
  87 + static async getAttentionBatchInfo(params: AttentionBatchDTO): Promise<ResponseDTO> {
  88 + return new Promise<ResponseDTO>((success, error) => {
  89 + Logger.debug(TAG, `getAttentionBatchInfo pageInfo start`);
  90 + PeopleShipMainViewModel.fetchAttentionBatchData(params)
  91 + .then((resDTO: ResponseDTO) => {
  92 + if (!resDTO || resDTO.code != 0) {
  93 + error(resDTO.message)
  94 + return
  95 + }
  96 + Logger.debug(TAG, "getAttentionBatchInfo then,navResDTO.timestamp:" + resDTO.timestamp);
  97 + success(resDTO);
  98 + })
  99 + .catch((err: Error) => {
  100 + Logger.error(TAG, `getAttentionBatchInfo catch, error.name : ${err.name}, error.message:${err.message}`);
  101 + error(err);
  102 + })
  103 + })
  104 + }
  105 +
  106 +
  107 +}
@@ -57,6 +57,10 @@ @@ -57,6 +57,10 @@
57 "value": "-4vp" 57 "value": "-4vp"
58 }, 58 },
59 { 59 {
  60 + "name": "margin_6_negative",
  61 + "value": "-6vp"
  62 + },
  63 + {
60 "name": "main_margin", 64 "name": "main_margin",
61 "value": "14vp" 65 "value": "14vp"
62 }, 66 },
@@ -271,6 +275,14 @@ @@ -271,6 +275,14 @@
271 { 275 {
272 "name": "vp_14", 276 "name": "vp_14",
273 "value": "14vp" 277 "value": "14vp"
  278 + },
  279 + {
  280 + "name": "vp_18",
  281 + "value": "18vp"
  282 + },
  283 + {
  284 + "name": "vp_13",
  285 + "value": "13vp"
274 } 286 }
275 ] 287 ]
276 } 288 }
1 -import { Logger, ResourcesUtils } from 'wdKit'; 1 +import { Logger, ResourcesUtils, EmitterUtils, EmitterEventId } from 'wdKit';
2 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork'; 2 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
3 import { ContentDetailDTO, InteractDataDTO } from 'wdBean'; 3 import { ContentDetailDTO, InteractDataDTO } from 'wdBean';
4 import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; 4 import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
@@ -321,8 +321,32 @@ export class ContentDetailRequest { @@ -321,8 +321,32 @@ export class ContentDetailRequest {
321 /** 321 /**
322 * 关注号主 322 * 关注号主
323 */ 323 */
324 - static postInteractAccentionOperate(params: postInteractAccentionOperateParams): Promise<ResponseDTO> { 324 + private static postInteractAccentionOperateInfo(params: postInteractAccentionOperateParams): Promise<ResponseDTO> {
325 let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_ACCENTION_OPERATION 325 let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_ACCENTION_OPERATION
326 return WDHttp.post(url, params) 326 return WDHttp.post(url, params)
327 } 327 }
  328 +
  329 + /**
  330 + * 关注号主
  331 + */
  332 + static postInteractAccentionOperate(params: postInteractAccentionOperateParams): Promise<ResponseDTO> {
  333 + return new Promise<ResponseDTO>((success, error) => {
  334 + Logger.debug(TAG, `postInteractAccentionOperate pageInfo start`);
  335 + ContentDetailRequest.postInteractAccentionOperateInfo(params)
  336 + .then((resDTO: ResponseDTO) => {
  337 + if (!resDTO || resDTO.code != 0) {
  338 + error(null)
  339 + return
  340 + }
  341 + Logger.debug(TAG, "postInteractAccentionOperate then,navResDTO.timestamp:" + resDTO.timestamp);
  342 + // 关注号后发送-更新关注页面
  343 + EmitterUtils.sendEvent(EmitterEventId.PEOPLE_SHIP_ATTENTION)
  344 + success(resDTO);
  345 + })
  346 + .catch((err: Error) => {
  347 + Logger.error(TAG, `postInteractAccentionOperate catch, error.name : ${err.name}, error.message:${err.message}`);
  348 + error(err);
  349 + })
  350 + })
  351 + }
328 } 352 }
@@ -9,8 +9,6 @@ import { ResponseDTO } from 'wdNetwork/Index'; @@ -9,8 +9,6 @@ import { ResponseDTO } from 'wdNetwork/Index';
9 * 系统定位服务实现 9 * 系统定位服务实现
10 * */ 10 * */
11 export class HWLocationUtils { 11 export class HWLocationUtils {
12 -  
13 -  
14 static LOCATION: Permissions = 'ohos.permission.LOCATION' 12 static LOCATION: Permissions = 'ohos.permission.LOCATION'
15 static APPROXIMATELY_LOCATION: Permissions = 'ohos.permission.APPROXIMATELY_LOCATION' 13 static APPROXIMATELY_LOCATION: Permissions = 'ohos.permission.APPROXIMATELY_LOCATION'
16 14
@@ -115,17 +113,23 @@ export class HWLocationUtils { @@ -115,17 +113,23 @@ export class HWLocationUtils {
115 if (cityName == name) { 113 if (cityName == name) {
116 return 114 return
117 } 115 }
118 - let code = await HWLocationUtils.getCityCode(data[0].administrativeArea, data[0].subAdministrativeArea)  
119 - if (code) { 116 + // code=[省份code,城市code]
  117 + let code: string[] = await HWLocationUtils.getCityCode(data[0].administrativeArea, data[0].subAdministrativeArea)
  118 + if (code && code.length >= 2) {
120 SPHelper.default.save(SpConstants.LOCATION_CITY_NAME, cityName) 119 SPHelper.default.save(SpConstants.LOCATION_CITY_NAME, cityName)
121 - SPHelper.default.save(SpConstants.LOCATION_CITY_CODE, code) 120 + SPHelper.default.save(SpConstants.LOCATION_PROVINCE_CODE, code[0])
  121 + SPHelper.default.save(SpConstants.LOCATION_CITY_CODE, code[1])
  122 + }
  123 + if (data[0].descriptions && data[0].descriptions.length > 1) {
  124 + // 保存区县code,9位数字
  125 + let districtCode = data[0].descriptions[1] || ''
  126 + SPHelper.default.save(SpConstants.LOCATION_DISTRICT_CODE, districtCode)
122 } 127 }
123 } 128 }
124 } 129 }
125 }) 130 })
126 } 131 }
127 132
128 -  
129 //取消定位 133 //取消定位
130 static cancelLocation() { 134 static cancelLocation() {
131 // geoLocationManager.off('locationChange') 135 // geoLocationManager.off('locationChange')
@@ -143,10 +147,14 @@ export class HWLocationUtils { @@ -143,10 +147,14 @@ export class HWLocationUtils {
143 if (bean.code == 0 && bean.data) { 147 if (bean.code == 0 && bean.data) {
144 for (let i = 0; i < bean.data.length; i++) { 148 for (let i = 0; i < bean.data.length; i++) {
145 if (bean.data[i].label == administrativeArea) { 149 if (bean.data[i].label == administrativeArea) {
  150 + let str:string[] = []
  151 + let provinceCode = bean.data[i].code
  152 + str[0] = provinceCode
146 for (let j = 0; j < bean.data[i].children.length; j++) { 153 for (let j = 0; j < bean.data[i].children.length; j++) {
147 if (bean.data[i].children[j].label == cityName) { 154 if (bean.data[i].children[j].label == cityName) {
148 Logger.debug("huaw" + bean.data[i].children[j].code) 155 Logger.debug("huaw" + bean.data[i].children[j].code)
149 - return bean.data[i].children[j].code 156 + str[1] = bean.data[i].children[j].code
  157 + return str
150 } 158 }
151 } 159 }
152 } 160 }
@@ -155,7 +163,7 @@ export class HWLocationUtils { @@ -155,7 +163,7 @@ export class HWLocationUtils {
155 163
156 } 164 }
157 } 165 }
158 - return '' 166 + return []
159 } 167 }
160 168
161 // 通过省份code获取省份名称 169 // 通过省份code获取省份名称
@@ -37,7 +37,7 @@ export struct LoginInputComponent { @@ -37,7 +37,7 @@ export struct LoginInputComponent {
37 .type(InputType.PhoneNumber) 37 .type(InputType.PhoneNumber)
38 .onChange((content) => { 38 .onChange((content) => {
39 this.phoneContent = content 39 this.phoneContent = content
40 - this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 6) 40 + this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 4)
41 if (content.length >= 11) { 41 if (content.length >= 11) {
42 this.codeBtnState = true 42 this.codeBtnState = true
43 } else { 43 } else {
@@ -55,7 +55,7 @@ export struct LoginInputComponent { @@ -55,7 +55,7 @@ export struct LoginInputComponent {
55 .type(InputType.Number) 55 .type(InputType.Number)
56 .onChange((content) => { 56 .onChange((content) => {
57 this.phoneContent = content 57 this.phoneContent = content
58 - this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 6) 58 + this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 4)
59 if (content.length >= 11) { 59 if (content.length >= 11) {
60 this.codeBtnState = true 60 this.codeBtnState = true
61 } else { 61 } else {
@@ -78,7 +78,7 @@ export struct LoginInputComponent { @@ -78,7 +78,7 @@ export struct LoginInputComponent {
78 // .backgroundImageSize(ImageSize.Contain) 78 // .backgroundImageSize(ImageSize.Contain)
79 .onChange((value) => { 79 .onChange((value) => {
80 this.codeContent = value 80 this.codeContent = value
81 - this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 6) 81 + this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 4)
82 }) 82 })
83 83
84 Text(this.isCodeSend ? this.timeCount + "s" : this.isFirst?"发送验证码":'重新发送') 84 Text(this.isCodeSend ? this.timeCount + "s" : this.isFirst?"发送验证码":'重新发送')
@@ -13,9 +13,9 @@ export class LoginModel { @@ -13,9 +13,9 @@ export class LoginModel {
13 sendVerifyCode(number: string) { 13 sendVerifyCode(number: string) {
14 let bean: Record<string, string> = {}; 14 let bean: Record<string, string> = {};
15 bean['phoneNum'] = number 15 bean['phoneNum'] = number
16 - return new Promise<string>((success, fail) => {  
17 - HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.getVerifyCodeUrl(), bean).then((data: ResponseDTO<string>) => {  
18 - if (!data || !data.data) { 16 + return new Promise<object>((success, fail) => {
  17 + HttpRequest.post<ResponseDTO<object>>(HttpUrlUtils.getVerifyCodeUrl(), bean).then((data: ResponseDTO<object>) => {
  18 + if (!data) {
19 fail("数据为空") 19 fail("数据为空")
20 return 20 return
21 } 21 }
@@ -23,7 +23,7 @@ export class LoginModel { @@ -23,7 +23,7 @@ export class LoginModel {
23 fail(data.message) 23 fail(data.message)
24 return 24 return
25 } 25 }
26 - success(data.data) 26 + success(data)
27 }, (error: Error) => { 27 }, (error: Error) => {
28 fail(error.message) 28 fail(error.message)
29 Logger.debug("LoginViewModel:error ", error.toString()) 29 Logger.debug("LoginViewModel:error ", error.toString())
@@ -84,7 +84,11 @@ export class LoginModel { @@ -84,7 +84,11 @@ export class LoginModel {
84 // {"password":"523acd319228efde34e8a30268ee8ca5e4fc421d72affa531676e1765940d22c","phone":"13625644528","loginType":0,"oldPassword":"BA5FD74F827AF9B271FE17CADC489C36","deviceId":"60da5af6-9c59-3566-8622-8c6c00710994"} 84 // {"password":"523acd319228efde34e8a30268ee8ca5e4fc421d72affa531676e1765940d22c","phone":"13625644528","loginType":0,"oldPassword":"BA5FD74F827AF9B271FE17CADC489C36","deviceId":"60da5af6-9c59-3566-8622-8c6c00710994"}
85 appLoginByPassword(phone: string, loginType: number, password: string, oldPassword: string) { 85 appLoginByPassword(phone: string, loginType: number, password: string, oldPassword: string) {
86 let bean: Record<string, string | number> = {}; 86 let bean: Record<string, string | number> = {};
  87 + if (loginType == 0) {
87 bean['phone'] = phone 88 bean['phone'] = phone
  89 + } else {
  90 + bean['userName'] = phone
  91 + }
88 bean['loginType'] = loginType 92 bean['loginType'] = loginType
89 bean['deviceId'] = '60da5af6-9c59-3566-8622-8c6c00710994' 93 bean['deviceId'] = '60da5af6-9c59-3566-8622-8c6c00710994'
90 bean['password'] = password 94 bean['password'] = password
1 -import { Logger } from 'wdKit/src/main/ets/utils/Logger' 1 +import { Logger, EmitterEventId, EmitterUtils } from 'wdKit'
2 import { CustomProtocolDialog } from './CustomProtocolDialog' 2 import { CustomProtocolDialog } from './CustomProtocolDialog'
3 import router from '@ohos.router' 3 import router from '@ohos.router'
4 import { LoginViewModel } from './LoginViewModel' 4 import { LoginViewModel } from './LoginViewModel'
@@ -196,7 +196,6 @@ struct LoginPage { @@ -196,7 +196,6 @@ struct LoginPage {
196 Column() { 196 Column() {
197 TextInput({ placeholder: "请输入账号", controller: this.phoneController }) 197 TextInput({ placeholder: "请输入账号", controller: this.phoneController })
198 .fontSize(16) 198 .fontSize(16)
199 - .maxLength(11)  
200 .height(48) 199 .height(48)
201 .backgroundColor("#F5F5F5") 200 .backgroundColor("#F5F5F5")
202 .borderRadius(4) 201 .borderRadius(4)
@@ -325,6 +324,7 @@ struct LoginPage { @@ -325,6 +324,7 @@ struct LoginPage {
325 let interestsModel = new InterestsHobbiesModel() 324 let interestsModel = new InterestsHobbiesModel()
326 interestsModel.updateInterests() 325 interestsModel.updateInterests()
327 this.queryUserDetail() 326 this.queryUserDetail()
  327 + EmitterUtils.sendEvent(EmitterEventId.PEOPLE_SHIP_ATTENTION)
328 }).catch((error:string)=>{ 328 }).catch((error:string)=>{
329 promptAction.showToast({ message: error }) 329 promptAction.showToast({ message: error })
330 }) 330 })
@@ -332,11 +332,12 @@ struct LoginPage { @@ -332,11 +332,12 @@ struct LoginPage {
332 this.loginViewModel.appLoginByPassword(this.accountContent, 0, this.passwordContent, "").then((data) => { 332 this.loginViewModel.appLoginByPassword(this.accountContent, 0, this.passwordContent, "").then((data) => {
333 Logger.debug(TAG, "requestLogin: " + data.jwtToken) 333 Logger.debug(TAG, "requestLogin: " + data.jwtToken)
334 promptAction.showToast({ message: '登录成功' }) 334 promptAction.showToast({ message: '登录成功' })
335 -  
336 ///同步兴趣tag 335 ///同步兴趣tag
337 let interestsModel = new InterestsHobbiesModel() 336 let interestsModel = new InterestsHobbiesModel()
338 interestsModel.updateInterests() 337 interestsModel.updateInterests()
339 this.queryUserDetail() 338 this.queryUserDetail()
  339 + EmitterUtils.sendEvent(EmitterEventId.PEOPLE_SHIP_ATTENTION)
  340 +
340 // router.back({ 341 // router.back({
341 // params: { userName: data.userName, 342 // params: { userName: data.userName,
342 // userId:data.id}, 343 // userId:data.id},
1 import { Logger } from 'wdKit/src/main/ets/utils/Logger' 1 import { Logger } from 'wdKit/src/main/ets/utils/Logger'
2 import { LoginModel } from './LoginModel' 2 import { LoginModel } from './LoginModel'
3 import { LoginBean } from './LoginBean' 3 import { LoginBean } from './LoginBean'
4 -import { SPHelper } from 'wdKit' 4 +import { SPHelper, StringUtils } from 'wdKit'
5 import { CheckVerifyBean } from './CheckVerifyBean' 5 import { CheckVerifyBean } from './CheckVerifyBean'
6 import cryptoFramework from '@ohos.security.cryptoFramework' 6 import cryptoFramework from '@ohos.security.cryptoFramework'
7 import buffer from '@ohos.buffer' 7 import buffer from '@ohos.buffer'
@@ -22,7 +22,7 @@ export class LoginViewModel { @@ -22,7 +22,7 @@ export class LoginViewModel {
22 22
23 //发送验证码 23 //发送验证码
24 sendVerifyCode(number: string) { 24 sendVerifyCode(number: string) {
25 - return new Promise<string>((success, fail) => { 25 + return new Promise<object>((success, fail) => {
26 this.loginModel.sendVerifyCode(number).then((data) => { 26 this.loginModel.sendVerifyCode(number).then((data) => {
27 success(data) 27 success(data)
28 }).catch((message: string) => { 28 }).catch((message: string) => {
@@ -55,9 +55,6 @@ export class LoginViewModel { @@ -55,9 +55,6 @@ export class LoginViewModel {
55 SPHelper.default.saveSync(SpConstants.USER_STATUS, data.status) 55 SPHelper.default.saveSync(SpConstants.USER_STATUS, data.status)
56 SPHelper.default.saveSync(SpConstants.USER_Type, data.userType) 56 SPHelper.default.saveSync(SpConstants.USER_Type, data.userType)
57 SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName) 57 SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName)
58 - HttpUtils.setUserId(data.id+"")  
59 - HttpUtils.setUserType(data.userType+"")  
60 - HttpUtils.setUserToken(data.jwtToken)  
61 success(data) 58 success(data)
62 }).catch((error:string) => { 59 }).catch((error:string) => {
63 fail(error) 60 fail(error)
@@ -66,11 +63,17 @@ export class LoginViewModel { @@ -66,11 +63,17 @@ export class LoginViewModel {
66 } 63 }
67 64
68 async appLoginByPassword(phone: string, loginType: number, password: string, oldPassword: string) { 65 async appLoginByPassword(phone: string, loginType: number, password: string, oldPassword: string) {
69 - 66 + let newLoginType: number
  67 + let isPhone = this.verifyIsPhoneNumber(phone)
  68 + if (isPhone) {
  69 + newLoginType = 0;
  70 + } else {
  71 + newLoginType = 8;
  72 + }
70 return new Promise<LoginBean>(async (success, fail) => { 73 return new Promise<LoginBean>(async (success, fail) => {
71 let passwordNew = await this.doMd(password) 74 let passwordNew = await this.doMd(password)
72 Logger.debug(TAG, "PASSWORD:" + passwordNew) 75 Logger.debug(TAG, "PASSWORD:" + passwordNew)
73 - this.loginModel.appLoginByPassword(phone, loginType, passwordNew, oldPassword).then((data: LoginBean) => { 76 + this.loginModel.appLoginByPassword(phone, newLoginType, passwordNew, oldPassword).then((data: LoginBean) => {
74 SPHelper.default.saveSync(SpConstants.USER_FIRST_MARK, data.firstMark) 77 SPHelper.default.saveSync(SpConstants.USER_FIRST_MARK, data.firstMark)
75 SPHelper.default.saveSync(SpConstants.USER_ID, data.id) 78 SPHelper.default.saveSync(SpConstants.USER_ID, data.id)
76 SPHelper.default.saveSync(SpConstants.USER_JWT_TOKEN, data.jwtToken) 79 SPHelper.default.saveSync(SpConstants.USER_JWT_TOKEN, data.jwtToken)
@@ -79,9 +82,6 @@ export class LoginViewModel { @@ -79,9 +82,6 @@ export class LoginViewModel {
79 SPHelper.default.saveSync(SpConstants.USER_STATUS, data.status) 82 SPHelper.default.saveSync(SpConstants.USER_STATUS, data.status)
80 SPHelper.default.saveSync(SpConstants.USER_Type, data.userType) 83 SPHelper.default.saveSync(SpConstants.USER_Type, data.userType)
81 SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName) 84 SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName)
82 - HttpUtils.setUserId(data.id+"")  
83 - HttpUtils.setUserType(data.userType+"")  
84 - HttpUtils.setUserToken(data.jwtToken)  
85 success(data) 85 success(data)
86 }).catch((value: string) => { 86 }).catch((value: string) => {
87 fail(value) 87 fail(value)
@@ -157,9 +157,6 @@ export class LoginViewModel { @@ -157,9 +157,6 @@ export class LoginViewModel {
157 SPHelper.default.saveSync(SpConstants.USER_STATUS, '') 157 SPHelper.default.saveSync(SpConstants.USER_STATUS, '')
158 SPHelper.default.saveSync(SpConstants.USER_Type, '') 158 SPHelper.default.saveSync(SpConstants.USER_Type, '')
159 SPHelper.default.saveSync(SpConstants.USER_NAME, '') 159 SPHelper.default.saveSync(SpConstants.USER_NAME, '')
160 - HttpUtils.setUserId("")  
161 - HttpUtils.setUserType("")  
162 - HttpUtils.setUserToken('')  
163 success(data) 160 success(data)
164 }).catch((message: string) => { 161 }).catch((message: string) => {
165 fail(message) 162 fail(message)
@@ -234,4 +231,18 @@ export class LoginViewModel { @@ -234,4 +231,18 @@ export class LoginViewModel {
234 }) 231 })
235 }) 232 })
236 } 233 }
  234 +
  235 +
  236 + public verifyIsPhoneNumber(phone: string): boolean {
  237 + const regex = /^1[3-9]\d{9}$/;
  238 + let isMatch: boolean;
  239 + if (StringUtils.isEmpty(phone)) {
  240 + return false;
  241 + } else if (phone.length != 11) {
  242 + return false;
  243 + } else {
  244 + isMatch = regex.test(phone)
  245 + }
  246 + return isMatch;
  247 + }
237 } 248 }