You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
52 lines
1.4 KiB
import 'dart:async';
|
|
import 'package:dating_touchme_app/model/mine/chat_static_data.dart';
|
|
import 'package:dating_touchme_app/pages/setting/match_spread_page.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
import '../../network/user_api.dart';
|
|
import '../global.dart';
|
|
|
|
class LeagueController extends GetxController {
|
|
|
|
late UserApi _userApi;
|
|
final genderCode = 0.obs;
|
|
final consumption = ChatStaticData(liveDurationMins: 0).obs;
|
|
final hours = 0.obs;
|
|
final canApply = false.obs;
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
// 从全局依赖中获取UserApi
|
|
_userApi = Get.find<UserApi>();
|
|
genderCode.value = GlobalData().userData!.genderCode!;
|
|
fetchData();
|
|
}
|
|
|
|
fetchData() async {
|
|
try{
|
|
final response = await _userApi.getChatStaticsInfo();
|
|
if (response.data.isSuccess && response.data.data != null) {
|
|
consumption.value = response.data.data!;
|
|
}
|
|
final result = await _userApi.getMatchmakerRequirement();
|
|
if (result.data.isSuccess && result.data.data != null) {
|
|
final roseList = result.data.data!;
|
|
hours.value = roseList[0].liveDurationHours!;
|
|
}
|
|
canApply.value = consumption.value.liveDurationMins! >= hours.value * 60;
|
|
} catch (e) {
|
|
print('spread: $e');
|
|
}
|
|
}
|
|
|
|
applyMatcher(){
|
|
if(canApply.value){
|
|
Get.off(() => MatchSpreadPage());
|
|
} else {
|
|
Get.back();
|
|
}
|
|
}
|
|
|
|
}
|
|
|