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.
148 lines
5.6 KiB
148 lines
5.6 KiB
import 'package:dating_touchme_app/controller/global.dart';
|
|
import 'package:dating_touchme_app/model/mine/chat_static_data.dart';
|
|
import 'package:dating_touchme_app/model/mine/matchmaker_requirement_data.dart';
|
|
import 'package:dating_touchme_app/network/user_api.dart';
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
import 'package:fluwx/fluwx.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
class TaskController extends GetxController {
|
|
|
|
// UserApi实例
|
|
late UserApi _userApi;
|
|
final roseList = <MatchmakerRequirement>[].obs;
|
|
|
|
final roseNum = 0.obs;
|
|
|
|
final payChecked = true.obs;
|
|
|
|
final activePay = 0.obs;
|
|
final enableIndex = (-1).obs;
|
|
final Fluwx fluwx = Fluwx();
|
|
final matchmakerFlag = false.obs;
|
|
final button = '立即申请'.obs;
|
|
final canApply = false.obs;
|
|
String paymentOrderId = '';
|
|
final revenue = [
|
|
{'icon': '1', 'desc': '礼物收益范围15%-30%,嘉宾消费的分成3%;'},
|
|
{'icon': '2', 'desc': '每天前5人连麦的礼物收益15%,第6-10人连麦的礼物收益20%,第11-15人连麦的礼物收益25%,第16人以上连麦的礼物收益30%;'},
|
|
{'icon': '3', 'desc': '红娘推荐的嘉宾成为红娘,赚取入驻费的20%分成;'},
|
|
{'icon': '4', 'desc': '新徒弟首月收益的10%(平台奖励)'},
|
|
].obs;
|
|
final userData = GlobalData().userData.obs;
|
|
final userId = GlobalData().userId.obs;
|
|
|
|
final consumption = ChatStaticData().obs;
|
|
final countdownSeconds = 0.obs;
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
_userApi = Get.find<UserApi>();
|
|
if(GlobalData().userData!.matchmakerFlag != null && GlobalData().userData!.matchmakerFlag!){
|
|
matchmakerFlag.value = true;
|
|
}
|
|
initDataList();
|
|
}
|
|
|
|
changePayActive(int index){
|
|
if(index < enableIndex.value && enableIndex.value >= 0){
|
|
return;
|
|
}
|
|
activePay.value = index;
|
|
canApply.value = false;
|
|
int hours = roseList[activePay.value].liveDurationHours!;
|
|
int rose = roseList[activePay.value].liveConsumptionAmount!;
|
|
if(hours > 0 && consumption.value.liveDurationMins! >= 60 * hours){
|
|
if(rose <= 0){
|
|
canApply.value = true;
|
|
} else if(consumption.value.liveConsumptionAmount! >= rose){
|
|
canApply.value = true;
|
|
}
|
|
}
|
|
|
|
button.value = canApply.value ? '立即申请' : '条件不满足';
|
|
// 实习红娘
|
|
if(roseList[activePay.value].type == 1){
|
|
revenue.value = [
|
|
{'icon': '1', 'desc': '礼物收益范围15%-30%,嘉宾消费的分成3%;'},
|
|
{'icon': '2', 'desc': '每天前5人连麦的礼物收益15%,第6-10人连麦的礼物收益20%,第11-15人连麦的礼物收益25%,第16人以上连麦的礼物收益30%;'},
|
|
{'icon': '3', 'desc': '红娘推荐的嘉宾成为红娘,赚取入驻费的20%分成;'},
|
|
{'icon': '4', 'desc': '新徒弟首月收益的10%(平台奖励)'},
|
|
];
|
|
} else if(roseList[activePay.value].type == 2){
|
|
revenue.value = [
|
|
{'icon': '1', 'desc': '礼物收益范围30%-40%,嘉宾消费的分成6%;'},
|
|
{'icon': '2', 'desc': '每天前5人连麦的礼物收益30%,第6-10人连麦的礼物收益35%,第11人以上连麦的礼物收益40%;'},
|
|
{'icon': '3', 'desc': '红娘推荐的嘉宾成为红娘,赚取入驻费的20%分成;'},
|
|
{'icon': '4', 'desc': '新徒弟首月收益的10%(平台奖励)'},
|
|
];
|
|
} else if(roseList[activePay.value].type == 3){
|
|
revenue.value = [
|
|
{'icon': '1', 'desc': '礼物收益范围40%,嘉宾消费的分成10%;'},
|
|
// {'icon': '2', 'desc': '每天前5人连麦的礼物收益15%,第6-10人连麦的礼物收益20%,第11-15人连麦的礼物收益25%,第16人以上连麦的礼物收益30%;'},
|
|
{'icon': '3', 'desc': '红娘推荐的嘉宾成为红娘,赚取入驻费的20%分成;'},
|
|
{'icon': '4', 'desc': '新徒弟首月收益的10%(平台奖励)'},
|
|
];
|
|
}
|
|
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
// WidgetsBinding.instance.removeObserver(this);
|
|
super.onClose();
|
|
}
|
|
|
|
initDataList() async {
|
|
try{
|
|
final result = await _userApi.getMatchmakerRequirement();
|
|
if (result.data.isSuccess && result.data.data != null) {
|
|
roseList.value = result.data.data!;
|
|
}
|
|
final response = await _userApi.getChatStaticsInfo();
|
|
if (response.data.isSuccess && response.data.data != null) {
|
|
consumption.value = response.data.data!;
|
|
if(roseList[activePay.value].liveDurationHours != null){
|
|
int hours = roseList[activePay.value].liveDurationHours!;
|
|
int rose = roseList[activePay.value].liveConsumptionAmount!;
|
|
if(hours > 0 && consumption.value.liveDurationMins! >= 60 * hours){
|
|
if(rose <= 0){
|
|
canApply.value = true;
|
|
} else if(consumption.value.liveConsumptionAmount! >= rose){
|
|
canApply.value = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(matchmakerFlag.value){
|
|
final index = roseList.indexWhere((item) => item.type == GlobalData().userData!.matchmakerType!);
|
|
enableIndex.value = index >= 0 ? index : 0;
|
|
changePayActive(enableIndex.value);
|
|
} else {
|
|
changePayActive(0);
|
|
}
|
|
} catch (e) {
|
|
print('spread: $e');
|
|
}
|
|
}
|
|
|
|
submitOrder() async {
|
|
if(!canApply.value){
|
|
return;
|
|
}
|
|
try {
|
|
final response = await _userApi.applyLiveMatchmaker({
|
|
"behavior": GlobalData().userData!.matchmakerFlag! ? 2 : 1,
|
|
"type": roseList[activePay.value].type
|
|
});
|
|
if (response.data.isSuccess) {
|
|
SmartDialog.showToast('申请成功,请等待审核');
|
|
Get.back();
|
|
}
|
|
} catch (e) {
|
|
SmartDialog.showToast('申请失败');
|
|
}
|
|
}
|
|
|
|
}
|