HarmonyOS 如何拉起应用市场?

HarmonyOS  如何拉起应用市场?

HarmonyOS
2024-11-01 09:13:10
815浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zbw_apple
import { BusinessError } from '@kit.BasicServicesKit'; 
import { common, Want } from '@kit.AbilityKit'; 
const TAG = '[StoreDemo]'; 
@Entry 
@Component 
struct Index { 
  dialogController: CustomDialogController | null = new CustomDialogController({ 
    builder: RouterDialog({ 
      jumpAppStore: (appid:string) => { 
        this.loadProduct(appid) 
      }, 
    }), 
    autoCancel: true, 
    alignment: DialogAlignment.Bottom, 
    offset: { dx: 0, dy: 0 }, 
    customStyle: true 
  }) 
  build() { 
    Column() { 
      Button('弹窗').onClick(() => { 
        this.dialogController?.open() 
      }) 
    }.justifyContent(FlexAlign.Center) 
    .width('100%') 
    .height('100%') 
  } 
  loadProduct(appid:string) { 
    try { 
      let uri = 'store://appgallery.huawei.com/app' //跳转到应用市场首页 
      if (appid.length > 0) { 
        uri = `store://appgallery.huawei.com/app/detail?id=${appid}`//跳转到应用市场具体app的详情页 
      } 
      const request: Want = { 
        uri: uri 
      }; 
      const context = getContext(this) as common.UIAbilityContext; 
      context.startAbility(request).then(()=>{ 
        console.debug('success startAbility') 
      }).catch((err:BusinessError)=>{ 
        console.debug('error startAbility' + err.message) 
      }); 
 
    } catch (err) { 
      console.error(TAG, `loadProduct failed. code is ${err.code}, message is ${err.message}`); 
    } 
  } 
 
} 
 
@CustomDialog 
struct RouterDialog { 
  private controller: CustomDialogController 
  jumpAppStore = (appid: string) => { 
  } 
  build() { 
    Column({space:10}) { 
      Button('跳转应用市场首页') 
        .width(300) 
        .height(50) 
        .onClick(() => { 
          this.jumpAppStore(''); 
        }) 
      Button('跳转某书详情页') 
        .width(300) 
        .height(50) 
        .onClick(() => { 
          this.jumpAppStore('C5765880207852917075'); 
        }) 
      Button('跳转视频详情页') 
        .width(300) 
        .height(50) 
        .onClick(() => { 
          this.jumpAppStore('C1081898888199154560'); 
        }) 
    }.width('100%') 
    .backgroundColor('#ff57ea66') 
  } 
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
分享
微博
QQ
微信
回复
2024-11-01 17:50:26
相关问题
如何拉起应用市场界面
3732浏览 • 1回复 待解决
HarmonyOS 如何通过应用市场更新
777浏览 • 1回复 待解决
HarmonyOS 如何拉起相机应用
775浏览 • 1回复 待解决
HarmonyOS 跳转应用市场
842浏览 • 1回复 待解决
HarmonyOS 跳转应用市场评分
1142浏览 • 1回复 待解决
HarmonyOS 跳转应用市场问题
852浏览 • 1回复 待解决
HarmonyOS应用升级跳转应用市场推荐
1064浏览 • 1回复 待解决
HarmonyOS webview拉起应用
1361浏览 • 1回复 待解决
HarmonyOS 应用市场评分机制
699浏览 • 1回复 待解决
求大佬告知如何跳转至应用市场
1345浏览 • 0回复 待解决
HarmonyOS 应用市场详情页面地址
711浏览 • 1回复 待解决