feat: 评论
This commit is contained in:
@ -1,8 +1,11 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/http/reply.dart';
|
||||
import 'package:pilipala/http/video.dart';
|
||||
import 'package:pilipala/models/common/reply_type.dart';
|
||||
import 'package:pilipala/models/video/reply/data.dart';
|
||||
import 'package:pilipala/models/video/reply/item.dart';
|
||||
|
||||
@ -10,7 +13,7 @@ class VideoReplyController extends GetxController {
|
||||
VideoReplyController(
|
||||
this.aid,
|
||||
this.rpid,
|
||||
this.level,
|
||||
this.level
|
||||
);
|
||||
final ScrollController scrollController = ScrollController();
|
||||
// 视频aid 请求时使用的oid
|
||||
@ -24,6 +27,15 @@ class VideoReplyController extends GetxController {
|
||||
int currentPage = 0;
|
||||
bool isLoadingMore = false;
|
||||
RxBool noMore = false.obs;
|
||||
RxBool autoFocus = false.obs;
|
||||
// 当前回复的回复
|
||||
ReplyItemModel? currentReplyItem;
|
||||
// 回复来源
|
||||
String replySource = 'main';
|
||||
// 根评论 id 回复楼中楼回复使用
|
||||
int? rPid;
|
||||
// 默认回复主楼
|
||||
String replyLevel = '0';
|
||||
|
||||
Future queryReplyList({type = 'init'}) async {
|
||||
isLoadingMore = true;
|
||||
@ -77,4 +89,29 @@ class VideoReplyController extends GetxController {
|
||||
Future onLoad() async {
|
||||
queryReplyList(type: 'onLoad');
|
||||
}
|
||||
|
||||
wakeUpReply() {
|
||||
autoFocus.value = true;
|
||||
}
|
||||
|
||||
// 发表评论
|
||||
Future submitReplyAdd() async {
|
||||
print('replyLevel: $replyLevel');
|
||||
// print('rpid: $rpid');
|
||||
// print('currentReplyItem!.rpid: ${currentReplyItem!.rpid}');
|
||||
|
||||
|
||||
var result = await VideoHttp.replyAdd(
|
||||
type: ReplyType.video,
|
||||
oid: int.parse(aid!),
|
||||
root: replyLevel == '0' ? 0 : replyLevel == '1' ? currentReplyItem!.rpid : rPid,
|
||||
parent: replyLevel == '0' ? 0 : replyLevel == '1' ? currentReplyItem!.rpid : currentReplyItem!.rpid,
|
||||
message: replyLevel == '2' ? ' 回复 @${currentReplyItem!.member!.uname!} : 2楼31' : '2楼31',
|
||||
);
|
||||
if(result['status']){
|
||||
SmartDialog.showToast(result['data']['success_toast']);
|
||||
}else{
|
||||
SmartDialog.showToast(result['message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user