part of user_gender;

class UserGenderController extends GetxController {
  final UserInfoModel userInfo;

  UserGenderController(this.userInfo);

  /// 修改用用户信息
  void _changeInfo(num sex) async {
    final result = await MineAPI.changeInfo(sex: sex);
    if (result) {
      Toast.show('修改成功');
      userInfo.sex = sex ;
      Map<String,dynamic> map = jsonDecode(StorageService.to.getString(kLocalUserInfo));
      if (map.keys.contains('sex')){
        map['sex'] = sex;
        await StorageService.to.setString(kLocalUserInfo, jsonEncode(map));
      }
      update();
    }
  }
}
