Commit a423aad768f5cf068c4282a36b5484d2c4e3e64f
1 parent
b0778384
用户反馈添加字符输入数量显示,添加用户反馈接口,接口联调
Showing
3 changed files
with
77 additions
and
17 deletions
lib/common/request/apis.dart
@@ -107,4 +107,7 @@ class Apis { | @@ -107,4 +107,7 @@ class Apis { | ||
107 | /// 获取微信支付token | 107 | /// 获取微信支付token |
108 | static const String getWxPayToken = 'pay/wxPay/token'; | 108 | static const String getWxPayToken = 'pay/wxPay/token'; |
109 | 109 | ||
110 | + /// 用户反馈 | ||
111 | + static const String feedBack = 'student/feedback'; | ||
112 | + | ||
110 | } | 113 | } |
lib/common/request/dao/user_dao.dart
@@ -113,4 +113,10 @@ class UserDao { | @@ -113,4 +113,10 @@ class UserDao { | ||
113 | } | 113 | } |
114 | return await requestClient.put(Apis.setUserInfo, data: data); | 114 | return await requestClient.put(Apis.setUserInfo, data: data); |
115 | } | 115 | } |
116 | + | ||
117 | + /// 用户反馈 | ||
118 | + static Future feedBack(String content, String deviceModel, String osType, String osVersion) async { | ||
119 | + final params = {'content': content, 'deviceModel': deviceModel, 'osType': osType, "osVersion": osVersion}; | ||
120 | + return await requestClient.post(Apis.feedBack, data: params); | ||
121 | + } | ||
116 | } | 122 | } |
lib/pages/user/setting/reback_page.dart
1 | +import 'dart:async'; | ||
2 | +import 'dart:io'; | ||
3 | +import 'dart:math'; | ||
4 | + | ||
5 | +import 'package:device_info_plus/device_info_plus.dart'; | ||
1 | import 'package:flutter/material.dart'; | 6 | import 'package:flutter/material.dart'; |
7 | +import 'package:flutter/services.dart'; | ||
8 | +import 'package:flutter_easyloading/flutter_easyloading.dart'; | ||
2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 9 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
10 | +import 'package:wow_english/common/core/app_config_helper.dart'; | ||
3 | import 'package:wow_english/common/extension/string_extension.dart'; | 11 | import 'package:wow_english/common/extension/string_extension.dart'; |
12 | +import 'package:wow_english/route/route.dart'; | ||
4 | import 'package:wow_english/utils/color_util.dart'; | 13 | import 'package:wow_english/utils/color_util.dart'; |
5 | 14 | ||
6 | -import '../../../common/widgets/we_app_bar.dart'; | 15 | +import 'package:wow_english/common/request/dao/user_dao.dart'; |
16 | +import 'package:wow_english/common/widgets/we_app_bar.dart'; | ||
17 | +import 'package:wow_english/utils/toast_util.dart'; | ||
7 | 18 | ||
8 | class ReBackPage extends StatefulWidget { | 19 | class ReBackPage extends StatefulWidget { |
9 | const ReBackPage({super.key}); | 20 | const ReBackPage({super.key}); |
@@ -16,11 +27,15 @@ class ReBackPage extends StatefulWidget { | @@ -16,11 +27,15 @@ class ReBackPage extends StatefulWidget { | ||
16 | 27 | ||
17 | class ReBackPageState extends State<ReBackPage> { | 28 | class ReBackPageState extends State<ReBackPage> { |
18 | late bool _canEnsure; | 29 | late bool _canEnsure; |
30 | + int _textCount = 0; | ||
31 | + String _textInputStr = ""; | ||
19 | 32 | ||
20 | @override | 33 | @override |
21 | void initState() { | 34 | void initState() { |
22 | super.initState(); | 35 | super.initState(); |
23 | _canEnsure = false; | 36 | _canEnsure = false; |
37 | + _textCount = 0; | ||
38 | + _textInputStr = ""; | ||
24 | } | 39 | } |
25 | 40 | ||
26 | @override | 41 | @override |
@@ -53,7 +68,7 @@ class ReBackPageState extends State<ReBackPage> { | @@ -53,7 +68,7 @@ class ReBackPageState extends State<ReBackPage> { | ||
53 | fontSize: 19.sp, color: HexColor('#333333')), | 68 | fontSize: 19.sp, color: HexColor('#333333')), |
54 | ), | 69 | ), |
55 | Text( | 70 | Text( |
56 | - '48/500', | 71 | + '$_textCount/500', |
57 | textAlign: TextAlign.right, | 72 | textAlign: TextAlign.right, |
58 | style: TextStyle( | 73 | style: TextStyle( |
59 | fontSize: 19.sp, color: HexColor('#333333')), | 74 | fontSize: 19.sp, color: HexColor('#333333')), |
@@ -72,6 +87,17 @@ class ReBackPageState extends State<ReBackPage> { | @@ -72,6 +87,17 @@ class ReBackPageState extends State<ReBackPage> { | ||
72 | vertical: 10, horizontal: 16), | 87 | vertical: 10, horizontal: 16), |
73 | // 设置对称内边距 | 88 | // 设置对称内边距 |
74 | child: TextField( | 89 | child: TextField( |
90 | + inputFormatters: [ | ||
91 | + LengthLimitingTextInputFormatter(500, maxLengthEnforcement: MaxLengthEnforcement.truncateAfterCompositionEnds), | ||
92 | + ], | ||
93 | + onChanged: (String value) { | ||
94 | + setState(() { | ||
95 | + _textInputStr = value; | ||
96 | + _textCount = min(value.length, 500); | ||
97 | + _canEnsure = value.length >= 10; | ||
98 | + }); | ||
99 | + }, | ||
100 | + maxLines: null, | ||
75 | textInputAction: TextInputAction.done, | 101 | textInputAction: TextInputAction.done, |
76 | decoration: InputDecoration( | 102 | decoration: InputDecoration( |
77 | border: InputBorder.none, | 103 | border: InputBorder.none, |
@@ -83,21 +109,26 @@ class ReBackPageState extends State<ReBackPage> { | @@ -83,21 +109,26 @@ class ReBackPageState extends State<ReBackPage> { | ||
83 | ), | 109 | ), |
84 | ), | 110 | ), |
85 | 4.5.verticalSpace, | 111 | 4.5.verticalSpace, |
86 | - Container( | ||
87 | - decoration: BoxDecoration( | ||
88 | - image: DecorationImage( | ||
89 | - fit: BoxFit.fill, | ||
90 | - image: AssetImage(_canEnsure | ||
91 | - ? 're_button'.assetPng | ||
92 | - : 're_button_dis'.assetPng))), | ||
93 | - alignment: Alignment.center, | ||
94 | - width: 91.w, | ||
95 | - height: 45.h, | ||
96 | - child: Text( | ||
97 | - '提交', | ||
98 | - textAlign: TextAlign.center, | ||
99 | - style: | ||
100 | - TextStyle(color: Colors.white, fontSize: 17.sp), | 112 | + GestureDetector( |
113 | + onTap: () { | ||
114 | + userFeedBack(_textInputStr); | ||
115 | + }, | ||
116 | + child: Container( | ||
117 | + decoration: BoxDecoration( | ||
118 | + image: DecorationImage( | ||
119 | + fit: BoxFit.fill, | ||
120 | + image: AssetImage(_canEnsure | ||
121 | + ? 're_button'.assetPng | ||
122 | + : 're_button_dis'.assetPng))), | ||
123 | + alignment: Alignment.center, | ||
124 | + width: 91.w, | ||
125 | + height: 45.h, | ||
126 | + child: Text( | ||
127 | + '提交', | ||
128 | + textAlign: TextAlign.center, | ||
129 | + style: | ||
130 | + TextStyle(color: Colors.white, fontSize: 17.sp), | ||
131 | + ), | ||
101 | ), | 132 | ), |
102 | ) | 133 | ) |
103 | ], | 134 | ], |
@@ -109,4 +140,24 @@ class ReBackPageState extends State<ReBackPage> { | @@ -109,4 +140,24 @@ class ReBackPageState extends State<ReBackPage> { | ||
109 | ), | 140 | ), |
110 | )); | 141 | )); |
111 | } | 142 | } |
143 | + | ||
144 | + Future<void> userFeedBack(content) async { | ||
145 | + String deviceModel = ""; | ||
146 | + String osType = AppConfigHelper.isIosPlatform() ? "ios" : "android"; | ||
147 | + String osVersion = ""; | ||
148 | + if (AppConfigHelper.isIosPlatform()) { | ||
149 | + final iosDeviceInfo = await DeviceInfoPlugin().iosInfo; | ||
150 | + osVersion = iosDeviceInfo.systemVersion; | ||
151 | + deviceModel = iosDeviceInfo.model; | ||
152 | + } else { | ||
153 | + final androidInfo = await DeviceInfoPlugin().androidInfo; | ||
154 | + osVersion = androidInfo.version.release.toString(); | ||
155 | + deviceModel = androidInfo.manufacturer; | ||
156 | + } | ||
157 | + EasyLoading.show(); | ||
158 | + await UserDao.feedBack(content, deviceModel, osType, osVersion); | ||
159 | + EasyLoading.dismiss(); | ||
160 | + showToast('提交成功'); | ||
161 | + popPage(); | ||
162 | + } | ||
112 | } | 163 | } |