fix:修复无网络下点击开锁会报错

This commit is contained in:
anfe 2024-05-30 15:31:14 +08:00
parent 26792c6c7f
commit dafb40954a
3 changed files with 59 additions and 54 deletions

View File

@ -45,7 +45,7 @@ class _StarLockMainXHJPageState extends State<StarLockMainXHJPage>
return Scaffold( return Scaffold(
backgroundColor: Colors.white, backgroundColor: Colors.white,
body: Stack( body: Stack(
children: [ children: <Widget>[
pageView( pageView(
widget: StarLockMainPage( widget: StarLockMainPage(
showAppBar: false, showAppBar: false,
@ -102,7 +102,7 @@ class _StarLockMainXHJPageState extends State<StarLockMainXHJPage>
child: SafeArea( child: SafeArea(
top: false, top: false,
child: Row( child: Row(
children: [ children: <Widget>[
navigationBarItem(Icons.key, navigationBarItem(Icons.key,
TranslationLoader.lanKeys!.device!.tr, logic, 0, () { TranslationLoader.lanKeys!.device!.tr, logic, 0, () {
logic.setIndex(0); logic.setIndex(0);
@ -142,8 +142,8 @@ class _StarLockMainXHJPageState extends State<StarLockMainXHJPage>
// //
Widget navigationBarItem(IconData icon, String text, LockMainXHJLogic logic, Widget navigationBarItem(IconData icon, String text, LockMainXHJLogic logic,
int index, var onTop) { int index, GestureTapCallback? onTop) {
bool check = logic.state.index == index; final bool check = logic.state.index == index;
return Expanded( return Expanded(
child: GestureDetector( child: GestureDetector(
onTap: onTop, onTap: onTop,
@ -151,7 +151,7 @@ class _StarLockMainXHJPageState extends State<StarLockMainXHJPage>
color: Colors.transparent, color: Colors.transparent,
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: <Widget>[
Padding( Padding(
padding: EdgeInsets.only(bottom: 8.h), padding: EdgeInsets.only(bottom: 8.h),
child: Icon( child: Icon(

View File

@ -11,7 +11,7 @@ class ApiProvider extends BaseProvider {
jsonEncode({ jsonEncode({
'countryCode': countryCode, 'countryCode': countryCode,
'account': account, 'account': account,
"channel": channel, 'channel': channel,
'codeType': codeType, 'codeType': codeType,
'xWidth': xWidth, 'xWidth': xWidth,
})); }));
@ -28,10 +28,10 @@ class ApiProvider extends BaseProvider {
jsonEncode({ jsonEncode({
'receiverType': receiverType, 'receiverType': receiverType,
'countryCode': countryCode, 'countryCode': countryCode,
"account": account, 'account': account,
'password': password, 'password': password,
'verificationCode': verificationCode, 'verificationCode': verificationCode,
'platId': "2", 'platId': '2',
})); }));
// post( // post(
@ -71,10 +71,10 @@ class ApiProvider extends BaseProvider {
jsonEncode({ jsonEncode({
'loginType': loginType, 'loginType': loginType,
'password': password, 'password': password,
"platId": "2", 'platId': '2',
'uniqueid': "477E6814-289D-402A-9F49-F89A8BD05D63", 'uniqueid': '477E6814-289D-402A-9F49-F89A8BD05D63',
'countryCode': countryCode, 'countryCode': countryCode,
"username": username 'username': username
})); }));
Future<Response> resetPassword( Future<Response> resetPassword(
@ -89,9 +89,9 @@ class ApiProvider extends BaseProvider {
jsonEncode({ jsonEncode({
'countryCode': countryCode, 'countryCode': countryCode,
'account': account, 'account': account,
"date": date, 'date': date,
'newPassword': newPassword, 'newPassword': newPassword,
"uniqueid": uniqueid, 'uniqueid': uniqueid,
'verificationCode': verificationCode, 'verificationCode': verificationCode,
})); }));
@ -114,7 +114,7 @@ class ApiProvider extends BaseProvider {
jsonEncode({ jsonEncode({
'endDate': endDate, 'endDate': endDate,
'keyId': keyId, 'keyId': keyId,
"keyStatus": keyStatus, 'keyStatus': keyStatus,
'lockId': lockId, 'lockId': lockId,
'pageNo': pageNo, 'pageNo': pageNo,
'pageSize': pageSize, 'pageSize': pageSize,
@ -178,13 +178,15 @@ class ApiProvider extends BaseProvider {
bool isUnShowLoading, bool isUnShowLoading,
) => ) =>
post( post(
uploadElectricQuantityURL.toUrl, uploadElectricQuantityURL.toUrl,
jsonEncode({ jsonEncode({
'electricQuantity': electricQuantity, 'electricQuantity': electricQuantity,
'electricQuantityStandby': electricQuantityStandby, 'electricQuantityStandby': electricQuantityStandby,
'lockId': lockId, 'lockId': lockId,
}), }),
isUnShowLoading: isUnShowLoading); isUnShowLoading: isUnShowLoading,
isShowErrMsg: false,
);
Future<Response> modifyKeyName( Future<Response> modifyKeyName(
String keyId, String keyId,
@ -300,9 +302,9 @@ class ApiProvider extends BaseProvider {
jsonEncode({ jsonEncode({
'lockId': lockId, 'lockId': lockId,
'lockEventType': lockEventType, 'lockEventType': lockEventType,
"pageNo": pageNo, 'pageNo': pageNo,
'pageSize': pageSize, 'pageSize': pageSize,
"startDate": startDate, 'startDate': startDate,
'endDate': endDate, 'endDate': endDate,
})); }));
@ -317,11 +319,13 @@ class ApiProvider extends BaseProvider {
// //
Future<Response> getLockRecordLastUploadDataTime(String lockId) => post( Future<Response> getLockRecordLastUploadDataTime(String lockId) => post(
getLockRecordLastUploadDataTimeURL.toUrl, getLockRecordLastUploadDataTimeURL.toUrl,
jsonEncode({ jsonEncode({
'lockId': lockId, 'lockId': lockId,
}), }),
isUnShowLoading: true); isUnShowLoading: true,
isShowErrMsg: false,
);
// token // token
Future<Response> getLockNetToken(String lockId) => post( Future<Response> getLockNetToken(String lockId) => post(
@ -354,7 +358,7 @@ class ApiProvider extends BaseProvider {
post( post(
bindingBlueAdminURL.toUrl, bindingBlueAdminURL.toUrl,
jsonEncode({ jsonEncode({
"lockAlias": lockAlias, 'lockAlias': lockAlias,
'position': position, 'position': position,
'bluetooth': bluetooth, 'bluetooth': bluetooth,
'lockInfo': lockInfo, 'lockInfo': lockInfo,
@ -370,7 +374,7 @@ class ApiProvider extends BaseProvider {
getLockInfoURL.toUrl, getLockInfoURL.toUrl,
jsonEncode({ jsonEncode({
'lastUpdateDate': lastUpdateDate, 'lastUpdateDate': lastUpdateDate,
"pageNo": pageNo, 'pageNo': pageNo,
})); }));
// //
@ -379,7 +383,7 @@ class ApiProvider extends BaseProvider {
post( post(
getStarLockInfoURL.toUrl, getStarLockInfoURL.toUrl,
jsonEncode({ jsonEncode({
"pageNo": pageNo, 'pageNo': pageNo,
'pageSize': pageSize, 'pageSize': pageSize,
}), }),
isUnShowLoading: isUnShowLoading); isUnShowLoading: isUnShowLoading);
@ -529,8 +533,8 @@ class ApiProvider extends BaseProvider {
'isCoerced': isCoerced, 'isCoerced': isCoerced,
'hoursStart': hoursStart, 'hoursStart': hoursStart,
'hoursEnd': hoursEnd, 'hoursEnd': hoursEnd,
"keyboardPwdType": keyboardPwdType, 'keyboardPwdType': keyboardPwdType,
"pwdRight": pwdRight 'pwdRight': pwdRight
})); }));
Future<Response> clearOperationRecord(String lockId) => Future<Response> clearOperationRecord(String lockId) =>
@ -1283,11 +1287,11 @@ class ApiProvider extends BaseProvider {
'startTime': startTime, 'startTime': startTime,
'endTime': endTime, 'endTime': endTime,
'faceType': faceType, 'faceType': faceType,
"weekDay": weekDay, 'weekDay': weekDay,
'faceName': faceName, 'faceName': faceName,
'addType': addType, 'addType': addType,
"isCoerced": isCoerced, 'isCoerced': isCoerced,
"faceRight": faceRight 'faceRight': faceRight
})); }));
// //
@ -1631,7 +1635,7 @@ class ApiProvider extends BaseProvider {
jsonEncode({ jsonEncode({
'countryCode': countryCode, 'countryCode': countryCode,
'account': account, 'account': account,
"channel": channel, 'channel': channel,
'codeType': codeType, 'codeType': codeType,
'xWidth': xWidth, 'xWidth': xWidth,
})); }));
@ -1679,9 +1683,9 @@ class ApiProvider extends BaseProvider {
post( post(
changePasswordURL.toUrl, changePasswordURL.toUrl,
jsonEncode({ jsonEncode({
"date": date, 'date': date,
'newPassword': newPassword, 'newPassword': newPassword,
"oldPassword": oldPassword, 'oldPassword': oldPassword,
})); }));
// //
@ -1689,7 +1693,7 @@ class ApiProvider extends BaseProvider {
post( post(
getQuestionListURL.toUrl, getQuestionListURL.toUrl,
jsonEncode({ jsonEncode({
"operatorUid": operatorUid, 'operatorUid': operatorUid,
'countryCode': countryCode, 'countryCode': countryCode,
})); }));
@ -1700,12 +1704,12 @@ class ApiProvider extends BaseProvider {
// //
Future<Response> setSafeAnswer(List questionAndAnswerList) => post( Future<Response> setSafeAnswer(List questionAndAnswerList) => post(
setSafeAnswerURL.toUrl, setSafeAnswerURL.toUrl,
jsonEncode({"questionAndAnswerList": questionAndAnswerList})); jsonEncode({'questionAndAnswerList': questionAndAnswerList}));
// //
Future<Response> updateSafeAnswer(List questionAndAnswerList) => post( Future<Response> updateSafeAnswer(List questionAndAnswerList) => post(
updateSafeAnswerURL.toUrl, updateSafeAnswerURL.toUrl,
jsonEncode({"questionAndAnswerList": questionAndAnswerList})); jsonEncode({'questionAndAnswerList': questionAndAnswerList}));
// upToken updateUserInfo // upToken updateUserInfo
Future<Response> getUpHeadToken( Future<Response> getUpHeadToken(
@ -1716,10 +1720,10 @@ class ApiProvider extends BaseProvider {
post( post(
getUpTokenURL.toUrl, getUpTokenURL.toUrl,
jsonEncode({ jsonEncode({
"module": "avatar", 'module': 'avatar',
"userId": userId, 'userId': userId,
"filename": filename, 'filename': filename,
"size": size, 'size': size,
})); }));
// //
@ -1731,17 +1735,17 @@ class ApiProvider extends BaseProvider {
//Token //Token
Future<Response> unbindPhoneToken(String verificationCode) => post( Future<Response> unbindPhoneToken(String verificationCode) => post(
unbindPhoneTokenURL.toUrl, unbindPhoneTokenURL.toUrl,
jsonEncode({"verificationCode": verificationCode})); jsonEncode({'verificationCode': verificationCode}));
//Token //Token
Future<Response> unbindEmailToken(String verificationCode) => post( Future<Response> unbindEmailToken(String verificationCode) => post(
unbindEmailTokenURL.toUrl, unbindEmailTokenURL.toUrl,
jsonEncode({"verificationCode": verificationCode})); jsonEncode({'verificationCode': verificationCode}));
//DeviceID //DeviceID
Future<Response> pushBindAppId(String deviceId, int deviceType) => post( Future<Response> pushBindAppId(String deviceId, int deviceType) => post(
pushBindAppIdURL.toUrl, pushBindAppIdURL.toUrl,
jsonEncode({"deviceId": deviceId, "deviceType": deviceType})); jsonEncode({'deviceId': deviceId, 'deviceType': deviceType}));
// //
Future<Response> messageListLoadData(String pageNo, String pageSize) => post( Future<Response> messageListLoadData(String pageNo, String pageSize) => post(
@ -2106,8 +2110,7 @@ class ApiProvider extends BaseProvider {
'recordType': recordType, 'recordType': recordType,
'records': records 'records': records
}), }),
isUnShowLoading: isUnShowLoading isUnShowLoading: isUnShowLoading);
);
// //
Future<Response<dynamic>> getNoticeTemplate( Future<Response<dynamic>> getNoticeTemplate(

View File

@ -34,9 +34,10 @@ class BaseProvider extends GetConnect with Api {
Progress? uploadProgress, Progress? uploadProgress,
bool? isUnShowLoading = false, // loading bool? isUnShowLoading = false, // loading
bool? isUserBaseUrl = true, // 使baseUrl bool? isUserBaseUrl = true, // 使baseUrl
bool? isShowErrMsg = true, // 使baseUrl
}) async { }) async {
AppLog.log('post: url:$url body:$body'); AppLog.log('post: url:$url body:$body');
if (isUnShowLoading == false){ if (isUnShowLoading == false) {
EasyLoading.show(); EasyLoading.show();
} }
if (isUserBaseUrl == false) { if (isUserBaseUrl == false) {
@ -54,8 +55,9 @@ class BaseProvider extends GetConnect with Api {
if (EasyLoading.isShow) await EasyLoading.dismiss(animation: true); if (EasyLoading.isShow) await EasyLoading.dismiss(animation: true);
// EasyLoading.showToast("Network Error!", duration: 2000.milliseconds); // EasyLoading.showToast("Network Error!", duration: 2000.milliseconds);
if (res.statusCode == null) { if (res.statusCode == null && isShowErrMsg!) {
EasyLoading.showToast('网络访问失败,请检查网络是否正常'.tr, duration: 2000.milliseconds); EasyLoading.showToast('网络访问失败,请检查网络是否正常'.tr,
duration: 2000.milliseconds);
// EasyLoading.showToast("Network Error!", duration: 2000.milliseconds); // EasyLoading.showToast("Network Error!", duration: 2000.milliseconds);
} }
var rs = { var rs = {