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

import 'showError.dart';

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

//登录
Future userLogin(String userName, String password) async {
  return request(
    '/login',
    options: Options(method: 'POST'),
    data: {'userName': userName, 'password': password},
  ).catchError(showError);
}

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

/**
 * 修改个人信息
 * @param {*}
 * @returns
 */
Future updateInfo(String id, userdata) async {
  return request('/person/$id', options: Options(method: 'PUT'), data: userdata)
      .catchError(showError);
}