import 'package:dio/dio.dart';
import 'package:farmer_client/utils/Request.dart';
import 'package:fluttertoast/fluttertoast.dart';


Future getSMSCaptch(String phone) async {
  return request('/sms-captcha', options: Options(method: 'POST'), queryParameters: { 'phone': phone }).then((value) {
    Fluttertoast.showToast(
        msg: '验证码发送成功!'
    );
  }).catchError((error) {

    Fluttertoast.showToast(
      msg: error.error['message']
    );
  });
}

//登陆
Future userLogin(String userName,String password) async {
  return request('/login', options: Options(method: 'POST'),
    data: { 'userName': userName, 'password': password},).catchError((error) =>
  { Fluttertoast.showToast(
      msg: error.error['message']
  ),});
}

Future getCurrent() async {
  return request('/person/current');
}