import 'dart:io'; import 'package:zhiying_comm/util/net_util.dart'; import 'package:zhiying_comm/util/shared_prefe_util.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; class BaseSettingModel { String fileProvider; String fileBucketHost; String fileBucketHostProtocol; String isIosReview; Map tab; static BaseSettingModel _setting; static BaseSettingModel get setting { if (_setting == null) { Logger.error('暂未初始化'); } return _setting; } BaseSettingModel( {this.fileProvider, this.fileBucketHost, this.fileBucketHostProtocol}); BaseSettingModel.fromJson(Map json) { fileProvider = json['file_provider']; fileBucketHost = json['file_bucket_host']; fileBucketHostProtocol = json['file_bucket_host_protocol']; isIosReview = json['is_ios_review']?.toString(); tab = Map.from(json['bottom_nav']); } Map toJson() { final Map data = new Map(); data['file_provider'] = this.fileProvider; data['file_bucket_host'] = this.fileBucketHost; data['file_bucket_host_protocol'] = this.fileBucketHostProtocol; data['bottom_nav'] = this.tab; data['is_ios_review'] = this.isIosReview; return data; } static Future init() async { Map result = await NetUtil.post('/api/v1/new/config.json', method: NetMethod.GET); try { var data = result['data']; _setting = BaseSettingModel.fromJson(Map.from(data)); if(Platform.isIOS) { if (null != _setting && _setting.isIosReview == '1') { SharedPreferencesUtil.setStringValue(GlobalConfig.IS_IOS_REVIEW, '1'); } else { SharedPreferencesUtil.setStringValue(GlobalConfig.IS_IOS_REVIEW, '0'); } } Logger.debug('基础设置初始化'); return _setting; } catch (err) { Logger.error(err); } return null; } }