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(
backgroundColor: Colors.white,
body: Stack(
children: [
children: <Widget>[
pageView(
widget: StarLockMainPage(
showAppBar: false,
@ -102,7 +102,7 @@ class _StarLockMainXHJPageState extends State<StarLockMainXHJPage>
child: SafeArea(
top: false,
child: Row(
children: [
children: <Widget>[
navigationBarItem(Icons.key,
TranslationLoader.lanKeys!.device!.tr, logic, 0, () {
logic.setIndex(0);
@ -142,8 +142,8 @@ class _StarLockMainXHJPageState extends State<StarLockMainXHJPage>
//
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<StarLockMainXHJPage>
color: Colors.transparent,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
children: <Widget>[
Padding(
padding: EdgeInsets.only(bottom: 8.h),
child: Icon(

View File

@ -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<Response> 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<Response> 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<Response> getLockRecordLastUploadDataTime(String lockId) => post(
getLockRecordLastUploadDataTimeURL.toUrl,
jsonEncode({
'lockId': lockId,
}),
isUnShowLoading: true);
getLockRecordLastUploadDataTimeURL.toUrl,
jsonEncode({
'lockId': lockId,
}),
isUnShowLoading: true,
isShowErrMsg: false,
);
// token
Future<Response> 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<Response> 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<Response> setSafeAnswer(List questionAndAnswerList) => post(
setSafeAnswerURL.toUrl,
jsonEncode({"questionAndAnswerList": questionAndAnswerList}));
jsonEncode({'questionAndAnswerList': questionAndAnswerList}));
//
Future<Response> updateSafeAnswer(List questionAndAnswerList) => post(
updateSafeAnswerURL.toUrl,
jsonEncode({"questionAndAnswerList": questionAndAnswerList}));
jsonEncode({'questionAndAnswerList': questionAndAnswerList}));
// upToken updateUserInfo
Future<Response> 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<Response> unbindPhoneToken(String verificationCode) => post(
unbindPhoneTokenURL.toUrl,
jsonEncode({"verificationCode": verificationCode}));
jsonEncode({'verificationCode': verificationCode}));
//Token
Future<Response> unbindEmailToken(String verificationCode) => post(
unbindEmailTokenURL.toUrl,
jsonEncode({"verificationCode": verificationCode}));
jsonEncode({'verificationCode': verificationCode}));
//DeviceID
Future<Response> pushBindAppId(String deviceId, int deviceType) => post(
pushBindAppIdURL.toUrl,
jsonEncode({"deviceId": deviceId, "deviceType": deviceType}));
jsonEncode({'deviceId': deviceId, 'deviceType': deviceType}));
//
Future<Response> messageListLoadData(String pageNo, String pageSize) => post(
@ -2106,8 +2110,7 @@ class ApiProvider extends BaseProvider {
'recordType': recordType,
'records': records
}),
isUnShowLoading: isUnShowLoading
);
isUnShowLoading: isUnShowLoading);
//
Future<Response<dynamic>> getNoticeTemplate(

View File

@ -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 = {