import 'package:domain/constants/api_constants.dart';
import 'package:get/get.dart';
import 'package:plugin_basic/constants/app_constant.dart';
import 'package:plugin_basic/service/app_config_service.dart';
import 'package:plugin_basic/service/http_provider_injection.dart';
import 'package:plugin_platform/engine/sp/sp_util.dart';
import 'package:shared/utils/log_utils.dart';

class SelectCountryController extends GetxController {
  //设置下一步
  void setupNext() {
    int country = ConfigService.to.selectCountry.value;
    SPUtil.putInt(AppConstant.storageSelectedCountry, country);

    String baseUrl;
    if (country == 1) {
      //新加坡
      baseUrl = ApiConstants.sgBaseUrl;
    } else if (country == 2) {
      //英国
      baseUrl = ApiConstants.ukBaseUrl;
    } else if (country == 3) {
      //马来西亚
      baseUrl = ApiConstants.msBaseUrl;
    } else if (country == 4) {
      //荷兰
      baseUrl = ApiConstants.nlBaseUrl;
    } else if (country == 5) {
      //泰国
      baseUrl = ApiConstants.thBaseUrl;
    } else {
      //默认是越南
      baseUrl = ApiConstants.vnBaseUrl;
    }

    Log.d("当前选择的国家：$country 当前要切换的域名为：$baseUrl");
    HttpProviderInjection.switchBaseUrl(baseUrl);

    Get.back();
  }
}
