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
yangsunyue_wd
2024-04-29 17:34:54 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0065429127bf7b630b932c4ff807fd29ccdb269e
00654291
1 parent
c328c349
desc:评论相关
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
150 additions
and
25 deletions
sight_harmony/features/wdComponent/src/main/ets/components/comment/model/PublishCommentModel.ets
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/CommentComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/CommentCustomDialog.ets
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/QualityCommentsComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/comment/model/PublishCommentModel.ets
View file @
0065429
...
...
@@ -15,7 +15,7 @@ export class publishCommentModel {
/*【迭代二新增】关联的频道id/专题id; 页面必传*/
targetRelObjectId: string = ""
/*【迭代二新增】是否是重点稿件 1是 0否 页面必传*/
keyArticle: string = ''
keyArticle: string = '
0
'
/*内容类别, 1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,8:图文,9:组图,10:H5新闻,11:频道,12:组件,13:音频,14:动态(13和14为中文版新增) 页面必传*/
targetType: string = ''
/*评论总数*/
...
...
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/CommentComponent.ets
View file @
0065429
...
...
@@ -9,8 +9,9 @@ import measure from '@ohos.measure'
import { CommentCustomDialog } from './CommentCustomDialog'
import { publishCommentModel } from '../model/PublishCommentModel';
import { ifaa } from '@kit.OnlineAuthenticationKit';
import { HttpUrlUtils } from 'wdNetwork/Index';
import { HttpUrlUtils
, HttpUtils
} from 'wdNetwork/Index';
import NoMoreLayout from '../../page/NoMoreLayout';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
const TAG = 'CommentComponent';
...
...
@@ -559,6 +560,12 @@ struct commentFooterView {
}
.onClick(() => {
// 未登录,跳转登录
const user_id = HttpUtils.getUserId()
if (!user_id) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
commentLikeChange(this.item)
commentViewModel.commentLike(this.item).then(() => {
}).catch(() => {
...
...
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/CommentCustomDialog.ets
View file @
0065429
...
...
@@ -7,17 +7,17 @@ import commentViewModel from '../viewmodel/CommentViewModel'
@Preview
@CustomDialog
export struct CommentCustomDialog {
@ObjectLink publishCommentModel: publishCommentModel
controller?: CustomDialogController
confirm: (value: Record<string, string>) => void = () => {
}
@State private emojiSwitch: boolean = false
textInputController: TextAreaController = new TextAreaController()
@State positionInfo: CaretOffset = { index: 0, x: 0, y: 0 }
aboutToAppear(): void {
// this.textInputController.caretPosition(0)
}
publishCommentRequest() {
...
...
@@ -25,7 +25,7 @@ export struct CommentCustomDialog {
// this.publishCommentModel.commentContent = this.commentText
//TODO 判断类型
this.publishCommentModel.commentType = '2'
commentViewModel.publishComment(this.publishCommentModel).then((model:commentItemModel) => {
commentViewModel.publishComment(this.publishCommentModel).then((model:
commentItemModel) => {
this.publishCommentModel.commentContent = ''
//
...
...
@@ -74,12 +74,13 @@ export struct CommentCustomDialog {
.height(30)
.onClick(() => {
// this.commentText = this.commentText + '神鼎'
this.positionInfo = this.textInputController.getCaretOffset()
this.emojiSwitch = !this.emojiSwitch
if (this.emojiSwitch) {
this.textInputController.stopEditing()
} else {
this.textInputController.caretPosition(this.textInputController.getTextContentRect().x)
//
this.textInputController.caretPosition(this.textInputController.getTextContentRect().x)
}
})
...
...
@@ -116,7 +117,7 @@ export struct CommentCustomDialog {
//表情view
if (this.emojiSwitch) {
emojiView()
emojiView(
{ publishCommentModel: this.publishCommentModel }).height(150
)
}
}.backgroundColor(Color.White)
...
...
@@ -129,8 +130,88 @@ export struct CommentCustomDialog {
@Component
struct emojiView {
@ObjectLink publishCommentModel: publishCommentModel
/*没找到获取系统emoji的方案*/
private emojiString = '😀,😁,😂,😃,😄,😅,😆,😇,😈,😉,😊,😋,😌,😍,😎,😏,😐,😑,😒,😓,😔,😕,😖,😗,😘,😙,😚,😛,😜,😝,😞,😟,😠,😡,😢,😣,😤,😥,😦,😧,😨,😩,😪,😫,😬,😭,😮,😯,😰,😱,😲,😳,😴,😵,😶,😷,😸,😹,😺,😻,😼,😽,😾,😿,🙀,🙅,🙆,🙇,🙈,🙉,🙊,🙋,🙌,🙍,🙎,🙏'
private displayArray: string[][] = []
private swiperController: SwiperController = new SwiperController()
aboutToAppear(): void {
this.displayArray = chunk(this.emojiString.split(','), 20)
//补上删除按钮以及空白占位
let lastElement = this.displayArray.slice(-1)[0];
if (lastElement.length < 20) {
let needLength = (20 - lastElement.length)
for (let index = 0; index < needLength; index++) {
lastElement.push('')
}
}
this.displayArray.forEach(element => {
element.push('删除')
});
}
build() {
// String.fromCodePoint()
Swiper(this.swiperController) {
ForEach(this.displayArray, (array: [], index) => {
Column() {
Grid() {
ForEach(array, (emoji: string, subIndex: number) => {
GridItem() {
Text() {
if (emoji == '删除') {
ImageSpan($r('app.media.wdInput_delete'))
} else {
Span(emoji)
}
}.textAlign(TextAlign.Center).width(30).height(30)
// .backgroundColor(Color.Orange)
}.onClick(() => {
if (emoji == '删除') {
this.publishCommentModel.commentContent = this.publishCommentModel.commentContent.substring(0, this.publishCommentModel.commentContent.length -1)
} else if (emoji == '') {
} else {
this.publishCommentModel.commentContent = this.publishCommentModel.commentContent + emoji
}
})
})
}
.maxCount(6)
.columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr 1fr')
.rowsGap(10)
.layoutDirection(GridDirection.Row)
Row().height(40)
}
})
}
.indicator(true)
.vertical(false)
.height(140)
}
}
function chunk<T>(array: T[], size: number): T[][] {
const result: T[][] = [];
for (let i = 0; i < array.length; i += size) {
result.push(array.slice(i, i + size));
}
return result;
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/QualityCommentsComponent.ets
View file @
0065429
...
...
@@ -5,12 +5,16 @@ import commentViewModel from '../viewmodel/CommentViewModel'
import { router, window } from '@kit.ArkUI'
import { CustomTitleUI } from '../../reusable/CustomTitleUI'
import { MyCommentDataSource } from '../model/MyCommentDataSource'
import { HttpUrlUtils } from 'wdNetwork/Index'
import { HttpUrlUtils
, HttpUtils
} from 'wdNetwork/Index'
import PageModel from '../../../viewmodel/PageModel'
import { ErrorComponent } from '../../view/ErrorComponent'
import { EmptyComponent , WDViewDefaultType} from '../../view/EmptyComponent'
import { CustomPullToRefresh } from '../../reusable/CustomPullToRefresh'
import NoMoreLayout from '../../page/NoMoreLayout'
import { CommentCustomDialog } from './CommentCustomDialog'
import { publishCommentModel } from '../model/PublishCommentModel'
import { ifaa } from '@kit.OnlineAuthenticationKit'
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
const TAG = 'QualityCommentsComponent';
...
...
@@ -24,9 +28,6 @@ export struct QualityCommentsComponent {
@State hasMore: boolean = true;
@State currentPage: number = 1;
private scroller: Scroller = new Scroller();
@State tileOpacity: number = 0;
firstPositionY: number = 0;
bottomSafeHeight: string = AppStorage.get<number>('bottomSafeHeight') + 'px';
...
...
@@ -34,6 +35,11 @@ export struct QualityCommentsComponent {
lastWindowColor: string = '#ffffff'
currentWindowColor: string = '#FF4202'
@State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource();
@State dialogController: CustomDialogController | null = null;
/*必传*/
@State publishCommentModel: publishCommentModel = new publishCommentModel()
aboutToDisappear(): void {
...
...
@@ -43,13 +49,33 @@ export struct QualityCommentsComponent {
windowClass.setWindowLayoutFullScreen(false)
// windowClass.setWindowSystemBarProperties({ statusBarColor: '#000' })
this.dialogController = null // 将dialogController置空
}
aboutToAppear(): void {
this.fullScreen();
this.getData();
this.showAlert()
}
showAlert(){
this.dialogController = new CustomDialogController({
builder: CommentCustomDialog({
confirm: (value: Record<string, string>) => {
},
publishCommentModel: this.publishCommentModel
}),
autoCancel: true,
alignment: DialogAlignment.Bottom,
customStyle: true,
offset: {
dx: 0,
dy: -20
},
})
}
getData(resolve?: (value: string | PromiseLike<string>) => void){
...
...
@@ -217,7 +243,7 @@ export struct QualityCommentsComponent {
// ListItemGroup({ header: this.titleHeader() })
LazyForEach(this.allDatas, (item: commentItemModel, index: number) => {
ListItem() {
QualityCommentItem({ item: item, index: index }).margin({ left: 12, right: 12 })
QualityCommentItem({ item: item, index: index
, dialogController:this.dialogController, publishCommentModel:this.publishCommentModel
}).margin({ left: 12, right: 12 })
}
})
// 加载更多
...
...
@@ -243,16 +269,6 @@ export struct QualityCommentsComponent {
}
@Builder
testLayout(){
List({ space: 12, scroller:this.scroller }){
LazyForEach(this.allDatas, (item: commentItemModel, index: number) => {
ListItem() {
QualityCommentItem({ item: item, index: index }).margin({ left: 12, right: 12 })
}
})
}
}
}
...
...
@@ -261,6 +277,8 @@ export struct QualityCommentsComponent {
@Component
struct QualityCommentItem {
@ObjectLink publishCommentModel: publishCommentModel
dialogController: CustomDialogController | null = null;
@ObjectLink item: commentItemModel
index: number = 0
...
...
@@ -360,7 +378,20 @@ struct QualityCommentItem {
Row({ space: 16 }) {
Row() {
Image($r('app.media.comment_icon_pinglun')).width(16).height(16)
}
}.onClick(()=>{
this.publishCommentModel.targetId = this.item.targetId
this.publishCommentModel.targetRelId = this.item.targetRelId
this.publishCommentModel.targetTitle = this.item.targetTitle
this.publishCommentModel.targetRelType = this.item.targetRelType
this.publishCommentModel.targetRelObjectId = this.item.targetRelObjectId
this.publishCommentModel.targetType = this.item.targetType
// this.publishCommentModel.keyArticle = this.item.keyArticle
this.publishCommentModel.rootCommentId = this.item.rootCommentId
this.publishCommentModel.parentId = this.item.id
this.dialogController?.open()
})
Row() {
Image($r(this.item.api_status ? 'app.media.comment_like_select' : 'app.media.comment_like_normal'))
...
...
@@ -373,6 +404,12 @@ struct QualityCommentItem {
.margin({ left: 3 })
}
}.onClick(() => {
// 未登录,跳转登录
const user_id = HttpUtils.getUserId()
if (!user_id) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
commentLikeChange(this.item)
commentViewModel.commentLike(this.item).then(() => {
}).catch(() => {
...
...
Please
register
or
login
to post a comment