import 'Network/HttpManager.dart';
import 'Network/BaseHttpModel.dart';
import 'UserModel.dart';

/// 所有接口类
class LoginApi {
  ///示例请求
  static loginRequest(Map<String, dynamic> param, OnResult onResult) {
    return HttpManager.getInstance().request('auth/oauth/token', parameters: param, onResult: (data,errorMsg){
      UserModel userModel = UserModel.fromJson(data.data);
      UserModel.saveModel(userModel);
      print(UserModel.getModel().token);
      if(onResult != null){
        onResult(data, errorMsg);
      }
    });
  }

  ///上传头像
  static uploadAvatarRequest(String avatarPath, OnResult onResult) {
    return HttpManager.getInstance().request('file/upload', parameters: null,method: "POST", imagePath: avatarPath,onResult: (data,errorMsg){
      if(onResult != null){
        onResult(data, errorMsg);
      }
    });
  }
}
