zhenghy

Merge remote-tracking branch 'origin/main'

Showing 25 changed files with 453 additions and 83 deletions
@@ -47,4 +47,5 @@ export class SpConstants{ @@ -47,4 +47,5 @@ export class SpConstants{
47 47
48 //游客状态下首次评论时间 48 //游客状态下首次评论时间
49 static FIRSTCOMMENTTIME = 'firstCommentTime' 49 static FIRSTCOMMENTTIME = 'firstCommentTime'
  50 + static TOURIST_NICK_NAME = 'touristNickName'
50 } 51 }
@@ -742,4 +742,8 @@ export class HttpUrlUtils { @@ -742,4 +742,8 @@ export class HttpUrlUtils {
742 return url 742 return url
743 } 743 }
744 744
745 -}  
  745 + static reportDeviceInfo() {
  746 + let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/common/user/c/device/push";
  747 + return url;
  748 + }
  749 +}
@@ -55,7 +55,7 @@ export struct WdWebLocalComponent { @@ -55,7 +55,7 @@ export struct WdWebLocalComponent {
55 .mixedMode(MixedMode.All) 55 .mixedMode(MixedMode.All)
56 .onlineImageAccess(true) 56 .onlineImageAccess(true)
57 .enableNativeEmbedMode(true) 57 .enableNativeEmbedMode(true)
58 - .layoutMode(WebLayoutMode.FIT_CONTENT) 58 + // .layoutMode(WebLayoutMode.FIT_CONTENT)
59 // .nestedScroll({ scrollForward: NestedScrollMode.SELF_FIRST, scrollBackward: NestedScrollMode.PARENT_FIRST }) 59 // .nestedScroll({ scrollForward: NestedScrollMode.SELF_FIRST, scrollBackward: NestedScrollMode.PARENT_FIRST })
60 .height(this.webHeight) 60 .height(this.webHeight)
61 .onPageBegin((event) => { 61 .onPageBegin((event) => {
@@ -69,6 +69,7 @@ export struct DynamicDetailComponent { @@ -69,6 +69,7 @@ export struct DynamicDetailComponent {
69 @State isNetConnected: boolean = true 69 @State isNetConnected: boolean = true
70 @State isPageEnd: boolean = false 70 @State isPageEnd: boolean = false
71 @State publishCommentModel: publishCommentModel = new publishCommentModel() 71 @State publishCommentModel: publishCommentModel = new publishCommentModel()
  72 + @State reachEndIncreament: number = 0
72 73
73 async aboutToAppear() { 74 async aboutToAppear() {
74 await this.getContentDetailData() 75 await this.getContentDetailData()
@@ -709,4 +710,4 @@ interface radiusType { @@ -709,4 +710,4 @@ interface radiusType {
709 topRight: number | Resource; 710 topRight: number | Resource;
710 bottomLeft: number | Resource; 711 bottomLeft: number | Resource;
711 bottomRight: number | Resource; 712 bottomRight: number | Resource;
712 -}  
  713 +}
@@ -52,6 +52,7 @@ export struct ImageAndTextPageComponent { @@ -52,6 +52,7 @@ export struct ImageAndTextPageComponent {
52 @State isNetConnected: boolean = true 52 @State isNetConnected: boolean = true
53 @State info: Area | null = null 53 @State info: Area | null = null
54 @State likeNum: number = 0 54 @State likeNum: number = 0
  55 + @State reachEndIncreament : number = 0
55 56
56 build() { 57 build() {
57 Column() { 58 Column() {
@@ -141,7 +142,12 @@ export struct ImageAndTextPageComponent { @@ -141,7 +142,12 @@ export struct ImageAndTextPageComponent {
141 if (this.contentDetailData?.openComment) { 142 if (this.contentDetailData?.openComment) {
142 Divider().strokeWidth(6).color('#f5f5f5') 143 Divider().strokeWidth(6).color('#f5f5f5')
143 CommentComponent({ 144 CommentComponent({
144 - publishCommentModel: this.publishCommentModel 145 + publishCommentModel: this.publishCommentModel,
  146 + fixedHeightMode: false,
  147 + reachEndIncreament: this.reachEndIncreament,
  148 + reachEndLoadMoreFinish: () => {
  149 +
  150 + }
145 }).onAreaChange((oldValue: Area, newValue: Area) => { 151 }).onAreaChange((oldValue: Area, newValue: Area) => {
146 this.info = newValue 152 this.info = newValue
147 }) 153 })
@@ -157,6 +163,9 @@ export struct ImageAndTextPageComponent { @@ -157,6 +163,9 @@ export struct ImageAndTextPageComponent {
157 .padding({ bottom: 76 }) 163 .padding({ bottom: 76 })
158 .scrollBar(BarState.Off) 164 .scrollBar(BarState.Off)
159 .align(Alignment.Top) 165 .align(Alignment.Top)
  166 + .onReachEnd(() => {
  167 + this.reachEndIncreament += 1
  168 + })
160 169
161 if (!this.isNetConnected) { 170 if (!this.isNetConnected) {
162 EmptyComponent({ 171 EmptyComponent({
@@ -228,6 +237,7 @@ export struct ImageAndTextPageComponent { @@ -228,6 +237,7 @@ export struct ImageAndTextPageComponent {
228 this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId) 237 this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId)
229 this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle) 238 this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle)
230 this.publishCommentModel.targetType = String(this.contentDetailData?.newsType) 239 this.publishCommentModel.targetType = String(this.contentDetailData?.newsType)
  240 + this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment)
231 } 241 }
232 if (this.contentDetailData?.openAudio && this.contentDetailData?.audioList?.length && 242 if (this.contentDetailData?.openAudio && this.contentDetailData?.audioList?.length &&
233 this.contentDetailData?.audioList[0].audioUrl) { 243 this.contentDetailData?.audioList[0].audioUrl) {
@@ -340,4 +350,4 @@ export struct ImageAndTextPageComponent { @@ -340,4 +350,4 @@ export struct ImageAndTextPageComponent {
340 350
341 aboutToDisappear() { 351 aboutToDisappear() {
342 } 352 }
343 -}  
  353 +}
@@ -449,6 +449,7 @@ export struct MultiPictureDetailPageComponent { @@ -449,6 +449,7 @@ export struct MultiPictureDetailPageComponent {
449 this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId) 449 this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId)
450 this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle) 450 this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle)
451 this.publishCommentModel.targetType = String(this.contentDetailData?.newsType) 451 this.publishCommentModel.targetType = String(this.contentDetailData?.newsType)
  452 + this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment)
452 } 453 }
453 // this.contentDetailData.photoList = [] 454 // this.contentDetailData.photoList = []
454 if (this.contentDetailData?.photoList && this.contentDetailData?.photoList?.length === 0) { 455 if (this.contentDetailData?.photoList && this.contentDetailData?.photoList?.length === 0) {
@@ -72,6 +72,7 @@ export struct SpacialTopicPageComponent { @@ -72,6 +72,7 @@ export struct SpacialTopicPageComponent {
72 this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId) 72 this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId)
73 this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle) 73 this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle)
74 this.publishCommentModel.targetType = String(this.contentDetailData?.newsType) 74 this.publishCommentModel.targetType = String(this.contentDetailData?.newsType)
  75 + this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment)
75 // } 76 // }
76 this.trySendData2H5() 77 this.trySendData2H5()
77 } 78 }
@@ -113,4 +114,4 @@ export struct SpacialTopicPageComponent { @@ -113,4 +114,4 @@ export struct SpacialTopicPageComponent {
113 } 114 }
114 this.getDetail() 115 this.getDetail()
115 } 116 }
116 -}  
  117 +}
@@ -20,6 +20,8 @@ export class publishCommentModel { @@ -20,6 +20,8 @@ export class publishCommentModel {
20 targetType: string = '' 20 targetType: string = ''
21 /*评论总数*/ 21 /*评论总数*/
22 totalCommentNumer: string = '0' 22 totalCommentNumer: string = '0'
  23 + /// 游客评论开关:visitorComment 1:打开;0:关闭
  24 + visitorComment: string = "0"
23 25
24 //评论传参 26 //评论传参
25 /*评论图片url,多个逗号隔开*/ 27 /*评论图片url,多个逗号隔开*/
@@ -27,12 +27,17 @@ export struct CommentComponent { @@ -27,12 +27,17 @@ export struct CommentComponent {
27 @Consume contentDetailData: ContentDetailDTO 27 @Consume contentDetailData: ContentDetailDTO
28 listScroller: ListScroller = new ListScroller(); // scroller控制器 28 listScroller: ListScroller = new ListScroller(); // scroller控制器
29 historyOffset: number = 0; // 上次浏览到列表距离顶端的偏移量offset 29 historyOffset: number = 0; // 上次浏览到列表距离顶端的偏移量offset
30 - isloading: boolean = false  
31 @State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource(); 30 @State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource();
32 @State dialogController: CustomDialogController | null = null; 31 @State dialogController: CustomDialogController | null = null;
33 32
34 // @State private browSingModel: commentListModel = new commentListModel() 33 // @State private browSingModel: commentListModel = new commentListModel()
35 34
  35 + // 是否为固定高度模式。true时,里面上拉加载更多生效,外层不能包Scroll。
  36 + // false时,外层实现加载更多,并通过reachEndIncreament通知开发加载更多,reachEndLoadMoreFinish 通知上层加载更多完成
  37 + fixedHeightMode: boolean = false
  38 + @Prop @Watch("parentOnReachEnd") reachEndIncreament : number = 0
  39 + reachEndLoadMoreFinish?: () => void
  40 +
36 // 在自定义组件即将析构销毁时将dialogControlle置空 41 // 在自定义组件即将析构销毁时将dialogControlle置空
37 aboutToDisappear() { 42 aboutToDisappear() {
38 this.dialogController = null // 将dialogController置空 43 this.dialogController = null // 将dialogController置空
@@ -186,23 +191,43 @@ export struct CommentComponent { @@ -186,23 +191,43 @@ export struct CommentComponent {
186 191
187 // 加载更多 192 // 加载更多
188 ListItem() { 193 ListItem() {
189 - if (this.hasMore === false) { 194 + if (this.hasMore == false) {
190 NoMoreLayout() 195 NoMoreLayout()
191 } 196 }
192 } 197 }
193 } 198 }
194 -  
195 } 199 }
  200 + .margin({bottom: 10})
196 .onReachEnd(() => { 201 .onReachEnd(() => {
  202 + if (!this.fixedHeightMode) {
  203 + return
  204 + }
197 if (this.hasMore) { 205 if (this.hasMore) {
198 this.getData() 206 this.getData()
199 } 207 }
200 }) 208 })
201 - .enableScrollInteraction(false) 209 + .enableScrollInteraction(this.fixedHeightMode ? true: false)
  210 + // .nestedScroll({
  211 + // scrollForward: NestedScrollMode.PARENT_FIRST,
  212 + // scrollBackward: NestedScrollMode.SELF_FIRST
  213 + // })
202 } 214 }
203 215
204 } 216 }
205 217
  218 + parentOnReachEnd() {
  219 + if (this.fixedHeightMode) {
  220 + return
  221 + }
  222 + if (this.hasMore) {
  223 + this.getData()
  224 + } else {
  225 + if (this.reachEndLoadMoreFinish) {
  226 + this.reachEndLoadMoreFinish()
  227 + }
  228 + }
  229 + }
  230 +
206 //获取数据 231 //获取数据
207 async getData() { 232 async getData() {
208 commentViewModel.fetchContentCommentList(this.currentPage + '', this.publishCommentModel.targetId, 233 commentViewModel.fetchContentCommentList(this.currentPage + '', this.publishCommentModel.targetId,
@@ -241,6 +266,9 @@ export struct CommentComponent { @@ -241,6 +266,9 @@ export struct CommentComponent {
241 } else { 266 } else {
242 this.hasMore = false 267 this.hasMore = false
243 } 268 }
  269 + if (!this.fixedHeightMode && this.reachEndLoadMoreFinish) {
  270 + this.reachEndLoadMoreFinish()
  271 + }
244 }) 272 })
245 } 273 }
246 } 274 }
@@ -468,7 +496,7 @@ struct commentHeaderView { @@ -468,7 +496,7 @@ struct commentHeaderView {
468 .margin({ left: 8 }) 496 .margin({ left: 8 })
469 .alignContent(Alignment.Center) 497 .alignContent(Alignment.Center)
470 .onClick(() => { 498 .onClick(() => {
471 - // TODO 跳转个人详情 499 + commentViewModel.jumpToAccountPage(this.item)
472 }) 500 })
473 501
474 //昵称 502 //昵称
  1 +import { ContentDetailDTO, PageInfoDTO } from 'wdBean/Index'
  2 +import { publishCommentModel } from '../model/PublishCommentModel'
  3 +
  4 +@CustomDialog
  5 +export struct CommentListDialog {
  6 +
  7 + /// 内部使用
  8 + private publishCommentModel: publishCommentModel = new publishCommentModel()
  9 + controller?: CustomDialogController
  10 +
  11 + /// 外部初始化
  12 + contentDetail?: ContentDetailDTO
  13 + pageInfo?: PageInfoDTO
  14 +
  15 + build() {
  16 + }
  17 +
  18 +
  19 +}
@@ -412,33 +412,7 @@ struct QualityCommentItem { @@ -412,33 +412,7 @@ struct QualityCommentItem {
412 412
413 jumpToAccountOwner() { 413 jumpToAccountOwner() {
414 414
415 - let url = HttpUrlUtils.getOtherUserDetailDataUrl()  
416 - let item : Record<string, string >= {  
417 - "creatorId": this.item.fromCreatorId || "",  
418 - "userType": `${this.item.fromUserType}`,  
419 - "userId": this.item.fromUserId || "-1",  
420 - }  
421 - HttpBizUtil.post<ResponseDTO<MasterDetailRes>>(url, item).then((result) => {  
422 - if (!result.data || result.data.mainControl != 1) {  
423 - ToastUtils.longToast("暂时无法查看该创作者主页")  
424 - return  
425 - }  
426 -  
427 - if (result.data.banControl == 1) {  
428 - ToastUtils.longToast("该账号已封禁,不予访问")  
429 - return  
430 - }  
431 -  
432 - if (result.data.userType === "1") { // 普通用户  
433 - let params: Record<string, string> = {'userId': result.data.userId};  
434 - WDRouterRule.jumpWithPage(WDRouterPage.otherNormalUserHomePagePage,params)  
435 - } else { // 非普通用户  
436 - ProcessUtils.gotoPeopleShipHomePage(result.data.creatorId)  
437 - }  
438 -  
439 - }).catch(() => {  
440 - ToastUtils.longToast("暂时无法查看该创作者主页")  
441 - }) 415 + commentViewModel.jumpToAccountPage(this.item)
442 } 416 }
443 417
444 jumpToDetail() { 418 jumpToDetail() {
  1 +import { MasterDetailRes } from 'wdBean/Index';
1 import { SpConstants } from 'wdConstant/Index'; 2 import { SpConstants } from 'wdConstant/Index';
2 -import { DateTimeUtils, Logger, SPHelper, ToastUtils, UserDataLocal } from 'wdKit/Index'; 3 +import {
  4 + AccountManagerUtils,
  5 + DateTimeUtils, DeviceUtil, Logger, SPHelper, ToastUtils, UserDataLocal } from 'wdKit/Index';
3 import { HttpBizUtil, HttpUrlUtils, HttpUtils, ResponseDTO } from 'wdNetwork/Index'; 6 import { HttpBizUtil, HttpUrlUtils, HttpUtils, ResponseDTO } from 'wdNetwork/Index';
4 import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; 7 import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
  8 +import { ProcessUtils, WDRouterPage, WDRouterRule } from 'wdRouter/Index';
5 import { 9 import {
6 commentItemModel, 10 commentItemModel,
7 commentListModel, 11 commentListModel,
@@ -160,7 +164,9 @@ class CommentViewModel { @@ -160,7 +164,9 @@ class CommentViewModel {
160 publishComment(model: publishCommentModel) { 164 publishComment(model: publishCommentModel) {
161 165
162 return new Promise<commentItemModel>((success, fail) => { 166 return new Promise<commentItemModel>((success, fail) => {
163 - let url = HttpUrlUtils.getPublishCommentUrl() 167 + const visitorMode = model.visitorComment == "1" && AccountManagerUtils.isLoginSync() == false
  168 + let url = visitorMode ? HttpUrlUtils.getNoUserPublishCommentUrl() : HttpUrlUtils.getPublishCommentUrl()
  169 +
164 let bean: Record<string, string> = {}; 170 let bean: Record<string, string> = {};
165 171
166 bean['targetId'] = model.targetId; 172 bean['targetId'] = model.targetId;
@@ -176,6 +182,11 @@ class CommentViewModel { @@ -176,6 +182,11 @@ class CommentViewModel {
176 bean['targetType'] = model.targetType 182 bean['targetType'] = model.targetType
177 bean['parentId'] = model.parentId 183 bean['parentId'] = model.parentId
178 184
  185 + if (visitorMode) {
  186 + bean['deviceId'] = DeviceUtil.clientId()
  187 + bean['userName'] = SPHelper.default.getSync(SpConstants.TOURIST_NICK_NAME, "") as string
  188 + }
  189 +
179 HttpRequest.post<ResponseDTO<commentItemModel>>(url, bean).then((data: ResponseDTO<commentItemModel>) => { 190 HttpRequest.post<ResponseDTO<commentItemModel>>(url, bean).then((data: ResponseDTO<commentItemModel>) => {
180 if (data.code != 0) { 191 if (data.code != 0) {
181 ToastUtils.showToast(data.message, 1000); 192 ToastUtils.showToast(data.message, 1000);
@@ -185,10 +196,9 @@ class CommentViewModel { @@ -185,10 +196,9 @@ class CommentViewModel {
185 ToastUtils.showToast(data.message, 1000); 196 ToastUtils.showToast(data.message, 1000);
186 let model = data.data as commentItemModel 197 let model = data.data as commentItemModel
187 198
188 - let userId = HttpUtils.getUserId()  
189 - let FIRSTCOMMENTTIME = SPHelper.default.getSync(SpConstants.FIRSTCOMMENTTIME, '') 199 + let firstCommentTime = SPHelper.default.getSync(SpConstants.FIRSTCOMMENTTIME, '') as string
190 200
191 - if (!userId && !FIRSTCOMMENTTIME) { 201 + if (visitorMode && firstCommentTime.length == 0) {
192 //保存首次评论时间 202 //保存首次评论时间
193 SPHelper.default.saveSync(SpConstants.FIRSTCOMMENTTIME, DateTimeUtils.formatDate(data.timestamp, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN)) 203 SPHelper.default.saveSync(SpConstants.FIRSTCOMMENTTIME, DateTimeUtils.formatDate(data.timestamp, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN))
194 } 204 }
@@ -472,6 +482,36 @@ class CommentViewModel { @@ -472,6 +482,36 @@ class CommentViewModel {
472 } 482 }
473 return false 483 return false
474 } 484 }
  485 +
  486 + jumpToAccountPage(commentItem: commentItemModel) {
  487 + let url = HttpUrlUtils.getOtherUserDetailDataUrl()
  488 + let item : Record<string, string >= {
  489 + "creatorId": commentItem.fromCreatorId || "",
  490 + "userType": `${commentItem.fromUserType}`,
  491 + "userId": commentItem.fromUserId || "-1",
  492 + }
  493 + HttpBizUtil.post<ResponseDTO<MasterDetailRes>>(url, item).then((result) => {
  494 + if (!result.data || result.data.mainControl != 1) {
  495 + ToastUtils.longToast("暂时无法查看该创作者主页")
  496 + return
  497 + }
  498 +
  499 + if (result.data.banControl == 1) {
  500 + ToastUtils.longToast("该账号已封禁,不予访问")
  501 + return
  502 + }
  503 +
  504 + if (result.data.userType === "1") { // 普通用户
  505 + let params: Record<string, string> = {'userId': result.data.userId};
  506 + WDRouterRule.jumpWithPage(WDRouterPage.otherNormalUserHomePagePage,params)
  507 + } else { // 非普通用户
  508 + ProcessUtils.gotoPeopleShipHomePage(result.data.creatorId)
  509 + }
  510 +
  511 + }).catch(() => {
  512 + ToastUtils.longToast("暂时无法查看该创作者主页")
  513 + })
  514 + }
475 } 515 }
476 516
477 517
  1 +import { insightIntent } from '@kit.IntentsKit';
1 import { BottomNavDTO, CompDTO, TopNavDTO } from 'wdBean'; 2 import { BottomNavDTO, CompDTO, TopNavDTO } from 'wdBean';
2 import { SpConstants } from 'wdConstant'; 3 import { SpConstants } from 'wdConstant';
3 import { DisplayUtils, LazyDataSource, Logger, NetworkUtil, SPHelper, ToastUtils } from 'wdKit'; 4 import { DisplayUtils, LazyDataSource, Logger, NetworkUtil, SPHelper, ToastUtils } from 'wdKit';
@@ -8,6 +9,7 @@ import { FirstTabTopSearchComponent } from '../search/FirstTabTopSearchComponent @@ -8,6 +9,7 @@ import { FirstTabTopSearchComponent } from '../search/FirstTabTopSearchComponent
8 import { AssignChannelParam } from 'wdRouter/src/main/ets/utils/HomeChannelUtils'; 9 import { AssignChannelParam } from 'wdRouter/src/main/ets/utils/HomeChannelUtils';
9 import { PeopleShipMainComponent } from '../peopleShip/PeopleShipMainComponent'; 10 import { PeopleShipMainComponent } from '../peopleShip/PeopleShipMainComponent';
10 import { channelSkeleton } from '../skeleton/channelSkeleton'; 11 import { channelSkeleton } from '../skeleton/channelSkeleton';
  12 +import { common } from '@kit.AbilityKit';
11 13
12 14
13 const TAG = 'TopNavigationComponent'; 15 const TAG = 'TopNavigationComponent';
@@ -37,6 +39,7 @@ export struct TopNavigationComponent { @@ -37,6 +39,7 @@ export struct TopNavigationComponent {
37 // 顶导当前选中/焦点下标 39 // 顶导当前选中/焦点下标
38 @State currentTopNavSelectedIndex: number = 0; 40 @State currentTopNavSelectedIndex: number = 0;
39 @State currentTopNavName: string = ''; 41 @State currentTopNavName: string = '';
  42 + @State currentTopNavItem: TopNavDTO = {} as TopNavDTO
40 // 顶导数据 43 // 顶导数据
41 @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = [] 44 @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = []
42 @State compList: LazyDataSource<CompDTO> = new LazyDataSource(); 45 @State compList: LazyDataSource<CompDTO> = new LazyDataSource();
@@ -58,6 +61,8 @@ export struct TopNavigationComponent { @@ -58,6 +61,8 @@ export struct TopNavigationComponent {
58 @Prop @Watch('onAutoRefresh') autoRefresh: number = 0 61 @Prop @Watch('onAutoRefresh') autoRefresh: number = 0
59 // 传递给page的自动刷新通知 62 // 传递给page的自动刷新通知
60 @State autoRefresh2Page: number = 0 63 @State autoRefresh2Page: number = 0
  64 + //保存当前导航选中时的时间戳 意图开始时间
  65 + @State executedStartTime: number = new Date().getTime()
61 // 当前底导index 66 // 当前底导index
62 @State navIndex: number = 0 67 @State navIndex: number = 0
63 @State animationDuration: number = 0 68 @State animationDuration: number = 0
@@ -167,6 +172,7 @@ export struct TopNavigationComponent { @@ -167,6 +172,7 @@ export struct TopNavigationComponent {
167 this.currentTopNavSelectedIndex = index 172 this.currentTopNavSelectedIndex = index
168 this.currentTopNavName = this.myChannelList[index].name 173 this.currentTopNavName = this.myChannelList[index].name
169 } 174 }
  175 + this.currentTopNavItem = this.myChannelList[this.currentTopNavSelectedIndex]
170 } 176 }
171 177
172 isBroadcast(item: TopNavDTO) { 178 isBroadcast(item: TopNavDTO) {
@@ -184,6 +190,49 @@ export struct TopNavigationComponent { @@ -184,6 +190,49 @@ export struct TopNavigationComponent {
184 return item.channelType === 3 190 return item.channelType === 3
185 } 191 }
186 192
  193 + //意图共享
  194 + topNavInsightIntentShare(item: TopNavDTO){
  195 + let tapNavIntent: insightIntent.InsightIntent = {
  196 + intentName: 'ViewColumn',
  197 + intentVersion: '1.0.1',
  198 + identifier: '52dac3b0-6520-4974-81e5-25f0879449b5',
  199 + intentActionInfo: {
  200 + actionMode: 'EXPECTED',
  201 + currentPercentage: 50,
  202 + executedTimeSlots: {
  203 + executedEndTime: new Date().getTime(),
  204 + executedStartTime: this.executedStartTime
  205 + }
  206 + },
  207 + intentEntityInfo: {
  208 + entityName: 'ViewColumn',
  209 + entityId: String(item.pageId) || '',
  210 + displayName: item.name,
  211 + logoURL: 'https://www-file.huawei.com/-/media/corporate/images/home/logo/huawei_logo.png',
  212 + rankingHint: 99,
  213 + isPublicData: true
  214 + }
  215 + }
  216 +
  217 + try {
  218 + let context = getContext(this) as common.UIAbilityContext;
  219 + // 共享数据
  220 + insightIntent.shareIntent(context, [tapNavIntent], (error) => {
  221 + if (error?.code) {
  222 + // 处理业务逻辑错误
  223 + console.error(`shareIntent failed, error.code: ${error?.code}, error.message: ${error?.message}`);
  224 + return;
  225 + }
  226 + // 执行正常业务
  227 + console.log('shareIntent succeed');
  228 + });
  229 + } catch (error) {
  230 + // 处理异常
  231 + console.error(`error.code: ${error?.code}, error.message: ${error?.message}`);
  232 + }
  233 + }
  234 +
  235 +
187 build() { 236 build() {
188 Column() { 237 Column() {
189 // 顶部搜索、日报logo、早晚报 238 // 顶部搜索、日报logo、早晚报
@@ -278,7 +327,11 @@ export struct TopNavigationComponent { @@ -278,7 +327,11 @@ export struct TopNavigationComponent {
278 if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) && 327 if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) &&
279 !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) 328 !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])
280 ) { 329 ) {
  330 + //在 tab 切换之前意图共享
  331 + // this.topNavInsightIntentShare(this.currentTopNavItem)
  332 +
281 this.currentTopNavSelectedIndex = index; 333 this.currentTopNavSelectedIndex = index;
  334 + this.currentTopNavItem = this.myChannelList[index]
282 } 335 }
283 if (this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])) { 336 if (this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])) {
284 // 跳转到播报页面 337 // 跳转到播报页面
@@ -416,9 +469,11 @@ export struct TopNavigationComponent { @@ -416,9 +469,11 @@ export struct TopNavigationComponent {
416 this.changeByClick = true 469 this.changeByClick = true
417 this.tabsController.changeIndex(index) 470 this.tabsController.changeIndex(index)
418 } 471 }
  472 +
419 }) 473 })
420 } 474 }
421 475
  476 +
422 aboutToAppear() { 477 aboutToAppear() {
423 //处理新闻tab顶导频道数据 478 //处理新闻tab顶导频道数据
424 this.topNavListHandle() 479 this.topNavListHandle()
@@ -70,6 +70,7 @@ export struct DetailPlayLiveCommon { @@ -70,6 +70,7 @@ export struct DetailPlayLiveCommon {
70 this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId) 70 this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId)
71 this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle) 71 this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle)
72 this.publishCommentModel.targetType = String(this.contentDetailData?.newsType) 72 this.publishCommentModel.targetType = String(this.contentDetailData?.newsType)
  73 + this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment)
73 this.publishCommentModel.commentContent = '' 74 this.publishCommentModel.commentContent = ''
74 // } 75 // }
75 } 76 }
@@ -2,7 +2,10 @@ import HuaweiAuth from './utils/HuaweiAuth' @@ -2,7 +2,10 @@ import HuaweiAuth from './utils/HuaweiAuth'
2 import { JumpInterceptorAction, RouterJumpInterceptor, WDRouterPage } from 'wdRouter' 2 import { JumpInterceptorAction, RouterJumpInterceptor, WDRouterPage } from 'wdRouter'
3 import { BusinessError } from '@kit.BasicServicesKit' 3 import { BusinessError } from '@kit.BasicServicesKit'
4 import { router } from '@kit.ArkUI' 4 import { router } from '@kit.ArkUI'
5 -import { AccountManagerUtils } from 'wdKit/Index' 5 +import { AccountManagerUtils, SPHelper } from 'wdKit/Index'
  6 +import { LoginViewModel } from './pages/login/LoginViewModel'
  7 +import { SpConstants } from 'wdConstant/Index'
  8 +import { ReportDeviceInfo } from './reportDeviceInfo/ReportDeviceInfo'
6 9
7 class LoginJumpHandler implements JumpInterceptorAction { 10 class LoginJumpHandler implements JumpInterceptorAction {
8 11
@@ -37,4 +40,14 @@ export class LoginModule { @@ -37,4 +40,14 @@ export class LoginModule {
37 } 40 }
38 41
39 } 42 }
  43 +
  44 + // 启动进入主页 和 每次登录成功调用
  45 + static reportDeviceInfo() {
  46 + ReportDeviceInfo.reportDeviceInfo().then((res) => {
  47 + let nickName = res.touristNickName
  48 + if (res.touristNickName) {
  49 + SPHelper.default.save(SpConstants.TOURIST_NICK_NAME, res.touristNickName)
  50 + }
  51 + })
  52 + }
40 } 53 }
@@ -82,6 +82,30 @@ export class LoginModel { @@ -82,6 +82,30 @@ export class LoginModel {
82 }) 82 })
83 } 83 }
84 84
  85 + // loginType 0:手机号密码 2:手机号登录 3:QQ 4:微信 5:微博 6:APPLEID 7:手机号一键登录8:账号+密码 9:华为一键登录
  86 + thirdPartLogin(loginType: number, otherParams: Record<string, string|number>) {
  87 + otherParams['loginType'] = loginType
  88 + otherParams['deviceId'] = HttpUtils.getDeviceId()
  89 +
  90 + return new Promise<LoginBean>((success, fail) => {
  91 + HttpRequest.post<ResponseDTO<LoginBean>>(HttpUrlUtils.getAppLoginUrl(), otherParams).then((data: ResponseDTO<LoginBean>) => {
  92 + Logger.debug("LoginViewModel:success2 ", data.message)
  93 + if (!data) {
  94 + fail("数据为空")
  95 + return
  96 + }
  97 + if (!data.data||data.code != 0) {
  98 + fail(data.message)
  99 + return
  100 + }
  101 + success(data.data)
  102 + }, (error: Error) => {
  103 + fail(error.message)
  104 + Logger.debug("LoginViewModel:error2 ", error.toString())
  105 + })
  106 + })
  107 + }
  108 +
85 // {"password":"523acd319228efde34e8a30268ee8ca5e4fc421d72affa531676e1765940d22c","phone":"13625644528","loginType":0,"oldPassword":"BA5FD74F827AF9B271FE17CADC489C36","deviceId":"60da5af6-9c59-3566-8622-8c6c00710994"} 109 // {"password":"523acd319228efde34e8a30268ee8ca5e4fc421d72affa531676e1765940d22c","phone":"13625644528","loginType":0,"oldPassword":"BA5FD74F827AF9B271FE17CADC489C36","deviceId":"60da5af6-9c59-3566-8622-8c6c00710994"}
86 appLoginByPassword(phone: string, loginType: number, password: string, oldPassword: string) { 110 appLoginByPassword(phone: string, loginType: number, password: string, oldPassword: string) {
87 let bean: Record<string, string | number> = {}; 111 let bean: Record<string, string | number> = {};
@@ -10,6 +10,7 @@ import { encryptMessage } from '../../utils/cryptoUtil' @@ -10,6 +10,7 @@ import { encryptMessage } from '../../utils/cryptoUtil'
10 import { SpConstants } from 'wdConstant/Index' 10 import { SpConstants } from 'wdConstant/Index'
11 import { UserDetail } from 'wdBean/Index'; 11 import { UserDetail } from 'wdBean/Index';
12 import { HttpUtils } from 'wdNetwork/Index' 12 import { HttpUtils } from 'wdNetwork/Index'
  13 +import { LoginModule } from '../../LoginModule'
13 14
14 const TAG = "LoginViewModel" 15 const TAG = "LoginViewModel"
15 16
@@ -47,15 +48,7 @@ export class LoginViewModel { @@ -47,15 +48,7 @@ export class LoginViewModel {
47 48
48 return new Promise<LoginBean>((success, fail) => { 49 return new Promise<LoginBean>((success, fail) => {
49 this.loginModel.appLogin(phone, loginType, verificationCode).then((data: LoginBean) => { 50 this.loginModel.appLogin(phone, loginType, verificationCode).then((data: LoginBean) => {
50 - SPHelper.default.saveSync(SpConstants.USER_FIRST_MARK, data.firstMark)  
51 - SPHelper.default.saveSync(SpConstants.USER_ID, data.id)  
52 - SPHelper.default.saveSync(SpConstants.USER_JWT_TOKEN, data.jwtToken)  
53 - SPHelper.default.saveSync(SpConstants.USER_LONG_TIME_NO_LOGIN_MARK, data.longTimeNoLoginMark)  
54 - SPHelper.default.saveSync(SpConstants.USER_REFRESH_TOKEN, data.refreshToken)  
55 - SPHelper.default.saveSync(SpConstants.USER_STATUS, data.status)  
56 - SPHelper.default.saveSync(SpConstants.USER_Type, data.userType)  
57 - SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName)  
58 - EmitterUtils.sendEmptyEvent(EmitterEventId.LOGIN_SUCCESS) 51 + this.dealWithLoginSuccess(data)
59 success(data) 52 success(data)
60 }).catch((error:string) => { 53 }).catch((error:string) => {
61 fail(error) 54 fail(error)
@@ -63,6 +56,32 @@ export class LoginViewModel { @@ -63,6 +56,32 @@ export class LoginViewModel {
63 }) 56 })
64 } 57 }
65 58
  59 + huaweiOneKeyLogin(authCode: string) {
  60 + return new Promise<LoginBean>((success, fail) => {
  61 + this.loginModel.thirdPartLogin(9, {"idToken": authCode}).then((data: LoginBean) => {
  62 + this.dealWithLoginSuccess(data)
  63 + success(data)
  64 + }).catch((error:string) => {
  65 + fail(error)
  66 + })
  67 + })
  68 + }
  69 +
  70 + //TODO: 这里要整体改掉
  71 + dealWithLoginSuccess(data: LoginBean) {
  72 + SPHelper.default.saveSync(SpConstants.USER_FIRST_MARK, data.firstMark)
  73 + SPHelper.default.saveSync(SpConstants.USER_ID, data.id)
  74 + SPHelper.default.saveSync(SpConstants.USER_JWT_TOKEN, data.jwtToken)
  75 + SPHelper.default.saveSync(SpConstants.USER_LONG_TIME_NO_LOGIN_MARK, data.longTimeNoLoginMark)
  76 + SPHelper.default.saveSync(SpConstants.USER_REFRESH_TOKEN, data.refreshToken)
  77 + SPHelper.default.saveSync(SpConstants.USER_STATUS, data.status)
  78 + SPHelper.default.saveSync(SpConstants.USER_Type, data.userType)
  79 + SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName)
  80 + EmitterUtils.sendEmptyEvent(EmitterEventId.LOGIN_SUCCESS)
  81 +
  82 + LoginModule.reportDeviceInfo()
  83 + }
  84 +
66 async appLoginByPassword(phone: string, loginType: number, password: string, oldPassword: string) { 85 async appLoginByPassword(phone: string, loginType: number, password: string, oldPassword: string) {
67 let newLoginType: number 86 let newLoginType: number
68 let isPhone = this.verifyIsPhoneNumber(phone) 87 let isPhone = this.verifyIsPhoneNumber(phone)
@@ -75,15 +94,7 @@ export class LoginViewModel { @@ -75,15 +94,7 @@ export class LoginViewModel {
75 let passwordNew = await this.doMd(password) 94 let passwordNew = await this.doMd(password)
76 Logger.debug(TAG, "PASSWORD:" + passwordNew) 95 Logger.debug(TAG, "PASSWORD:" + passwordNew)
77 this.loginModel.appLoginByPassword(phone, newLoginType, passwordNew, oldPassword).then((data: LoginBean) => { 96 this.loginModel.appLoginByPassword(phone, newLoginType, passwordNew, oldPassword).then((data: LoginBean) => {
78 - SPHelper.default.saveSync(SpConstants.USER_FIRST_MARK, data.firstMark)  
79 - SPHelper.default.saveSync(SpConstants.USER_ID, data.id)  
80 - SPHelper.default.saveSync(SpConstants.USER_JWT_TOKEN, data.jwtToken)  
81 - SPHelper.default.saveSync(SpConstants.USER_LONG_TIME_NO_LOGIN_MARK, data.longTimeNoLoginMark)  
82 - SPHelper.default.saveSync(SpConstants.USER_REFRESH_TOKEN, data.refreshToken)  
83 - SPHelper.default.saveSync(SpConstants.USER_STATUS, data.status)  
84 - SPHelper.default.saveSync(SpConstants.USER_Type, data.userType)  
85 - SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName)  
86 - EmitterUtils.sendEmptyEvent(EmitterEventId.LOGIN_SUCCESS) 97 + this.dealWithLoginSuccess(data)
87 success(data) 98 success(data)
88 }).catch((value: string) => { 99 }).catch((value: string) => {
89 fail(value) 100 fail(value)
@@ -3,13 +3,30 @@ import { Params } from 'wdBean/Index' @@ -3,13 +3,30 @@ import { Params } from 'wdBean/Index'
3 import { WDRouterPage, WDRouterRule } from 'wdRouter/Index' 3 import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
4 import HuaweiAuth from '../../utils/HuaweiAuth' 4 import HuaweiAuth from '../../utils/HuaweiAuth'
5 import { BusinessError } from '@kit.BasicServicesKit' 5 import { BusinessError } from '@kit.BasicServicesKit'
6 -import { ToastUtils } from 'wdKit/Index' 6 +import { Logger, ToastUtils, CustomToast, EmitterUtils, EmitterEventId } from 'wdKit/Index'
  7 +import { LoginViewModel } from './LoginViewModel'
  8 +import {InterestsHobbiesModel} from '../../../../../../../products/phone/src/main/ets/pages/viewModel/InterestsHobbiesModel'
  9 +
  10 +const TAG = "OneKeyLoginPage"
7 11
8 @Entry 12 @Entry
9 @Component 13 @Component
10 struct OneKeyLoginPage { 14 struct OneKeyLoginPage {
11 anonymousPhone: string = '' 15 anonymousPhone: string = ''
12 @State agreeProtocol: boolean = false 16 @State agreeProtocol: boolean = false
  17 + viewModel: LoginViewModel = new LoginViewModel()
  18 + @State toastText:string = ""
  19 + dialogToast: CustomDialogController = new CustomDialogController({
  20 + builder: CustomToast({
  21 + msg: this.toastText,
  22 + }),
  23 + autoCancel: false,
  24 + alignment: DialogAlignment.Center,
  25 + offset: { dx: 0, dy: -20 },
  26 + gridCount: 1,
  27 + customStyle: true,
  28 + maskColor:"#00000000"
  29 + })
13 30
14 aboutToAppear(): void { 31 aboutToAppear(): void {
15 this.anonymousPhone = HuaweiAuth.sharedInstance().anonymousPhone||"" 32 this.anonymousPhone = HuaweiAuth.sharedInstance().anonymousPhone||""
@@ -44,17 +61,7 @@ struct OneKeyLoginPage { @@ -44,17 +61,7 @@ struct OneKeyLoginPage {
44 if (!this.agreeProtocol) { 61 if (!this.agreeProtocol) {
45 return 62 return
46 } 63 }
47 - HuaweiAuth.sharedInstance().oneKeyLogin().then((authorizeCode) => {  
48 - //TODO: 调用服务端接口登录  
49 -  
50 - ToastUtils.shortToast("获取到授权code: " + authorizeCode + ",由于需要后台接口支持,暂时先跳转其他登录方式")  
51 - setTimeout(() => {  
52 - router.replaceUrl({url: WDRouterPage.loginPage.url()})  
53 - }, 3000)  
54 -  
55 - }).catch((error: BusinessError) => {  
56 -  
57 - }) 64 + this.requestLogin()
58 }) 65 })
59 } 66 }
60 .padding({ left: 25, right: 25 }) 67 .padding({ left: 25, right: 25 })
@@ -113,4 +120,47 @@ struct OneKeyLoginPage { @@ -113,4 +120,47 @@ struct OneKeyLoginPage {
113 }.margin({ top: 15, right: 15 }) 120 }.margin({ top: 15, right: 15 })
114 .width("100%") 121 .width("100%")
115 } 122 }
  123 +
  124 + async requestLogin() {
  125 + try {
  126 + let authorizeCode = await HuaweiAuth.sharedInstance().oneKeyLogin()
  127 +
  128 + let data = await this.viewModel.huaweiOneKeyLogin(authorizeCode)
  129 +
  130 + Logger.debug(TAG, "requestLogin: " + data.jwtToken)
  131 + this.showToastTip('登录成功')
  132 +
  133 + ///同步兴趣tag
  134 + let interestsModel = new InterestsHobbiesModel()
  135 + interestsModel.updateInterests()
  136 + this.queryUserDetail()
  137 + EmitterUtils.sendEvent(EmitterEventId.PEOPLE_SHIP_ATTENTION)
  138 +
  139 + } catch (error) {
  140 + if (typeof error == "string") {
  141 + this.showToastTip(error)
  142 + } else {
  143 + (error as BusinessError)
  144 + this.showToastTip("登录失败")
  145 + }
  146 + }
  147 + }
  148 +
  149 + showToastTip(msg:string){
  150 + this.toastText = msg
  151 + this.dialogToast.open()
  152 + }
  153 +
  154 + queryUserDetail(){
  155 + this.viewModel.queryUserDetail().then(()=>{
  156 + router.back({
  157 + url: `${WDRouterPage.getBundleInfo()}`
  158 + }
  159 + )
  160 + }).catch(()=>{
  161 + router.back({
  162 + url: `${WDRouterPage.getBundleInfo()}`
  163 + })
  164 + })
  165 + }
116 } 166 }
  1 +import { AppUtils, DeviceUtil, Logger, UserDataLocal } from 'wdKit/Index';
  2 +import { HttpBizUtil, HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index';
  3 +
  4 +export class ReportDeviceInfo {
  5 + static reportDeviceInfo() {
  6 + const userId = UserDataLocal.getUserId() || ""
  7 + const url = HttpUrlUtils.reportDeviceInfo()
  8 +
  9 + let bean: Record<string, string | number> = {};
  10 + bean['deviceId'] = DeviceUtil.clientId()
  11 + bean['appVersion'] = AppUtils.getAppVersionCode()
  12 + bean['platform'] = 3 /// 1Android 2iOS
  13 + bean['userId'] = userId
  14 + bean['brand'] = DeviceUtil.getMarketName()
  15 + bean['modelSystemVersion'] = DeviceUtil.getDisplayVersion()
  16 + bean['tenancy'] = 3 ///1-视界 2-英文版 3-中文版
  17 +
  18 + return new Promise<ReportDeviceInfoRes>((success, fail) => {
  19 + HttpBizUtil.post<ResponseDTO<ReportDeviceInfoRes>>(url,bean).then((data: ResponseDTO<ReportDeviceInfoRes>) => {
  20 + if (!data) {
  21 + fail("数据为空")
  22 + return
  23 + }
  24 + if (data.code != 0) {
  25 + fail(data.message)
  26 + return
  27 + }
  28 + success(data.data!)
  29 + }, (error: Error) => {
  30 + fail(error.message)
  31 + Logger.debug("ReportDeviceInfo", error.toString())
  32 + })
  33 + })
  34 +
  35 + }
  36 +}
  37 +
  38 +export class ReportDeviceInfoRes {
  39 + clean : number = 0
  40 + touristNickName : string = ""
  41 +}
@@ -16,12 +16,15 @@ struct ImageAndTextDetailPage { @@ -16,12 +16,15 @@ struct ImageAndTextDetailPage {
16 } 16 }
17 } 17 }
18 18
19 - pageTransition(){  
20 - // 定义页面进入时的效果,从右边侧滑入  
21 - PageTransitionEnter({ type: RouteType.None, duration: 300 }) 19 + pageTransition() {
  20 + // 为目标页面时,进入:从右边侧滑入,退出:是右侧划出;跳转别的页面:左侧划出,返回:左侧划入。
  21 + PageTransitionEnter({ type: RouteType.Push, duration: 300 })
22 .slide(SlideEffect.Right) 22 .slide(SlideEffect.Right)
23 - // 定义页面退出时的效果,向右边侧滑出  
24 - PageTransitionExit({ type: RouteType.None, duration: 300 }) 23 + PageTransitionEnter({ type: RouteType.Pop, duration: 300 })
  24 + .slide(SlideEffect.Left)
  25 + PageTransitionExit({ type: RouteType.Push, duration: 300 })
  26 + .slide(SlideEffect.Left)
  27 + PageTransitionExit({ type: RouteType.Pop, duration: 300 })
25 .slide(SlideEffect.Right) 28 .slide(SlideEffect.Right)
26 } 29 }
27 30
@@ -8,6 +8,7 @@ import router from '@ohos.router'; @@ -8,6 +8,7 @@ import router from '@ohos.router';
8 import { promptAction } from '@kit.ArkUI'; 8 import { promptAction } from '@kit.ArkUI';
9 import { UpgradeTipDialog } from "./upgradePage/UpgradeTipDialog" 9 import { UpgradeTipDialog } from "./upgradePage/UpgradeTipDialog"
10 import { ProcessUtils } from 'wdRouter/Index'; 10 import { ProcessUtils } from 'wdRouter/Index';
  11 +import { StartupManager } from '../startupmanager/StartupManager';
11 12
12 const TAG = 'MainPage'; 13 const TAG = 'MainPage';
13 14
@@ -27,6 +28,8 @@ struct MainPage { @@ -27,6 +28,8 @@ struct MainPage {
27 28
28 aboutToAppear() { 29 aboutToAppear() {
29 30
  31 + StartupManager.sharedInstance().appReachMainPage()
  32 +
30 this.breakpointSystem.register() 33 this.breakpointSystem.register()
31 34
32 let context = getContext(this) as common.UIAbilityContext 35 let context = getContext(this) as common.UIAbilityContext
@@ -18,11 +18,14 @@ struct SpacialTopicPage { @@ -18,11 +18,14 @@ struct SpacialTopicPage {
18 } 18 }
19 19
20 pageTransition() { 20 pageTransition() {
21 - // 定义页面进入时的效果,从右边侧滑入  
22 - PageTransitionEnter({ type: RouteType.None, duration: 300 }) 21 + // 为目标页面时,进入:从右边侧滑入,退出:是右侧划出;跳转别的页面:左侧划出,返回:左侧划入。
  22 + PageTransitionEnter({ type: RouteType.Push, duration: 300 })
23 .slide(SlideEffect.Right) 23 .slide(SlideEffect.Right)
24 - // 定义页面退出时的效果,向右边侧滑出  
25 - PageTransitionExit({ type: RouteType.None, duration: 300 }) 24 + PageTransitionEnter({ type: RouteType.Pop, duration: 300 })
  25 + .slide(SlideEffect.Left)
  26 + PageTransitionExit({ type: RouteType.Push, duration: 300 })
  27 + .slide(SlideEffect.Left)
  28 + PageTransitionExit({ type: RouteType.Pop, duration: 300 })
26 .slide(SlideEffect.Right) 29 .slide(SlideEffect.Right)
27 } 30 }
28 31
@@ -90,6 +90,9 @@ export class StartupManager { @@ -90,6 +90,9 @@ export class StartupManager {
90 appReachMainPage() : Promise<void> { 90 appReachMainPage() : Promise<void> {
91 return new Promise((resolve) => { 91 return new Promise((resolve) => {
92 Logger.debug(TAG, "App 进入首页,开始其他任务初始化") 92 Logger.debug(TAG, "App 进入首页,开始其他任务初始化")
  93 +
  94 + LoginModule.reportDeviceInfo()
  95 +
93 //TODO: 96 //TODO:
94 97
95 resolve() 98 resolve()
  1 +import { insightIntent, InsightIntentExecutor } from '@kit.AbilityKit';
  2 +import { window } from '@kit.ArkUI';
  3 +import { BusinessError } from '@kit.BasicServicesKit';
  4 +
  5 +/**
  6 + * 意图调用
  7 + */
  8 +export default class InsightIntentExecutorImpl extends InsightIntentExecutor {
  9 + private static readonly ViewColumn = 'ViewColumn';
  10 + /**
  11 + * override 执行前台UIAbility意图
  12 + *
  13 + * @param name 意图名称
  14 + * @param param 意图参数
  15 + * @param pageLoader 窗口
  16 + * @returns 意图调用结果
  17 + */
  18 + onExecuteInUIAbilityForegroundMode(name: string, param: Record<string, Object>, pageLoader: window.WindowStage):
  19 + Promise<insightIntent.ExecuteResult> {
  20 + // 根据意图名称分发处理逻辑
  21 + switch (name) {
  22 + case InsightIntentExecutorImpl.ViewColumn:
  23 + return this.jumpToView(param, pageLoader);
  24 + default:
  25 + break;
  26 + }
  27 + return Promise.resolve({
  28 + code: -1,
  29 + result: {
  30 + message: 'unknown intent'
  31 + }
  32 + } as insightIntent.ExecuteResult)
  33 + }
  34 + /**
  35 + * 实现跳转新闻页面功能
  36 + *
  37 + * @param param 意图参数
  38 + * @param pageLoader 窗口
  39 + */
  40 + private jumpToView(param: Record<string, Object>, pageLoader: window.WindowStage): Promise<insightIntent.ExecuteResult> {
  41 + return new Promise((resolve, reject) => {
  42 + // TODO 实现意图调用,loadContent的入参为歌曲落地页路径,例如:pages/SongPage
  43 + pageLoader.loadContent('pages/MainPage')
  44 + .then(() => {
  45 + let entityId: string = (param.items as Array<object>)?.[0]?.['entityId'];
  46 + // TODO 调用成功的情况,此处可以打印日志
  47 + resolve({
  48 + code: 0,
  49 + result: {
  50 + message: 'Intent execute success'
  51 + }
  52 + });
  53 + })
  54 + .catch((err: BusinessError) => {
  55 + // TODO 调用失败的情况
  56 + resolve({
  57 + code: -1,
  58 + result: {
  59 + message: 'Intent execute failed'
  60 + }
  61 + })
  62 + });
  63 + })
  64 + }
  65 +}
  1 +{
  2 + "insightIntents": [
  3 + {
  4 + "intentName": "ViewColumn",
  5 + "domain": "",
  6 + "intentVersion": "1.0.1",
  7 + "srcEntry": "./ets/utils/InsightIntentExecutorImpl.ets",
  8 + "uiAbility": {
  9 + "ability": "EntryAbility",
  10 + "executeMode": [
  11 + "background",
  12 + "foreground"
  13 + ]
  14 + }
  15 + }
  16 + ]
  17 +}