daily pastebin goal
74%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Modulo
  2. =======================================================================================================================================
  3.  
  4. import { NgModule } from '@angular/core';
  5. import { IonicPageModule } from 'ionic-angular';
  6. import { BrMaskerModule } from 'brmasker-ionic-3';
  7. import { CadastroPage } from './cadastro';
  8.  
  9. @NgModule({
  10.   declarations: [
  11.     CadastroPage
  12.   ],
  13.   imports: [
  14.     BrMaskerModule,
  15.     IonicPageModule.forChild(CadastroPage)
  16.   ],
  17. })
  18.  
  19. export class CadastroPageModule {}
  20.  
  21. =======================================================================================================================================
  22. Controller
  23. =======================================================================================================================================
  24.  
  25. import { Component } from '@angular/core';
  26. import { IonicPage, NavController, NavParams, ToastController, Platform, MenuController, LoadingController } from 'ionic-angular';
  27. import { FormBuilder, FormGroup, Validators } from '@angular/forms'
  28. import { BrMaskerIonic3 } from 'brmasker-ionic-3';
  29.  
  30. import { MovieService } from '../../providers/service/MovieService';
  31.  
  32. @IonicPage()
  33. @Component({
  34.   selector: 'page-cadastro',
  35.     templateUrl: 'cadastro.html',
  36.     providers: [MovieService]
  37. })
  38.  
  39. export class CadastroPage {
  40.  
  41.   cadastroForm: FormGroup;
  42.  
  43.   constructor(public navCtrl: NavController,
  44.     public FormBuilder: FormBuilder,
  45.     public platform: Platform,
  46.     public form: FormBuilder,
  47.     private movieService: MovieService,
  48.     public toastCtrl: ToastController,
  49.     public menuCtrl: MenuController,
  50.     public loadingCtrl: LoadingController,
  51.     public navParams: NavParams,
  52.     public brMaskerIonic3: BrMaskerIonic3) {
  53.  
  54.     // Ocultar Menu
  55.     this.menuCtrl.enable(false);
  56.  
  57.     // Executar ao Voltar Celular
  58.     this.platform.registerBackButtonAction(() => {
  59.       this.navCtrl.setRoot('ConfirmacaoPage', {}, { animate: true, direction: 'back' });
  60.     });
  61.  
  62.     // Formulário de Cadastro
  63.     this.cadastroForm = this.form.group({
  64.       nmEntregador: ['', Validators.required],
  65.       dtNascimento: ['', Validators.required],
  66.       sexo: ['', Validators.required],
  67.       celular: ['', Validators.required]
  68.     })
  69.  
  70.   }
  71.  
  72.   ionViewDidLoad() {
  73.   }
  74.  
  75.   // Efetuar Cadastro do Entregador
  76.   cadastrar() {
  77.  
  78.     // Enviar Dados
  79.     var entregador = {
  80.       "cdEntregador": 0,
  81.       "nmEntregador": this.cadastroForm.value.nmEntregador,
  82.       "dtNascimento": this.cadastroForm.value.dtNascimento,
  83.       "sexo": this.cadastroForm.value.sexo,
  84.       "celular": this.cadastroForm.value.celular,
  85.       "email": localStorage.getItem('email'),
  86.       "senha": localStorage.getItem('senha'),
  87.       "playerId": localStorage.getItem('playerId')
  88.     };
  89.  
  90.     // Enviar Dados
  91.     let dados = new FormData();
  92.     dados.append('entregador', JSON.stringify(entregador));
  93.  
  94.     // Loading...
  95.     let loading = this.loadingCtrl.create({ content: 'Salvando...' });
  96.     loading.present();
  97.  
  98.     var self = this;
  99.     this.movieService.WebService('wsSalvarEntregador', dados).then(function (retorno) {
  100.  
  101.       // Mensagem do Tost
  102.       let toast = self.toastCtrl.create({ message: retorno.mensagem, duration: 3000, position: 'bottom' });
  103.       toast.present(toast);
  104.  
  105.       if (retorno.sucesso) {
  106.         localStorage.setItem('entregador', JSON.stringify(retorno.entregador));
  107.         self.navCtrl.setRoot('HomePage', {}, { animate: true, direction: 'forward' });
  108.       }
  109.  
  110.     });
  111.  
  112.     loading.dismiss();
  113.  
  114.   }
  115.  
  116. }
  117.  
  118. =======================================================================================================================================
  119. view
  120. =======================================================================================================================================
  121.  
  122. <ion-header>
  123.   <ion-navbar color="danger">
  124.     <ion-title>Fome Demais LogĂ­stica</ion-title>
  125.   </ion-navbar>
  126. </ion-header>
  127.  
  128. <ion-content padding>
  129.   <form [formGroup]="cadastroForm">
  130.  
  131.  
  132.  
  133. <ion-item>
  134.   <ion-input type="text" name="celular" placeholder="celular" [brmasker]="{mask:'(00) 00000-0000', len:15}"></ion-input>
  135. </ion-item>
  136.  
  137.  
  138.     <ion-item>
  139.       <ion-label stacked>Nome</ion-label>
  140.       <ion-input type="text" name="nmEntregador" formControlName="nmEntregador"></ion-input>
  141.     </ion-item>
  142.  
  143.     <ion-item>
  144.       <ion-label stacked>Data de Nascimento</ion-label>
  145.       <ion-datetime name="dtNascimento" formControlName="dtNascimento" displayFormat="DD/MM/YYYY" cancelText="Cancelar" doneText="OK"></ion-datetime>
  146.     </ion-item>
  147.  
  148.     <ion-list radio-group formControlName="sexo">
  149.       <ion-grid>
  150.         <ion-row>
  151.           <ion-col col-12>
  152.             <ion-label stacked>Sexo</ion-label>
  153.           </ion-col>
  154.         </ion-row>
  155.         <ion-row>
  156.           <ion-col col-6>
  157.             <ion-radio value="F"></ion-radio> FEMININO
  158.           </ion-col>
  159.           <ion-col col-6>
  160.             <ion-radio value="M"></ion-radio> MASCULINO
  161.           </ion-col>
  162.         </ion-row>
  163.       </ion-grid>
  164.     </ion-list>
  165.  
  166.     <!--
  167.     <ion-item>
  168.       <ion-label stacked>Celular</ion-label>
  169.       <ion-input type="tel"  maxlength="15" name="celular" [(ngModel)]="celular" formControlName="celular"></ion-input>
  170.     </ion-item>
  171.     -->
  172.    
  173.     <button [disabled]="cadastroForm.invalid" ion-button block color="danger" class="botao" (click)="cadastrar()"> Cadastrar </button>
  174.  
  175.   </form>
  176. </ion-content>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top