Procházet zdrojové kódy

1.优化启动页面

2.增加配置缓存
3.增加无网络下进入app会定时重试
4.优化我的页面昵称长度固定
5.隐藏评个分
tags/0.0.3+5
“yanghuaxuan” před 3 roky
rodič
revize
8463bcfbe0
2 změnil soubory, kde provedl 80 přidání a 43 odebrání
  1. +19
    -19
      lib/models/base/base_setting_model.dart
  2. +61
    -24
      lib/pages/login_page/login_page.dart

+ 19
- 19
lib/models/base/base_setting_model.dart Zobrazit soubor

@@ -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<String, dynamic>.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<String, dynamic>.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<String, dynamic>.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('基础设置初始化');
}
}

+ 61
- 24
lib/pages/login_page/login_page.dart Zobrazit soubor

@@ -52,6 +52,7 @@ class _LoginPageContainerState extends State<LoginPageContainer> {
var _qqUserData;
var _wxUserData;
String _appleData;
bool checkBool = false;

@override
void initState() {
@@ -88,6 +89,10 @@ class _LoginPageContainerState extends State<LoginPageContainer> {

/// 微信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<LoginPageContainer> {
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<LoginBloc>(context).add(LoginThirdWeChatEvent(model: tempUserData));
}else if(Platform.isAndroid){
} else if (Platform.isAndroid) {
_wxUserData = jsonDecode(userdata['dbInfo']);
BlocProvider.of<LoginBloc>(context).add(LoginThirdWeChatEvent(model: userdata));
}
@@ -136,6 +148,10 @@ class _LoginPageContainerState extends State<LoginPageContainer> {

/// 第三方登陆
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<LoginPageContainer> {

/// 协议
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: <Widget>[
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()),
),
],
);
}



Načítá se…
Zrušit
Uložit