| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- import { BasicType, IBestToast, userInfo, UserInfo, YTAvoid, YTLog, yTRouter } from 'basic'
- import { common, Want } from '@kit.AbilityKit'
- import { BusinessError } from '@kit.BasicServicesKit'
- import { BUNDLE_NAME } from 'BuildProfile'
- import { systemShare } from '@kit.ShareKit'
- import { uniformTypeDescriptor } from '@kit.ArkData'
- @Component
- export struct Mine {
- @StorageProp(YTAvoid.SAFE_TOP_KEY) safeTop: number = 0
- @StorageProp(UserInfo.KEY) userInfo: UserInfo = userInfo
- setArr: Array<BasicType> = [
- {
- text: '分享给好友',
- message: '去分享',
- click: () => {
- this.shareData()
- },
- src: $r('app.media.mine_right_arrow')
- },
- {
- text: '意见反馈',
- click: () => {
- if (this.userInfo.checkLogin()) {
- yTRouter.router2SuggestionPage()
- } else {
- yTRouter.router2LoginPage()
- }
- },
- src: $r('app.media.mine_right_arrow')
- },
- {
- text: '给个好评',
- click: () => {
- const want: Want = {
- uri: "store://appgallery.huawei.com/app/detail?id=" + BUNDLE_NAME
- };
- const context = this.getUIContext().getHostContext() as common.UIAbilityContext;
- context.startAbility(want).then(() => {
- //拉起成功
- YTLog.info('跳转成功')
- }).catch((err: BusinessError) => {
- // 拉起失败
- YTLog.error(err)
- IBestToast.show('出现未知错误,请稍后再试')
- });
- },
- src: $r('app.media.mine_right_arrow')
- },
- {
- text: '关于我们',
- click: () => {
- yTRouter.router2AboutUS()
- },
- src: $r('app.media.mine_right_arrow')
- }
- ]
- aboutToAppear(): void {
- }
- build() {
- RelativeContainer() {
- Image(this.userInfo.getHeadImg())
- .aspectRatio(1)
- .height(80)
- .borderRadius(999)
- .border({ width: 4, color: Color.White })
- .alignRules({
- top: { anchor: "__container__", align: VerticalAlign.Top },
- left: { anchor: "__container__", align: HorizontalAlign.Start },
- bottom: { anchor: "bottomColumn", align: VerticalAlign.Top },
- bias: { vertical: 176 / (176 - 40) }
- })
- .offset({ x: 28 })
- .zIndex(999)
- .id("headerImg")
- Text(this.userInfo.getName())
- .fontSize(18)
- .fontColor('#FF1C1C1C')
- .fontWeight(500)
- .alignRules({
- top: { anchor: "headerImg", align: VerticalAlign.Bottom },
- left: { anchor: "headerImg", align: HorizontalAlign.Start },
- })
- .offset({ x: 28, y: 20 })
- .zIndex(999)
- Text(this.userInfo.checkLogin() ? '编辑' : '登录')
- .textAlign(TextAlign.Center)
- .height(29)
- .width(57)
- .borderRadius(32)
- .fontColor(Color.White)
- .fontSize(14)
- .fontWeight(400)
- .alignRules({
- center: { anchor: "headerImg", align: VerticalAlign.Bottom },
- right: { anchor: "__container__", align: HorizontalAlign.End },
- })
- .zIndex(999)
- .linearGradient({ angle: 135, colors: [['#CAE2F9', -0.1571], ['#D4D1F4', 0.4709], ['#EDF5FD', 1.1235]] })
- .offset({ x: -32, y: -2 })
- .onClick(() => {
- if (!this.userInfo.checkLogin()) {
- yTRouter.router2LoginPage()
- } else {
- yTRouter.router2SettingPage()
- }
- })
- Column() {
- List() {
- ForEach(this.setArr, (item: BasicType, index) => {
- ListItem() {
- Row() {
- Text(item.text)
- .fontColor('#FF1C1C1C')
- .fontSize(14)
- if (!index) {
- Text('去分享')
- .fontColor('#801C1C1C')
- .fontSize(14)
- .fontWeight(400)
- } else {
- Image($r('app.media.right_arrow'))
- .width(24)
- .aspectRatio(1)
- }
- }
- .width('100%')
- .height(56)
- .justifyContent(FlexAlign.SpaceBetween)
- .onClick(() => {
- item.click?.()
- })
- }
- })
- }
- .divider({ strokeWidth: 1, color: '#1A1C1C1C', })
- .width('100%')
- .height('100%')
- }
- .backgroundColor(Color.White)
- .width('100%')
- .height(550)
- .borderRadius({ topRight: 32 })
- .alignRules({
- bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
- left: { anchor: "__container__", align: HorizontalAlign.Start },
- })
- .id("bottomColumn")
- .padding({ top: 142, left: 24, right: 24 })
- }
- .height('100%')
- .backgroundImage($r('app.media.mine_bgc'))
- .backgroundImageSize({ width: '100%', height: 305 })
- .backgroundImagePosition(Alignment.Top)
- }
- async shareData() {
- try {
- // 构造ShareData,需配置一条有效数据信息
- const data = new systemShare.SharedData({
- // utd: uniformTypeDescriptor.UniformDataType.HYPERLINK,
- utd: uniformTypeDescriptor.UniformDataType.TEXT,
- title: '盒小仓',
- content: 'http://appgallery.huawei.com/app/detail?id=6917580461832049757',
- description: "http://appgallery.huawei.com/app/detail?id=6917580461832049757"
- })
- const controller = new systemShare.ShareController(data)
- const context = this.getUIContext().getHostContext()! as common.UIAbilityContext;
- // 进行分享面板显示
- controller.show(context, {
- previewMode: systemShare.SharePreviewMode.DEFAULT,
- selectionMode: systemShare.SelectionMode.SINGLE,
- // anchor: { windowOffset: { x: 0, y: 0 }, size: { width: this.breakWidth, height: 500 } }
- })
- } catch (error) {
- IBestToast.show({ message: '当前设备不支持', duration: 500 })
- }
- }
- }
|