ajuste da busca e cadastro pelos cpfs dos pais
This commit is contained in:
@@ -84,13 +84,31 @@ class _TelaCadastroState extends State<TelaCadastro> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buscarCPF()async{
|
buscarCPF()async{
|
||||||
final url = '${widget.api}/buscarcpf?CPF=${inputCPF.text.replaceAll('.','').replaceAll('-', '')}&CIDADE=${cidadeQuery.toUpperCase()}';
|
final url = '${widget.api}/buscarCPFMae?CPF=${inputCPF.text}&CIDADE=${cidadeQuery.toUpperCase()}';
|
||||||
print(url);
|
print(url);
|
||||||
final response = await http.get(Uri.parse(url));
|
final response = await http.get(Uri.parse(url));
|
||||||
if(response.body == 'false'){
|
if(response.body == 'false'){
|
||||||
showSnackBar(context, 'CPF não encontrado entre em contato com a escola!', Colors.red);
|
final url = '${widget.api}/buscarCPFPai?CPF=${inputCPF.text}&CIDADE=${cidadeQuery.toUpperCase()}';
|
||||||
carregando = false;
|
print(url);
|
||||||
setState(() {});
|
final response = await http.get(Uri.parse(url));
|
||||||
|
mapAluno = json.decode(response.body);
|
||||||
|
print(mapAluno);
|
||||||
|
print(mapAluno!['CD_ALUNO']);
|
||||||
|
// inserirDB(map);
|
||||||
|
if(tentativas <=3){
|
||||||
|
tentativas = tentativas + 1;
|
||||||
|
criarNumero(mapAluno!['DDD_CELULAR_PAI'].toString(),mapAluno!['CELULAR_PAI'].toString());
|
||||||
|
}else{
|
||||||
|
showSnackBar(context, 'Excedeu suas tentativas, entre em contato com a escola', Colors.red);
|
||||||
|
carregando = false;
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
if(response.body == 'false'){
|
||||||
|
showSnackBar(context, 'CPF não encontrado entre em contato com a escola!', Colors.red);
|
||||||
|
carregando = false;
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
mapAluno = json.decode(response.body);
|
mapAluno = json.decode(response.body);
|
||||||
print(mapAluno);
|
print(mapAluno);
|
||||||
@@ -98,20 +116,22 @@ class _TelaCadastroState extends State<TelaCadastro> {
|
|||||||
// inserirDB(map);
|
// inserirDB(map);
|
||||||
if(tentativas <=3){
|
if(tentativas <=3){
|
||||||
tentativas = tentativas + 1;
|
tentativas = tentativas + 1;
|
||||||
criarNumero();
|
criarNumero(mapAluno!['DDD_CELULAR_MAE'].toString(),mapAluno!['CELULAR_MAE'].toString());
|
||||||
}else{
|
}else{
|
||||||
showSnackBar(context, 'Excedeu suas tentativas, entre em contato com a escola', Colors.red);
|
showSnackBar(context, 'Excedeu suas tentativas, entre em contato com a escola', Colors.red);
|
||||||
|
carregando = false;
|
||||||
|
setState(() {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
criarNumero(){
|
criarNumero(String DDD, String numero){
|
||||||
var random = Random();
|
var random = Random();
|
||||||
nroSMS = (random.nextInt(900000) + 100000).toString();
|
nroSMS = (random.nextInt(900000) + 100000).toString();
|
||||||
apiSMS();
|
apiSMS(DDD,numero);
|
||||||
}
|
}
|
||||||
|
|
||||||
apiSMS()async{
|
apiSMS(String DDD, String numero)async{
|
||||||
final String apiUrl = 'https://api-rest.zenvia.com/services/send-sms';
|
final String apiUrl = 'https://api-rest.zenvia.com/services/send-sms';
|
||||||
final String authToken = '6nPV7rkTncLaugyoEBHQklHrvD5-GzDVMCeI';
|
final String authToken = '6nPV7rkTncLaugyoEBHQklHrvD5-GzDVMCeI';
|
||||||
final headers = {
|
final headers = {
|
||||||
@@ -124,12 +144,14 @@ class _TelaCadastroState extends State<TelaCadastro> {
|
|||||||
final data = {
|
final data = {
|
||||||
"sendSmsRequest": {
|
"sendSmsRequest": {
|
||||||
"from": "RKM EDUCA",
|
"from": "RKM EDUCA",
|
||||||
"to": "+5515996083456",
|
"to": "+55$DDD$numero",
|
||||||
"msg": "Seu codigo de acesso : $nroSMS",
|
"msg": "Seu codigo de acesso : $nroSMS",
|
||||||
"flashSms": true,
|
"flashSms": true,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
print('deu certo +55$DDD$numero');
|
||||||
|
|
||||||
final response = await http.post(
|
final response = await http.post(
|
||||||
Uri.parse(apiUrl),
|
Uri.parse(apiUrl),
|
||||||
headers: headers,
|
headers: headers,
|
||||||
|
|||||||
Reference in New Issue
Block a user