diff --git a/lib/common/request/apis.dart b/lib/common/request/apis.dart index 5682d84..986c202 100644 --- a/lib/common/request/apis.dart +++ b/lib/common/request/apis.dart @@ -107,4 +107,7 @@ class Apis { /// 获取微信支付token static const String getWxPayToken = 'pay/wxPay/token'; + /// 用户反馈 + static const String feedBack = 'student/feedback'; + } diff --git a/lib/common/request/dao/user_dao.dart b/lib/common/request/dao/user_dao.dart index 0cacd63..cda84ed 100644 --- a/lib/common/request/dao/user_dao.dart +++ b/lib/common/request/dao/user_dao.dart @@ -113,4 +113,10 @@ class UserDao { } return await requestClient.put(Apis.setUserInfo, data: data); } + + /// 用户反馈 + static Future feedBack(String content, String deviceModel, String osType, String osVersion) async { + final params = {'content': content, 'deviceModel': deviceModel, 'osType': osType, "osVersion": osVersion}; + return await requestClient.post(Apis.feedBack, data: params); + } } diff --git a/lib/pages/user/setting/reback_page.dart b/lib/pages/user/setting/reback_page.dart index 33edfe0..e651962 100644 --- a/lib/pages/user/setting/reback_page.dart +++ b/lib/pages/user/setting/reback_page.dart @@ -1,9 +1,20 @@ +import 'dart:async'; +import 'dart:io'; +import 'dart:math'; + +import 'package:device_info_plus/device_info_plus.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:wow_english/common/core/app_config_helper.dart'; import 'package:wow_english/common/extension/string_extension.dart'; +import 'package:wow_english/route/route.dart'; import 'package:wow_english/utils/color_util.dart'; -import '../../../common/widgets/we_app_bar.dart'; +import 'package:wow_english/common/request/dao/user_dao.dart'; +import 'package:wow_english/common/widgets/we_app_bar.dart'; +import 'package:wow_english/utils/toast_util.dart'; class ReBackPage extends StatefulWidget { const ReBackPage({super.key}); @@ -16,11 +27,15 @@ class ReBackPage extends StatefulWidget { class ReBackPageState extends State { late bool _canEnsure; + int _textCount = 0; + String _textInputStr = ""; @override void initState() { super.initState(); _canEnsure = false; + _textCount = 0; + _textInputStr = ""; } @override @@ -53,7 +68,7 @@ class ReBackPageState extends State { fontSize: 19.sp, color: HexColor('#333333')), ), Text( - '48/500', + '$_textCount/500', textAlign: TextAlign.right, style: TextStyle( fontSize: 19.sp, color: HexColor('#333333')), @@ -72,6 +87,17 @@ class ReBackPageState extends State { vertical: 10, horizontal: 16), // 设置对称内边距 child: TextField( + inputFormatters: [ + LengthLimitingTextInputFormatter(500, maxLengthEnforcement: MaxLengthEnforcement.truncateAfterCompositionEnds), + ], + onChanged: (String value) { + setState(() { + _textInputStr = value; + _textCount = min(value.length, 500); + _canEnsure = value.length >= 10; + }); + }, + maxLines: null, textInputAction: TextInputAction.done, decoration: InputDecoration( border: InputBorder.none, @@ -83,21 +109,26 @@ class ReBackPageState extends State { ), ), 4.5.verticalSpace, - Container( - decoration: BoxDecoration( - image: DecorationImage( - fit: BoxFit.fill, - image: AssetImage(_canEnsure - ? 're_button'.assetPng - : 're_button_dis'.assetPng))), - alignment: Alignment.center, - width: 91.w, - height: 45.h, - child: Text( - '提交', - textAlign: TextAlign.center, - style: - TextStyle(color: Colors.white, fontSize: 17.sp), + GestureDetector( + onTap: () { + userFeedBack(_textInputStr); + }, + child: Container( + decoration: BoxDecoration( + image: DecorationImage( + fit: BoxFit.fill, + image: AssetImage(_canEnsure + ? 're_button'.assetPng + : 're_button_dis'.assetPng))), + alignment: Alignment.center, + width: 91.w, + height: 45.h, + child: Text( + '提交', + textAlign: TextAlign.center, + style: + TextStyle(color: Colors.white, fontSize: 17.sp), + ), ), ) ], @@ -109,4 +140,24 @@ class ReBackPageState extends State { ), )); } + + Future userFeedBack(content) async { + String deviceModel = ""; + String osType = AppConfigHelper.isIosPlatform() ? "ios" : "android"; + String osVersion = ""; + if (AppConfigHelper.isIosPlatform()) { + final iosDeviceInfo = await DeviceInfoPlugin().iosInfo; + osVersion = iosDeviceInfo.systemVersion; + deviceModel = iosDeviceInfo.model; + } else { + final androidInfo = await DeviceInfoPlugin().androidInfo; + osVersion = androidInfo.version.release.toString(); + deviceModel = androidInfo.manufacturer; + } + EasyLoading.show(); + await UserDao.feedBack(content, deviceModel, osType, osVersion); + EasyLoading.dismiss(); + showToast('提交成功'); + popPage(); + } }