feed_back_model.dart 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import 'package:flutter/material.dart';
  2. import 'package:fluttertoast/fluttertoast.dart';
  3. import 'package:sport/bean/feed_back.dart';
  4. import 'package:sport/services/api/inject_api.dart';
  5. import 'package:sport/utils/toast.dart';
  6. class FeedBackModel extends ChangeNotifier with InjectLoginApi {
  7. FeedTypeInfo data;
  8. FeedBackInfo feedBackInfo;
  9. Future getFeedBackTypes() async {
  10. FeedTypeInfo _feedTypeInfo = await loginApi.getFeedBackTypes();
  11. if (_feedTypeInfo.code != 0) {
  12. // Fluttertoast.showToast(
  13. // msg: "${_feedTypeInfo.msg}",
  14. // toastLength: Toast.LENGTH_SHORT,
  15. // gravity: ToastGravity.CENTER,
  16. // backgroundColor: Colors.white,
  17. // textColor: Colors.black,
  18. // fontSize: 13.0);
  19. }
  20. data = _feedTypeInfo;
  21. notifyListeners();
  22. return _feedTypeInfo;
  23. }
  24. Future<FeedBackInfo> getFeedBackInfo(
  25. {int typeId, int groupId, int limit}) async {
  26. FeedBackInfo _feedBackInfo = await loginApi.getFeedBackChats(
  27. typeId: typeId, groupId: groupId, limit: limit);
  28. feedBackInfo = _feedBackInfo;
  29. notifyListeners();
  30. return _feedBackInfo;
  31. }
  32. Future postFeedback(int typeId, String content) async {
  33. var data = await loginApi.postFeedBack(typeId, content);
  34. print(data);
  35. if (data['code'] != 0) {
  36. ToastUtil.show(data.msg);
  37. // Fluttertoast.showToast(
  38. // msg: "${data.msg}",
  39. // toastLength: Toast.LENGTH_SHORT,
  40. // gravity: ToastGravity.CENTER,
  41. // backgroundColor: Colors.white,
  42. // textColor: Colors.black,
  43. // fontSize: 13.0);
  44. }else{
  45. ToastUtil.show("感谢你的建议,我们会第一时间解决");
  46. // Fluttertoast.showToast(
  47. // msg: "感谢你的建议,我们会第一时间解决",
  48. // toastLength: Toast.LENGTH_SHORT,
  49. // gravity: ToastGravity.CENTER,
  50. // backgroundColor: Colors.white,
  51. // textColor: Colors.black,
  52. // fontSize: 13.0);
  53. }
  54. notifyListeners();
  55. return data;
  56. }
  57. }