Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <template>
- <div class="customers">
- <!-- <navbar></navbar> -->
- <div v-if="sections.navbar" id="navbar">
- <nav class="navbar navbar-default">
- <img id="logo" src="~@/assets/logotarget.png" alt="targetmoda">
- <div class="container">
- <div class="navbar-header">
- <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- </div>
- <div id="navbar" class="collapse navbar-collapse">
- <!-- <ul class="nav navbar-nav">
- <li><router-link to="/">Home</router-link></li>
- <li><router-link to="/products">Productos</router-link></li>
- </ul> -->
- <!-- <qty></qty> -->
- <div v-on:click="handler('cart')" id="cart-badge" class="button-logout">
- <button type="button" class="btn btn-large" title="Ir al carrito">
- <!-- <router-link to="/cart"><span class="glyphicon glyphicon-shopping-cart btn-large" aria-hidden="true"></span> <span v-model="badgeItems" class="badge"> {{ badge }}</span></router-link> -->
- <span class="icon-Mi_carrito-02 size-3x coral" aria-hidden="true"></span><br><span v-model="badgeItems" class="badge"> {{ badge }}</span>
- </button>
- </div>
- <div v-on:click="syncApp" class="button-logout">
- <button type="button" class="btn btn-large" title="Sincronizar aplicación">
- <span class="icon-Sincronizar-02 size-3x coral" aria-hidden="true"></span><br><span class="text-uppercase x-small coral">Sincronizar</span>
- </button>
- </div>
- <div v-on:click="goToSection('orders')" class="button-logout">
- <button type="button" class="btn btn-large" title="Ver pedidos">
- <span class="icon-Pedidos-02 size-3x coral" aria-hidden="true"></span><br><span class="text-uppercase x-small coral">Pedidos</span>
- </button>
- </div>
- <div v-on:click="logout" class="button-logout">
- <button type="button" class="btn btn-large" title="Salir y cerrar sesión">
- <span class="icon-Salir-02 size-3x coral" aria-hidden="true"></span><br><span class="text-uppercase x-small coral" style="margin-left:10px;">Salir</span>
- </button>
- </div>
- </div>
- </div>
- </nav>
- <div id="success-add-to-cart" class="flash-message">
- <div class="alert alert-success">
- <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
- <strong>¡Agregado satisfactoriamente!</strong>
- </div>
- </div>
- <div id="success-downloaded-csv" class="flash-message">
- <div class="alert alert-success">
- <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
- <strong>¡CSV descargado satisfactoriamente!</strong>
- </div>
- </div>
- <div id="error-downloaded-csv" class="flash-message">
- <div class="alert alert-danger">
- <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
- <strong>Error al descargar el CSV</strong>
- </div>
- </div>
- </div>
- <div v-if="sections.thanks" id="thanks">
- <div class="row">
- <div class="jumbotron" style="box-shadow: 2px 2px 4px #000000;">
- <h4 class="text-center">El pedido se finalizó y guardó correctamente. <br> Por favor no olvides enviarnos el pedido una vez tengas conexión a Internet</h4>
- <center><div class="btn-group" style="margin-top:50px;">
- <!-- <div class="btn btn-success"><router-link to="/products">Seguir comprando</router-link></div> -->
- <div v-on:click="goToSection('products'), emptyQuoute" class="btn btn-success" id="thanks-keep">Seguir comprando</div>
- </div></center>
- </div>
- </div>
- </div>
- <!-- INDEX Checkout -->
- <div v-if="sections.checkout" id="checkout">
- <div id="checkout-content">
- <!-- BREADCRUMBS -->
- <div class="page-header">
- <span v-on:click="goToSection('products')" class="pointerHand">Carrito</span>
- >
- <span class="active-step">Check Out</span>
- >
- <span>Pedido finalizado</span>
- </div>
- <!-- /BREADCRUMBS/ -->
- <!-- CHECKOUT Body -->
- <div class="row grid-divider">
- <!-- LEFT Column -->
- <div id="order-box" class="col-md-7">
- <div class="col-padding">
- <h3>TU PEDIDO</h3>
- <h4>*Despliegue las categorías para aplicar descuentos individualmente a los productos que seleccionó </h4>
- <div v-for="(value, key, index) in categories" class="panel-group">
- <div class="panel panel-default">
- <div class="panel-heading">
- <h4 class="panel-title">
- <a :href="'#' + key.replace(/[\s\W]/g, '')">{{ key }}<!--<span v-show="!isEmpty(value)"class="caret"></span--></a>
- <div class="discount-box">
- <label :for="'discount_' + key.replace(/[\s\W]/g, '')">Descuento</label>
- <input type="number" min="0" class="discount-input"
- :id="'discount_' + key.replace(/[\s\W]/g, '')" @change="setCategoryDiscount(key)" placeholder="%">
- </div>
- </h4>
- </div>
- <div :id="key.replace(/[\s\W]/g, '')" class="panel-collapse">
- <!-- <div v-for="(valueK, keyK, indexK) in value" class="panel-body"> -->
- <div class="panel-body">
- <div class="border-box">
- <table :class="'table table-hover table-condensed table_cat_' + key.replace(/\s/g, '')">
- <!-- <table style="display:none" :class="'table table-hover table-condensed'"> -->
- <thead>
- <tr>
- <th class="col-xs-2">Foto</th>
- <th class="col-xs-2">Producto</th>
- <th class="col-xs-1">Precio</th>
- <th class="col-xs-1">Cantidad</th>
- <th class="col-xs-1">% Desc.</th>
- <th class="text-center col-xs-1">Subtotal</th>
- </tr>
- </thead>
- <tbody>
- <!-- <tr v-if="checkProductParentCat(valueP.data.categories, key.replace(/\s/g, ''))" v-for="(valueP, keyP, indexP) in sessionProductsData"> -->
- <tr v-if="fetchCategories()" v-for="(valueP, keyP, indexP) in sessionProductsData">
- categories --> {{valueP.data.categories}}
- <td data-th="Product">
- <div class="row">
- <div class="col-sm-2 hidden-xs">
- <img class="product-image" v-bind:src="'file://' + valueP.data.images[0].local_src" alt="" />
- </div>
- </div>
- </td>
- <td data-th="Product">
- <div class="row">
- <div class="col-sm-10">
- <div class="nomargin title-table">
- <input :id="'checkbox_' + keyP" type="checkbox" :value="keyP.replace(/\s/g, '')" checked>
- {{valueP.data.title}}
- </div>
- <!-- <h4 class="nomargin">{{keyK}}</h4> -->
- </div>
- </div>
- </td>
- <input type="hidden" class="show_table_desc" :value="key.replace(/\s/g, '')"/>
- <td data-th="Quantity">
- <div class="text-center price-table">${{valueP.data.price}}</div>
- </td>
- <td data-th="Quantity">
- <span class="form-control text-center">{{valueP.data.qty}}</span>
- </td>
- <td data-th="Quantity">
- <input type="number" min="0"
- :class="'form-control text-center discount-input-' + keyP.replace(/\s/g, '')"
- :id="'discount_' + keyP.replace(/\s/g, '')" placeholder="%"
- value="" @change="setProductDiscount(keyP.replace(/\s/g, ''))">
- </td>
- <td style="padding-top:4%" data-th="Subtotal" class="text-center" v-if="valueP.data.subtotal > 0">
- <strike>${{ valueP.data.price * valueP.data.qty }}<br></strike>
- ${{ valueP.data.subtotal }}</td>
- <td style="padding-top:4%" data-th="Subtotal" class="text-center" v-else>
- ${{ valueP.data.price * valueP.data.qty }}
- </td>
- </tr>
- </tbody>
- <tfoot>
- </tfoot>
- </table>
- </div>
- <div class="panel panel-default">
- <!-- <div class="panel-heading">
- <h4 class="panel-title">
- <a data-toggle="collapse" :href="'#' + key.replace(/[\s\W]/g, '') + '_' + keyK.replace(/[\s\W]/g, '')">{{ keyK }}<span v-show="!isEmpty(valueK)"class="caret"></span></a>
- <div class="discount-box">
- <label :for="'discount_' + key.replace(/[\s\W]/g, '') + '_' + keyK.replace(/[\s\W]/g, '')">Descuento </label>
- <input type="number"
- min="0" :class="'discount-input-' + key.replace(/[\s\W]/g, '') + '_' + keyK.replace(/[\s\W]/g, '')" :id="'discount_' + key.replace(/[\s\W]/g, '') + '_' + keyK.replace(/[\s\W]/g, '')"
- @change="setCategoryDiscount(key + '_' + keyK)" placeholder="%">
- </div>
- </h4>
- </div> -->
- </div>
- <div class="panel panel-default">
- <!-- <div class="panel-heading">
- <h4 class="panel-title">
- <a data-toggle="collapse" :href="'#' + key.replace(/[\s\W]/g, '') + '_' + keyK.replace(/[\s\W]/g, '')">{{ keyK }}<span v-show="!isEmpty(valueK)"class="caret"></span></a>
- <div class="discount-box">
- <label :for="'discount_' + key.replace(/[\s\W]/g, '') + '_' + keyK.replace(/[\s\W]/g, '')">Descuento </label>
- <input type="number"
- min="0" :class="'discount-input-' + key.replace(/[\s\W]/g, '') + '_' + keyK.replace(/[\s\W]/g, '')" :id="'discount_' + key.replace(/[\s\W]/g, '') + '_' + keyK.replace(/[\s\W]/g, '')"
- @change="setCategoryDiscount(key + '_' + keyK)" placeholder="%">
- </div>
- </h4>
- </div> -->
- <!-- <div :id="key.replace(/[\s\W]/g, '') + '_' + keyK.replace(/[\s\W]/g, '')" class="panel-collapse collapse">
- <div v-for="(valueM, keyM, indexM) in valueK" class="panel-body">
- <div class="border-box">
- <table style="display:none" :class="'table table-hover table-condensed table_cat_' + keyM">
- <thead>
- <tr>
- <th class="col-xs-2">Foto</th>
- <th class="col-xs-2">Producto</th>
- <th class="col-xs-1">Precio</th>
- <th class="col-xs-1">Cantidad</th>
- <th class="col-xs-2">% Desc.</th>
- <th class="text-center col-xs-1">Subtotal</th>
- </tr>
- </thead>
- <tbody>
- <tr v-if="valuePQ.data.categories[0].replace(/\s/g, '') === keyM.replace(/\s/g, '')" v-for="(valuePQ, keyPQ, indexPQ) in sessionProductsData">
- <td data-th="Product">
- <div class="row">
- <div class="col-sm-2 hidden-xs">
- <img class="product-image" v-bind:src="'file://' + valuePQ.data.images[0].local_src" alt="" />
- </div>
- </div>
- </td>
- <td data-th="Product">
- <div class="row">
- <div class="col-sm-10">
- <div class="nomargin title-table">
- <input :id="'checkbox_' + keyPQ" type="checkbox" :value="keyPQ.replace(/\s/g, '')" checked>
- {{valuePQ.data.title}}
- </div>
- </div>
- </div>
- </td>
- <input type="hidden" class="show_table_desc" :value="valuePQ.data.categories[0].replace(/\s/g, '')"/>
- <td data-th="Quantity">
- <div class="text-center price-table">${{valuePQ.data.price}}</div>
- </td>
- <td data-th="Quantity">
- <span class="form-control text-center">{{valuePQ.data.qty}}</span>
- </td>
- <td data-th="Quantity">
- <input class="form-control text-center" type="number" min="0"
- :class="'discount-input-' + keyPQ.replace(/\s/g, '')"
- :id="'discount_' + keyPQ.replace(/\s/g, '')" placeholder="%"
- value="" @change="setProductDiscount(keyPQ.replace(/\s/g, ''))">
- </td>
- <td style="padding-top:4%" data-th="Subtotal" class="text-center" v-if="valuePQ.data.subtotal > 0">
- <strike>${{ valuePQ.data.price * valuePQ.data.qty }}<br></strike>
- ${{ valuePQ.data.subtotal }}</td>
- <td style="padding-top:4%" data-th="Subtotal" class="text-center" v-else>
- ${{ valuePQ.data.price * valuePQ.data.qty }}
- </td>
- </tr>
- </tbody>
- <tfoot>
- </tfoot>
- </table>
- </div>
- <div class="">
- <div class="panel-heading last-child-cat">
- <h4 class="panel-title">
- <span>{{ keyM }}</span>
- <div class="discount-box">
- <label :for="'discount_' + key.replace(/[\s\W]/g, '') + '_' + keyK.replace(/[\s\W]/g, '') + '_' + keyM.replace(/[\s\W]/g, '')">Descuento </label>
- <input type="number" min="0" :class="'discount-input-' + key.replace(/[\s\W]/g, '') + '_' + keyK.replace(/[\s\W]/g, '') + '_' + keyM.replace(/[\s\W]/g, '')" :id="'discount_' + key.replace(/[\s\W]/g, '') + '_' + keyK.replace(/[\s\W]/g, '') + '_' + keyM.replace(/[\s\W]/g, '')" @change="setCategoryDiscount(key + '_' + keyK + '_' + keyM)" placeholder="%">
- </div>
- </h4>
- </div>
- </div>
- </div>
- </div> -->
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="panel-group">
- <div class="panel panel-default">
- <div style="border-top:solid 1px #ccc"class="panel-heading">
- <div class="total-order"><strong>Total ${{totalCart}}</strong></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- /LEFT Column/ -->
- <!-- RIGHT Column -->
- <div class="col-md-5">
- <div class="col-padding">
- <div class="panel-group">
- </div>
- <div class="order-box">
- </div>
- <div class="col-padding">
- <h3>NOTAS</h3>
- <p>Por favor, ingrese información a tener en cuenta sobre este pedido.</p>
- <div class="form-group">
- <textarea class="form-control" rows="2" cols="5" id="notes"></textarea>
- </div>
- </div>
- <div class="col-padding">
- <h3>ENVÍO</h3>
- <p>¿Desea unificar los envíos con pedidos pendientes?</p>
- <input type="radio" class="unify-pendings" name="unify-pendings" value="si">
- <label for="unify-yes"> Sí </label>
- <input type="radio" class="unify-pendings" name="unify-pendings" value="no">
- <label for="unify-yes"> No </label>
- <p>¿Desea unificar los envíos con pedidos de PREVENTA?</p>
- <input type="radio" class="unify-presale" name="unify-presale" value="si">
- <label for="unify-yes"> Sí </label>
- <input type="radio" class="unify-presale" name="unify-presale" value="no">
- <label for="unify-yes"> No </label>
- </div>
- <!-- <div class="h-divider-large"></div> -->
- <div class="col-padding">
- <h3>TIEMPO DE ENTREGA</h3>
- <!-- <div class="h-divider"></div> -->
- <p>La demora de entrega de productos en STOCK es de 10 días hábiles.</p>
- <div v-on:click="placeLocalOrder" class="btn btn-success btn-make-order">
- FINALIZAR PEDIDO
- </div>
- </div>
- </div>
- </div>
- <!-- /RIGHT Column/ -->
- </div>
- <!-- /CHECKOUT Body/ -->
- </div>
- </div>
- <!-- /INDEX Checkout/ -->
- <!-- VIEW Order -->
- <div v-if="sections.orderDetail">
- <div class="container">
- <div v-if="!orderDetail.pushed">
- <h2>Orden N° {{ orderDetail._id }}</h2>
- <hr>
- <table class="table table-hover table-condensed">
- <thead>
- <tr>
- <th style="width:50%">Producto</th>
- <th style="width:15%">Precio</th>
- <th style="width:8%">Cantidad</th>
- <th style="width:27%" class="text-center">Subtotal</th>
- </tr>
- </thead>
- <tbody>
- <tr v-for="product in orderProducts" >
- <td data-th="Product">
- <div class="row">
- <div class="col-sm-2 hidden-xs"><img class="img-responsive" v-bind:src="'file://' + product.images[0].local_src" alt="" /></div>
- <div class="col-sm-10">
- <h4 class="nomargin">{{ product.title }}</h4>
- <p v-html="product.short_description"></p>
- </div>
- </div>
- </td>
- <td data-th="Price" class="price">${{ product.price }}</td>
- <td data-th="Quantity">{{ product.quantity }}</td>
- <td data-th="Subtotal" class="text-center subtotal">${{ product.price * product.quantity }}</td>
- </tr>
- </tbody>
- </table>
- </div>
- <div v-else>
- <h2>Orden N° {{ orderDetail.order.id }}</h2>
- <hr>
- <table class="table table-hover table-condensed">
- <thead>
- <tr>
- <th style="width:50%">Producto</th>
- <th style="width:15%">Precio</th>
- <th style="width:8%">Cantidad</th>
- <th style="width:27%" class="text-center">Subtotal</th>
- </tr>
- </thead>
- <tbody>
- <tr v-for="product in orderProducts" >
- <td data-th="Product">
- <div class="row">
- <div class="col-sm-2 hidden-xs"><img class="img-responsive" v-bind:src="'file://' + product.images[0].local_src" alt="" /></div>
- <div class="col-sm-10">
- <h4 class="nomargin">{{ product.title }}</h4>
- <p v-html="product.short_description"></p>
- </div>
- </div>
- </td>
- <td data-th="Price" class="price">${{ product.price }}</td>
- <td data-th="Quantity">{{ product.quantity }}</td>
- <td data-th="Subtotal" class="text-center subtotal">${{ product.subtotal }}</td>
- </tr>
- </tbody>
- </table>
- </div>
- <div v-on:click="goToSection('orders')" class="btn btn-warning"><i class="glyphicon glyphicon-arrow-left"></i>Volver a compras</div>
- </div>
- </div>
- <!--/ VIEW Order /-->
- <!-- INDEX Orders -->
- <div v-if="sections.orders" id="orders">
- <div class="container">
- <h1 class="text-center">PEDIDOS</h1>
- <hr class="hr-title">
- <div class="row">
- <div v-if="pendingOrders.length">
- <h2>Órdenes pendientes</h2>
- <table class="table table-hover table-condensed">
- <thead>
- <tr class="border-bottom">
- <th style="width:10%">N°</th>
- <th style="width:20%" class="text-center">Cliente</th>
- <th style="width:20%" class="text-center">Fecha</th>
- <th style="width:20%" class="text-center">Total</th>
- <th style="width:10%" class="text-center">Estado</th>
- <th style="width:20%"></th>
- </tr>
- </thead>
- <tbody>
- <tr v-for="(order, key, index) in pendingOrders">
- <td data-th="Order">{{ order._id }}</td>
- <td data-th="Customer" class="text-center">{{ order.customer.display_name }}</td>
- <td data-th="Date" class="text-center">{{ dateFormat(order.created, 'dd/mm/yyyy HH:MM:ss') }}</td>
- <td data-th="Total" class="text-center subtotal">${{ order.total }}</td>
- <td data-th="Status" class="text-center">No enviado</td>
- <td class="actions text-center" data-th="">
- <button v-on:click="viewOrder(order)" class="button-action-order" title="Ver detalle">
- <span class="glyphicon icon-Ver-01 coral size-2x" aria-hidden="true"></span>
- </button>
- <button v-on:click="authorizeOrder(!order.authorized, key)" class="button-action-order" :title="order.authorized ? 'Cancelar envío de la orden' : 'Autorizar envío de la orden'">
- <span :class="'glyphicon ' + (order.authorized ? 'glyphicon-ok' : 'glyphicon-remove') + ' coral size-2x'" aria-hidden="true"></span>
- </button>
- <button v-on:click="removeOrder(order._id, order._rev)" class="button-action-order" title="Eliminar orden">
- <span class="glyphicon icon-Eliminar-01 coral size-2x" aria-hidden="true"></span>
- </button>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <div v-if="pushedOrders.length">
- <h2>Órdenes enviadas</h2>
- <table class="table table-hover table-condensed">
- <thead>
- <tr class="border-bottom">
- <th style="width:10%">N°</th>
- <th style="width:20%" class="text-center">Cliente</th>
- <th style="width:20%" class="text-center">Fecha</th>
- <th style="width:20%" class="text-center">Total</th>
- <th style="width:10%" class="text-center">Estado</th>
- <th style="width:20%"></th>
- </tr>
- </thead>
- <tbody>
- <tr v-for="order in pushedOrders">
- <td data-th="Order">{{ order.order.id }}</td>
- <td data-th="Customer" class="text-center">{{ order.order.customer.username }}</td>
- <td data-th="Date" class="text-center">{{ dateFormat(order.order.created_at, 'dd/mm/yyyy HH:MM:ss') }}</td>
- <td data-th="Total" class="text-center subtotal">${{ order.order.total }}</td>
- <td data-th="Status" class="text-center">Enviado</td>
- <td class="actions text-center" data-th="">
- <button v-on:click="viewOrder(order)" class="button-action-order" title="Ver detalle">
- <span class="icon-Ver-01 coral size-2x" aria-hidden="true"></span>
- </button>
- <button v-on:click="downloadCSV(order)" class="button-action-order" title="Descargar CSV">
- <span class="icon-Descargar-01 coral size-2x" aria-hidden="true"></span>
- </button>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- <div v-on:click="goToSection('products')" class="btn btn-warning"><i class="glyphicon glyphicon-arrow-left"></i>Volver al catálogo</div>
- </div>
- </div>
- <!--/ INDEX Orders /-->
- <!-- INDEX Cart -->
- <div v-if="sections.cart" id="cart">
- <div id="cart-content">
- <table class="table table-hover table-condensed">
- <thead>
- <tr>
- <th >PRODUCTO</th>
- <th style="width:10%"></th>
- <th style="width:30%"></th>
- <th style="width:10%">PRECIO</th>
- <th style="width:8%">CANTIDAD</th>
- <th style="width:22%" class="text-center">Total</th>
- <th style="width:10%"></th>
- </tr>
- </thead>
- <tbody>
- <tr v-for="(value, key, index) in sessionProductsData">
- <td >
- <div v-on:click="deleteCartProductById(key)" class="btn box-delete-product">
- <span v-bind="dataBindCartProducts(key, 'delete')" class="glyphicon glyphicon-remove-circle" aria-hidden="true"></span>
- </div>
- </td>
- <td data-th="Product">
- <div class="row">
- <div class="col-sm-2 hidden-xs">
- <img class="product-image" v-bind:src="'file://' + value.data.images[0].local_src" alt="" />
- </div>
- </div>
- </td>
- <td>
- <div class="col-sm-10">
- <span class="nomargin">{{value.data.title}}</span>
- </div>
- </td>
- <td data-th="Price" class="price">${{value.data.price}}</td>
- <td data-th="Quantity">
- <input type="number" class="form-control text-center" :class="cartQty(key)" :step="value.data.step" v-model="value.data.qty" @change="itemQtyCart($event, value.data.id)">
- </td>
- <td data-th="Subtotal" :class="cartSubtotal(key)" class="text-center subtotal">${{ value.data.price * value.data.qty }}</td>
- <td class="actions" data-th="Subtotal"></td>
- </tr>
- </tbody>
- <tfoot></tfoot>
- </table>
- </div>
- <div class="col-sm-5">
- <div class="col-padding">
- <h3>TOTAL</h3>
- <div class="order-box">
- <table class="table table-hover table-condensed">
- <thead>
- <tr>
- <th style="width:80%"></th>
- <th style="width:10%"></th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td data-th="Product">
- <div class="row">
- <div class="col-sm-10">
- <h4 class="nomargin">Subtotal</h4>
- </div>
- </div>
- </td>
- <td data-th="Product">
- <div class="row">
- <div class="col-sm-10">
- <h4 class="nomargin">${{totalCart}}</h4>
- </div>
- </div>
- </td>
- </tr>
- <tr>
- <td data-th="Product">
- <div class="row">
- <div class="col-sm-10">
- <h4 class="nomargin">Total</h4>
- </div>
- </div>
- </td>
- <td data-th="Product">
- <div class="row">
- <div class="col-sm-10">
- <h4 class="nomargin">${{totalCart}}</h4>
- </div>
- </div>
- </td>
- </tr>
- <tr>
- <td data-th="Product"></td>
- <td></td>
- </tr>
- </tbody>
- <tfoot></tfoot>
- </table>
- <div class="row">
- <div v-on:click="saveQuoteToSession" class="btn btn-success go-to-checkout">
- CHECK OUT
- </div>
- </div>
- <div class="row">
- <div v-on:click="goToSection('products')" class="btn btn-warning go-to-products"><i class="fa fa-angle-left"></i>SEGUIR COMPRANDO</div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- /INDEX Cart/ -->
- <div v-if="sections.products" class="products">
- <!-- <navbar></navbar> -->
- <div id="products-content">
- <nav class="devsite-section-nav devsite-nav nocontent" style="left: auto; max-height: 643px; position: relative; top: 0px;">
- <div id="client-box">
- <span>CLIENTE </span>
- <p>Seleccione el cliente del que va a realizar el pedido </p>
- </div>
- <select class="customerSelect" v-model="sellerCustomerSelected">
- <option value="">Seleccione un cliente</option>
- <option v-for="customer in sellerCustomers" v-on:click="setCustomer(customer.ID)" v-bind:value="customer.ID">{{ customer.display_name }} | {{ customer.user_email }}</option>
- </select>
- <ul class="devsite-nav-list devsite-nav-expandable">
- <div id="search-input" class="container">
- <div class="row">
- <div class="col-md-2">
- <span>BUSCADOR </span>
- <p>Utilice el buscador para encontrar productos rápidamente </p>
- <div id="custom-search-input">
- <div class="input-group col-md-12">
- <input v-model="sku" type="text" class="form-control input-lg" placeholder="Ingrese su búsqueda" />
- <span class="input-group-btn">
- <button v-bind:disabled="!sku" v-on:click="filterSearch" class="btn btn-info btn-lg" type="button">
- <i class="glyphicon glyphicon-search"></i>
- </button>
- </span>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- CATEGORIES -->
- <li class="devsite-nav-item devsite-nav-item-heading1">
- <span class="devsite-nav-title devsite-nav-title-no-path" track-type="leftNav" track-name="expandNavSectionNoLink" track-metadata-position="0">
- <div id="categories-box">
- <span >CATEGORÍAS</span>
- <p>Seleccione una categoría para comenzar a comprar </p>
- </div>
- </span>
- </li>
- <div class="dropdown pointerHand">
- <ul id="cats" v-for="(value, key, index) in categories" class="upperCase head-ul-first devsite-nav-item devsite-nav-item-heading">
- <li v-if="!isEmpty(value)">
- <div v-on:click="pagination(key, 'categories')" v-bind:id="key"
- class="devsite-nav-title devsite-nav-title-no-path dropdown-toggle"
- track-type="leftNav"
- track-name="expandNavSectionNoLink"
- track-metadata-position="0"
- data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"
- >{{ key }}<span class="caret"></span></div>
- <ul class="head-ul-first devsite-nav-item devsite-nav-item-heading dropdown-menu" data-toggle="dropdown" aria-haspopup="true" v-bind:aria-labelledby="key" aria-expanded="true" >
- <li v-for="(valueK, keyK, indexK) in value" v-if="!isEmpty(value)" class="head-ul-second devsite-nav-item devsite-nav-item-heading ">
- <span v-on:click="changeColor(keyK), pagination(keyK, 'categories')" v-bind:id="keyK"
- class="devsite-nav-title devsite-nav-title-no-path"
- track-type="leftNav"
- track-name="expandNavSectionNoLink"
- track-metadata-position="0"
- data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
- {{ keyK }}
- <span class="caret"></span>
- </span>
- <ul class="head-ul-second devsite-nav-item devsite-nav-item-heading lowerCase ">
- <li class="devsite-nav-li" v-on:click="pagination(keyM, 'categories')" v-bind:id="keyM" v-for="(valueM, keyM, indexM) in valueK" v-if="!isEmpty(valueK)">
- {{ keyM }}
- </li>
- </ul>
- </li>
- <li v-else>
- <span class="devsite-nav-title devsite-nav-title-no-path" track-type="leftNav" track-name="expandNavSectionNoLink" track-metadata-position="0">
- {{ keyK }}
- </span>
- </li>
- </ul>
- </li>
- <li v-else>
- <span class="devsite-nav-title devsite-nav-title-no-path" track-type="leftNav" track-name="expandNavSectionNoLink" track-metadata-position="0">
- {{ key }}
- </span>
- </li>
- </ul>
- </div>
- <li class="devsite-nav-item devsite-nav-item-heading1">
- <span class="devsite-nav-title devsite-nav-title-no-path" track-type="leftNav" track-name="expandNavSectionNoLink" track-metadata-position="0">
- <div id="filtros-box">
- <span >FILTROS</span>
- <p>Seleccione una opción para filtrar</p>
- </div>
- <select @change="filterByType($event)" class="customerSelect" >
- <option :value="null" disabled selected>Seleccione un filtro</option>
- <option
- v-for="filter in filtersList"
- :value="filter.param + ',' + filter.condition + ',' + filter.selector"
- >
- {{ filter.title }}
- </option>
- </select>
- </span>
- <br>
- <div id="filtros-box">
- <span >FILTRO POR PRECIO</span>
- </div>
- <div>
- <br><br><br>
- <vue-slider @callback="cb" ref="slider4" v-bind="priceRange" v-model="priceRange.value"></vue-slider>
- </div>
- </li>
- </ul>
- </nav>
- <div v-show="productsAlert" id="products-alert" class="alert alert-info">No hay categorías selecionadas o la categoría que seleccionó no tiene productos.</div>
- <paginate id="products" name="itemsData" :per="8" :list="items" class="row list-group">
- <li v-for="(item, key) in paginated('itemsData')" class="item col-xs-3 col-lg3">
- <div class="thumbnail">
- <img :id="'img_' + item.id" data-toggle="modal" :data-target="'#modal_' + item.id" class="group list-group-image" v-bind:src="'file://' + item.images[0].local_src" alt="" />
- <div class="caption">
- <div class="">
- <h5 style="float:left" class="group inner list-group-item-heading">{{ item.title }}</h5>
- <span style="float:right" >${{ item.price }}</span>
- </div>
- <p v-html="'<br>' + item.short_description + 'Stock: ' + item.stock_quantity" class="group inner list-group-item-text">
- <br>
- </p>
- <div class="row">
- <div class="col-xs-12 col-md-12">
- <button v-on:click="decQty(item)" class="glyphicon glyphicon-minus btn btn-xs btn-default"></button>
- <span>{{ itemQty(item) }}</span>
- <button v-on:click="addQty(item)" class="glyphicon glyphicon-plus btn btn-xs btn-default"></button>
- </div>
- <div class="col-xs-12 col-md-12">
- <div v-on:click.prevent="getDataBind($event, item.id)" v-bind="dataBind(item.id, item)" class="btn btn-success add-cart-btn">Agregar al carrito</div>
- </div>
- </div>
- </div>
- </div>
- <div v-bind:id="'modal_' + item.id" class="modal fade" role="dialog">
- <div class="thumbnail">
- <img data-toggle="modal" :data-target="'#modal_' + item.id" class="group list-group-image" v-bind:src="'file://' + item.images[0].local_src" alt="" />
- <div class="caption">
- <div class="">
- <h5 style="float:left" class="group inner list-group-item-heading">{{ item.title }}</h5>
- <span style="float:right" >${{ item.price }}</span>
- </div>
- <p v-html="'<br>' + item.short_description" class="group inner list-group-item-text"></p>
- <div class="row">
- <div class="col-xs-12 col-md-12">
- <button v-on:click="decQty(item)" class="glyphicon glyphicon-minus btn btn-xs btn-default"></button>
- <span>{{ itemQty(item) }}</span>
- <button v-on:click="addQty(item)" class="glyphicon glyphicon-plus btn btn-xs btn-default"></button>
- </div>
- <div class="col-xs-12 col-md-12">
- <div v-on:click.prevent="getDataBind($event, item.id)" v-bind="dataBind(item.id, item)" class="btn btn-success">Añadir al carrito</div>
- </div>
- </div>
- <div class="col-xs-12 col-md-6">
- <p class="lead">{{ item.categories[0] }}</p>
- </div>
- </div>
- </div>
- </div>
- </li>
- </paginate>
- <div id="pages">
- <paginate-links class="pagination" for="itemsData" :limit="10" :show-step-links="true" ></paginate-links>
- </div>
- </div>
- </div>
- <div v-show="!isUserLoggedAttr && !sections.setup" id="login-container">
- <div class="col-lg-4 col-md-3 col-sm-2"></div>
- <div class="col-lg-4 col-md-6 col-sm-8">
- <div class="logo">
- <img src="~@/assets/logotarget.png" alt="Logo" >
- </div>
- <form v-on:submit.prevent="submitForm">
- <div class="row loginbox">
- <div class="col-lg-12">
- <span class="singtext" >Ingresar </span>
- </div>
- <div class="col-lg-12 col-md-12 col-sm-12">
- <input v-model="username" class="form-control" type="email" placeholder="Ingresá tu email" >
- </div>
- <div class="col-lg-12 col-md-12 col-sm-12">
- <input v-model="password" class="form-control" type="password" placeholder="Ingresá tu contraseña" >
- </div>
- <div class="col-lg-12 col-md-12 col-sm-12">
- <button v-bind:disabled="!isFormValid()" class="btn submitButton">Enviar</button>
- <div v-show="loginError" class="col-lg-12">
- <p class="text-center singtext14Red" >Password y / o usuario incorrectos. </p>
- </div>
- </div>
- <div v-show="showUsersSessions" class="">
- <div class="col-lg-12">
- <p class="text-center singtext14Black" >Seleccione un usuario para ingresar </p>
- </div>
- <ul v-for="(value, key, index) in usersSessionsList.docs">
- <li> <a v-on:click.prevent="usePreviousUser(value.email)" href="#">{{ value.nicename }} - {{ value.email }} </a> </li>
- </ul>
- </div>
- </div>
- </form>
- </div>
- </div>
- <div v-if="sections.setup" id="app-setup">
- <h1 class="text-center">¡Bienvenido a Target Moda!</h1>
- <h2 class="text-center">A continuación iniciará la instalación de la Aplicación</h2>
- <button v-on:click.once="initSetup" type="button" class="btn btn-lg btn-primary center-block">Comenzar</button>
- <p class="text-center" style="margin-top:32px;" >{{ setupInit }}</p>
- <p class="text-center">{{ productsInit }}</p>
- <p class="text-center">{{ productsComplete }}</p>
- <p class="text-center">{{ categoriesInit }}</p>
- <p class="text-center">{{ categoriesComplete }}</p>
- <p class="text-center">{{ customersInit }}</p>
- <p class="text-center">{{ customersComplete }}</p>
- <p class="text-center">{{ directoriesInit }}</p>
- <p class="text-center">{{ directoriesComplete }}</p>
- <p class="text-center">{{ imagesInit }}</p>
- <p class="text-center">{{ imagesComplete }}</p>
- <p class="text-center">{{ setupComplete }}</p>
- <p></p>
- <button v-show="appInstalled" v-on:click="goToSection('products')" type="button" class="btn btn-lg btn-primary center-block">Entrar</button>
- </div>
- <div v-if="logged" id="app-content">
- <table class="table table-striped">
- <thead>
- <tr>
- <th>Id</th>
- <th>Last Name</th>
- <th>Email</th>
- <th></th>
- </tr>
- </thead>
- <tbody>
- <tr v-for="customer in customerst">
- <td> {{ customer.id }} </td>
- <td> {{ customer.username }} </td>
- <td> {{ customer.email }} </td>
- </tr>
- </tbody>
- </table>
- </div>
- <div v-show="loading" class="loading">Loading…</div>
- </div>
- </template>
- <script>
- // import WooCommerceAPI from 'woocommerce-api'
- // import Vue from 'vue'
- import Navbar from './Elements/Navbar'
- import Filters from './Elements/Filters'
- import Syncprocess from './Syncprocess'
- import store from '../store'
- import vueSlider from 'vue-slider-component'
- var SHA256 = require('crypto-js/sha256.js')
- const remote = require('electron').remote
- export default {
- name: 'customers',
- components: { Navbar, Filters, vueSlider },
- data () {
- return {
- sections: {
- login: false,
- setup: false,
- products: false,
- orders: false,
- orderDetail: false,
- cart: false,
- checkout: false,
- thanks: false,
- navbar: false
- },
- usersSessionsList: {},
- showUsersSessions: false,
- setupInit: '',
- productsInit: '',
- productsComplete: '',
- categoriesInit: '',
- categoriesComplete: '',
- customersInit: '',
- customersComplete: '',
- directoriesInit: '',
- directoriesComplete: '',
- imagesInit: '',
- imagesComplete: '',
- setupComplete: '',
- appInstalled: false,
- isUserLoggedAttr: false,
- customerst: [],
- auth: [],
- username: '',
- password: '',
- loginError: false,
- sku: '',
- logged: false,
- productsSync: '',
- badge: 0,
- // cartObject: {},
- // PRODUCTS & FILTERS
- categories: [],
- collapse: true,
- categoriesDiscounts: [],
- items: [],
- pendingOrders: [],
- pushedOrders: [],
- orderDetail: {},
- orderProducts: [],
- products: {},
- // items: ['Item One', 'Item Two', 'Item Three', 'Item Four', 'Item Five', 'Item Six', 'Item Seven', 'Item Eight', 'Item Nine', 'Item Ten', 'Item Eleven', 'Item Twelve', 'Item Thirteen'],
- paginate: ['itemsData'],
- priceRange: {
- value: ['0', '100'],
- width: '100%',
- height: 4,
- dotSize: 14,
- min: 1,
- max: 100,
- interval: 3,
- disabled: false,
- show: true,
- tooltip: 'always',
- piecewise: true,
- data: [
- '0',
- '100',
- '300',
- '500',
- '800',
- '1000',
- '5000',
- '8000',
- '10000'
- ]
- },
- total: 10,
- // END PRODUCTS & FILTERS
- // sessionProducts: this.$session.get('target-cart'),
- sessionProductsData: {},
- quoteProducts: this.$session.get('target-quote'),
- sessionUserData: this.$session.get('user-session'),
- sellerCustomers: {},
- sellerCustomerSelected: '',
- totalCart: 0,
- section: this.$session.get('target-current-step'),
- error: false,
- dateFormat: require('dateformat'),
- loading: false,
- productsAlert: false,
- filtersList: [
- {
- 'param': 'asc',
- 'condition': '$eq',
- 'selector': 'sku',
- 'title': 'Predeterminado'
- },
- {
- 'param': 'desc',
- 'selector': 'sku',
- 'condition': '$gt',
- 'title': 'Novedades'
- },
- {
- 'param': 'asc',
- 'selector': 'price',
- 'condition': '$gt',
- 'title': 'Menor Precio'
- },
- {
- 'param': 'desc',
- 'selector': 'price',
- 'condition': '$gt',
- 'title': 'Mayor Precio'
- },
- {
- 'param': '50',
- 'selector': 'stock_quantity',
- 'condition': '$gt',
- 'title': 'Más de 50 unidades'
- },
- {
- 'param': '100',
- 'selector': 'stock_quantity',
- 'condition': '$gt',
- 'title': 'Más de 100 unidades'
- },
- {
- 'param': '200',
- 'selector': 'stock_quantity',
- 'condition': '$gt',
- 'title': 'Más de 200 unidades'
- },
- {
- 'param': '300',
- 'selector': 'stock_quantity',
- 'condition': '$gt',
- 'title': 'Más de 300 unidades'
- },
- {
- 'param': '400',
- 'selector': 'stock_quantity',
- 'condition': '$gt',
- 'title': 'Más de 400 unidades'
- },
- {
- 'param': '500',
- 'selector': 'stock_quantity',
- 'condition': '$gt',
- 'title': 'Más de 500 unidades'
- }
- ]
- }
- },
- methods: {
- checkProductParentCat: function (catProdArray, parentCat) {
- var sizeCat = catProdArray.length
- console.log('!!! array cat', catProdArray)
- console.log('cat prod en el if', catProdArray[sizeCat - 1])
- console.log('parentCat en el if', parentCat)
- var resParentCat = parentCat.replace('%', '_')
- console.log('resParentCat en el if', resParentCat)
- catProdArray.map(function (obj, index) {
- console.log('index', index, 'object', obj)
- if (obj.replace(/\s/g, '') === resParentCat.replace(/\s/g, '')) {
- return true
- }
- })
- // $('#' + resParentCat.replace(/\s/g, '')).show()
- // this.showDiscTable()
- // if (catProdArray[sizeCat - 1].replace(/\s/g, '') === resParentCat.replace(/\s/g, '')) {
- // console.log('cat prod en el if', catProdArray[sizeCat - 1])
- // console.log('parentCat en el if', resParentCat)
- // return true
- // } else {
- // return false
- // }
- // for (var i = 0; i <= sizeCat; i++) {
- // if (catProdArray[i].replace(/\s/g, '') === parentCat) {
- // return true
- // }
- // }
- },
- downloadCSV: function (order) {
- var fileName = 'order_' + order._id + '.csv'
- Syncprocess.createCSV(order.order.line_items).then((csv) => {
- Syncprocess.downloadCSV(fileName, csv).then((result) => {
- console.log(result)
- $('#success-downloaded-csv').fadeIn().delay(1000).fadeOut(2000)
- }).catch((err) => {
- console.log(err)
- $('#error-downloaded-csv').fadeIn().delay(1000).fadeOut(2000)
- })
- }).catch((err) => {
- console.log(err)
- $('#error-downloaded-csv').fadeIn().delay(1000).fadeOut(2000)
- })
- },
- showDiscTable: function () {
- // var collapse = this.collapse
- // console.log(collapse)
- // var tableShow = $('.show_table_desc').val()
- // $('.table_cat_' + tableShow).show()
- $('.show_table_desc').each(function (i, obj) {
- console.log('CLASE table_cat_', obj.value)
- $('.table_cat_' + obj.value).show()
- })
- // $('#order-box div').removeClass('collpase')
- // console.log(event)
- // console.log(parentLevel)
- },
- filterByType: function (event) {
- // selector, condition, param
- let self = this
- let optionValue = event.target.value
- // let sort = {}
- let skuSort = true
- let dataQuery = optionValue.split(',')
- var param = dataQuery[0].trim()
- var condition = dataQuery[1].trim()
- var selector = dataQuery[2].trim()
- var sortParam = ''
- if (selector === 'stock_quantity') {
- param = parseInt(param)
- skuSort = false
- } else if (selector === 'price' || selector === 'sku') {
- skuSort = true
- param = '"' + param + '"'
- sortParam = JSON.parse('{"' + selector + '": ' + param + '}')
- console.log('MOSTRAME SORT', sortParam)
- }
- // sortParam = JSON.parse('{"sku": "desc" }')
- // sortParam = JSON.parse('{"price": "' + param + '"}')
- // sort.push(sortParam)
- var query = JSON.parse('{"' + selector + '":{"' + condition + '":' + param + '}}')
- // console.log('EVENT TARGET', param, condition, selector)
- // console.log('MOSTRAME EL QUERY', query)
- // console.log('QUERY FILTERS', query)
- self.loading = true
- if (skuSort) {
- store.filtersByPriceAndSku(sortParam).then(function (result) {
- if (self.isEmpty(result.docs)) {
- self.productsAlert = true
- self.loading = false
- } else {
- self.productsAlert = false
- self.loading = false
- $('#pages').show()
- }
- self.items = result.docs
- self.products = result.docs
- })
- } else {
- store.filtersByType(query).then(function (result) {
- if (self.isEmpty(result.docs)) {
- self.productsAlert = true
- self.loading = false
- } else {
- self.productsAlert = false
- self.loading = false
- $('#pages').show()
- }
- self.items = result.docs
- self.products = result.docs
- })
- }
- },
- itemQtyCart: function (event, id) {
- var items = this.$session.get('target-cart')
- items[id].data.qty = event.target.valueAsNumber
- if (event.target.valueAsNumber < items[id].data.step) {
- items[id].data.qty = items[id].data.step
- } else if (event.target.valueAsNumber % items[id].data.step !== 0) {
- items[id].data.qty = event.target.valueAsNumber - (event.target.valueAsNumber % items[id].data.step)
- }
- this.$session.set('target-cart', items)
- this.sessionProductsData = this.$session.get('target-cart')
- this.jQuerySetBadge(this.sessionProductsData)
- this.getCartSessionItems()
- this.$forceUpdate()
- },
- checkCategories: function (id) {
- console.log(id)
- if ($('#' + id + ':checkbox:checked').length > 0) {
- console.log('está checkeado')
- $('.' + id + '_child').prop('checked', true)
- } else {
- $('.' + id + '_child').prop('checked', false)
- }
- // console.log('parent!!!', event.target)
- // console.log('event clikc!', event.target.id)
- // jQuery(this).closest('tr').find('[type=checkbox]').prop('checked', true);
- },
- setProductDiscount: function (id) {
- let inputValue = $('#discount_' + id).val()
- this.sessionProductsData[id].data.discount_product = inputValue
- this.sessionProductsData[id].data.subtotal = this.sessionProductsData[id].data.price * this.sessionProductsData[id].data.qty - this.sessionProductsData[id].data.price * this.sessionProductsData[id].data.qty * this.sessionProductsData[id].data.discount_product / 100
- var sessionProducts = this.$session.get('target-quote')
- var total = 0
- var count = 0
- // Apply discounts to products in this.sessionProductsData
- for (var index in this.sessionProductsData) {
- if (this.sessionProductsData[index].data.discount_product > 0) {
- sessionProducts.order.line_items[count].total = this.sessionProductsData[index].data.subtotal
- total += this.sessionProductsData[index].data.subtotal
- } else if (this.sessionProductsData[index].data.discount_category > 0) {
- sessionProducts.order.line_items[count].total = this.sessionProductsData[index].data.subtotal
- total += this.sessionProductsData[index].data.price * this.sessionProductsData[index].data.qty - this.sessionProductsData[index].data.price * this.sessionProductsData[index].data.qty * this.sessionProductsData[index].data.discount_category / 100
- } else {
- this.sessionProductsData[index].data.subtotal = 0
- total += this.sessionProductsData[index].data.price * this.sessionProductsData[index].data.qty
- }
- count++
- }
- sessionProducts.total = total
- this.totalCart = total
- this.$session.set('target-quote', sessionProducts)
- this.$forceUpdate()
- },
- setCategoryDiscount: function (input) {
- console.log('target-quote', this.$session.get('target-quote'))
- // Recursively apply discounts on DOM
- let inputAttribute = input.replace(/[\s\W]/g, '')
- let inputValue = $('#discount_' + inputAttribute).val()
- // $('.parent_cat_disc_' + input).val(inputValue)
- $('input[class^=discount-input-' + inputAttribute + ']').val(inputValue)
- // Save Categories Discounts in this.categoriesDiscounts
- var scope = input.split('_')
- var exist = false
- this.categoriesDiscounts.map((discount, i) => {
- var matches = []
- for (var j = scope.length - 1; j >= 0; j--) {
- matches.push(false)
- }
- for (var k = scope.length - 1; k >= 0; k--) {
- if (discount.scope[k] === scope[k]) {
- matches[k] = true
- }
- }
- if (matches.indexOf(false) === -1) {
- this.categoriesDiscounts[i] = {scope: scope, discount: inputValue}
- exist = true
- }
- })
- if (!exist || this.categoriesDiscounts.length === 0) {
- this.categoriesDiscounts.push({scope: scope, discount: inputValue})
- }
- var sessionProducts = this.$session.get('target-quote')
- var total = 0
- var count = 0
- // Apply discounts to products in this.sessionProductsData
- for (var index in this.sessionProductsData) {
- var categories = this.sessionProductsData[index].data.categories
- var matches = []
- this.categoriesDiscounts.map((discount, j) => {
- categories.map((category, k) => {
- if (discount.scope[discount.scope.length - 1] === category) {
- matches.push(discount)
- }
- })
- })
- var specificity = 0
- matches.map((match) => {
- if (match.scope.length > specificity) {
- this.sessionProductsData[index].data.discount_category = match.discount
- specificity = match.scope.length
- }
- })
- if (this.sessionProductsData[index].data.discount_product > 0) {
- sessionProducts.order.line_items[count].total = this.sessionProductsData[index].data.price * this.sessionProductsData[index].data.qty - this.sessionProductsData[index].data.price * this.sessionProductsData[index].data.qty * this.sessionProductsData[index].data.discount_product / 100
- total += this.sessionProductsData[index].data.price * this.sessionProductsData[index].data.qty - this.sessionProductsData[index].data.price * this.sessionProductsData[index].data.qty * this.sessionProductsData[index].data.discount_product / 100
- } else if (this.sessionProductsData[index].data.discount_category > 0) {
- this.sessionProductsData[index].data.subtotal = this.sessionProductsData[index].data.price * this.sessionProductsData[index].data.qty - this.sessionProductsData[index].data.price * this.sessionProductsData[index].data.qty * this.sessionProductsData[index].data.discount_category / 100
- sessionProducts.order.line_items[count].total = this.sessionProductsData[index].data.subtotal
- total += this.sessionProductsData[index].data.subtotal
- } else {
- this.sessionProductsData[index].data.subtotal = 0
- total += this.sessionProductsData[index].data.price * this.sessionProductsData[index].data.qty
- }
- count++
- }
- sessionProducts.total = total
- this.totalCart = total
- this.$session.set('target-quote', sessionProducts)
- this.$forceUpdate()
- },
- changeColor: function (event) {
- console.log('cateeeeee', this.categories)
- let targetId = event.replace(/\s/g, '')
- console.log('eventooo', targetId)
- // let targetId = event.currentTarget.id
- $('#products-content ul').css('color', '#000 !important')
- $('.dropdown li').css('color', '#000 !important')
- $('.dropdown div').css('color', '#000 !important')
- $('#' + targetId).css('color', '#f2696c')
- console.log('CHANGECOLOR', targetId)
- return 'esteId'
- },
- setUsersSessions: function () {
- let self = this
- store.findByTypeInSession('user_session').then(function (usersInDB) {
- self.usersSessionsList = usersInDB
- console.log('usersInDB ->>>>>->>->>', usersInDB)
- if (usersInDB.docs.length > 0) {
- self.showUsersSessions = true
- }
- console.log('usersInDB LENGH ->>>>>->>->>', usersInDB.docs.length)
- })
- },
- usePreviousUser: function (email) {
- console.log('EMAILLLLL', email)
- this.username = email
- },
- initSetup: function (event) {
- event.disabled = true
- this.setupInit = 'Ha comenzado la instalación ...'
- this.productsInit = 'Sincronizando productos'
- var p1 = new Promise((resolve, reject) => {
- Syncprocess.countSyncWC('products').then((result) => {
- var numProducts = result
- Syncprocess.initProductsWC(numProducts).then((result) => {
- this.productsComplete = 'Productos sincronizados'
- this.directoriesInit = 'Creando directorios de imágenes'
- Syncprocess.initProductImages().then((result) => {
- this.directoriesComplete = 'Directorios creados'
- this.imagesInit = 'Sincronizando imágenes'
- Syncprocess.downloadProductImages().then((result) => {
- this.imagesComplete = 'Imágenes sincronizadas'
- this.appInstalled = true
- resolve('OK')
- }).catch((err) => {
- console.log('ERROR get Images', err)
- })
- }).catch((err) => {
- console.log('ERROR create Images Directories', err)
- })
- }).catch((err) => {
- console.log('ERROR get Products', err)
- })
- }).catch((err) => {
- console.log('ERROR count Products', err)
- })
- })
- var p2 = new Promise((resolve, reject) => {
- this.categoriesInit = 'Sincronizando categorías'
- Syncprocess.initCategoriesWC().then((result) => {
- this.categoriesComplete = 'Categorías sincronizadas'
- resolve('OK')
- }).catch((err) => {
- console.log('ERROR get Categories:', err)
- })
- })
- var p3 = new Promise((resolve, reject) => {
- this.customersInit = 'Sincronizando clientes'
- var sellerId = this.$session.get('user-session')._id
- Syncprocess.initCustomersWC(sellerId).then((result) => {
- this.sellerCustomers = result.docs
- this.customersComplete = 'Clientes sincronizados'
- resolve('OK')
- }).catch((err) => {
- console.log('ERROR get Customers:', err)
- })
- })
- Promise.all([p1, p2, p3]).then(data => {
- console.log('Install COMPLETE')
- Syncprocess.setupComplete().then((result) => {
- this.setupComplete = 'Instalación finalizada con éxito'
- this.appInstalled = true
- this.isUserLoggedAttr = true
- })
- }).catch((err) => {
- console.log('ERROR install complete:', err)
- })
- },
- handler: function (arg1) {
- this.goToSection(arg1)
- this.setCartItems()
- this.getCartSessionItems()
- },
- logout: function () {
- var window = remote.getCurrentWindow()
- let user = this.$session.get('user-session')
- let userId = user._id
- store.logout(userId)
- store.logout('customers_seller_' + userId)
- console.log(this.$session.get('user-session'))
- this.$session.destroy('user-session')
- console.log(this.$session.get('user-session'))
- window.close()
- // customers_seller_
- // id
- },
- badgeItems: function (qty) {
- this.badge = qty
- },
- getSellerCustomers: function () {
- var self = this
- store.findByType('seller_customer').then((result) => {
- console.log('seller customerssss', result)
- self.sellerCustomers = result.docs
- })
- },
- setCustomer: function (customerId) {
- this.sellerCustomerSelected = customerId
- },
- setCartItems: function () {
- console.log('entro set cartitmes!')
- this.sessionProductsData = this.$session.get('target-cart')
- },
- setCartQtyItems: function (cartSession) {
- let qty = 0
- console.log(typeof cartSession)
- Object.keys(cartSession).map(function (objectKey, index) {
- var value = cartSession[objectKey]
- console.log('nav bar QTY---->', value)
- qty += parseInt(value.data.qty)
- console.log('nav bar QTY---->', value.data.qty)
- })
- console.log('var QTY navbar!!!!', qty)
- this.badgeItems(qty)
- },
- itemQty: function (item) {
- if (typeof item.qty === 'undefined') {
- return item.step
- }
- return item.qty
- },
- decQty: function (item) {
- item.qty -= item.step
- if (item.qty <= 0) {
- item.qty = item.step
- }
- this.$forceUpdate()
- },
- addQty: function (item) {
- if (typeof item.qty === 'undefined') {
- item.qty = item.step
- }
- item.qty += item.step
- this.$forceUpdate()
- },
- emptyQuoute: function () {
- this.$session.set('target-cart', {})
- this.$session.set('target-quote', {})
- },
- goToSection: function (to) {
- for (var section in this.sections) {
- this.sections[section] = false
- if (section === to) {
- this.sections[section] = true
- }
- }
- if (this.appInstalled && this.isUserLoggedAttr) {
- this.sections.navbar = true
- }
- },
- setCurrentStep: function (section, to = null) {
- console.log('section', section)
- console.log('TO', to)
- $(section).hide()
- if (to !== null) {
- $(to).show()
- if (this.appInstalled) {
- $('#navbar').show()
- }
- }
- },
- // customer sellers
- getCustomersBySellerId: function () {
- let self = this
- let userSession = this.$session.get('user-session')
- // if (typeof userSession === 'undefined') {
- // this.$session.set('user-session', {})
- // console.log('user session no definida la crea', userSession)
- // }
- // let sellerId = userSession._id
- let sellerId = userSession._id
- store.getDataSessionById('customers_seller_' + sellerId).then(function (customerSellerRes) {
- console.log('STOREEEE data sesuib get', customerSellerRes)
- console.log('66666666lo tengo en sesion customerSeller ', customerSellerRes.data)
- self.sellerCustomers = customerSellerRes.data
- })
- },
- setCustomerSeller: function (id) {
- let self = this
- let addCustomerSeller = {}
- addCustomerSeller = self.sessionUserData
- console.log('addCustomerSellerDDDDDDDD', addCustomerSeller)
- let clientToSeller = addCustomerSeller
- clientToSeller['customer_seller_id'] = id
- self.$session.set('user-session', addCustomerSeller)
- console.log('ADD CUSTOMER', this.sessionUserData)
- // store.createSession(userSession)
- },
- dataBind: function (id, item) {
- // item.qty = 0
- let itemString = JSON.stringify(item)
- // console.log(id)
- return {
- [`data-product-${id}`]: itemString
- }
- },
- jQuerySetBadge: function (cartSession) {
- let qty = 0
- Object.keys(cartSession).map(function (objectKey, index) {
- var value = cartSession[objectKey]
- qty += value.data.qty
- })
- if (qty === 0) {
- this.totalCart = 0
- }
- $(document).ready(function () {
- $('.badge').text(qty)
- })
- },
- getDataBind: function (event, id) {
- // let self = this
- $('#success-add-to-cart').fadeIn(500)
- let element = event.currentTarget
- let data = element.getAttribute('data-product-' + id)
- let productById = this.$session.get('target-cart')
- data = JSON.parse(data)
- console.log('data producto', data)
- console.log('data productById', productById)
- console.log('data EL ID', id)
- if (typeof productById[id] !== 'undefined' || productById.length > 0) {
- // let insertData = []
- console.log('ProductId', productById)
- console.log('Id', id)
- if (typeof data.qty === 'undefined') {
- console.log('cantidad no definida', productById[id].data.qty)
- data.qty = data.step
- }
- data.qty += productById[id].data.qty
- productById[id] = {data}
- this.$session.set('target-cart', productById)
- this.jQuerySetBadge(this.$session.get('target-cart'))
- } else {
- if (typeof data.qty === 'undefined') {
- data.qty = data.step
- }
- productById[id] = {data}
- console.log('entra al else EL ID', id)
- this.$session.set('target-cart', productById)
- this.jQuerySetBadge(this.$session.get('target-cart'))
- }
- console.log('CART OBJECT', productById)
- var cart = $('#cart-badge')
- setTimeout(function () {
- cart.addClass('shake-cart')
- }, 50)
- cart.removeClass('shake-cart')
- $('#success-add-to-cart').fadeIn().delay(1000).fadeOut(2000)
- },
- cb: function (val) {
- setTimeout(() => {
- this.pagination(val, 'price')
- }, 2000)
- console.log(val)
- },
- incrementTotal: function () {
- this.total++
- },
- // end products
- // login
- isFormValid: function () {
- return this.username !== '' && this.password !== ''
- },
- decodeHtml: function (html) {
- var txt = unescape(html)
- return txt
- },
- submitForm: function () {
- if (!this.isFormValid()) {
- return false
- } else {
- this.authUser()
- // this.logged = true
- }
- },
- // end login
- // images
- initImages: function () {
- Syncprocess.initProductImages().then((result) => {
- console.log('Init Images Promise:', result)
- }).catch(function (err) {
- console.log(err)
- })
- },
- getImages: function () {
- Syncprocess.getProductImages().then((result) => {
- console.log('Get Images Promise:', result)
- }).catch(function (err) {
- console.log(err)
- })
- },
- downloadImages: function () {
- Syncprocess.downloadProductImages().then((result) => {
- console.log('Download Images Promise:', result)
- }).catch(function (err) {
- console.log(err)
- })
- },
- // end images
- getProducts: function () {
- Syncprocess.getProducts().then((result) => {
- console.log('Get Products:', result)
- }).catch((err) => {
- console.log(err)
- })
- },
- // orders - Quote
- cartQty: function (id) {
- let qtyClass = 'cart-qty-' + id
- return qtyClass
- },
- cartSubtotal: function (id) {
- let subTotalClass = 'cart-subtotal-' + id
- return subTotalClass
- },
- updateCartProductById: function (id) {
- console.log('UPDATE CART PRODUCT', id)
- let cartQty = $('.cart-qty-' + id).val()
- let sessionProducts = this.$session.get('target-cart')
- sessionProducts[id].data.qty = parseInt(cartQty)
- console.log('UPDATE CART sessionProducts', sessionProducts)
- this.$session.set('target-cart', sessionProducts)
- this.setCartItems()
- this.getCartSessionItems()
- this.sessionProductsData = this.$session.get('target-cart')
- this.jQuerySetBadge(sessionProducts)
- },
- deleteCartProductById: function (id) {
- // let cartQty = $('.cart-qty-' + id).val()
- let productsToDelete = {}
- let sessionProducts = this.$session.get('target-cart')
- delete sessionProducts[id]
- productsToDelete = sessionProducts
- this.$session.set('target-cart', {})
- this.$session.set('target-cart', productsToDelete)
- // this.setCartItems()
- this.getCartSessionItems()
- this.jQuerySetBadge(sessionProducts)
- this.sessionProductsData = this.$session.get('target-cart')
- // $('.cart-qty-' + id).parent().parent().hide('fade')
- },
- saveQuoteToSession: function () {
- // let sessionProducts = this.sessionProductsData
- let sessionProducts = this.$session.get('target-cart')
- let quote = this.$session.get('target-quote')
- let data = {}
- let user = this.$session.get('user-session')
- if (typeof quote === 'undefined') {
- this.$session.set('target-quote', {})
- }
- let lineItems = []
- Object.keys(sessionProducts).map(function (objectKey, index) {
- var value = sessionProducts[objectKey]
- lineItems.push({ product_id: value.data.id, quantity: value.data.qty })
- console.log('PRODUCTOS EN EL CARRITO--->', value.data.id)
- })
- console.log('lineitemssss', lineItems)
- console.log('USER - SESSION', user.customer_seller_id)
- var customerId = this.sellerCustomerSelected
- var customerObj
- store.getDoc(customerId).then((result) => {
- if (!result) {
- customerId = user.customer_seller_id
- customerObj = {display_name: 'No especificado'}
- } else {
- customerId = result.ID
- customerObj = result
- }
- console.log('Find Customer by ID:', result)
- console.log('Total Cart:', this.totalCart)
- data = {
- order: {
- payment_details: {
- method_id: 'bacs',
- method_title: 'Pago a coordinar',
- paid: true
- },
- billing_address: {
- first_name: '',
- last_name: '',
- address_1: '',
- address_2: '',
- city: '',
- state: '',
- postcode: '',
- country: '',
- email: '',
- phone: ''
- },
- shipping_address: {
- first_name: '',
- last_name: '',
- address_1: '',
- address_2: '',
- city: '',
- state: '',
- postcode: '',
- country: ''
- },
- customer_id: customerId,
- line_items: lineItems,
- shipping_lines: []
- },
- user: user,
- customer: customerObj,
- total: this.totalCart,
- authorized: false,
- pushed: false,
- created: new Date()
- }
- this.$session.set('target-quote', data)
- console.log(data)
- })
- this.goToSection('checkout')
- },
- placeLocalOrder: function () {
- let self = this
- console.log('placeORder', self.quoteProducts)
- // self.saveOrders(self.quoteProducts)
- var totalCart = this.$session.get('target-quote')
- totalCart.totalCart = this.totalCart
- self.saveOrders(totalCart)
- // vaciar el quote y el cart
- self.$session.set('target-cart', {})
- self.$session.set('target-quote', {})
- $(document).ready(function () {
- $('.badge').text(0)
- })
- // redirección a thanks
- // self.$router.push('/thanks')
- this.goToSection('thanks')
- },
- fetchOrders: function () {
- store.findAllOrders().then((result) => {
- var orders = result.rows
- var pushedOrders = []
- var pendingOrders = []
- orders.map((order) => {
- if (order.doc.pushed) {
- pushedOrders.push(order.doc)
- } else {
- pendingOrders.push(order.doc)
- }
- })
- this.pushedOrders = pushedOrders
- this.pendingOrders = pendingOrders
- console.log('GET pendingOrders:', this.pendingOrders)
- console.log('GET pushedOrders:', this.pushedOrders)
- })
- },
- saveOrders: function (data) {
- Syncprocess.saveOrders(data).then((result) => {
- console.log('Saved Order:', result)
- this.fetchOrders()
- }).catch((err) => {
- console.log(err)
- })
- },
- pushOrders: function () {
- this.loading = true
- Syncprocess.pushOrders().then((result) => {
- console.log('Pushed Orders:', result)
- this.fetchOrders()
- this.loading = false
- }).catch((err) => {
- this.loading = false
- console.log(err)
- })
- },
- removeOrder: function (id, rev) {
- store.removeOrder(id, rev).then((result) => {
- console.log('Removed Order:', result)
- this.fetchOrders()
- }).catch((err) => {
- console.log(err)
- })
- },
- pushOrder: function (order) {
- this.loading = true
- Syncprocess.pushOrder(order).then((result) => {
- console.log('Pushed Order:', result)
- this.fetchOrders()
- this.loading = false
- }).catch((err) => {
- this.loading = false
- console.log(err)
- })
- },
- viewOrder: function (order) {
- this.orderProducts = []
- console.log('Order:', order)
- order.order.line_items.map((product) => {
- store.getDoc(product.product_id.toString()).then((result) => {
- console.log('Order Product:', result)
- result.quantity = product.quantity
- result.subtotal = product.subtotal
- this.orderProducts.push(result)
- })
- })
- this.orderDetail = order
- this.goToSection('orderDetail')
- },
- authorizeOrder: function (authorization, pos) {
- this.pendingOrders[pos].authorized = authorization
- store.updateOrder(this.pendingOrders[pos]).then((result) => {
- this.fetchOrders()
- console.log(result)
- }).catch((err) => {
- console.log('ERROR:', err)
- })
- },
- // end orders
- isUserLogged: function () {
- let self = this
- return store.findByTypeInSession('user_session').then(function (resSessionUser) {
- console.log('lo tengo en sesion LOGIN ', resSessionUser.docs.length)
- if (resSessionUser.docs.length) {
- let userSession = self.$session.get('user-session')
- if (typeof userSession === 'undefined') {
- self.$session.set('user-session', resSessionUser)
- }
- console.log('lo tengo en sesion ', userSession)
- // self.$router.push('/products')
- self.isUserLoggedAttr = true
- $(document).ready(function () {
- $('.products').show()
- $('#navbar').show()
- // $('#thanks').hide()
- // $('#checkout').hide()
- // $('#cart').hide()
- // $('#navbar').show()
- // $('#login-container').show()
- })
- // return Promise.resolve(true)
- // oculto login
- // redirijo
- } else {
- // muestro login
- // return Promise.resolve(false)
- self.isUserLoggedAttr = false
- }
- })
- },
- authUser: function () {
- let self = this
- let userSession = {}
- if (!self.isFormValid()) {
- return false
- } else {
- // chequearlo en sesion primero
- // store.findByTypeInSession('user_session').then(function (resSessionUser) {
- // console.log('busca al usuario en la db de la sesion', resSessionUser)
- // })
- // self.setCurrentStep('products')
- // store.findByTypeInSession('user_session').then(function (resSessionUser) {
- store.findUserSessionByEmail(self.username).then(function (resSessionUser) {
- console.log('busca al usuario en la db de la sesion', resSessionUser)
- // if (typeof resSessionUser === 'undefined' || resSessionUser.docs.length === 0) {
- if (typeof resSessionUser === 'undefined' || resSessionUser.length === 0) {
- store.findUserByEmail(self.username).then(function (result) {
- console.log('resultado ', result)
- if (result != null && result.status === 'ok') {
- // utilizo la data del usuario y lo logueo internamente
- // guardarlo en sesiòn
- console.log(result.status)
- console.log(result)
- var userData = result.user
- // result._id = userData.id.toString()
- userSession._id = userData.id.toString()
- userSession.nickname = userData.nickname
- userSession.nicename = userData.nicename
- userSession.username = userData.username
- userSession.password = SHA256(self.password).toString()
- userSession.email = userData.email
- userSession.displayname = userData.displayname
- userSession.session_type = 'user_session'
- userSession.customer_seller_id = ''
- self.$session.set('user-session', userSession)
- store.createSession(userSession)
- if (!self.appInstalled) {
- console.log('App no instalada')
- self.goToSection('setup')
- } else {
- self.isUserLoggedAttr = true
- self.syncApp()
- self.goToSection('products')
- }
- // self.isUserLoggedAttr = true
- // self.syncApp()
- // self.goToSection('login', 'products')
- } else {
- console.log('entra acá si el usuario no está en la DB')
- self.$http.get('http://targetmoda2.braintlylabs.com/home/carrito/api/user/generate_auth_cookie/?insecure=cool&username=' + self.username + '&password=' + self.password)
- .then(function (response) {
- // logica de guardado del usuario en la DB
- var userObj = response.data
- console.log(userObj)
- if (userObj.status === 'ok') {
- var userData = userObj.user
- console.log('UserData', userData)
- console.log('userObj', userObj)
- userObj._id = userData.id.toString()
- userSession._id = userData.id.toString()
- userSession.nickname = userData.nickname
- userSession.nicename = userData.nicename
- userSession.username = userData.username
- userSession.password = SHA256(self.password).toString()
- userSession.email = userData.email
- userSession.displayname = userData.displayname
- self.$session.set('user-session', userSession)
- userSession.session_type = 'user_session'
- userSession.customer_seller_id = ''
- store.createSession(userSession)
- console.log('App instalada:', self.appInstalled)
- if (!self.appInstalled) {
- console.log('App no instalada')
- self.goToSection('setup')
- } else {
- self.isUserLoggedAttr = true
- self.syncApp()
- self.goToSection('products')
- }
- // console.log('check user', store.findUserByEmail(userData.id.email))
- // guardarlo en sesión
- // store.create(userObj)
- // store.createSession(userSession)
- }
- self.auth = response.data
- setTimeout(() => {
- // this.logged = true
- // #/register tener en cuenta esto
- // self.$router.push('/products')
- }, 1000)
- })
- }
- })
- } else {
- let userSession = self.$session.get('user-session')
- if (typeof userSession === 'undefined') {
- self.$session.set('user-session', resSessionUser)
- }
- console.log('DATA SESSION DB ->>>>>>>', resSessionUser)
- console.log('lo tengo en sesion else! ', userSession)
- if (!self.appInstalled) {
- console.log('App no instalada')
- self.goToSection('setup')
- } else {
- console.log('Entra aca para loguearse y luego ir aproductos')
- console.log('RECIBO EL USUARIO ->>>>>>>', resSessionUser)
- console.log('RECIBO EL passowrd del form->>>>>>>', self.password)
- if (SHA256(self.password).toString() === resSessionUser.password) {
- self.isUserLoggedAttr = true
- self.loginError = false
- self.syncApp()
- self.goToSection('products')
- } else {
- self.loginError = true
- console.log('password incorrecto')
- }
- }
- // self.isUserLoggedAttr = true
- // self.syncApp()
- // self.goToSection('login', 'products')
- // oculto login
- // redirijo
- }
- })
- }
- },
- syncApp: function () {
- this.pagination()
- this.fetchCategories()
- this.fetchOrders()
- this.getSellerCustomers()
- this.pushOrders()
- console.log('Products:', this.sessionProductsData)
- // this.getSeller()
- let cartSession = this.$session.get('target-cart')
- let userSession = this.$session.get('user-session')
- // this.$session.remove('target-cart')
- if (typeof cartSession === 'undefined') {
- console.log('session no definida la crea')
- this.$session.start()
- this.$session.set('target-cart', {})
- } else if (typeof userSession === 'undefined') {
- console.log('user session no definida la crea')
- // this.$session.start()
- this.$session.set('user-session', {})
- }
- this.getCartSessionItems()
- Syncprocess.init().then(function (result) {
- console.log('iniiiit', result)
- })
- },
- // end auth users
- // FILTERS BEGINS
- isEmpty: function (element) {
- let check
- Object.keys(element).length === 0 ? check = true : check = false
- // console.log('check vacio', check)
- return check
- },
- // pagination: function () {
- // var self = this
- // store.filters({categories: {$all: ['Anillos']}}).then(function (result) {
- // console.log('FILTROS', result.docs)
- // self.items = result.docs
- // self.products = result.docs
- // })
- // },
- pagination: function (id, type = 'categories') {
- // let self = this
- console.log(id)
- if (type === 'categories') {
- this.filterCategories(id)
- } else {
- this.filterPrice(id)
- }
- // store.filters({categories: {$all: [id]}}).then(function (result) {
- // console.log('ESTA EMPTY', self.isEmpty(result.docs))
- // if (self.isEmpty(result.docs)) {
- // self.pagination('Anillos')
- // }
- // self.items = result.docs
- // self.products = result.docs
- // })
- },
- filterPrice: function (value) {
- let self = this
- self.loading = true
- store.productFiltByPrice(value).then(function (result) {
- console.log('priceeee', result)
- self.items = result.docs
- self.products = result.docs
- self.loading = false
- })
- },
- filterSearch: function () {
- let self = this
- // $('.loading').show()
- self.loading = true
- store.filterSearch(self.sku).then(function (result) {
- if (self.isEmpty(result.docs)) {
- console.log('esta vacio!!!!')
- // $('.loading').hide()
- self.loading = false
- self.productsAlert = true
- } else {
- self.loading = false
- self.productsAlert = false
- console.log('FILTER SKU!!', result.docs)
- // $('.loading').hide()
- }
- self.items = result.docs
- self.products = result.docs
- })
- },
- filterCategories: function (id) {
- console.log('FILTER CATES', id)
- let self = this
- store.filters({categories: {$all: [id]}}).then(function (result) {
- if (self.isEmpty(result.docs)) {
- console.log('esta vacio')
- // self.pagination('Anillos')
- // $('#pages').hide()
- // $('#products-alert').show()
- self.productsAlert = true
- } else {
- // $('#products-alert').hide()
- self.productsAlert = false
- $('#pages').show()
- }
- self.items = result.docs
- self.products = result.docs
- })
- },
- fetchCategories: function () {
- var self = this
- self.loading = true
- store.findByType('category').then(function (catsWC) {
- // let categoriesWC = catsWC.docs
- self.categories = self.arrangeCategories(catsWC.docs)
- console.log('todas las categorias', self.categories)
- self.loading = false
- })
- },
- arrangeCategories: function (categories, parent = 0) {
- let self = this
- let result = {}
- categories.filter(function (category) {
- if (category.parent === parent) {
- result[category.name] = self.arrangeCategories(categories, category.id)
- }
- })
- return result
- },
- // CATEGORIES - DROPDOWN
- catDropdown: function (classTo) {
- console.log('hizo click!!!!!!')
- console.log('tocaaaaaa', classTo)
- $('.dropdown-submenu a.' + classTo).next('ul').toggle(function (e) {
- e.stopPropagation()
- e.preventDefault()
- })
- // e.stopPropagation()
- // e.preventDefault()
- },
- // FILTERS ENDS
- // CART
- setTotal: function (value, qty) {
- let total = value * qty
- this.totalCart = total
- console.log('TOTAL EN SET TOTAL', total)
- },
- getCartSessionItems: function () {
- let self = this
- let cartSession = this.$session.get('target-cart')
- let qty = 0
- let total = 0
- // let price = 0
- Object.keys(cartSession).map(function (objectKey, index) {
- var value = cartSession[objectKey]
- console.log('PRODUCTOS EN EL CARRITO--->', cartSession[objectKey])
- qty += parseInt(value.data.qty)
- total = self.setTotal(parseInt(value.data.price), qty)
- })
- // total = price
- console.log('var QTY !!!!', qty)
- console.log('var TOTAL !!!!', total)
- // self.totalCart = total
- // this.badgeItems(qty)
- },
- dataBindCartProducts: function (id, name, item = null) {
- return {
- [`data-${name}-product-${id}`]: id
- }
- },
- // CART ENDS
- wooAuth () {
- }
- },
- created: function () {
- this.loading = false
- this.setUsersSessions()
- let cartSession = this.$session.get('target-cart')
- let userSession = this.$session.get('user-session')
- store.findById('app_setup').then((result) => {
- console.log('App installed:', result)
- if (result) {
- this.appInstalled = true
- }
- })
- if (this.appInstalled) {
- this.pagination()
- this.fetchCategories()
- // this.$session.remove('user-session')
- if (typeof cartSession === 'undefined') {
- console.log('session no definida la crea')
- this.$session.start()
- this.$session.set('target-cart', {})
- } else if (typeof userSession === 'undefined') {
- console.log('user session no definida la crea')
- // this.$session.start()
- this.$session.set('user-session', {})
- }
- // this.setCartQtyItems(cartSession)
- this.getCartSessionItems()
- Syncprocess.init().then(function (result) {
- console.log('iniiiit', result)
- })
- }
- console.log('cart sesiooo', this.$session.get('target-cart'))
- if (typeof cartSession !== 'undefined') {
- this.setCartQtyItems(cartSession)
- }
- // PRODUCTS & FILTERS
- console.log('SESION ALL', this.$session.getAll())
- }
- }
- </script>
- <!-- Add "scoped" attribute to limit CSS to this component only -->
- <style scoped>
- ul{
- list-style-type: none !important;
- }
- #checkout .btn-make-order{
- width: 100%;
- }
- .last-child-cat{
- border-color:transparent !important;
- background-color:transparent !important;
- padding-left:5%;
- }
- .discount-box {margin-left:2%;display: inline;}
- .discount-box input{width: 10%;}
- .checkbox{margin-right: 2%;}
- #thanks-keep {background-color: #000 !important}
- .flash-message{display:none}
- .shake-cart {
- animation: shake 0.82s cubic-bezier(.36,.07,.19,.97) both;
- transform: translate3d(0, 0, 0);
- backface-visibility: hidden;
- perspective: 1000px;
- }
- @keyframes shake {
- 10%, 90% {
- transform: translate3d(-1px, 0, 0);
- }
- 20%, 80% {
- transform: translate3d(2px, 0, 0);
- }
- 30%, 50%, 70% {
- transform: translate3d(-4px, 0, 0);
- }
- 40%, 60% {
- transform: translate3d(4px, 0, 0);
- }
- }
- .panel-default>.panel-heading{
- background: none;
- }
- .total-order{
- float: right;
- height: 60px;
- margin: 0px 40px 0px 0px;
- /* border-top:1px solid #ccc; */
- /* width: 100%; */
- }
- .panel {
- border:none;
- -webkit-box-shadow: none;
- }
- .price-table{
- border:none !important;
- padding-top:40%;
- -webkit-box-shadow: none !important;
- }
- .table td {
- font-family: 'Montserrat-Light' !important;
- }
- .title-table{
- margin-top:21%;
- }
- </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement