Sfoglia il codice sorgente

[ADD] chrome warning with images

Gogs 7 anni fa
parent
commit
69f1b3219d
2 ha cambiato i file con 28 aggiunte e 4 eliminazioni
  1. 1 0
      src/components/CartItem.vue
  2. 27 4
      src/components/ProductCard.vue

+ 1 - 0
src/components/CartItem.vue

@@ -14,6 +14,7 @@
             data: {
                 type: Object,
                 default: () => {
+                    console.log(this)
                     return {}
                 }
             }

+ 27 - 4
src/components/ProductCard.vue

@@ -1,7 +1,7 @@
 <template lang="pug">
     .product-card(@click="selectProduct({ data })")
         h2.product-title {{ data.name }}
-        img.product-image(:src="data.image_medium ? 'data:image/png;base64,' + data.image_medium : '/web/static/src/img/placeholder.png'")
+        img.product-image(:src="this.data.image_medium ? 'data:image/png;base64,' + this.data.image_medium : '/web/static/src/img/placeholder.png'")
         .product-price
             span Gs {{ data.list_price }}
         .product-qty
@@ -19,9 +19,32 @@
                 }
             }
         },
-        methods: mapActions([
-            'selectProduct'
-        ])
+        computed: {
+            // FIXME
+            productImage() {
+                let img = new Image()
+                img.src = this.data.image_medium ? 'data:image/png;base64,' + this.data.image_medium : '/web/static/src/img/placeholder.png'
+                return img.src
+            }
+        },
+        methods: {
+            //  TODO
+            drawImage() {
+                let ctx = this.$el.querySelector('.product-image').getContext('2d')
+                let img = new Image()
+                img.onload = () => {
+                    ctx.drawImage(img, 0, 0, 80, 80)
+                }
+                console.log(this.data.image_medium)
+                img.src = this.data.image_medium ? 'data:image/png;base64,' + this.data.image_medium : '/web/static/src/img/placeholder.png'
+            },
+            ...mapActions([
+                'selectProduct'
+            ])
+        },
+        mounted() {
+            // this.drawImage()
+        }
     }
 </script>