user.dart 965B

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