From dafb40954a0ba972852aced1d39a19e579aa8450 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Thu, 30 May 2024 15:31:14 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E6=97=A0?= =?UTF-8?q?=E7=BD=91=E7=BB=9C=E4=B8=8B=E7=82=B9=E5=87=BB=E5=BC=80=E9=94=81?= =?UTF-8?q?=E4=BC=9A=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lockMain/xhj/lockMain_xhj_page.dart | 10 +- lib/network/api_provider.dart | 95 ++++++++++--------- lib/network/api_provider_base.dart | 8 +- 3 files changed, 59 insertions(+), 54 deletions(-) diff --git a/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart b/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart index c616b2f9..c9c5a493 100755 --- a/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart +++ b/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart @@ -45,7 +45,7 @@ class _StarLockMainXHJPageState extends State return Scaffold( backgroundColor: Colors.white, body: Stack( - children: [ + children: [ pageView( widget: StarLockMainPage( showAppBar: false, @@ -102,7 +102,7 @@ class _StarLockMainXHJPageState extends State child: SafeArea( top: false, child: Row( - children: [ + children: [ navigationBarItem(Icons.key, TranslationLoader.lanKeys!.device!.tr, logic, 0, () { logic.setIndex(0); @@ -142,8 +142,8 @@ class _StarLockMainXHJPageState extends State //底部按钮 Widget navigationBarItem(IconData icon, String text, LockMainXHJLogic logic, - int index, var onTop) { - bool check = logic.state.index == index; + int index, GestureTapCallback? onTop) { + final bool check = logic.state.index == index; return Expanded( child: GestureDetector( onTap: onTop, @@ -151,7 +151,7 @@ class _StarLockMainXHJPageState extends State color: Colors.transparent, child: Column( mainAxisSize: MainAxisSize.min, - children: [ + children: [ Padding( padding: EdgeInsets.only(bottom: 8.h), child: Icon( diff --git a/lib/network/api_provider.dart b/lib/network/api_provider.dart index 49d0a0aa..a162ddf7 100755 --- a/lib/network/api_provider.dart +++ b/lib/network/api_provider.dart @@ -11,7 +11,7 @@ class ApiProvider extends BaseProvider { jsonEncode({ 'countryCode': countryCode, 'account': account, - "channel": channel, + 'channel': channel, 'codeType': codeType, 'xWidth': xWidth, })); @@ -28,10 +28,10 @@ class ApiProvider extends BaseProvider { jsonEncode({ 'receiverType': receiverType, 'countryCode': countryCode, - "account": account, + 'account': account, 'password': password, 'verificationCode': verificationCode, - 'platId': "2", + 'platId': '2', })); // post( @@ -71,10 +71,10 @@ class ApiProvider extends BaseProvider { jsonEncode({ 'loginType': loginType, 'password': password, - "platId": "2", - 'uniqueid': "477E6814-289D-402A-9F49-F89A8BD05D63", + 'platId': '2', + 'uniqueid': '477E6814-289D-402A-9F49-F89A8BD05D63', 'countryCode': countryCode, - "username": username + 'username': username })); Future resetPassword( @@ -89,9 +89,9 @@ class ApiProvider extends BaseProvider { jsonEncode({ 'countryCode': countryCode, 'account': account, - "date": date, + 'date': date, 'newPassword': newPassword, - "uniqueid": uniqueid, + 'uniqueid': uniqueid, 'verificationCode': verificationCode, })); @@ -114,7 +114,7 @@ class ApiProvider extends BaseProvider { jsonEncode({ 'endDate': endDate, 'keyId': keyId, - "keyStatus": keyStatus, + 'keyStatus': keyStatus, 'lockId': lockId, 'pageNo': pageNo, 'pageSize': pageSize, @@ -178,13 +178,15 @@ class ApiProvider extends BaseProvider { bool isUnShowLoading, ) => post( - uploadElectricQuantityURL.toUrl, - jsonEncode({ - 'electricQuantity': electricQuantity, - 'electricQuantityStandby': electricQuantityStandby, - 'lockId': lockId, - }), - isUnShowLoading: isUnShowLoading); + uploadElectricQuantityURL.toUrl, + jsonEncode({ + 'electricQuantity': electricQuantity, + 'electricQuantityStandby': electricQuantityStandby, + 'lockId': lockId, + }), + isUnShowLoading: isUnShowLoading, + isShowErrMsg: false, + ); Future modifyKeyName( String keyId, @@ -300,9 +302,9 @@ class ApiProvider extends BaseProvider { jsonEncode({ 'lockId': lockId, 'lockEventType': lockEventType, - "pageNo": pageNo, + 'pageNo': pageNo, 'pageSize': pageSize, - "startDate": startDate, + 'startDate': startDate, 'endDate': endDate, })); @@ -317,11 +319,13 @@ class ApiProvider extends BaseProvider { // 查询锁记录最后时间 Future getLockRecordLastUploadDataTime(String lockId) => post( - getLockRecordLastUploadDataTimeURL.toUrl, - jsonEncode({ - 'lockId': lockId, - }), - isUnShowLoading: true); + getLockRecordLastUploadDataTimeURL.toUrl, + jsonEncode({ + 'lockId': lockId, + }), + isUnShowLoading: true, + isShowErrMsg: false, + ); // 获取手机联网token Future getLockNetToken(String lockId) => post( @@ -354,7 +358,7 @@ class ApiProvider extends BaseProvider { post( bindingBlueAdminURL.toUrl, jsonEncode({ - "lockAlias": lockAlias, + 'lockAlias': lockAlias, 'position': position, 'bluetooth': bluetooth, 'lockInfo': lockInfo, @@ -370,7 +374,7 @@ class ApiProvider extends BaseProvider { getLockInfoURL.toUrl, jsonEncode({ 'lastUpdateDate': lastUpdateDate, - "pageNo": pageNo, + 'pageNo': pageNo, })); // 获取锁信息列表 @@ -379,7 +383,7 @@ class ApiProvider extends BaseProvider { post( getStarLockInfoURL.toUrl, jsonEncode({ - "pageNo": pageNo, + 'pageNo': pageNo, 'pageSize': pageSize, }), isUnShowLoading: isUnShowLoading); @@ -529,8 +533,8 @@ class ApiProvider extends BaseProvider { 'isCoerced': isCoerced, 'hoursStart': hoursStart, 'hoursEnd': hoursEnd, - "keyboardPwdType": keyboardPwdType, - "pwdRight": pwdRight + 'keyboardPwdType': keyboardPwdType, + 'pwdRight': pwdRight })); Future clearOperationRecord(String lockId) => @@ -1283,11 +1287,11 @@ class ApiProvider extends BaseProvider { 'startTime': startTime, 'endTime': endTime, 'faceType': faceType, - "weekDay": weekDay, + 'weekDay': weekDay, 'faceName': faceName, 'addType': addType, - "isCoerced": isCoerced, - "faceRight": faceRight + 'isCoerced': isCoerced, + 'faceRight': faceRight })); // 删除人脸 @@ -1631,7 +1635,7 @@ class ApiProvider extends BaseProvider { jsonEncode({ 'countryCode': countryCode, 'account': account, - "channel": channel, + 'channel': channel, 'codeType': codeType, 'xWidth': xWidth, })); @@ -1679,9 +1683,9 @@ class ApiProvider extends BaseProvider { post( changePasswordURL.toUrl, jsonEncode({ - "date": date, + 'date': date, 'newPassword': newPassword, - "oldPassword": oldPassword, + 'oldPassword': oldPassword, })); //获取安全信息列表 @@ -1689,7 +1693,7 @@ class ApiProvider extends BaseProvider { post( getQuestionListURL.toUrl, jsonEncode({ - "operatorUid": operatorUid, + 'operatorUid': operatorUid, 'countryCode': countryCode, })); @@ -1700,12 +1704,12 @@ class ApiProvider extends BaseProvider { //设置安全信息 Future setSafeAnswer(List questionAndAnswerList) => post( setSafeAnswerURL.toUrl, - jsonEncode({"questionAndAnswerList": questionAndAnswerList})); + jsonEncode({'questionAndAnswerList': questionAndAnswerList})); //修改安全信息 Future updateSafeAnswer(List questionAndAnswerList) => post( updateSafeAnswerURL.toUrl, - jsonEncode({"questionAndAnswerList": questionAndAnswerList})); + jsonEncode({'questionAndAnswerList': questionAndAnswerList})); // 获取上传文件的upToken 再调用updateUserInfo Future getUpHeadToken( @@ -1716,10 +1720,10 @@ class ApiProvider extends BaseProvider { post( getUpTokenURL.toUrl, jsonEncode({ - "module": "avatar", - "userId": userId, - "filename": filename, - "size": size, + 'module': 'avatar', + 'userId': userId, + 'filename': filename, + 'size': size, })); // 文件上传 @@ -1731,17 +1735,17 @@ class ApiProvider extends BaseProvider { //获取解绑手机号Token Future unbindPhoneToken(String verificationCode) => post( unbindPhoneTokenURL.toUrl, - jsonEncode({"verificationCode": verificationCode})); + jsonEncode({'verificationCode': verificationCode})); //获取解绑邮箱Token Future unbindEmailToken(String verificationCode) => post( unbindEmailTokenURL.toUrl, - jsonEncode({"verificationCode": verificationCode})); + jsonEncode({'verificationCode': verificationCode})); //推送绑定DeviceID Future pushBindAppId(String deviceId, int deviceType) => post( pushBindAppIdURL.toUrl, - jsonEncode({"deviceId": deviceId, "deviceType": deviceType})); + jsonEncode({'deviceId': deviceId, 'deviceType': deviceType})); // 消息列表 Future messageListLoadData(String pageNo, String pageSize) => post( @@ -2106,8 +2110,7 @@ class ApiProvider extends BaseProvider { 'recordType': recordType, 'records': records }), - isUnShowLoading: isUnShowLoading - ); + isUnShowLoading: isUnShowLoading); // 获取短信或者邮箱模板 Future> getNoticeTemplate( diff --git a/lib/network/api_provider_base.dart b/lib/network/api_provider_base.dart index 00f2c2ae..b67ae870 100755 --- a/lib/network/api_provider_base.dart +++ b/lib/network/api_provider_base.dart @@ -34,9 +34,10 @@ class BaseProvider extends GetConnect with Api { Progress? uploadProgress, bool? isUnShowLoading = false, // 是否显示loading bool? isUserBaseUrl = true, // 文件上传不使用baseUrl + bool? isShowErrMsg = true, // 文件上传不使用baseUrl }) async { AppLog.log('post: url:$url body:$body'); - if (isUnShowLoading == false){ + if (isUnShowLoading == false) { EasyLoading.show(); } if (isUserBaseUrl == false) { @@ -54,8 +55,9 @@ class BaseProvider extends GetConnect with Api { if (EasyLoading.isShow) await EasyLoading.dismiss(animation: true); // EasyLoading.showToast("Network Error!", duration: 2000.milliseconds); - if (res.statusCode == null) { - EasyLoading.showToast('网络访问失败,请检查网络是否正常'.tr, duration: 2000.milliseconds); + if (res.statusCode == null && isShowErrMsg!) { + EasyLoading.showToast('网络访问失败,请检查网络是否正常'.tr, + duration: 2000.milliseconds); // EasyLoading.showToast("Network Error!", duration: 2000.milliseconds); } var rs = {