"use strict"; function format(e, t) { var n, i, a, o, r = ""; for (e = String(e), t = String(t), a = 0, o = 1; o && a < t.length; ++a) switch (n = e.charAt(a), i = t.charAt(a)) { case "#": /\d/.test(n) ? r += n : o = 0; break; case "A": /[a-z]/i.test(n) ? r += n : o = 0; break; case "N": case "?": /[a-z0-9]/i.test(n) ? r += n : o = 0; break; case "X": r += n; break; default: r += i } return r } function triggerEvent(e, t) { if ("createEvent" in document) { var n = document.createEvent("HTMLEvents"); n.initEvent(t, !1, !0), e.dispatchEvent(n) } else { var n = document.createEventObject(); n.eventType = t, e.fireEvent("on" + n.eventType, n) } } function format(e, t) { var n, i, a, o, r = ""; for (e = String(e), t = String(t), a = 0, o = 1; o && a < t.length; ++a) switch (n = e.charAt(a), i = t.charAt(a)) { case "#": /\d/.test(n) ? r += n : o = 0; break; case "A": /[a-z]/i.test(n) ? r += n : o = 0; break; case "N": case "?": /[a-z0-9]/i.test(n) ? r += n : o = 0; break; case "X": r += n; break; default: r += i } return r } function triggerEvent(e, t) { if ("createEvent" in document) { var n = document.createEvent("HTMLEvents"); n.initEvent(t, !1, !0), e.dispatchEvent(n) } else { var n = document.createEventObject(); n.eventType = t, e.fireEvent("on" + n.eventType, n) } } function _classCallCheck(e, t) { if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") } function _classCallCheck(e, t) { if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") } var state = { user: { profile: {} }, cart_items: { resume: { quantity_cart: 0 }, items: [] }, categories: [], orderForm: {} }, mutations = { CHANGE_USER: function(e, t) { e.user.profile = t }, CHANGE_CATEGORIES: function(e, t) { e.categories = t }, CHANGE_CART_ITEMS: function(e, t) { e.cart_items = t }, CHANGE_ORDER_FORM: function(e, t) { e.orderForm = t } }, actions = { changeCategories: function(e, t) { e.commit("CHANGE_CATEGORIES", t) }, changeUser: function(e, t) { e.commit("CHANGE_USER", t) }, changeCartItems: function(e, t) { e.commit("CHANGE_CART_ITEMS", t) }, changeOrderForm: function(e, t) { e.commit("CHANGE_ORDER_FORM", t) } }, getters = { localidade: function(e) { return e.user.city + " - " + e.user.state } }, store = new Vuex.Store({ state: state, mutations: mutations, actions: actions, getters: getters }); corebiz.config({ DEBUG: !0, store_url: "https://augustojoias.vtexcommercestable.com.br", namestore: "augustojoias", headers: { Accept: "application/json; charset=utf-8", "Content-Type": "application/json" } }); var config = { url: "" }, HelpersComponents = function() { this.sizeImageThumb = function(e, t, n) { if (n && t && e) return e.replace(t, n) }, this.sizeImageProductSearch = function(e, t, n, i) { if (t && n && e) return i && (e = e.replace("~/", "http://augustojoias.vteximg.com.br/")), e.replace(/\#width\#/g, t).replace(/\#height\#/g, n) }, this.addQuantityOnitem = function(e) { if (e || e.length) return console.warn("items", e), e = e.map(function(e) { return e.quantity_item = 1, e }) }, this.toMoney = function(e) { if (e) return savana.formatMoney(e / 100, 2, ",", ".", "R$") }, this.installment = function(e) { if (e) return savana.installment(e.price, e.max_parc, 0, e.min_value_parc, "R$") } }, helpers_component = new HelpersComponents; Vue.filter("tomoney", function(e) { return helpers_component.toMoney(e) }); var formatModel = function(e, t) { var n, i, a, o, r = "", s = 0; for (e = String(e), t = String(t), a = 0, o = 1; o && a < t.length; ++a) switch (n = e.charAt(a - s), i = t.charAt(a)) { case "#": /\d/.test(n) ? r += n : o = 0; break; case "A": /[a-z]/i.test(n) ? r += n : o = 0; break; case "N": case "?": /[a-z0-9]/i.test(n) ? r += n : o = 0; break; case "X": r += n; break; default: r += i, s++ } return r }, Mask = function(e) { var t = {}; e.directive("mask", { bind: function(e, n, i) { t.handler = function(e) { var n = this.value, i = e.srcElement.getAttribute("f-mask"), a = n; t.previous.length < n.length && (a = format(n, i)), this.value = a, t.previous = a }, t.clearInputInvalid = function(e) { for (var t = this.value, n = e.srcElement.getAttribute("f-mask"), i = 0, a = 0, o = n.length; a < o; a++) "?" != n.charAt(a) && i++; t.length < i && (this.value = "") }, e.setAttribute("maxlength", i.data.attrs["f-mask"].length), t.previous = "", e.addEventListener("input", t.handler, !1), e.addEventListener("change", t.clearInputInvalid, !1) }, unbind: function() { el.removeEventListener("input", t.handler, !1), el.removeEventListener("blur", t.clearInputInvalid, !1) } }), e.filter("mask", function(e, t) { return formatModel(e, t) }) }, mask = new Mask(Vue), formatModel = function(e, t) { var n, i, a, o, r = "", s = 0; for (e = String(e), t = String(t), a = 0, o = 1; o && a < t.length; ++a) switch (n = e.charAt(a - s), i = t.charAt(a)) { case "#": /\d/.test(n) ? r += n : o = 0; break; case "A": /[a-z]/i.test(n) ? r += n : o = 0; break; case "N": case "?": /[a-z0-9]/i.test(n) ? r += n : o = 0; break; case "X": r += n; break; default: r += i, s++ } return r }, Mask = function(e) { var t = {}; e.directive("mask", { bind: function(e, n, i) { t.handler = function(e) { var n = this.value, i = e.srcElement.getAttribute("f-mask"), a = n; t.previous.length < n.length && (a = format(n, i)), this.value = a, t.previous = a }, t.clearInputInvalid = function(e) { for (var t = this.value, n = e.srcElement.getAttribute("f-mask"), i = 0, a = 0, o = n.length; a < o; a++) "?" != n.charAt(a) && i++; t.length < i && (this.value = "") }, e.setAttribute("maxlength", i.data.attrs["f-mask"].length), t.previous = "", e.addEventListener("input", t.handler, !1), e.addEventListener("change", t.clearInputInvalid, !1) }, unbind: function() { el.removeEventListener("input", t.handler, !1), el.removeEventListener("blur", t.clearInputInvalid, !1) } }), e.filter("mask", function(e, t) { return formatModel(e, t) }) }, mask = new Mask(Vue), CartServices = function() { this.getItems = function(e, t) { var n = "function" == typeof e && "function" == typeof t; corebiz.cart.list(function(t) { n && e(t) }, function(e) { n && t(e) }) }, this.getItemsFinal = function(e, t) { var n = "function" == typeof e && "function" == typeof t; vtexjs.checkout.getOrderForm().done(function(t) { vtexjs.checkout.changeItemsOrdination("add_time", !1).then(function(t) { var i = {}, a = t.items.reduce(function(e, t) { return e + t.quantity }, 0); i.resume = { total_cart: t.value, quantity_cart: a }, i.items = t.items, n && e(i) }).fail(function(e) { n && error(e) }) }) }, this.verifyQuantityMaxPerUnit = function(e) { return e && e.length ? (e.forEach(function(e) { e.is_unit && parseInt(e.quantity) > parseInt(e.quantity_max_per_unit - 1) && (e.quantity = e.quantity_max_per_unit - 1) }), e) : e }, this.addItem = function(e, t, n) { if (e) { var i = "function" == typeof t && "function" == typeof n; e.items = this.verifyQuantityMaxPerUnit(e.items), corebiz.cart.add(e.sc, e.items, function(e) { i && t(e) }, function(e) { i && n(e) }) } }, this.updateItem = function(e, t, n) { if (e) { var i = "function" == typeof t; e.items = this.verifyQuantityMaxPerUnit(e.items), corebiz.cart.update(e.items, function(e) { i && t(e) }, function(e) { i && n(e) }) } }, this.deleteItem = function(e, t, n) { if (void 0 !== e) { var i = "function" == typeof t && "function" == typeof n; corebiz.cart.remove(e, function(e) { i && t(e) }, function(e) { i && n(e) }) } }, this.deleteAllItems = function(e, t) { var n = "function" == typeof e && "function" == typeof t; corebiz.cart.remove(-1, function(t) { n && e(t) }, function(e) { n && t(e) }) }, this.simulationShipping = function(e, t, n) { if (e) { var i = "function" == typeof t && "function" == typeof n; corebiz.cart.simulationShipping(e, function(e) { i && t(e) }, function(e) { i && n(e) }) } } }, CategoryServices = function() { this.getCategories = function(e, t) { var n = "function" == typeof e && "function" == typeof t; corebiz.category.list(function(t) { n && e(t) }, function(e) { n && t(e) }) } }, _createClass = function() { function e(e, t) { for (var n = 0; n < t.length; n++) { var i = t[n]; i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i) } } return function(t, n, i) { return n && e(t.prototype, n), i && e(t, i), t } }(), DefaultServices = function() { function e(t, n, i) { _classCallCheck(this, e), this.username = t, this.email = n, this.password = i } return _createClass(e, [{ key: "register", value: function() { console.log(this.username + " os now registered") } }], [{ key: "countUsers", value: function() { console.log("There are 50 users") } }]), e }(), ProductServices = function() { this.getProductJson = function(e, t) { var n, i = "function" == typeof e; try { n = skuJson } catch (e) { n = skuJson_1, console.error(e) } return i && e(n), null }, this.getProduct = function(e, t, n) { if (e) { corebiz.search.products({ fq: "productId:" + e }, function(e) { t(e) }, function(e) { n(e) }) } }, this.getProductVault = function(e, t, n) { if (e) { var i = "function" == typeof t && "function" == typeof n, a = { Accept: "application/vnd.vtex.pricing.v3+json", "Content-Type": "application/json" }; $.ajax({ type: "GET", url: "https://api.vtex.com/nestlebr/pricing/prices/" + e, headers: a, async: !0, crossDomain: !0 }).success(function(e) { i && t(e) }).error(function(e) { i && n(e) }) } }, this.setWarnMe = function(e, t, n) { if (e) { var i = "function" == typeof t || "function" == typeof n; corebiz.products.warnMe(e, function(e) { i && t(e) }.bind(this), function(e) { i && n(!1, e) }.bind(this)) } }, this.getProductSku = function(e, t, n) { if (e) { var i = "function" == typeof t; corebiz.products.sku(e, function(e) { i && t(e) }, function(e) { i && n(e) }) } }, this.getSearchPage = function(e, t, n) { if (e) { var i = "function" == typeof t && "function" == typeof n; corebiz.search.buscapagina({ sl: "dbf783cd-66ac-4eca-a1ba-fe99bbfea2f2", PS: 16, sm: 0, cc: 16, fq: "H:" + e }, function(e) { i && t(e) }, function(e) { i && n(e) }) } }, this.getBuyTogether = function(e, t, n) { e && corebiz.products.buyTogether(e, t, n) }, this.getSearchPageByCategory = function(e, t, n) { var i = "function" == typeof t && "function" == typeof n, a = e ? "C:" + e : ""; corebiz.search.buscapagina({ sl: "dbf783cd-66ac-4eca-a1ba-fe99bbfea2f2", PS: 16, sm: 0, cc: 4, fq: a }, function(e) { i && t(e) }, function(e) { i && n(e) }) } }, ProfileServices = function() { this.getProfile = function(e, t) { var n = "function" == typeof e && "function" == typeof t; corebiz.profile.getProfile(function(t) { n && e(t) }, function(e) { n && t(e) }) } }, SearchServices = function() { this.getSuggestions = function(e, t, n) { if (e) { var i = "function" == typeof t && "function" == typeof n; corebiz.search.products(e, function(e) { i && t(e) }, function(e) { i && n(e), console.error("SearchServices products", e) }) } }, this.getAutocomplete = function(e, t, n) { if (e) { var i = "function" == typeof t && "function" == typeof n; corebiz.search.autocomplete(e, function(e) { i && t(e) }, function(e) { i && n(e), console.error("SearchServices getAutocomplete", e) }) } } }, CartController = function() { this.getItemsCart = function(e) { var t = "function" == typeof e; (new CartServices).getItems(function(n) { t && e(n) }, function(n) { t && e(!1, n) }) }, this.addItemCart = function(e, t) { var n = this; if (e) { var i = "function" == typeof t, a = new CartServices; console.warn("data", e), a.addItem(e, function(e) { i && t(n.totalCartItemsResume(e)) }, function(e) { i && t(!1, e) }) } }, this.updateItemCart = function(e, t) { var n = this; if (e) { var i = "function" == typeof t; (new CartServices).updateItem(e, function(e) { i && t(n.totalCartItemsResume(e)) }, function(e) { i && t(!1, e) }) } }, this.deleteItemCart = function(e, t) { var n = this; if (void 0 !== e) { var i = "function" == typeof t; (new CartServices).deleteItem(e, function(e) { i && t(n.totalCartItemsResume(e)) }, function(e) { i && t(!1, e) }) } }, this.deleteAllItemsCart = function(e) { var t = this, n = "function" == typeof e; (new CartServices).deleteAllItems(function(i) { n && e(t.totalCartItemsResume(i)) }, function(t) { n && e(!1, t) }) }, this.totalCartItemsResume = function(e) { if (e) { var t = {}, n = e.items.reduce(function(e, t) { return e + t.quantity }, 0); return t.resume = { total_cart: e.value, quantity_cart: n }, t.items = e.items, t } }, this.setPriceItems = function(e) { if (e) return e.items = e.items.map(function(e) { return e }), e }, this.totalCart = function(e) { if (e) { var t = 0; return e.items.reduce(function(e, n) { return e || (e = 0), t = n.sellingPrice * n.quantity + e }, 0) } }, this.simulationShipping = function(e, t) { if (e) { var n = "function" == typeof t; (new CartServices).simulationShipping(e, function(e) { n && t(e) }, function(e) { n && err(e) }) } } }, CategoryController = function() { this.getCategories = function(e) { var t = "function" == typeof e; (new CategoryServices).getCategories(function(n) { t && e(n) }, function(n) { t && e(!1, resp) }) } }, ProductController = function() { this.getProduct = function(e) { return (new ProductServices).getProductJson(function(t) { e(t) }, function(t) { e(!1, t) }), null }, this.getProductDefault = function(e, t) { if (e) { var n = new ProductServices, i = "function" == typeof t; return n.getProduct(e, function(e) { i && t(e) }, function(e) { i && t(!1, e) }), null } }, this.getProductSku = function(e, t) { if (e) { var n = new ProductServices, i = "function" == typeof t; return n.getProductSku(e, function(e) { i && t(e) }, function(e) { i && t(!1, e) }), null } }, this.setWarnMe = function(e, t) { if (e) { (new ProductServices).setWarnMe(e, function(e) { t(e) }, function(e) { t(!1, e) }) } }, this.getProductVault = function(e, t) { if (e) { var n = "function" == typeof t; (new ProductServices).getProductVault(e, function(e) { n && t(e) }, function(e) { n && t(!1, e) }) } }, this.getSearchPage = function(e, t) { if (e) { (new ProductServices).getSearchPage(e, function(e) { t(e) }, function(e) { t(!1, e) }) } }, this.getSearchPageByCategory = function(e, t) { (new ProductServices).getSearchPageByCategory(e, function(e) { t(e) }, function(e) { t(!1, e) }) }, this.getBuyTogether = function(e, t, n) { if (e) { (new ProductServices).getBuyTogether(e, function(e) { t(e) }, function(e) { t(!1, e) }) } } }, ProfileController = function() { this.getUserLogged = function(e) { var t = "function" == typeof e; (new ProfileServices).getProfile(function(n) { t && e(!!n.IsUserDefined && n) }, function(e) { console.error(e) }) } }, SearchController = function() { this.getProducts = function(e, t) { if (e) { var n = "function" == typeof t; (new SearchServices).getSuggestions(e, function(e) { n && t(e) }, function(e) { n && t(!1, e) }) } }, this.getAutocomplete = function(e, t) { if (e) { var n = "function" == typeof t; (new SearchServices).getAutocomplete(e, function(e) { n && t(e) }, function(e) { n && t(!1, e) }) } }, this.isSearchValid = function(e) { if (!(e.length < 3)) return !0 }, this.buildWordSearch = function(e) { if (e) return e = e.replace(/\s/g, "+") } }, _createClass = function() { function e(e, t) { for (var n = 0; n < t.length; n++) { var i = t[n]; i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i) } } return function(t, n, i) { return n && e(t.prototype, n), i && e(t, i), t } }(), UserController = function() { function e(t, n, i) { _classCallCheck(this, e), this.username = t, this.email = n, this.password = i } return _createClass(e, [{ key: "register", value: function() { console.log(this.username + " os now registered") } }], [{ key: "countUsers", value: function() { console.log("There are 50 users") } }]), e }(), html = '\n
\n
\n
\n

\n {{ product.price.listPrice }}\n

\x3c!-- /.widget__oldprice --\x3e\n\n

\n {{ product.price.bestPrice }}\n

\n\n

\n {{ product.installment.quatity }}x de {{ product.installment.value }}\n

\n
\x3c!-- /.widget__price --\x3e\n\n \x3c!-- /.widget__actions --\x3e\n\n
\n

\n {{ valueDiscountBoleto() }}% de desconto no boleto {{ product.price.discount }} \n

\x3c!-- /.promo --\x3e\n
\x3c!-- /.widget__promo --\x3e\n
\x3c!-- /.widget__offer --\x3e\n\n
\n
\n
\n

Produto indisponível avise-me!

\n\n

Este produto está fora do estoque no momento. Preencha os campos abaixo para ser avisado sobre a disponibilidade.

\n
\x3c!-- /.search__body --\x3e\n\n
\n \n \n \n
\x3c!-- /.search__body --\x3e\n\n
\n \n \n \n
\x3c!-- /.search__body --\x3e\n\n
\n \x3c!-- /.field--send --\x3e\n
\x3c!-- /.search__body --\x3e\n
\x3c!-- /.product--notifyme --\x3e\n
\x3c!-- /.widget__offer --\x3e\n
\x3c!-- /.product--stock --\x3e'; Vue.component("buy-component", { template: html, data: function() { return { product: { idProduct: "", name: "", sku: "", SellerId: "", stock: !0, modal: !1, load: !0, price: { listPrice: "", bestPrice: "", discount: "" }, installment: { quatity: "", value: "" } }, notifyme: { name: "", email: "" } } }, created: function() { var e = this; "undefined" == typeof skuJson ? e.getSku($("#___rc-p-sku-ids").val()) : (e.product.stock = skuJson.available, e.selectFirstSkuAvailable()), $(window).on("skuSelected.vtex", function(t, n, i) { e.getSku(i.sku) }) }, methods: { getSku: function(e) { var t = this; $.ajax({ url: "/produto/sku/" + e, type: "GET", dataType: "json", success: function(e) { t.formatDateProduct(e[0]) } }) }, formatDateProduct: function(e) { var t = this; t.product.idProduct = e.IdProduct, t.product.name = e.Name, t.product.sku = e.Id, t.product.price.listPrice = t.formatMoney(e.ListPrice, 2, ",", ".", "R$"), t.product.price.bestPrice = t.formatMoney(e.Price, 2, ",", ".", "R$"), t.product.price.discount = t.valueDiscount(e.Price), t.product.installment.quatity = e.BestInstallmentNumber, t.product.installment.value = t.formatMoney(e.BestInstallmentValue, 2, ",", ".", "R$"), t.product.SellerId = e.DefaultSellerId, t.product.stock = e.Availability }, selectFirstSkuAvailable: function() { var e = skuJson.skus.filter(function(e) { return 1 == e.available }); this.getSku(e[0].sku) }, formatMoney: function(e, t, n, i, a) { if (e && t && n && i && a) { e = (e + "").replace(",", "").replace(" ", ""); var o = isFinite(+e) ? +e : 0, r = isFinite(+t) ? Math.abs(t) : 0, s = void 0 === i ? "," : i, c = void 0 === n ? "." : n, l = "", u = function(e, t) { var n = Math.pow(10, t); return "" + Math.round(e * n) / n }; return l = (r ? u(o, r) : "" + Math.round(o)).split("."), l[0].length > 3 && (l[0] = l[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, s)), (l[1] || "").length < r && (l[1] = l[1] || "", l[1] += new Array(r - l[1].length + 1).join("0")), a + " " + l.join(c) } }, convertMoneyToFloat: function(e) { if (e) return parseFloat(e.toString().replace(".", "").replace(",", ".").replace("R$", "").replace("R$ ", "")) }, valueDiscountBoleto: function() { // var e, t, n, i = "BL"; // return $.ajax({ // url: "//api.vtexcrm.com.br/" + jsnomeLoja + "/dataentities/" + i + "/search?_fields=desconto,ativo", // type: "GET", // async: !1, // headers: { // Accept: "application/vnd.vtex.ds.v10+json", // "Content-Type": "application/json" // }, // success: function(i) { // if (t = i, t.length > 0) // for (n = 0; n < t.length; n++) // if (1 == t[n].ativo) { // e = t[n].desconto; // break // } // }, // error: function(e) {} // }), e }, installment: function(e, t, n, i, a) { if (e && t && i && a) { var o = this, r = []; t = parseInt(t), n = parseFloat(n), i = parseFloat(i); var s, c = o.convertMoneyToFloat(e, a), l = parseInt(c / i), u = ""; if (l > t && (l = t), s = c / l, 0 === n) { if (l > 0) return r.parc = l + "x", r.parc_number = l, r.vl = o.formatMoney(s, 2, ",", ".", a), r.vl_number = s, r.juros = null, r } else if (u = n / 100, s = c * Math.pow(1 + u, l) / l, l > 0) return r.parc = l + "x", r.parc_number = l, r.val = o.formatMoney(s, 2, ",", ".", a), r.vl_number = s, r.juros = parseFloat(n) + "% a.m", r.juros_number = n, r } }, valueDiscount: function(e) { // if (e) { // var t = this.valueDiscountBoleto(); // return this.formatMoney(e - e * parseInt(t) / 100, 2, ",", ".", "R$") // } }, addToCart: function() { return "/checkout/cart/add?sku=" + this.product.sku + "&qty=1&seller=" + this.product.SellerId + "&redirect=true&sc=1" }, sendNotifyme: function() { var e = this; if (!/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i.test(e.notifyme.email)) return swal({ type: "error", title: "Ops.. informe um e-mail valido." }), !1; $.ajax({ url: "/no-cache/AviseMe.aspx", type: "POST", dataType: "json", data: { notifymeClientName: e.notifyme.name, notifymeClientEmail: e.notifyme.email, notifymeIdSku: skuJson.skus[0].sku }, success: function(e) { swal({ type: "success", title: "Assim que o produto for disponibilizado você receberá um email avisando." }) }, error: function(e) { swal({ type: "error", title: "Ocorreu um erro ao cadastrar seu email tente novamente mais tarde." }) } }) } } }); var html = '\n
\n
\n

Compre junto:

\n\n
\n
\n
\n
\n \n \n \n
\x3c!-- /.book__image --\x3e\n \n
{{item.title}}
\x3c!-- /.book__title --\x3e\n \n
\x3c!-- /.book__author --\x3e\n \n \x3c!-- /.rating --\x3e\n
\x3c!-- /.book --\x3e\n
\x3c!-- /.section__content --\x3e\n\n
\n
Leve os {{buy_together.items.length}} produtos por:
\n\n

{{buy_together.total_price}} em {{buy_together.installment.number}} de {{buy_together.installment.price}}

\n\n

{{total_price_with_desc}} à vista | 1x no cartão
\n Economize {{price_desc}} ({{desc_a_vista}}%)

\n\n Comprar produtos juntos\x3c!-- /.btn-secondary --\x3e\n
\x3c!-- /.section__aside --\x3e\n
\x3c!-- /.section__image --\x3e\n
\x3c!-- /.shell --\x3e\n
\x3c!-- /.section-suggestion --\x3e\n'; Vue.component("buytogether-component", { template: html, props: ["items"], data: function() { return { data: [], product_ctrl: new ProductController, id_sku: "", buy_together: "", desc_a_vista: 5, total_price_with_desc: "", price_desc: "" } }, methods: { getProductsOfBuyTogether: function() { var e = this; this.product_ctrl.getBuyTogether(this.id_sku, function(t) { if (console.warn("getProductsOfBuyTogether", t), !t) return void(e.buy_together = ""); e.buy_together = t, e.totalPriceWithDesc() }) }, totalPriceWithDesc: function() { var e = savana.getValueBill(this.buy_together.total_price, this.desc_a_vista, "R$"); this.total_price_with_desc = e.total, this.price_desc = e.descount }, init: function(e) { e && (this.id_sku = e, this.getProductsOfBuyTogether()) } }, mounted: function() {}, computed: {}, watch: {} }); var html = '\n\x3c!-- /.gallery--componen --\x3e'; Vue.component("gallery-component", { template: html, data: function() { return { gallery: { main: "", name: "", thumbs: [], active: !1, video: { thumb: "", src: "", empty: !0, showModal: !1 } } } }, mounted: function() { $("body").hasClass("produto-kit") ? this.getImages($("#___rc-p-sku-ids").val(), !0) : this.getImages($("input#___rc-p-sku-ids").val().split(",")[0]), this.getVideo() }, methods: { getImages: function(e, t) { var n = this; $.get("/produto/sku/" + e, function(e) { if (n.gallery.main = e[0].Images[0][0].Path, t) for (var i = 0; i < e[0].Images.length; i++) for (var a = 0; a < e[0].Images[i].length; a++) "hoverVitrine" == e[0].Images[i][a].Name && (n.gallery.main = e[0].Images[i][a].Path); n.gallery.name = savana.rewrite(e[0].Name); for (var o = 0; o < e[0].Images.length; o++) n.gallery.thumbs.push(e[0].Images[o][0].Path) }) }, changeImage: function(e, t) { this.gallery.main = e, this.gallery.active = t }, getVideo: function() { var e = this; $.get("/api/catalog_system/pub/products/search/?fq=productId:" + $("#___rc-p-id").val(), function(t) { t[0].Video && t[0].Video[0] && (e.gallery.video.thumb = "http://i3.ytimg.com/vi/" + t[0].Video[0].split("watch?v=")[1] + "/default.jpg", e.gallery.video.src = "https://www.youtube.com/embed/" + t[0].Video[0].split("watch?v=")[1] + "?rel=0&showinfo=0", e.gallery.video.empty = !1) }) } } }); var html = '
\n \n \n \n
'; Vue.component("instagram-component", { template: html, data: function() { return { vtexName: "augustojoias", instaToken: "6026a132e2f240d3aa03283a620aa35d", instaUser: "25637926", MDEntity: "IN", MDDateField: "LastHour", MDObjectField: "Images", header: { Accept: "application/vnd.vtex.ds.v10+json", "Content-Type": "application/json; charset=utf-8" }, now: "", alreadyGetMDInfo: !1, photos: [] } }, created: function() { var e = new Date; e.setMinutes(0), e.setSeconds(0), e.setMilliseconds(0), this.now = e }, mounted: function() {}, methods: { getInfoMD: function() { var e = this; $.ajax({ url: "//api.vtexcrm.com.br/" + this.vtexName + "/dataentities/" + this.MDEntity + "/search?_fields=" + this.MDDateField + "," + this.MDObjectField + ",id", type: "GET", headers: this.header, success: function(t) { t.length && !(new Date(t[0].LastHour) < e.now) && void 0 != t[0].Images || e.alreadyGetMDInfo ? t.length && void 0 != t[0].Images && (e.photos = JSON.parse(t[0].Images).data.filter(function(e, t) { if (t < 6) return e })) : (e.alreadyGetMDInfo = !0, e.getInfoInsta()) }, error: function(e) { console.error(e) } }) }, getInfoInsta: function() { var e = this; $.ajax({ url: "https://api.instagram.com/v1/users/" + this.instaUser + "/media/recent/?access_token=" + this.instaToken, type: "GET", dataType: "jsonp", cache: !1, success: function(t) { console.log(">>>>>>>>>>> getInfoInsta <<<<<<<<<<<<", t), e.updateInstaToMD(t) } }) }, updateInstaToMD: function(e) { var t = this; $.ajax({ url: "//api.vtexcrm.com.br/" + this.vtexName + "/dataentities/" + this.MDEntity + "/documents", data: JSON.stringify({ id: "1000001", LastHour: this.now.toString(), Images: JSON.stringify(e) }), type: "PATCH", headers: this.header, success: function(e) { t.getInfoMD() }, error: function(e) { console.error(e) } }) } } }); var html = '
\n
\n
\n
Para ela:
\n\n \n
\x3c!-- /.buy-component --\x3e\n\n
\n
Para ele:
\n\n \n
\x3c!-- /.buy-component --\x3e\n\n \n \n Guia de
Medidas
\n
\n
\x3c!-- /.widget__section --\x3e\n\n
\n
\n

\n {{ formatMoney(product.listPrice, 2, ",", ".", "R$") }}\n

\x3c!-- /.widget__oldprice --\x3e\n\n

\n {{ formatMoney(product.bestPrice, 2, ",", ".", "R$") }} \n

\n\n

\n {{ product.installment.number }}x de {{ formatMoney(product.installment.value, 2, ",", ".", "R$") }}\n

\n
\x3c!-- /.widget__price --\x3e\n\n \x3c!-- /.widget__actions --\x3e\n\n
\n

\n \n 10% de desconto no boleto\n

\x3c!-- /.promo --\x3e\n
\x3c!-- /.widget__promo --\x3e\n
\x3c!-- /.widget__offer --\x3e\n\n \n \x3c!-- /.modal-mask --\x3e\n \n\n
\n \n
\x3c!-- /.shipping-component --\x3e\n
'; Vue.component("kit-component", { template: html, data: function() { return { variations: { woman: [], man: [] }, selected: { woman: { tapy: "woman", sku: "", variation: "Selecione", disabled: !1 }, man: { tapy: "man", sku: "", variation: "Selecione", disabled: !1 } }, addToCart: { link: !1, disabled: !0 }, product: { name: "", isKit: !0, listPrice: "", bestPrice: "", stock: "", discount: "", showModal: !1, installment: { number: "", value: "" } } } }, created: function() { this.getSkus(), this.getPrice($("#___rc-p-sku-ids").val()) }, methods: { getSkus: function() { var e = this, t = $("#___rc-p-kit-ids").val().split(","), n = ""; t.forEach(function(e) { n += "&fq=skuId:" + e }), $.get("/api/catalog_system/pub/products/search?fq=" + n, function(t) { for (var n = 0; n < t.length; n++) { if (t[n]["Tipo da alianca"] || swal("Ops..", "Houve um erro ao carregar esse produto", "error"), t[n]["Tipo da alianca"] && "Feminino" == t[n]["Tipo da alianca"][0]) for (var i = 0; i < t[n].items.length; i++) e.variations.woman.push({ sku: t[n].items[i].itemId, name: t[n].items[i].name, variation: t[n].items[i].Aro[0] }); if (t[n]["Tipo da alianca"] && "Masculino" == t[n]["Tipo da alianca"][0]) for (var i = 0; i < t[n].items.length; i++) e.variations.man.push({ sku: t[n].items[i].itemId, name: t[n].items[i].name, variation: t[n].items[i].Aro[0] }) } }) }, getPrice: function(e) { var t = this; $.get("/produto/sku/" + e, function(e) { t.product.name = e[0].name, t.product.listPrice = e[0].ListPrice, t.product.bestPrice = e[0].Price, t.product.stock = e[0].Availability, t.product.discount = t.discount(e[0].Price), t.product.installment.number = e[0].BestInstallmentNumber, t.product.installment.value = e[0].BestInstallmentValue }) }, validateStock: function(e) { var t = this; if ("woman" == e.tapy) for (var n = 0; n < t.variations.woman.length; n++) t.variations.woman[n].variation == e.variation && "woman" == e.tapy && (t.selected.woman.sku = t.variations.woman[n].sku, t.selected.woman.disabled = !0); if ("man" == e.tapy) for (var n = 0; n < t.variations.man.length; n++) t.variations.man[n].variation == e.variation && "man" == e.tapy && (t.selected.man.sku = t.variations.man[n].sku, t.selected.man.disabled = !0); t.selected.woman.disabled && t.selected.man.disabled && (t.addToCart.link = "/checkout/cart/add?sku=" + t.selected.woman.sku + "&qty=1&seller=1&sku=" + t.selected.man.sku + "&qty=1&seller=1&redirect=true&sc=1", t.addToCart.disabled = !1) }, formatMoney: function(e, t, n, i, a) { if (e && t && n && i && a) { e = (e + "").replace(",", "").replace(" ", ""); var o = isFinite(+e) ? +e : 0, r = isFinite(+t) ? Math.abs(t) : 0, s = void 0 === i ? "," : i, c = void 0 === n ? "." : n, l = "", u = function(e, t) { var n = Math.pow(10, t); return "" + Math.round(e * n) / n }; return l = (r ? u(o, r) : "" + Math.round(o)).split("."), l[0].length > 3 && (l[0] = l[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, s)), (l[1] || "").length < r && (l[1] = l[1] || "", l[1] += new Array(r - l[1].length + 1).join("0")), a + " " + l.join(c) } }, discount: function(e) { if (e) { var t = 10 * e / 100; return this.formatMoney(e - t, 2, ",", ".", "R$") } } } }); var $cart = '\n
  • \n \n {{ cart.amount }} \n \n\n \n \x3c!-- /.popup-cart --\x3e\n \n\n \n
    \n
    \n
  • \x3c!-- /. mini-cart --\x3e\n'; Vue.component("mini-cart", { template: $cart, data: function() { return { cart: { show: !1, products: [], amount: null, totalPrice: null, installments: "", installmentValue: "" }, modal: !1 } }, created: function() { this.getProducts() }, mounted: function() { this.scrollBar() }, methods: { getProducts: function() { var e = this; vtexjs.checkout.getOrderForm().then(function(t) { e.cart.products = []; t.items.filter(function(t) { return e.cart.products.push({ sku: t.id, link: t.detailUrl, price: e.formatMoney(t.price / 100, 2, ",", ".", "R$"), name: t.name, image: t.imageUrl.replace("-55-55", "-106-106"), quantity: t.quantity }) }); t.items.length, e.cart.amount = t.items.length, e.cart.totalPrice = e.formatMoney(t.value / 100, 2, ",", ".", "R$"), t.items.length && (e.cart.installments = t.paymentData.installmentOptions[0].installments.length, e.cart.installmentValue = e.installment(e.formatMoney(t.paymentData.installmentOptions[0].value / 100, 2, ",", ".", "R$"), parseFloat(e.cart.installments), 0, 5, "R$").vl) }) }, scrollBar: function() { var e = setInterval(function() { $(".container-products .products .product-alternative").length && ($(".component-item-cart .container-products .products").mCustomScrollbar({ setHeight: 250, scrollInertia: 250 }), clearInterval(e)) }, 2e3) }, removeItem: function(e) { var t = this; vtexjs.checkout.getOrderForm().then(function(t) { var n = t.items[e]; return n.index = e, vtexjs.checkout.removeItems([n]) }).done(function(e) { t.getProducts(), swal({ type: "success", title: "Removido...", text: "Item removido com sucesso." }) }) }, updateItems: function(e, t) { var n = this; vtexjs.checkout.getOrderForm().then(function(n) { return vtexjs.checkout.updateItems([{ index: e, quantity: t }], null, !1) }).done(function(e) { n.getProducts() }) }, formatMoney: function(e, t, n, i, a) { if (e && t && n && i && a) { e = (e + "").replace(",", "").replace(" ", ""); var o = isFinite(+e) ? +e : 0, r = isFinite(+t) ? Math.abs(t) : 0, s = void 0 === i ? "," : i, c = void 0 === n ? "." : n, l = "", u = function(e, t) { var n = Math.pow(10, t); return "" + Math.round(e * n) / n }; return l = (r ? u(o, r) : "" + Math.round(o)).split("."), l[0].length > 3 && (l[0] = l[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, s)), (l[1] || "").length < r && (l[1] = l[1] || "", l[1] += new Array(r - l[1].length + 1).join("0")), a + " " + l.join(c) } }, limitString: function(e, t) { return e.length > t ? e.substr(0, t) + " ..." : e }, installment: function(e, t, n, i, a) { if (e && t && i && a) { var o = this, r = []; t = parseInt(t), n = parseFloat(n), i = parseFloat(i); var s, c = o.convertMoneyToFloat(e, a), l = parseInt(c / i), u = ""; if (l > t && (l = t), s = c / l, 0 === n) { if (l > 0) return r.parc = l + "x", r.parc_number = l, r.vl = o.formatMoney(s, 2, ",", ".", a), r.vl_number = s, r.juros = null, r } else if (u = n / 100, s = c * Math.pow(1 + u, l) / l, l > 0) return r.parc = l + "x", r.parc_number = l, r.val = o.formatMoney(s, 2, ",", ".", a), r.vl_number = s, r.juros = parseFloat(n) + "% a.m", r.juros_number = n, r } }, convertMoneyToFloat: function(e) { if (e) return parseFloat(e.toString().replace(".", "").replace(",", ".").replace("R$", "").replace("R$ ", "")) } } }); var html = '\n\x3c!-- /.nav-categories --\x3e\n'; Vue.component("nav-component", { template: html, props: ["items"], data: function() { return { data: [] } }, methods: { getCategories: function() { var e = this; (new CategoryController).getCategories(function(t) { t.splice(0, 1), t = t.map(function(t) { return t.rewrite = e.rewrite(t.name), t.children = t.children.map(function(t) { return t.rewrite = e.rewrite(t.name), t }), t }), e.$store.dispatch("changeCategories", t) }) }, rewrite: function(e) { if (e) return savana.rewrite(e) } }, mounted: function() { this.getCategories() }, computed: { categories: function() { return this.$store.state.categories } }, watch: { categories: function() { console.warn("categories=============", this.categories) } } }); var html = '\n
    \n
    \n
    \n \n\n
    \n \n
    \x3c!-- /.form__controls --\x3e\n
    \x3c!-- /.form__col --\x3e\n \n
    \n \n\n
    \n \n \n
    \x3c!-- /.form__controls --\x3e\n
    \x3c!-- /.form__col --\x3e\n
    \x3c!-- /.form__row --\x3e\n
    \n'; Vue.component("newslatter-component", { template: html, data: function() { return { email: "", name: "" } }, created: function() {}, mounted: function() {}, methods: { validateBeforeSubmit: function() { var e = this, t = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; return null != e.email && "" != e.email && t.test(e.email) ? null == e.name || "" == e.name ? (swal({ type: "error", title: "Oops...", text: "Informe seu nome." }), !1) : void e.sendNewsletter() : (swal({ type: "error", title: "Oops...", text: "Informe um e-mail valido." }), !1) }, sendNewsletter: function() { var e = this; $.ajax({ url: "/no-cache/Newsletter.aspx", type: "POST", dataType: "json", data: { newsletterClientName: e.name, newsletterClientEmail: e.email, newsInternalPage: "_", newsInternalPart: "newsletter", newsInternalCampaign: "newsletter:opt-in" }, success: function(e) { swal({ type: "success", text: "E-mail cadastrado com sucesso!" }) }, error: function(e) { toast({ type: "success", title: "Ocorreu um erro ao cadastrar seu email tente novamente mais tarde." }), swal({ type: "error", title: "Oops...", text: "Ocorreu um erro ao cadastrar seu email tente novamente mais tarde." }) } }) } } }); var html = '
    \n \n\n \n \n Guia de
    Medidas
    \n
    \n\n \n \x3c!-- /.modal-mask --\x3e\n \n
    '; Vue.component("products-similar", { template: html, data: function() { return { showModal: !1, variations: [], selected: skuJson.skus[0].dimensions.Comprimento } }, created: function() { this.getSkus() }, methods: { getSkus: function() { var e = this, t = ""; $("#___rc-p-kit-ids").val().split(",").forEach(function(e) { t += "&fq=skuId:" + e }), $.get("/api/catalog_system/pub/products/crossselling/similars/" + $("#___rc-p-id").val(), function(t) { for (var n = 0; n < t.length; n++) e.variations.push({ idSku: t[n].items[0].itemId, variation: t[n].items[0].Comprimento[0], link: t[n].link, stock: t[n].items[0].sellers[0].commertialOffer.AvailableQuantity }) }) }, changeSelector: function() { var e = this; e.variations.filter(function(t) { t.variation == e.selected && savana.redirect(t.link + "?idsku=" + t.idSku) }) } } }); var html = '\n
  • \n \n Minha Conta\n \n \n
    \n \n \n
    \n
  • \n'; Vue.component("profile", { template: html, props: ["items"], data: function() { return { profile: {}, is_auth: !1 } }, methods: { getOrderForm: function() { var e = this; vtexjs.checkout.getOrderForm().done(function(t) { e.$store.dispatch("changeOrderForm", t) }) }, getUserLogged: function() { var e = this; (new ProfileController).getUserLogged(function(t) { e.profile = t, console.log(t) }) } }, mounted: function() { this.getUserLogged() } }); var html = '\n\x3c!-- /.search --\x3e\n'; Vue.component("searchtop-component", { template: html, props: ["items"], data: function() { return { data: [], search_query: "", category: "", category_rewrite: "", search_context: [], suggestions: [], has_suggestions: !1 } }, methods: { handleSearch: function() { var e = this; this.has_suggestions = !0, this.search_context = ""; var t = this.search_query, n = new SearchController; clearInterval(window.interval), n.isSearchValid(t) && (window.interval = setInterval(function() { clearInterval(window.interval), e.autocomplete() }, 500)) }, buildImage: function(e) { if (e) return '' }, sizeImageProductSearch: function(e) { if (e) { var t = new HelpersComponents; return this.buildImage(t.sizeImageThumb(e, "25-25", "60-60")) } }, searchContext: function(e) { if (this.search_query) { var t = "function" == typeof e; (new SearchController).getAutocomplete(this.search_query, function(n) { t && e(n ? n : !1) }) } }, searchProducts: function(e) { if (this.search_query) { var t = "function" == typeof e, n = this.search_query, i = { ft: n + "&O=OrderByBestDiscountDESC", _from: 0, _to: 49 }; (new SearchController).getProducts(i, function(n) { t && e(n ? n : !1) }) } }, autocomplete: function() { var e = this; this.search_query && (this.search_context = [], this.suggestions = [], this.searchContext(function(t) { if (!t) return void nestle.notify().error(); console.log("response 11======>", t), e.search_context = t.slice(0, 5), e.searchProducts(function(t) { return t ? t.length ? (t = (new HelpersComponents).addQuantityOnitem(t), e.suggestions = t, void setTimeout(function() { $(".search__results .products").mCustomScrollbar() }, 500)) : void(e.has_suggestions = !1) : void nestle.notify().error() }) })) }, goSearchPage: function() { if (this.search_query.length) { var e, t; t = this.search_query; e = (this.category_rewrite ? "/" + this.category_rewrite : "") + "/" + t, savana.redirect(e) } }, convertToMoney: function(e) { if (void 0 !== e) return savana.formatMoney(e, 2, ",", ".", "R$") }, setCategoryChoose: function() { var e = this.category.split("-")[1]; return this.category_rewrite = savana.rewrite(e), !0 } }, mounted: function() {}, computed: { categories: function() { return this.$store.state.categories } } }); var html = '\n
    \n
    Escolha as medidas:
    \n\n \n\n \n \n Guia de
    Medidas
    \n
    \x3c!-- /.widget__btn --\x3e\n\n \n \x3c!-- /.modal-mask --\x3e\n \n
    \x3c!-- /.selection--component --\x3e'; Vue.component("selection-component", { template: html, data: function() { return { product: { stock: !1, existVariations: "", variations: "", selected: "Selecione", showModal: !1 } } }, created: function() { this.getSkus() }, methods: { getSkus: function() { var e = this; e.product.existVariations = skuJson.skus.length > 0, e.product.variations = skuJson.skus.map(function(e, t) { return { name: e.skuname, variation: e.dimensions.Aro, stock: e.available, sku: e.sku } }), e.product.variations.sort(function(e, t) { return e.variation < t.variation ? -1 : e.variation > t.variation ? 1 : 0 }) }, changeSku: function(e) { var t = this, n = t.product.variations.filter(function(t, n) { return t.variation == e }); App.$refs.bayButtom.getSku(n[0].sku) } } }); var html = '\n
    \n
    \n \n \n \n
    \n\n \n \x3c!-- /.popup-cart --\x3e\n \n\n \n
    \n
    \n
    \x3c!-- /.widget__shipping --\x3e\n'; Vue.component("shipping", { template: html, data: function() { return { shipping: { stock: "", showModal: !1, postalCode: "", logistics: [], load: !1 } } }, created: function() { this.getStock() }, methods: { getStock: function() { var e = this; $.ajax({ url: "/produto/sku/" + $("#___rc-p-sku-ids").val().split(",")[0], type: "GET", dataType: "json", success: function(t) { e.shipping.stock = t[0].Availability } }) }, formatMoney: function(e, t, n, i, a) { if (e && t && n && i && a) { e = (e + "").replace(",", "").replace(" ", ""); var o = isFinite(+e) ? +e : 0, r = isFinite(+t) ? Math.abs(t) : 0, s = void 0 === i ? "," : i, c = void 0 === n ? "." : n, l = "", u = function(e, t) { var n = Math.pow(10, t); return "" + Math.round(e * n) / n }; return l = (r ? u(o, r) : "" + Math.round(o)).split("."), l[0].length > 3 && (l[0] = l[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, s)), (l[1] || "").length < r && (l[1] = l[1] || "", l[1] += new Array(r - l[1].length + 1).join("0")), a + " " + l.join(c) } }, validadePostalCode: function() { var e = this; if (e.shipping.load = !0, null == e.shipping.postalCode || "" == e.shipping.postalCode || e.shipping.postalCode.length < 8) return void swal({ type: "error", title: "Informe um CEP valido." }); e.getShipping() }, getShipping: function() { var e = this; e.shipping.logistics = []; for (var t = 0; t < skuJson_0.skus.length; t++) if (1 == skuJson_0.skus[t].available) { var n = { items: [{ id: skuJson_0.skus[t].sku, quantity: 1, seller: skuJson_0.skus[t].sellerId }], postalCode: e.shipping.postalCode, country: "BRA", sc: '6' }; vtexjs.checkout.getOrderForm().then(function(t) { $.ajax({ type: "POST", dataType: "json", contentType: "application/json", url: "/api/checkout/pub/orderForms/simulation/", data: JSON.stringify(n), success: function(t) { e.shipping.showModal = !0; for (var n = 0; n < t.logisticsInfo[0].slas.length; n++) e.shipping.logistics.push({ name: t.logisticsInfo[0].slas[n].name, price: t.logisticsInfo[0].slas[n].price > 0 ? e.formatMoney(t.logisticsInfo[0].slas[n].price / 100, 2, ",", ".", "R$") : "Grátis", estimated: t.logisticsInfo[0].slas[n].shippingEstimate.replace("bd", "") }) }, error: function() { e.shipping.showModal = !1, swal({ type: "error", title: "Informe um CEP valido." }) } }) }); break } } } }); var App = new Vue({ store: store, el: "#app" });