张善主

fix(直播详情页):非Wifi提示

@@ -11,6 +11,7 @@ export struct CustomToast { @@ -11,6 +11,7 @@ export struct CustomToast {
11 fontSizeValue :number | string | Resource = "27lpx" 11 fontSizeValue :number | string | Resource = "27lpx"
12 lineHeightValue :number | string | Resource = "38lpx" 12 lineHeightValue :number | string | Resource = "38lpx"
13 controller: CustomDialogController 13 controller: CustomDialogController
  14 + marginTop :number | string | Resource = 0
14 15
15 dismiss: () => void = () => { 16 dismiss: () => void = () => {
16 } 17 }
@@ -38,5 +39,6 @@ export struct CustomToast { @@ -38,5 +39,6 @@ export struct CustomToast {
38 .padding({top:"23lpx",bottom:'23lpx',left:"35lpx",right:"35lpx"}) 39 .padding({top:"23lpx",bottom:'23lpx',left:"35lpx",right:"35lpx"})
39 .backgroundColor(this.bgColor) 40 .backgroundColor(this.bgColor)
40 .opacity(this.opacityValue) 41 .opacity(this.opacityValue)
  42 + .margin({top:this.marginTop})
41 } 43 }
42 } 44 }
@@ -15,4 +15,18 @@ async function onlyWifiLoadImg(): Promise<boolean> { @@ -15,4 +15,18 @@ async function onlyWifiLoadImg(): Promise<boolean> {
15 return false 15 return false
16 } 16 }
17 17
18 -export { onlyWifiLoadImg }  
  18 +async function onlyWifiLoadVideo(): Promise<boolean> {
  19 + let loadImageOnlyWifiSwitch = await SPHelper.default.get(SpConstants.SETTING_WIFI_VIDEO_SWITCH, '') || false;
  20 + if (!loadImageOnlyWifiSwitch) {
  21 + // 开关没开,直接让加载视频
  22 + return true
  23 + }
  24 + let netWorkStatus = NetworkUtil.getNetworkType();
  25 + // 开关打开,wifi下才加载视频
  26 + if (netWorkStatus === NetworkUtil.TYPE_WIFI) {
  27 + return true
  28 + }
  29 + return false
  30 +}
  31 +
  32 +export { onlyWifiLoadImg,onlyWifiLoadVideo }
@@ -4,12 +4,13 @@ import { TabComponent } from '../widgets/details/TabComponent'; @@ -4,12 +4,13 @@ import { TabComponent } from '../widgets/details/TabComponent';
4 import { TopPlayComponent } from '../widgets/details/video/TopPlayComponet'; 4 import { TopPlayComponent } from '../widgets/details/video/TopPlayComponet';
5 import { DisplayDirection } from 'wdConstant/Index'; 5 import { DisplayDirection } from 'wdConstant/Index';
6 import mediaquery from '@ohos.mediaquery'; 6 import mediaquery from '@ohos.mediaquery';
7 -import { Logger, WindowModel } from 'wdKit/Index'; 7 +import { CustomToast, Logger, WindowModel } from 'wdKit/Index';
8 import { router, window } from '@kit.ArkUI'; 8 import { router, window } from '@kit.ArkUI';
9 import { WDAliPlayerController } from 'wdPlayer/Index'; 9 import { WDAliPlayerController } from 'wdPlayer/Index';
10 import { LiveOperRowListView } from 'wdComponent'; 10 import { LiveOperRowListView } from 'wdComponent';
11 import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment/model/PublishCommentModel'; 11 import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment/model/PublishCommentModel';
12 import { TrackConstants, TrackingContent, TrackParamConvert } from 'wdTracking/Index'; 12 import { TrackConstants, TrackingContent, TrackParamConvert } from 'wdTracking/Index';
  13 +import { onlyWifiLoadVideo } from 'wdComponent/src/main/ets/utils/lazyloadImg';
