user.dart 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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', options: Options(method: 'POST'), queryParameters: { 'phone': phone }).then((value) {
  6. Fluttertoast.showToast(
  7. msg: '验证码发送成功!'
  8. );
  9. }).catchError((error) {
  10. Fluttertoast.showToast(
  11. msg: error.error['message']
  12. );
  13. });
  14. }
  15. //登陆
  16. Future userLogin(String userName,String password) async {
  17. return request('/login', options: Options(method: 'POST'),
  18. data: { 'userName': userName, 'password': password},).catchError((error) =>
  19. { Fluttertoast.showToast(
  20. msg: error.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).catchError((error) =>
  33. { Fluttertoast.showToast(
  34. msg: error.error['message']
  35. ),});
  36. }