import 'package:dating_touchme_app/controller/global.dart'; import 'package:dating_touchme_app/generated/assets.dart'; import 'package:dating_touchme_app/model/mine/education_data.dart'; import 'package:dating_touchme_app/model/mine/occupation_data.dart'; import 'package:dating_touchme_app/model/mine/user_data.dart'; import 'package:dating_touchme_app/network/user_api.dart'; import 'package:dating_touchme_app/pages/mine/auth_center_page.dart'; import 'package:dating_touchme_app/pages/mine/my_wallet_page.dart'; import 'package:dating_touchme_app/pages/mine/rose_page.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; class EditInfoController extends GetxController { late UserApi _userApi; final menuActive = 1.obs; List imgList = [ "https://fastly.picsum.photos/id/64/800/800.jpg?hmac=NBZ4_-vqzD6p25oCeaW0H5vH-ql9zzei-SqJNeUo1QU", "https://fastly.picsum.photos/id/985/800/800.jpg?hmac=DfRt99HFbMJ96DlN-poOhruWYRsexESE94ilLC3g1rU", "https://fastly.picsum.photos/id/703/800/800.jpg?hmac=-bRTkPxnsiQ5kCo2tfXj6tFrXMD7YnVx7bQ0STno3Tg" ]; final nowSelect = 0.obs; List tagList = [ "北京", "160cm", "想要甜甜的恋爱", "本科", "朋友圈摄影师", "英雄联盟", "流放之路", "CF", "DNA", "堡垒之夜", "SCP" ]; final userData = GlobalData().userData.obs; String height = ''; final TextEditingController heightController = TextEditingController(); final educationList = [].obs; final incomeList = [].obs; final maritalList = [].obs; final propertyList = [].obs; final occupationList = [].obs; final occupationShowData = {}.obs; @override void onInit() { super.onInit(); _userApi = Get.find(); getEducationList(); getIncomeList(); getMaritalList(); getPropertyList(); getOccupationList(); } getEducationList() async { try { final response = await _userApi.getEducationList({}); if (response.data.isSuccess && response.data.data != null) { final data = response.data.data; educationList.clear(); educationList.addAll(data?.toList() ?? []); } else { // 响应失败,抛出异常 throw Exception(response.data.message ?? '获取数据失败'); } } catch(e){ print('学历列表获取失败: $e'); SmartDialog.showToast('学历列表获取失败'); rethrow; } } getIncomeList() async { try { final response = await _userApi.getIncomeList({}); if (response.data.isSuccess && response.data.data != null) { final data = response.data.data; incomeList.clear(); incomeList.addAll(data?.toList() ?? []); } else { // 响应失败,抛出异常 throw Exception(response.data.message ?? '获取数据失败'); } } catch(e){ print('收入列表获取失败: $e'); SmartDialog.showToast('收入列表获取失败'); rethrow; } } getMaritalList() async { try { final response = await _userApi.getMaritalStatusList({}); if (response.data.isSuccess && response.data.data != null) { final data = response.data.data; maritalList.clear(); maritalList.addAll(data?.toList() ?? []); } else { // 响应失败,抛出异常 throw Exception(response.data.message ?? '获取数据失败'); } } catch(e){ print('收入列表获取失败: $e'); SmartDialog.showToast('收入列表获取失败'); rethrow; } } getPropertyList() async { try { final response = await _userApi.getPropertyList({}); if (response.data.isSuccess && response.data.data != null) { final data = response.data.data; propertyList.clear(); propertyList.addAll(data?.toList() ?? []); } else { // 响应失败,抛出异常 throw Exception(response.data.message ?? '获取数据失败'); } } catch(e){ print('收入列表获取失败: $e'); SmartDialog.showToast('收入列表获取失败'); rethrow; } } getOccupationList() async { try { final response = await _userApi.getOccupationList({}); if (response.data.isSuccess && response.data.data != null) { final data = response.data.data; occupationList.clear(); occupationList.addAll(data?.toList() ?? []); for(int i = 0; i < occupationList.length; i++){ occupationShowData[occupationList[i].industry] = occupationList[i].occupationList?.map((e){ return e.occupation; }).toList(); } print(occupationShowData); } else { // 响应失败,抛出异常 throw Exception(response.data.message ?? '获取数据失败'); } } catch(e){ print('收入列表获取失败: $e'); SmartDialog.showToast('收入列表获取失败'); rethrow; } } }