├── components ├── SlotComponents │ └── buttonComp.js ├── DirectiveOnce.js ├── DirectivePre.js ├── DirectiveHtml.js ├── HelloWorld.js ├── DirectiveSlot.js ├── DirectiveShow.js ├── SaludarComp.js ├── DirectiveIf.js ├── computedComponents │ ├── ComputedPropertiesGetSet.js │ └── ComputedProperties.js ├── movies │ ├── MovieFav.js │ ├── SearchComp.js │ ├── MovieDetails.js │ ├── MovieComp.js │ └── index.js ├── DirectiveModel.js ├── VueDirectives.js ├── DirectiveOn.js ├── DirectiveFor.js └── PropsComp.js ├── movies.text ├── computed.html ├── index2.html ├── movie_fav.css ├── movies.html └── index.html /components/SlotComponents/buttonComp.js: -------------------------------------------------------------------------------- 1 | let buttonComp = { 2 | template: `` 6 | } -------------------------------------------------------------------------------- /components/DirectiveOnce.js: -------------------------------------------------------------------------------- 1 | let DirectiveOnce = { 2 | template: `
3 |

4 |
5 | `, 6 | data () { 7 | return { 8 | title: 'Directiva v-once', 9 | } 10 | }, 11 | } -------------------------------------------------------------------------------- /components/DirectivePre.js: -------------------------------------------------------------------------------- 1 | let DirectivePre = { 2 | template: `
3 |

4 |

{{ title }}

5 |
6 | `, 7 | data () { 8 | return { 9 | title: 'Directiva v-pre', 10 | } 11 | }, 12 | } -------------------------------------------------------------------------------- /components/DirectiveHtml.js: -------------------------------------------------------------------------------- 1 | 2 | let DirectiveHtml = { 3 | template: `
4 |

5 |

6 |
7 | `, 8 | data () { 9 | return { 10 | title: 'Directiva v-html', 11 | message: 'Hola desde directive html', 12 | } 13 | }, 14 | } -------------------------------------------------------------------------------- /components/HelloWorld.js: -------------------------------------------------------------------------------- 1 | Vue.component('hello-world', { 2 | template:`
3 |

{{ title }}

4 |

{{ message }}

5 |
6 | `, 7 | data() { 8 | return { 9 | title: 'Hola Mundo', 10 | message: 'Bienvenido al curso de Vuejs' 11 | } 12 | } 13 | }) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /components/DirectiveSlot.js: -------------------------------------------------------------------------------- 1 | let DirectiveSlot = { 2 | template: `
3 |

4 | 5 | 8 | 11 | 12 |
13 | `, 14 | data () { 15 | return { 16 | title: 'Directiva v-slot', 17 | } 18 | }, 19 | components: { 20 | buttonComp, 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /components/DirectiveShow.js: -------------------------------------------------------------------------------- 1 | 2 | let DirectiveShow = { 3 | template: `
4 |

5 |

6 |

El Usuario Tiene Permiso para ver esto

7 |

El Usuario Tiene No Tiene Permisos

8 | 9 |
10 | `, 11 | data () { 12 | return { 13 | title: 'Directiva v-show', 14 | message: 'Hola desde directive v-show', 15 | mostrar: true, 16 | user: { 17 | permission: false, 18 | } 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /movies.text: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | id: 1, 4 | title: 'Titanic', 5 | synopsis: 'Durante las labores de recuperación de los restos del famoso trasatlántico Titanic, una anciana norteamericana se pone en contacto con la expedición para acudir…', 6 | cover: 'https://image.tmdb.org/t/p/w185_and_h278_bestv2/zraTDtulFw2wrpyuYf646k95MNq.jpg' 7 | }, 8 | { 9 | id: 2, 10 | title: 'El Rey León', 11 | synopsis: 'Un remake del clásico animado de Disney de 1994 El rey león que estará dirigido por Jon Favreu. Simba (Donald Glover) es el hijo del rey de los leones, Mufasa…', 12 | cover: 'https://image.tmdb.org/t/p/w185_and_h278_bestv2/3A8ca8WOBacCRujSKJ2tCVKsieQ.jpg' 13 | }, 14 | { 15 | id: 3, 16 | title: 'Toy Story', 17 | cover: 'https://image.tmdb.org/t/p/w185_and_h278_bestv2/uMZqKhT4YA6mqo2yczoznv7IDmv.jpg' 18 | } 19 | ] -------------------------------------------------------------------------------- /computed.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Propiedades Computadas 8 | 9 | 10 |
11 | 12 | 13 |
14 | 15 | 16 | 17 | 27 | 28 | -------------------------------------------------------------------------------- /components/SaludarComp.js: -------------------------------------------------------------------------------- 1 | var SaludarComp = ('formuario-vue',{ 2 | template: ` 3 |
4 |

Saludo para tí

5 | 6 | 7 | 8 | 9 | 10 |
11 | `, 12 | data(){ 13 | return { 14 | 15 | } 16 | }, 17 | methods: { 18 | saludar(){ 19 | var name = document.getElementById('nombre').value; 20 | var pais = document.getElementById('pais').value; 21 | alert('Hola mi nombre es '+name+' y soy de '+pais); 22 | }, 23 | hey () { 24 | alert('Hey') 25 | }, 26 | upps(){ 27 | alert('No diste click en el botón'); 28 | } 29 | } 30 | }); -------------------------------------------------------------------------------- /components/DirectiveIf.js: -------------------------------------------------------------------------------- 1 | 2 | let DirectiveIf = { 3 | template: `
4 |

5 |

6 |

Uso de v-if / v-else

7 |

El Usuario Tiene Permiso para ver esto

8 |

El Usuario Tiene No Tiene Permisos

9 |

Uso de v-if / v-else-if / v-else

10 |

El Usuario Tiene Permiso y es VIP

11 |

El Usuario Tiene Permiso

12 |

El Usuario es VIP

13 |

El Usuario No tiene Permisos ni es VIP

14 | 15 |
16 | `, 17 | data () { 18 | return { 19 | title: 'Directiva v-if', 20 | message: 'Hola desde directive v-if', 21 | mostrar: true, 22 | user: { 23 | permission: false, 24 | vip: true, 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /components/computedComponents/ComputedPropertiesGetSet.js: -------------------------------------------------------------------------------- 1 | Vue.component('computed-properties-get-set', { 2 | template: ` 3 |
4 |

Computed Properties con Getter y Setter

5 |

Hola Soy {{ fullName }}

6 |

Y tengo {{ userAge }} años

7 |
8 | `, 9 | data () { 10 | return { 11 | user: { 12 | name: 'Jesus', 13 | lastName: 'Lopez', 14 | year: '1992' 15 | } 16 | } 17 | }, 18 | computed: { 19 | fullName: { 20 | get () { 21 | return `${ this.user.name } ${ this.user.lastName }` 22 | }, 23 | set (newValue) { 24 | let name = newValue.split(' ') 25 | 26 | this.user.name = name[0] 27 | this.user.lastName = name[1] 28 | } 29 | }, 30 | userAge () { 31 | let date = new Date() 32 | let currentYear = date.getFullYear() 33 | 34 | return currentYear - Number(this.user.year) 35 | } 36 | 37 | }, 38 | 39 | }) -------------------------------------------------------------------------------- /components/movies/MovieFav.js: -------------------------------------------------------------------------------- 1 | let MovieFav = { 2 | template: ` 3 |
4 |
5 | 6 |
7 |
8 | `, 9 | 10 | props: { 11 | show: { 12 | type: Boolean, 13 | default () { 14 | return false 15 | } 16 | } 17 | }, 18 | beforeCreate() { 19 | console.log('Esto es antes de que se cree') 20 | }, 21 | created() { 22 | console.log('Ya creado') 23 | }, 24 | beforeMount() { 25 | console.log('Antes de montarse') 26 | }, 27 | mounted() { 28 | let vm = this 29 | let $element = document.getElementById(`fav-${this._uid}`) 30 | $element.addEventListener('animationend', function () { 31 | vm.$emit('update:show', false) 32 | }) 33 | }, 34 | beforeUpdate() { 35 | 36 | }, 37 | updated() { 38 | 39 | }, 40 | beforeDestroy() { 41 | console.log('Antes de destruirse') 42 | }, 43 | destroyed() { 44 | console.log('Ya destruido') 45 | }, 46 | } -------------------------------------------------------------------------------- /components/DirectiveModel.js: -------------------------------------------------------------------------------- 1 | let DirectiveModel = { 2 | template: `
3 |

4 |

5 | 6 | 7 |

Tipo Checkbox

8 | 12 | 13 |

Peliculas

14 | 15 | 19 | 20 |
21 |

Peliculas Favoritas

22 | 25 |
26 | 27 |
28 | `, 29 | data () { 30 | return { 31 | title: 'Directiva v-model', 32 | message: 'Hola desde directive v-model', 33 | inputText: 'Data del input', 34 | checked: false, 35 | favoritesMovies: [], 36 | movies: ['Buscando a Nemo', 'Titanic', 'Toy Storie'] 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /components/computedComponents/ComputedProperties.js: -------------------------------------------------------------------------------- 1 | Vue.component('computed-properties', { 2 | template: ` 3 |
4 |

Computed Properties

5 |

Hola Soy {{ fullName }}

6 |

Y tengo {{ userAge }} años

7 |
8 | `, 9 | data () { 10 | return { 11 | user: { 12 | name: 'Jesus', 13 | lastName: 'Lopez', 14 | year: '1992' 15 | } 16 | } 17 | }, 18 | computed: { 19 | fullName () { 20 | return `${ this.user.name } ${ this.user.lastName }` 21 | }, 22 | userAge () { 23 | 24 | // EXPLICACIÓN JEJEJE 25 | 26 | let date = new Date() 27 | // new Date() es un Objeto JS 28 | // nos retorna el tiempo actual 29 | 30 | let currentYear = date.getFullYear() 31 | // con con .getFullYaer() es un metodo 32 | // del Objeto Date 33 | // que nos retorna el año de la fecha que instanciamos 34 | 35 | return currentYear - Number(this.user.year) 36 | 37 | } 38 | 39 | }, 40 | methods: { 41 | nombreCompleto () { 42 | return `${ this.user.name } ${ this.user.lastName }` 43 | } 44 | } 45 | }) -------------------------------------------------------------------------------- /components/VueDirectives.js: -------------------------------------------------------------------------------- 1 | 2 | Vue.component('vue-directives', { 3 | template: `
4 |

5 |

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | `, 19 | data () { 20 | return { 21 | title: 'Directivas de Vue.js', 22 | text: 'Texto de prueba v-text', 23 | link: { 24 | text: 'VueJS Home', 25 | href: 'https://vuejs.org/', 26 | title: 'Documentacion Vue JS' 27 | } 28 | } 29 | }, 30 | components: { 31 | DirectiveHtml, 32 | DirectiveShow, 33 | DirectiveIf, 34 | DirectiveFor, 35 | DirectiveOn, 36 | DirectiveModel, 37 | DirectiveSlot, 38 | DirectivePre, 39 | DirectiveOnce, 40 | SaludarComp 41 | } 42 | 43 | }) 44 | -------------------------------------------------------------------------------- /components/DirectiveOn.js: -------------------------------------------------------------------------------- 1 | 2 | let DirectiveOn = { 3 | template:`
4 |

5 |

6 |

7 | 8 | 9 | disponibles 10 |
11 |

Modificando Vista y Modelo

12 | 13 |
14 |
15 | `, 16 | data() { 17 | return { 18 | title: 'Directiva v-on', 19 | message: 'Hola desde directiva v-on', 20 | welcome_text: 'Bienvenido desde la data', 21 | pelicula: 'Dora la exploradora', 22 | entradas: 5, 23 | textInput: 'Valor por defecto del input text', 24 | } 25 | }, 26 | methods: { 27 | updateDataTextInput (event) { 28 | this.textInput = event.target.value 29 | }, 30 | decirHola () { 31 | alert(this.welcome_text) 32 | }, 33 | comprarEntrada () { 34 | if(this.entradas > 0) { 35 | this.entradas-- 36 | return alert(`Entrada para ${this.pelicula} comprada`) 37 | } 38 | return alert('Ya no hay entradas') 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /index2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Curso de Vue.js 8 | 13 | 14 | 15 |
16 |

{{ title }}

17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | -------------------------------------------------------------------------------- /movie_fav.css: -------------------------------------------------------------------------------- 1 | .movieFav-wrapper{ 2 | background: #fff; 3 | position: fixed; 4 | display: flex; 5 | justify-content: center; 6 | align-items: center; 7 | width: 100%; 8 | height: 100%; 9 | left: 0; 10 | top: 0; 11 | } 12 | .movieFav { 13 | position: relative; 14 | width: 100px; 15 | height: 90px; 16 | animation: heartbeat 2s forwards; 17 | margin:0 auto 18 | } 19 | .movieFav:before, 20 | .movieFav:after { 21 | position: absolute; 22 | content: ""; 23 | left: 50px; 24 | top: 0; 25 | width: 50px; 26 | height: 80px; 27 | background: rgb(246, 71, 71); 28 | -moz-border-radius: 50px 50px 0 0; 29 | border-radius: 50px 50px 0 0; 30 | -webkit-transform: rotate(-45deg); 31 | -moz-transform: rotate(-45deg); 32 | -ms-transform: rotate(-45deg); 33 | -o-transform: rotate(-45deg); 34 | transform: rotate(-45deg); 35 | -webkit-transform-origin: 0 100%; 36 | -moz-transform-origin: 0 100%; 37 | -ms-transform-origin: 0 100%; 38 | -o-transform-origin: 0 100%; 39 | transform-origin: 0 100%; 40 | } 41 | .movieFav:after { 42 | left: 0; 43 | -webkit-transform: rotate(45deg); 44 | -moz-transform: rotate(45deg); 45 | -ms-transform: rotate(45deg); 46 | -o-transform: rotate(45deg); 47 | transform: rotate(45deg); 48 | -webkit-transform-origin: 100% 100%; 49 | -moz-transform-origin: 100% 100%; 50 | -ms-transform-origin: 100% 100%; 51 | -o-transform-origin: 100% 100%; 52 | transform-origin :100% 100%; 53 | } 54 | @keyframes heartbeat 55 | { 56 | 0% 57 | { 58 | transform: scale( .5 ); 59 | opacity: 1; 60 | } 61 | 50% { 62 | transform: scale( 1.2 ); 63 | opacity: 1; 64 | } 65 | 100% 66 | { 67 | transform: scale( 1.5 ); 68 | opacity: 0; 69 | } 70 | } -------------------------------------------------------------------------------- /components/DirectiveFor.js: -------------------------------------------------------------------------------- 1 | 2 | let DirectiveFor = { 3 | template: `
4 |

5 |

6 |

Lista de un Array

7 | 10 |

Lista de un Objeto

11 | 16 |

Lista de un Array con Objectos

17 | 24 |
25 | `, 26 | data () { 27 | return { 28 | title: 'Directiva v-for', 29 | message: 'Hola desde directive v-for', 30 | list: ['Rojo', 'Amarrillo', 'Azul', 'Purpura', 'Rosa'], 31 | object_list: { 32 | name: 'Jesus', 33 | last_name: 'Lopez', 34 | nick: 'Lopvi', 35 | }, 36 | 37 | other_list: [ 38 | { 39 | name: 'Jesus', 40 | last_name: 'Lopez', 41 | nick: 'Lopvi', 42 | }, 43 | { 44 | name: 'Jorge', 45 | last_name: 'Martinez', 46 | nick: 'jmar', 47 | }, 48 | { 49 | name: 'Ismael', 50 | last_name: 'Carranza', 51 | nick: 'IsamaCa', 52 | }, 53 | ] 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /components/movies/SearchComp.js: -------------------------------------------------------------------------------- 1 | let SearchComp = { 2 | template: ` 3 |
4 | 5 |
6 |
7 |
8 | 9 | 10 | 11 |
12 | 16 |
17 | 22 |
23 |
24 |
25 |
26 | `, 27 | data () { 28 | return { 29 | query: '', 30 | page: 1, 31 | } 32 | }, 33 | methods: { 34 | search () { 35 | let URL = `${BASEURL}search/movie?api_key=${APIKEY}&language=es-MX&query=${this.query}&page=${this.page}` 36 | 37 | fetch(URL) 38 | .then(res => res.json()) 39 | .then(data => { 40 | this.$emit('input', data) 41 | }) 42 | }, 43 | setPage (page) { 44 | this.page = page 45 | this.search() 46 | }, 47 | resetSearch () { 48 | this.query = '' 49 | this.page = 1 50 | this.$emit('input', {}) 51 | } 52 | }, 53 | 54 | } -------------------------------------------------------------------------------- /components/movies/MovieDetails.js: -------------------------------------------------------------------------------- 1 | let MovieDetails = { 2 | name: 'MovieDetails', 3 | template: `
4 | 5 |
9 |
10 |
11 |
12 | 13 |
14 |
15 |

Detalles: {{ movie.title }}

16 | 17 |

18 |

19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | 33 |
34 |
35 |
36 |
`, 37 | data () { 38 | return { 39 | movie: {}, 40 | similar: [] 41 | } 42 | }, 43 | components: { 44 | MovieComp 45 | }, 46 | watch: { 47 | '$route.params.id' () { 48 | this.getMovie() 49 | } 50 | }, 51 | methods: { 52 | getSimilar () { 53 | fetch(`${this.apiBaseURL}movie/${this.$route.params.id}/similar${this.apiConfig}`) 54 | .then(res => res.json()) 55 | .then(({results}) =>{ 56 | this.similar = results 57 | }) 58 | }, 59 | getMovie () { 60 | fetch(`${this.apiBaseURL}movie/${this.$route.params.id}${this.apiConfig}`) 61 | .then(res => res.json()) 62 | .then(data =>{ 63 | this.movie = data 64 | this.getSimilar() 65 | }) 66 | } 67 | }, 68 | mounted() { 69 | this.getMovie() 70 | }, 71 | } -------------------------------------------------------------------------------- /components/movies/MovieComp.js: -------------------------------------------------------------------------------- 1 | let MovieComp = { 2 | template: ` 3 |
4 | 5 |
6 |

{{ title | uppercase }}

7 |

{{ synopsis | excertp }}

8 | 15 | Detalle 16 |
17 |
18 | `, 19 | props: { 20 | id: { 21 | type: Number, 22 | required: true, 23 | }, 24 | title: { 25 | type: String, 26 | required: true, 27 | }, 28 | synopsis: { 29 | type: String, 30 | default: 'No posee Sinopsis' 31 | }, 32 | cover: { 33 | type: String, 34 | required: true, 35 | }, 36 | like: { 37 | type:Boolean, 38 | required: true, 39 | default () { 40 | return false 41 | } 42 | } 43 | }, 44 | filters: { 45 | formatId (value) { 46 | return `movieCard-${value}` 47 | }, 48 | uppercase (value) { 49 | return value.toUpperCase() 50 | }, 51 | reverse (value) { 52 | let word = value.split('') 53 | return word.reverse().join('') 54 | }, 55 | excertp (value) { 56 | return value.substring(0, 100) + '...' 57 | } 58 | }, 59 | data () { 60 | return { 61 | className: { 62 | 'btn-like': true, 63 | 'btn-light': false, 64 | myclass: true 65 | }, 66 | user: 'Jesus Lopez' 67 | 68 | } 69 | }, 70 | watch: { 71 | like (newVal, oldVal) { 72 | console.log(newVal, oldVal) 73 | } 74 | }, 75 | computed: { 76 | btnStatus () { 77 | return this.isFav ? 'btn-like' : 'btn-ligth' 78 | }, 79 | 80 | isFav () { 81 | let favMovies = this.$store.state.favMovies 82 | 83 | let index = favMovies.findIndex(movie => movie.id === this.id) 84 | 85 | return index >= 0 86 | } 87 | }, 88 | methods: { 89 | toggleLike () { 90 | // this.like = !this.like 91 | let data = { 92 | id: this.id, 93 | like: !this.like 94 | } 95 | this.$emit('toggleLike', data) 96 | } 97 | }, 98 | } -------------------------------------------------------------------------------- /components/PropsComp.js: -------------------------------------------------------------------------------- 1 | Vue.component('props-comp', { 2 | template: ` 3 |
4 |
Bienvenido {{ user }}
5 |

Peliculas Props

6 |
7 |
9 | 17 |
18 |
19 | 23 | {{ oldUser }} 24 | 25 | 26 |
27 | `, 28 | data () { 29 | return { 30 | user: { 31 | name: 'Jesus', 32 | lastName: 'Lopez' 33 | }, 34 | oldUser: null, 35 | movies: [ 36 | { 37 | id: 1, 38 | title: 'Titanic', 39 | synopsis: 'Durante las labores de recuperación de los restos del famoso trasatlántico Titanic, una anciana norteamericana se pone en contacto con la expedición para acudir…', 40 | cover: 'https://image.tmdb.org/t/p/w185_and_h278_bestv2/zraTDtulFw2wrpyuYf646k95MNq.jpg', 41 | like: false 42 | }, 43 | { 44 | id: 2, 45 | title: 'El Rey León', 46 | synopsis: 'Un remake del clásico animado de Disney de 1994 El rey león que estará dirigido por Jon Favreu. Simba (Donald Glover) es el hijo del rey de los leones, Mufasa…', 47 | cover: 'https://image.tmdb.org/t/p/w185_and_h278_bestv2/3A8ca8WOBacCRujSKJ2tCVKsieQ.jpg', 48 | like: false 49 | }, 50 | { 51 | id: 3, 52 | title: 'Toy Story', 53 | cover: 'https://image.tmdb.org/t/p/w185_and_h278_bestv2/uMZqKhT4YA6mqo2yczoznv7IDmv.jpg', 54 | like: false 55 | } 56 | ], 57 | showFav: false 58 | 59 | } 60 | }, 61 | watch: { 62 | // user (newVal, oldVal) { 63 | 64 | // console.log(newVal, oldVal) 65 | // this.oldUser = oldVal 66 | // } 67 | user: { 68 | handler: function (newVal, oldVal) { 69 | console.log('new:', newVal, 'old:', oldVal) 70 | }, 71 | deep: true 72 | }, 73 | 'user.name': { 74 | handler: function (newVal, oldVal) { 75 | console.log('new:', newVal, 'old:', oldVal) 76 | }, 77 | deep: true 78 | }, 79 | 'user.lastName': { 80 | handler: function (newVal, oldVal) { 81 | console.log('new:', newVal, 'old:', oldVal) 82 | }, 83 | deep: true 84 | }, 85 | 86 | }, 87 | components: { 88 | MovieComp, 89 | MovieFav 90 | }, 91 | methods: { 92 | setNameUser (event) { 93 | this.user.name = event.target.value 94 | }, 95 | setLastNameUser (event) { 96 | this.user.lastName = event.target.value 97 | }, 98 | onToggleLike (data) { 99 | let movieLike = this.movies.find(movie => movie.id == data.id) 100 | movieLike.like = data.like 101 | this.showFav = data.like 102 | }, 103 | // onHideFav (show) { 104 | // this.showFav = show 105 | // } 106 | }, 107 | }) -------------------------------------------------------------------------------- /movies.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Props 8 | 9 | 88 | 89 | 90 |
91 | 92 |
93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 111 | 112 | -------------------------------------------------------------------------------- /components/movies/index.js: -------------------------------------------------------------------------------- 1 | 2 | const MovieApp= Vue.component('movie-app', { 3 | template: ` 4 |
5 |
Bienvenido {{ user.name }} {{ user.lastName }}
6 | 7 |
8 |

Peliculas App

9 |
{{ favMovies }}
10 |
11 |
13 | 21 |
22 |
23 | 24 |
25 | 32 |
33 |
34 |
35 |

Resultados de busqueda

36 |
37 |
40 | 48 |
49 |
50 |
51 | 58 |
59 |
60 | 61 | 62 |
63 | `, 64 | data () { 65 | return { 66 | 67 | add: 0, 68 | user: { 69 | name: 'Jesus', 70 | lastName: 'Lopez' 71 | }, 72 | oldUser: null, 73 | movies: [ 74 | 75 | ], 76 | searchMovies: { 77 | 78 | }, 79 | showFav: false, 80 | page: 1, 81 | total_pages: null 82 | } 83 | }, 84 | computed:{ 85 | ...Vuex.mapState(['favMovies','counter']) 86 | }, 87 | watch: { 88 | page () { 89 | this.getPopularMovies() 90 | } 91 | }, 92 | components: { 93 | MovieComp, 94 | MovieFav, 95 | SearchComp 96 | }, 97 | methods: { 98 | 99 | onToggleLike (data) { 100 | let movieLike = this.movies.find(movie => movie.id == data.id) 101 | movieLike.like = data.like 102 | // this.$store.commit('toggleFavMovie', movieLike) 103 | this.storeFavorita(movieLike) 104 | this.showFav = data.like 105 | }, 106 | getPopularMovies () { 107 | const URL = `${BASEURL}discover/movie?sort_by=popularity.desc&api_key=${APIKEY}&page=${this.page}` 108 | fetch(URL) 109 | .then(response => response.json()) 110 | .then(({results, page, total_pages}) => { 111 | console.log(page, total_pages) 112 | this.total_pages = total_pages 113 | this.movies = results.map(m => { 114 | m.like = false 115 | return m 116 | }) 117 | }) 118 | }, 119 | setPage (page) { 120 | this.page = page 121 | this.getPopularMovies() 122 | }, 123 | ...Vuex.mapMutations({ 124 | storeFavorita: 'toggleFavMovie' 125 | }) 126 | // onHideFav (show) { 127 | // this.showFav = show 128 | // } 129 | }, 130 | mounted() { 131 | let locationURL = new URL(window.location.href) 132 | this.page = locationURL.searchParams.get('page') || 1 133 | 134 | this.getPopularMovies() 135 | }, 136 | }) -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Props 8 | 9 | 96 | 97 | 98 |
99 | 100 | 101 | 102 |
103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 189 | 190 | --------------------------------------------------------------------------------