NewIndex.ets 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. import { AppUtil, DeviceUtil,DisplayUtil, PreferencesUtil, ToastUtil } from '@pura/harmony-utils';
  2. import TitleBar from '../view/TitleBar';
  3. import { router } from '@kit.ArkUI';
  4. import mainViewModel, { MainViewModel } from '../viewmodel/MainViewModel';
  5. import ItemData from '../viewmodel/ItemData';
  6. import { CommonConstants } from '../common/constants/CommonConstants';
  7. import { VideoItem } from '../viewmodel/VideoItem';
  8. import ScreenUtil from '../common/util/ScreenUtil';
  9. import { Utility } from '../common/util/Utility';
  10. import { BusinessError, emitter } from '@kit.BasicServicesKit';
  11. import { common } from '@kit.AbilityKit';
  12. import { AdSlot, AdSlotBuilder,
  13. CSJAdCreator,
  14. CSJAdSdk, CSJNativeExpressAd, NativeExpressAdListener } from '@csj/openadsdk';
  15. import { PrintBiddingTokenUtils } from '../common/util/PrintBiddintTokenUtils';
  16. import { ArrayList } from '@kit.ArkTS';
  17. import { CSJUtil } from '../common/util/CSJUtil';
  18. import { LocalMusic } from '../view/LocalMusic';
  19. import { StreamContent } from '../view/StreamContent';
  20. import { AvSessionController } from '../controller/AvSessionController';
  21. import { BreakpointSystem, BreakpointTypeEnum } from '../common/util/BreakpointSystem';
  22. import dataStorage from '@ohos.data.storage';
  23. import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
  24. import { SettingPage } from './SettingPage';
  25. import { deviceInfo } from '@kit.BasicServicesKit';
  26. import { resourceManager } from '@kit.LocalizationKit';
  27. import { systemShare } from '@kit.ShareKit';
  28. import { uniformTypeDescriptor } from '@kit.ArkData';
  29. const TAG = 'NewIndex'; // 日志标签
  30. /**
  31. * 首页主组件,包含顶部标题栏、主内容区(本地音乐/网络内容)、侧边抽屉菜单等。
  32. * 支持多端适配、广告集成、导航、生命周期管理等功能。
  33. */
  34. @Preview
  35. @Entry
  36. @Component
  37. struct NewIndex{
  38. /** 列表滚动器,用于抽屉菜单列表滚动 */
  39. private scroller: Scroller = new Scroller();
  40. /** 应用包名 */
  41. @State bundleName:string = ''
  42. @State appName:string = ''
  43. /** 是否显示侧边抽屉菜单 */
  44. @Provide isShowDrawer:boolean = false;
  45. /** 抽屉菜单 X 轴偏移量,用于手势滑动动画 */
  46. @Provide offsetX: number = 0;
  47. /** 本地视频列表,页面参数传入 */
  48. @Provide videoLocalList: Array<VideoItem> = []
  49. /** Y 轴偏移量(预留) */
  50. @State offsetY: number = 0;
  51. /** 主内容类型(0:本地音乐,1:网络内容) */
  52. @State mType:number = 0
  53. /** 模式类型(如歌手、专辑等) */
  54. @Provide modeType:number = 0
  55. /** 是否为零状态(预留) */
  56. @Provide('isZero') isZero:boolean = false;
  57. /** 是否显示赞助入口 */
  58. @State isShowSponsorship:boolean = false
  59. /** 页面上下文 */
  60. context = getContext(this);
  61. /** 音乐是否为零状态(预留) */
  62. @Provide('isMusicZero') isMusicZero:boolean = false;
  63. /** 本地音乐列表,持久化存储 */
  64. @StorageLink('musicLocalList') musicLocalList: Array<VideoItem> = []
  65. @Provide isFavMusic:boolean = false
  66. /** 标题栏配置模型 */
  67. @State titleBarModel: TitleBar.Model = new TitleBar.Model()
  68. .setTitleTextStyle(FontStyle.Normal)
  69. .setTitleBarStyle(TitleBar.BarStyle.TRANSPARENT)
  70. .setLeftIcon($r('app.media.menu'))
  71. .setLeftIconWidth(28)
  72. .setLeftIconHeight(28)
  73. .setTitleBarMinHeight(64)
  74. .setTitleName('首页')
  75. // .setRightIcon($r('app.media.add'))
  76. .setTitleFontSize(19)
  77. .setTitleFontColor(Color.White)
  78. .setTitleBarBackground($r('app.color.title_bar_bg'))
  79. .setLeftTitleBackground($r('app.color.title_bar_bg'))
  80. .setOnLeftClickListener(() => {
  81. // 打开菜单栏动画
  82. animateTo({ duration: 555 }, () => {
  83. this.isShowDrawer = true
  84. this.offsetX = 0
  85. })
  86. })
  87. .setRightTitleBackground($r('app.color.title_bar_bg'))
  88. // .setOnRightClickListener(()=>{
  89. // // this.goSelectVideo()
  90. // this.showSheelDialog()
  91. // })
  92. /** 应用版本号 */
  93. @State versionName:string =''
  94. /** 音频根目录路径 */
  95. @Provide rootPath:string = ''
  96. /** 当前路径 */
  97. @Provide currentPath:string = ''
  98. /** 是否为历史记录页面 */
  99. @Provide isHistory:boolean = false
  100. /** 是否可以返回上一级 */
  101. @Provide isCanBack:boolean= false
  102. @StorageProp('currentColorMode') currentMode: number = ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT;
  103. /**
  104. * 一多界面适配断点系统
  105. */
  106. private breakpointSystem: BreakpointSystem = new BreakpointSystem();
  107. /** 当前断点类型(如大屏/小屏) */
  108. @StorageProp('currentBreakpoint') currentBreakpoint: string = BreakpointTypeEnum.MD;
  109. /** 记录上一次点击返回键的时间戳,用于双击退出 */
  110. private backTime:number=0;
  111. /**
  112. * 返回键处理逻辑:
  113. * - 如果不是根目录或有历史记录,发送广播通知更新列表
  114. * - 如果是根目录,双击返回键退出应用,否则提示
  115. */
  116. onBackPress(): boolean | void {
  117. if(this.currentPath !== this.rootPath||this.isHistory||this.isFavMusic||(this.modeType!==0&&this.isCanBack)){
  118. const eventData: emitter.EventData = {};
  119. emitter.emit({ eventId: 888 }, eventData); // 发送音频广播通知更新doSwipBack
  120. }else{
  121. let nowtime = Date.now();
  122. if(nowtime - this.backTime < 1000){
  123. const mContext = getContext(this) as common.UIAbilityContext
  124. mContext.terminateSelf(); // 关闭应用
  125. AvSessionController.getInstance(true).unregisterSessionListener()
  126. }else {
  127. if(this.isShowDrawer){
  128. // 如果抽屉菜单打开,先关闭抽屉
  129. animateTo({ duration: 555 }, () => {
  130. this.isShowDrawer = false
  131. })
  132. }else{
  133. this.backTime=nowtime;
  134. ToastUtil.showToast("再按一次将退出当前应用")
  135. }
  136. }
  137. }
  138. return true;
  139. }
  140. /**
  141. * 页面显示生命周期钩子
  142. * - 注册断点系统
  143. * - 获取页面参数
  144. * - 设置状态栏样式
  145. * - 初始化图片缓存
  146. * - 判断是否显示赞助入口
  147. */
  148. async aboutToAppear() {
  149. Utility.enableFullScreen()
  150. Utility.getAppName(getContext(this)).then((appName:string)=>{
  151. this.appName = appName
  152. })
  153. this.breakpointSystem.register();
  154. let params = router.getParams() as Record<string, Object>;
  155. this.videoLocalList = params.videoList as VideoItem[];
  156. Utility.setStatusBarLight()
  157. ScreenUtil.setScreenSize();
  158. this.bundleName = AppUtil.getBundleName()
  159. this.versionName = AppUtil.getVersionName();
  160. // await ImageKnife.getInstance().initFileCache(this.context, 256, 256 * 1024 * 1024)
  161. this.isShowSponsorship = Utility.isOpenTime()
  162. }
  163. /**
  164. * 页面消失生命周期钩子
  165. * 注销断点系统
  166. */
  167. aboutToDisappear() {
  168. console.info('NewIndex aboutToDisappear');
  169. this.breakpointSystem.unregister();
  170. }
  171. /**
  172. * 构建主页面结构,包括顶部横线、主内容区和抽屉菜单
  173. */
  174. build() {
  175. Stack({ alignContent: Alignment.TopStart }) {
  176. // 顶部横线
  177. Column(){
  178. Line()
  179. .width('100%')
  180. .height(1)
  181. }
  182. .backgroundColor($r('app.color.title_bar_bg'))
  183. .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP])
  184. // 主内容区
  185. Column() {
  186. Stack(){
  187. // 本地音乐内容区
  188. LocalMusic()
  189. .visibility(this.mType===0?Visibility.Visible:Visibility.None)
  190. // 网络内容区
  191. StreamContent()
  192. .visibility(this.mType===1?Visibility.Visible:Visibility.None)
  193. }
  194. }
  195. .width('100%')
  196. .height('100%')
  197. .justifyContent(FlexAlign.Start)
  198. .backgroundColor($r('app.color.bottom_control_background'))
  199. // 侧边抽屉菜单
  200. if(this.isShowDrawer){
  201. Column() {
  202. Column() {
  203. // 抽屉顶部背景图
  204. Image($r('app.media.bg_music'))
  205. .width('100%')
  206. .visibility(this.isCoverOpacity()?Visibility.None:Visibility.Visible)
  207. .height(180)
  208. Blank()
  209. .backgroundColor($r('app.color.title_bar_bg'))
  210. .visibility(this.isCoverOpacity()?Visibility.Visible:Visibility.None)
  211. .width('100%')
  212. .height(55)
  213. // 动态生成抽屉菜单内容
  214. this.getDrawerView()
  215. }
  216. .width(this.currentBreakpoint !== BreakpointTypeEnum.SM?'40%':'75%')
  217. .height('100%')
  218. .backgroundColor($r('app.color.silvery'))
  219. .onClick((event:ClickEvent)=>{
  220. // 阻止事件冒泡
  221. })
  222. }
  223. .width('100%')
  224. .height('100%')
  225. .backgroundColor($r('app.color.ban_touming'))
  226. .alignItems(HorizontalAlign.Start)
  227. .onClick((event:ClickEvent)=>{
  228. // 点击抽屉外部关闭抽屉
  229. animateTo({ duration: 555 }, () => {
  230. this.isShowDrawer = false
  231. })
  232. })
  233. .translate({ x: this.offsetX, y: 0, z: 0 })
  234. .transition({ type: TransitionType.Insert, translate: { x: -DisplayUtil.getWidth(), y: 0 } })
  235. .transition({ type: TransitionType.Delete, translate: { x: -DisplayUtil.getWidth(), y: 0 } })
  236. .gesture(
  237. PanGesture()
  238. .onActionUpdate((event:GestureEvent)=>{
  239. // 手势滑动更新抽屉偏移
  240. if(event.offsetX<0){
  241. this.offsetX = event.offsetX;
  242. }
  243. })
  244. .onActionEnd(() => {
  245. // 手势结束判断是否关闭抽屉
  246. if(this.offsetX<-DisplayUtil.getWidth()/9){
  247. animateTo({ duration: 555 }, () => {
  248. this.isShowDrawer = false
  249. })
  250. }else{
  251. animateTo({ duration: 555 }, () => {
  252. this.isShowDrawer = true
  253. this.offsetX = 0
  254. })
  255. }
  256. })
  257. )
  258. }
  259. }
  260. }
  261. /**
  262. * 动态生成抽屉菜单内容
  263. * 根据 isShowSponsorship 展示不同菜单项
  264. */
  265. @Builder
  266. getDrawerView(){
  267. List({space: 0, scroller: this.scroller}){
  268. ForEach(this.isShowSponsorship?mainViewModel.getDrawerData2():mainViewModel.getDrawerData(),(item: ItemData)=>{
  269. ListItem(){
  270. Button({ type: ButtonType.Capsule, stateEffect: true }) {
  271. Row() {
  272. // 菜单图标
  273. Image(item.img)
  274. .height(22)
  275. .alignSelf(ItemAlign.Center)
  276. .margin({ left: 2 })
  277. // 菜单标题
  278. Text(item.title)
  279. .margin({ left: 10, right: 20 })
  280. .fontSize(15)
  281. .fontColor($r('app.color.index_tab_font_color'))
  282. .fontWeight(480)
  283. Blank()
  284. // 右侧箭头
  285. Image($r('app.media.arrow_right'))
  286. .width(22)
  287. .height(22)
  288. .margin({ left: 20, right: 0 })
  289. .align(Alignment.Center)
  290. }
  291. .width('100%')
  292. .height(55)
  293. }
  294. .backgroundColor(Color.Transparent)
  295. .onClick(async () => {
  296. // 根据 item.id 跳转或切换功能
  297. switch (item.id) {
  298. case MainViewModel.MENU_MUSIC:
  299. this.mType = 0
  300. animateTo({ duration: 555 }, () => {
  301. this.isShowDrawer = false
  302. })
  303. break
  304. case MainViewModel.MENU_FILE_SCAN:
  305. router.pushUrl({
  306. url: 'pages/ScanFilePage'
  307. });
  308. break
  309. case MainViewModel.MENU_HOME:
  310. this.mType = 0
  311. this.modeType = 0
  312. animateTo({ duration: 555 }, () => {
  313. this.isShowDrawer = false
  314. })
  315. break
  316. case MainViewModel.MENU_MIEDIA_KU:
  317. this.modeType = 1
  318. animateTo({ duration: 555 }, () => {
  319. this.isShowDrawer = false
  320. })
  321. break
  322. case MainViewModel.MENU_MIEDIA_ARTIST:
  323. this.modeType = 2
  324. animateTo({ duration: 555 }, () => {
  325. this.isShowDrawer = false
  326. })
  327. break
  328. case MainViewModel.MENU_MIEDIA_ALBUM:
  329. this.modeType = 3
  330. animateTo({ duration: 555 }, () => {
  331. this.isShowDrawer = false
  332. })
  333. break
  334. case MainViewModel.MENU_SETTING:
  335. router.pushUrl({
  336. url: 'pages/SettingPage'
  337. }, router.RouterMode.Single);
  338. break
  339. case MainViewModel.MENU_VIP:
  340. router.pushUrl({
  341. url: 'pages/VipPage'
  342. }, router.RouterMode.Single);
  343. break
  344. case MainViewModel.MENU_NET_CONNECT:
  345. this.mType = 1
  346. animateTo({ duration: 555 }, () => {
  347. this.isShowDrawer = false
  348. })
  349. break
  350. case MainViewModel.MENU_SIMI:
  351. router.pushUrl({
  352. url: 'pages/VerifyPage'
  353. });
  354. break
  355. case MainViewModel.MENU_LIKE:
  356. router.pushUrl({
  357. url: 'pages/LikeVideoPage'
  358. });
  359. break
  360. case MainViewModel.MENU_DUTY:
  361. router.pushUrl({
  362. url: 'pages/WebIndex',
  363. params: { titleName: '用户协议', webUrl: CommonConstants.NEW_DUTY }
  364. });
  365. break
  366. case MainViewModel.MENU_HAOPING:
  367. Utility.gotoMarket(getContext(this) as common.UIAbilityContext,this.bundleName)
  368. break
  369. case MainViewModel.MENU_TEST_SPEED:
  370. router.pushUrl({
  371. url: 'pages/SpeedIndex'
  372. });
  373. break
  374. case MainViewModel.MENU_OPTIMIZE:
  375. router.pushUrl({
  376. url: 'pages/AddSpeedPage'
  377. });
  378. break
  379. case MainViewModel.MENU_ABOUT:
  380. router.pushUrl({
  381. url: 'pages/AboutPage'
  382. }, router.RouterMode.Single);
  383. break
  384. case MainViewModel.MENU_UPDATE:
  385. AlertDialog.show({title:'版本更新',message:'当前版本为最新版本:'+this.versionName,
  386. autoCancel:true, alignment:DialogAlignment.Center,
  387. offset:{dx:0,dy:-20},//在Y轴方向上的编译量
  388. confirm:{
  389. value:'确定',fontColor:Color.White,backgroundColor:$r('app.color.title_bar_bg'),
  390. action:()=>{
  391. }
  392. }
  393. })
  394. break
  395. case MainViewModel.MENU_YSZC:
  396. router.pushUrl({
  397. url: 'pages/WebIndex',
  398. params: { titleName: '隐私政策', webUrl: CommonConstants.NEW_YS_HW }
  399. });
  400. break
  401. case MainViewModel.MENU_SHARE:
  402. this.gotoShare()
  403. break
  404. }
  405. })
  406. }
  407. .width('90%')
  408. .height(55)
  409. })
  410. }
  411. .width('100%')
  412. .alignListItem(ListItemAlign.Center)
  413. .backgroundColor($r('app.color.silvery'))
  414. .layoutWeight(1)
  415. // .divider({ strokeWidth: 1, color: this.isDarkMode? '333333':'#ffe9f0f0' })
  416. .edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
  417. }
  418. gotoShare(){
  419. let shareData: systemShare.SharedData = new systemShare.SharedData({
  420. utd: uniformTypeDescriptor.UniformDataType.TEXT,
  421. content: 'https://appgallery.huawei.com/app/detail?id='+this.bundleName,
  422. title: this.appName, // 不传title字段时,显示content
  423. description: '精心雕琢的无损音乐播放器',
  424. // thumbnail: new Uint8Array() // 推荐传入适合的缩略图 不传则显示默认text图标
  425. });
  426. // 进行分享面板显示
  427. let controller: systemShare.ShareController = new systemShare.ShareController(shareData);
  428. let context = getContext(this) as common.UIAbilityContext;
  429. controller.show(context, {
  430. selectionMode: systemShare.SelectionMode.SINGLE,
  431. previewMode: systemShare.SharePreviewMode.DETAIL,
  432. }).then(() => {
  433. console.info('ShareController show success.');
  434. }).catch((error: BusinessError) => {
  435. console.error(`ShareController show error. code: ${error.code}, message: ${error.message}`);
  436. });
  437. }
  438. /**
  439. * ================== 穿山甲广告相关 ==================
  440. */
  441. /** Banner广告对象 */
  442. private declare bannerAd: CSJNativeExpressAd;
  443. /** 广告加载状态 */
  444. @State private status: string = "未加载"
  445. /** 是否展示广告 */
  446. @State private isShowAd: boolean = false
  447. /** 广告位配置信息 */
  448. private declare mAdSlot: AdSlot;
  449. /** 服务端bidding广告内容(可选) */
  450. private mBiddingAdm = ''
  451. /** 广告加载监听器 */
  452. private expressLoadAdListener: NativeExpressAdListener = {
  453. /**
  454. * 广告加载失败回调
  455. */
  456. onError: (code: number, message: string) => {
  457. console.error("加载广告失败,code=" + code + ",message=" + message);
  458. this.status = "加载广告失败,code=" + code + ",message=" + message;
  459. },
  460. /**
  461. * 广告加载成功回调
  462. * @param ads 返回的广告列表
  463. */
  464. onNativeExpressAdLoad: (ads: ArrayList<CSJNativeExpressAd>) => {
  465. console.log("BannerExpressAdPage==onNativeExpressAdLoad......success");
  466. if (ads && ads.length > 0) {
  467. ads.forEach((ad: CSJNativeExpressAd, idx: number) => {
  468. // 设置广告交互监听
  469. ad.setExpressInteractionListener({
  470. /** 广告点击回调 */
  471. onAdClicked: (type: number) => {
  472. console.log("BannerExpressAdPage==onAdClicked......");
  473. },
  474. /** 广告展示回调 */
  475. onAdShow: (type: number) => {
  476. console.log("BannerExpressAdPage==onAdShow......");
  477. },
  478. /** 模板渲染失败回调 */
  479. onRenderFail: (code: number, msg: string) => {
  480. console.log("BannerExpressAdPage==onRenderFail...code=" + code + ",msg=" + msg);
  481. },
  482. /** 模板渲染成功回调 */
  483. onRenderSuccess: (width: number, height: number) => {
  484. console.log("BannerExpressAdPage==onRenderSuccess......width=" + width + ",height=" + height);
  485. this.bannerAd = ad;
  486. this.status = "广告加载完成待展示";
  487. this.showBannerAd()
  488. }
  489. })
  490. // 设置广告轮播时间
  491. ad.setSlideIntervalTime(30 * 1000);//设置轮播时间长
  492. this.setDislikeCallback(ad); //设置dislike
  493. ad.render(this.getUIContext()) // 开始渲染广告
  494. this.status = "广告加载中...";
  495. });
  496. }
  497. }
  498. }
  499. /**
  500. * 设置广告 dislike 回调
  501. * @param ad 广告对象
  502. */
  503. private setDislikeCallback(ad: CSJNativeExpressAd) {
  504. ad.setDislikeCallback({
  505. /** dislike 弹窗显示 */
  506. onShow: () => {
  507. console.log("BannerExpressAdPage==dislike......show");
  508. },
  509. /** 选择 dislike 选项 */
  510. onSelected: (position: number, value: string, enforceRemove: boolean) => {
  511. this.isShowAd = false;
  512. console.log("BannerExpressAdPage==dislike......onSelected:position=" + position + ",value:" + value + ",enforce=" + enforceRemove);
  513. },
  514. /** 点击取消 dislike */
  515. onCancel: () => {
  516. console.log("BannerExpressAdPage==dislike......onCancel");
  517. }
  518. })
  519. }
  520. /**
  521. * 加载Banner广告
  522. * @param rit 广告位ID
  523. */
  524. loadBannerAd(rit: string) {
  525. // 仅在满足条件时加载广告
  526. if(!Utility.isNoble()){
  527. return
  528. }
  529. if(!Utility.isPassInstallTime(2)){
  530. return
  531. }
  532. this.isShowAd = false;
  533. let adCreator:CSJAdCreator = CSJAdSdk.getAdCreator()
  534. this.mAdSlot = new AdSlotBuilder()
  535. .setCodeId(rit)
  536. .setAcceptSize(CSJUtil.BANNER_WIGTH, CSJUtil.BANNER_HEIGHT)
  537. .setAdCount(1)
  538. .setBidAdm(this.mBiddingAdm)
  539. .build()
  540. PrintBiddingTokenUtils.printBiddingToken(this.mAdSlot, adCreator);
  541. adCreator.loadBannerAd(this.mAdSlot, this.expressLoadAdListener)
  542. this.status = "广告加载中..."
  543. }
  544. @StorageProp('currentHeightBreakpoint') currentHeightBreakpoint: HeightBreakpoint | undefined =
  545. HeightBreakpoint.HEIGHT_LG;
  546. @StorageProp('currentWidthBreakpoint') currentWidthBreakpoint: WidthBreakpoint | undefined = WidthBreakpoint.WIDTH_SM;
  547. //是否是Pura X外屏,或者小屏幕
  548. isPuraWP() {
  549. return this.currentWidthBreakpoint === WidthBreakpoint.WIDTH_SM
  550. && this.currentHeightBreakpoint === HeightBreakpoint.HEIGHT_MD
  551. }
  552. //是否是Pura X外屏,或者小屏幕或者手机横屏
  553. isCoverOpacity() {
  554. if (this.isPuraWP()) {
  555. return true
  556. }
  557. if (this.isPhoneLan()) {
  558. return true
  559. }
  560. if (deviceInfo.marketName.includes('Pura X')
  561. && this.currentHeightBreakpoint === HeightBreakpoint.HEIGHT_SM) {
  562. return true
  563. }
  564. return false
  565. }
  566. //是不是手机横屏
  567. isPhoneLan() {
  568. if (DeviceUtil.getDeviceType() === resourceManager.DeviceType.DEVICE_TYPE_PHONE
  569. && this.currentBreakpoint !== BreakpointTypeEnum.SM) {
  570. if (DisplayUtil.getFoldStatus() === 0 ) {
  571. return true
  572. }
  573. }
  574. return false
  575. }
  576. /**
  577. * 展示Banner广告
  578. */
  579. showBannerAd() {
  580. if (!this.bannerAd) {
  581. return
  582. }
  583. this.isShowAd = true
  584. this.status = "已展示"
  585. }
  586. /**
  587. * ================== 穿山甲广告相关结束 ==================
  588. */
  589. // geIDD() {
  590. // // 获取应用签名等信息示例代码
  591. // let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION |
  592. // bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
  593. // try {
  594. // bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => {
  595. // hilog.info(0x0000, 'testTag11', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data));
  596. // }).catch((err: BusinessError) => {
  597. // hilog.error(0x0000, 'testTag11', 'getBundleInfoForSelf failed. Cause: %{public}s', err.message);
  598. // });
  599. // } catch (err) {
  600. // let message = (err as BusinessError).message;
  601. // hilog.error(0x0000, 'testTag33', 'getBundleInfoForSelf failed: %{public}s', message);
  602. // }
  603. // }
  604. }