uma dúvida por exemplo é quanto ao arquivo app.js
talvez tenha me perdido na leitura mas ao final ele ficou assim:
$(’.collection’)
.on(‘click’,’.collection-item’, function(){
var nomeProduto = this.firstChild.textContent;
Materialize.toast(nomeProduto + ' Adicionado', 1000);
var $badge = $('.badge', this);
if ($badge.length === 0) {
$badge = $('<span class="badge brown-text">0</span>')
.appendTo(this);
}
$badge.text(parseInt($badge.text())+1);
})
.on(‘click’, ‘.badge’, function(){
$(this).remove();
return false;
});
$(’.scan-qrcode’).on(‘click’, function(){
cordova.plugins.barcodeScanner.scan(
function(resultado){
if (resultado.text) {
Materialize.toast('Mesa ' + resultado.text, 2000);
$('#numero-mesa').val(resultado.text);
}
},
function (error) {
Materialize.toast('Erro: ' + error, 3000, 'red-text');
}
);
});
$(’.modal-trigger’).leanModal();
$(’#confirmar’).on(‘click’, function(){
var texto = " ";
$('.badge').parent().each(function(){
texto += this.firstChild.textContent + ': ';
texto += this.lastChild.textContent + ', ';
});
$('#resumo').empty().text(texto);
});
$(’.acao-limpar’).on(‘click’, function() {
$('#numero-mesa').val('');
$('.badge').remove();
});
$(’.acao-finalizar’).on(‘click’, function() {
$.ajax({
url:'http://cozinhaapp.sergiolopes/novo-pedido',
data: {
mesa: $('#numero-mesa').val(),
pedido: $('#resumo').text()
},
error: function(erro){
Materialize.toast(erro.responseTex, 3000, 'red-text');
},
success: function(dados) {
Materialize.toast(dados, 2000);
$('#numero-mesa').val('');
$('.badge').remove();
}
});
});