Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

Não consegui fazer funcionar no celular, no navegador funciono o envio de pedido.

Segue o meu config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="org.gabrielucas.garconapp" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Gabriel e Lucas</name>
    <description>
        App para uso das garçonetes dentro do restaurante.
    </description>
    <author email="lucaspiovani90@outlook.com.br" href="http://lucaspiovani.com.br">
        Lucas Piovani
    </author>
    <access origin="http://cozinhapp.sergiolopes.org" />
    <preference name="Orientation" value="portrait" />
    <preference name="BackgroundColor" value="0xF2F2F2FF" />
    <preference name="DisallowOverscroll" value="true" />
    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenDelay" value="3000" />
    <platform name="android">
        <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
        <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
        <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
        <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
        <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
        <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
        <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
        <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
        <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
        <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
        <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
        <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
    </platform>
    <platform name="ios">
        <icon height="57" src="resources/ios/icon/icon.png" width="57" />
        <icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
        <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
        <icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
        <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
        <icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
        <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
        <icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
        <icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
        <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
        <icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
        <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
        <icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
        <icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
        <icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" />
        <icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87" />
        <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
        <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
        <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
        <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
        <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
        <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
        <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
    </platform>
    <icon src="resources/android/icon/drawable-xhdpi-icon.png" />
    <platform name="windows">
        <icon height="150" src="resources/windows/icon/Square150x150Logo.scale-100.png" width="150" />
        <icon height="360" src="resources/windows/icon/Square150x150Logo.scale-240.png" width="360" />
        <icon height="30" src="resources/windows/icon/Square30x30Logo.scale-100.png" width="30" />
        <icon height="310" src="resources/windows/icon/Square310x310Logo.scale-100.png" width="310" />
        <icon height="106" src="resources/windows/icon/Square44x44Logo.scale-240.png" width="106" />
        <icon height="70" src="resources/windows/icon/Square70x70Logo.scale-100.png" width="70" />
        <icon height="170" src="resources/windows/icon/Square71x71Logo.scale-240.png" width="170" />
        <icon height="50" src="resources/windows/icon/StoreLogo.scale-100.png" width="50" />
        <icon height="120" src="resources/windows/icon/StoreLogo.scale-240.png" width="120" />
        <icon height="150" src="resources/windows/icon/Wide310x150Logo.scale-100.png" width="310" />
        <icon height="360" src="resources/windows/icon/Wide310x150Logo.scale-240.png" width="744" />
        <splash height="300" src="resources/windows/splash/SplashScreen.scale-100.png" width="620" />
        <splash height="1920" src="resources/windows/splash/SplashScreen.scale-240.png" width="1152" />
        <splash height="1920" src="resources/windows/splash/SplashScreenPhone.scale-240.png" width="1152" />
    </platform>
    <engine name="android" />
    <plugin name="cordova-plugin-statusbar" spec="*" />
    <platform name="android">
        <preference name="StatusBarBackgroundColor" value="#E86C13" />
    </platform>
    <platform name="ios">
        <preference name="StatusBarOverlaysWebView" value="false" />
        <preference name="StatusBarBackgroundColor" value="#F57F17" />
    </platform>
    <plugin name="phonegap-plugin-barcodescanner" spec="*" />
    <plugin name="cordova-plugin-whitelist" spec="*" />
</widget>

Segue o app.js

$('.collection-item').on('click', function(){

  var $badge = $('.badge', this);
  if ($badge.length == 0) {
       $badge = $('<span class="badge brown-text">0</span>').appendTo(this);
  }

  $badge.text(parseInt($badge.text()) + 1);

});


$('#confirmar').on('click', function(){

    var texto = '';

    $('.badge').parent().each(function(){
        var produto = this.firstChild.textContent;
        var quantidade = this.lastChild.textContent;

         texto += produto + ':' + quantidade + ',';
        //alert( produto + quantidade );
    });

    $('#resumo').text(texto);
});

$('.modal-trigger').leanModal();



$('.collection').on('click', '.badge', function(){
    $(this).remove();
    return false;
});

$('.acao-limpar').on('click', function(){
    $('#numero-mesa').val('');
    $('.badge').remove();
});

$('.scan-qrcode').click(function(){

    cordova.plugins.barcodeScanner.scan(function(resultado){
        if (resultado.text) {
            Materialize.toast('Mesa' + resultado.text, 2000);
            $('#numero-mesa').val(resultado.text);
        }

    },
    function(erro){
        Materialize.toast('Erro' + erro, 2000, 'red-text');
    });

});



$('.acao-finalizar').on('click', function() {
    $.ajax({
        url: 'http://cozinhapp.sergiolopes.org/novo-pedido',
        data: {
            mesa: $('#numero-mesa').val(),
            pedido: $('#resumo').text()
        },
        error: function(erro) {
           Materialize.toast(erro.responseText, 3000, 'red-text');
        },
        success: function(dados) {
            Materialize.toast(dados, 2000);

            $('#numero-mesa').val('');
            $('.badge').remove();
        }
    });
});