13 14
14 let TAG: string = 'DetailPlayLivePage'; 15 let TAG: string = 'DetailPlayLivePage';
15 16
@@ -41,7 +42,28 @@ export struct DetailPlayLivePage { @@ -41,7 +42,28 @@ export struct DetailPlayLivePage {
41 // 顶部状态栏高度 42 // 顶部状态栏高度
42 @Consume topSafeHeight: number 43 @Consume topSafeHeight: number
43 44
44 - aboutToAppear(): void { 45 + @State toastText: ResourceStr = "这是一个非Wi-Fi环境。请注意流量消耗"
  46 + dialogToast: CustomDialogController = new CustomDialogController({
  47 + builder: CustomToast({
  48 + bgColor: 0xB3000000,
  49 + opacityValue: 1,
  50 + fontSizeValue: "25lpx",
  51 + lineHeightValue: "36lpx",
  52 + msg: this.toastText,
  53 + marginTop:211/2+px2vp(this.topSafeHeight)-px2vp(84/2)
  54 + }),
  55 + autoCancel: false,
  56 + alignment: DialogAlignment.Top,
  57 + customStyle: true,
  58 + maskColor: "#00000000"
  59 + })
  60 +
  61 + showToastTip(msg: ResourceStr) {
  62 + this.toastText = msg
  63 + this.dialogToast.open()
  64 + }
  65 +
  66 + async aboutToAppear(): Promise<void> {
45 Logger.info(TAG, `wyj-aboutToAppear`) 67 Logger.info(TAG, `wyj-aboutToAppear`)
46 68
47 this.listener?.on("change", (mediaQueryResult) => { 69 this.listener?.on("change", (mediaQueryResult) => {
@@ -56,6 +78,9 @@ export struct DetailPlayLivePage { @@ -56,6 +78,9 @@ export struct DetailPlayLivePage {
56 this.getLiveDetails() 78 this.getLiveDetails()
57 this.getLiveRoomData() 79 this.getLiveRoomData()
58 80
  81 + if(!await onlyWifiLoadVideo()){
  82 + this.showToastTip(this.toastText)
  83 + }
59 } 84 }
60 85
61 async aboutToDisappear() { 86 async aboutToDisappear() {
@@ -115,7 +140,6 @@ export struct DetailPlayLivePage { @@ -115,7 +140,6 @@ export struct DetailPlayLivePage {
115 } 140 }
116 .height('100%') 141 .height('100%')
117 .width('100%') 142 .width('100%')
118 -  
119 } 143 }
120 144
121 onPageShowCus(): void { 145 onPageShowCus(): void {
1 import { ContentDetailDTO, LiveRoomDataBean } from 'wdBean/Index'; 1 import { ContentDetailDTO, LiveRoomDataBean } from 'wdBean/Index';
2 import { LiveViewModel } from '../viewModel/LiveViewModel'; 2 import { LiveViewModel } from '../viewModel/LiveViewModel';
3 -import { WindowModel } from 'wdKit/Index'; 3 +import { CustomToast, WindowModel } from 'wdKit/Index';
4 import { PlayerComponent } from '../widgets/vertical/PlayerComponent'; 4 import { PlayerComponent } from '../widgets/vertical/PlayerComponent';
5 import { PlayerInfoComponent } from '../widgets/vertical/PlayerInfoComponent'; 5 import { PlayerInfoComponent } from '../widgets/vertical/PlayerInfoComponent';
6 import { WDAliPlayerController } from 'wdPlayer/Index'; 6 import { WDAliPlayerController } from 'wdPlayer/Index';
@@ -9,6 +9,7 @@ import { LiveEmptyComponent, WDLiveViewDefaultType } from 'wdComponent/Index'; @@ -9,6 +9,7 @@ import { LiveEmptyComponent, WDLiveViewDefaultType } from 'wdComponent/Index';
9 import { PlayerEndView } from '../widgets/vertical/PlayerEndView'; 9 import { PlayerEndView } from '../widgets/vertical/PlayerEndView';
10 import { TrackConstants, TrackingButton } from 'wdTracking/Index'; 10 import { TrackConstants, TrackingButton } from 'wdTracking/Index';
11 import { LiveDetailPageLogic } from '../viewModel/LiveDetailPageLogic'; 11 import { LiveDetailPageLogic } from '../viewModel/LiveDetailPageLogic';
  12 +import { onlyWifiLoadVideo } from 'wdComponent/src/main/ets/utils/lazyloadImg';
12 13
13 const storage = LocalStorage.getShared(); 14 const storage = LocalStorage.getShared();
14 const TAG = 'DetailPlayVLivePage' 15 const TAG = 'DetailPlayVLivePage'
@@ -40,11 +41,32 @@ export struct DetailPlayVLivePage { @@ -40,11 +41,32 @@ export struct DetailPlayVLivePage {
40 //播放错误 41 //播放错误
41 @State isPlayerError: boolean = false 42 @State isPlayerError: boolean = false
42 @State isCanplay: boolean = false 43 @State isCanplay: boolean = false
  44 + @State toastText: ResourceStr = "这是一个非Wi-Fi环境。请注意流量消耗"
  45 + dialogToast: CustomDialogController = new CustomDialogController({
  46 + builder: CustomToast({
  47 + bgColor: 0xB3000000,
  48 + opacityValue: 1,
  49 + fontSizeValue: "25lpx",
  50 + lineHeightValue: "36lpx",
  51 + msg: this.toastText,
  52 + }),
  53 + autoCancel: false,
  54 + alignment: DialogAlignment.Center,
  55 + customStyle: true,
  56 + maskColor: "#00000000"
  57 + })
  58 +
  59 + showToastTip(msg: ResourceStr) {
  60 + this.toastText = msg
  61 + this.dialogToast.open()
  62 + }
43 63
44 - aboutToAppear(): void { 64 + async aboutToAppear(): Promise<void> {
45 this.openFullScreen() 65 this.openFullScreen()
46 this.getLiveRoomData() 66 this.getLiveRoomData()
47 - 67 + if(!await onlyWifiLoadVideo()){
  68 + this.showToastTip(this.toastText)
  69 + }
48 } 70 }
49 71
50 aboutToDisappear(): void { 72 aboutToDisappear(): void {