feat: 带图评论

This commit is contained in:
guozhigq
2024-10-17 00:40:42 +08:00
parent 853627097d
commit 113a76894a
12 changed files with 319 additions and 7 deletions

View File

@ -1,4 +1,6 @@
import 'dart:convert';
import 'dart:developer';
import 'package:dio/dio.dart';
import 'package:hive/hive.dart';
import '../common/constants.dart';
import '../models/common/reply_type.dart';
@ -343,18 +345,35 @@ class VideoHttp {
required String message,
int? root,
int? parent,
List<Map<dynamic, dynamic>>? pictures,
}) async {
if (message == '') {
return {'status': false, 'data': [], 'msg': '请输入评论内容'};
}
var res = await Request().post(Api.replyAdd, queryParameters: {
'type': type.index,
var params = <String, dynamic>{
'plat': 1,
'oid': oid,
'root': root == null || root == 0 ? '' : root,
'parent': parent == null || parent == 0 ? '' : parent,
'type': type.index,
// 'root': root == null || root == 0 ? '' : root,
// 'parent': parent == null || parent == 0 ? '' : parent,
'message': message,
'at_name_to_mid': {},
if (pictures != null) 'pictures': jsonEncode(pictures),
'gaia_source': 'main_web',
'csrf': await Request.getCsrf(),
});
};
Map sign = await WbiSign().makSign(params);
params.remove('wts');
params.remove('w_rid');
FormData formData = FormData.fromMap({...params});
var res = await Request().post(
Api.replyAdd,
queryParameters: {
'w_rid': sign['w_rid'],
'wts': sign['wts'],
},
data: formData,
);
log(res.toString());
if (res.data['code'] == 0) {
return {'status': true, 'data': res.data['data']};