e o index.html

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta charset="utf-8">
    <title>Só de Cenoura Garçom</title>
    <link rel="stylesheet" href="icons/material.css">
    <link rel="stylesheet" href="css/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="css/estilos.css">
</head>
<body>

    <div class="topo-fixo z-depth-2">

        <div class="yellow darken-4 white-text valign-wrapper">
           <h5 class="titulo">Só de Cenoura</h5>

           <div>
           <i class="material-icons waves-effect waves-light waves-circle scan-qrcode">camera</i>
               <i data-activates="submenu" datas-gutter="5"
               data-contrainwidth="false"
               class="material-icons waves-effect waves-light waves-circle 
               dropdown-button">
               more_vert</i>
           </div>

           <ul class="dropdown-content" id="submenu">
            <li><a class="black-text acao-limpar">Limpar</a></li>
           </ul>
        </div>
         <ul class="tabs yellow darken-4">
             <li class="tab"><a href="#bolos" class="white-text waves-effect waves-light">Bolos</a></li>
             <li class="tab"><a href="#bebidas" class="white-text waves-effect waves-light">Bebidas</a></li>
         </ul>

    </div>
             <div class="section" id="bolos">
             <h6 class="container brown-text">Bolos em pedaços</h6>
               <div class="collection">
                   <a class="collection-item waves-effect black-text">Só de Cenoura</a>
                   <a class="collection-item waves-effect black-text">Bolo com nutella</a>
                   <a class="collection-item waves-effect black-text">Bolo de brigadeiro</a>
                   <a class="collection-item waves-effect black-text">Açucarado</a>
               </div>
               <h6 class="container">Inteiros</h6>
               <div class="collection brown-text">
                   <a class="collection-item waves-effect black-text">
                   Só de Cenoura Inteiro
                   </a>
                   <a class="collection-item waves-effect black-text">
                   Bolo com nutella Inteiro
                   </a>
                   <a class="collection-item waves-effect black-text">Bolo de brigadeiro Inteiro</a>
                   <a class="collection-item waves-effect black-text">Açucarado Inteiro</a>
               </div>
             </div>

            <div class="section" id="bebidas">
                <h6 class="container brown-text">Cafes</h6>
                <div class="collection">
                   <a class="collection-item waves-effect black-text">Espresso</a>
                   <a class="collection-item waves-effect black-text">Capuccino</a>
                   <a class="collection-item waves-effect black-text">Mochacino</a>
                   <a class="collection-item waves-effect black-text">Cafe-com-leite</a>
               </div>
               <h6 class="container brown-text">Refrigerantes</h6>
                <div class="collection">
                   <a class="collection-item waves-effect black-text">Coca</a>
                   <a class="collection-item waves-effect black-text">Soda</a>
                   <a class="collection-item waves-effect black-text">Fanta Uva</a>
                   <a class="collection-item waves-effect black-text">Guarana</a>
               </div>
             </div>

            <div class="fixed-action-btn" >
               <a href="#confirmacao" id="confirmar" 
                class="btn-floating btn-large waves-effect 
                waves-light brown modal-trigger">
                   <i class="material-icons">done</i>
               </a>
            </div>

            <div class="modal modal-fixed-footer" id="confirmacao">
               <div class="modal-content">
                  <h5>Resumo do Pedido</h5>
                  <input type="number" class="validate" placeholder="Número da mesa" 
                  id="numero-mesa">
                  <blockquote id="resumo"></blockquote>              
               </div>
               <div class="modal-footer">
                    <button class="btn deep-orange waves-effect waves-light modal-close acao-finalizar">
                        Pedir
                    </button>
                     <button class="acao-limpar btn-flat waves-effect waves-red modal-close">
                        Cancelar
                    </button>
               </div>
            </div>

    <script src="js/jquery.min.js"></script>
    <script src="js/materialize.min.js"></script>
    <script src="js/app.js"></script>
    <script src="cordova.js"></script>
</body>
</html>

o que voces acham que pode ser?

3 respostas

Caramba, parece tudo correto.

Qual device vc ta testando? Android ou iOS? E rola um debug pra ver se não tem nenhum erro no console?

Se quiser fazer chutes, tenta mudar o XML e o JS pra usar o serviço de forma segura com essa URL: https://cozinha.herokuapp.com/

(já vi problemas no iOS sem https, não sei se é o caso)

solução!

Fiquei testando e não estava dando certo, testei de manha e funciono a única coisa que pensei que pudesse ser seria a rede wifi, mas testei novamente na rede wifi que estava dando problema e funciono. Acho que pode ser alguma alteração que fiz no acess que funciono, sabe quando você fica testando .... e não funciona e depois você mexe em algo e funciona rsrs pode ter sido isso . Sobre a navegação de telas exemplo uma tela de login e depois para uma listagem de itens desse login vai ter algum exemplo sobre isso em algum curso de desenvolvimento híbrido? como que funciona nesse caso teria que criar um login.html , telainicial.html ? ou faria tudo direto no index.html ?

Oi Felipe, geralmente fazemos essas navegações com algum framework de SPA. O novo curso de ionic mostra bem isso! Recomendo.