Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
陈剑华
2024-05-29 17:54:06 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
4530708d9eb5c4bc4ff11767125cc68fc7f2d4ee
4530708d
2 parents
b70f8311
3979f9da
Merge remote-tracking branch 'origin/main'
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
19 deletions
sight_harmony/features/wdComponent/src/main/ets/components/view/LiveLikeComponent.ets
sight_harmony/features/wdComponent/src/main/module.json5
sight_harmony/features/wdComponent/src/main/ets/components/view/LiveLikeComponent.ets
View file @
4530708
...
...
@@ -9,6 +9,8 @@ import {
} from 'wdBean';
import { LiveModel } from '../../viewmodel/LiveModel';
import { HttpUtils } from 'wdNetwork/Index';
import vibrator from '@ohos.vibrator';
import { BusinessError } from '@ohos.base';
const TAG = 'LiveLikeComponent';
...
...
@@ -106,38 +108,63 @@ export struct LiveLikeComponent {
@Builder
likeCompStyle() {
Stack({ alignContent: Alignment.
Bottom
}) {
Stack({ alignContent: Alignment.
TopEnd
}) {
Column() {
Image(this.transLikeStyle().url)
.width(24)
.height(24)
.onClick(() => {
this.clickButtonEvent()
})
}
.justifyContent(FlexAlign.Center)
.width(36)
.height(36)
.borderRadius(18)
.backgroundColor((this.pageComponentType === 4 || this.pageComponentType === 2) ? '#4D000000' : this.pageComponentType === 8 ? Color.Transparent : '#FFF5F5F5')
Row() {
Text(NumberFormatterUtils.formatNumberWithWan(this.likeCount || ''))
.fontSize(8)
.fontColor(Color.White)
.padding({ left: 8, right: 2 })
if (this.likeCount != 0) {
RelativeContainer() {
Image(this.styleType == 1 ? $r('app.media.comment_icon_number_bg') : $r('app.media.ic_like_back_Select'))
.objectFit(ImageFit.Fill)
.resizable({
slice: {
top: 1,
left: 20,
right: 1,
bottom: 1
}
})
.alignRules({
top: { anchor: "Text", align: VerticalAlign.Top },
left: { anchor: "Text", align: HorizontalAlign.Start },
right: { anchor: "Text", align: HorizontalAlign.End },
bottom: { anchor: "Text", align: VerticalAlign.Bottom },
})
.id("Image")
Text(NumberFormatterUtils.formatNumberWithWan(this.likeCount || ''))// Text("44444444")
.fontSize(8)
.fontColor('#ffffff')// .backgroundColor('#ED2800')
.height(12)
.textAlign(TextAlign.Center)
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
left: { anchor: "__container__", align: HorizontalAlign.Start }
})// .margin({left: 4,right:4
// })
/*动态计算文字宽度*/
.width(this.getMeasureText(NumberFormatterUtils.formatNumberWithWan(this.likeCount || '')) +
12)// .backgroundColor(Color.Green)
.id("Text")
.visibility(this.likeCount > 0 ? Visibility.Visible : Visibility.Hidden)
}
.offset({
x: 18
})
}
.height(12)
.alignItems(VerticalAlign.Center)
.position({ x: '100%', y: 10 })
.markAnchor({ x: '100%' })
.backgroundImage($r('app.media.ic_like_back'))
.backgroundImageSize({height: 13})
.width(this.getMeasureText(NumberFormatterUtils.formatNumberWithWan(this.likeCount || '')) +
12)
.visibility(this.likeCount > 0 ? Visibility.Visible : Visibility.Hidden)
}
.width(36)
.height(42)
.height(36)
.onClick(() => {
this.clickButtonEvent()
})
.visibility(this.likesStyle == 'empty' || !this.openLikes ? Visibility.None : Visibility.Visible)
}
...
...
@@ -164,6 +191,25 @@ export struct LiveLikeComponent {
this.LiveModel.getLiveRoomNumberLike(this.likeBean['contentId'], 1, HttpUtils.getDeviceId()).then((data) => {
console.log(TAG, '点赞接口调用成功', JSON.stringify(data))
try {
// 触发马达振动
vibrator.startVibration({
type: 'time',
duration: 100,
}, {
id: 0,
usage: 'alarm'
}, (error: BusinessError) => {
if (error) {
console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
return;
}
console.info('Succeed in starting vibration');
});
} catch (err) {
let e: BusinessError = err as BusinessError;
console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`);
}
this.likeCount++
}).catch(() => {
...
...
sight_harmony/features/wdComponent/src/main/module.json5
View file @
4530708
...
...
@@ -12,6 +12,9 @@
"requestPermissions"
:
[
{
"name"
:
"ohos.permission.INTERNET"
},
{
"name"
:
"ohos.permission.VIBRATE"
}
],
"pages"
:
"$profile:main_pages"
...
...
Please
register
or
login
to post a comment