|
|
|
@ -16,8 +16,10 @@ import 'package:flutter/services.dart';
|
|
|
|
|
import 'package:huixiang/generated/l10n.dart'; |
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
|
import 'package:dio/dio.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/round_button.dart'; |
|
|
|
|
import 'package:photo_view/photo_view.dart'; |
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
|
import 'package:sharesdk_plugin/sharesdk_interface.dart'; |
|
|
|
|
import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart'; |
|
|
|
|
|
|
|
|
|
class LoginPage extends StatefulWidget { |
|
|
|
@ -55,9 +57,14 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
|
|
|
|
|
|
|
|
|
|
isLogin() async { |
|
|
|
|
SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); |
|
|
|
|
if (sharedPreferences.containsKey('token') |
|
|
|
|
&& sharedPreferences.getString("token") != null |
|
|
|
|
&& sharedPreferences.getString("token") != "") { |
|
|
|
|
|
|
|
|
|
if (sharedPreferences.getBool("isShowPrivacyPolicy") == null || !sharedPreferences.getBool("isShowPrivacyPolicy")) { |
|
|
|
|
showAlertDialog(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (sharedPreferences.containsKey('token') && |
|
|
|
|
sharedPreferences.getString("token") != null && |
|
|
|
|
sharedPreferences.getString("token") != "") { |
|
|
|
|
Navigator.of(context).popAndPushNamed('/router/main_page'); |
|
|
|
|
} else { |
|
|
|
|
client = ApiService(Dio()); |
|
|
|
@ -89,7 +96,6 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
|
|
|
|
|
RenderBox renderBox = loginKey.currentContext.findRenderObject(); |
|
|
|
|
|
|
|
|
|
offsetBtn = scrollController.offset; |
|
|
|
|
print("offsetBtn: $offsetBtn"); |
|
|
|
|
var screenHeight = MediaQuery.of(context).size.height; |
|
|
|
|
var scrollHeight = screenHeight * 1.47; |
|
|
|
|
var height = scrollHeight - renderBox.size.height; |
|
|
|
@ -98,7 +104,6 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
|
|
|
|
|
(scrollController.offset / (height - chaHeight) * (255)).toInt(); |
|
|
|
|
changeAlpha = (changeAlpha > 255 ? 255 : changeAlpha); |
|
|
|
|
changeAlpha = (changeAlpha < 0 ? 0 : changeAlpha); |
|
|
|
|
print("changeAlpha: $changeAlpha"); |
|
|
|
|
alpha = (initAlpha + |
|
|
|
|
scrollController.offset / |
|
|
|
|
(height - chaHeight) * |
|
|
|
@ -106,7 +111,6 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
|
|
|
|
|
.toInt(); |
|
|
|
|
alpha = (alpha > 255 ? 255 : alpha); |
|
|
|
|
alpha = (alpha < 0 ? 0 : alpha); |
|
|
|
|
print("alpha: $alpha"); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
_controllerPhone.addListener(() { |
|
|
|
@ -155,6 +159,11 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
|
|
|
|
|
Color statusCodeLineColor = Color(0xFF32A060); |
|
|
|
|
|
|
|
|
|
_sendCode() async { |
|
|
|
|
SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); |
|
|
|
|
if (!sharedPreferences.containsKey("isShowPrivacyPolicy") || !sharedPreferences.getBool("isShowPrivacyPolicy")) { |
|
|
|
|
showAlertDialog(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (!checkStatus) { |
|
|
|
|
SmartDialog.showToast(S.of(context).gouxuanxieyi); |
|
|
|
|
return; |
|
|
|
@ -216,14 +225,15 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_login() async { |
|
|
|
|
// Navigator.of(context).popAndPushNamed('/router/main_page'); |
|
|
|
|
// return; |
|
|
|
|
print("222222"); |
|
|
|
|
if (alpha != 255) { |
|
|
|
|
scrollToTop(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); |
|
|
|
|
if (!sharedPreferences.containsKey("isShowPrivacyPolicy") || !sharedPreferences.getBool("isShowPrivacyPolicy")) { |
|
|
|
|
showAlertDialog(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (!checkStatus) { |
|
|
|
|
SmartDialog.showToast(S.of(context).gouxuanxieyi); |
|
|
|
|
return; |
|
|
|
@ -270,7 +280,8 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
|
|
|
|
|
eventBus.fire(EventType(3)); |
|
|
|
|
|
|
|
|
|
xgFlutterPlugin.setAccount(mobile, AccountType.CUSTOM); |
|
|
|
|
xgFlutterPlugin.bindWithIdentifier(identify: mobile, bindType: XGBindType.account); |
|
|
|
|
xgFlutterPlugin.bindWithIdentifier( |
|
|
|
|
identify: mobile, bindType: XGBindType.account); |
|
|
|
|
|
|
|
|
|
if (widget.arguments != null) { |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
@ -890,6 +901,149 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
|
|
|
|
|
duration: Duration(milliseconds: 500), curve: Curves.ease); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
showAlertDialog() { |
|
|
|
|
//显示对话框 |
|
|
|
|
showDialog( |
|
|
|
|
context: context, |
|
|
|
|
builder: (BuildContext context) { |
|
|
|
|
return SimpleDialog( |
|
|
|
|
titlePadding: EdgeInsets.all(10), |
|
|
|
|
backgroundColor: Colors.transparent, |
|
|
|
|
elevation: 0, |
|
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(6))), |
|
|
|
|
children: <Widget>[ |
|
|
|
|
Stack( |
|
|
|
|
alignment: Alignment.bottomCenter, |
|
|
|
|
children: [ |
|
|
|
|
Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
width: double.infinity, |
|
|
|
|
height: 305.h, |
|
|
|
|
// margin: EdgeInsets.only(left: 40.w, right: 40.w), |
|
|
|
|
padding: EdgeInsets.only(left: 16.w, right: 16.w), |
|
|
|
|
decoration: new BoxDecoration( |
|
|
|
|
color: Colors.white, |
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(8))), |
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
Padding( |
|
|
|
|
padding: EdgeInsets.only(top: 24.h, bottom: 10.h), |
|
|
|
|
child: Text( |
|
|
|
|
S.of(context).xieyitanchuang, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xff4D4D4D), |
|
|
|
|
fontSize: 18.sp, |
|
|
|
|
fontWeight: FontWeight.bold,), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Text.rich( |
|
|
|
|
TextSpan(children: [ |
|
|
|
|
TextSpan( |
|
|
|
|
text: S.of(context).yinsizhengce1, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontWeight: FontWeight.w500, |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
height: 1.3.h, |
|
|
|
|
color: Color(0xff727272)), |
|
|
|
|
), |
|
|
|
|
TextSpan( |
|
|
|
|
text: S.of(context).yinsixieyi, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontWeight: FontWeight.w500, |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
color: Color(0xff32A060)), |
|
|
|
|
recognizer: TapGestureRecognizer() |
|
|
|
|
..onTap = () { |
|
|
|
|
Navigator.of(context).popAndPushNamed('/router/treaty_page'); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
]), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
height: 10.h, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
S.of(context).yinsizhengce2, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xff727272), |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
height: 1.3.h, |
|
|
|
|
fontWeight: FontWeight.w500, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
height: 16.h, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
height: 40.h, |
|
|
|
|
alignment: Alignment.bottomCenter, |
|
|
|
|
margin: EdgeInsets.only(bottom: 20.h), |
|
|
|
|
child: BorderText( |
|
|
|
|
padding: EdgeInsets.only( |
|
|
|
|
top: 10.h, bottom: 10.h, left: 36.w, right: 36.w), |
|
|
|
|
text: S.of(context).jujue, |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
textColor: Color(0xFF32A060), |
|
|
|
|
borderColor: Color(0xFF32A060), |
|
|
|
|
borderWidth: 1.w, |
|
|
|
|
radius: 23, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 21.w, |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
height: 40.h, |
|
|
|
|
margin: EdgeInsets.only(bottom: 20.h), |
|
|
|
|
alignment: Alignment.bottomCenter, |
|
|
|
|
child: RoundButton( |
|
|
|
|
text: S.of(context).tongyibingjixu, |
|
|
|
|
textColor: Colors.white, |
|
|
|
|
fontSize: 12, |
|
|
|
|
callback: () { |
|
|
|
|
SharedPreferences.getInstance().then((value) { |
|
|
|
|
value.setBool("isShowPrivacyPolicy", true); |
|
|
|
|
}); |
|
|
|
|
SharesdkPlugin.uploadPrivacyPermissionStatus( |
|
|
|
|
1, |
|
|
|
|
(success) => { |
|
|
|
|
Navigator.of(context).pop(), |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
padding: EdgeInsets.only( |
|
|
|
|
top: 10.h, |
|
|
|
|
bottom: 10.h, |
|
|
|
|
left: 21.5.w, |
|
|
|
|
right: 21.5.w), |
|
|
|
|
backgroup: Color(0xff32A060), |
|
|
|
|
radius: 23, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
height: 20.h, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool isPhone(mobile) { |
|
|
|
|
RegExp exp = RegExp( |
|
|
|
|
r'^((13[0-9])|(14[0-9])|(15[0-9])|(16[0-9])|(17[0-9])|(18[0-9])|(19[0-9]))\d{8}$'); |
|
|
|
|