hyzp_ybqx-Commit004:使用统一的全局区县信息
This commit is contained in:
@@ -16,6 +16,21 @@ import 'package:hyzp_ybqx/provider/player_region.dart';
|
||||
|
||||
import 'UserInfo.dart';
|
||||
|
||||
////////////////////////////////////////////
|
||||
// begin 统一的全局区县信息
|
||||
//1、宜宾市
|
||||
// String yibin_QuXian = '宜宾市';
|
||||
// String copyright_info = '© 宜宾市翠屏生态环境局\n© 四川省踏石科技有限公司 版权所有 \n服务热线:187-8467-8300';
|
||||
// String copyright_info_PinYin = 'YIBIN BLACK SMOKE CAR CAPTURE SYSTEM';
|
||||
|
||||
//2、翠屏区
|
||||
String yibin_QuXian = '宜宾市翠屏';
|
||||
String copyright_info = '© 宜宾市翠屏生态环境局 版权所有';
|
||||
String copyright_info_PinYin = 'YIBIN CUIPING BLACK SMOKE CAR CAPTURE SYSTEM';
|
||||
|
||||
// end 统一的全局版权信息
|
||||
////////////////////////////////////////////
|
||||
|
||||
//LED字幕信息
|
||||
//String g_ledMessage = '绿水青山就是金山银山 宜宾市翠屏生态环境局宣。';
|
||||
|
||||
|
||||
@@ -1,279 +0,0 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hyzp_ybqx/components/UserAuthority.dart';
|
||||
import '../../components/commonFun.dart';
|
||||
import '../../widget/JdText.dart';
|
||||
import '../../widget/JdButton.dart';
|
||||
|
||||
import '../../config/Config.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import '../../services/Storage.dart';
|
||||
import 'dart:convert';
|
||||
import '../../components/EncryptUtil.dart';
|
||||
|
||||
import '../../services/EventBus.dart';
|
||||
import '../../config/service_url.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
|
||||
|
||||
class LoginByName extends StatefulWidget {
|
||||
LoginByName({Key key}) : super(key: key);
|
||||
|
||||
_LoginPageState createState() => _LoginPageState();
|
||||
}
|
||||
|
||||
class _LoginPageState extends State<LoginByName> {
|
||||
//监听登录页面销毁的事件
|
||||
dispose() {
|
||||
super.dispose();
|
||||
eventBus.fire(new UserEvent('登录成功...'));
|
||||
}
|
||||
|
||||
bool bRemmberPW = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// g_userInfo.username = 'the_user_03';
|
||||
// g_userInfo.password = '123456';
|
||||
// g_userInfo.password = 'ybhb1234';
|
||||
g_userInfo.username = '';
|
||||
g_userInfo.password = '';
|
||||
doInit();
|
||||
}
|
||||
|
||||
doInit() async {
|
||||
bRemmberPW = await Storage.getBool('bRemmberPW');
|
||||
bRemmberPW = (null == bRemmberPW) ? false : bRemmberPW;
|
||||
print('bRemmberPW = $bRemmberPW');
|
||||
|
||||
if (bRemmberPW) {
|
||||
//取出后需解密
|
||||
g_userInfo.username = await Storage.getString('username');
|
||||
g_userInfo.username = EncryptUtil.aesDecode(g_userInfo.username);
|
||||
g_userInfo.password = await Storage.getString('password');
|
||||
g_userInfo.password = EncryptUtil.aesDecode(g_userInfo.password);
|
||||
}
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
doLogin() async {
|
||||
//测试用,临时绕过登录处理
|
||||
// Navigator.pushNamed(context, '/tabs', arguments: g_iIndex);
|
||||
// return;
|
||||
|
||||
if (bRemmberPW) {
|
||||
Storage.setBool('bRemmberPW', bRemmberPW);
|
||||
//加密保存
|
||||
Storage.setString('username', EncryptUtil.aesEncode(g_userInfo.username));
|
||||
Storage.setString('password', EncryptUtil.aesEncode(g_userInfo.password));
|
||||
} else {
|
||||
Storage.remove('username');
|
||||
Storage.remove('password');
|
||||
}
|
||||
|
||||
var api = ServicePath.loginUrl;
|
||||
print(api);
|
||||
try {
|
||||
print('开始处理登录请求...');
|
||||
print('username = ${g_userInfo.username}');
|
||||
print('password = ${g_userInfo.password}');
|
||||
Response response;
|
||||
Dio dio = Dio();
|
||||
|
||||
String random = RandomBit(6); //flutter (dart)生成N位随机数
|
||||
response = await dio.post(api, data: {
|
||||
"username": g_userInfo.username,
|
||||
"password": g_userInfo.password,
|
||||
"sign": GenerateMd5(APPkey + random),
|
||||
"random": random,
|
||||
});
|
||||
print('response = ${response.toString()}');
|
||||
//I/flutter ( 5242): {"ret":200,"data":{"is_login":true,"user_id":3,"token":"32EE57A0109A3D1D6590CFD3DEBA71820F77AB654093C1DE750347C88D1A41CF"},"msg":""}
|
||||
if (response.statusCode == 200) {
|
||||
// Storage.setString('userInfo', json.encode(response.data["userinfo"]));
|
||||
// //Navigator.pop(context);
|
||||
// Navigator.pushNamed(context, '/tabs', arguments: g_iIndex);
|
||||
|
||||
//print('response.data["data"]["is_login"] = ${response.data["data"]["is_login"]}');
|
||||
//I/flutter ( 5242): response.data["data"]["is_login"] = true
|
||||
|
||||
//{
|
||||
// "ret": 200,
|
||||
// "data": {
|
||||
// "is_login": true,
|
||||
// "user_id": 1,
|
||||
// "token": "B93EC91FA2FE293B7077162D4527FC4BB228CD6C0A4F24A882B9A8BBE6C3FB47"
|
||||
// },
|
||||
// "msg": ""
|
||||
// }
|
||||
|
||||
print('response = ${response}');
|
||||
//response = {"ret":406,"data":{},"msg":"非法请求:签名错误"}
|
||||
if (true == response.data["data"]["is_login"]) {
|
||||
print('登录成功');
|
||||
print('response.data = ${response.data}');
|
||||
//保存用户信息
|
||||
Storage.setString('userInfo', json.encode(response.data["data"]));
|
||||
g_userInfo.setUserInfo(theMapUserInfoRet: await getMapFromJson(response.data));
|
||||
//获取用户所属分组和相应权限
|
||||
getUserGroupAll().then((value) {
|
||||
//Navigator.pop(context);
|
||||
Navigator.pushNamed(context, '/tabs', arguments: g_iIndex);
|
||||
});
|
||||
} else {
|
||||
print('登录失败:${response.data["data"]}');
|
||||
Fluttertoast.showToast(
|
||||
msg: '登录失败:用户名或密码不正确。}',
|
||||
toastLength: Toast.LENGTH_LONG,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
print('登录失败:${response.data["data"]}');
|
||||
}
|
||||
print('登录过程正常完成');
|
||||
} else {
|
||||
throw Exception('后端接口出现异常,请检测代码和服务器情况.........');
|
||||
}
|
||||
} catch (e) {
|
||||
print('登录过程异常...');
|
||||
print('ERROR:======>${e}');
|
||||
Fluttertoast.showToast(
|
||||
msg: 'ERROR:======>${e}',
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.CENTER,
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
|
||||
//FocusScope.of(context).requestFocus(FocusNode());
|
||||
//FocusScope.of(context).unfocus();
|
||||
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
padding: EdgeInsets.only(top: 20, bottom: 20, left: 20, right: 20),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
Center(
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: 30),
|
||||
height: ScreenUtil().setWidth(160),
|
||||
width: ScreenUtil().setWidth(160),
|
||||
//child: Image.asset('assets/images/user.png', fit: BoxFit.cover),
|
||||
child: Image.asset('assets/images/ybsthbj.png', fit: BoxFit.fitHeight),
|
||||
// child: Image.network(
|
||||
// 'https://www.itying.com/images/flutter/list5.jpg',
|
||||
// fit: BoxFit.cover),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 30),
|
||||
JdText(
|
||||
height: ScreenUtil().setHeight(300),
|
||||
title: '账号:',
|
||||
text: "请输入账号",
|
||||
onChanged: (String value) {
|
||||
// print(value);
|
||||
g_userInfo.username = value;
|
||||
},
|
||||
endBtn: 'ClearBtn',
|
||||
controller: TextEditingController(text: g_userInfo.username),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
JdText(
|
||||
height: ScreenUtil().setHeight(300),
|
||||
title: '密码:',
|
||||
text: "请输入密码",
|
||||
password: true,
|
||||
onChanged: (String value) {
|
||||
// print(value);
|
||||
g_userInfo.password = value;
|
||||
},
|
||||
endBtn: 'ShowHiddenBtn',
|
||||
controller: TextEditingController(text: g_userInfo.password),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Container(
|
||||
padding: EdgeInsets.all(ScreenUtil().setWidth(20)),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
// Align(
|
||||
// alignment: Alignment.centerLeft,
|
||||
// child: InkWell(
|
||||
// onTap: () {
|
||||
// Navigator.pushNamed(context, '/forgotPassword');
|
||||
// },
|
||||
// child: Text('忘记密码'),
|
||||
// ),
|
||||
// ),
|
||||
Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, '/registerFirst');
|
||||
},
|
||||
//child: Text('记住密码'),
|
||||
child: Container(
|
||||
alignment: Alignment(1, -1),
|
||||
width: 150,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('记住密码:'),
|
||||
Container(
|
||||
alignment: Alignment(1, -1),
|
||||
height: 22,
|
||||
width: 22,
|
||||
child: Checkbox(
|
||||
value: bRemmberPW,
|
||||
activeColor: Colors.blue,
|
||||
onChanged: (bool val) {
|
||||
this.setState(() {
|
||||
bRemmberPW = !bRemmberPW;
|
||||
});
|
||||
Storage.setBool('bRemmberPW', bRemmberPW);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Align(
|
||||
// alignment: Alignment.centerRight,
|
||||
// child: InkWell(
|
||||
// onTap: () {
|
||||
// Navigator.pushNamed(context, '/registerFirst');
|
||||
// },
|
||||
// child: Text(
|
||||
// '新用户注册',
|
||||
// style: TextStyle(
|
||||
// // 创建 paint 对象,设置 color 属性为想要的颜色
|
||||
// background: Paint()..color = Color.fromRGBO(218, 218, 218, 1)),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
JdButton(
|
||||
height: ScreenUtil().setHeight(350),
|
||||
text: "登录",
|
||||
color: Colors.blueAccent,
|
||||
onTop: doLogin,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../../components/commonFun.dart';
|
||||
import '../../services/Storage.dart';
|
||||
import 'FaceLogin.dart';
|
||||
import 'LoginByName2.dart';
|
||||
|
||||
// class LoginTabs extends StatelessWidget {
|
||||
// // This widget is the root of your application.
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// //Flutter 强制竖屏
|
||||
// SystemChrome.setPreferredOrientations([
|
||||
// DeviceOrientation.portraitUp, //只能纵向
|
||||
// DeviceOrientation.portraitDown, //只能纵向
|
||||
// ]);
|
||||
//
|
||||
// return MaterialApp(
|
||||
// debugShowCheckedModeBanner: false,
|
||||
// title: 'Flutter Demo',
|
||||
// theme: ThemeData(
|
||||
// primarySwatch: Colors.blue,
|
||||
// visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
// ),
|
||||
// home: MyHomePage(title: 'Flutter Demo Home Page'),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
class LoginTabs extends StatefulWidget {
|
||||
LoginTabs({Key key, this.title}) : super(key: key);
|
||||
final String title;
|
||||
|
||||
@override
|
||||
_MyHomePageState createState() => _MyHomePageState();
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<LoginTabs> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
//若下面文件不存在,
|
||||
// /data/data/com.flutter.hyzp_ybqx/shared_prefs/FlutterSharedPreferences.xml
|
||||
// value为null, 会抛出异常:
|
||||
// [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Invalid argument(s): The source must not be null
|
||||
// int.parse (dart:core-patch/integers_patch.dart:51:25)
|
||||
Storage.getString("tabs_index").then((value) {
|
||||
g_iIndex = (null == value) ? 0 : int.parse(value);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage("assets/images/背景图.png"),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: 400,
|
||||
child: Container(
|
||||
constraints: BoxConstraints(
|
||||
minWidth: double.infinity, //最小宽度尽量取最大
|
||||
maxHeight: 400 //最小高度为80
|
||||
),
|
||||
child: DefaultTabController(
|
||||
length: 2,
|
||||
child: Scaffold(
|
||||
//backgroundColor: Colors.transparent,
|
||||
appBar: AppBar(
|
||||
//backgroundColor: Colors.transparent,
|
||||
title: Text("宜宾市翠屏黑烟车电子抓拍系统"),
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.close),
|
||||
onPressed: () {
|
||||
SystemNavigator.pop();
|
||||
},
|
||||
),
|
||||
centerTitle: true,
|
||||
bottom: TabBar(
|
||||
labelColor: Colors.blueAccent,
|
||||
unselectedLabelColor: Colors.black26,
|
||||
tabs: <Widget>[Tab(text: "密码登录"), Tab(text: "刷脸登录")],
|
||||
),
|
||||
),
|
||||
body: TabBarView(
|
||||
//flutter tabbar禁止手势滑动-OK
|
||||
physics: new NeverScrollableScrollPhysics(),
|
||||
children: <Widget>[
|
||||
LoginByName2(),
|
||||
FaceLogin(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:hyzp_ybqx/components/commonFun.dart';
|
||||
|
||||
import 'LoginTabsWidget.dart';
|
||||
|
||||
@@ -82,7 +83,8 @@ class LoginTabs2State extends State<LoginTabs2> {
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(children: [
|
||||
TextSpan(
|
||||
text: '宜宾市翠屏黑烟车',
|
||||
// text: '宜宾市翠屏黑烟车',
|
||||
text: yibin_QuXian,
|
||||
style: TextStyle(
|
||||
fontSize: 26.0, color: Colors.white, fontWeight: FontWeight.bold)),
|
||||
TextSpan(
|
||||
@@ -92,7 +94,7 @@ class LoginTabs2State extends State<LoginTabs2> {
|
||||
color: Color.fromRGBO(49, 216, 123, 1),
|
||||
fontWeight: FontWeight.bold)),
|
||||
TextSpan(
|
||||
text: '\nYIBIN BLACK SMOKE CAR CAPTURE SYSTEM',
|
||||
text: '\n' + copyright_info_PinYin,
|
||||
style:
|
||||
TextStyle(fontSize: 11.0, color: Color.fromRGBO(101, 117, 142, 1))),
|
||||
]),
|
||||
@@ -110,8 +112,9 @@ class LoginTabs2State extends State<LoginTabs2> {
|
||||
child: Text(
|
||||
//'© 宜宾市翠屏生态环境局\n© 四川省踏石科技有限公司 版权所有 \n服务热线:187-8467-8300',
|
||||
//'© 宜宾市翠屏生态环境局\n© 四川省踏石科技有限公司',
|
||||
// '© 宜宾市翠屏生态环境局 四川省踏石科技 版权所有\n服务热线:187-8467-8300',
|
||||
'© 宜宾市翠屏生态环境局 版权所有',
|
||||
//'© 宜宾市翠屏生态环境局 四川省踏石科技 版权所有\n服务热线:187-8467-8300',
|
||||
//'© 宜宾市翠屏生态环境局 版权所有',
|
||||
copyright_info,
|
||||
maxLines: 2,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
|
||||
@@ -227,10 +227,12 @@ class _MyUpdatedState extends State<MyUpdated> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SizedBox(height: 60),
|
||||
Text('宜宾市翠屏黑烟车电子抓拍系统', style: TextStyle(fontSize: 20)),
|
||||
// Text('宜宾市翠屏黑烟车电子抓拍系统', style: TextStyle(fontSize: 20)),
|
||||
Text(yibin_QuXian + '黑烟车电子抓拍系统', style: TextStyle(fontSize: 20)),
|
||||
Text('v${widget.ver}(${widget.date})', style: TextStyle(fontSize: 20)),
|
||||
SizedBox(height: 60),
|
||||
Text('© 宜宾市翠屏生态环境局 版权所有',
|
||||
//Text('© 宜宾市翠屏生态环境局 版权所有',
|
||||
Text(copyright_info,
|
||||
maxLines: 2, style: TextStyle(fontSize: 16), textAlign: TextAlign.center),
|
||||
// Text('© 宜宾市翠屏生态环境局 四川省踏石科技 版权所有\n服务热线:187-8467-8300',
|
||||
],
|
||||
|
||||
@@ -112,10 +112,12 @@ class _LoginPageState extends State<MyAbout> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SizedBox(height: 60),
|
||||
Text('宜宾市翠屏黑烟车电子抓拍系统', style: TextStyle(fontSize: 20)),
|
||||
// Text('宜宾市翠屏黑烟车电子抓拍系统', style: TextStyle(fontSize: 20)),
|
||||
Text(yibin_QuXian + '黑烟车电子抓拍系统', style: TextStyle(fontSize: 20)),
|
||||
Text('v${widget.ver}(${widget.date})', style: TextStyle(fontSize: 20)),
|
||||
SizedBox(height: 60),
|
||||
Text('© 宜宾市翠屏生态环境局 版权所有',
|
||||
// Text('© 宜宾市翠屏生态环境局 版权所有',
|
||||
Text(copyright_info,
|
||||
maxLines: 2, style: TextStyle(fontSize: 16), textAlign: TextAlign.center),
|
||||
],
|
||||
// Text('© 宜宾市翠屏生态环境局 四川省踏石科技 版权所有\n服务热线:187-8467-8300',
|
||||
|
||||
Reference in New Issue
Block a user