customizada rotas com nomes das bases
This commit is contained in:
@@ -9,9 +9,11 @@ import '../utils/fixos.dart';
|
||||
import '../widgets/buttom_custom.dart';
|
||||
import '../widgets/snackBars.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:universal_html/html.dart' as html;
|
||||
|
||||
class LoginScreen extends StatefulWidget {
|
||||
const LoginScreen({Key? key}) : super(key: key);
|
||||
String cidade;
|
||||
LoginScreen({required this.cidade});
|
||||
|
||||
@override
|
||||
State<LoginScreen> createState() => _LoginScreenState();
|
||||
@@ -22,23 +24,31 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
//las1594@@
|
||||
//SENHAS CRIPTOGRAFADAS PORQUE FORMA ALTERADAS, SENHAS NOVAS USUÁRIO E SENHA SÃO IGUAIS
|
||||
//ibueno
|
||||
final inputLogin = TextEditingController(text: 'admin');
|
||||
final inputSenha = TextEditingController(text: 'las1594@@');
|
||||
final inputCodigo = TextEditingController(text: 'e003');
|
||||
// final inputLogin = TextEditingController(text: 'admin');
|
||||
// final inputSenha = TextEditingController(text: 'las1594@@');
|
||||
// final inputCodigo = TextEditingController(text: 'e003');
|
||||
final inputLogin = TextEditingController();
|
||||
final inputSenha = TextEditingController();
|
||||
final inputCodigo = TextEditingController();
|
||||
bool carregando = false;
|
||||
List listCodigo = [];
|
||||
String urlAPI = 'https://homol-controle-educa-api.rkmsistemas.com.br';
|
||||
int contLogo = 0;
|
||||
String cidade = '';
|
||||
|
||||
carregarLista(){
|
||||
for(int i=0;Cidades().listCidades.length>i;i++){
|
||||
listCodigo.add(Cidades().listCidades[i].codigo);
|
||||
listCodigo.add(Cidades().listCidades[i].cidadeQuery);
|
||||
}
|
||||
}
|
||||
|
||||
verificacao(){
|
||||
if(inputLogin.text.isNotEmpty){
|
||||
if(inputSenha.text.isNotEmpty){
|
||||
if(inputCodigo.text.isNotEmpty){
|
||||
if(listCodigo.contains(inputCodigo.text.toUpperCase())){
|
||||
if(cidade!=''){
|
||||
if(listCodigo.contains(cidade.toLowerCase())){
|
||||
print('baseParam');
|
||||
print(cidade);
|
||||
setState(() {
|
||||
carregando = true;
|
||||
});
|
||||
@@ -48,10 +58,10 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
getAcessosMariaDB();
|
||||
}
|
||||
}else{
|
||||
showSnackBar(context, 'Código inválido', Colors.red);
|
||||
showSnackBar(context, 'Base não cadastrada', Colors.red);
|
||||
}
|
||||
}else{
|
||||
showSnackBar(context, 'Preencha o código de acesso', Colors.red);
|
||||
showSnackBar(context, 'Preencha o cidade para avançar', Colors.red);
|
||||
}
|
||||
}else{
|
||||
showSnackBar(context, 'Preencha sua senha', Colors.red);
|
||||
@@ -62,13 +72,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
}
|
||||
|
||||
getAcessosMariaDB()async{
|
||||
String cidade = '';
|
||||
for(int i =0; Cidades().listCidades.length>i;i++){
|
||||
if(Cidades().listCidades[i].codigo == inputCodigo.text.toUpperCase()){
|
||||
cidade = Cidades().listCidades[i].cidadeQuery.toUpperCase();
|
||||
}
|
||||
}
|
||||
final url = 'http://${Fixos.IP_API_PORTA}/acesso_maria?LOGIN=${inputLogin.text.toUpperCase()}&CIDADE=$cidade';
|
||||
final url = '$urlAPI/acesso_maria?LOGIN=${inputLogin.text.toUpperCase()}&CIDADE=${cidade.toUpperCase()}';
|
||||
print(url);
|
||||
final response = await http.get(Uri.parse(url));
|
||||
var map = json.decode(response.body);
|
||||
@@ -95,14 +99,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
|
||||
conectAPI()async{
|
||||
|
||||
String cidade = '';
|
||||
for(int i =0; Cidades().listCidades.length>i;i++){
|
||||
if(Cidades().listCidades[i].codigo == inputCodigo.text.toUpperCase()){
|
||||
cidade = Cidades().listCidades[i].cidadeQuery.toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
final url = 'http://${Fixos.IP_API_PORTA}/logincontrole?NO_USERNAME=${inputLogin.text.toUpperCase()}&CIDADE=$cidade';
|
||||
final url = '$urlAPI/logincontrole?NO_USERNAME=${inputLogin.text.toUpperCase()}&CIDADE=${cidade.toUpperCase()}';
|
||||
print(url);
|
||||
final response = await http.get(Uri.parse(url));
|
||||
var map = json.decode(response.body);
|
||||
@@ -113,7 +110,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
if(map['NO_USERNAME']==map['SENHA']){
|
||||
if(map['NO_USERNAME']==inputLogin.text.toUpperCase() && map['SENHA']==inputSenha.text.toUpperCase()){
|
||||
showSnackBar(context, 'Acesso validado', Colors.green);
|
||||
List dados = [cidade,inputLogin.text];
|
||||
List dados = [cidade.toUpperCase(),inputLogin.text,urlAPI];
|
||||
Navigator.pushNamed(context, '/home',arguments: dados);
|
||||
}else{
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta e/ou Código incorreto', Colors.red);
|
||||
@@ -121,7 +118,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
}else{
|
||||
if(MainControllers().encrypt(inputSenha.text,map['SENHA']) == map['SENHA']){
|
||||
showSnackBar(context, 'Acesso validado', Colors.green);
|
||||
List dados = [cidade,inputLogin.text];
|
||||
List dados = [cidade.toUpperCase(),inputLogin.text,urlAPI];
|
||||
Navigator.pushNamed(context, '/home',arguments: dados);
|
||||
}else{
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta e/ou Código incorreto', Colors.red);
|
||||
@@ -144,6 +141,10 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
double height = MediaQuery.of(context).size.height;
|
||||
double width = MediaQuery.of(context).size.width;
|
||||
|
||||
Uri uri = Uri.parse(html.window.location.href);
|
||||
cidade = uri.queryParameters['cidade']!;
|
||||
print(cidade);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: PaletteColors.white,
|
||||
body: Center(
|
||||
@@ -151,9 +152,38 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Spacer(),
|
||||
Container(
|
||||
child: Image.asset("assets/images/logoEduca.png",width:width * 0.15,height: height * 0.12)
|
||||
GestureDetector(
|
||||
onTap: carregando?null:()=>setState((){
|
||||
contLogo++;
|
||||
if(contLogo<5){
|
||||
urlAPI = Fixos.AMB_HOMO;
|
||||
}else{
|
||||
contLogo=0;
|
||||
urlAPI = Fixos.AMB_DEV;
|
||||
}
|
||||
// if(contLogo>=5 && contLogo<=10){
|
||||
// urlAPI = Fixos.AMB_HOMO;
|
||||
// }
|
||||
// if(contLogo>10){
|
||||
// urlAPI = Fixos.AMB_DEV;
|
||||
// if(contLogo==15){
|
||||
// contLogo=0;
|
||||
// urlAPI = Fixos.AMB_PROD;
|
||||
// }
|
||||
// }
|
||||
// print(contLogo);
|
||||
// print(urlAPI);
|
||||
}),
|
||||
child: Container(
|
||||
child: Image.asset("assets/images/logoEduca.png",width:width * 0.15,height: height * 0.12)
|
||||
),
|
||||
),
|
||||
urlAPI==Fixos.AMB_DEV?Container(
|
||||
child: Image.asset("assets/images/desenvolvimento.png",width:width * 0.15,height: height * 0.12)
|
||||
):Container(),
|
||||
urlAPI==Fixos.AMB_HOMO?Container(
|
||||
child: Image.asset("assets/images/homologacao.png",width:width * 0.15,height: height * 0.12)
|
||||
):Container(),
|
||||
carregando?Container():Container(
|
||||
width: width>900? width * 0.18:width*0.5,
|
||||
child: InputText(
|
||||
@@ -177,17 +207,17 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
),
|
||||
),
|
||||
SizedBox(height: height * 0.02),
|
||||
carregando?Container():Container(
|
||||
width: width>900? width * 0.18:width*0.5,
|
||||
child: InputText(
|
||||
inputFormatters: [],
|
||||
controller: inputCodigo,
|
||||
title: 'CÓDIGO',
|
||||
width: width>900? width * 0.18:width*0.5,
|
||||
colorBorder: PaletteColors.white,
|
||||
),
|
||||
),
|
||||
SizedBox(height: height * 0.02),
|
||||
// carregando?Container():Container(
|
||||
// width: width>900? width * 0.18:width*0.5,
|
||||
// child: InputText(
|
||||
// inputFormatters: [],
|
||||
// controller: inputCodigo,
|
||||
// title: 'CÓDIGO',
|
||||
// width: width>900? width * 0.18:width*0.5,
|
||||
// colorBorder: PaletteColors.white,
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(height: height * 0.02),
|
||||
carregando?Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user