Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | <template> <main> <div v-if="error"> {{ error }} </div> <div v-if="this.product !== null"> <div class="row m-1 m-md-5"> <div class="col-md-6 col-12 rounded pt-2 pb-2"> <div class="m-auto images-wrapper"> <div class="image-wrapper"> <div class="image" @click="setCoolLightBox(index)" :style="{ backgroundImage: `url(${images[index]})` }" ></div> <ssr-carousel class="all-images mt-3" :show-arrows="images.length > 5" :loop="true" :slides-per-page="5" > <div class="image-wrapper slide mr-2" v-for="(image, imageIndex) in images" :key="imageIndex" :index="imageIndex" > <div class="image gold-border" v-on:click="index = imageIndex" :style="{ backgroundImage: `url(${image})` }" ></div> </div> </ssr-carousel> </div> </div> </div> <div class=" col-md-6 col-12 pt-0 pl-md-5 py-2 flex flex-col justify-content-between " > <div> <h5 v-html="colorTitleNumbers(product.title)" class="font-weight-bold text-md-left text-uppercase" ></h5> <h6 class=" product-price mt-3 font-weight-bold text-md-left text-center " > <span class="position-relative" :class="discount && 'cross-out'" >${{ calcPrice() | formatNumber }}</span > </h6> <div v-if="discount" class="d-flex align-items-center"> <h6 class="m-0 font-weight-bold text-md-left text-center"> ${{ calcDiscoutPrice() | formatNumber }} </h6> <div class="d-flex ml-3 position-relative align-items-center"> <span class="icon-tag"></span> <span class="discount position-absolute gold-background">{{ discount }}</span> </div> </div> <div class=" d-flex mt-1 mb-5 justify-content-md-start justify-content-center " > <div class="d-flex"> <div class="d-flex border position-relative quantity mr-2"> <input type="number" :value="selected.quantity" class="px-2 w-100" /> <div class=" d-flex flex-column position-absolute number-input-buttons justify-content-center " > <button v-on:click="quantityPlus" class="m-0 p-0 btn btn-light" > <Icon icon="angle-up" class="angle-up" /> </button> <button v-on:click="quantityMinus" class="m-0 p-0 btn btn-light" > <Icon icon="angle-down" class="angle-down" /> </button> </div> </div> <button class=" py-2 px-4 rounded btn btn-dark d-flex justify-content-center align-items-center text-uppercase text-nowrap add-cart-button " v-on:click="addToCart" > <span class="icon icon-bag mr-2 d-none d-lg-flex"></span> Add to cart </button> </div> </div> <PurchaseTypes v-on:setTypes="setTypes" :purType="selected.purchaseTypeId" :subType="selected.subscriptionTypeId" /> <div class="mt-1 items-baseline text-gray-600"> {{ product.description }} </div> <div v-if="included.length" class="mt-1 items-baseline text-gray-600" > <span class="gold font-weight-bold">Included:</span> <ul class="included d-flex flex-column p-0"> <li v-for="include in included" :key="include"> {{ include }} </li> </ul> </div> <BundleProducts :product="product" /> </div> </div> </div> <RelatedProducts :product="product" /> </div> </main> </template> <script> import { mapGetters, mapMutations } from "vuex"; import { getStrapiMedia } from "~/utils/medias"; import { colorTitleNumbers } from "~/helpers"; import "~/utils/filters"; import Icon from "@/assets/icons"; import RelatedProducts from "~/components/products/RelatedProducts"; import BundleProducts from "~/components/products/BundleProducts"; import PurchaseTypes from "~/components/common/PurchaseTypes"; export default { layout: "header_without_text_bunner", components: { Icon, RelatedProducts, BundleProducts, PurchaseTypes }, data: () => ({ product: null, options: [], error: null, images: [], discount: null, included: [], selected: { productId: null, quantity: 1, purchaseTypeId: 1, subscriptionTypeId: null, total: 0, }, index: 0, imageIndex: null, }), computed: { ...mapGetters({ purchaseTypes: "purchase-types/getTypes", }), }, async mounted() { try { this.product = await this.$strapi.findOne( "products", this.$route.params.id ); this.selected.productId = this.product.id; this.selected.total = this.product.price; this.images = this.product.image.map((item) => this.getImage(item)); this.setImages(this.images); if (this.product.included) { this.included = this.product.included; } } catch (error) { this.error = error; } }, methods: { getStrapiMedia, colorTitleNumbers, ...mapMutations({ setImages: "cool_light_box/setImages", setImageIndex: "cool_light_box/setImageIndex", }), setCoolLightBox: function (index) { this.setImageIndex(index); }, getImage: function (image) { if (image.url) { return this.getStrapiMedia(image.url); } return this.getStrapiMedia("/uploads/image_not_found_8c8e4b17cc.jpg"); }, setTypes: function (types) { this.selected.purchaseTypeId = types.purchase_type; this.selected.subscriptionTypeId = types.subscription_type; this.calcDiscoutPrice(); }, quantityPlus: function () { if (this.selected.quantity < 99) { this.selected.quantity = this.selected.quantity + 1; this.selected.total = this.selected.quantity * this.product.price; } }, quantityMinus: function () { if (this.selected.quantity > 1) { this.selected.quantity = this.selected.quantity - 1; this.selected.total = this.selected.quantity * this.product.price; } }, calcPrice: function () { return this.product.price * this.selected.quantity; }, calcDiscoutPrice: function () { const purchaseType = this.purchaseTypes.filter( (item) => item.id === this.selected.purchaseTypeId ); const price = this.product.price * this.selected.quantity; if (purchaseType.length && purchaseType[0].title) { const { description } = purchaseType[0]; if (!description) { this.discount = null; return price; } if (description.includes("%")) { let per = description.match(/(?<!\d)\d{1,2}(?=%)/gi)[0]; if (per && +per > 0) { per = +per; } this.discount = `${per}%`; const value = (price / 100) * per; return price - value; } else if (description.includes("$")) { let val = description.match(/(?<!\d)\d{1,2}(?=$)/gi)[0]; if (val && +val > 0) { val = +val; } this.discount = `${val}$`; return price - val; } this.discount = null; return price; } this.discount = null; return price; }, addToCart: async function () { await this.$store.dispatch("order/addProduct", this.selected); }, }, }; </script> <style scoped> button:hover { color: #9e7d24; } .icon-tag { display: inline-block; min-width: 44px; height: 50px; background-size: cover; transform: rotate(-45deg); filter: invert(45%) sepia(61%) saturate(475%) hue-rotate(6deg) brightness(96%) contrast(95%); background-image: url("../../assets/icons/tag-solid.svg"); } .discount { left: 15px; color: white; padding: 0 5px 1px 0; border-radius: 0 10px 10px 0; } .product-price > span.cross-out::before { position: absolute; content: ""; display: block; width: 140%; height: 3px; top: 50%; left: -20%; transform: rotate(-14deg); background-color: #9e7d24; } .add-cart-button { background-color: #1f2020; color: #fff; } .quantity { width: 56px; } .icon-bag { width: 14px; height: 14px; background-image: url("../../assets/icons/shopping-bag.svg"); filter: invert(98%) sepia(98%) saturate(0%) hue-rotate(326deg) brightness(103%) contrast(102%); } .angle-up, .angle-down { width: 20px; height: 12px; filter: invert(0%) sepia(100%) saturate(27%) hue-rotate(33deg) brightness(105%) contrast(106%); } .number-input-buttons { right: 2px; top: 1px; bottom: 1px; } .number-input-buttons > button { font-size: 11.5px; } .included > li:first-child { margin-top: 10px; } .image-wrapper > .image { cursor: pointer; background-position: 50%; background-repeat: no-repeat; background-size: contain; padding-top: 100%; } </style> |