YSFeedback.dart 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:ysairplane/base/YSBase.dart';
  4. import 'package:ysairplane/tools/YSNetWorking.dart';
  5. class YSFeedback extends StatefulWidget {
  6. @override
  7. _YSFeedbackState createState() => _YSFeedbackState();
  8. }
  9. class _YSFeedbackState extends State<YSFeedback> {
  10. List _types = [];
  11. Map _type;
  12. TextEditingController _content = TextEditingController();
  13. @override
  14. void initState() {
  15. Future.delayed(Duration(seconds: 0)).then((value){
  16. _getTypeData();
  17. });
  18. super.initState();
  19. }
  20. @override
  21. Widget build(BuildContext context) {
  22. return YSBase(
  23. ystitle: '意见反馈',
  24. yschild: Column(
  25. children: [
  26. Divider(height: 5,thickness: 5,color: Color(0xFFF5F6F8),),
  27. Container(
  28. height: 50,
  29. padding: EdgeInsets.only(left: 15,right: 15),
  30. child: Row(
  31. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  32. children: [
  33. Text('意见反馈类型',style: TextStyle(fontSize: 16,color: Color(0xFF000000)),),
  34. if(_types.length>0)DropdownButton(
  35. value: _type,
  36. items: [
  37. for(int i=0;i<_types.length;i++)DropdownMenuItem(child: Text('${_types[i]['name']}'),value: _types[i],),
  38. ],
  39. onChanged: (value){
  40. setState(() {
  41. _type = value;
  42. });
  43. },
  44. underline: Container(),
  45. icon: Icon(Icons.keyboard_arrow_down,size: 20,color: Color(0xFF999999),),
  46. style: TextStyle(fontSize: 15,color: Color(0xFF999999)),
  47. )
  48. ],
  49. ),
  50. ),
  51. Divider(height: 0.5,thickness: 0.5,color: Color(0xFFF5F6F8),),
  52. Container(
  53. margin: EdgeInsets.only(top: 15,bottom: 15),
  54. width: MediaQuery.of(context).size.width-30,
  55. child: Text('留言内容',style: TextStyle(fontSize: 14,color: Color(0xFF999999)),),
  56. ),
  57. Container(
  58. width: MediaQuery.of(context).size.width-30,
  59. padding: EdgeInsets.all(5),
  60. height: 200,
  61. color: Color(0xFFF5F5F7),
  62. child: CupertinoTextField(
  63. style: TextStyle(fontSize: 14,color: Color(0xFF000000)),
  64. decoration: BoxDecoration(),
  65. controller: _content,
  66. maxLines: 100,
  67. placeholder: '请输入反馈内容',
  68. ),
  69. ),
  70. GestureDetector(
  71. onTap: (){
  72. _postFeedbackData();
  73. },
  74. child: Container(
  75. width: MediaQuery.of(context).size.width-30,
  76. margin: EdgeInsets.only(top: 40),
  77. height: 40,
  78. alignment: Alignment.center,
  79. decoration: BoxDecoration(
  80. color: Color(0xFF0079FF),
  81. borderRadius: BorderRadius.all(Radius.circular(5))
  82. ),
  83. child: Text('提交',style: TextStyle(fontSize: 17,color: Colors.white,fontWeight: FontWeight.bold),),
  84. ),
  85. )
  86. ],
  87. ),
  88. );
  89. }
  90. _getTypeData() async{
  91. FocusScope.of(context).unfocus();
  92. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/feedback/type',parameter: {},
  93. isLoading: false,isToken: true,refresh: (){_getTypeData();});
  94. if(dict!=null){
  95. setState(() {
  96. _types = dict['data'];
  97. _type = _types[0];
  98. });
  99. }
  100. }
  101. _postFeedbackData() async{
  102. FocusScope.of(context).unfocus();
  103. if(_content.text.isEmpty){
  104. ysFlutterToast(context, '请输入反馈内容');
  105. return;
  106. }
  107. Map dict = await ysRequestHttp(context,type: requestType.post,api: '/app/applets/feedback/submit',parameter: {'categoryId':_type['id'],'content':_content.text},
  108. isLoading: false,isToken: true,refresh: (){_getTypeData();});
  109. if(dict!=null){
  110. Navigator.pop(context);
  111. }
  112. }
  113. }