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.
 
 
 
 
 

84 lines
2.7 KiB

import 'package:dating_touchme_app/model/mine/rose_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 SpreadController extends GetxController {
// UserApi实例
late UserApi _userApi;
final roseList = <RoseData>[].obs;
final roseNum = 0.obs;
final payChecked = true.obs;
final activePay = 0.obs;
final Fluwx fluwx = Fluwx();
changePayActive(int index){
activePay.value = index;
}
List<Map> list2 = [
{'title': '邀请注册', 'unit': '10%', 'desc': '分佣', 'enable': 1, 'value': 111, 'icon': 'icon-right1'},
{'title': '发布悬赏', 'unit': '10%', 'desc': '分佣', 'enable': 1, 'value': 112, 'icon': 'icon-right2'},
{'title': '匹配悬赏', 'unit': '10%', 'desc': '分佣', 'enable': 0, 'value': 113, 'icon': 'icon-right41'},
{'title': '推荐红娘', 'unit': '10%', 'desc': '分佣', 'enable': 1, 'value': 114, 'icon': 'icon-right3'},
{'title': '免费升级', 'desc': '门店合伙人', 'enable': 0, 'value': 0, 'icon': 'icon-right51'},
{'title': '资源共享', 'desc': '所有资料', 'enable': 1, 'value': 0, 'icon': 'icon-right6'},
{'title': '业绩奖励', 'unit': '5%', 'desc': '奖励', 'enable': 1, 'value': 0, 'icon': 'icon-right71'},
{'title': '次年续签', 'unit': '90%', 'desc': '减免', 'enable': 1, 'value': 0, 'icon': 'icon-right8'}
].obs;
@override
void onInit() {
super.onInit();
_userApi = Get.find<UserApi>();
getRoseList();
}
getRoseList() async {
try{
final response = await _userApi.getMatchmakerFee();
if (response.data.isSuccess && response.data.data != null) {
final data = response.data.data!.records;
roseList.addAll(data.toList());
}
print('rose>>>${roseList.length}');
} catch (e) {
print('玫瑰列表获取失败: $e');
rethrow;
}
}
submitOrder() async {
try {
final response = await _userApi.submitOrder({
"productSpecId": roseList[activePay.value].productSpecId
});
if (response.data.isSuccess && response.data.data != null) {
final data = response.data.data;
fluwx.open(target: MiniProgram(
username: 'gh_9ea8d46add6f',
path:"pages/index/index?amount=${roseList[activePay.value].unitSellingPrice}&paymentOrderId=${data!.paymentOrderId}&url=match-fee"
));
SmartDialog.showToast('开始支付');
} else {
// 响应失败,抛出异常
throw Exception(response.data.message ?? '获取数据失败');
}
} catch (e) {
print('玫瑰列表获取失败: $e');
SmartDialog.showToast('下单失败');
rethrow;
}
}
}