张善主

Merge remote-tracking branch 'origin/main'

Showing 24 changed files with 159 additions and 147 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
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() 30 + if (HttpUtils.isLogin()) {
  31 + headers['RMRB-X-TOKEN'] = HttpUtils.getUserToken()
  32 + headers['cookie'] = 'RMRB-X-TOKEN=' + HttpUtils.getUserToken()
  33 + headers['userId'] = HttpUtils.getUserId()
  34 + headers['userType'] = HttpUtils.getUserType()
33 } 35 }
34 - headers['userId'] = HttpUtils.getUserId()  
35 - headers['userType'] = HttpUtils.getUserType()  
36 - headers['mpassid'] = 'ZbHTMeTsfaYDAHqt8ZHIzcPs'  
37 HttpParams.addSpecialHeaders(headers); 36 HttpParams.addSpecialHeaders(headers);
38 return headers; 37 return headers;
39 } 38 }
@@ -46,10 +46,6 @@ export class HttpUrlUtils { @@ -46,10 +46,6 @@ export class HttpUrlUtils {
46 */ 46 */
47 static readonly INTERACT_EXECUTELIKE: string = "/api/rmrb-interact/interact/zh/c/like/executeLike"; 47 static readonly INTERACT_EXECUTELIKE: string = "/api/rmrb-interact/interact/zh/c/like/executeLike";
48 /** 48 /**
49 - * 收藏、取消收藏  
50 - */  
51 - static readonly INTERACT_EXECUTECOLLECTRECORD: string = "/api/rmrb-interact/interact/zh/c/collect/executeCollcetRecord";  
52 - /**  
53 * 关注号主 49 * 关注号主
54 */ 50 */
55 static readonly INTERACT_ACCENTION_OPERATION: string = "/api/rmrb-interact/interact/zh/c/attention/operation"; 51 static readonly INTERACT_ACCENTION_OPERATION: string = "/api/rmrb-interact/interact/zh/c/attention/operation";
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;  
92 - }  
93 -  
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 '' 62 + return SPHelper.default.getSync(SpConstants.USER_Type, "") as string
103 } 63 }
104 64
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;  
112 - }  
113 -  
114 - public static setUserToken(token: string) {  
115 - HttpUtils.token = token; 69 + public static isLogin(): boolean {
  70 + let token = HttpUtils.getUserToken()
  71 + if (token == null || token == undefined || token.length <= 0) {
  72 + return false
  73 + }
  74 + return true
116 } 75 }
117 } 76 }
@@ -2,11 +2,11 @@ @@ -2,11 +2,11 @@
2 * 批查接口查询互动相关数据,返回数据bean 2 * 批查接口查询互动相关数据,返回数据bean
3 */ 3 */
4 export interface InteractDataDTO { 4 export interface InteractDataDTO {
5 - collectNum: number | String;  
6 - commentNum: number | String; 5 + collectNum: number | string;
  6 + commentNum: number | string;
7 contentId: string; 7 contentId: string;
8 contentType: number; 8 contentType: number;
9 - likeNum: number | String; 9 + likeNum: number | string;
10 readNum: number; 10 readNum: number;
11 shareNum: number; 11 shareNum: number;
12 } 12 }
@@ -38,7 +38,7 @@ export struct ImageAndTextPageComponent { @@ -38,7 +38,7 @@ export struct ImageAndTextPageComponent {
38 @State interactData: InteractDataDTO = {} as InteractDataDTO 38 @State interactData: InteractDataDTO = {} as InteractDataDTO
39 @State isPageEnd: boolean = false 39 @State isPageEnd: boolean = false
40 @State publishTime: string = '' 40 @State publishTime: string = ''
41 - @State publishCommentModel: publishCommentModel = {} as publishCommentModel 41 + @State publishCommentModel: publishCommentModel = new publishCommentModel()
42 42
43 build() { 43 build() {
44 Column() { 44 Column() {
@@ -142,7 +142,10 @@ export struct ImageAndTextPageComponent { @@ -142,7 +142,10 @@ export struct ImageAndTextPageComponent {
142 142
143 //底部交互区 143 //底部交互区
144 if (this.contentDetailData?.length) { 144 if (this.contentDetailData?.length) {
145 - OperRowListView({ contentDetailData: this.contentDetailData[0] }) 145 + OperRowListView({
  146 + contentDetailData: this.contentDetailData[0],
  147 + publishCommentModel: this.publishCommentModel
  148 + })
146 } 149 }
147 } 150 }
148 151
@@ -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 }
@@ -3,10 +3,12 @@ @@ -3,10 +3,12 @@
3 */ 3 */
4 import { RmhInfoDTO } from 'wdBean' 4 import { RmhInfoDTO } from 'wdBean'
5 import { CommonConstants } from 'wdConstant/Index'; 5 import { CommonConstants } from 'wdConstant/Index';
  6 +import { DateTimeUtils } from 'wdKit';
6 7
7 @Component 8 @Component
8 export struct RmhTitle { 9 export struct RmhTitle {
9 @Prop rmhInfo: RmhInfoDTO 10 @Prop rmhInfo: RmhInfoDTO
  11 + @Prop publishTime: string | undefined
10 12
11 build() { 13 build() {
12 Flex() { 14 Flex() {
@@ -29,12 +31,22 @@ export struct RmhTitle { @@ -29,12 +31,22 @@ export struct RmhTitle {
29 .fontColor($r('app.color.color_222222')) 31 .fontColor($r('app.color.color_222222'))
30 .fontWeight(600) 32 .fontWeight(600)
31 .alignSelf(ItemAlign.Start) 33 .alignSelf(ItemAlign.Start)
32 - Text(this.rmhInfo.rmhDesc)  
33 - .fontSize($r("app.float.font_size_12"))  
34 - .fontColor($r("app.color.color_B0B0B0"))  
35 - .maxLines(1)  
36 - .alignSelf(ItemAlign.Start)  
37 - .textOverflow({ overflow: TextOverflow.Ellipsis }) 34 + Row() {
  35 + if (this.publishTime) {
  36 + Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.publishTime)))
  37 + .fontSize($r("app.float.font_size_12"))
  38 + .fontColor($r("app.color.color_B0B0B0"))
  39 + Image($r('app.media.point'))
  40 + .width(16)
  41 + .height(16)
  42 + }
  43 + Text(this.rmhInfo.rmhDesc)
  44 + .fontSize($r("app.float.font_size_12"))
  45 + .fontColor($r("app.color.color_B0B0B0"))
  46 + .maxLines(1)
  47 + .alignSelf(ItemAlign.Start)
  48 + .textOverflow({ overflow: TextOverflow.Ellipsis })
  49 + }
38 } 50 }
39 51
40 Blank() 52 Blank()
@@ -20,7 +20,7 @@ export struct Card12Component { @@ -20,7 +20,7 @@ export struct Card12Component {
20 Column() { 20 Column() {
21 // rmh信息 21 // rmh信息
22 if (this.contentDTO.rmhInfo) { 22 if (this.contentDTO.rmhInfo) {
23 - RmhTitle({ rmhInfo: this.contentDTO.rmhInfo }) 23 + RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
24 } 24 }
25 // 标题 25 // 标题
26 if (this.contentDTO.newsTitle) { 26 if (this.contentDTO.newsTitle) {
@@ -52,7 +52,7 @@ export struct Card14Component { @@ -52,7 +52,7 @@ export struct Card14Component {
52 Column() { 52 Column() {
53 // rmh信息 53 // rmh信息
54 if (this.contentDTO.rmhInfo) { 54 if (this.contentDTO.rmhInfo) {
55 - RmhTitle({ rmhInfo: this.contentDTO.rmhInfo }) 55 + RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
56 } 56 }
57 // 左标题,右图 57 // 左标题,右图
58 Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween }) { 58 Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween }) {
@@ -58,7 +58,7 @@ export struct Card15Component { @@ -58,7 +58,7 @@ export struct Card15Component {
58 build() { 58 build() {
59 Column() { 59 Column() {
60 // rmh信息 60 // rmh信息
61 - RmhTitle({ rmhInfo: this.contentDTO.rmhInfo }) 61 + RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
62 //新闻标题 62 //新闻标题
63 if (this.contentDTO.newsTitle) { 63 if (this.contentDTO.newsTitle) {
64 Text(this.contentDTO.newsTitle) 64 Text(this.contentDTO.newsTitle)
@@ -25,7 +25,7 @@ export struct Card16Component { @@ -25,7 +25,7 @@ export struct Card16Component {
25 Column() { 25 Column() {
26 // rmh信息 26 // rmh信息
27 if (this.contentDTO.rmhInfo) { 27 if (this.contentDTO.rmhInfo) {
28 - RmhTitle({ rmhInfo: this.contentDTO.rmhInfo }) 28 + RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
29 } 29 }
30 // 标题 30 // 标题
31 if (this.contentDTO.newsTitle) { 31 if (this.contentDTO.newsTitle) {
@@ -77,7 +77,7 @@ export struct Card19Component { @@ -77,7 +77,7 @@ export struct Card19Component {
77 build() { 77 build() {
78 Column() { 78 Column() {
79 // rmh信息 79 // rmh信息
80 - RmhTitle({ rmhInfo: this.contentDTO.rmhInfo }) 80 + RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
81 // 标题 81 // 标题
82 if (this.contentDTO.newsTitle) { 82 if (this.contentDTO.newsTitle) {
83 Text(this.contentDTO.newsTitle) 83 Text(this.contentDTO.newsTitle)
@@ -50,7 +50,7 @@ export struct Card20Component { @@ -50,7 +50,7 @@ export struct Card20Component {
50 build() { 50 build() {
51 Column() { 51 Column() {
52 // rmh信息 52 // rmh信息
53 - RmhTitle({ rmhInfo: this.contentDTO.rmhInfo }) 53 + RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
54 // 标题 54 // 标题
55 if (this.contentDTO.newsTitle) { 55 if (this.contentDTO.newsTitle) {
56 Text(this.contentDTO.newsTitle) 56 Text(this.contentDTO.newsTitle)
@@ -16,7 +16,7 @@ export struct Card21Component { @@ -16,7 +16,7 @@ export struct Card21Component {
16 build() { 16 build() {
17 Column() { 17 Column() {
18 // 顶部 rmh信息 18 // 顶部 rmh信息
19 - RmhTitle({ rmhInfo: this.contentDTO.rmhInfo }) 19 + RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
20 // 中间内容 20 // 中间内容
21 Grid() { 21 Grid() {
22 GridItem() { 22 GridItem() {
@@ -6,7 +6,7 @@ import { ProcessUtils } from 'wdRouter'; @@ -6,7 +6,7 @@ import { ProcessUtils } from 'wdRouter';
6 import { HttpUtils } from 'wdNetwork/Index'; 6 import { HttpUtils } from 'wdNetwork/Index';
7 7
8 /** 8 /**
9 - * 小视频横划 9 + * 直播预约
10 * Zh_Single_Row-02 10 * Zh_Single_Row-02
11 */ 11 */
12 const TAG = 'Zh_Single_Row-03' 12 const TAG = 'Zh_Single_Row-03'
@@ -42,7 +42,7 @@ export struct ZhSingleRow03 { @@ -42,7 +42,7 @@ export struct ZhSingleRow03 {
42 Row() { 42 Row() {
43 Flex({justifyContent: FlexAlign.SpaceBetween}){ 43 Flex({justifyContent: FlexAlign.SpaceBetween}){
44 Row() { 44 Row() {
45 - Text(item.liveInfo.liveStartTime.split(' ')[0].slice(5)) 45 + Text(item.liveInfo.liveStartTime.split(' ')[0].slice(5).split('-').join('月')+'日')
46 .margin({right: 6}) 46 .margin({right: 6})
47 .fontColor(0x000000) 47 .fontColor(0x000000)
48 .fontSize(13) 48 .fontSize(13)
@@ -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 + "评")  
433 - .fontSize(12)  
434 - .fontColor(Color.Gray)  
435 - .margin({ left: 22 }) 459 + Row() {
  460 + Text(this.item?.source)
  461 + .fontSize(12)
  462 + .fontColor(Color.Gray)
  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 }
@@ -30,21 +30,21 @@ const TAG = 'OperRowListView'; @@ -30,21 +30,21 @@ const TAG = 'OperRowListView';
30 * comment--评论;like--点赞;collect--收藏;share--分享; 30 * comment--评论;like--点赞;collect--收藏;share--分享;
31 * 31 *
32 * 传值示例: 32 * 传值示例:
33 - OperRowListView({  
34 - contentDetailData: this.contentDetailData[0],  
35 - operationButtonList: ['comment', 'like', 'collect', 'share']  
36 - }) 33 + OperRowListView({
  34 + contentDetailData: this.contentDetailData[0],
  35 + operationButtonList: ['comment', 'like', 'collect', 'share']
  36 + })
37 */ 37 */
38 @Preview 38 @Preview
39 @Component 39 @Component
40 export struct OperRowListView { 40 export struct OperRowListView {
41 @Prop contentDetailData: ContentDetailDTO // 稿件详情 41 @Prop contentDetailData: ContentDetailDTO // 稿件详情
42 @State operationButtonList: string[] = ['comment', 'like', 'collect', 'share'] // 组件展示条件 42 @State operationButtonList: string[] = ['comment', 'like', 'collect', 'share'] // 组件展示条件
  43 + @Prop publishCommentModel: publishCommentModel
43 // @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO 44 // @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
44 @State interactData: InteractDataDTO = {} as InteractDataDTO 45 @State interactData: InteractDataDTO = {} as InteractDataDTO
45 @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 46 @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
46 @State likeBean: Record<string, string> = {} 47 @State likeBean: Record<string, string> = {}
47 - @State publishCommentModel: publishCommentModel = new publishCommentModel()  
48 48
49 async aboutToAppear() { 49 async aboutToAppear() {
50 const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') 50 const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
@@ -62,13 +62,13 @@ export struct OperRowListView { @@ -62,13 +62,13 @@ export struct OperRowListView {
62 console.info(TAG, 'contentDetailData----', JSON.stringify(this.contentDetailData)) 62 console.info(TAG, 'contentDetailData----', JSON.stringify(this.contentDetailData))
63 console.info(TAG, 'likeBean----', JSON.stringify(this.likeBean)) 63 console.info(TAG, 'likeBean----', JSON.stringify(this.likeBean))
64 // 评论需要数据 64 // 评论需要数据
65 - this.publishCommentModel.targetId = this.contentDetailData.newsId + ''  
66 - this.publishCommentModel.targetRelId = this.contentDetailData.reLInfo?.relId + ''  
67 - this.publishCommentModel.targetTitle = this.contentDetailData.newsTitle + ''  
68 - this.publishCommentModel.targetRelType = this.contentDetailData.reLInfo?.relType + ''  
69 - this.publishCommentModel.targetRelObjectId = this.contentDetailData.reLInfo?.relObjectId + ''  
70 - this.publishCommentModel.keyArticle = this.contentDetailData.keyArticle + ''  
71 - this.publishCommentModel.targetType = this.contentDetailData.newsType + '' 65 + /* this.publishCommentModel.targetId = this.contentDetailData.newsId + ''
  66 + this.publishCommentModel.targetRelId = this.contentDetailData.reLInfo?.relId + ''
  67 + this.publishCommentModel.targetTitle = this.contentDetailData.newsTitle + ''
  68 + this.publishCommentModel.targetRelType = this.contentDetailData.reLInfo?.relType + ''
  69 + this.publishCommentModel.targetRelObjectId = this.contentDetailData.reLInfo?.relObjectId + ''
  70 + this.publishCommentModel.keyArticle = this.contentDetailData.keyArticle + ''
  71 + this.publishCommentModel.targetType = this.contentDetailData.newsType + ''*/
72 } 72 }
73 73
74 build() { 74 build() {
@@ -232,7 +232,6 @@ export struct OperRowListView { @@ -232,7 +232,6 @@ export struct OperRowListView {
232 232
233 } 233 }
234 PageRepository.postExecuteCollectRecord(params).then(res => { 234 PageRepository.postExecuteCollectRecord(params).then(res => {
235 - // console.log(TAG, '收藏、取消收藏', 'toggleLikeStatus==',)  
236 if (this.newsStatusOfUser) { 235 if (this.newsStatusOfUser) {
237 this.newsStatusOfUser.collectStatus = this.newsStatusOfUser?.collectStatus === 1 ? 0 : 1 236 this.newsStatusOfUser.collectStatus = this.newsStatusOfUser?.collectStatus === 1 ? 0 : 1
238 this.queryContentInteractCount() 237 this.queryContentInteractCount()
@@ -258,7 +257,9 @@ export struct OperRowListView { @@ -258,7 +257,9 @@ export struct OperRowListView {
258 this.interactData.collectNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.collectNum) 257 this.interactData.collectNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.collectNum)
259 this.interactData.commentNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.commentNum) 258 this.interactData.commentNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.commentNum)
260 // 评论组件需要数据 259 // 评论组件需要数据
261 - this.publishCommentModel.totalCommentNumer = this.interactData.commentNum + '' || '0' 260 + if (Number.parseInt(this.interactData.commentNum) > Number.parseInt(this.publishCommentModel.totalCommentNumer)) {
  261 + this.publishCommentModel.totalCommentNumer = this.interactData.commentNum + '' || '0'
  262 + }
262 } 263 }
263 // console.log(TAG, '获取互动点赞等数据===', JSON.stringify(res)) 264 // console.log(TAG, '获取互动点赞等数据===', JSON.stringify(res))
264 console.log(TAG, 'this.interactData', JSON.stringify(this.interactData)) 265 console.log(TAG, 'this.interactData', JSON.stringify(this.interactData))
@@ -283,7 +283,7 @@ export class PageRepository { @@ -283,7 +283,7 @@ export class PageRepository {
283 * @returns 283 * @returns
284 */ 284 */
285 static postExecuteCollectRecord(params: postExecuteCollectRecordParams): Promise<ResponseDTO> { 285 static postExecuteCollectRecord(params: postExecuteCollectRecordParams): Promise<ResponseDTO> {
286 - let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTECOLLECTRECORD 286 + let url = HttpUrlUtils.getExecuteCollcetUrl()
287 return WDHttp.post(url, params) 287 return WDHttp.post(url, params)
288 } 288 }
289 289
@@ -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 }
@@ -288,7 +288,7 @@ export class ContentDetailRequest { @@ -288,7 +288,7 @@ export class ContentDetailRequest {
288 * @returns 288 * @returns
289 */ 289 */
290 static postExecuteCollectRecord(params: postExecuteCollectRecordParams): Promise<ResponseDTO> { 290 static postExecuteCollectRecord(params: postExecuteCollectRecordParams): Promise<ResponseDTO> {
291 - let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTECOLLECTRECORD 291 + let url = HttpUrlUtils.getExecuteCollcetUrl()
292 return WDHttp.post(url, params) 292 return WDHttp.post(url, params)
293 } 293 }
294 294
@@ -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获取省份名称
@@ -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)
@@ -85,9 +82,6 @@ export class LoginViewModel { @@ -85,9 +82,6 @@ export class LoginViewModel {
85 SPHelper.default.saveSync(SpConstants.USER_STATUS, data.status) 82 SPHelper.default.saveSync(SpConstants.USER_STATUS, data.status)
86 SPHelper.default.saveSync(SpConstants.USER_Type, data.userType) 83 SPHelper.default.saveSync(SpConstants.USER_Type, data.userType)
87 SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName) 84 SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName)
88 - HttpUtils.setUserId(data.id+"")  
89 - HttpUtils.setUserType(data.userType+"")  
90 - HttpUtils.setUserToken(data.jwtToken)  
91 success(data) 85 success(data)
92 }).catch((value: string) => { 86 }).catch((value: string) => {
93 fail(value) 87 fail(value)
@@ -163,9 +157,6 @@ export class LoginViewModel { @@ -163,9 +157,6 @@ export class LoginViewModel {
163 SPHelper.default.saveSync(SpConstants.USER_STATUS, '') 157 SPHelper.default.saveSync(SpConstants.USER_STATUS, '')
164 SPHelper.default.saveSync(SpConstants.USER_Type, '') 158 SPHelper.default.saveSync(SpConstants.USER_Type, '')
165 SPHelper.default.saveSync(SpConstants.USER_NAME, '') 159 SPHelper.default.saveSync(SpConstants.USER_NAME, '')
166 - HttpUtils.setUserId("")  
167 - HttpUtils.setUserType("")  
168 - HttpUtils.setUserToken('')  
169 success(data) 160 success(data)
170 }).catch((message: string) => { 161 }).catch((message: string) => {
171 fail(message) 162 fail(message)