part of user_info;

class UserInfoController extends GetxController {
  final UserInfoModel userInfo;
  UserInfoController(this.userInfo);

  /// 上传头像
  void upload({
    required String path
  }) async {
     // String result  = await CommonAPI.upload(path:path,fileTypes: 'user');
     OssTool tool = OssTool('zxts-user-file');
     print('------path--------------------------$path');
     final response = await tool.putObjectFile(path);
     print('------response--------------------------${response.realUri}');
     _changeInfo(response.realUri.toString());
  }

  /// 修改用用户信息
  void _changeInfo(String img) async {
    final result = await MineAPI.changeInfo(headImg: img);
    if(result){
      Toast.show('修改成功');
      userInfo.headImg = img;
      update();
    }
  }


}