Merge branch 'main' of http://192.168.1.42/developOne/harmonyPool
Showing
23 changed files
with
820 additions
and
376 deletions
| @@ -77,18 +77,32 @@ export class PermissionUtil { | @@ -77,18 +77,32 @@ export class PermissionUtil { | ||
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | 79 | ||
| 80 | - static openPermissionsInSystemSettings(component: Object): void { | ||
| 81 | - let context = getContext(component) as common.UIAbilityContext; | ||
| 82 | - let wantInfo:Want = { | ||
| 83 | - action: 'action.settings.app.info', | 80 | + /**跳转设置页面*/ |
| 81 | + static openPermissionsInSystemSettings(context: Object): void { | ||
| 82 | + let uiContext = getContext(context) as common.UIAbilityContext; | ||
| 83 | + let wantInfo: Want = { | ||
| 84 | + bundleName: 'com.huawei.hmos.settings', | ||
| 85 | + abilityName: 'com.huawei.hmos.settings.MainAbility', | ||
| 86 | + uri: 'application_info_entry', | ||
| 84 | parameters: { | 87 | parameters: { |
| 85 | - settingsParamBundleName: AppUtils.getPackageName(context) // 打开指定应用的详情页面 | 88 | + pushParams: AppUtils.getPackageName(uiContext) // 打开指定应用的设置页面 |
| 86 | } | 89 | } |
| 87 | } | 90 | } |
| 88 | - context.startAbility(wantInfo).then(() => { | ||
| 89 | - // ... | ||
| 90 | - }).catch((err:Error) => { | ||
| 91 | - // ... | ||
| 92 | - }) | 91 | + uiContext.startAbility(wantInfo) |
| 93 | } | 92 | } |
| 93 | + | ||
| 94 | + // static openPermissionsInSystemSettings(component: Object): void { | ||
| 95 | + // let context = getContext(component) as common.UIAbilityContext; | ||
| 96 | + // let wantInfo:Want = { | ||
| 97 | + // action: 'action.settings.app.info', | ||
| 98 | + // parameters: { | ||
| 99 | + // settingsParamBundleName: AppUtils.getPackageName(context) // 打开指定应用的详情页面 | ||
| 100 | + // } | ||
| 101 | + // } | ||
| 102 | + // context.startAbility(wantInfo).then(() => { | ||
| 103 | + // // ... | ||
| 104 | + // }).catch((err:Error) => { | ||
| 105 | + // // ... | ||
| 106 | + // }) | ||
| 107 | + // } | ||
| 94 | } | 108 | } |
| @@ -24,6 +24,7 @@ export class UserDataLocal { | @@ -24,6 +24,7 @@ export class UserDataLocal { | ||
| 24 | static USER_HEADER_URL="userHeaderUrl" | 24 | static USER_HEADER_URL="userHeaderUrl" |
| 25 | static USER_LEVEL="userLevel" | 25 | static USER_LEVEL="userLevel" |
| 26 | static USER_LEVEL_HEADER_URL="userLevelHeaderUrl" | 26 | static USER_LEVEL_HEADER_URL="userLevelHeaderUrl" |
| 27 | + static USER_FOLLOW_OPERATION="user_follow_operation" | ||
| 27 | 28 | ||
| 28 | //刷新token 用到 | 29 | //刷新token 用到 |
| 29 | static USER_REFRESH_TOKEN="refreshToken" | 30 | static USER_REFRESH_TOKEN="refreshToken" |
| @@ -89,6 +90,10 @@ export class UserDataLocal { | @@ -89,6 +90,10 @@ export class UserDataLocal { | ||
| 89 | SPHelper.default.save(UserDataLocal.USER_HEADER_URL, url) | 90 | SPHelper.default.save(UserDataLocal.USER_HEADER_URL, url) |
| 90 | } | 91 | } |
| 91 | 92 | ||
| 93 | + public static setUserFollowOperation(timestamp:string) { | ||
| 94 | + SPHelper.default.saveSync(UserDataLocal.USER_FOLLOW_OPERATION, timestamp) | ||
| 95 | + } | ||
| 96 | + | ||
| 92 | 97 | ||
| 93 | public static getUserLevel() { | 98 | public static getUserLevel() { |
| 94 | if(UserDataLocal.userLevel != -1){ | 99 | if(UserDataLocal.userLevel != -1){ |
| @@ -281,6 +281,11 @@ export class HttpUrlUtils { | @@ -281,6 +281,11 @@ export class HttpUrlUtils { | ||
| 281 | * 更新 兴趣偏好 | 281 | * 更新 兴趣偏好 |
| 282 | */ | 282 | */ |
| 283 | static readonly INTERESTS_UPDATETAG_PATH: string = "/api/rmrb-user-center/user/zh/c/tag/updateUserTag"; | 283 | static readonly INTERESTS_UPDATETAG_PATH: string = "/api/rmrb-user-center/user/zh/c/tag/updateUserTag"; |
| 284 | + /** | ||
| 285 | + * 获取启动页相关数据 | ||
| 286 | + */ | ||
| 287 | + static readonly LAUNCH_PAGE_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/launchPage"; | ||
| 288 | + | ||
| 284 | private static _hostUrl: string = HttpUrlUtils.HOST_PRODUCT; | 289 | private static _hostUrl: string = HttpUrlUtils.HOST_PRODUCT; |
| 285 | /** | 290 | /** |
| 286 | * 推荐列表 | 291 | * 推荐列表 |
| @@ -714,6 +719,12 @@ export class HttpUrlUtils { | @@ -714,6 +719,12 @@ export class HttpUrlUtils { | ||
| 714 | return url; | 719 | return url; |
| 715 | } | 720 | } |
| 716 | 721 | ||
| 722 | + static getLaunchPageDataUrl() { | ||
| 723 | + let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LAUNCH_PAGE_PATH; | ||
| 724 | + return url; | ||
| 725 | + | ||
| 726 | + } | ||
| 727 | + | ||
| 717 | static getLiveDetailsUrl() { | 728 | static getLiveDetailsUrl() { |
| 718 | let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_DETAILS_PATH | 729 | let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_DETAILS_PATH |
| 719 | return url | 730 | return url |
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/QualityCommentsComponent.ets
| @@ -174,7 +174,7 @@ export struct QualityCommentsComponent { | @@ -174,7 +174,7 @@ export struct QualityCommentsComponent { | ||
| 174 | // ListItemGroup({ header: this.titleHeader() }) | 174 | // ListItemGroup({ header: this.titleHeader() }) |
| 175 | LazyForEach(this.allDatas, (item: commentItemModel, index: number) => { | 175 | LazyForEach(this.allDatas, (item: commentItemModel, index: number) => { |
| 176 | ListItem() { | 176 | ListItem() { |
| 177 | - QualityCommentItem({ item: item }).margin({ left: 12, right: 12 }) | 177 | + QualityCommentItem({ item: item, index:index }).margin({ left: 12, right: 12 }) |
| 178 | } | 178 | } |
| 179 | }) | 179 | }) |
| 180 | ListItem() { | 180 | ListItem() { |
| @@ -217,6 +217,7 @@ export struct QualityCommentsComponent { | @@ -217,6 +217,7 @@ export struct QualityCommentsComponent { | ||
| 217 | @Component | 217 | @Component |
| 218 | struct QualityCommentItem { | 218 | struct QualityCommentItem { |
| 219 | @ObjectLink item: commentItemModel | 219 | @ObjectLink item: commentItemModel |
| 220 | + index:number = 0 | ||
| 220 | 221 | ||
| 221 | build() { | 222 | build() { |
| 222 | Column() { | 223 | Column() { |
| @@ -326,6 +327,7 @@ struct QualityCommentItem { | @@ -326,6 +327,7 @@ struct QualityCommentItem { | ||
| 326 | } | 327 | } |
| 327 | }.onClick(() => { | 328 | }.onClick(() => { |
| 328 | this.item.api_status = !this.item.api_status | 329 | this.item.api_status = !this.item.api_status |
| 330 | + | ||
| 329 | // commentViewModel.commnetLikeChange(this.item) | 331 | // commentViewModel.commnetLikeChange(this.item) |
| 330 | commentViewModel.commentLike(this.item).then(() => { | 332 | commentViewModel.commentLike(this.item).then(() => { |
| 331 | 333 |
| 1 | -import { StringUtils, ToastUtils } from 'wdKit/Index' | 1 | +import { DateTimeUtils, StringUtils, ToastUtils, UserDataLocal } from 'wdKit/Index' |
| 2 | import { HttpUrlUtils } from 'wdNetwork/Index' | 2 | import { HttpUrlUtils } from 'wdNetwork/Index' |
| 3 | import { WDRouterRule, WDRouterPage } from 'wdRouter/Index' | 3 | import { WDRouterRule, WDRouterPage } from 'wdRouter/Index' |
| 4 | import MinePageDatasModel from '../../../model/MinePageDatasModel' | 4 | import MinePageDatasModel from '../../../model/MinePageDatasModel' |
| @@ -133,14 +133,17 @@ export struct FollowChildComponent{ | @@ -133,14 +133,17 @@ export struct FollowChildComponent{ | ||
| 133 | .maxLines(1) | 133 | .maxLines(1) |
| 134 | .margin({bottom:'12lpx'}) | 134 | .margin({bottom:'12lpx'}) |
| 135 | Row(){ | 135 | Row(){ |
| 136 | - Text(`粉丝${this.data.cnFansNum}`) | ||
| 137 | - .fontColor($r('app.color.color_B0B0B0')) | ||
| 138 | - .fontSize('23lpx') | ||
| 139 | - | ||
| 140 | - Image($r("app.media.point")) | ||
| 141 | - .width('31lpx') | ||
| 142 | - .height('31lpx') | ||
| 143 | - .objectFit(ImageFit.Auto) | 136 | + if(this.data.cnFansNum!="0"){ |
| 137 | + Text(`粉丝${this.data.cnFansNum}`) | ||
| 138 | + .fontColor($r('app.color.color_B0B0B0')) | ||
| 139 | + .fontSize('23lpx') | ||
| 140 | + } | ||
| 141 | + if(this.data.cnFansNum!="0" && StringUtils.isNotEmpty(this.data.introduction)){ | ||
| 142 | + Image($r("app.media.point")) | ||
| 143 | + .width('31lpx') | ||
| 144 | + .height('31lpx') | ||
| 145 | + .objectFit(ImageFit.Auto) | ||
| 146 | + } | ||
| 144 | 147 | ||
| 145 | Text(`${this.data.introduction}`) | 148 | Text(`${this.data.introduction}`) |
| 146 | .fontColor($r('app.color.color_B0B0B0')) | 149 | .fontColor($r('app.color.color_B0B0B0')) |
| @@ -222,6 +225,12 @@ export struct FollowChildComponent{ | @@ -222,6 +225,12 @@ export struct FollowChildComponent{ | ||
| 222 | if(value!=null){ | 225 | if(value!=null){ |
| 223 | if (value.code === 0 || value.code.toString() === "0") { | 226 | if (value.code === 0 || value.code.toString() === "0") { |
| 224 | this.data.status = this.data.status ==="0"?"1":"0" | 227 | this.data.status = this.data.status ==="0"?"1":"0" |
| 228 | + | ||
| 229 | + if(this.data.status === "1"){ | ||
| 230 | + UserDataLocal.setUserFollowOperation(DateTimeUtils.getTimeStamp()+"") | ||
| 231 | + }else{ | ||
| 232 | + UserDataLocal.setUserFollowOperation(DateTimeUtils.getTimeStamp()+","+this.data.creatorId) | ||
| 233 | + } | ||
| 225 | } | 234 | } |
| 226 | } | 235 | } |
| 227 | }) | 236 | }) |
| 1 | -import { LazyDataSource } from 'wdKit'; | 1 | +import { LazyDataSource, SPHelper, UserDataLocal } from 'wdKit'; |
| 2 | import MinePageDatasModel from '../../../model/MinePageDatasModel'; | 2 | import MinePageDatasModel from '../../../model/MinePageDatasModel'; |
| 3 | import SearcherAboutDataModel from '../../../model/SearcherAboutDataModel'; | 3 | import SearcherAboutDataModel from '../../../model/SearcherAboutDataModel'; |
| 4 | import { CreatorDetailRequestItem } from '../../../viewmodel/CreatorDetailRequestItem'; | 4 | import { CreatorDetailRequestItem } from '../../../viewmodel/CreatorDetailRequestItem'; |
| @@ -9,50 +9,55 @@ import { MineFollowListDetailItem } from '../../../viewmodel/MineFollowListDetai | @@ -9,50 +9,55 @@ import { MineFollowListDetailItem } from '../../../viewmodel/MineFollowListDetai | ||
| 9 | import { QueryListIsFollowedItem } from '../../../viewmodel/QueryListIsFollowedItem'; | 9 | import { QueryListIsFollowedItem } from '../../../viewmodel/QueryListIsFollowedItem'; |
| 10 | import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI'; | 10 | import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI'; |
| 11 | import { FollowChildComponent } from './FollowChildComponent'; | 11 | import { FollowChildComponent } from './FollowChildComponent'; |
| 12 | +import dataPreferences from '@ohos.data.preferences'; | ||
| 12 | 13 | ||
| 13 | const TAG = "FollowListDetailUI" | 14 | const TAG = "FollowListDetailUI" |
| 15 | + | ||
| 14 | @Component | 16 | @Component |
| 15 | -export struct FollowListDetailUI{ | ||
| 16 | - @State creatorDirectoryId:number = -1; | ||
| 17 | - @State type:number = 0 | 17 | +export struct FollowListDetailUI { |
| 18 | + @State creatorDirectoryId: number = -1; | ||
| 19 | + @State type: number = 0 | ||
| 18 | @State data: LazyDataSource<FollowListDetailItem> = new LazyDataSource(); | 20 | @State data: LazyDataSource<FollowListDetailItem> = new LazyDataSource(); |
| 19 | - @State count:number = 0; | ||
| 20 | - @State isLoading:boolean = false | ||
| 21 | - @State hasMore:boolean = true | ||
| 22 | - curPageNum:number = 1; | 21 | + @State count: number = 0; |
| 22 | + @State isLoading: boolean = false | ||
| 23 | + @State hasMore: boolean = true | ||
| 24 | + curPageNum: number = 1; | ||
| 25 | + preferences: dataPreferences.Preferences | null = null; | ||
| 23 | 26 | ||
| 24 | - aboutToAppear(){ | 27 | + aboutToAppear() { |
| 25 | this.getNewPageData() | 28 | this.getNewPageData() |
| 29 | + this.addFollowStatusObserver() | ||
| 26 | } | 30 | } |
| 27 | 31 | ||
| 28 | - build(){ | ||
| 29 | - Column(){ | ||
| 30 | - if(this.count === 0){ | ||
| 31 | - ListHasNoMoreDataUI({style:2}) | 32 | + build() { |
| 33 | + Column() { | ||
| 34 | + if (this.count === 0) { | ||
| 35 | + ListHasNoMoreDataUI({ style: 2 }) | ||
| 32 | .height('100%') | 36 | .height('100%') |
| 33 | - }else{ | 37 | + } else { |
| 34 | List({ space: 3 }) { | 38 | List({ space: 3 }) { |
| 35 | LazyForEach(this.data, (item: FollowListDetailItem, index: number = 0) => { | 39 | LazyForEach(this.data, (item: FollowListDetailItem, index: number = 0) => { |
| 36 | ListItem() { | 40 | ListItem() { |
| 37 | - FollowChildComponent({data: item,type:this.type}) | 41 | + FollowChildComponent({ data: item, type: this.type }) |
| 38 | } | 42 | } |
| 39 | .onClick(() => { | 43 | .onClick(() => { |
| 40 | }) | 44 | }) |
| 41 | - }, (item: FollowListDetailItem, index: number) => index.toString()) | 45 | + }, (item: FollowListDetailItem) => item.creatorId) |
| 42 | 46 | ||
| 43 | //没有更多数据 显示提示 | 47 | //没有更多数据 显示提示 |
| 44 | - if(!this.hasMore){ | ||
| 45 | - ListItem(){ | 48 | + if (!this.hasMore) { |
| 49 | + ListItem() { | ||
| 46 | ListHasNoMoreDataUI() | 50 | ListHasNoMoreDataUI() |
| 47 | } | 51 | } |
| 48 | } | 52 | } |
| 49 | - }.cachedCount(10) | ||
| 50 | - .padding({left:'31lpx',right:'31lpx'}) | 53 | + } |
| 54 | + .cachedCount(10) | ||
| 55 | + .padding({ left: '31lpx', right: '31lpx' }) | ||
| 51 | .layoutWeight(1) | 56 | .layoutWeight(1) |
| 52 | .scrollBar(BarState.Off) | 57 | .scrollBar(BarState.Off) |
| 53 | - .onReachEnd(()=>{ | ||
| 54 | - console.log(TAG,"触底了"); | ||
| 55 | - if(!this.isLoading){ | 58 | + .onReachEnd(() => { |
| 59 | + console.log(TAG, "触底了"); | ||
| 60 | + if (!this.isLoading) { | ||
| 56 | this.isLoading = true | 61 | this.isLoading = true |
| 57 | //加载分页数据 | 62 | //加载分页数据 |
| 58 | this.getNewPageData() | 63 | this.getNewPageData() |
| @@ -63,79 +68,128 @@ export struct FollowListDetailUI{ | @@ -63,79 +68,128 @@ export struct FollowListDetailUI{ | ||
| 63 | .width('100%') | 68 | .width('100%') |
| 64 | } | 69 | } |
| 65 | 70 | ||
| 66 | - getNewPageData(){ | ||
| 67 | - this.isLoading = true | ||
| 68 | - //我的关注列表 | ||
| 69 | - if (this.creatorDirectoryId === -1){ | ||
| 70 | - if(this.hasMore){ | ||
| 71 | - let object = new FollowListDetailRequestItem(-1,20,this.curPageNum) | ||
| 72 | - | ||
| 73 | - MinePageDatasModel.getMineFollowListData(object,getContext(this)).then((value)=>{ | ||
| 74 | - if (!this.data || value.list.length == 0){ | ||
| 75 | - this.hasMore = false | 71 | + async addFollowStatusObserver() { |
| 72 | + this.preferences = await SPHelper.default.getPreferences(); | ||
| 73 | + let observer = (key: string) => { | ||
| 74 | + if (key == UserDataLocal.USER_FOLLOW_OPERATION) { | ||
| 75 | + if (this.creatorDirectoryId === -1) { | ||
| 76 | + let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION,"") as string | ||
| 77 | + let arr = value.split(',') | ||
| 78 | + if(arr!=null && arr.length === 2){ | ||
| 79 | + this.data.getDataArray().forEach((element,index) => { | ||
| 80 | + if (element.creatorId === arr[1]) { | ||
| 81 | + this.data.deleteItem(index) | ||
| 82 | + } | ||
| 83 | + }); | ||
| 76 | }else{ | 84 | }else{ |
| 77 | - value.list.forEach((value)=>{ | ||
| 78 | - this.data.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,value.fansNum+"",value.introduction,value.attentionCreatorId,"1",value.attentionUserId,value.attentionUserType,value.attentionUserId,value.mainControl,value.banControl)) | ||
| 79 | - }) | ||
| 80 | - this.data.notifyDataReload() | ||
| 81 | - this.count = this.data.totalCount() | ||
| 82 | - if (this.data.totalCount() < value.totalCount) { | ||
| 83 | - this.curPageNum++ | ||
| 84 | - }else { | ||
| 85 | - this.hasMore = false | 85 | + if(!this.isLoading){ |
| 86 | + this.isLoading = true | ||
| 87 | + this.hasMore = true | ||
| 88 | + this.curPageNum = 1 | ||
| 89 | + this.data.clear() | ||
| 90 | + this.data.notifyDataReload() | ||
| 91 | + this.getMyFollowListDetail() | ||
| 86 | } | 92 | } |
| 87 | } | 93 | } |
| 88 | - this.isLoading = false | ||
| 89 | - }).catch((err:Error)=>{ | ||
| 90 | - console.log(TAG,"请求失败") | ||
| 91 | - this.isLoading = false | ||
| 92 | - }) | 94 | + } |
| 93 | } | 95 | } |
| 94 | - }else{ | ||
| 95 | - if(this.hasMore){ | ||
| 96 | - let object = new FollowListDetailRequestItem(this.creatorDirectoryId,20,this.curPageNum) | 96 | + } |
| 97 | + this.preferences.on('change', observer); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + getMyFollowListDetail() { | ||
| 101 | + if (this.hasMore) { | ||
| 102 | + let object = new FollowListDetailRequestItem(-1, 20, this.curPageNum) | ||
| 97 | 103 | ||
| 98 | - MinePageDatasModel.getFollowListDetailData(object,getContext(this)).then((value)=>{ | ||
| 99 | - if (!this.data || value.list.length == 0){ | 104 | + MinePageDatasModel.getMineFollowListData(object, getContext(this)).then((value) => { |
| 105 | + if (!this.data || value.list.length == 0) { | ||
| 106 | + this.hasMore = false | ||
| 107 | + this.isLoading = false | ||
| 108 | + } else { | ||
| 109 | + value.list.forEach((value) => { | ||
| 110 | + let fansNum:number = value.fansNum | ||
| 111 | + let fansNumString = "" | ||
| 112 | + if (fansNum > 10000) { | ||
| 113 | + let temp = (fansNum / 10000) + "" | ||
| 114 | + let index = temp.indexOf('.') | ||
| 115 | + if (index != -1) { | ||
| 116 | + temp = temp.substring(0, index + 2) | ||
| 117 | + } else { | ||
| 118 | + temp = temp | ||
| 119 | + } | ||
| 120 | + fansNumString = temp + "万" | ||
| 121 | + } else { | ||
| 122 | + fansNumString = fansNum + "" | ||
| 123 | + } | ||
| 124 | + this.data.push(new FollowListDetailItem(value.attentionHeadPhotoUrl, value.attentionUserName, fansNumString, value.introduction, value.attentionCreatorId, "1", value.attentionUserId, value.attentionUserType, value.attentionUserId, value.mainControl, value.banControl)) | ||
| 125 | + }) | ||
| 126 | + this.data.notifyDataReload() | ||
| 127 | + this.count = this.data.totalCount() | ||
| 128 | + if (this.data.totalCount() < value.totalCount) { | ||
| 129 | + this.curPageNum++ | ||
| 130 | + } else { | ||
| 131 | + this.hasMore = false | ||
| 132 | + } | ||
| 133 | + } | ||
| 134 | + this.isLoading = false | ||
| 135 | + }).catch((err: Error) => { | ||
| 136 | + console.log(TAG, "请求失败") | ||
| 137 | + this.isLoading = false | ||
| 138 | + }) | ||
| 139 | + }else { | ||
| 140 | + this.isLoading = false | ||
| 141 | + } | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + getNewPageData() { | ||
| 145 | + //我的关注列表 | ||
| 146 | + if (this.creatorDirectoryId === -1) { | ||
| 147 | + this.getMyFollowListDetail() | ||
| 148 | + } else { | ||
| 149 | + if (this.hasMore) { | ||
| 150 | + let object = new FollowListDetailRequestItem(this.creatorDirectoryId, 20, this.curPageNum) | ||
| 151 | + | ||
| 152 | + MinePageDatasModel.getFollowListDetailData(object, getContext(this)).then((value) => { | ||
| 153 | + if (!this.data || value.list.length == 0) { | ||
| 100 | this.hasMore = false | 154 | this.hasMore = false |
| 101 | this.isLoading = false | 155 | this.isLoading = false |
| 102 | - }else{ | 156 | + } else { |
| 103 | this.getFollowListStatus(value) | 157 | this.getFollowListStatus(value) |
| 104 | } | 158 | } |
| 105 | - }).catch((err:Error)=>{ | ||
| 106 | - console.log(TAG,"请求失败") | 159 | + }).catch((err: Error) => { |
| 160 | + console.log(TAG, "请求失败") | ||
| 107 | this.isLoading = false | 161 | this.isLoading = false |
| 108 | }) | 162 | }) |
| 109 | } | 163 | } |
| 110 | } | 164 | } |
| 111 | } | 165 | } |
| 112 | 166 | ||
| 113 | - getFollowListStatus(result:MineFollowListDetailItem){ | ||
| 114 | - let data_temp : FollowListDetailItem[] = [] | ||
| 115 | - result.list.forEach((item)=>{ | ||
| 116 | - data_temp.push(new FollowListDetailItem(item.headPhotoUrl,item.cnUserName,item.cnFansNum,item.introduction,item.creatorId,"0",item.attentionUserId,item.cnUserType,item.cnUserId,item.cnMainControl,-1)) | 167 | + getFollowListStatus(result: MineFollowListDetailItem) { |
| 168 | + let data_temp: FollowListDetailItem[] = [] | ||
| 169 | + result.list.forEach((item) => { | ||
| 170 | + data_temp.push(new FollowListDetailItem(item.headPhotoUrl, item.cnUserName, item.cnFansNum, item.introduction, item.creatorId, "0", item.attentionUserId, item.cnUserType, item.cnUserId, item.cnMainControl, -1)) | ||
| 117 | }) | 171 | }) |
| 118 | let request = new CreatorDetailRequestItem() | 172 | let request = new CreatorDetailRequestItem() |
| 119 | 173 | ||
| 120 | - data_temp.forEach((data)=>{ | 174 | + data_temp.forEach((data) => { |
| 121 | request.creatorIdList.push(data.creatorId) | 175 | request.creatorIdList.push(data.creatorId) |
| 122 | }) | 176 | }) |
| 123 | - SearcherAboutDataModel.getCreatorDetailListData(request).then((value)=>{ | ||
| 124 | - if(value!=null && value.length>0){ | ||
| 125 | - data_temp.forEach((data)=>{ | ||
| 126 | - value.forEach((item)=>{ | ||
| 127 | - if(data.creatorId == item.creatorId){ | 177 | + SearcherAboutDataModel.getCreatorDetailListData(request).then((value) => { |
| 178 | + if (value != null && value.length > 0) { | ||
| 179 | + data_temp.forEach((data) => { | ||
| 180 | + value.forEach((item) => { | ||
| 181 | + if (data.creatorId == item.creatorId) { | ||
| 128 | data.headPhotoUrl = item.headPhotoUrl | 182 | data.headPhotoUrl = item.headPhotoUrl |
| 129 | - if(item.fansNum>10000){ | ||
| 130 | - let temp = (item.fansNum/10000)+"" | 183 | + if (item.fansNum > 10000) { |
| 184 | + let temp = (item.fansNum / 10000) + "" | ||
| 131 | let index = temp.indexOf('.') | 185 | let index = temp.indexOf('.') |
| 132 | - if(index != -1){ | ||
| 133 | - temp = temp.substring(0,index+2) | ||
| 134 | - }else{ | 186 | + if (index != -1) { |
| 187 | + temp = temp.substring(0, index + 2) | ||
| 188 | + } else { | ||
| 135 | temp = temp | 189 | temp = temp |
| 136 | } | 190 | } |
| 137 | data.cnFansNum = temp + "万" | 191 | data.cnFansNum = temp + "万" |
| 138 | - }else{ | 192 | + } else { |
| 139 | data.cnFansNum = item.fansNum + "" | 193 | data.cnFansNum = item.fansNum + "" |
| 140 | } | 194 | } |
| 141 | data.introduction = item.introduction | 195 | data.introduction = item.introduction |
| @@ -144,32 +198,32 @@ export struct FollowListDetailUI{ | @@ -144,32 +198,32 @@ export struct FollowListDetailUI{ | ||
| 144 | } | 198 | } |
| 145 | }) | 199 | }) |
| 146 | }) | 200 | }) |
| 147 | - this.getFollowStatus(data_temp,result.totalCount) | 201 | + this.getFollowStatus(data_temp, result.totalCount) |
| 148 | } | 202 | } |
| 149 | - }).catch((err:Error)=>{ | ||
| 150 | - console.log(TAG,JSON.stringify(err)) | 203 | + }).catch((err: Error) => { |
| 204 | + console.log(TAG, JSON.stringify(err)) | ||
| 151 | this.isLoading = false | 205 | this.isLoading = false |
| 152 | - this.count = this.count===-1?0:this.count | 206 | + this.count = this.count === -1 ? 0 : this.count |
| 153 | }) | 207 | }) |
| 154 | } | 208 | } |
| 155 | 209 | ||
| 156 | - getFollowStatus(result : FollowListDetailItem[],totalCount:number){ | 210 | + getFollowStatus(result: FollowListDetailItem[], totalCount: number) { |
| 157 | let status = new FollowListStatusRequestItem() | 211 | let status = new FollowListStatusRequestItem() |
| 158 | - result.forEach((item)=>{ | 212 | + result.forEach((item) => { |
| 159 | status.creatorIds.push(new QueryListIsFollowedItem(item.creatorId)) | 213 | status.creatorIds.push(new QueryListIsFollowedItem(item.creatorId)) |
| 160 | }) | 214 | }) |
| 161 | 215 | ||
| 162 | - MinePageDatasModel.getFollowListStatusData(status,getContext(this)).then((newValue)=>{ | ||
| 163 | - newValue.forEach((item)=>{ | ||
| 164 | - result.forEach((list)=>{ | 216 | + MinePageDatasModel.getFollowListStatusData(status, getContext(this)).then((newValue) => { |
| 217 | + newValue.forEach((item) => { | ||
| 218 | + result.forEach((list) => { | ||
| 165 | if (item.creatorId == list.creatorId) { | 219 | if (item.creatorId == list.creatorId) { |
| 166 | list.status = item.status | 220 | list.status = item.status |
| 167 | } | 221 | } |
| 168 | }) | 222 | }) |
| 169 | }) | 223 | }) |
| 170 | 224 | ||
| 171 | - result.forEach((item)=>{ | ||
| 172 | - this.data.push(new FollowListDetailItem(item.headPhotoUrl,item.cnUserName,item.cnFansNum,item.introduction,item.creatorId,item.status,item.attentionUserId,item.cnUserType,item.cnUserId,item.mainControl,item.banControl)) | 225 | + result.forEach((item) => { |
| 226 | + this.data.push(new FollowListDetailItem(item.headPhotoUrl, item.cnUserName, item.cnFansNum, item.introduction, item.creatorId, item.status, item.attentionUserId, item.cnUserType, item.cnUserId, item.mainControl, item.banControl)) | ||
| 173 | }) | 227 | }) |
| 174 | 228 | ||
| 175 | this.data.notifyDataReload() | 229 | this.data.notifyDataReload() |
| @@ -177,15 +231,14 @@ export struct FollowListDetailUI{ | @@ -177,15 +231,14 @@ export struct FollowListDetailUI{ | ||
| 177 | this.count = this.data.totalCount() | 231 | this.count = this.data.totalCount() |
| 178 | if (this.data.totalCount() < totalCount) { | 232 | if (this.data.totalCount() < totalCount) { |
| 179 | this.curPageNum++ | 233 | this.curPageNum++ |
| 180 | - }else { | 234 | + } else { |
| 181 | this.hasMore = false | 235 | this.hasMore = false |
| 182 | } | 236 | } |
| 183 | 237 | ||
| 184 | this.isLoading = false | 238 | this.isLoading = false |
| 185 | - }).catch((err:Error)=>{ | ||
| 186 | - console.log(TAG,"请求失败") | 239 | + }).catch((err: Error) => { |
| 240 | + console.log(TAG, "请求失败") | ||
| 187 | this.isLoading = false | 241 | this.isLoading = false |
| 188 | }) | 242 | }) |
| 189 | } | 243 | } |
| 190 | - | ||
| 191 | } | 244 | } |
| 1 | import { Params } from 'wdBean'; | 1 | import { Params } from 'wdBean'; |
| 2 | -import { DateTimeUtils, LazyDataSource,UserDataLocal } from 'wdKit'; | 2 | +import { DateTimeUtils, LazyDataSource, SPHelper,UserDataLocal } from 'wdKit'; |
| 3 | import { WDRouterPage, WDRouterRule } from 'wdRouter'; | 3 | import { WDRouterPage, WDRouterRule } from 'wdRouter'; |
| 4 | import MinePageDatasModel from '../../../model/MinePageDatasModel'; | 4 | import MinePageDatasModel from '../../../model/MinePageDatasModel'; |
| 5 | import { CommentListItem } from '../../../viewmodel/CommentListItem'; | 5 | import { CommentListItem } from '../../../viewmodel/CommentListItem'; |
| @@ -7,6 +7,7 @@ import { FollowListDetailItem } from '../../../viewmodel/FollowListDetailItem'; | @@ -7,6 +7,7 @@ import { FollowListDetailItem } from '../../../viewmodel/FollowListDetailItem'; | ||
| 7 | import { FollowListDetailRequestItem } from '../../../viewmodel/FollowListDetailRequestItem'; | 7 | import { FollowListDetailRequestItem } from '../../../viewmodel/FollowListDetailRequestItem'; |
| 8 | import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI'; | 8 | import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI'; |
| 9 | import { FollowChildComponent } from '../follow/FollowChildComponent'; | 9 | import { FollowChildComponent } from '../follow/FollowChildComponent'; |
| 10 | +import dataPreferences from '@ohos.data.preferences'; | ||
| 10 | 11 | ||
| 11 | const TAG = "HomePageBottomComponent" | 12 | const TAG = "HomePageBottomComponent" |
| 12 | @Component | 13 | @Component |
| @@ -21,9 +22,38 @@ export struct HomePageBottomComponent{ | @@ -21,9 +22,38 @@ export struct HomePageBottomComponent{ | ||
| 21 | @State isMineAccount:boolean = true; | 22 | @State isMineAccount:boolean = true; |
| 22 | @State userId:string = ""; | 23 | @State userId:string = ""; |
| 23 | @Link commentNum:number | 24 | @Link commentNum:number |
| 25 | + preferences: dataPreferences.Preferences | null = null; | ||
| 24 | 26 | ||
| 25 | aboutToAppear(){ | 27 | aboutToAppear(){ |
| 26 | this.getNewPageData() | 28 | this.getNewPageData() |
| 29 | + this.addFollowStatusObserver() | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + async addFollowStatusObserver() { | ||
| 33 | + this.preferences = await SPHelper.default.getPreferences(); | ||
| 34 | + let observer = (key: string) => { | ||
| 35 | + if (key == UserDataLocal.USER_FOLLOW_OPERATION) { | ||
| 36 | + let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION,"") as string | ||
| 37 | + let arr = value.split(',') | ||
| 38 | + if(arr!=null && arr.length === 2){ | ||
| 39 | + this.data_follow.getDataArray().forEach((element,index) => { | ||
| 40 | + if (element.creatorId === arr[1]) { | ||
| 41 | + this.data_follow.deleteItem(index) | ||
| 42 | + } | ||
| 43 | + }); | ||
| 44 | + }else{ | ||
| 45 | + if(!this.isLoading){ | ||
| 46 | + this.isLoading = true | ||
| 47 | + this.hasMore = true | ||
| 48 | + this.curPageNum = 1 | ||
| 49 | + this.data_follow.clear() | ||
| 50 | + this.data_follow.notifyDataReload() | ||
| 51 | + this.getMyFollowListDetail() | ||
| 52 | + } | ||
| 53 | + } | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + this.preferences.on('change', observer); | ||
| 27 | } | 57 | } |
| 28 | 58 | ||
| 29 | build(){ | 59 | build(){ |
| @@ -175,34 +205,55 @@ export struct HomePageBottomComponent{ | @@ -175,34 +205,55 @@ export struct HomePageBottomComponent{ | ||
| 175 | .borderRadius(12) | 205 | .borderRadius(12) |
| 176 | } | 206 | } |
| 177 | 207 | ||
| 208 | + | ||
| 209 | + getMyFollowListDetail(){ | ||
| 210 | + if(this.hasMore){ | ||
| 211 | + let object = new FollowListDetailRequestItem(-1,20,this.curPageNum) | ||
| 212 | + | ||
| 213 | + MinePageDatasModel.getMineFollowListData(object,getContext(this)).then((value)=>{ | ||
| 214 | + if (!this.data_follow || value.list.length == 0){ | ||
| 215 | + this.hasMore = false | ||
| 216 | + }else{ | ||
| 217 | + value.list.forEach((value)=>{ | ||
| 218 | + let fansNum:number = value.fansNum | ||
| 219 | + let fansNumString = "" | ||
| 220 | + if (fansNum > 10000) { | ||
| 221 | + let temp = (fansNum / 10000) + "" | ||
| 222 | + let index = temp.indexOf('.') | ||
| 223 | + if (index != -1) { | ||
| 224 | + temp = temp.substring(0, index + 2) | ||
| 225 | + } else { | ||
| 226 | + temp = temp | ||
| 227 | + } | ||
| 228 | + fansNumString = temp + "万" | ||
| 229 | + } else { | ||
| 230 | + fansNumString = fansNum + "" | ||
| 231 | + } | ||
| 232 | + this.data_follow.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,fansNumString,value.introduction,value.attentionCreatorId,"1",value.attentionUserId,value.attentionUserType,value.attentionUserId,value.mainControl,value.banControl)) | ||
| 233 | + }) | ||
| 234 | + this.data_follow.notifyDataReload() | ||
| 235 | + this.count = this.data_follow.totalCount() | ||
| 236 | + if (this.data_follow.totalCount() < value.totalCount) { | ||
| 237 | + this.curPageNum++ | ||
| 238 | + }else { | ||
| 239 | + this.hasMore = false | ||
| 240 | + } | ||
| 241 | + } | ||
| 242 | + this.isLoading = false | ||
| 243 | + }).catch((err:Error)=>{ | ||
| 244 | + console.log(TAG,"请求失败") | ||
| 245 | + this.isLoading = false | ||
| 246 | + }) | ||
| 247 | + }else{ | ||
| 248 | + this.isLoading = false | ||
| 249 | + } | ||
| 250 | + } | ||
| 251 | + | ||
| 178 | getNewPageData(){ | 252 | getNewPageData(){ |
| 179 | this.isLoading = true | 253 | this.isLoading = true |
| 180 | //我的关注列表 | 254 | //我的关注列表 |
| 181 | if (this.style === 1){ | 255 | if (this.style === 1){ |
| 182 | - if(this.hasMore){ | ||
| 183 | - let object = new FollowListDetailRequestItem(-1,20,this.curPageNum) | ||
| 184 | - | ||
| 185 | - MinePageDatasModel.getMineFollowListData(object,getContext(this)).then((value)=>{ | ||
| 186 | - if (!this.data_follow || value.list.length == 0){ | ||
| 187 | - this.hasMore = false | ||
| 188 | - }else{ | ||
| 189 | - value.list.forEach((value)=>{ | ||
| 190 | - this.data_follow.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,value.fansNum+"",value.introduction,value.attentionCreatorId,"1",value.attentionUserId,value.attentionUserType,value.attentionUserId,value.mainControl,value.banControl)) | ||
| 191 | - }) | ||
| 192 | - this.data_follow.notifyDataReload() | ||
| 193 | - this.count = this.data_follow.totalCount() | ||
| 194 | - if (this.data_follow.totalCount() < value.totalCount) { | ||
| 195 | - this.curPageNum++ | ||
| 196 | - }else { | ||
| 197 | - this.hasMore = false | ||
| 198 | - } | ||
| 199 | - } | ||
| 200 | - this.isLoading = false | ||
| 201 | - }).catch((err:Error)=>{ | ||
| 202 | - console.log(TAG,"请求失败") | ||
| 203 | - this.isLoading = false | ||
| 204 | - }) | ||
| 205 | - } | 256 | + this.getMyFollowListDetail() |
| 206 | }else if(this.style === 0){ | 257 | }else if(this.style === 0){ |
| 207 | if(this.hasMore){ | 258 | if(this.hasMore){ |
| 208 | let time = encodeURI(DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN)) | 259 | let time = encodeURI(DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN)) |
| @@ -230,6 +281,8 @@ export struct HomePageBottomComponent{ | @@ -230,6 +281,8 @@ export struct HomePageBottomComponent{ | ||
| 230 | console.log(TAG,"请求失败") | 281 | console.log(TAG,"请求失败") |
| 231 | this.isLoading = false | 282 | this.isLoading = false |
| 232 | }) | 283 | }) |
| 284 | + }else{ | ||
| 285 | + this.isLoading = false | ||
| 233 | } | 286 | } |
| 234 | } | 287 | } |
| 235 | } | 288 | } |
| 1 | +import dataPreferences from '@ohos.data.preferences'; | ||
| 2 | +import { PermissionUtil } from 'wdKit' | ||
| 3 | +import { SPHelper } from 'wdKit' | ||
| 4 | +import hilog from '@ohos.hilog'; | ||
| 5 | +import { PrivacySettingModel } from '../../model/PrivacySettingModel' | ||
| 6 | +import { Params } from 'wdBean'; | ||
| 7 | +import { WDRouterPage, WDRouterRule } from 'wdRouter'; | ||
| 8 | + | ||
| 9 | +const TAG = 'PrivacySettingPage'; | ||
| 10 | +const DiyString = '开启个性化推荐' | ||
| 11 | +const DiyCloseTipsString = '关闭后,将不会使用你的偏好进行内容推荐' | ||
| 1 | 12 | ||
| 2 | -import { PrivacySettingComponents } from '../setting/PrivacySettingComponents'; | ||
| 3 | @Entry | 13 | @Entry |
| 4 | @Component | 14 | @Component |
| 5 | -struct PrivacySettingPage { | 15 | +export struct PrivacySettingPage { |
| 16 | + @State listData: Array<PrivacySettingModel> = [new PrivacySettingModel(DiyString, false, 'ohos.permission.READ_MEDIA'), new PrivacySettingModel('相册权限', false, 'ohos.permission.READ_MEDIA'), new PrivacySettingModel('相机权限', false, 'ohos.permission.CAMERA'), new PrivacySettingModel('定位权限', false, 'ohos.permission.APPROXIMATELY_LOCATION'), new PrivacySettingModel('麦克风权限', false, 'ohos.permission.MICROPHONE')]; | ||
| 17 | + tips: string = '设置前可查阅' | ||
| 18 | + privacyTips: string = '《隐私政策》' | ||
| 19 | + tipsEnd = '中相应权限使用规则' | ||
| 20 | + | ||
| 21 | + onPageShow(): void { | ||
| 22 | + this.getPermissionStatus(); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + aboutToAppear() { | ||
| 26 | + // 获取权限= | ||
| 27 | + // SPHelper.default.save('sdf','sdf'); | ||
| 28 | + // this.initListData(); | ||
| 29 | + this.getPermissionStatus(); | ||
| 30 | + // RefreshStatus; | ||
| 31 | + | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + async getPermissionStatus() { | ||
| 35 | + const permissionUtil = new PermissionUtil(); | ||
| 36 | + for (const element of this.listData) { | ||
| 37 | + if (element.privacyName == DiyString) { | ||
| 38 | + element.queryUserDetail(); | ||
| 39 | + // element.permission = true; | ||
| 40 | + continue; | ||
| 41 | + } | ||
| 42 | + const result = await permissionUtil.checkPermissions(element.permissionKey); | ||
| 43 | + element.permission = result; | ||
| 44 | + } | ||
| 45 | + } | ||
| 46 | + | ||
| 6 | build() { | 47 | build() { |
| 7 | - Column(){ | ||
| 8 | - PrivacySettingComponents() | 48 | + Navigation() { |
| 49 | + //滑动区域 | ||
| 50 | + this.PrivacySettingComponentsUI() | ||
| 51 | + | ||
| 52 | + }.titleMode(NavigationTitleMode.Mini) | ||
| 53 | + .title('隐私设置') | ||
| 54 | + .backgroundColor('#F8F8F8') | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + @Builder PrivacySettingComponentsUI() { | ||
| 58 | + Column() { | ||
| 59 | + | ||
| 60 | + List({ space: '23lpx' }) { | ||
| 61 | + ForEach(this.listData, (item: PrivacySettingModel, index:number) => { | ||
| 62 | + ListItem() { | ||
| 63 | + if (index == 0) { | ||
| 64 | + getTuiJianCell({ item:item, index:index }); | ||
| 65 | + } else { | ||
| 66 | + getArrowCell({ item:item, index:index }); | ||
| 67 | + } | ||
| 68 | + }.onClick(() => { | ||
| 69 | + if (index != 0) { | ||
| 70 | + if (!item.permission) { | ||
| 71 | + //跳转权限设置 | ||
| 72 | + const permissionUtil = new PermissionUtil(); | ||
| 73 | + PermissionUtil.reqPermissionsFromUser([item.permissionKey], this).then((res)=>{ | ||
| 74 | + item.permission = res; | ||
| 75 | + }); | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + }) | ||
| 79 | + }) | ||
| 80 | + } | ||
| 81 | + .padding({ left: '29lpx', right: '29lpx' }) | ||
| 82 | + .margin({ top: '38lpx' }) | ||
| 83 | + | ||
| 84 | + Row() { | ||
| 85 | + Text(this.tips) | ||
| 86 | + .fontSize('25lpx') | ||
| 87 | + .textAlign(TextAlign.Start) | ||
| 88 | + .fontColor($r("app.color.color_666666")) | ||
| 89 | + .margin({ left: '29lpx', top: '46lpx' }) | ||
| 90 | + // .backgroundColor(Color.Orange) | ||
| 91 | + Text(this.privacyTips) | ||
| 92 | + .fontSize('25lpx') | ||
| 93 | + .textAlign(TextAlign.Start) | ||
| 94 | + .fontColor('#ED2800') | ||
| 95 | + .margin({ top: '46lpx' }) | ||
| 96 | + .onClick(() => { | ||
| 97 | + //跳转隐私政策 | ||
| 98 | + let bean={contentID:"2",pageID:""} as Params | ||
| 99 | + WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean) | ||
| 100 | + }) | ||
| 101 | + Text(this.tipsEnd) | ||
| 102 | + .fontSize('25lpx') | ||
| 103 | + .textAlign(TextAlign.Start) | ||
| 104 | + .fontColor($r("app.color.color_666666")) | ||
| 105 | + .margin({ top: '46lpx' }) | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + } | ||
| 109 | + .width('100%') | ||
| 110 | + .height('100%') | ||
| 111 | + .backgroundColor('#F8F8F8') | ||
| 112 | + .alignItems(HorizontalAlign.Start) | ||
| 113 | + } | ||
| 114 | +} | ||
| 115 | + | ||
| 116 | + | ||
| 117 | +@Component | ||
| 118 | +struct getArrowCell { | ||
| 119 | + @ObjectLink item: PrivacySettingModel; | ||
| 120 | + index:number = 0; | ||
| 121 | + // 右文字+箭头cell | ||
| 122 | + // @Builder getArrowCell(item:PrivacySettingModel, index) { | ||
| 123 | + build() { | ||
| 124 | + Row() { | ||
| 125 | + // 左侧标题 | ||
| 126 | + Text(this.item.privacyName) | ||
| 127 | + .fontColor('#666666') | ||
| 128 | + .fontSize('31lpx') | ||
| 129 | + | ||
| 130 | + Row() { | ||
| 131 | + Text(this.item.permission ? '已开启' : '去设置') | ||
| 132 | + .fontColor(this.item.permission ? '#666666' : '#CCCCCC') | ||
| 133 | + .fontSize('31lpx') | ||
| 134 | + .margin({ right: '8lpx' }) | ||
| 135 | + | ||
| 136 | + Image($r('app.media.mine_user_arrow')) | ||
| 137 | + .width('27lpx') | ||
| 138 | + .height('27lpx') | ||
| 139 | + .objectFit(ImageFit.Auto) | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + } | ||
| 143 | + .alignItems(VerticalAlign.Center) | ||
| 144 | + .justifyContent(FlexAlign.SpaceBetween) | ||
| 145 | + .height('97lpx') | ||
| 146 | + .width('100%') | ||
| 147 | + .padding({ left: '29lpx', right: '29lpx' }) | ||
| 148 | + .backgroundColor('#FFFFFF') | ||
| 149 | + .borderRadius('8lpx') | ||
| 150 | + } | ||
| 151 | +} | ||
| 152 | + | ||
| 153 | +@Component | ||
| 154 | +struct getTuiJianCell { | ||
| 155 | + @ObjectLink item: PrivacySettingModel; | ||
| 156 | + index:number = 0; | ||
| 157 | + build() { | ||
| 158 | + Column() { | ||
| 159 | + | ||
| 160 | + Row() { | ||
| 161 | + // 左侧标题 | ||
| 162 | + Text(this.item.privacyName) | ||
| 163 | + .fontColor('#666666') | ||
| 164 | + .fontSize('31lpx') | ||
| 165 | + | ||
| 166 | + Row() { | ||
| 167 | + Toggle({ type: ToggleType.Switch, isOn: this.item.permission }) | ||
| 168 | + .height('58lpx') | ||
| 169 | + .width('96lpx') | ||
| 170 | + .selectedColor('#ED2700') | ||
| 171 | + .onChange((isOn: boolean) => { | ||
| 172 | + // this.privacySwitch = isOn; | ||
| 173 | + this.item.editUserDetail(isOn?'1':'0'); | ||
| 174 | + }) | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + } | ||
| 178 | + .alignItems(VerticalAlign.Center) | ||
| 179 | + .justifyContent(FlexAlign.SpaceBetween) | ||
| 180 | + .height('97lpx') | ||
| 181 | + .width('100%') | ||
| 182 | + | ||
| 183 | + | ||
| 184 | + Blank() | ||
| 185 | + .backgroundColor('#EDEDED') | ||
| 186 | + .height('1lpx') | ||
| 187 | + | ||
| 188 | + Text(DiyCloseTipsString) | ||
| 189 | + .fontColor('#999999') | ||
| 190 | + .fontSize('23lpx') | ||
| 191 | + .margin({ right: '8lpx' }) | ||
| 192 | + .height('69lpx') | ||
| 193 | + | ||
| 9 | } | 194 | } |
| 195 | + .alignItems(HorizontalAlign.Start) | ||
| 196 | + .backgroundColor('#FFFFFF') | ||
| 197 | + .borderRadius('8lpx') | ||
| 198 | + .padding({ left: '29lpx', right: '29lpx' }) | ||
| 10 | } | 199 | } |
| 11 | -} | ||
| 200 | +} |
| 1 | -import dataPreferences from '@ohos.data.preferences'; | ||
| 2 | -import { PermissionUtil } from 'wdKit' | ||
| 3 | -import { SPHelper } from 'wdKit' | ||
| 4 | -import hilog from '@ohos.hilog'; | ||
| 5 | -import { PrivacySettingModel } from '../../model/PrivacySettingModel' | ||
| 6 | -import { Params } from 'wdBean'; | ||
| 7 | -import { WDRouterPage, WDRouterRule } from 'wdRouter'; | ||
| 8 | - | ||
| 9 | -const TAG = 'PrivacySettingComponents'; | ||
| 10 | - | ||
| 11 | -@Component | ||
| 12 | -export struct PrivacySettingComponents { | ||
| 13 | - @State listData: Array<PrivacySettingModel> = [new PrivacySettingModel('开启个性推荐', false, 'ohos.permission.READ_MEDIA'), new PrivacySettingModel('相册权限', false, 'ohos.permission.READ_MEDIA'), new PrivacySettingModel('相机权限', false, 'ohos.permission.CAMERA'), new PrivacySettingModel('定位权限', false, 'ohos.permission.APPROXIMATELY_LOCATION'), new PrivacySettingModel('麦克风权限', false, 'ohos.permission.MICROPHONE')]; | ||
| 14 | - @State tips: string = '设置前可查阅' | ||
| 15 | - @State privacyTips: string = '《隐私政策》' | ||
| 16 | - | ||
| 17 | - aboutToAppear() { | ||
| 18 | - // 获取权限= | ||
| 19 | - // SPHelper.default.save('sdf','sdf'); | ||
| 20 | - // this.initListData(); | ||
| 21 | - this.getPermissionStatus(); | ||
| 22 | - // RefreshStatus; | ||
| 23 | - | ||
| 24 | - } | ||
| 25 | - | ||
| 26 | - async getPermissionStatus() { | ||
| 27 | - const permissionUtil = new PermissionUtil(); | ||
| 28 | - for (const element of this.listData) { | ||
| 29 | - if (element.privacyName == '开启个性推荐') { | ||
| 30 | - element.queryUserDetail(); | ||
| 31 | - // element.permission = true; | ||
| 32 | - continue; | ||
| 33 | - } | ||
| 34 | - const result = await permissionUtil.checkPermissions(element.permissionKey); | ||
| 35 | - element.permission = result; | ||
| 36 | - } | ||
| 37 | - } | ||
| 38 | - | ||
| 39 | - build() { | ||
| 40 | - Navigation() { | ||
| 41 | - //滑动区域 | ||
| 42 | - this.PrivacySettingComponentsUI() | ||
| 43 | - | ||
| 44 | - }.titleMode(NavigationTitleMode.Mini) | ||
| 45 | - .title('隐私设置') | ||
| 46 | - .backgroundColor('#F8F8F8') | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - @Builder PrivacySettingComponentsUI() { | ||
| 50 | - Column() { | ||
| 51 | - | ||
| 52 | - List({ space: '23lpx' }) { | ||
| 53 | - ForEach(this.listData, (item: PrivacySettingModel, index:number) => { | ||
| 54 | - ListItem() { | ||
| 55 | - if (index == 0) { | ||
| 56 | - getTuiJianCell({ item:item, index:index }); | ||
| 57 | - } else { | ||
| 58 | - getArrowCell({ item:item, index:index }); | ||
| 59 | - } | ||
| 60 | - }.onClick(() => { | ||
| 61 | - if (index != 0) { | ||
| 62 | - if (!item.permission) { | ||
| 63 | - //跳转权限设置 | ||
| 64 | - const permissionUtil = new PermissionUtil(); | ||
| 65 | - PermissionUtil.reqPermissionsFromUser([item.permissionKey], this).then((res)=>{ | ||
| 66 | - item.permission = res; | ||
| 67 | - }); | ||
| 68 | - } | ||
| 69 | - } | ||
| 70 | - }) | ||
| 71 | - }) | ||
| 72 | - } | ||
| 73 | - .padding({ left: '29lpx', right: '29lpx' }) | ||
| 74 | - .margin({ top: '38lpx' }) | ||
| 75 | - | ||
| 76 | - Row() { | ||
| 77 | - Text(this.tips) | ||
| 78 | - .fontSize('25lpx') | ||
| 79 | - .textAlign(TextAlign.Start) | ||
| 80 | - .fontColor($r("app.color.color_666666")) | ||
| 81 | - .margin({ left: '29lpx', top: '46lpx' }) | ||
| 82 | - // .backgroundColor(Color.Orange) | ||
| 83 | - Text(this.privacyTips) | ||
| 84 | - .fontSize('25lpx') | ||
| 85 | - .textAlign(TextAlign.Start) | ||
| 86 | - .fontColor('#ED2800') | ||
| 87 | - .margin({ top: '46lpx' }) | ||
| 88 | - .onClick(() => { | ||
| 89 | - //跳转隐私政策 | ||
| 90 | - let bean={contentId:"2",pageID:""} as Params | ||
| 91 | - WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean) | ||
| 92 | - }) | ||
| 93 | - } | ||
| 94 | - | ||
| 95 | - } | ||
| 96 | - .width('100%') | ||
| 97 | - .height('100%') | ||
| 98 | - .backgroundColor('#F8F8F8') | ||
| 99 | - .alignItems(HorizontalAlign.Start) | ||
| 100 | - } | ||
| 101 | -} | ||
| 102 | - | ||
| 103 | - | ||
| 104 | -@Component | ||
| 105 | -struct getArrowCell { | ||
| 106 | - @ObjectLink item: PrivacySettingModel; | ||
| 107 | - index:number = 0; | ||
| 108 | - // 右文字+箭头cell | ||
| 109 | - // @Builder getArrowCell(item:PrivacySettingModel, index) { | ||
| 110 | - build() { | ||
| 111 | - Row() { | ||
| 112 | - // 左侧标题 | ||
| 113 | - Text(this.item.privacyName) | ||
| 114 | - .fontColor('#666666') | ||
| 115 | - .fontSize('31lpx') | ||
| 116 | - | ||
| 117 | - Row() { | ||
| 118 | - Text(this.item.permission ? '已开启' : '去设置') | ||
| 119 | - .fontColor(this.item.permission ? '#666666' : '#CCCCCC') | ||
| 120 | - .fontSize('31lpx') | ||
| 121 | - .margin({ right: '8lpx' }) | ||
| 122 | - | ||
| 123 | - Image($r('app.media.mine_user_arrow')) | ||
| 124 | - .width('27lpx') | ||
| 125 | - .height('27lpx') | ||
| 126 | - .objectFit(ImageFit.Auto) | ||
| 127 | - } | ||
| 128 | - | ||
| 129 | - } | ||
| 130 | - .alignItems(VerticalAlign.Center) | ||
| 131 | - .justifyContent(FlexAlign.SpaceBetween) | ||
| 132 | - .height('97lpx') | ||
| 133 | - .width('100%') | ||
| 134 | - .padding({ left: '29lpx', right: '29lpx' }) | ||
| 135 | - .backgroundColor('#FFFFFF') | ||
| 136 | - .borderRadius('8lpx') | ||
| 137 | - } | ||
| 138 | -} | ||
| 139 | - | ||
| 140 | -@Component | ||
| 141 | -struct getTuiJianCell { | ||
| 142 | - @ObjectLink item: PrivacySettingModel; | ||
| 143 | - index:number = 0; | ||
| 144 | - build() { | ||
| 145 | - Column() { | ||
| 146 | - | ||
| 147 | - Row() { | ||
| 148 | - // 左侧标题 | ||
| 149 | - Text(this.item.privacyName) | ||
| 150 | - .fontColor('#666666') | ||
| 151 | - .fontSize('31lpx') | ||
| 152 | - | ||
| 153 | - Row() { | ||
| 154 | - Toggle({ type: ToggleType.Switch, isOn: this.item.permission }) | ||
| 155 | - .height('58lpx') | ||
| 156 | - .width('96lpx') | ||
| 157 | - // .selectedColor(Color.Pink) | ||
| 158 | - .onChange((isOn: boolean) => { | ||
| 159 | - // this.privacySwitch = isOn; | ||
| 160 | - this.item.editUserDetail(isOn?'1':'0'); | ||
| 161 | - }) | ||
| 162 | - } | ||
| 163 | - | ||
| 164 | - } | ||
| 165 | - .alignItems(VerticalAlign.Center) | ||
| 166 | - .justifyContent(FlexAlign.SpaceBetween) | ||
| 167 | - .height('97lpx') | ||
| 168 | - .width('100%') | ||
| 169 | - | ||
| 170 | - | ||
| 171 | - Blank() | ||
| 172 | - .backgroundColor('#EDEDED') | ||
| 173 | - .height('1lpx') | ||
| 174 | - | ||
| 175 | - Text('关闭后,将无法看到个性化推荐的服务') | ||
| 176 | - .fontColor('#999999') | ||
| 177 | - .fontSize('23lpx') | ||
| 178 | - .margin({ right: '8lpx' }) | ||
| 179 | - .height('69lpx') | ||
| 180 | - | ||
| 181 | - } | ||
| 182 | - .alignItems(HorizontalAlign.Start) | ||
| 183 | - .backgroundColor('#FFFFFF') | ||
| 184 | - .borderRadius('8lpx') | ||
| 185 | - .padding({ left: '29lpx', right: '29lpx' }) | ||
| 186 | - } | ||
| 187 | -} |
| @@ -3,9 +3,17 @@ import { EmptyComponent } from '../view/EmptyComponent' | @@ -3,9 +3,17 @@ import { EmptyComponent } from '../view/EmptyComponent' | ||
| 3 | @Entry | 3 | @Entry |
| 4 | @Component | 4 | @Component |
| 5 | export struct DefaultPage { | 5 | export struct DefaultPage { |
| 6 | + retry() { | ||
| 7 | + console.log('daj点击了重试') | ||
| 8 | + } | ||
| 9 | + | ||
| 6 | build() { | 10 | build() { |
| 7 | Row() { | 11 | Row() { |
| 8 | - EmptyComponent({ emptyType: 8 }) | 12 | + EmptyComponent({ |
| 13 | + emptyType: 8, emptyButton: true, retry: () => { | ||
| 14 | + this.retry() | ||
| 15 | + } | ||
| 16 | + }) | ||
| 9 | } | 17 | } |
| 10 | } | 18 | } |
| 11 | } | 19 | } |
| @@ -37,10 +37,6 @@ export const enum WDViewDefaultType { | @@ -37,10 +37,6 @@ export const enum WDViewDefaultType { | ||
| 37 | WDViewDefaultType_NoVisitAccount, | 37 | WDViewDefaultType_NoVisitAccount, |
| 38 | /// 15.暂无关注 | 38 | /// 15.暂无关注 |
| 39 | WDViewDefaultType_NoFollow, | 39 | WDViewDefaultType_NoFollow, |
| 40 | - /// 16.直播结束 | ||
| 41 | - WDViewDefaultType_NoLiveEnd, | ||
| 42 | - /// 17.直播暂停 | ||
| 43 | - WDViewDefaultType_NoLiveSuspend, | ||
| 44 | /// 18.视频加载失败 | 40 | /// 18.视频加载失败 |
| 45 | WDViewDefaultType_NoVideo, | 41 | WDViewDefaultType_NoVideo, |
| 46 | /// 19.暂无内容1 | 42 | /// 19.暂无内容1 |
| @@ -56,7 +52,9 @@ export struct EmptyComponent { | @@ -56,7 +52,9 @@ export struct EmptyComponent { | ||
| 56 | // private emptySize: SizeOptions = {}; | 52 | // private emptySize: SizeOptions = {}; |
| 57 | @State emptyWidth: string | number = CommonConstants.FULL_PARENT; | 53 | @State emptyWidth: string | number = CommonConstants.FULL_PARENT; |
| 58 | @State emptyHeight: string | number = CommonConstants.FULL_PARENT; | 54 | @State emptyHeight: string | number = CommonConstants.FULL_PARENT; |
| 59 | - @State emptyType: number = WDViewDefaultType.WDViewDefaultType_Default | 55 | + @State emptyType: number = WDViewDefaultType.WDViewDefaultType_Default; |
| 56 | + @State emptyButton: boolean = false | ||
| 57 | + @State timeNum: number = 10 | ||
| 60 | /** | 58 | /** |
| 61 | * The empty image width percentage setting. | 59 | * The empty image width percentage setting. |
| 62 | */ | 60 | */ |
| @@ -73,6 +71,42 @@ export struct EmptyComponent { | @@ -73,6 +71,42 @@ export struct EmptyComponent { | ||
| 73 | * The empty data text opacity. | 71 | * The empty data text opacity. |
| 74 | */ | 72 | */ |
| 75 | readonly TEXT_OPACITY: number = 0.4; | 73 | readonly TEXT_OPACITY: number = 0.4; |
| 74 | + private timer: number = -1 | ||
| 75 | + retry: () => void = () => { | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + createTimer() { | ||
| 79 | + if (this.emptyType === 8) { | ||
| 80 | + this.timer = setInterval(() => { | ||
| 81 | + this.timeNum--; | ||
| 82 | + if (this.timeNum === 0) { | ||
| 83 | + clearInterval(this.timer); | ||
| 84 | + } | ||
| 85 | + }, 1000); | ||
| 86 | + } | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + destroyTimer() { | ||
| 90 | + if (this.emptyType === 8) { | ||
| 91 | + clearInterval(this.timer); | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + onPageShow(): void { | ||
| 96 | + this.createTimer() | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + aboutToAppear(): void { | ||
| 100 | + this.createTimer() | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + onPageHide(): void { | ||
| 104 | + this.destroyTimer() | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + aboutToDisappear() { | ||
| 108 | + this.destroyTimer() | ||
| 109 | + } | ||
| 76 | 110 | ||
| 77 | build() { | 111 | build() { |
| 78 | this.noProgrammeData(); | 112 | this.noProgrammeData(); |
| @@ -90,7 +124,7 @@ export struct EmptyComponent { | @@ -90,7 +124,7 @@ export struct EmptyComponent { | ||
| 90 | .objectFit(ImageFit.Contain) | 124 | .objectFit(ImageFit.Contain) |
| 91 | // .border({ width: 1, color: Color.Red, radius: 6 }) | 125 | // .border({ width: 1, color: Color.Red, radius: 6 }) |
| 92 | 126 | ||
| 93 | - Text(this.buildNoDataTip()) | 127 | + Text(this.emptyType !== 8 ? this.buildNoDataTip() : `${this.buildNoDataTip()}(${this.timeNum}s)`) |
| 94 | .fontSize($r('app.float.normal_text_size')) | 128 | .fontSize($r('app.float.normal_text_size')) |
| 95 | .fontColor('#000000') | 129 | .fontColor('#000000') |
| 96 | .fontWeight(FontWeight.Normal) | 130 | .fontWeight(FontWeight.Normal) |
| @@ -99,6 +133,23 @@ export struct EmptyComponent { | @@ -99,6 +133,23 @@ export struct EmptyComponent { | ||
| 99 | .onClick((event: ClickEvent) => { | 133 | .onClick((event: ClickEvent) => { |
| 100 | Logger.info(TAG, `noProgrammeData onClick event?.source: ${event.source}`); | 134 | Logger.info(TAG, `noProgrammeData onClick event?.source: ${event.source}`); |
| 101 | }) | 135 | }) |
| 136 | + | ||
| 137 | + if (this.emptyButton) { | ||
| 138 | + Button('点击重试') | ||
| 139 | + .type(ButtonType.Normal) | ||
| 140 | + .width(80) | ||
| 141 | + .height(28) | ||
| 142 | + .backgroundColor('#fffffff') | ||
| 143 | + .fontColor('#FF666666') | ||
| 144 | + .border({ width: 1 }) | ||
| 145 | + .borderColor('#FFEDEDED') | ||
| 146 | + .fontSize($r('app.float.font_size_12')) | ||
| 147 | + .margin({ top: 16 }) | ||
| 148 | + .padding(0) | ||
| 149 | + .onClick(() => { | ||
| 150 | + this.retry() | ||
| 151 | + }) | ||
| 152 | + } | ||
| 102 | } | 153 | } |
| 103 | .justifyContent(FlexAlign.Center) | 154 | .justifyContent(FlexAlign.Center) |
| 104 | .width(this.emptyWidth) | 155 | .width(this.emptyWidth) |
| @@ -127,13 +178,9 @@ export struct EmptyComponent { | @@ -127,13 +178,9 @@ export struct EmptyComponent { | ||
| 127 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoBooking) { | 178 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoBooking) { |
| 128 | contentString = '暂无预约' | 179 | contentString = '暂无预约' |
| 129 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NetworkFailed) { | 180 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NetworkFailed) { |
| 130 | - contentString = '' // 前方拥堵,请耐心等待 | 181 | + contentString = '前方拥堵,请耐心等待...' // 前方拥堵,请耐心等待... |
| 131 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVisitAccount) { | 182 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVisitAccount) { |
| 132 | contentString = '该号主暂时无法访问' // 前方拥堵,请耐心等待 | 183 | contentString = '该号主暂时无法访问' // 前方拥堵,请耐心等待 |
| 133 | - } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveEnd) { | ||
| 134 | - contentString = '直播已结束' // 前方拥堵,请耐心等待 | ||
| 135 | - } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveSuspend) { | ||
| 136 | - contentString = '主播暂时离开,马上回来' // 前方拥堵,请耐心等待 | ||
| 137 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVideo) { | 184 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVideo) { |
| 138 | contentString = '获取内容失败请重试' // 前方拥堵,请耐心等待 | 185 | contentString = '获取内容失败请重试' // 前方拥堵,请耐心等待 |
| 139 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoContent1) { | 186 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoContent1) { |
| @@ -163,15 +210,13 @@ export struct EmptyComponent { | @@ -163,15 +210,13 @@ export struct EmptyComponent { | ||
| 163 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoBooking) { | 210 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoBooking) { |
| 164 | imageString = $r('app.media.icon_no_appointmentMade') | 211 | imageString = $r('app.media.icon_no_appointmentMade') |
| 165 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NetworkFailed) { | 212 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NetworkFailed) { |
| 166 | - imageString = $r('app.media.icon_no_net') | 213 | + imageString = $r('app.media.icon_no_limiting') |
| 167 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVisitAccount) { | 214 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVisitAccount) { |
| 168 | imageString = $r('app.media.icon_no_master1') | 215 | imageString = $r('app.media.icon_no_master1') |
| 169 | - } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveEnd) { | ||
| 170 | - imageString = $r('app.media.icon_no_end') | ||
| 171 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVideo) { | 216 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVideo) { |
| 172 | imageString = $r('app.media.icon_no_content') | 217 | imageString = $r('app.media.icon_no_content') |
| 173 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoContent1) { | 218 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoContent1) { |
| 174 | - imageString = $r('app.media.icon_no_appointmentMade') | 219 | + imageString = $r('app.media.icon_no_appointmentMade1') |
| 175 | } | 220 | } |
| 176 | return imageString | 221 | return imageString |
| 177 | } | 222 | } |
| 1 | +import { CommonConstants } from 'wdConstant'; | ||
| 2 | +import { Logger } from 'wdKit'; | ||
| 3 | + | ||
| 4 | +const TAG = 'LiveEmptyComponent'; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * WDViewDefaultType 缺省页 | ||
| 8 | + */ | ||
| 9 | +export const enum WDViewDefaultType { | ||
| 10 | + /// 1.默认 | ||
| 11 | + WDViewDefaultType_Default, | ||
| 12 | + /// 16.直播结束 | ||
| 13 | + WDViewDefaultType_NoLiveEnd, | ||
| 14 | + /// 17.直播暂停 | ||
| 15 | + WDViewDefaultType_NoLiveSuspend, | ||
| 16 | + | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * 空数据/无数据 | ||
| 21 | + */ | ||
| 22 | +@Preview | ||
| 23 | +@Component | ||
| 24 | +export struct LiveEmptyComponent { | ||
| 25 | + // private emptySize: SizeOptions = {}; | ||
| 26 | + @State emptyWidth: string | number = CommonConstants.FULL_PARENT; | ||
| 27 | + @State emptyHeight: string | number = CommonConstants.FULL_PARENT; | ||
| 28 | + @State emptyType: number = WDViewDefaultType.WDViewDefaultType_Default | ||
| 29 | + /** | ||
| 30 | + * The empty image width percentage setting. | ||
| 31 | + */ | ||
| 32 | + readonly EMPTY_IMAGE_WIDTH: string = '15%'; | ||
| 33 | + /** | ||
| 34 | + * The empty image height percentage setting. | ||
| 35 | + */ | ||
| 36 | + readonly EMPTY_IMAGE_HEIGHT: string = '15%'; | ||
| 37 | + /** | ||
| 38 | + * The empty data text component margin top. | ||
| 39 | + */ | ||
| 40 | + readonly EMPTY_TIP_TEXT_MARGIN_TOP: string = '10'; | ||
| 41 | + /** | ||
| 42 | + * The empty data text opacity. | ||
| 43 | + */ | ||
| 44 | + readonly TEXT_OPACITY: number = 0.4; | ||
| 45 | + | ||
| 46 | + build() { | ||
| 47 | + this.noProgrammeData(); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * 无数据,空白view组件 | ||
| 52 | + */ | ||
| 53 | + @Builder | ||
| 54 | + noProgrammeData() { | ||
| 55 | + Column() { | ||
| 56 | + Image(this.buildNoDataTipImage()) | ||
| 57 | + .width('this.EMPTY_IMAGE_WIDTH') | ||
| 58 | + .height(this.EMPTY_IMAGE_HEIGHT) | ||
| 59 | + .objectFit(ImageFit.Contain) | ||
| 60 | + // .border({ width: 1, color: Color.Red, radius: 6 }) | ||
| 61 | + | ||
| 62 | + Text(this.buildNoDataTip()) | ||
| 63 | + .fontSize($r('app.float.normal_text_size')) | ||
| 64 | + .fontColor('#000000') | ||
| 65 | + .fontWeight(FontWeight.Normal) | ||
| 66 | + .opacity(this.TEXT_OPACITY) | ||
| 67 | + .margin({ top: this.EMPTY_TIP_TEXT_MARGIN_TOP }) | ||
| 68 | + .onClick((event: ClickEvent) => { | ||
| 69 | + Logger.info(TAG, `noProgrammeData onClick event?.source: ${event.source}`); | ||
| 70 | + }) | ||
| 71 | + } | ||
| 72 | + .justifyContent(FlexAlign.Center) | ||
| 73 | + .width(this.emptyWidth) | ||
| 74 | + .height(this.emptyHeight) | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + buildNoDataTip(): string { | ||
| 78 | + Logger.info(TAG, "buildNoDataTip"); | ||
| 79 | + let contentString: string = '暂无内容' | ||
| 80 | + if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveEnd) { | ||
| 81 | + contentString = '直播已结束' // 前方拥堵,请耐心等待 | ||
| 82 | + } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveSuspend) { | ||
| 83 | + contentString = '主播暂时离开,马上回来' // 前方拥堵,请耐心等待 | ||
| 84 | + } | ||
| 85 | + return contentString | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + buildNoDataTipImage(): Resource | string { | ||
| 89 | + Logger.info(TAG, "buildNoDataTip"); | ||
| 90 | + let imageString: Resource | string = $r('app.media.icon_no_content') | ||
| 91 | + if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveEnd) { | ||
| 92 | + imageString = $r('app.media.icon_no_end') | ||
| 93 | + } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveSuspend) { | ||
| 94 | + imageString = $r('app.media.icon_no_liver') | ||
| 95 | + } | ||
| 96 | + return imageString | ||
| 97 | + } | ||
| 98 | +} |
| @@ -45,7 +45,7 @@ class MineSettingDatasModel{ | @@ -45,7 +45,7 @@ class MineSettingDatasModel{ | ||
| 45 | this.mainSettingData.push(new MineMainSettingFunctionItem(null, '隐私设罝', null, 0, false)) | 45 | this.mainSettingData.push(new MineMainSettingFunctionItem(null, '隐私设罝', null, 0, false)) |
| 46 | this.mainSettingData.push(new MineMainSettingFunctionItem(null, '仅WiFi网络加载图片', null, 1, false)) | 46 | this.mainSettingData.push(new MineMainSettingFunctionItem(null, '仅WiFi网络加载图片', null, 1, false)) |
| 47 | this.mainSettingData.push(new MineMainSettingFunctionItem(null, 'WiFi网络情况下自动播放视频', null, 1, false)) | 47 | this.mainSettingData.push(new MineMainSettingFunctionItem(null, 'WiFi网络情况下自动播放视频', null, 1, false)) |
| 48 | - this.mainSettingData.push(new MineMainSettingFunctionItem(null, '开户播放器悬浮窗', null, 1, false)) | 48 | + this.mainSettingData.push(new MineMainSettingFunctionItem(null, '开启播放器悬浮窗', null, 1, false)) |
| 49 | this.mainSettingData.push(new MineMainSettingFunctionItem(null, null, null, 2, null)) | 49 | this.mainSettingData.push(new MineMainSettingFunctionItem(null, null, null, 2, null)) |
| 50 | this.mainSettingData.push(new MineMainSettingFunctionItem(null, '清除缓存', '32MB', 0, false)) | 50 | this.mainSettingData.push(new MineMainSettingFunctionItem(null, '清除缓存', '32MB', 0, false)) |
| 51 | this.mainSettingData.push(new MineMainSettingFunctionItem(null, '评价我们', null, 0, false)) | 51 | this.mainSettingData.push(new MineMainSettingFunctionItem(null, '评价我们', null, 0, false)) |
| @@ -9,12 +9,14 @@ import { Logger, WindowModel } from 'wdKit/Index'; | @@ -9,12 +9,14 @@ import { Logger, WindowModel } from 'wdKit/Index'; | ||
| 9 | import { window } from '@kit.ArkUI'; | 9 | import { window } from '@kit.ArkUI'; |
| 10 | import { devicePLSensorManager } from 'wdDetailPlayApi/Index'; | 10 | import { devicePLSensorManager } from 'wdDetailPlayApi/Index'; |
| 11 | import { LiveCommentComponent } from 'wdComponent/Index'; | 11 | import { LiveCommentComponent } from 'wdComponent/Index'; |
| 12 | +import { WDPlayerController } from 'wdPlayer/Index'; | ||
| 12 | 13 | ||
| 13 | @Entry | 14 | @Entry |
| 14 | @Component | 15 | @Component |
| 15 | export struct DetailPlayLivePage { | 16 | export struct DetailPlayLivePage { |
| 16 | //横竖屏,默认竖屏 | 17 | //横竖屏,默认竖屏 |
| 17 | @Provide displayDirection: DisplayDirection = DisplayDirection.VERTICAL | 18 | @Provide displayDirection: DisplayDirection = DisplayDirection.VERTICAL |
| 19 | + playerController: WDPlayerController = new WDPlayerController(); | ||
| 18 | TAG: string = 'DetailPlayLivePage'; | 20 | TAG: string = 'DetailPlayLivePage'; |
| 19 | liveViewModel: LiveViewModel = new LiveViewModel() | 21 | liveViewModel: LiveViewModel = new LiveViewModel() |
| 20 | @State relId: string = '' | 22 | @State relId: string = '' |
| @@ -23,18 +25,19 @@ export struct DetailPlayLivePage { | @@ -23,18 +25,19 @@ export struct DetailPlayLivePage { | ||
| 23 | @Provide liveDetailsBean: LiveDetailsBean = {} as LiveDetailsBean | 25 | @Provide liveDetailsBean: LiveDetailsBean = {} as LiveDetailsBean |
| 24 | @Provide liveRoomDataBean: LiveRoomDataBean = {} as LiveRoomDataBean | 26 | @Provide liveRoomDataBean: LiveRoomDataBean = {} as LiveRoomDataBean |
| 25 | @State tabs: string[] = [] | 27 | @State tabs: string[] = [] |
| 28 | + //监听屏幕横竖屏变化 | ||
| 29 | + listener = mediaquery.matchMediaSync('(orientation: landscape)'); | ||
| 26 | 30 | ||
| 27 | aboutToAppear(): void { | 31 | aboutToAppear(): void { |
| 28 | - //监听屏幕横竖屏变化 | ||
| 29 | - let listener = mediaquery.matchMediaSync('(orientation: landscape)'); | ||
| 30 | - listener.on("change", (mediaQueryResult) => { | 32 | + Logger.info(this.TAG, `wyj-aboutToAppear`) |
| 33 | + this.listener?.on("change", (mediaQueryResult) => { | ||
| 31 | Logger.info(this.TAG, `change;${mediaQueryResult.matches}`) | 34 | Logger.info(this.TAG, `change;${mediaQueryResult.matches}`) |
| 32 | - if (mediaQueryResult.matches) { | 35 | + if (mediaQueryResult?.matches) { |
| 33 | this.displayDirection = DisplayDirection.VIDEO_HORIZONTAL | 36 | this.displayDirection = DisplayDirection.VIDEO_HORIZONTAL |
| 34 | } else { | 37 | } else { |
| 35 | this.displayDirection = DisplayDirection.VERTICAL | 38 | this.displayDirection = DisplayDirection.VERTICAL |
| 36 | } | 39 | } |
| 37 | - // WindowModel.shared.setMainWindowFullScreen(this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL) | 40 | + WindowModel.shared.setMainWindowFullScreen(this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL) |
| 38 | }) | 41 | }) |
| 39 | let par: Action = router.getParams() as Action; | 42 | let par: Action = router.getParams() as Action; |
| 40 | let params = par?.params; | 43 | let params = par?.params; |
| @@ -47,7 +50,7 @@ export struct DetailPlayLivePage { | @@ -47,7 +50,7 @@ export struct DetailPlayLivePage { | ||
| 47 | 50 | ||
| 48 | build() { | 51 | build() { |
| 49 | Column() { | 52 | Column() { |
| 50 | - TopPlayComponent() | 53 | + TopPlayComponent({ playerController: this.playerController }) |
| 51 | .layoutWeight(211) | 54 | .layoutWeight(211) |
| 52 | TabComponent({ tabs: this.tabs }) | 55 | TabComponent({ tabs: this.tabs }) |
| 53 | .layoutWeight(503) | 56 | .layoutWeight(503) |
| @@ -60,12 +63,15 @@ export struct DetailPlayLivePage { | @@ -60,12 +63,15 @@ export struct DetailPlayLivePage { | ||
| 60 | } | 63 | } |
| 61 | 64 | ||
| 62 | onPageShow(): void { | 65 | onPageShow(): void { |
| 63 | - WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); | 66 | + Logger.info(this.TAG, `wyj-onPageShow`) |
| 67 | + // WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); | ||
| 64 | } | 68 | } |
| 65 | 69 | ||
| 66 | onPageHide(): void { | 70 | onPageHide(): void { |
| 71 | + Logger.info(this.TAG, `wyj-onPageHide`) | ||
| 67 | devicePLSensorManager.devicePLSensorOff(); | 72 | devicePLSensorManager.devicePLSensorOff(); |
| 68 | - WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); | 73 | + // WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); |
| 74 | + this.playerController?.pause() | ||
| 69 | } | 75 | } |
| 70 | 76 | ||
| 71 | getLiveDetails() { | 77 | getLiveDetails() { |
| @@ -98,7 +104,7 @@ export struct DetailPlayLivePage { | @@ -98,7 +104,7 @@ export struct DetailPlayLivePage { | ||
| 98 | } | 104 | } |
| 99 | 105 | ||
| 100 | aboutToDisappear(): void { | 106 | aboutToDisappear(): void { |
| 101 | - | 107 | + Logger.info(this.TAG, `wyj-aboutToDisappear`) |
| 102 | } | 108 | } |
| 103 | 109 | ||
| 104 | onBackPress(): boolean | void { | 110 | onBackPress(): boolean | void { |
| @@ -8,6 +8,7 @@ import PageModel from 'wdComponent/src/main/ets/viewmodel/PageModel' | @@ -8,6 +8,7 @@ import PageModel from 'wdComponent/src/main/ets/viewmodel/PageModel' | ||
| 8 | import { ViewType } from 'wdConstant/Index' | 8 | import { ViewType } from 'wdConstant/Index' |
| 9 | import LoadMoreLayout from 'wdComponent/src/main/ets/components/page/LoadMoreLayout' | 9 | import LoadMoreLayout from 'wdComponent/src/main/ets/components/page/LoadMoreLayout' |
| 10 | import RefreshLayout from 'wdComponent/src/main/ets/components/page/RefreshLayout' | 10 | import RefreshLayout from 'wdComponent/src/main/ets/components/page/RefreshLayout' |
| 11 | +import { StringUtils } from 'wdKit/Index' | ||
| 11 | 12 | ||
| 12 | @Component | 13 | @Component |
| 13 | export struct TabLiveComponent { | 14 | export struct TabLiveComponent { |
| @@ -94,15 +95,6 @@ export struct TabLiveComponent { | @@ -94,15 +95,6 @@ export struct TabLiveComponent { | ||
| 94 | 2.名称固定:人民日报主持人 | 95 | 2.名称固定:人民日报主持人 |
| 95 | 3.内容:详情接口的简介,newIntroduction | 96 | 3.内容:详情接口的简介,newIntroduction |
| 96 | */ | 97 | */ |
| 97 | - // if (StringUtils.isNotEmpty(this.liveDetailsBean.oldNewsId) | ||
| 98 | - // && this.liveDetailsBean | ||
| 99 | - // && this.liveDetailsBean.liveInfo.liveState != 'wait' | ||
| 100 | - // && this.pageModel.currentPage == 1) { | ||
| 101 | - // let liveRoomItemBeanTemp: LiveRoomItemBean = {} as LiveRoomItemBean | ||
| 102 | - // liveRoomItemBeanTemp.text = this.liveDetailsBean.newIntroduction | ||
| 103 | - // liveRoomItemBeanTemp.senderUserName = '人民日报主持人' | ||
| 104 | - // data.barrageResponses.push(liveRoomItemBeanTemp) | ||
| 105 | - // } | ||
| 106 | this.pageModel.viewType = ViewType.LOADED; | 98 | this.pageModel.viewType = ViewType.LOADED; |
| 107 | this.liveList.push(...data.barrageResponses) | 99 | this.liveList.push(...data.barrageResponses) |
| 108 | if (data.barrageResponses.length === this.pageModel.pageSize) { | 100 | if (data.barrageResponses.length === this.pageModel.pageSize) { |
| @@ -110,6 +102,14 @@ export struct TabLiveComponent { | @@ -110,6 +102,14 @@ export struct TabLiveComponent { | ||
| 110 | this.pageModel.hasMore = true; | 102 | this.pageModel.hasMore = true; |
| 111 | } else { | 103 | } else { |
| 112 | this.pageModel.hasMore = false; | 104 | this.pageModel.hasMore = false; |
| 105 | + if (StringUtils.isNotEmpty(this.liveDetailsBean.oldNewsId) | ||
| 106 | + && this.liveDetailsBean | ||
| 107 | + && this.liveDetailsBean.liveInfo.liveState != 'wait') { | ||
| 108 | + let liveRoomItemBeanTemp: LiveRoomItemBean = {} as LiveRoomItemBean | ||
| 109 | + liveRoomItemBeanTemp.text = this.liveDetailsBean.newIntroduction | ||
| 110 | + liveRoomItemBeanTemp.senderUserName = '人民日报主持人' | ||
| 111 | + this.liveList.push(liveRoomItemBeanTemp) | ||
| 112 | + } | ||
| 113 | } | 113 | } |
| 114 | } else { | 114 | } else { |
| 115 | this.pageModel.viewType = ViewType.EMPTY; | 115 | this.pageModel.viewType = ViewType.EMPTY; |
| @@ -91,6 +91,7 @@ export struct TabLiveItemComponent { | @@ -91,6 +91,7 @@ export struct TabLiveItemComponent { | ||
| 91 | .objectFit(ImageFit.Auto) | 91 | .objectFit(ImageFit.Auto) |
| 92 | .borderRadius(4) | 92 | .borderRadius(4) |
| 93 | }.onClick(() => { | 93 | }.onClick(() => { |
| 94 | + this.photoList=[] | ||
| 94 | for (let item of this.item.pictureUrls) { | 95 | for (let item of this.item.pictureUrls) { |
| 95 | this.photoList.push({ | 96 | this.photoList.push({ |
| 96 | width: 0, | 97 | width: 0, |
| @@ -9,7 +9,7 @@ import { DisplayDirection } from 'wdConstant/Index' | @@ -9,7 +9,7 @@ import { DisplayDirection } from 'wdConstant/Index' | ||
| 9 | export struct PlayUIComponent { | 9 | export struct PlayUIComponent { |
| 10 | playerController: WDPlayerController = new WDPlayerController(); | 10 | playerController: WDPlayerController = new WDPlayerController(); |
| 11 | //菜单键是否可见 | 11 | //菜单键是否可见 |
| 12 | - @State isMenuVisible: boolean = true | 12 | + @State @Watch('onChangeMenuVisible') isMenuVisible: boolean = true |
| 13 | @Consume liveDetailsBean: LiveDetailsBean | 13 | @Consume liveDetailsBean: LiveDetailsBean |
| 14 | @Consume liveRoomDataBean: LiveRoomDataBean | 14 | @Consume liveRoomDataBean: LiveRoomDataBean |
| 15 | @State currentTime: string = '' | 15 | @State currentTime: string = '' |
| @@ -19,13 +19,26 @@ export struct PlayUIComponent { | @@ -19,13 +19,26 @@ export struct PlayUIComponent { | ||
| 19 | @State isPlayStatus: boolean = true | 19 | @State isPlayStatus: boolean = true |
| 20 | @Consume displayDirection: DisplayDirection | 20 | @Consume displayDirection: DisplayDirection |
| 21 | 21 | ||
| 22 | + onChangeMenuVisible() { | ||
| 23 | + let time: number = 0 | ||
| 24 | + if (this.isMenuVisible) { | ||
| 25 | + setTimeout(() => { | ||
| 26 | + this.isMenuVisible = false | ||
| 27 | + }, 5 * 1000) | ||
| 28 | + } else { | ||
| 29 | + clearTimeout(time) | ||
| 30 | + } | ||
| 31 | + } | ||
| 32 | + | ||
| 22 | aboutToAppear(): void { | 33 | aboutToAppear(): void { |
| 34 | + this.onChangeMenuVisible() | ||
| 23 | //播放进度监听 | 35 | //播放进度监听 |
| 24 | this.playerController.onTimeUpdate = (position: number, duration: number) => { | 36 | this.playerController.onTimeUpdate = (position: number, duration: number) => { |
| 25 | this.currentTime = DateFormatUtil.secondToTime(Math.floor(position / 1000)); | 37 | this.currentTime = DateFormatUtil.secondToTime(Math.floor(position / 1000)); |
| 26 | this.totalTime = DateFormatUtil.secondToTime(Math.floor(duration / 1000)); | 38 | this.totalTime = DateFormatUtil.secondToTime(Math.floor(duration / 1000)); |
| 27 | this.progressVal = Math.floor(position * 100 / duration); | 39 | this.progressVal = Math.floor(position * 100 / duration); |
| 28 | } | 40 | } |
| 41 | + | ||
| 29 | } | 42 | } |
| 30 | 43 | ||
| 31 | build() { | 44 | build() { |
| @@ -178,7 +191,12 @@ export struct PlayUIComponent { | @@ -178,7 +191,12 @@ export struct PlayUIComponent { | ||
| 178 | @Builder | 191 | @Builder |
| 179 | getBottomUIComponent() { | 192 | getBottomUIComponent() { |
| 180 | Row() { | 193 | Row() { |
| 181 | - if (this.liveDetailsBean?.liveInfo?.liveState == 'end') { | 194 | + if (this.liveDetailsBean?.liveInfo?.liveState == 'wait') { |
| 195 | + Blank() | ||
| 196 | + } else if (this.liveDetailsBean?.liveInfo?.liveState == 'running') { | ||
| 197 | + this.playOrPauseBtn() | ||
| 198 | + Blank() | ||
| 199 | + } else if (this.liveDetailsBean?.liveInfo?.liveState == 'end') { | ||
| 182 | this.playOrPauseBtn() | 200 | this.playOrPauseBtn() |
| 183 | Text(this.currentTime) | 201 | Text(this.currentTime) |
| 184 | .fontColor(Color.White) | 202 | .fontColor(Color.White) |
| @@ -187,9 +205,7 @@ export struct PlayUIComponent { | @@ -187,9 +205,7 @@ export struct PlayUIComponent { | ||
| 187 | .margin({ | 205 | .margin({ |
| 188 | left: 16 | 206 | left: 16 |
| 189 | }) | 207 | }) |
| 190 | - | ||
| 191 | this.playProgressView() | 208 | this.playProgressView() |
| 192 | - | ||
| 193 | Text(this.totalTime) | 209 | Text(this.totalTime) |
| 194 | .fontColor(Color.White) | 210 | .fontColor(Color.White) |
| 195 | .fontWeight(600) | 211 | .fontWeight(600) |
| @@ -197,8 +213,6 @@ export struct PlayUIComponent { | @@ -197,8 +213,6 @@ export struct PlayUIComponent { | ||
| 197 | .margin({ | 213 | .margin({ |
| 198 | right: 16 | 214 | right: 16 |
| 199 | }) | 215 | }) |
| 200 | - } else { | ||
| 201 | - Blank() | ||
| 202 | } | 216 | } |
| 203 | if (this.liveDetailsBean?.liveInfo?.liveState == 'running' | 217 | if (this.liveDetailsBean?.liveInfo?.liveState == 'running' |
| 204 | || this.liveDetailsBean?.liveInfo?.liveState == 'end') { | 218 | || this.liveDetailsBean?.liveInfo?.liveState == 'end') { |
| 1 | import { LiveDetailsBean } from 'wdBean/Index'; | 1 | import { LiveDetailsBean } from 'wdBean/Index'; |
| 2 | +import { Logger } from 'wdKit/Index'; | ||
| 2 | import { WDPlayerController, WDPlayerRenderLiveView } from 'wdPlayer/Index'; | 3 | import { WDPlayerController, WDPlayerRenderLiveView } from 'wdPlayer/Index'; |
| 3 | import { PlayUIComponent } from './PlayUIComponent'; | 4 | import { PlayUIComponent } from './PlayUIComponent'; |
| 4 | 5 | ||
| 5 | @Component | 6 | @Component |
| 6 | export struct TopPlayComponent { | 7 | export struct TopPlayComponent { |
| 8 | + TAG: string = 'TopPlayComponent' | ||
| 7 | @Consume @Watch('updateData') liveDetailsBean: LiveDetailsBean | 9 | @Consume @Watch('updateData') liveDetailsBean: LiveDetailsBean |
| 8 | playerController: WDPlayerController = new WDPlayerController(); | 10 | playerController: WDPlayerController = new WDPlayerController(); |
| 9 | @State imgUrl: string = '' | 11 | @State imgUrl: string = '' |
| @@ -42,6 +44,18 @@ export struct TopPlayComponent { | @@ -42,6 +44,18 @@ export struct TopPlayComponent { | ||
| 42 | .height('100%') | 44 | .height('100%') |
| 43 | .width('100%') | 45 | .width('100%') |
| 44 | .visibility(this.isWait ? Visibility.None : Visibility.Visible) | 46 | .visibility(this.isWait ? Visibility.None : Visibility.Visible) |
| 47 | + .onVisibleAreaChange([0.0, 1.0], (isVisible: boolean, currentRatio: number) => { | ||
| 48 | + Logger.debug(this.TAG, `当前屏幕可见区域大小: currentRatio:' +${currentRatio}`) | ||
| 49 | + if (isVisible && currentRatio >= 1.0) { | ||
| 50 | + Logger.debug(this.TAG, `播放器-暂停. currentRatio:' +${currentRatio}`) | ||
| 51 | + this.playerController.play() | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + if (!isVisible && currentRatio <= 0.0) { | ||
| 55 | + Logger.debug(this.TAG, `播放器-播放. currentRatio:' +${currentRatio}`) | ||
| 56 | + this.playerController.pause() | ||
| 57 | + } | ||
| 58 | + }) | ||
| 45 | Image(this.imgUrl) | 59 | Image(this.imgUrl) |
| 46 | .objectFit(ImageFit.Contain) | 60 | .objectFit(ImageFit.Contain) |
| 47 | .visibility(this.isWait ? Visibility.Visible : Visibility.None) | 61 | .visibility(this.isWait ? Visibility.Visible : Visibility.None) |
| @@ -12,6 +12,7 @@ struct LaunchAdvertisingPage { | @@ -12,6 +12,7 @@ struct LaunchAdvertisingPage { | ||
| 12 | // url:'pages/MainPage' | 12 | // url:'pages/MainPage' |
| 13 | // }) | 13 | // }) |
| 14 | WDRouterRule.jumpWithReplacePage(WDRouterPage.mainPage) | 14 | WDRouterRule.jumpWithReplacePage(WDRouterPage.mainPage) |
| 15 | + clearInterval(this.timer) | ||
| 15 | } | 16 | } |
| 16 | 17 | ||
| 17 | onPageShow(){ | 18 | onPageShow(){ |
| @@ -9,6 +9,7 @@ import { GlobalContext } from '../../utils/GlobalContext' | @@ -9,6 +9,7 @@ import { GlobalContext } from '../../utils/GlobalContext' | ||
| 9 | import { WDRouterRule } from 'wdRouter'; | 9 | import { WDRouterRule } from 'wdRouter'; |
| 10 | import { WDRouterPage } from 'wdRouter'; | 10 | import { WDRouterPage } from 'wdRouter'; |
| 11 | import { LaunchModel } from '../viewModel/LaunchModel' | 11 | import { LaunchModel } from '../viewModel/LaunchModel' |
| 12 | +import { LaunchPageModel } from '../viewModel/LaunchPageModel' | ||
| 12 | 13 | ||
| 13 | @Entry | 14 | @Entry |
| 14 | @Component | 15 | @Component |
| @@ -44,7 +45,8 @@ struct LaunchPage { | @@ -44,7 +45,8 @@ struct LaunchPage { | ||
| 44 | this.saveIsPrivacy(); | 45 | this.saveIsPrivacy(); |
| 45 | //跳转引导页 | 46 | //跳转引导页 |
| 46 | this.jumpToGuidePage(); | 47 | this.jumpToGuidePage(); |
| 47 | - | 48 | + //同意隐私协议后请求启动页相关数据 |
| 49 | + this.requestLaunchPageData(); | ||
| 48 | } | 50 | } |
| 49 | 51 | ||
| 50 | jumpToAdvertisingPage() { | 52 | jumpToAdvertisingPage() { |
| @@ -90,9 +92,11 @@ struct LaunchPage { | @@ -90,9 +92,11 @@ struct LaunchPage { | ||
| 90 | this.dialogController.open(); | 92 | this.dialogController.open(); |
| 91 | // } | 93 | // } |
| 92 | } else { | 94 | } else { |
| 95 | + //需要根据请求数据判断是否需要进入广告页,广告数据为nil则直接跳转到首页 | ||
| 93 | //跳转广告页 | 96 | //跳转广告页 |
| 94 | this.jumpToAdvertisingPage(); | 97 | this.jumpToAdvertisingPage(); |
| 95 | - | 98 | + //同意隐私协议后每次启动app请求启动页相关数据,并更新数据 |
| 99 | + this.requestLaunchPageData(); | ||
| 96 | } | 100 | } |
| 97 | }); | 101 | }); |
| 98 | }); | 102 | }); |
| @@ -154,4 +158,12 @@ struct LaunchPage { | @@ -154,4 +158,12 @@ struct LaunchPage { | ||
| 154 | launchModel.getAgreement() | 158 | launchModel.getAgreement() |
| 155 | } | 159 | } |
| 156 | 160 | ||
| 161 | + requestLaunchPageData() { | ||
| 162 | + //请求启动页相关接口数据并保存 | ||
| 163 | + let launchPageModel = new LaunchPageModel() | ||
| 164 | + launchPageModel.getLaunchPageData() | ||
| 165 | + | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + | ||
| 157 | } | 169 | } |
| @@ -46,16 +46,6 @@ export class InterestsHobbiesModel { | @@ -46,16 +46,6 @@ export class InterestsHobbiesModel { | ||
| 46 | Logger.debug("InterestsHobbiesModel兴趣偏好数据获取成功:success ", JSON.stringify(data)) | 46 | Logger.debug("InterestsHobbiesModel兴趣偏好数据获取成功:success ", JSON.stringify(data)) |
| 47 | success(data.data); | 47 | success(data.data); |
| 48 | 48 | ||
| 49 | - | ||
| 50 | - //保存数据 | ||
| 51 | - // for (let i = 0; i < data.data.length; i++) { | ||
| 52 | - // if (data.data[i].type == 1) { | ||
| 53 | - // SPHelper.default.save(SpConstants.USER_PROTOCOL, data.data[i].linkUrl) | ||
| 54 | - // } else if (data.data[i].type == 2) { | ||
| 55 | - // SPHelper.default.save(SpConstants.PRIVATE_PROTOCOL, data.data[i].linkUrl) | ||
| 56 | - // } | ||
| 57 | - // } | ||
| 58 | - | ||
| 59 | }, (error: Error) => { | 49 | }, (error: Error) => { |
| 60 | Logger.debug("InterestsHobbiesModel兴趣偏好数据获取失败:error ", error.toString()) | 50 | Logger.debug("InterestsHobbiesModel兴趣偏好数据获取失败:error ", error.toString()) |
| 61 | fail(error.message) | 51 | fail(error.message) |
| 1 | + | ||
| 2 | + | ||
| 3 | +export interface NetLayerLaunchOperatModel { | ||
| 4 | + | ||
| 5 | + ID : string | ||
| 6 | + screenName : string //开机屏名称 | ||
| 7 | + objectType : string // WDPublicProgramType 对象类型 0:不跳转,1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,11:图文,12:组图,13:H5新闻,14:频道 | ||
| 8 | + objectId : string //跳转id | ||
| 9 | + objectLevel : string //频道(1:一级频道,2:二级频道),专题(1:普通专题,2:主题专题,3:作者专题 21:文章专题,22:音频专题,23:直播专题,24:话题专题) | ||
| 10 | + pageId : string //跳转页面id,objectType=5,14使用页面跳转 | ||
| 11 | + durations : string //展示时长(单位:秒) | ||
| 12 | + linkUrl : string //转链接地址【objectType=6,13】 | ||
| 13 | + screenType : string // 0, 1 : WDDisplayStyle_Logo 2 : WDDisplayStyle_Full | ||
| 14 | + bootScreenUrl : string //开机屏封面图/视频地址 | ||
| 15 | + bootVideoScreenUrl : string //视频封面地址 | ||
| 16 | + showType : string //文件类型WDPublicFileType 2: 视频 其他: 图片 | ||
| 17 | + isAd : string //0-非广告,1-是广告 | ||
| 18 | + bottomNavId : string //底部导航ID | ||
| 19 | + relId : string //频道/专题内容关系id | ||
| 20 | + | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | + | ||
| 24 | +export interface NetLayerLauncherADMaterialModel{ | ||
| 25 | + | ||
| 26 | + matType : string //1 video 其他 image | ||
| 27 | + startStyle : number // 1 WDDisplayStyle_Full 全屏样式 其他 WDDisplayStyle_Logo 底部logo样式 | ||
| 28 | + advTitle : string | ||
| 29 | + matImageUrl : string[] //取firstObject | ||
| 30 | + matVideoUrl : string | ||
| 31 | + | ||
| 32 | + openType : string //链接打开方式,0-没链接,不用打开,1-端内打开,2-端外打开 | ||
| 33 | + linkUrl : string | ||
| 34 | + | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +export interface NetLayerLauncherADInfoModel{ | ||
| 38 | + | ||
| 39 | + ID : string | ||
| 40 | + startTime : number | ||
| 41 | + endTime : number | ||
| 42 | + displayDuration : number | ||
| 43 | + displayRound : number | ||
| 44 | + matInfo : NetLayerLauncherADMaterialModel | ||
| 45 | + | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +export interface NetLayerLauncherH5TemplateInfoModel{ | ||
| 49 | + | ||
| 50 | + versionRangeMin : string | ||
| 51 | + versionRangeMax : string | ||
| 52 | + h5TemplateUrl : string | ||
| 53 | + version : string | ||
| 54 | + md5 : string | ||
| 55 | + | ||
| 56 | +} | ||
| 57 | + | ||
| 58 | + | ||
| 59 | +export default interface LaunchDataModel{ | ||
| 60 | + | ||
| 61 | + launchPageInfo : NetLayerLaunchOperatModel | ||
| 62 | + launchAdInfo : NetLayerLauncherADInfoModel[] | ||
| 63 | + h5Template : NetLayerLauncherH5TemplateInfoModel[] | ||
| 64 | + | ||
| 65 | +} |
| 1 | + | ||
| 2 | +import LaunchDataModel from '../viewModel/LaunchDataModel' | ||
| 3 | + | ||
| 4 | +import HashMap from '@ohos.util.HashMap'; | ||
| 5 | +import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; | ||
| 6 | +import { HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index'; | ||
| 7 | +import { Logger, SPHelper } from 'wdKit/Index'; | ||
| 8 | +import data from '@ohos.telephony.data'; | ||
| 9 | +import { SpConstants } from 'wdConstant/Index'; | ||
| 10 | + | ||
| 11 | + | ||
| 12 | +export class LaunchPageModel { | ||
| 13 | + | ||
| 14 | + getLaunchPageData() { | ||
| 15 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 16 | + return new Promise<LaunchDataModel>((success, fail) => { | ||
| 17 | + HttpRequest.get<ResponseDTO<LaunchDataModel>>(HttpUrlUtils.getLaunchPageDataUrl(), headers).then((data: ResponseDTO<LaunchDataModel>) => { | ||
| 18 | + if (!data || !data.data) { | ||
| 19 | + fail("数据为空") | ||
| 20 | + return | ||
| 21 | + } | ||
| 22 | + if (data.code != 0) { | ||
| 23 | + fail(data.message) | ||
| 24 | + return | ||
| 25 | + } | ||
| 26 | + Logger.debug("LaunchPageModel获取启动相关数据获取成功:success ", JSON.stringify(data)) | ||
| 27 | + success(data.data); | ||
| 28 | + //存储数据 | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + }, (error: Error) => { | ||
| 33 | + Logger.debug("LaunchPageModel获取启动相关数据获取失败:error ", error.toString()) | ||
| 34 | + fail(error.message) | ||
| 35 | + }) | ||
| 36 | + }) | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + | ||
| 40 | + | ||
| 41 | +} |
-
Please register or login to post a comment