12345678910111213141516171819202122232425262728293031323334353637383940
  1. import 'package:dio/dio.dart';
  2. import 'package:farmer_client/utils/Request.dart';
  3. import 'package:fluttertoast/fluttertoast.dart';
  4. Future getSMSCaptch(String phone) async {
  5. return request('/sms-captcha',
  6. options: Options(method: 'POST'),
  7. queryParameters: {'phone': phone}).then((value) {
  8. Fluttertoast.showToast(msg: '验证码发送成功!');
  9. }).catchError((error) {
  10. Fluttertoast.showToast(msg: error.error['message']);
  11. });
  12. }
  13. //登录
  14. Future userLogin(String userName, String password) async {
  15. return request(
  16. '/login',
  17. options: Options(method: 'POST'),
  18. data: {'userName': userName, 'password': password},
  19. ).catchError((error) => {
  20. Fluttertoast.showToast(msg: error['message']),
  21. });
  22. }
  23. Future getCurrent() async {
  24. return request('/person/current');
  25. }
  26. /**
  27. * 修改个人信息
  28. * @param {*}
  29. * @returns
  30. */
  31. Future updateInfo(String id, userdata) async {
  32. return request('/person/$id', options: Options(method: 'PUT'), data: userdata)
  33. .catchError((error) => {
  34. Fluttertoast.showToast(msg: error.error['message']),
  35. });
  36. }