user.dart 856B

1234567891011121314151617181920212223242526272829303132
  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. }