part of user_info;

class UserInfoController extends GetxController {
  final UserInfoModel userInfo;
  UserInfoController(this.userInfo);
// 时候展示底部视图
  bool showDetail = false;
  /// 上传头像
  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 show(){
    showDetail = !showDetail;
    update();
  }

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


}