From 8463bcfbe014a0f48c64cb555922acc72f7e4784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyanghuaxuan=E2=80=9D?= <“646903573@qq.com”> Date: Sat, 9 Jan 2021 19:11:14 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E5=90=AF=E5=8A=A8=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=202.=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE=E7=BC=93?= =?UTF-8?q?=E5=AD=98=203.=E5=A2=9E=E5=8A=A0=E6=97=A0=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E4=B8=8B=E8=BF=9B=E5=85=A5app=E4=BC=9A=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E9=87=8D=E8=AF=95=204.=E4=BC=98=E5=8C=96=E6=88=91=E7=9A=84?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=98=B5=E7=A7=B0=E9=95=BF=E5=BA=A6=E5=9B=BA?= =?UTF-8?q?=E5=AE=9A=205.=E9=9A=90=E8=97=8F=E8=AF=84=E4=B8=AA=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/models/base/base_setting_model.dart | 38 +++++------ lib/pages/login_page/login_page.dart | 85 ++++++++++++++++++------- 2 files changed, 80 insertions(+), 43 deletions(-) diff --git a/lib/models/base/base_setting_model.dart b/lib/models/base/base_setting_model.dart index dc3cb01..481cc61 100644 --- a/lib/models/base/base_setting_model.dart +++ b/lib/models/base/base_setting_model.dart @@ -47,34 +47,22 @@ class BaseSettingModel { if (isGetCache != null && isGetCache) { String configData = await SharedPreferencesUtil.getStringValue(GlobalConfig.MAIN_CONFIG, defaultVal: '1'); if (configData != "1") { - _setting = BaseSettingModel.fromJson(Map.from(json.decode(configData))); - if (Platform.isIOS) { - if (null != _setting && _setting.isIosReview == '1') { - SharedPreferencesUtil.setStringValue(GlobalConfig.IS_IOS_REVIEW, '1'); - } else { - SharedPreferencesUtil.setStringValue(GlobalConfig.IS_IOS_REVIEW, '0'); - } - } + createBaseSet(json.decode(configData)); Logger.debug('基础设置初始化'); } - NetUtil.request('/api/v1/new/config.json',onSuccess: (data){ + NetUtil.request('/api/v1/new/config.json',onSuccess: (data){ + print(data); + var cacheString=json.encode(data); + SharedPreferencesUtil.setNetCacheResult(GlobalConfig.MAIN_CONFIG, cacheString); }); - + return _setting; } else { Map result = await NetUtil.post('/api/v1/new/config.json', method: NetMethod.GET); 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('基础设置初始化'); + createBaseSet(data); return _setting; } } catch (err) { @@ -82,4 +70,16 @@ class BaseSettingModel { } return null; } + + static createBaseSet(dynamic 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('基础设置初始化'); + } } diff --git a/lib/pages/login_page/login_page.dart b/lib/pages/login_page/login_page.dart index f34eacd..3bc86d7 100644 --- a/lib/pages/login_page/login_page.dart +++ b/lib/pages/login_page/login_page.dart @@ -52,6 +52,7 @@ class _LoginPageContainerState extends State { var _qqUserData; var _wxUserData; String _appleData; + bool checkBool = false; @override void initState() { @@ -88,6 +89,10 @@ class _LoginPageContainerState extends State { /// 微信or手机登陆 void _loginClick(String type, LoginStyleModel model) { + if(!checkBool){ + Fluttertoast.showToast(msg: "请阅读并勾选同意用户协议选项"); + return; + } print('登陆$type'); RouterUtil.hideKeyboard(context); if ('mobile' == type) { @@ -104,20 +109,27 @@ class _LoginPageContainerState extends State { Logger.log('state = ${state?.toString()}, userInfo = ${userdata?.toString()}'); if (state == SSDKResponseState.Success) { try { - if(Platform.isIOS){ - Map credentialDic=userdata['credential']; - Map rawDatalDic=userdata['rawData']; - var name=userdata['nickname']; - var gender=userdata['gender']; - var icon=userdata['icon']; - var userID=userdata['uid']; - var unionid=rawDatalDic['unionid']; - var token=credentialDic['token']; - Map dbInfoDic={'nickname':name,'gender':gender,'icon':icon,'userID':userID,'unionid':unionid,'token':token,}; - Map tempUserData = {'dbInfo':jsonEncode(dbInfoDic)}; + if (Platform.isIOS) { + Map credentialDic = userdata['credential']; + Map rawDatalDic = userdata['rawData']; + var name = userdata['nickname']; + var gender = userdata['gender']; + var icon = userdata['icon']; + var userID = userdata['uid']; + var unionid = rawDatalDic['unionid']; + var token = credentialDic['token']; + Map dbInfoDic = { + 'nickname': name, + 'gender': gender, + 'icon': icon, + 'userID': userID, + 'unionid': unionid, + 'token': token, + }; + Map tempUserData = {'dbInfo': jsonEncode(dbInfoDic)}; _wxUserData = jsonDecode(tempUserData['dbInfo']); BlocProvider.of(context).add(LoginThirdWeChatEvent(model: tempUserData)); - }else if(Platform.isAndroid){ + } else if (Platform.isAndroid) { _wxUserData = jsonDecode(userdata['dbInfo']); BlocProvider.of(context).add(LoginThirdWeChatEvent(model: userdata)); } @@ -136,6 +148,10 @@ class _LoginPageContainerState extends State { /// 第三方登陆 void _otherLoginClick(BottomIcons model) async { + if(!checkBool){ + Fluttertoast.showToast(msg: "请阅读并勾选同意用户协议选项"); + return; + } print('第三方登陆${model.type}'); if (EmptyUtil.isEmpty(model) || EmptyUtil.isEmpty(model.type)) { Fluttertoast.showToast(msg: '暂不支持~'); @@ -434,18 +450,39 @@ class _LoginPageContainerState extends State { /// 协议 Widget _protocolWidget(LoginStyleModel model) { - return RichText( - text: TextSpan( - text: '', - children: model.main.agreements.map((item) { - return TextSpan( - text: item?.text, - style: TextStyle(color: HexColor.fromHex(item?.textColor), fontSize: 10), - recognizer: TapGestureRecognizer() - ..onTap = () { - _jumpUserAgreement(item?.url); - }); - }).toList()), + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + InkWell( + borderRadius: BorderRadius.circular(20), + onTap: () { + checkBool = !checkBool; + setState(() {}); + }, + child: Container( + width: 32, + height: 32, + child: Icon( + checkBool ? Icons.check_box : Icons.check_box_outline_blank, + size: 16, + color: checkBool?Colors.red:Colors.black12, + ), + ), + ), + RichText( + text: TextSpan( + text: '', + children: model.main.agreements.map((item) { + return TextSpan( + text: item?.text, + style: TextStyle(color: HexColor.fromHex(item?.textColor), fontSize: 10), + recognizer: TapGestureRecognizer() + ..onTap = () { + _jumpUserAgreement(item?.url); + }); + }).toList()), + ), + ], ); }