barra de busqeda
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
<template>
|
||||
<div class="divMaster row mb-5">
|
||||
<div class="col-10 offset-1 d-flex flex-wrap justify-content-center">
|
||||
<div
|
||||
class="card m-3"
|
||||
style="width: 12rem;"
|
||||
v-bind:key="libro.id"
|
||||
v-for="libro in Libros"
|
||||
@click="descripcion(libro.id)"
|
||||
>
|
||||
<router-link :to="{ path: 'home' }" class="textt">
|
||||
<img :src="libro.img" class="card-img-top rounded" alt="libro" />
|
||||
<div class="card-body cd textt">
|
||||
<p class="card-text textt">
|
||||
{{ libro.title }}
|
||||
</p>
|
||||
</div>
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from "axios";
|
||||
import config from "../config/config.js";
|
||||
export default {
|
||||
components: {},
|
||||
|
||||
data() {
|
||||
return {
|
||||
categoria: "",
|
||||
Libros: []
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async descripcion(idLibro) {
|
||||
localStorage.clear();
|
||||
window.localStorage.setItem("idLibro", idLibro);
|
||||
this.$router.push("/desc");
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
let path = `${config.api}`;
|
||||
this.categoria = window.localStorage.getItem("categoria");
|
||||
try {
|
||||
let similares = await axios.get(
|
||||
`${config.api}/temaLibro?categoria=${this.categoria}`
|
||||
);
|
||||
similares = similares.data.data;
|
||||
console.log(` este es el resutlado${similares}`);
|
||||
for (let i = 0; i < similares.length; i++) {
|
||||
let config = {
|
||||
// example url
|
||||
url: `${path}/libroImagen?idLibro=${(i % 4) + 1}`,
|
||||
method: "GET",
|
||||
responseType: "blob"
|
||||
};
|
||||
await axios(config).then(response => {
|
||||
let reader = new FileReader();
|
||||
reader.readAsDataURL(response.data);
|
||||
reader.onload = () => {
|
||||
this.Libros.push({
|
||||
id: similares[i].idLibro,
|
||||
title: similares[i].titulo,
|
||||
img: reader.result
|
||||
});
|
||||
//this.Libros[i].img = reader.result;
|
||||
};
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(`Ocurrio un error ${error}`);
|
||||
}
|
||||
},
|
||||
beforeCreate() {
|
||||
if (!window.localStorage.getItem("categoria")) this.$router.push("/");
|
||||
else this.categoria = window.localStorage.getItem("categoria");
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.divMaster {
|
||||
height: auto;
|
||||
}
|
||||
.card {
|
||||
border: none !important;
|
||||
border-bottom: 5px solid #1b3d70 !important;
|
||||
}
|
||||
a {
|
||||
text-decoration: none !important;
|
||||
color: black;
|
||||
}
|
||||
</style>
|
||||
+50
-1
@@ -104,6 +104,7 @@
|
||||
placeholder="Buscar"
|
||||
aria-label="Recipient's username"
|
||||
aria-describedby="basic-addon2"
|
||||
v-model="nombre"
|
||||
/>
|
||||
<div class="input-group-append reDer bg-white">
|
||||
<button class="btn my-0" type="submit">
|
||||
@@ -126,6 +127,18 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div>-->
|
||||
<div v-if="nombre.length > 2">
|
||||
<ul
|
||||
class="list-group"
|
||||
v-for="item in buscarLibro"
|
||||
v-bind:key="item.idLibro"
|
||||
>
|
||||
<li class="list-group-item" @click="descripcion(item.idLibro)">
|
||||
{{ item.titulo }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</nav>
|
||||
</div>
|
||||
@@ -133,13 +146,25 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from "axios";
|
||||
import config from "../config/config.js";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
isExist: true
|
||||
isExist: true,
|
||||
libros: [],
|
||||
nombre: ""
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async descripcion(idLibro) {
|
||||
console.log(` Este es el id del libro ${idLibro}`);
|
||||
localStorage.clear();
|
||||
window.localStorage.setItem("idLibro", idLibro);
|
||||
this.$router.push("/desc").catch(() => {
|
||||
location.reload();
|
||||
});
|
||||
},
|
||||
inicio() {
|
||||
this.$router.push("/").catch(() => {
|
||||
location.reload();
|
||||
@@ -147,10 +172,29 @@ export default {
|
||||
},
|
||||
async tema(categoria) {
|
||||
window.localStorage.setItem("categoria", categoria);
|
||||
this.$router.push("/tema").catch(() => {
|
||||
location.reload();
|
||||
});
|
||||
},
|
||||
method() {
|
||||
this.isExist = !this.isExist;
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
let path = `${config.api}`;
|
||||
try {
|
||||
let libros = await axios.get(`${path}/getLibros`);
|
||||
this.libros = await libros.data.data;
|
||||
} catch (error) {
|
||||
console.log(`Error ${error}`);
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
buscarLibro: function() {
|
||||
return this.libros.filter(item =>
|
||||
item.titulo.toLowerCase().includes(this.nombre.toLowerCase())
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -173,6 +217,11 @@ nav {
|
||||
.azulUnam {
|
||||
background-color: #1e3c70;
|
||||
}
|
||||
|
||||
.list-group-item:hover {
|
||||
background-color: #1e3c70;
|
||||
color: white;
|
||||
}
|
||||
.doradoUnam {
|
||||
background-color: #bb8800;
|
||||
}
|
||||
|
||||
+3
-1
@@ -3,11 +3,13 @@ import login from "./view/login.vue";
|
||||
import libroDescripcion from "./view/libroDescripcion.vue";
|
||||
import difusion from "./view/difusion.vue";
|
||||
import lineamientos from "./view/lineamiento.vue";
|
||||
import tema from "./view/tema.vue";
|
||||
|
||||
export const routes = [
|
||||
{ path: "/", component: home, name: "form" },
|
||||
{ path: "/login", component: login, name: "Login" },
|
||||
{ path: "/desc", component: libroDescripcion, name: "LibroDesc" },
|
||||
{ path: "/difusion", component: difusion, name: "difusion" },
|
||||
{ path: "/lineamientos", component: lineamientos, name: "lineamientos" }
|
||||
{ path: "/lineamientos", component: lineamientos, name: "lineamientos" },
|
||||
{ path: "/tema", component: tema, name: "tema" }
|
||||
];
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<template>
|
||||
<div>
|
||||
<Header />
|
||||
<Nav />
|
||||
<Title title="Resultado" />
|
||||
<Cart />
|
||||
<Footer />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Header from "./../components/header.vue";
|
||||
import Nav from "./../esteticas/nav.vue";
|
||||
//import Nav from "./../components/navPrincipal.vue";
|
||||
import Footer from "./../components/footer.vue";
|
||||
import Cart from "../components/temaLibro.vue";
|
||||
import Title from "../components/titulo.vue";
|
||||
|
||||
export default {
|
||||
name: "home",
|
||||
components: {
|
||||
Header,
|
||||
Nav,
|
||||
Footer,
|
||||
Cart,
|
||||
Title
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user