Advertisement
Guest User

Untitled

a guest
May 24th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.48 KB | None | 0 0
  1. <template>
  2. <section class="product">
  3. <div class="row">
  4. <div class="column is-12">
  5. <h3 class="title has-no-margin">{{ product.name }}</h3>
  6. </div>
  7. </div>
  8. <div class="row">
  9. <div class="column is-12 is-desktop-6">
  10. <section class="product-images">
  11. <section class="preview">
  12. <a class="preview-link" href=""><img class="preview-img" src="10.0.0.41/images/categories/category.jpg"></a>
  13. </section>
  14.  
  15. <section class="thumbnails-container">
  16. <section class="thumbnails">
  17. <a class="thumbnail" href=""><img class="thumbnail-img" src="10.0.0.41/images/categories/thumb.jpg"></a>
  18. <a class="thumbnail" href=""><img class="thumbnail-img" src="10.0.0.41/images/categories/thumb.jpg"></a>
  19. <a class="thumbnail" href=""><img class="thumbnail-img" src="10.0.0.41/images/categories/thumb.jpg"></a>
  20. <a class="thumbnail" href=""><img class="thumbnail-img" src="10.0.0.41/images/categories/thumb.jpg"></a>
  21. <a class="thumbnail" href=""><img class="thumbnail-img" src="10.0.0.41/images/categories/thumb.jpg"></a>
  22. </section>
  23. </section>
  24. </section>
  25. </div>
  26.  
  27. <div class="column is-12 is-desktop-6">
  28. <p class="description paragraph has-max-width has-no-margin">When an unknown printer took a galley of type and scrambled it to make a type specimen book. Electronic typesetting, remaining essentially unchanged It was popularised.</p>
  29.  
  30. <section class="variants">
  31.  
  32. <section class="variant" v-for="(attribute, index) in product.attributes">
  33. <select v-bind:key="attribute.name" v-model="selectedOptions[index]" v-on:change="getVariant">
  34. <option v-for="option in attribute.options" v-bind:value="option.id">{{ option.option }}</option>
  35. </select>
  36. </section>
  37.  
  38. <!--<button v-on:click="getVariantId">Send</button>-->
  39.  
  40. <!--<span>{{ selectedOptions }}<br></span>
  41. <span>Variant: {{ variant_id }}<br></span>
  42. <span>Price: {{ price }}<br></span>
  43. <span>Discount: {{ discount }}<br></span>
  44. <span>Price before: {{ price_before }}<br></span>
  45. <span>Stock: {{ stock_quantity }}<br></span>-->
  46. </section>
  47.  
  48. <section class="info-container">
  49. <section class="info">
  50. <span class="stock is-red" v-if="variant.stock.quantity == 0">Není skladem</span>
  51. <span class="stock is-green" v-else-if="variant.stock.quantity <= 15">Skladem {{ variant.stock.quantity }}ks</span>
  52. <span class="stock is-green" v-else-if="variant.stock.quantity >= 15">Skladem > 15ks</span>
  53.  
  54. <a class="stock-link" href="#">Kdy zboží dostanu?</a>
  55. </section>
  56.  
  57. <section class="info">
  58. <section class="price-container" v-if="variant.discount != null">
  59. <section class="discount">
  60. <span class="before">{{ variant.price }}Kč</span>
  61. <span class="percents">-{{ variant.discount.percents }}%</span>
  62. </section>
  63. <span class="price" v-if="variant.discount != null">{{ variant.price_now }}Kč</span>
  64. <span class="price" v-if="variant.discount == null">{{ variant.price }}Kč</span>
  65. </section>
  66.  
  67. <fieldset class="cart">
  68. <input class="quantity form-control" type="number" name="quantity" min="1" v-model="quantity">
  69. <button class="button" v-on:click="addToCart">Přidat do košíku</button>
  70. </fieldset>
  71. </section>
  72. </section>
  73. </div>
  74. </div>
  75. <div class="row">
  76. <div class="column is-12 is-desktop-6">
  77. <section class="tabs-container">
  78.  
  79. <section class="tab-buttons">
  80. <button class="tab-button">Popis</button>
  81. <button class="tab-button is-active">Komentáře</button>
  82. </section>
  83.  
  84. <section class="tabs">
  85. <section class="tab" id="description">
  86. <p class="has-max-width has-no-margin">When an unknown printer took a galley of type and scrambled it to make a type specimen book. Electronic typesetting, remaining essentially unchanged It was popularised.</p>
  87. </section>
  88.  
  89. <section class="tab is-active" id="reviews">
  90. <section class="reviews">
  91.  
  92. <section class="review">
  93. <section class="review-head">
  94. <span class="name">Richard Závodný</span>
  95. <span class="date">17.5.2019</span>
  96. </section>
  97. <section class="review-body">
  98. <p class="has-max-width has-no-margin">Dobrý produkt, kvalitní, motiv drží i po několikátém praní.</p>
  99. </section>
  100. </section>
  101.  
  102. <section class="review">
  103. <section class="review-head">
  104. <span class="name">Richard Závodný</span>
  105. <span class="date">17.5.2019</span>
  106. </section>
  107. <section class="review-body">
  108. <p class="has-max-width has-no-margin">Dobrý produkt, kvalitní, motiv drží i po několikátém praní.</p>
  109. </section>
  110. </section>
  111.  
  112. </section>
  113. </section>
  114. </section>
  115.  
  116. </section>
  117. </div>
  118. </div>
  119. </section>
  120. </template>
  121.  
  122. <script>
  123. export default {
  124. data: function() {
  125. return {
  126. selectedOptions: [1,5],
  127. variant_id: null,
  128. quantity: 1,
  129. product: null,
  130. variant: null
  131. }
  132. },
  133.  
  134. methods: {
  135. getProduct() {
  136. axios.get('/api/product/1')
  137. .then(response => {
  138. //console.log(response.data);
  139. this.product = response.data;
  140. })
  141. .catch(function(error) {
  142. //console.log(error.data);
  143. });
  144. },
  145.  
  146. getVariant() {
  147. axios.post('/api/product/1/variant', { options: this.selectedOptions })
  148. .then(response => {
  149. //console.log(response.data);
  150. /*this.variant_id = response.data.variant_id;
  151. this.price = response.data.price;
  152. this.discount = response.data.discount;
  153. this.price_before = response.data.price_before;
  154. this.stock_quantity = response.data.stock_quantity;
  155.  
  156. if(response.data.variant_id == null) {
  157. alert('Varianta neexistuje');
  158. }*/
  159.  
  160. this.variant = response.data;
  161. this.variant_id = response.data.id;
  162. })
  163. .catch(function(error) {
  164. //console.log(error.data);
  165. });
  166. },
  167.  
  168. addToCart() {
  169. axios.post('/api/cart/item/add', { variant_id: this.variant_id, quantity: this.quantity })
  170. .then(response => {
  171. //console.log(response.data);
  172. if(response.data.variant_id == null) {
  173. alert('Přidáno do košíku');
  174. }
  175. })
  176. .catch(function(error) {
  177. //console.log(error.data);
  178. });
  179. }
  180. },
  181.  
  182. mounted() {
  183. this.getProduct();
  184. this.getVariant();
  185. }
  186. }
  187. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement