Inicio de desarrollo de funcionalidad Facturas/Boletas y backup.
This commit is contained in:
parent
65d434b5fa
commit
2639d6303a
47
Backend/Pedidos/obtenerPedidosActuales.ts
Normal file
47
Backend/Pedidos/obtenerPedidosActuales.ts
Normal file
@ -0,0 +1,47 @@
|
||||
const obtenerPedidosActuales = (req:any, res:any) => {
|
||||
res.header('Access-Control-Allow-Origin', 'http://localhost:8081');
|
||||
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
|
||||
res.header('Access-Control-Allow-Headers', 'Content-Type');
|
||||
|
||||
const USER_ID = req.body.USER_ID;
|
||||
const storedUserId = req.session.USER_ID.toString();
|
||||
|
||||
console.log(`La comparacion: ${USER_ID} === ${storedUserId}. ${typeof USER_ID} y ${typeof storedUserId}`);
|
||||
|
||||
if (USER_ID === storedUserId) {
|
||||
|
||||
const SQL_CONNECT_DATA = require('../VARIABLES').sqlConnectData;
|
||||
const con = require('mysql').createConnection(SQL_CONNECT_DATA);
|
||||
|
||||
con.connect((err:any) => {
|
||||
if (err) {
|
||||
console.log(`Error al conectarse a la base de datos en obtenerPedidosActuales.ts 13.\n${err}`);
|
||||
res.send(`{"error": "Error al conectarse a la base de datos."}`);
|
||||
return;
|
||||
}
|
||||
|
||||
con.query(
|
||||
`SELECT BOLETA_ID, transacciones, horaEntrega FROM boletas WHERE USER_ID='${USER_ID}'
|
||||
ORDER BY BOLETA_ID DESC `,
|
||||
(err:any, response:any) => {
|
||||
if (err) {
|
||||
console.log(`Error al obtener las boletas del usuario ${USER_ID} en obtenerPedidosActuales.ts \
|
||||
23.\n${err}`);
|
||||
res.send("");
|
||||
return;
|
||||
}
|
||||
|
||||
res.send(JSON.stringify(response));
|
||||
res.end();
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
} else {
|
||||
res.send(`{"error": "El usuario que envia la peticion y el usuario logeado no coinciden."}`);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports.obtenerPedido = obtenerPedidosActuales;
|
@ -18,7 +18,7 @@ const exec = (nombre:string, email:string, pass:string, sesion:any) =>
|
||||
`INSERT INTO usuarios (GOOGLE_ID, nombre, email, img, carritoActual, contrasena, ROL)
|
||||
VALUES ('0','${nombre}', '${email}', '/img/usuario.png', '{}', '${pass}', 'user' )`,
|
||||
(err:any, respuesta:any) => {
|
||||
if (err) reject ('Error al ejecutar SQL. registrarUsuario.ts 22\n' + err);
|
||||
if (err) reject ('Error al ejecutar SQL. registrarUsuario.ts 21\n' + err);
|
||||
|
||||
/* El servidor me obligo a hacer esto en vez de usar SELECT LAST_INSERT_ID() */
|
||||
con.query(
|
||||
@ -35,8 +35,8 @@ const exec = (nombre:string, email:string, pass:string, sesion:any) =>
|
||||
sesion.ROL = 'user';
|
||||
|
||||
sesion.save((err:any) => {
|
||||
if (err)
|
||||
console.log(`Error :c\n${err}`)
|
||||
if (err) console.log(`Error :c\n${err}`);
|
||||
console.log("En teoria ya guarde la sesion....");
|
||||
});
|
||||
|
||||
const datos = {
|
||||
|
@ -1,21 +1,28 @@
|
||||
const validator = require('./google_validation.js').validator;
|
||||
|
||||
const crearUsuario = (con:any, data:object) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const crearUsuario = (con:any, data:object) =>
|
||||
new Promise((resolve, reject) => {
|
||||
con.query (
|
||||
`INSERT INTO usuarios (nombre, email, img, carritoActual, GOOGLE_ID, ROL)\
|
||||
VALUES ('${(data as any)["nombreUsuario"]}', '${(data as any)["emailUsuario"]}',
|
||||
'${(data as any)["imagenUsuario"]}', '{}', '${(data as any)["googleID"]}', 'user')`,
|
||||
(err:any, res:string) => {
|
||||
if (err) {
|
||||
reject("Error al ejecutar query SQL (revisarUsuarioG.ts fila 18))...\n" + err);
|
||||
reject("Error al ejecutar query SQL (revisarUsuarioG.ts fila 11))...\n" + err);
|
||||
}
|
||||
console.log("Resultado de añadir usuario a la BBDD (revisarUsuarioG.ts 22):\n" + res);
|
||||
resolve("Exito.");
|
||||
|
||||
/* Luego de insertar el usuario, como GET_LAST_INDEX no funciona, otra query obtiene el num de usuario */
|
||||
con.query(
|
||||
`SELECT USER_ID FROM usuarios WHERE GOOGLE_ID='${(data as any)["googleID"]}'`,
|
||||
(err:any, res:any) => {
|
||||
if (err) reject(`Error al ejecutar query SQL en revisarUsuarios.ts 18.\n${err}`);
|
||||
|
||||
resolve(res[0]["USER_ID"]);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const revisarUsuarioG = (usuario:object, sesion:any) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -39,18 +46,48 @@ const revisarUsuarioG = (usuario:object, sesion:any) => {
|
||||
if (err) {
|
||||
reject("Error al ejecutar query SQL");
|
||||
}
|
||||
|
||||
const respuestaBD:string = JSON.stringify(response);
|
||||
if (respuestaBD === '[]') {
|
||||
/* El usuario no existe :D */
|
||||
crearUsuario(con, {nombreUsuario, emailUsuario, imagenUsuario, googleID})
|
||||
.then( () => {
|
||||
.then( (res:any) => {
|
||||
|
||||
/* Almacenar la sesion :c */
|
||||
sesion.nombre = nombreUsuario;
|
||||
sesion.email = emailUsuario;
|
||||
sesion.img = imagenUsuario;
|
||||
sesion.USER_ID = res[0]["USER_ID"];
|
||||
sesion.ROL = "user";
|
||||
sesion.carritoActual = "{}";
|
||||
|
||||
sesion.save((err:any) => {
|
||||
if (err)
|
||||
console.log(`Error al guardar sesion :c\n${err}`)
|
||||
});
|
||||
|
||||
resolve(`{ "nombre": "${nombreUsuario}", "email": "${emailUsuario}", "img": "${imagenUsuario}",
|
||||
"carrito": {}, "rol": "user"}`);
|
||||
"carrito": {}, "rol": "user", "USER_ID": "${res}"}`);
|
||||
})
|
||||
.catch((msg:string) => {
|
||||
reject("Error al crear el usuario...\n" + msg);
|
||||
})
|
||||
} else {
|
||||
/* Almacenar la sesion :c */
|
||||
sesion.nombre = nombreUsuario;
|
||||
sesion.email = emailUsuario;
|
||||
sesion.img = imagenUsuario;
|
||||
sesion.USER_ID = response[0]["USER_ID"];
|
||||
sesion.ROL = response[0]["ROL"];
|
||||
sesion.carritoActual = response[0]["carritoActual"];
|
||||
|
||||
sesion.save((err:any) => {
|
||||
if (err)
|
||||
console.log(`Error :c\n${err}`)
|
||||
});
|
||||
|
||||
console.log(`Respuesta servidor:\n${respuestaBD}`);
|
||||
|
||||
resolve(JSON.stringify(response[0]));
|
||||
}
|
||||
});
|
||||
|
@ -27,6 +27,7 @@ function revisarSesion(req:any, res:any) {
|
||||
|
||||
res.send(JSON.stringify(data));
|
||||
} else {
|
||||
console.log("Hmmph, no hay nadie logeado....");
|
||||
res.send(`{ "logged": false }`);
|
||||
}
|
||||
}
|
||||
|
3
app.ts
3
app.ts
@ -1,3 +1,5 @@
|
||||
require('@google-cloud/debug-agent').start();
|
||||
|
||||
const expressr = require('express');
|
||||
const apuri = expressr();
|
||||
const session = require('express-session');
|
||||
@ -18,6 +20,7 @@ apuri.post('/log-inG', require('./Backend/revisarUsuarioG.js').revisarUsuarioG);
|
||||
apuri.post('/usuarios', require('./Backend/usuarios.js').usuarios);
|
||||
apuri.post('/registro', require('./Backend/registrarUsuario.js').registrar);
|
||||
apuri.post('/sesion', require('./Backend/usuarioLogueado').revisarSesion);
|
||||
apuri.post('/pedidos/actual', require('./Backend/Pedidos/obtenerPedidosActuales').obtenerPedido);
|
||||
|
||||
apuri.get('/');
|
||||
|
||||
|
248
package-lock.json
generated
248
package-lock.json
generated
@ -769,6 +769,108 @@
|
||||
"to-fast-properties": "2.0.0"
|
||||
}
|
||||
},
|
||||
"@google-cloud/common": {
|
||||
"version": "0.23.0",
|
||||
"resolved": "https://registry.npmjs.org/@google-cloud/common/-/common-0.23.0.tgz",
|
||||
"integrity": "sha512-RhHjlFzbvjFobVUeeziX0789SJ2j1XlAaCLK25766G1FyAsKCpfWu2XJSV85fRQGiet79Hnlx9ZFSXzAVCpBOw==",
|
||||
"requires": {
|
||||
"@google-cloud/projectify": "0.3.1",
|
||||
"@google-cloud/promisify": "0.3.1",
|
||||
"@types/duplexify": "3.5.0",
|
||||
"@types/request": "2.48.0",
|
||||
"arrify": "1.0.1",
|
||||
"duplexify": "3.6.0",
|
||||
"ent": "2.2.0",
|
||||
"extend": "3.0.2",
|
||||
"google-auth-library": "1.6.1",
|
||||
"is": "3.2.1",
|
||||
"pify": "4.0.1",
|
||||
"retry-request": "4.0.0",
|
||||
"through2": "2.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"gcp-metadata": {
|
||||
"version": "0.6.3",
|
||||
"resolved": "http://registry.npmjs.org/gcp-metadata/-/gcp-metadata-0.6.3.tgz",
|
||||
"integrity": "sha512-MSmczZctbz91AxCvqp9GHBoZOSbJKAICV7Ow/AIWSJZRrRchUd5NL1b2P4OfP+4m490BEUPhhARfpHdqCxuCvg==",
|
||||
"requires": {
|
||||
"axios": "0.18.0",
|
||||
"extend": "3.0.2",
|
||||
"retry-axios": "0.3.2"
|
||||
}
|
||||
},
|
||||
"google-auth-library": {
|
||||
"version": "1.6.1",
|
||||
"resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-1.6.1.tgz",
|
||||
"integrity": "sha512-jYiWC8NA9n9OtQM7ANn0Tk464do9yhKEtaJ72pKcaBiEwn4LwcGYIYOfwtfsSm3aur/ed3tlSxbmg24IAT6gAg==",
|
||||
"requires": {
|
||||
"axios": "0.18.0",
|
||||
"gcp-metadata": "0.6.3",
|
||||
"gtoken": "2.3.0",
|
||||
"jws": "3.1.5",
|
||||
"lodash.isstring": "4.0.1",
|
||||
"lru-cache": "4.1.3",
|
||||
"retry-axios": "0.3.2"
|
||||
}
|
||||
},
|
||||
"pify": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
|
||||
"integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"@google-cloud/debug-agent": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@google-cloud/debug-agent/-/debug-agent-3.0.0.tgz",
|
||||
"integrity": "sha512-CwwQvCFYAPE6KVCpLmOAc2/EBRFy1AsMDiGtvvHg83f628eKwLQj+xyn2iERgZHpH92GzdJhiw0sl0VKl81VYQ==",
|
||||
"requires": {
|
||||
"@google-cloud/common": "0.23.0",
|
||||
"acorn": "5.7.3",
|
||||
"coffeescript": "2.3.2",
|
||||
"console-log-level": "1.4.0",
|
||||
"extend": "3.0.2",
|
||||
"findit2": "2.2.3",
|
||||
"gcp-metadata": "0.7.0",
|
||||
"lodash": "4.17.11",
|
||||
"p-limit": "2.0.0",
|
||||
"semver": "5.6.0",
|
||||
"source-map": "0.6.1",
|
||||
"split": "1.0.1",
|
||||
"teeny-request": "3.11.0",
|
||||
"util.promisify": "1.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"p-limit": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.0.0.tgz",
|
||||
"integrity": "sha512-fl5s52lI5ahKCernzzIyAP0QAZbGIovtVHGwpcu1Jr/EpzLVDI2myISHwGqK7m8uQFugVWSrbxH7XnhGtvEc+A==",
|
||||
"requires": {
|
||||
"p-try": "2.0.0"
|
||||
}
|
||||
},
|
||||
"p-try": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.0.0.tgz",
|
||||
"integrity": "sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ=="
|
||||
},
|
||||
"source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"@google-cloud/projectify": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@google-cloud/projectify/-/projectify-0.3.1.tgz",
|
||||
"integrity": "sha512-HvugQ8fC87kTNGs9ZQTTEwrJt67zfero9lDQCukJvAC2IuIyS1/6h4NqHBZK9lOnsmfHTQYhPq7GD2vzWEcm6g=="
|
||||
},
|
||||
"@google-cloud/promisify": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@google-cloud/promisify/-/promisify-0.3.1.tgz",
|
||||
"integrity": "sha512-QzB0/IMvB0eFxFK7Eqh+bfC8NLv3E9ScjWQrPOk6GgfNroxcVITdTlT8NRsRrcp5+QQJVPLkRqKG0PUdaWXmHw=="
|
||||
},
|
||||
"@intervolga/optimize-cssnano-plugin": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@intervolga/optimize-cssnano-plugin/-/optimize-cssnano-plugin-1.0.6.tgz",
|
||||
@ -805,6 +907,11 @@
|
||||
"@types/node": "10.12.1"
|
||||
}
|
||||
},
|
||||
"@types/caseless": {
|
||||
"version": "0.12.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/caseless/-/caseless-0.12.1.tgz",
|
||||
"integrity": "sha512-FhlMa34NHp9K5MY1Uz8yb+ZvuX0pnvn3jScRSNAb75KHGB8d3rEU6hqMs3Z2vjuytcMfRg6c5CHMc3wtYyD2/A=="
|
||||
},
|
||||
"@types/connect": {
|
||||
"version": "3.4.32",
|
||||
"resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.32.tgz",
|
||||
@ -813,6 +920,14 @@
|
||||
"@types/node": "10.12.1"
|
||||
}
|
||||
},
|
||||
"@types/duplexify": {
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/duplexify/-/duplexify-3.5.0.tgz",
|
||||
"integrity": "sha512-+aZCCdxuR/Q6n58CBkXyqGqimIqpYUcFLfBXagXv7e9TdJUevqkKhzopBuRz3RB064sQxnJnhttHOkK/O93Ouw==",
|
||||
"requires": {
|
||||
"@types/node": "10.12.1"
|
||||
}
|
||||
},
|
||||
"@types/events": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "http://registry.npmjs.org/@types/events/-/events-1.2.0.tgz",
|
||||
@ -838,6 +953,14 @@
|
||||
"@types/range-parser": "1.2.2"
|
||||
}
|
||||
},
|
||||
"@types/form-data": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz",
|
||||
"integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==",
|
||||
"requires": {
|
||||
"@types/node": "10.12.1"
|
||||
}
|
||||
},
|
||||
"@types/mime": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-2.0.0.tgz",
|
||||
@ -861,6 +984,17 @@
|
||||
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.2.tgz",
|
||||
"integrity": "sha512-HtKGu+qG1NPvYe1z7ezLsyIaXYyi8SoAVqWDZgDQ8dLrsZvSzUNCwZyfX33uhWxL/SU0ZDQZ3nwZ0nimt507Kw=="
|
||||
},
|
||||
"@types/request": {
|
||||
"version": "2.48.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/request/-/request-2.48.0.tgz",
|
||||
"integrity": "sha512-KnfoOtqXKllSqfXSEvGTd8KDkNlpHs+PWr6I6XiEIWk/jckH3pNmWDXNFZyPkB9wApb8vzDq2wMByM/0GFSmXg==",
|
||||
"requires": {
|
||||
"@types/caseless": "0.12.1",
|
||||
"@types/form-data": "2.2.1",
|
||||
"@types/node": "10.12.1",
|
||||
"@types/tough-cookie": "2.3.4"
|
||||
}
|
||||
},
|
||||
"@types/serve-static": {
|
||||
"version": "1.13.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.2.tgz",
|
||||
@ -870,6 +1004,11 @@
|
||||
"@types/mime": "2.0.0"
|
||||
}
|
||||
},
|
||||
"@types/tough-cookie": {
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-2.3.4.tgz",
|
||||
"integrity": "sha512-Set5ZdrAaKI/qHdFlVMgm/GsAv/wkXhSTuZFkJ+JI7HK+wIkIlOaUXSXieIvJ0+OvGIqtREFoE+NHJtEq0gtEw=="
|
||||
},
|
||||
"@vue/babel-preset-app": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@vue/babel-preset-app/-/babel-preset-app-3.0.5.tgz",
|
||||
@ -1253,8 +1392,7 @@
|
||||
"acorn": {
|
||||
"version": "5.7.3",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz",
|
||||
"integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==",
|
||||
"dev": true
|
||||
"integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw=="
|
||||
},
|
||||
"acorn-dynamic-import": {
|
||||
"version": "3.0.0",
|
||||
@ -1748,8 +1886,7 @@
|
||||
"arrify": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz",
|
||||
"integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=",
|
||||
"dev": true
|
||||
"integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0="
|
||||
},
|
||||
"asn1": {
|
||||
"version": "0.2.4",
|
||||
@ -2847,6 +2984,11 @@
|
||||
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
|
||||
"dev": true
|
||||
},
|
||||
"coffeescript": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/coffeescript/-/coffeescript-2.3.2.tgz",
|
||||
"integrity": "sha512-YObiFDoukx7qPBi/K0kUKyntEZDfBQiqs/DbrR1xzASKOBjGT7auD85/DiPeRr9k++lRj7l3uA9TNMLfyfcD/Q=="
|
||||
},
|
||||
"collection-visit": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz",
|
||||
@ -3005,6 +3147,11 @@
|
||||
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
|
||||
"dev": true
|
||||
},
|
||||
"console-log-level": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/console-log-level/-/console-log-level-1.4.0.tgz",
|
||||
"integrity": "sha1-QDWBi+6jflhQoMA8jUUMpfLNEhc="
|
||||
},
|
||||
"consolidate": {
|
||||
"version": "0.15.1",
|
||||
"resolved": "https://registry.npmjs.org/consolidate/-/consolidate-0.15.1.tgz",
|
||||
@ -3562,7 +3709,6 @@
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz",
|
||||
"integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"object-keys": "1.0.12"
|
||||
}
|
||||
@ -3818,7 +3964,6 @@
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.6.0.tgz",
|
||||
"integrity": "sha512-fO3Di4tBKJpYTFHAxTU00BcfWMY9w24r/x21a6rZRbsD/ToUgGxsMbiGRmB7uVAXeGKXD9MwiLZa5E97EVgIRQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"end-of-stream": "1.4.1",
|
||||
"inherits": "2.0.3",
|
||||
@ -3898,7 +4043,6 @@
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz",
|
||||
"integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"once": "1.4.0"
|
||||
}
|
||||
@ -3914,6 +4058,11 @@
|
||||
"tapable": "1.1.0"
|
||||
}
|
||||
},
|
||||
"ent": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz",
|
||||
"integrity": "sha1-6WQhkyWiHQX0RGai9obtbOX13R0="
|
||||
},
|
||||
"entities": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz",
|
||||
@ -3951,7 +4100,6 @@
|
||||
"version": "1.12.0",
|
||||
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.12.0.tgz",
|
||||
"integrity": "sha512-C8Fx/0jFmV5IPoMOFPA9P9G5NtqW+4cOPit3MIuvR2t7Ag2K15EJTpxnHAYTzL+aYQJIESYeXZmDBfOBE1HcpA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"es-to-primitive": "1.2.0",
|
||||
"function-bind": "1.1.1",
|
||||
@ -3964,7 +4112,6 @@
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz",
|
||||
"integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-callable": "1.1.4",
|
||||
"is-date-object": "1.0.1",
|
||||
@ -4699,6 +4846,11 @@
|
||||
"locate-path": "2.0.0"
|
||||
}
|
||||
},
|
||||
"findit2": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/findit2/-/findit2-2.2.3.tgz",
|
||||
"integrity": "sha1-WKRmaX34piBc39vzlVNri9d3pfY="
|
||||
},
|
||||
"flatten": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/flatten/-/flatten-1.0.2.tgz",
|
||||
@ -5436,8 +5588,7 @@
|
||||
"function-bind": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
||||
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
|
||||
"dev": true
|
||||
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
|
||||
},
|
||||
"gauge": {
|
||||
"version": "2.7.4",
|
||||
@ -5701,7 +5852,6 @@
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
|
||||
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"function-bind": "1.1.1"
|
||||
}
|
||||
@ -5732,8 +5882,7 @@
|
||||
"has-symbols": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz",
|
||||
"integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=",
|
||||
"dev": true
|
||||
"integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q="
|
||||
},
|
||||
"has-unicode": {
|
||||
"version": "2.0.1",
|
||||
@ -6596,6 +6745,11 @@
|
||||
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.8.0.tgz",
|
||||
"integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4="
|
||||
},
|
||||
"is": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is/-/is-3.2.1.tgz",
|
||||
"integrity": "sha1-0Kwq1V63sL7JJqUmb2xmKqqD3KU="
|
||||
},
|
||||
"is-absolute-url": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-absolute-url/-/is-absolute-url-2.1.0.tgz",
|
||||
@ -6643,8 +6797,7 @@
|
||||
"is-callable": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz",
|
||||
"integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==",
|
||||
"dev": true
|
||||
"integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA=="
|
||||
},
|
||||
"is-ci": {
|
||||
"version": "1.2.1",
|
||||
@ -6681,8 +6834,7 @@
|
||||
"is-date-object": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz",
|
||||
"integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=",
|
||||
"dev": true
|
||||
"integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY="
|
||||
},
|
||||
"is-descriptor": {
|
||||
"version": "0.1.6",
|
||||
@ -6832,7 +6984,6 @@
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz",
|
||||
"integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"has": "1.0.3"
|
||||
}
|
||||
@ -6862,7 +7013,6 @@
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz",
|
||||
"integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"has-symbols": "1.0.0"
|
||||
}
|
||||
@ -7178,8 +7328,7 @@
|
||||
"lodash": {
|
||||
"version": "4.17.11",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
|
||||
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==",
|
||||
"dev": true
|
||||
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg=="
|
||||
},
|
||||
"lodash.assign": {
|
||||
"version": "4.2.0",
|
||||
@ -7767,6 +7916,11 @@
|
||||
"lower-case": "1.1.4"
|
||||
}
|
||||
},
|
||||
"node-fetch": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.2.0.tgz",
|
||||
"integrity": "sha512-OayFWziIxiHY8bCUyLX6sTpDH8Jsbp4FfYd1j1f7vZyfgkcOnAyM4oQR16f8a0s7Gl/viMGRey8eScYk4V4EZA=="
|
||||
},
|
||||
"node-forge": {
|
||||
"version": "0.7.5",
|
||||
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.7.5.tgz",
|
||||
@ -8118,8 +8272,7 @@
|
||||
"object-keys": {
|
||||
"version": "1.0.12",
|
||||
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz",
|
||||
"integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag==",
|
||||
"dev": true
|
||||
"integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag=="
|
||||
},
|
||||
"object-visit": {
|
||||
"version": "1.0.1",
|
||||
@ -8154,7 +8307,6 @@
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz",
|
||||
"integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"define-properties": "1.1.3",
|
||||
"es-abstract": "1.12.0"
|
||||
@ -8222,7 +8374,6 @@
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"wrappy": "1.0.2"
|
||||
}
|
||||
@ -10109,6 +10260,14 @@
|
||||
"resolved": "https://registry.npmjs.org/retry-axios/-/retry-axios-0.3.2.tgz",
|
||||
"integrity": "sha512-jp4YlI0qyDFfXiXGhkCOliBN1G7fRH03Nqy8YdShzGqbY5/9S2x/IR6C88ls2DFkbWuL3ASkP7QD3pVrNpPgwQ=="
|
||||
},
|
||||
"retry-request": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/retry-request/-/retry-request-4.0.0.tgz",
|
||||
"integrity": "sha512-S4HNLaWcMP6r8E4TMH52Y7/pM8uNayOcTDDQNBwsCccL1uI+Ol2TljxRDPzaNfbhOB30+XWP5NnZkB3LiJxi1w==",
|
||||
"requires": {
|
||||
"through2": "2.0.3"
|
||||
}
|
||||
},
|
||||
"rgb-regex": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/rgb-regex/-/rgb-regex-1.0.1.tgz",
|
||||
@ -10917,6 +11076,14 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"split": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz",
|
||||
"integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==",
|
||||
"requires": {
|
||||
"through": "2.3.8"
|
||||
}
|
||||
},
|
||||
"split-string": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz",
|
||||
@ -11052,8 +11219,7 @@
|
||||
"stream-shift": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz",
|
||||
"integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=",
|
||||
"dev": true
|
||||
"integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI="
|
||||
},
|
||||
"string-width": {
|
||||
"version": "2.1.1",
|
||||
@ -11208,6 +11374,16 @@
|
||||
"inherits": "2.0.3"
|
||||
}
|
||||
},
|
||||
"teeny-request": {
|
||||
"version": "3.11.0",
|
||||
"resolved": "https://registry.npmjs.org/teeny-request/-/teeny-request-3.11.0.tgz",
|
||||
"integrity": "sha512-bBULmB5Lk2RaEdz2MJMl4+T5+IHSZojDV9ZrxcIv5q1xJvHwCqhfS5nE3JR1D+a4cl6Anhj61CHNuiTM6SRnyg==",
|
||||
"requires": {
|
||||
"https-proxy-agent": "2.2.1",
|
||||
"node-fetch": "2.2.0",
|
||||
"uuid": "3.3.2"
|
||||
}
|
||||
},
|
||||
"thread-loader": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/thread-loader/-/thread-loader-1.2.0.tgz",
|
||||
@ -11230,11 +11406,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"through": {
|
||||
"version": "2.3.8",
|
||||
"resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz",
|
||||
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU="
|
||||
},
|
||||
"through2": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz",
|
||||
"integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"readable-stream": "2.3.6",
|
||||
"xtend": "4.0.1"
|
||||
@ -11767,7 +11947,6 @@
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/util.promisify/-/util.promisify-1.0.0.tgz",
|
||||
"integrity": "sha512-i+6qA2MPhvoKLuxnJNpXAGhg7HphQOSUq2LKMZD0m15EiskXUkMvKdF4Uui0WYeCUGea+o2cw/ZuwehtfsrNkA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"define-properties": "1.1.3",
|
||||
"object.getownpropertydescriptors": "2.0.3"
|
||||
@ -11787,8 +11966,7 @@
|
||||
"uuid": {
|
||||
"version": "3.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz",
|
||||
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==",
|
||||
"dev": true
|
||||
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
|
||||
},
|
||||
"validate-npm-package-license": {
|
||||
"version": "3.0.4",
|
||||
@ -12528,8 +12706,7 @@
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
|
||||
"dev": true
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||
},
|
||||
"ws": {
|
||||
"version": "4.1.0",
|
||||
@ -12550,8 +12727,7 @@
|
||||
"xtend": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
|
||||
"integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=",
|
||||
"dev": true
|
||||
"integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68="
|
||||
},
|
||||
"y18n": {
|
||||
"version": "4.0.0",
|
||||
|
@ -8,6 +8,7 @@
|
||||
"start": "node app.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@google-cloud/debug-agent": "^3.0.0",
|
||||
"@types/express": "^4.16.0",
|
||||
"@types/mysql": "^2.15.5",
|
||||
"@types/node": "^10.12.1",
|
||||
|
@ -7,6 +7,7 @@
|
||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||
<script src="https://apis.google.com/js/platform.js" async defer></script>
|
||||
<meta name="google-signin-client_id" content="443321715214-9joe4c9l00osc6qcc4l0i2k3420jvb7q.apps.googleusercontent.com">
|
||||
|
||||
<title>L'Assiete</title>
|
||||
</head>
|
||||
<body>
|
||||
|
33
src/components/botonCerrarSesion.vue
Normal file
33
src/components/botonCerrarSesion.vue
Normal file
@ -0,0 +1,33 @@
|
||||
<template>
|
||||
<a v-on:click.prevent="cerrarSesion" title="Cerrar Sesion">Cerrar Sesion</a>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "botonCerrarSesion",
|
||||
methods: {
|
||||
cerrarSesion: function () {
|
||||
const scriptGAPI = document.getElementById("googleGAPI");
|
||||
|
||||
try {
|
||||
gapi.auth2.getAuthInstance().signOut()
|
||||
.then(() =>
|
||||
console.log('User signed out.')
|
||||
);
|
||||
} catch (e) {
|
||||
let scr = document.createElement("script");
|
||||
scr.src = "https://apis.google.com/js/platform.js";
|
||||
scr.onload = renderButton;
|
||||
scr.defer = true;
|
||||
document.head.appendChild(scr);
|
||||
|
||||
this.cerrarSesion();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
@ -7,13 +7,24 @@
|
||||
<li><router-link to="/mi-cuenta/">Mi cuenta</router-link></li>
|
||||
<li><router-link to="/carrito/">Mi carrito</router-link></li>
|
||||
<li><router-link to="/mi-pedido/">Mis pedidos</router-link></li>
|
||||
<li class="right" v-if="usuarioLogeado"><boton-cerrar-sesion /></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import BotonCerrarSesion from './botonCerrarSesion'
|
||||
|
||||
export default {
|
||||
name: 'HeaderMini'
|
||||
name: 'HeaderMini',
|
||||
components: {
|
||||
'boton-cerrar-sesion': BotonCerrarSesion
|
||||
},
|
||||
computed: {
|
||||
usuarioLogeado: function () {
|
||||
return window.usuarioActual[0]["logged"];
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
16
src/components/pedido.vue
Normal file
16
src/components/pedido.vue
Normal file
@ -0,0 +1,16 @@
|
||||
<template>
|
||||
<div class="pedido">
|
||||
Este es un pedido we v:
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "pedido"
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="sass">
|
||||
.pedido
|
||||
padding: 20px
|
||||
</style>
|
@ -407,3 +407,8 @@ input
|
||||
text-align: center
|
||||
color: white
|
||||
font-size: large
|
||||
|
||||
.irAlCarrito
|
||||
text-decoration: underline
|
||||
color: white
|
||||
cursor: pointer
|
||||
|
@ -10,3 +10,9 @@ function onSignIn(googleUser:any) {
|
||||
};
|
||||
xhr.send('idtoken=' + id_token);
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
window.irAlCarro = () => {
|
||||
// @ts-ignore
|
||||
window.elRouter.push('/carrito/');
|
||||
};
|
@ -1,8 +1,8 @@
|
||||
const conexion_backend = "http://localhost:8080";
|
||||
const conexion_gcloud = "";
|
||||
const conexion_gcloud = "https://lassiete-unsa.appspot.com/";
|
||||
|
||||
/* De este estilo porque por alguna razon a babel no le agrado module.exports en este archivo. */
|
||||
export default conexion_backend;
|
||||
export default conexion_gcloud;
|
||||
|
||||
|
||||
// module.exports.conexion = conexion_backend;
|
@ -64,7 +64,8 @@
|
||||
<br>
|
||||
</div>
|
||||
<div id="pantalla-carga" pantalla-activa="false">
|
||||
Trabajando... <br>
|
||||
Iniciando Sesión...<br>
|
||||
<br>
|
||||
<div class="preloader-wrapper active center" id="esfera-carga">
|
||||
<div class="spinner-layer spinner-blue">
|
||||
<div class="circle-clipper left">
|
||||
|
@ -25,7 +25,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
We v:
|
||||
<pedido v-for="pedido in pedidos"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -38,24 +38,63 @@
|
||||
import NavBar from '../components/navBar'
|
||||
import LoginBar from '../components/navBarInicioSesion'
|
||||
import MiFooter from '../components/mi-footer'
|
||||
import Pedido from '../components/pedido'
|
||||
import conexion from '../variables';
|
||||
|
||||
export default {
|
||||
name: "MiPedido",
|
||||
data: function () {
|
||||
return {
|
||||
usuario: window.usuarioActual[0]
|
||||
usuario: window.usuarioActual[0],
|
||||
pedidos: []
|
||||
}
|
||||
},
|
||||
components: {
|
||||
'header-mini': HeaderMini,
|
||||
'nav-bar': NavBar,
|
||||
'login-bar': LoginBar,
|
||||
'mi-footer': MiFooter
|
||||
'mi-footer': MiFooter,
|
||||
'pedido': Pedido
|
||||
},
|
||||
computed: {
|
||||
usuarioNoLogeado: function () {
|
||||
return !this.usuario.logged;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
obtenerPedidos: function () {
|
||||
let vm = this;
|
||||
const usuarioLogueado = !this.usuario.logged;
|
||||
return new Promise((resolve, reject) => {
|
||||
if ( usuarioLogueado ) {
|
||||
reject("Usuario no logeado.");
|
||||
return;
|
||||
}
|
||||
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open("POST",`${conexion}/pedidos/actual`);
|
||||
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
|
||||
xhr.onload = () => {
|
||||
console.log(`Esta es mi respuesta we :3\n${xhr.responseText}`);
|
||||
resolve(xhr.responseText);
|
||||
};
|
||||
|
||||
xhr.send(`USER_ID=${vm.usuario["USER_ID"]}`);
|
||||
});
|
||||
}
|
||||
},
|
||||
created: function () {
|
||||
let vm = this;
|
||||
this.obtenerPedidos()
|
||||
.then(response => {
|
||||
while (vm.pedidos.pop() !== 0);
|
||||
|
||||
const data = JSON.parse(response);
|
||||
for (item of data) {
|
||||
vm.pedidos.push(item);
|
||||
}
|
||||
})
|
||||
.catch(reason => console.log(`Obtener pedidos desde el servidor rechazado. Razón: ${reason}`));
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -123,7 +123,7 @@
|
||||
const obj = JSON.parse(JSON.stringify(plato));
|
||||
obj["cantidad"] = cantidad;
|
||||
carritoUsuario.push(obj);
|
||||
M.toast({html: 'Añadido al carrito'})
|
||||
M.toast({html: `Añadido al carrito. <span onclick="window.irAlCarro()" class="irAlCarrito">Ir al carrito</span>`})
|
||||
},
|
||||
aumentarCantidad: function (id) {
|
||||
const elem = document.getElementById(id);
|
||||
@ -147,5 +147,5 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
<style scoped lang="sass">
|
||||
</style>
|
@ -74,9 +74,14 @@
|
||||
</div>
|
||||
<br>
|
||||
<br>
|
||||
<a class="carrito--precio--contenido--botonPagar">
|
||||
<div style="text-align: center">
|
||||
<a class="carrito--precio--contenido--botonPagar" v-if="usuarioLogeado">
|
||||
Completar Transaccion
|
||||
</a>
|
||||
<router-link to="/iniciar-sesion/" v-else class="carrito__precio__usuarioNoLogeado hoverable">
|
||||
Inicia Sesion o Regístrate para continuar.
|
||||
</router-link>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
No hay nada en tu carrito de compras :c
|
||||
@ -99,7 +104,6 @@
|
||||
import MiFooter from '@/components/mi-footer'
|
||||
import NavBarInicioSesion from '../components/navBarInicioSesion.vue';
|
||||
|
||||
|
||||
export default {
|
||||
name: 'Carrito',
|
||||
components: {
|
||||
@ -140,6 +144,9 @@
|
||||
}
|
||||
return false;
|
||||
},
|
||||
usuarioLogeado: function () {
|
||||
return window.usuarioActual[0]["logged"];
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
restarCantidad: function (elem) {
|
||||
@ -156,5 +163,12 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
<style scoped lang="sass">
|
||||
.carrito__precio__usuarioNoLogeado
|
||||
display: inline-block
|
||||
background-color: green
|
||||
color: white
|
||||
border-radius: 3px
|
||||
padding: 10px
|
||||
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user