Browse Source

no message

dev-2.0
ZHR007 2 months ago
parent
commit
31b6460779
6 changed files with 238 additions and 20 deletions
  1. 23
      lib/controller/setting/task_controller.dart
  2. 115
      lib/model/live/matchmaker_task.dart
  3. 3
      lib/network/api_urls.dart
  4. 8
      lib/network/home_api.dart
  5. 33
      lib/network/home_api.g.dart
  6. 76
      lib/pages/setting/match_task_page.dart

23
lib/controller/setting/task_controller.dart

@ -1,4 +1,6 @@
import 'package:dating_touchme_app/model/live/matchmaker_task.dart';
import 'package:dating_touchme_app/model/mine/matchmaker_requirement_data.dart';
import 'package:dating_touchme_app/network/home_api.dart';
import 'package:dating_touchme_app/network/user_api.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
@ -6,23 +8,34 @@ import 'package:get/get.dart';
class TaskController extends GetxController {
// UserApi实例
late UserApi _userApi;
final roseList = <MatchmakerRequirement>[].obs;
late HomeApi _homeApi;
final dayTask = MatchmakerTask().obs;
final weekTask = MatchmakerTask().obs;
final monthTask = MatchmakerTask().obs;
final loading = true.obs;
@override
void onInit() {
super.onInit();
_userApi = Get.find<UserApi>();
_homeApi = Get.find<HomeApi>();
initDataList();
}
initDataList() async {
try{
loading.value = true;
final result = await _userApi.getMatchmakerRequirement();
final result = await _homeApi.getMatchmakerTask(taskType: 1);
if (result.data.isSuccess && result.data.data != null) {
roseList.value = result.data.data!;
dayTask.value = result.data.data!;
}
final result2 = await _homeApi.getMatchmakerTask(taskType: 2);
if (result2.data.isSuccess && result2.data.data != null) {
weekTask.value = result2.data.data!;
}
// Get.log(weekTask.value.toString());
final result3 = await _homeApi.getMatchmakerTask(taskType: 3);
if (result3.data.isSuccess && result3.data.data != null) {
monthTask.value = result3.data.data!;
}
} finally {
loading.value = false;

115
lib/model/live/matchmaker_task.dart

@ -0,0 +1,115 @@
class SubListItem {
final String? subTaskName;
final int? subTaskType;
final String? subTaskDesc;
final int? requiredCount;
final int? completeCount;
final bool? completeStatus;
final String? completeTime;
final int? sort;
SubListItem({
this.subTaskName,
this.subTaskType,
this.subTaskDesc,
this.requiredCount,
this.completeCount,
this.completeStatus,
this.completeTime,
this.sort,
});
factory SubListItem.fromJson(Map<String, dynamic> json) {
return SubListItem(
subTaskName: json['subTaskName'] as String?,
subTaskType: json['subTaskType'] as int?,
subTaskDesc: json['subTaskDesc'] as String?,
requiredCount: json['requiredCount'] as int?,
completeCount: json['completeCount'] as int?,
completeStatus: json['completeStatus'] as bool?,
completeTime: json['completeTime'] as String?,
sort: json['sort'] as int?,
);
}
Map<String, dynamic> toJson() {
return {
'subTaskName': subTaskName,
'subTaskType': subTaskType,
'subTaskDesc': subTaskDesc,
'requiredCount': requiredCount,
'completeCount': completeCount,
'completeStatus': completeStatus,
'completeTime': completeTime,
'sort': sort,
};
}
}
class MatchmakerTask {
final String? userTaskCompleteId;
final int? taskGroup;
final int? taskType;
final int? stageCode;
final String? taskName;
final String? taskDesc;
final String? taskStartDate;
final String? taskEndDate;
final String? rewardValue;
final bool? completeStatus;
final int? rewardReceiveStatus;
final String? completeTime;
final List<SubListItem>? subList;
MatchmakerTask({
this.userTaskCompleteId,
this.taskGroup,
this.taskType,
this.stageCode,
this.taskName,
this.taskDesc,
this.taskStartDate,
this.taskEndDate,
this.rewardValue,
this.completeStatus,
this.rewardReceiveStatus,
this.completeTime,
this.subList,
});
factory MatchmakerTask.fromJson(Map<String, dynamic> json) {
return MatchmakerTask(
userTaskCompleteId: json['userTaskCompleteId'] as String?,
taskGroup: json['taskGroup'] as int?,
taskType: json['taskType'] as int?,
stageCode: json['stageCode'] as int?,
taskName: json['taskName'] as String?,
taskDesc: json['taskDesc'] as String?,
taskStartDate: json['taskStartDate'] as String?,
taskEndDate: json['taskEndDate'] as String?,
rewardValue: json['rewardValue'] as String?,
completeStatus: json['completeStatus'] as bool?,
rewardReceiveStatus: json['rewardReceiveStatus'] as int?,
completeTime: json['completeTime'] as String?,
subList: (json['subList'] as List<dynamic>?)?.map((e) => SubListItem.fromJson(e as Map<String, dynamic>)).toList() ?? [],
);
}
Map<String, dynamic> toJson() {
return {
'userTaskCompleteId': userTaskCompleteId,
'taskGroup': taskGroup,
'taskType': taskType,
'stageCode': stageCode,
'taskName': taskName,
'taskDesc': taskDesc,
'taskStartDate': taskStartDate,
'taskEndDate': taskEndDate,
'rewardValue': rewardValue,
'completeStatus': completeStatus,
'rewardReceiveStatus': rewardReceiveStatus,
'completeTime': completeTime,
'subList': subList?.map((e) => e.toJson()).toList(),
};
}
}

3
lib/network/api_urls.dart

@ -163,4 +163,7 @@ class ApiUrls {
static const String userPageMicJoinRtcChannelUser =
'dating-agency-chat-audio/user/page/mic-join/rtc-channel-user';
static const String listMatchmakerTask =
'dating-agency-mall/user/get/user-task-complete';
}

8
lib/network/home_api.dart

@ -1,3 +1,4 @@
import 'package:dating_touchme_app/model/live/matchmaker_task.dart';
import 'package:dating_touchme_app/network/api_urls.dart';
import 'package:dating_touchme_app/network/response_model.dart';
import 'package:retrofit/retrofit.dart';
@ -20,4 +21,11 @@ abstract class HomeApi {
@Query('pageSize') required int pageSize,
@Query('type') required int type,
});
@GET(ApiUrls.listMatchmakerTask)
Future<HttpResponse<BaseResponse<MatchmakerTask>>> getMatchmakerTask({
@Query('taskType') required int taskType,
});
}

33
lib/network/home_api.g.dart

@ -65,6 +65,39 @@ class _HomeApi implements HomeApi {
return httpResponse;
}
@override
Future<HttpResponse<BaseResponse<MatchmakerTask>>> getMatchmakerTask({
required int taskType,
}) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{r'taskType': taskType};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _options = _setStreamType<HttpResponse<BaseResponse<MatchmakerTask>>>(
Options(method: 'GET', headers: _headers, extra: _extra)
.compose(
_dio.options,
'dating-agency-mall/user/get/user-task-complete',
queryParameters: queryParameters,
data: _data,
)
.copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
);
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late BaseResponse<MatchmakerTask> _value;
try {
_value = BaseResponse<MatchmakerTask>.fromJson(
_result.data!,
(json) => MatchmakerTask.fromJson(json as Map<String, dynamic>),
);
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
final httpResponse = HttpResponse(_value, _result);
return httpResponse;
}
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
if (T != dynamic &&
!(requestOptions.responseType == ResponseType.bytes ||

76
lib/pages/setting/match_task_page.dart

@ -1,7 +1,6 @@
import 'package:dating_touchme_app/components/page_appbar.dart';
import 'package:dating_touchme_app/controller/global.dart';
import 'package:dating_touchme_app/controller/setting/task_controller.dart';
import 'package:dating_touchme_app/model/mine/matchmaker_requirement_data.dart';
import 'package:dating_touchme_app/model/live/matchmaker_task.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
@ -34,7 +33,7 @@ class MatchTaskPage extends StatelessWidget {
children: [
Row(
children: [
TDText('日任务', style: TextStyle(color: Color(0xFF333333), fontWeight: FontWeight.bold, fontSize: 16.w)),
TDText(controller.dayTask.value.taskName, style: TextStyle(color: Color(0xFF333333), fontWeight: FontWeight.bold, fontSize: 16.w)),
SizedBox(width: 4.w),
Container(
width: 4,
@ -45,17 +44,17 @@ class MatchTaskPage extends StatelessWidget {
),
),
SizedBox(width: 4.w),
TDText('任务时间:截止 23:25', style: TextStyle(color: Color(0xFF666666), fontSize: 16.w)),
TDText('任务截止时间:${controller.dayTask.value.taskEndDate}', style: TextStyle(color: Color(0xFF666666), fontSize: 16.w)),
],
),
SizedBox(height: 12.w,),
...controller.roseList.asMap().entries.map((entry){
...controller.dayTask.value.subList!.asMap().entries.map((entry){
return TaskItem(item: entry.value);
}),
SizedBox(height: 24.w,),
Row(
if(controller.weekTask.value.taskName != null && controller.weekTask.value.taskName!.isNotEmpty) SizedBox(height: 24.w,),
if(controller.weekTask.value.taskName != null && controller.weekTask.value.taskName!.isNotEmpty) Row(
children: [
TDText('月任务', style: TextStyle(color: Color(0xFF333333), fontWeight: FontWeight.bold, fontSize: 16.w)),
TDText(controller.weekTask.value.taskName, style: TextStyle(color: Color(0xFF333333), fontWeight: FontWeight.bold, fontSize: 16.w)),
SizedBox(width: 4.w),
Container(
width: 4,
@ -66,11 +65,32 @@ class MatchTaskPage extends StatelessWidget {
),
),
SizedBox(width: 4.w),
TDText('任务时间:截止 03/15 23:59', style: TextStyle(color: Color(0xFF666666), fontSize: 16.w)),
TDText('任务截止时间:${controller.weekTask.value.taskEndDate}', style: TextStyle(color: Color(0xFF666666), fontSize: 16.w)),
],
),
SizedBox(height: 12.w,),
...controller.roseList.asMap().entries.map((entry){
if(controller.weekTask.value.taskName != null && controller.weekTask.value.taskName!.isNotEmpty)SizedBox(height: 12.w,),
if(controller.weekTask.value.taskName != null && controller.weekTask.value.taskName!.isNotEmpty)...controller.weekTask.value.subList!.asMap().entries.map((entry){
return TaskItem(item: entry.value);
}),
if(controller.monthTask.value.taskName != null && controller.monthTask.value.taskName!.isNotEmpty) SizedBox(height: 24.w,),
if(controller.monthTask.value.taskName != null && controller.monthTask.value.taskName!.isNotEmpty) Row(
children: [
TDText(controller.monthTask.value.taskName, style: TextStyle(color: Color(0xFF333333), fontWeight: FontWeight.bold, fontSize: 16.w)),
SizedBox(width: 4.w),
Container(
width: 4,
height: 4,
decoration: BoxDecoration(
color: Color(0xFF999999), //
shape: BoxShape.circle, //
),
),
SizedBox(width: 4.w),
TDText('任务截止时间:${controller.monthTask.value.taskEndDate}', style: TextStyle(color: Color(0xFF666666), fontSize: 16.w)),
],
),
if(controller.monthTask.value.taskName != null && controller.monthTask.value.taskName!.isNotEmpty)SizedBox(height: 12.w,),
if(controller.monthTask.value.taskName != null && controller.monthTask.value.taskName!.isNotEmpty)...controller.monthTask.value.subList!.asMap().entries.map((entry){
return TaskItem(item: entry.value);
}),
SizedBox(height: 12.w,),
@ -105,7 +125,7 @@ class MatchTaskPage extends StatelessWidget {
}
class TaskItem extends StatelessWidget {
final MatchmakerRequirement item;
final SubListItem item;
const TaskItem({super.key, required this.item });
@override
@ -115,19 +135,45 @@ class TaskItem extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TDText(item.liveConsumptionAmount! > 0 ? '累计消费' : '累计连麦相亲', style: TextStyle(color: Color(0xFF333333), fontSize: 16.w)),
TDText(item.subTaskName, style: TextStyle(color: Color(0xFF333333), fontSize: 16.w)),
SizedBox(height: 4.w),
TDProgress(
type: TDProgressType.linear,
value: 0.5,
value: _getTaskProgress(item),
strokeWidth: 6,
progressLabelPosition: TDProgressLabelPosition.right,
color: Color(0xFF7562F9),
),
SizedBox(height: 2.w),
TDText('目前有效金额:22.66元', style: TextStyle(color: Color(0xFF999999), fontSize: 12.w)),
TDText(_getTaskLabel(item), style: TextStyle(color: Color(0xFF999999), fontSize: 12.w)),
],
),
);
}
double _getTaskProgress(SubListItem item) {
if(item.completeCount! <= 0){
return 0;
}
if(item.requiredCount! <= 0){
return 0;
}
double progress = item.completeCount! / item.requiredCount!;
return double.parse(progress.toStringAsFixed(3));
}
// 123
String _getTaskLabel(SubListItem item) {
if(item.subTaskType == 1){
return '目前直播时长:${item.completeCount}分钟';
}
if(item.subTaskType == 2){
return '目前相亲次数:${item.completeCount}';
}
if(item.subTaskType == 3){
return '目前打卡人数:${item.completeCount}';
}
return '';
}
}
Loading…
Cancel
Save