Advertisement
Guest User

target - customer antes cats

a guest
Nov 30th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 112.15 KB | None | 0 0
  1. <template>
  2. <div class="customers">
  3. <!-- <navbar></navbar> -->
  4. <div v-if="sections.navbar" id="navbar">
  5. <nav class="navbar navbar-default">
  6. <img id="logo" src="~@/assets/logotarget.png" alt="targetmoda">
  7. <div class="container">
  8. <div class="navbar-header">
  9. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
  10. <span class="sr-only">Toggle navigation</span>
  11. <span class="icon-bar"></span>
  12. <span class="icon-bar"></span>
  13. <span class="icon-bar"></span>
  14. </button>
  15. </div>
  16.  
  17. <div id="navbar" class="collapse navbar-collapse">
  18. <!-- <ul class="nav navbar-nav">
  19. <li><router-link to="/">Home</router-link></li>
  20. <li><router-link to="/products">Productos</router-link></li>
  21. </ul> -->
  22.  
  23. <!-- <qty></qty> -->
  24. <div v-on:click="handler('cart')" id="cart-badge" class="button-logout">
  25. <button type="button" class="btn btn-large" title="Ir al carrito">
  26. <!-- <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> -->
  27. <span class="icon-Mi_carrito-02 size-3x coral" aria-hidden="true"></span><br><span v-model="badgeItems" class="badge"> {{ badge }}</span>
  28. </button>
  29. </div>
  30. <div v-on:click="syncApp" class="button-logout">
  31. <button type="button" class="btn btn-large" title="Sincronizar aplicación">
  32. <span class="icon-Sincronizar-02 size-3x coral" aria-hidden="true"></span><br><span class="text-uppercase x-small coral">Sincronizar</span>
  33. </button>
  34. </div>
  35. <div v-on:click="goToSection('orders')" class="button-logout">
  36. <button type="button" class="btn btn-large" title="Ver pedidos">
  37. <span class="icon-Pedidos-02 size-3x coral" aria-hidden="true"></span><br><span class="text-uppercase x-small coral">Pedidos</span>
  38. </button>
  39. </div>
  40. <div v-on:click="logout" class="button-logout">
  41. <button type="button" class="btn btn-large" title="Salir y cerrar sesión">
  42. <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>
  43. </button>
  44. </div>
  45. </div>
  46. </div>
  47. </nav>
  48. <div id="success-add-to-cart" class="flash-message">
  49. <div class="alert alert-success">
  50. <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  51. <strong>¡Agregado satisfactoriamente!</strong>
  52. </div>
  53. </div>
  54. <div id="success-downloaded-csv" class="flash-message">
  55. <div class="alert alert-success">
  56. <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  57. <strong>¡CSV descargado satisfactoriamente!</strong>
  58. </div>
  59. </div>
  60. <div id="error-downloaded-csv" class="flash-message">
  61. <div class="alert alert-danger">
  62. <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  63. <strong>Error al descargar el CSV</strong>
  64. </div>
  65. </div>
  66. </div>
  67. <div v-if="sections.thanks" id="thanks">
  68. <div class="row">
  69. <div class="jumbotron" style="box-shadow: 2px 2px 4px #000000;">
  70. <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>
  71. <center><div class="btn-group" style="margin-top:50px;">
  72. <!-- <div class="btn btn-success"><router-link to="/products">Seguir comprando</router-link></div> -->
  73. <div v-on:click="goToSection('products'), emptyQuoute" class="btn btn-success" id="thanks-keep">Seguir comprando</div>
  74. </div></center>
  75. </div>
  76. </div>
  77. </div>
  78.  
  79. <!-- INDEX Checkout -->
  80. <div v-if="sections.checkout" id="checkout">
  81. <div id="checkout-content">
  82.  
  83. <!-- BREADCRUMBS -->
  84. <div class="page-header">
  85.  
  86. <span v-on:click="goToSection('products')" class="pointerHand">Carrito</span>
  87. >
  88. <span class="active-step">Check Out</span>
  89. >
  90. <span>Pedido finalizado</span>
  91. </div>
  92. <!-- /BREADCRUMBS/ -->
  93.  
  94. <!-- CHECKOUT Body -->
  95. <div class="row grid-divider">
  96. <!-- LEFT Column -->
  97. <div id="order-box" class="col-md-7">
  98. <div class="col-padding">
  99. <h3>TU PEDIDO</h3>
  100. <h4>*Despliegue las categorías para aplicar descuentos individualmente a los productos que seleccionó </h4>
  101. <div v-for="(value, key, index) in categories" class="panel-group">
  102.  
  103. <div class="panel panel-default">
  104. <div class="panel-heading">
  105. <h4 class="panel-title">
  106. <a @click="showDiscTable" data-toggle="collapse" :href="'#' + key.replace(/[\s\W]/g, '')">{{ key }}<span v-show="!isEmpty(value)"class="caret"></span></a>
  107. <div class="discount-box">
  108. <label :for="'discount_' + key.replace(/[\s\W]/g, '')">Descuento Pelo</label>
  109. <input type="number" min="0" class="discount-input"
  110. :id="'discount_' + key.replace(/[\s\W]/g, '')" @change="setCategoryDiscount(key)" placeholder="%">
  111. </div>
  112. </h4>
  113. </div>
  114. <div :id="key.replace(/[\s\W]/g, '')" class="panel-collapse collapse">
  115.  
  116. <div v-for="(valueK, keyK, indexK) in value" class="panel-body">
  117. <div class="border-box">
  118. <table style="display:none" :class="'table table-hover table-condensed table_cat_' + keyK">
  119. <thead>
  120. <tr>
  121. <th class="col-xs-2">Foto</th>
  122. <th class="col-xs-2">Producto</th>
  123. <th class="col-xs-1">Precio</th>
  124. <th class="col-xs-1">Cantidad</th>
  125. <th class="col-xs-1">% Desc.</th>
  126. <th class="text-center col-xs-1">Subtotal</th>
  127. </tr>
  128. </thead>
  129. <tbody>
  130. <tr v-if="valueP.data.categories[0].replace(/\s/g, '') === keyK.replace(/\s/g, '')" v-for="(valueP, keyP, indexP) in sessionProductsData">
  131. <td data-th="Product">
  132. <div class="row">
  133. <div class="col-sm-2 hidden-xs">
  134. <img class="product-image" v-bind:src="'file://' + valueP.data.images[0].local_src" alt="" />
  135. </div>
  136. </div>
  137. </td>
  138. <td data-th="Product">
  139. <div class="row">
  140. <div class="col-sm-10">
  141.  
  142. <div class="nomargin title-table">
  143. <input :id="'checkbox_' + keyP" type="checkbox" :value="keyP.replace(/\s/g, '')" checked>
  144. {{valueP.data.title}}
  145. </div>
  146. <!-- <h4 class="nomargin">{{keyK}}</h4> -->
  147. </div>
  148. </div>
  149. </td>
  150. <input type="hidden" class="show_table_desc" :value="valueP.data.categories[0].replace(/\s/g, '')"/>
  151. <td data-th="Quantity">
  152. <div class="text-center price-table">${{valueP.data.price}}</div>
  153. </td>
  154. <td data-th="Quantity">
  155. <span class="form-control text-center">{{valueP.data.qty}}</span>
  156. </td>
  157. <td data-th="Quantity">
  158. <input type="number" min="0"
  159. :class="'form-control text-center discount-input-' + keyP.replace(/\s/g, '')"
  160. :id="'discount_' + keyP.replace(/\s/g, '')" placeholder="%"
  161. value="" @change="setProductDiscount(keyP.replace(/\s/g, ''))">
  162.  
  163. <!-- <span class="form-control text-center" v-if="valueP.data.discount_product > 0">
  164. {{ valueP.data.discount_product }}
  165. </span>
  166. <span class="form-control text-center" v-else-if="valueP.data.discount_category > 0">
  167. {{ valueP.data.discount_category }}
  168. </span> -->
  169. <!-- <span class="form-control text-center" v-else>
  170. ___
  171. </span> -->
  172. </td>
  173. <!-- <td data-th="Subtotal" class="text-center" v-if="valueP.data.subtotal > 0">
  174. <strike>${{ valueP.data.price * valueP.data.qty }}<br>
  175. </strike>${{ valueP.data.subtotal }}
  176. </td> -->
  177. <!-- <td data-th="Subtotal" class="text-center" v-else>${{ value.data.price * value.data.qty }}</td> -->
  178. <td style="padding-top:4%" data-th="Subtotal" class="text-center" v-if="valueP.data.subtotal > 0">
  179. <strike>${{ valueP.data.price * valueP.data.qty }}<br></strike>
  180. ${{ valueP.data.subtotal }}</td>
  181. <td style="padding-top:4%" data-th="Subtotal" class="text-center" v-else>
  182. ${{ valueP.data.price * valueP.data.qty }}
  183. </td>
  184. </tr>
  185.  
  186. </tbody>
  187. <tfoot>
  188. <!-- <td></td>
  189. <tr class="visible-xs">
  190. <td class="text-center"><strong>Total 1.99</strong></td>
  191. </tr>
  192. <tr>
  193. <td>
  194. <div v-on:click="placeLocalOrder" class="btn btn-success btn-make-order">
  195.  
  196. FINALIZAR PEDIDO
  197.  
  198. </div>
  199. </td>
  200. <td></td>
  201. <td colspan="1" class="hidden-xs"></td>
  202. <td class="hidden-xs text-center"><strong>Total ${{totalCart}}</strong></td>
  203. <td></td>
  204. </tr> -->
  205. </tfoot>
  206. </table>
  207. </div><!-- border box final-->
  208.  
  209.  
  210. <div class="panel panel-default">
  211. <div class="panel-heading">
  212. <h4 class="panel-title">
  213. <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>
  214. <div class="discount-box">
  215. <label :for="'discount_' + key.replace(/[\s\W]/g, '') + '_' + keyK.replace(/[\s\W]/g, '')">Descuento </label>
  216. <input type="number"
  217. 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, '')"
  218. @change="setCategoryDiscount(key + '_' + keyK)" placeholder="%">
  219. </div>
  220. </h4>
  221.  
  222.  
  223.  
  224. </div>
  225. </div>
  226.  
  227.  
  228. <!-- <div v-if="value.data.categories[0].replace(/\s/g, '') === keyK.replace(/\s/g, '')" v-for="(value, key, index) in sessionProductsData" class="panel-body">
  229. <input :id="'checkbox_' + key" type="checkbox" :value="key.replace(/\s/g, '')" checked>
  230. {{value.data.title}}
  231. {{keyK}}
  232. <div class="discount-box">
  233. <label :for="'discount_' + key.replace(/\s/g, '')">Descuento </label>
  234. <input type="number" min="0" :class="'discount-input-' + key.replace(/\s/g, '')" :id="'discount_' + key.replace(/\s/g, '')" placeholder="%" value="" @change="setProductDiscount(key.replace(/\s/g, ''))">
  235. </div>
  236. </div> -->
  237. <!-- -->
  238.  
  239.  
  240. <div class="panel panel-default">
  241. <!-- <div class="panel-heading">
  242. <h4 class="panel-title">
  243. <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>
  244. <div class="discount-box">
  245. <label :for="'discount_' + key.replace(/[\s\W]/g, '') + '_' + keyK.replace(/[\s\W]/g, '')">Descuento </label>
  246. <input type="number"
  247. 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, '')"
  248. @change="setCategoryDiscount(key + '_' + keyK)" placeholder="%">
  249. </div>
  250. </h4>
  251. </div> -->
  252.  
  253. <div :id="key.replace(/[\s\W]/g, '') + '_' + keyK.replace(/[\s\W]/g, '')" class="panel-collapse collapse">
  254. <div v-for="(valueM, keyM, indexM) in valueK" class="panel-body">
  255. <div class="border-box">
  256. <table style="display:none" :class="'table table-hover table-condensed table_cat_' + keyM">
  257. <thead>
  258. <tr>
  259. <th class="col-xs-2">Foto</th>
  260. <th class="col-xs-2">Producto</th>
  261. <th class="col-xs-1">Precio</th>
  262. <th class="col-xs-1">Cantidad</th>
  263. <th class="col-xs-2">% Desc.</th>
  264. <th class="text-center col-xs-1">Subtotal</th>
  265. </tr>
  266. </thead>
  267. <tbody>
  268. <tr v-if="valuePQ.data.categories[0].replace(/\s/g, '') === keyM.replace(/\s/g, '')" v-for="(valuePQ, keyPQ, indexPQ) in sessionProductsData">
  269. <td data-th="Product">
  270. <div class="row">
  271. <div class="col-sm-2 hidden-xs">
  272. <img class="product-image" v-bind:src="'file://' + valuePQ.data.images[0].local_src" alt="" />
  273. </div>
  274. </div>
  275. </td>
  276. <td data-th="Product">
  277. <div class="row">
  278. <div class="col-sm-10">
  279.  
  280. <div class="nomargin title-table">
  281. <input :id="'checkbox_' + keyPQ" type="checkbox" :value="keyPQ.replace(/\s/g, '')" checked>
  282. {{valuePQ.data.title}}
  283. </div>
  284. <!-- <h4 class="nomargin">keyk->{{keyM}}</h4>
  285. <h4 class="nomargin">value category->{{valuePQ.data.categories[0]}}</h4> -->
  286. </div>
  287. </div>
  288. </td>
  289. <input type="hidden" class="show_table_desc" :value="valuePQ.data.categories[0].replace(/\s/g, '')"/>
  290. <td data-th="Quantity">
  291. <div class="text-center price-table">${{valuePQ.data.price}}</div>
  292. </td>
  293. <td data-th="Quantity">
  294. <span class="form-control text-center">{{valuePQ.data.qty}}</span>
  295. </td>
  296. <td data-th="Quantity">
  297. <input class="form-control text-center" type="number" min="0"
  298. :class="'discount-input-' + keyPQ.replace(/\s/g, '')"
  299. :id="'discount_' + keyPQ.replace(/\s/g, '')" placeholder="%"
  300. value="" @change="setProductDiscount(keyPQ.replace(/\s/g, ''))">
  301.  
  302. <!-- <span class="form-control text-center" v-if="valuePQ.data.discount_product > 0">
  303. {{ valuePQ.data.discount_product }}
  304. </span>
  305. <span class="form-control text-center" v-else-if="valuePQ.data.discount_category > 0">
  306. {{ valuePQ.data.discount_category }}
  307. </span> -->
  308. <!-- <span class="form-control text-center" v-else>
  309. ___
  310. </span> -->
  311. </td>
  312. <!-- <td data-th="Subtotal" class="text-center" v-if="valuePQ.data.subtotal > 0">
  313. <strike>${{ valuePQ.data.price * valuePQ.data.qty }}<br>
  314. </strike>${{ valuePQ.data.subtotal }}
  315. </td> -->
  316. <!-- <td data-th="Subtotal" class="text-center" v-else>${{ value.data.price * value.data.qty }}</td> -->
  317. <td style="padding-top:4%" data-th="Subtotal" class="text-center" v-if="valuePQ.data.subtotal > 0">
  318. <strike>${{ valuePQ.data.price * valuePQ.data.qty }}<br></strike>
  319. ${{ valuePQ.data.subtotal }}</td>
  320. <td style="padding-top:4%" data-th="Subtotal" class="text-center" v-else>
  321. ${{ valuePQ.data.price * valuePQ.data.qty }}
  322. </td>
  323. </tr>
  324.  
  325. <!-- <tr v-for="(value, key, index) in sessionProductsData">
  326. <td data-th="Product">
  327. <div class="row">
  328. <div class="col-sm-10">
  329. <h4 class="nomargin">{{value.data.title}}</h4>
  330. </div>
  331. </div>
  332. </td>
  333. <td data-th="Quantity">
  334. <span class="form-control text-center">{{value.data.qty}}</span>
  335. </td>
  336. <td data-th="Quantity">
  337. <input type="number" min="0"
  338. :class="'discount-input-' + key.replace(/\s/g, '')"
  339. :id="'discount_' + key.replace(/\s/g, '')" placeholder="%"
  340. value="" @change="setProductDiscount(key.replace(/\s/g, ''))">
  341.  
  342. <span class="form-control text-center" v-if="value.data.discount_product > 0">
  343. {{ value.data.discount_product }}
  344. </span>
  345. <span class="form-control text-center" v-else-if="value.data.discount_category > 0">
  346. {{ value.data.discount_category }}
  347. </span>
  348. <span class="form-control text-center" v-else>
  349. ___
  350. </span>
  351.  
  352. </td>
  353. <td data-th="Subtotal" class="text-center" v-if="value.data.subtotal > 0"><strike>${{ value.data.price * value.data.qty }}<br></strike>${{ value.data.subtotal }}</td>
  354. <td data-th="Subtotal" class="text-center" v-else>${{ value.data.price * value.data.qty }}</td>
  355. </tr> -->
  356. <!-- <tr v-for="(value, key, index) in sessionProductsData">
  357. <td data-th="Product">
  358. <div class="row">
  359. <div class="col-sm-10">
  360. <h4 class="nomargin">{{value.data.title}}</h4>
  361. </div>
  362. </div>
  363. </td>
  364. <td data-th="Quantity">
  365. <span class="form-control text-center">{{value.data.qty}}</span>
  366. </td>
  367. <td data-th="Quantity">
  368. <input type="number" min="0"
  369. :class="'discount-input-' + key.replace(/\s/g, '')"
  370. :id="'discount_' + key.replace(/\s/g, '')" placeholder="%"
  371. value="" @change="setProductDiscount(key.replace(/\s/g, ''))">
  372.  
  373. <span class="form-control text-center" v-if="value.data.discount_product > 0">
  374. {{ value.data.discount_product }}
  375. </span>
  376. <span class="form-control text-center" v-else-if="value.data.discount_category > 0">
  377. {{ value.data.discount_category }}
  378. </span>
  379. <span class="form-control text-center" v-else>
  380. ___
  381. </span>
  382.  
  383. </td>
  384. <td data-th="Subtotal" class="text-center" v-if="value.data.subtotal > 0"><strike>${{ value.data.price * value.data.qty }}<br></strike>${{ value.data.subtotal }}</td>
  385. <td data-th="Subtotal" class="text-center" v-else>${{ value.data.price * value.data.qty }}</td>
  386. </tr> -->
  387. </tbody>
  388. <tfoot>
  389. <!-- <td></td>
  390. <tr class="visible-xs">
  391. <td class="text-center"><strong>Total 1.99</strong></td>
  392. </tr>
  393. <tr>
  394. <td>
  395. <div v-on:click="placeLocalOrder" class="btn btn-success btn-make-order">
  396.  
  397. FINALIZAR PEDIDO
  398.  
  399. </div>
  400. </td>
  401. <td></td>
  402. <td colspan="1" class="hidden-xs"></td>
  403. <td class="hidden-xs text-center"><strong>Total ${{totalCart}}</strong></td>
  404. <td></td>
  405. </tr> -->
  406. </tfoot>
  407. </table>
  408. </div><!-- border box final-->
  409.  
  410. <!-- -->
  411. <!-- <div v-if="value.data.categories[0].replace(/\s/g, '') === keyM.replace(/\s/g, '')" v-for="(value, key, index) in sessionProductsData" class="panel-body">
  412. <input :id="'checkbox_' + key" type="checkbox" :value="key.replace(/\s/g, '')" checked>
  413. {{value.data.title}}
  414. {{value.data.categories[1]}}
  415. {{keyM.replace(/\s/g, '')}}
  416. <div class="discount-box">
  417. <label :for="'discount_' + key.replace(/\s/g, '')">Descuento </label>
  418. <input type="number" min="0" :class="'discount-input-' + key.replace(/\s/g, '')" :id="'discount_' + key.replace(/\s/g, '')" placeholder="%" value=""
  419. @change="setProductDiscount(key.replace(/\s/g, ''))">
  420. </div>
  421. </div> -->
  422. <!-- -->
  423. <div class="">
  424. <div class="panel-heading last-child-cat">
  425. <h4 class="panel-title">
  426. <span>{{ keyM }}</span>
  427. <div class="discount-box">
  428. <label :for="'discount_' + key.replace(/[\s\W]/g, '') + '_' + keyK.replace(/[\s\W]/g, '') + '_' + keyM.replace(/[\s\W]/g, '')">Descuento </label>
  429. <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="%">
  430. </div>
  431. </h4>
  432.  
  433.  
  434. </div>
  435. </div>
  436. </div>
  437. </div>
  438. </div><!-- fin categorias y productos-->
  439. </div>
  440. </div>
  441. </div>
  442.  
  443. </div>
  444. <div class="panel-group">
  445. <div class="panel panel-default">
  446. <div style="border-top:solid 1px #ccc"class="panel-heading">
  447. <div class="total-order"><strong>Total ${{totalCart}}</strong></div>
  448. </div>
  449. </div>
  450. </div>
  451. <!-- <div class="panel-group">
  452. <div class="panel panel-default">
  453. <div class="panel-heading">
  454. <h4 class="panel-title">
  455. <a data-toggle="collapse" href="#collapse1">Productos <span class="caret"></span></a>
  456. </h4>
  457. </div>
  458. <div id="collapse1" class="panel-collapse collapse">
  459. <div v-for="(value, key, index) in sessionProductsData" class="panel-body">
  460. <input :id="'checkbox_' + key" type="checkbox" :value="key.replace(/\s/g, '')" checked>
  461. {{value.data.title}}
  462. <div class="discount-box">
  463. <label :for="'discount_' + key.replace(/\s/g, '')">Descuento </label>
  464. <input type="number" min="0" :class="'discount-input-' + key.replace(/\s/g, '')" :id="'discount_' + key.replace(/\s/g, '')" placeholder="%" value="" @change="setProductDiscount(key.replace(/\s/g, ''))">
  465. </div>
  466. </div>
  467. <div class="panel-footer"></div>
  468. </div>
  469. </div>
  470. </div> -->
  471. </div>
  472. </div>
  473. <!-- /LEFT Column/ -->
  474.  
  475. <!-- RIGHT Column -->
  476. <div class="col-md-5">
  477. <div class="col-padding">
  478. <div class="panel-group">
  479. <!-- <div class="panel panel-default">
  480. <div class="panel-heading">
  481. <h4 class="panel-title">
  482. <a data-toggle="collapse" href="#collapse1">Productos <span class="caret"></span></a>
  483. </h4>
  484. </div>
  485. <div id="collapse1" class="panel-collapse collapse">
  486. <div v-for="(value, key, index) in sessionProductsData" class="panel-body">
  487. <input :id="'checkbox_' + key" type="checkbox" :value="key.replace(/\s/g, '')" checked>
  488. {{value.data.title}}
  489. <div class="discount-box">
  490. <label :for="'discount_' + key.replace(/\s/g, '')">Descuento </label>
  491. <input type="number" min="0" :class="'discount-input-' + key.replace(/\s/g, '')" :id="'discount_' + key.replace(/\s/g, '')" placeholder="%" value="" @change="setProductDiscount(key.replace(/\s/g, ''))">
  492. </div>
  493. </div>
  494. <div class="panel-footer"></div>
  495. </div>
  496. </div> -->
  497. </div>
  498. <div class="order-box">
  499. <!-- <table class="table table-hover table-condensed">
  500. <thead>
  501. <tr>
  502. <th style="width:50%">Producto</th>
  503. <th style="width:8%">Cantidad</th>
  504. <th style="width:8%">% Desc.</th>
  505. <th style="width:22%" class="text-center">Subtotal</th>
  506. </tr>
  507. </thead>
  508. <tbody>
  509. <tr v-for="(value, key, index) in sessionProductsData">
  510. <td data-th="Product">
  511. <div class="row">
  512. <div class="col-sm-10">
  513. <h4 class="nomargin">{{value.data.title}}</h4>
  514. </div>
  515. </div>
  516. </td>
  517. <td data-th="Quantity">
  518. <span class="form-control text-center">{{value.data.qty}}</span>
  519. </td>
  520. <td data-th="Quantity">
  521. <span class="form-control text-center" v-if="value.data.discount_product > 0">
  522. {{ value.data.discount_product }}
  523. </span>
  524. <input type="number" min="0"
  525. :class="'discount-input-' + key.replace(/\s/g, '')"
  526. :id="'discount_' + key.replace(/\s/g, '')" placeholder="%"
  527. value="" @change="setProductDiscount(key.replace(/\s/g, ''))">
  528.  
  529. <span class="form-control text-center" v-if="value.data.discount_product > 0">
  530. {{ value.data.discount_product }}
  531. </span>
  532. <span class="form-control text-center" v-else-if="value.data.discount_category > 0">
  533. {{ value.data.discount_category }}
  534. </span>
  535. <span class="form-control text-center" v-else>
  536. ___
  537. </span>
  538. subtotal 1 {{value.data.subtotal}}
  539. </td>
  540. <td data-th="Subtotal" class="text-center" v-if="value.data.subtotal > 0"><strike>${{ value.data.price * value.data.qty }}<br></strike>${{ value.data.subtotal }}</td>
  541. <td data-th="Subtotal" class="text-center" v-else>${{ value.data.price * value.data.qty }}</td>
  542. </tr>
  543. </tbody>
  544. <tfoot>
  545. <td></td>
  546. <tr class="visible-xs">
  547. <td class="text-center"><strong>Total 1.99</strong></td>
  548. </tr>
  549. <tr>
  550. <td>
  551. <div v-on:click="placeLocalOrder" class="btn btn-success btn-make-order">
  552.  
  553. FINALIZAR PEDIDO
  554.  
  555. </div>
  556. </td>
  557. <td></td>
  558. <td colspan="1" class="hidden-xs"></td>
  559. <td class="hidden-xs text-center"><strong>Total ${{totalCart}}</strong></td>
  560. <td></td>
  561. </tr>
  562. </tfoot>
  563. </table> -->
  564. </div>
  565. <div class="col-padding">
  566. <h3>NOTAS</h3>
  567. <p>Por favor, ingrese información a tener en cuenta sobre este pedido.</p>
  568. <div class="form-group">
  569. <textarea class="form-control" rows="2" cols="5" id="notes"></textarea>
  570. </div>
  571. </div>
  572. <div class="col-padding">
  573. <h3>ENVÍO</h3>
  574. <p>¿Desea unificar los envíos con pedidos pendientes?</p>
  575. <input type="radio" class="unify-pendings" name="unify-pendings" value="si">
  576. <label for="unify-yes"> Sí </label>
  577.  
  578. <input type="radio" class="unify-pendings" name="unify-pendings" value="no">
  579. <label for="unify-yes"> No </label>
  580.  
  581. <p>¿Desea unificar los envíos con pedidos de PREVENTA?</p>
  582. <input type="radio" class="unify-presale" name="unify-presale" value="si">
  583. <label for="unify-yes"> Sí </label>
  584.  
  585. <input type="radio" class="unify-presale" name="unify-presale" value="no">
  586. <label for="unify-yes"> No </label>
  587. </div>
  588. <!-- <div class="h-divider-large"></div> -->
  589. <div class="col-padding">
  590. <h3>TIEMPO DE ENTREGA</h3>
  591. <!-- <div class="h-divider"></div> -->
  592. <p>La demora de entrega de productos en STOCK es de 10 días hábiles.</p>
  593. <div v-on:click="placeLocalOrder" class="btn btn-success btn-make-order">
  594.  
  595. FINALIZAR PEDIDO
  596.  
  597. </div>
  598. </div>
  599. </div>
  600. </div>
  601. <!-- /RIGHT Column/ -->
  602.  
  603.  
  604. </div>
  605. <!-- /CHECKOUT Body/ -->
  606.  
  607. </div>
  608. </div>
  609. <!-- /INDEX Checkout/ -->
  610.  
  611. <!-- VIEW Order -->
  612. <div v-if="sections.orderDetail">
  613. <div class="container">
  614. <div v-if="!orderDetail.pushed">
  615. <h2>Orden N° {{ orderDetail._id }}</h2>
  616. <hr>
  617. <table class="table table-hover table-condensed">
  618. <thead>
  619. <tr>
  620. <th style="width:50%">Producto</th>
  621. <th style="width:15%">Precio</th>
  622. <th style="width:8%">Cantidad</th>
  623. <th style="width:27%" class="text-center">Subtotal</th>
  624. </tr>
  625. </thead>
  626. <tbody>
  627. <tr v-for="product in orderProducts" >
  628. <td data-th="Product">
  629. <div class="row">
  630. <div class="col-sm-2 hidden-xs"><img class="img-responsive" v-bind:src="'file://' + product.images[0].local_src" alt="" /></div>
  631. <div class="col-sm-10">
  632. <h4 class="nomargin">{{ product.title }}</h4>
  633. <p v-html="product.short_description"></p>
  634. </div>
  635. </div>
  636. </td>
  637. <td data-th="Price" class="price">${{ product.price }}</td>
  638. <td data-th="Quantity">{{ product.quantity }}</td>
  639. <td data-th="Subtotal" class="text-center subtotal">${{ product.price * product.quantity }}</td>
  640. </tr>
  641. </tbody>
  642. </table>
  643. </div>
  644. <div v-else>
  645. <h2>Orden N° {{ orderDetail.order.id }}</h2>
  646. <hr>
  647. <table class="table table-hover table-condensed">
  648. <thead>
  649. <tr>
  650. <th style="width:50%">Producto</th>
  651. <th style="width:15%">Precio</th>
  652. <th style="width:8%">Cantidad</th>
  653. <th style="width:27%" class="text-center">Subtotal</th>
  654. </tr>
  655. </thead>
  656. <tbody>
  657. <tr v-for="product in orderProducts" >
  658. <td data-th="Product">
  659. <div class="row">
  660. <div class="col-sm-2 hidden-xs"><img class="img-responsive" v-bind:src="'file://' + product.images[0].local_src" alt="" /></div>
  661. <div class="col-sm-10">
  662. <h4 class="nomargin">{{ product.title }}</h4>
  663. <p v-html="product.short_description"></p>
  664. </div>
  665. </div>
  666. </td>
  667. <td data-th="Price" class="price">${{ product.price }}</td>
  668. <td data-th="Quantity">{{ product.quantity }}</td>
  669. <td data-th="Subtotal" class="text-center subtotal">${{ product.subtotal }}</td>
  670. </tr>
  671. </tbody>
  672. </table>
  673. </div>
  674. <div v-on:click="goToSection('orders')" class="btn btn-warning"><i class="glyphicon glyphicon-arrow-left"></i>Volver a compras</div>
  675. </div>
  676. </div>
  677. <!--/ VIEW Order /-->
  678.  
  679. <!-- INDEX Orders -->
  680. <div v-if="sections.orders" id="orders">
  681. <div class="container">
  682. <h1 class="text-center">PEDIDOS</h1>
  683. <hr class="hr-title">
  684. <div class="row">
  685. <div v-if="pendingOrders.length">
  686. <h2>Órdenes pendientes</h2>
  687. <table class="table table-hover table-condensed">
  688. <thead>
  689. <tr class="border-bottom">
  690. <th style="width:10%">N°</th>
  691. <th style="width:20%" class="text-center">Cliente</th>
  692. <th style="width:20%" class="text-center">Fecha</th>
  693. <th style="width:20%" class="text-center">Total</th>
  694. <th style="width:10%" class="text-center">Estado</th>
  695. <th style="width:20%"></th>
  696. </tr>
  697. </thead>
  698. <tbody>
  699. <tr v-for="(order, key, index) in pendingOrders">
  700. <td data-th="Order">{{ order._id }}</td>
  701. <td data-th="Customer" class="text-center">{{ order.customer.display_name }}</td>
  702. <td data-th="Date" class="text-center">{{ dateFormat(order.created, 'dd/mm/yyyy HH:MM:ss') }}</td>
  703. <td data-th="Total" class="text-center subtotal">${{ order.total }}</td>
  704. <td data-th="Status" class="text-center">No enviado</td>
  705. <td class="actions text-center" data-th="">
  706. <button v-on:click="viewOrder(order)" class="button-action-order" title="Ver detalle">
  707. <span class="glyphicon icon-Ver-01 coral size-2x" aria-hidden="true"></span>
  708. </button>
  709. <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'">
  710. <span :class="'glyphicon ' + (order.authorized ? 'glyphicon-ok' : 'glyphicon-remove') + ' coral size-2x'" aria-hidden="true"></span>
  711. </button>
  712. <button v-on:click="removeOrder(order._id, order._rev)" class="button-action-order" title="Eliminar orden">
  713. <span class="glyphicon icon-Eliminar-01 coral size-2x" aria-hidden="true"></span>
  714. </button>
  715. </td>
  716. </tr>
  717. </tbody>
  718. </table>
  719. </div>
  720. <div v-if="pushedOrders.length">
  721. <h2>Órdenes enviadas</h2>
  722. <table class="table table-hover table-condensed">
  723. <thead>
  724. <tr class="border-bottom">
  725. <th style="width:10%">N°</th>
  726. <th style="width:20%" class="text-center">Cliente</th>
  727. <th style="width:20%" class="text-center">Fecha</th>
  728. <th style="width:20%" class="text-center">Total</th>
  729. <th style="width:10%" class="text-center">Estado</th>
  730. <th style="width:20%"></th>
  731. </tr>
  732. </thead>
  733. <tbody>
  734. <tr v-for="order in pushedOrders">
  735. <td data-th="Order">{{ order.order.id }}</td>
  736. <td data-th="Customer" class="text-center">{{ order.order.customer.username }}</td>
  737. <td data-th="Date" class="text-center">{{ dateFormat(order.order.created_at, 'dd/mm/yyyy HH:MM:ss') }}</td>
  738. <td data-th="Total" class="text-center subtotal">${{ order.order.total }}</td>
  739. <td data-th="Status" class="text-center">Enviado</td>
  740. <td class="actions text-center" data-th="">
  741. <button v-on:click="viewOrder(order)" class="button-action-order" title="Ver detalle">
  742. <span class="icon-Ver-01 coral size-2x" aria-hidden="true"></span>
  743. </button>
  744. <button v-on:click="downloadCSV(order)" class="button-action-order" title="Descargar CSV">
  745. <span class="icon-Descargar-01 coral size-2x" aria-hidden="true"></span>
  746. </button>
  747. </td>
  748. </tr>
  749. </tbody>
  750. </table>
  751. </div>
  752. </div>
  753. <div v-on:click="goToSection('products')" class="btn btn-warning"><i class="glyphicon glyphicon-arrow-left"></i>Volver al catálogo</div>
  754. </div>
  755. </div>
  756. <!--/ INDEX Orders /-->
  757.  
  758. <!-- INDEX Cart -->
  759. <div v-if="sections.cart" id="cart">
  760. <div id="cart-content">
  761. <table class="table table-hover table-condensed">
  762. <thead>
  763. <tr>
  764. <th >PRODUCTO</th>
  765. <th style="width:10%"></th>
  766. <th style="width:30%"></th>
  767. <th style="width:10%">PRECIO</th>
  768. <th style="width:8%">CANTIDAD</th>
  769. <th style="width:22%" class="text-center">Total</th>
  770. <th style="width:10%"></th>
  771. </tr>
  772. </thead>
  773. <tbody>
  774. <tr v-for="(value, key, index) in sessionProductsData">
  775. <td >
  776. <div v-on:click="deleteCartProductById(key)" class="btn box-delete-product">
  777. <span v-bind="dataBindCartProducts(key, 'delete')" class="glyphicon glyphicon-remove-circle" aria-hidden="true"></span>
  778. </div>
  779. </td>
  780. <td data-th="Product">
  781. <div class="row">
  782. <div class="col-sm-2 hidden-xs">
  783. <img class="product-image" v-bind:src="'file://' + value.data.images[0].local_src" alt="" />
  784. </div>
  785. </div>
  786. </td>
  787. <td>
  788. <div class="col-sm-10">
  789. <span class="nomargin">{{value.data.title}}</span>
  790. </div>
  791. </td>
  792. <td data-th="Price" class="price">${{value.data.price}}</td>
  793. <td data-th="Quantity">
  794. <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)">
  795. </td>
  796. <td data-th="Subtotal" :class="cartSubtotal(key)" class="text-center subtotal">${{ value.data.price * value.data.qty }}</td>
  797. <td class="actions" data-th="Subtotal"></td>
  798. </tr>
  799. </tbody>
  800. <tfoot></tfoot>
  801. </table>
  802. </div>
  803. <div class="col-sm-5">
  804. <div class="col-padding">
  805. <h3>TOTAL</h3>
  806. <div class="order-box">
  807. <table class="table table-hover table-condensed">
  808. <thead>
  809. <tr>
  810. <th style="width:80%"></th>
  811. <th style="width:10%"></th>
  812. </tr>
  813. </thead>
  814. <tbody>
  815. <tr>
  816. <td data-th="Product">
  817. <div class="row">
  818. <div class="col-sm-10">
  819. <h4 class="nomargin">Subtotal</h4>
  820. </div>
  821. </div>
  822. </td>
  823. <td data-th="Product">
  824. <div class="row">
  825. <div class="col-sm-10">
  826. <h4 class="nomargin">${{totalCart}}</h4>
  827. </div>
  828. </div>
  829. </td>
  830. </tr>
  831. <tr>
  832. <td data-th="Product">
  833. <div class="row">
  834. <div class="col-sm-10">
  835. <h4 class="nomargin">Total</h4>
  836. </div>
  837. </div>
  838. </td>
  839. <td data-th="Product">
  840. <div class="row">
  841. <div class="col-sm-10">
  842. <h4 class="nomargin">${{totalCart}}</h4>
  843. </div>
  844. </div>
  845. </td>
  846. </tr>
  847. <tr>
  848. <td data-th="Product"></td>
  849. <td></td>
  850. </tr>
  851. </tbody>
  852. <tfoot></tfoot>
  853. </table>
  854. <div class="row">
  855. <div v-on:click="saveQuoteToSession" class="btn btn-success go-to-checkout">
  856. CHECK OUT
  857. </div>
  858. </div>
  859. <div class="row">
  860. <div v-on:click="goToSection('products')" class="btn btn-warning go-to-products"><i class="fa fa-angle-left"></i>SEGUIR COMPRANDO</div>
  861. </div>
  862. </div>
  863. </div>
  864. </div>
  865. </div>
  866. <!-- /INDEX Cart/ -->
  867.  
  868. <div v-if="sections.products" class="products">
  869. <!-- <navbar></navbar> -->
  870. <div id="products-content">
  871. <nav class="devsite-section-nav devsite-nav nocontent" style="left: auto; max-height: 643px; position: relative; top: 0px;">
  872. <div id="client-box">
  873. <span>CLIENTE </span>
  874. <p>Seleccione el cliente del que va a realizar el pedido </p>
  875. </div>
  876. <select class="customerSelect" v-model="sellerCustomerSelected">
  877. <option value="">Seleccione un cliente</option>
  878. <option v-for="customer in sellerCustomers" v-on:click="setCustomer(customer.ID)" v-bind:value="customer.ID">{{ customer.display_name }} | {{ customer.user_email }}</option>
  879. </select>
  880. <ul class="devsite-nav-list devsite-nav-expandable">
  881. <!-- <div class="container">
  882. <div class="dropdown">
  883. <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">Tutorials
  884. <span class="caret"></span></button>
  885. <ul class="dropdown-menu">
  886. <li><a tabindex="-1" href="#">HTML</a></li>
  887. <li><a tabindex="-1" href="#">CSS</a></li>
  888. <li class="dropdown-submenu">
  889. <a v-on:click="catDropdown('test')" class="test" tabindex="-1" href="#">New dropdown <span class="caret"></span></a>
  890. <ul class="dropdown-menu">
  891. <li><a tabindex="-1" href="#">2nd level dropdown</a></li>
  892. <li><a tabindex="-1" href="#">2nd level dropdown</a></li>
  893. <li class="dropdown-submenu">
  894. <a class="test" href="#">Another dropdown <span class="caret"></span></a>
  895. <ul class="dropdown-menu">
  896. <li><a href="#">3rd level dropdown</a></li>
  897. <li><a href="#">3rd level dropdown</a></li>
  898. </ul>
  899. </li>
  900. </ul>
  901. </li>
  902. </ul>
  903. </div>
  904. </div> -->
  905. <div id="search-input" class="container">
  906. <div class="row">
  907. <div class="col-md-2">
  908. <span>BUSCADOR </span>
  909. <p>Utilice el buscador para encontrar productos rápidamente </p>
  910. <div id="custom-search-input">
  911. <div class="input-group col-md-12">
  912. <input v-model="sku" type="text" class="form-control input-lg" placeholder="Ingrese su búsqueda" />
  913. <span class="input-group-btn">
  914. <button v-bind:disabled="!sku" v-on:click="filterSearch" class="btn btn-info btn-lg" type="button">
  915. <i class="glyphicon glyphicon-search"></i>
  916. </button>
  917. </span>
  918. </div>
  919. </div>
  920. </div>
  921. </div>
  922. </div>
  923. <!-- CATEGORIES -->
  924. <li class="devsite-nav-item devsite-nav-item-heading1">
  925. <span class="devsite-nav-title devsite-nav-title-no-path" track-type="leftNav" track-name="expandNavSectionNoLink" track-metadata-position="0">
  926. <div id="categories-box">
  927. <span >CATEGORÍAS</span>
  928. <p>Seleccione una categoría para comenzar a comprar </p>
  929. </div>
  930. </span>
  931. </li>
  932. <div class="dropdown pointerHand">
  933. <ul id="cats" v-for="(value, key, index) in categories" class="upperCase head-ul-first devsite-nav-item devsite-nav-item-heading">
  934. <li v-if="!isEmpty(value)">
  935. <div v-on:click="pagination(key, 'categories')" v-bind:id="key"
  936. class="devsite-nav-title devsite-nav-title-no-path dropdown-toggle"
  937. track-type="leftNav"
  938. track-name="expandNavSectionNoLink"
  939. track-metadata-position="0"
  940. data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"
  941. >{{ key }}<span class="caret"></span></div>
  942. <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" >
  943. <li v-for="(valueK, keyK, indexK) in value" v-if="!isEmpty(value)" class="head-ul-second devsite-nav-item devsite-nav-item-heading ">
  944. <span v-on:click="changeColor(keyK), pagination(keyK, 'categories')" v-bind:id="keyK"
  945. class="devsite-nav-title devsite-nav-title-no-path"
  946. track-type="leftNav"
  947. track-name="expandNavSectionNoLink"
  948. track-metadata-position="0"
  949. data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
  950. {{ keyK }}
  951. <span class="caret"></span>
  952. </span>
  953. <ul class="head-ul-second devsite-nav-item devsite-nav-item-heading lowerCase ">
  954. <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)">
  955. {{ keyM }}
  956. </li>
  957. </ul>
  958. </li>
  959. <li v-else>
  960. <span class="devsite-nav-title devsite-nav-title-no-path" track-type="leftNav" track-name="expandNavSectionNoLink" track-metadata-position="0">
  961. {{ keyK }}
  962. </span>
  963. </li>
  964. </ul>
  965. </li>
  966. <li v-else>
  967. <span class="devsite-nav-title devsite-nav-title-no-path" track-type="leftNav" track-name="expandNavSectionNoLink" track-metadata-position="0">
  968. {{ key }}
  969. </span>
  970. </li>
  971. </ul>
  972. </div>
  973. <li class="devsite-nav-item devsite-nav-item-heading1">
  974. <span class="devsite-nav-title devsite-nav-title-no-path" track-type="leftNav" track-name="expandNavSectionNoLink" track-metadata-position="0">
  975. <div id="filtros-box">
  976. <span >FILTROS</span>
  977. <p>Seleccione una opción para filtrar</p>
  978. </div>
  979. <select @change="filterByType($event)" class="customerSelect" >
  980. <option :value="null" disabled selected>Seleccione un filtro</option>
  981. <option
  982. v-for="filter in filtersList"
  983. :value="filter.param + ',' + filter.condition + ',' + filter.selector"
  984. >
  985. {{ filter.title }}
  986. </option>
  987. </select>
  988. </span>
  989. <br>
  990. <div id="filtros-box">
  991. <span >FILTRO POR PRECIO</span>
  992. </div>
  993. <div>
  994. <br><br><br>
  995. <vue-slider @callback="cb" ref="slider4" v-bind="priceRange" v-model="priceRange.value"></vue-slider>
  996. </div>
  997. <!-- <div class="form-group">
  998. <label for="sel1">Select list:</label>
  999. <select class="form-control" id="sel1">
  1000. <option>1</option>
  1001. <option>2</option>
  1002. <option>3</option>
  1003. <option>4</option>
  1004. </select>
  1005. </div> -->
  1006. </li>
  1007. </ul>
  1008. </nav>
  1009. <!-- <div v-on:click="setCurrentStep('login')" class="btn btn-success">
  1010. section
  1011. </div> -->
  1012. <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>
  1013. <paginate id="products" name="itemsData" :per="8" :list="items" class="row list-group">
  1014. <li v-for="(item, key) in paginated('itemsData')" class="item col-xs-3 col-lg3">
  1015. <div class="thumbnail">
  1016. <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="" />
  1017. <div class="caption">
  1018. <div class="">
  1019. <h5 style="float:left" class="group inner list-group-item-heading">{{ item.title }}</h5>
  1020. <span style="float:right" >${{ item.price }}</span>
  1021. </div>
  1022. <p v-html="'<br>' + item.short_description + 'Stock: ' + item.stock_quantity" class="group inner list-group-item-text">
  1023. <br>gggg
  1024. </p>
  1025. <div class="row">
  1026. <!-- <div class="col-xs-12 col-md-6">
  1027. <p class="lead">{{ item.price }}</p>
  1028. </div> -->
  1029. <!-- <div class="col-xs-12 col-md-6">
  1030. <p class="lead">{{ item.categories[0] }}</p>
  1031. </div> -->
  1032. <div class="col-xs-12 col-md-12">
  1033. <button v-on:click="decQty(item)" class="glyphicon glyphicon-minus btn btn-xs btn-default"></button>
  1034. <span>{{ itemQty(item) }}</span>
  1035. <button v-on:click="addQty(item)" class="glyphicon glyphicon-plus btn btn-xs btn-default"></button>
  1036. </div>
  1037. <div class="col-xs-12 col-md-12">
  1038. <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>
  1039. </div>
  1040. </div>
  1041. </div>
  1042. </div>
  1043. <div v-bind:id="'modal_' + item.id" class="modal fade" role="dialog">
  1044. <div class="thumbnail">
  1045. <img data-toggle="modal" :data-target="'#modal_' + item.id" class="group list-group-image" v-bind:src="'file://' + item.images[0].local_src" alt="" />
  1046. <div class="caption">
  1047. <div class="">
  1048. <h5 style="float:left" class="group inner list-group-item-heading">{{ item.title }}</h5>
  1049. <span style="float:right" >${{ item.price }}</span>
  1050. </div>
  1051.  
  1052. <p v-html="'<br>' + item.short_description" class="group inner list-group-item-text"></p>
  1053. <div class="row">
  1054. <!-- <div class="col-xs-12 col-md-6">
  1055. <p class="lead">{{ item.price }}</p>
  1056. </div> -->
  1057. <!-- <div class="col-xs-12 col-md-6">
  1058. <p class="lead">{{ item.categories[0] }}</p>
  1059. </div> -->
  1060. <div class="col-xs-12 col-md-12">
  1061. <button v-on:click="decQty(item)" class="glyphicon glyphicon-minus btn btn-xs btn-default"></button>
  1062. <span>{{ itemQty(item) }}</span>
  1063. <button v-on:click="addQty(item)" class="glyphicon glyphicon-plus btn btn-xs btn-default"></button>
  1064. </div>
  1065. <div class="col-xs-12 col-md-12">
  1066. <div v-on:click.prevent="getDataBind($event, item.id)" v-bind="dataBind(item.id, item)" class="btn btn-success">Añadir al carrito</div>
  1067. </div>
  1068. </div>
  1069. <div class="col-xs-12 col-md-6">
  1070. <p class="lead">{{ item.categories[0] }}</p>
  1071. </div>
  1072. </div>
  1073. </div>
  1074. </div>
  1075. <!-- <div class="modal-dialog">
  1076. <div class="modal-content">
  1077. <div class="modal-header">
  1078. <button type="button" class="close" data-dismiss="modal">&times;</button>
  1079. <h4 class="modal-title">Modal Header</h4>
  1080. </div>
  1081. <div class="modal-body">
  1082. <p>Some text in the modal.</p>
  1083. </div>
  1084. <div class="modal-footer">
  1085. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  1086. </div>
  1087. </div>
  1088. </div> -->
  1089. </li>
  1090. </paginate>
  1091. <div id="pages">
  1092. <paginate-links class="pagination" for="itemsData" :limit="10" :show-step-links="true" ></paginate-links>
  1093. </div>
  1094. </div>
  1095. </div>
  1096. <!-- <div v-if="!isUserLogged" id="login-container"> -->
  1097. <div v-show="!isUserLoggedAttr && !sections.setup" id="login-container">
  1098. <div class="col-lg-4 col-md-3 col-sm-2"></div>
  1099. <div class="col-lg-4 col-md-6 col-sm-8">
  1100. <div class="logo">
  1101. <img src="~@/assets/logotarget.png" alt="Logo" >
  1102. </div>
  1103. <form v-on:submit.prevent="submitForm">
  1104. <div class="row loginbox">
  1105. <div class="col-lg-12">
  1106. <span class="singtext" >Ingresar </span>
  1107. </div>
  1108. <div class="col-lg-12 col-md-12 col-sm-12">
  1109. <input v-model="username" class="form-control" type="email" placeholder="Ingresá tu email" >
  1110. </div>
  1111. <div class="col-lg-12 col-md-12 col-sm-12">
  1112. <input v-model="password" class="form-control" type="password" placeholder="Ingresá tu contraseña" >
  1113. </div>
  1114. <div class="col-lg-12 col-md-12 col-sm-12">
  1115. <button v-bind:disabled="!isFormValid()" class="btn submitButton">Enviar</button>
  1116. <div v-show="loginError" class="col-lg-12">
  1117. <p class="text-center singtext14Red" >Password y / o usuario incorrectos. </p>
  1118. </div>
  1119. </div>
  1120. <div v-show="showUsersSessions" class="">
  1121. <div class="col-lg-12">
  1122. <p class="text-center singtext14Black" >Seleccione un usuario para ingresar </p>
  1123. </div>
  1124. <ul v-for="(value, key, index) in usersSessionsList.docs">
  1125. <li> <a v-on:click.prevent="usePreviousUser(value.email)" href="#">{{ value.nicename }} - {{ value.email }} </a> </li>
  1126. </ul>
  1127. </div>
  1128. </div>
  1129. </form>
  1130. </div>
  1131. </div>
  1132. <div v-if="sections.setup" id="app-setup">
  1133. <h1 class="text-center">¡Bienvenido a Target Moda!</h1>
  1134. <h2 class="text-center">A continuación iniciará la instalación de la Aplicación</h2>
  1135. <button v-on:click.once="initSetup" type="button" class="btn btn-lg btn-primary center-block">Comenzar</button>
  1136. <p class="text-center" style="margin-top:32px;" >{{ setupInit }}</p>
  1137. <p class="text-center">{{ productsInit }}</p>
  1138. <p class="text-center">{{ productsComplete }}</p>
  1139. <p class="text-center">{{ categoriesInit }}</p>
  1140. <p class="text-center">{{ categoriesComplete }}</p>
  1141. <p class="text-center">{{ customersInit }}</p>
  1142. <p class="text-center">{{ customersComplete }}</p>
  1143. <p class="text-center">{{ directoriesInit }}</p>
  1144. <p class="text-center">{{ directoriesComplete }}</p>
  1145. <p class="text-center">{{ imagesInit }}</p>
  1146. <p class="text-center">{{ imagesComplete }}</p>
  1147. <p class="text-center">{{ setupComplete }}</p>
  1148. <p></p>
  1149. <button v-show="appInstalled" v-on:click="goToSection('products')" type="button" class="btn btn-lg btn-primary center-block">Entrar</button>
  1150. </div>
  1151. <div v-if="logged" id="app-content">
  1152. <table class="table table-striped">
  1153. <thead>
  1154. <tr>
  1155. <th>Id</th>
  1156. <th>Last Name</th>
  1157. <th>Email</th>
  1158. <th></th>
  1159. </tr>
  1160. </thead>
  1161. <tbody>
  1162. <tr v-for="customer in customerst">
  1163. <td> {{ customer.id }} </td>
  1164. <td> {{ customer.username }} </td>
  1165. <td> {{ customer.email }} </td>
  1166. </tr>
  1167. </tbody>
  1168. </table>
  1169. </div>
  1170. <div v-show="loading" class="loading">Loading&#8230;</div>
  1171. <!-- Trigger the modal with a button -->
  1172. <!-- <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button> -->
  1173.  
  1174. <!-- Modal -->
  1175. <!-- <div id="myModal" class="modal fade" role="dialog">
  1176. <div class="modal-dialog">
  1177. <div class="modal-content">
  1178. <div class="modal-header">
  1179. <button type="button" class="close" data-dismiss="modal">&times;</button>
  1180. <h4 class="modal-title">Modal Header</h4>
  1181. </div>
  1182. <div class="modal-body">
  1183. <p>Some text in the modal.</p>
  1184. </div>
  1185. <div class="modal-footer">
  1186. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  1187. </div>
  1188. </div>
  1189. </div>
  1190. </div> -->
  1191. </div>
  1192. </template>
  1193.  
  1194. <script>
  1195. // import WooCommerceAPI from 'woocommerce-api'
  1196. // import Vue from 'vue'
  1197. import Navbar from './Elements/Navbar'
  1198. import Filters from './Elements/Filters'
  1199. import Syncprocess from './Syncprocess'
  1200. import store from '../store'
  1201. import vueSlider from 'vue-slider-component'
  1202. var SHA256 = require('crypto-js/sha256.js')
  1203. const remote = require('electron').remote
  1204.  
  1205. export default {
  1206. name: 'customers',
  1207. components: { Navbar, Filters, vueSlider },
  1208. data () {
  1209. return {
  1210. sections: {
  1211. login: false,
  1212. setup: false,
  1213. products: false,
  1214. orders: false,
  1215. orderDetail: false,
  1216. cart: false,
  1217. checkout: false,
  1218. thanks: false,
  1219. navbar: false
  1220. },
  1221. usersSessionsList: {},
  1222. showUsersSessions: false,
  1223. setupInit: '',
  1224. productsInit: '',
  1225. productsComplete: '',
  1226. categoriesInit: '',
  1227. categoriesComplete: '',
  1228. customersInit: '',
  1229. customersComplete: '',
  1230. directoriesInit: '',
  1231. directoriesComplete: '',
  1232. imagesInit: '',
  1233. imagesComplete: '',
  1234. setupComplete: '',
  1235. appInstalled: false,
  1236. isUserLoggedAttr: false,
  1237. customerst: [],
  1238. auth: [],
  1239. username: '',
  1240. password: '',
  1241. loginError: false,
  1242. sku: '',
  1243. logged: false,
  1244. productsSync: '',
  1245. badge: 0,
  1246. // cartObject: {},
  1247. // PRODUCTS & FILTERS
  1248. categories: [],
  1249. collapse: true,
  1250. categoriesDiscounts: [],
  1251. items: [],
  1252. pendingOrders: [],
  1253. pushedOrders: [],
  1254. orderDetail: {},
  1255. orderProducts: [],
  1256. products: {},
  1257. // 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'],
  1258. paginate: ['itemsData'],
  1259. priceRange: {
  1260. value: ['0', '100'],
  1261. width: '100%',
  1262. height: 4,
  1263. dotSize: 14,
  1264. min: 1,
  1265. max: 100,
  1266. interval: 3,
  1267. disabled: false,
  1268. show: true,
  1269. tooltip: 'always',
  1270. piecewise: true,
  1271. data: [
  1272. '0',
  1273. '100',
  1274. '300',
  1275. '500',
  1276. '800',
  1277. '1000',
  1278. '5000',
  1279. '8000',
  1280. '10000'
  1281. ]
  1282. },
  1283. total: 10,
  1284. // END PRODUCTS & FILTERS
  1285. // sessionProducts: this.$session.get('target-cart'),
  1286. sessionProductsData: {},
  1287. quoteProducts: this.$session.get('target-quote'),
  1288. sessionUserData: this.$session.get('user-session'),
  1289. sellerCustomers: {},
  1290. sellerCustomerSelected: '',
  1291. totalCart: 0,
  1292. section: this.$session.get('target-current-step'),
  1293. error: false,
  1294. dateFormat: require('dateformat'),
  1295. loading: false,
  1296. productsAlert: false,
  1297. filtersList: [
  1298. {
  1299. 'param': 'asc',
  1300. 'condition': '$eq',
  1301. 'selector': 'sku',
  1302. 'title': 'Predeterminado'
  1303. },
  1304. {
  1305. 'param': 'desc',
  1306. 'selector': 'sku',
  1307. 'condition': '$gt',
  1308. 'title': 'Novedades'
  1309. },
  1310. {
  1311. 'param': 'asc',
  1312. 'selector': 'price',
  1313. 'condition': '$gt',
  1314. 'title': 'Menor Precio'
  1315. },
  1316. {
  1317. 'param': 'desc',
  1318. 'selector': 'price',
  1319. 'condition': '$gt',
  1320. 'title': 'Mayor Precio'
  1321. },
  1322. {
  1323. 'param': '50',
  1324. 'selector': 'stock_quantity',
  1325. 'condition': '$gt',
  1326. 'title': 'Más de 50 unidades'
  1327. },
  1328. {
  1329. 'param': '100',
  1330. 'selector': 'stock_quantity',
  1331. 'condition': '$gt',
  1332. 'title': 'Más de 100 unidades'
  1333. },
  1334. {
  1335. 'param': '200',
  1336. 'selector': 'stock_quantity',
  1337. 'condition': '$gt',
  1338. 'title': 'Más de 200 unidades'
  1339. },
  1340. {
  1341. 'param': '300',
  1342. 'selector': 'stock_quantity',
  1343. 'condition': '$gt',
  1344. 'title': 'Más de 300 unidades'
  1345. },
  1346. {
  1347. 'param': '400',
  1348. 'selector': 'stock_quantity',
  1349. 'condition': '$gt',
  1350. 'title': 'Más de 400 unidades'
  1351. },
  1352. {
  1353. 'param': '500',
  1354. 'selector': 'stock_quantity',
  1355. 'condition': '$gt',
  1356. 'title': 'Más de 500 unidades'
  1357. }
  1358. ]
  1359. }
  1360. },
  1361. methods: {
  1362. downloadCSV: function (order) {
  1363. var fileName = 'order_' + order._id + '.csv'
  1364. Syncprocess.createCSV(order.order.line_items).then((csv) => {
  1365. Syncprocess.downloadCSV(fileName, csv).then((result) => {
  1366. console.log(result)
  1367. $('#success-downloaded-csv').fadeIn().delay(1000).fadeOut(2000)
  1368. }).catch((err) => {
  1369. console.log(err)
  1370. $('#error-downloaded-csv').fadeIn().delay(1000).fadeOut(2000)
  1371. })
  1372. }).catch((err) => {
  1373. console.log(err)
  1374. $('#error-downloaded-csv').fadeIn().delay(1000).fadeOut(2000)
  1375. })
  1376. },
  1377. showDiscTable: function () {
  1378. // var collapse = this.collapse
  1379. // console.log(collapse)
  1380. // var tableShow = $('.show_table_desc').val()
  1381. // $('.table_cat_' + tableShow).show()
  1382. $('.show_table_desc').each(function (i, obj) {
  1383. // console.log(obj.value)
  1384. $('.table_cat_' + obj.value).show()
  1385. })
  1386. // $('#order-box div').removeClass('collpase')
  1387. // console.log(event)
  1388. // console.log(parentLevel)
  1389. },
  1390. filterByType: function (event) {
  1391. // selector, condition, param
  1392. let self = this
  1393. let optionValue = event.target.value
  1394. // let sort = {}
  1395. let skuSort = true
  1396. let dataQuery = optionValue.split(',')
  1397. var param = dataQuery[0].trim()
  1398. var condition = dataQuery[1].trim()
  1399. var selector = dataQuery[2].trim()
  1400. var sortParam = ''
  1401. if (selector === 'stock_quantity') {
  1402. param = parseInt(param)
  1403. skuSort = false
  1404. } else if (selector === 'price' || selector === 'sku') {
  1405. skuSort = true
  1406. param = '"' + param + '"'
  1407. sortParam = JSON.parse('{"' + selector + '": ' + param + '}')
  1408. console.log('MOSTRAME SORT', sortParam)
  1409. }
  1410. // sortParam = JSON.parse('{"sku": "desc" }')
  1411. // sortParam = JSON.parse('{"price": "' + param + '"}')
  1412. // sort.push(sortParam)
  1413. var query = JSON.parse('{"' + selector + '":{"' + condition + '":' + param + '}}')
  1414. // console.log('EVENT TARGET', param, condition, selector)
  1415. // console.log('MOSTRAME EL QUERY', query)
  1416. // console.log('QUERY FILTERS', query)
  1417. self.loading = true
  1418. if (skuSort) {
  1419. store.filtersByPriceAndSku(sortParam).then(function (result) {
  1420. if (self.isEmpty(result.docs)) {
  1421. self.productsAlert = true
  1422. self.loading = false
  1423. } else {
  1424. self.productsAlert = false
  1425. self.loading = false
  1426. $('#pages').show()
  1427. }
  1428. self.items = result.docs
  1429. self.products = result.docs
  1430. })
  1431. } else {
  1432. store.filtersByType(query).then(function (result) {
  1433. if (self.isEmpty(result.docs)) {
  1434. self.productsAlert = true
  1435. self.loading = false
  1436. } else {
  1437. self.productsAlert = false
  1438. self.loading = false
  1439. $('#pages').show()
  1440. }
  1441. self.items = result.docs
  1442. self.products = result.docs
  1443. })
  1444. }
  1445. },
  1446. itemQtyCart: function (event, id) {
  1447. var items = this.$session.get('target-cart')
  1448. items[id].data.qty = event.target.valueAsNumber
  1449. if (event.target.valueAsNumber < items[id].data.step) {
  1450. items[id].data.qty = items[id].data.step
  1451. } else if (event.target.valueAsNumber % items[id].data.step !== 0) {
  1452. items[id].data.qty = event.target.valueAsNumber - (event.target.valueAsNumber % items[id].data.step)
  1453. }
  1454. this.$session.set('target-cart', items)
  1455. this.sessionProductsData = this.$session.get('target-cart')
  1456. this.jQuerySetBadge(this.sessionProductsData)
  1457. this.getCartSessionItems()
  1458. this.$forceUpdate()
  1459. },
  1460. checkCategories: function (id) {
  1461. console.log(id)
  1462. if ($('#' + id + ':checkbox:checked').length > 0) {
  1463. console.log('está checkeado')
  1464. $('.' + id + '_child').prop('checked', true)
  1465. } else {
  1466. $('.' + id + '_child').prop('checked', false)
  1467. }
  1468. // console.log('parent!!!', event.target)
  1469. // console.log('event clikc!', event.target.id)
  1470. // jQuery(this).closest('tr').find('[type=checkbox]').prop('checked', true);
  1471. },
  1472. setProductDiscount: function (id) {
  1473. let inputValue = $('#discount_' + id).val()
  1474. this.sessionProductsData[id].data.discount_product = inputValue
  1475. 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
  1476.  
  1477. var sessionProducts = this.$session.get('target-quote')
  1478. var total = 0
  1479. var count = 0
  1480.  
  1481. // Apply discounts to products in this.sessionProductsData
  1482. for (var index in this.sessionProductsData) {
  1483. if (this.sessionProductsData[index].data.discount_product > 0) {
  1484. sessionProducts.order.line_items[count].total = this.sessionProductsData[index].data.subtotal
  1485. total += this.sessionProductsData[index].data.subtotal
  1486. } else if (this.sessionProductsData[index].data.discount_category > 0) {
  1487. sessionProducts.order.line_items[count].total = this.sessionProductsData[index].data.subtotal
  1488. 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
  1489. } else {
  1490. this.sessionProductsData[index].data.subtotal = 0
  1491. total += this.sessionProductsData[index].data.price * this.sessionProductsData[index].data.qty
  1492. }
  1493. count++
  1494. }
  1495.  
  1496. sessionProducts.total = total
  1497. this.totalCart = total
  1498. this.$session.set('target-quote', sessionProducts)
  1499.  
  1500. this.$forceUpdate()
  1501. },
  1502. setCategoryDiscount: function (input) {
  1503. console.log('target-quote', this.$session.get('target-quote'))
  1504. // Recursively apply discounts on DOM
  1505. let inputAttribute = input.replace(/[\s\W]/g, '')
  1506. let inputValue = $('#discount_' + inputAttribute).val()
  1507. $('input[class^=discount-input-' + inputAttribute + ']').val(inputValue)
  1508.  
  1509. // Save Categories Discounts in this.categoriesDiscounts
  1510. var scope = input.split('_')
  1511. var exist = false
  1512.  
  1513. this.categoriesDiscounts.map((discount, i) => {
  1514. var matches = []
  1515. for (var j = scope.length - 1; j >= 0; j--) {
  1516. matches.push(false)
  1517. }
  1518. for (var k = scope.length - 1; k >= 0; k--) {
  1519. if (discount.scope[k] === scope[k]) {
  1520. matches[k] = true
  1521. }
  1522. }
  1523. if (matches.indexOf(false) === -1) {
  1524. this.categoriesDiscounts[i] = {scope: scope, discount: inputValue}
  1525. exist = true
  1526. }
  1527. })
  1528.  
  1529. if (!exist || this.categoriesDiscounts.length === 0) {
  1530. this.categoriesDiscounts.push({scope: scope, discount: inputValue})
  1531. }
  1532.  
  1533. var sessionProducts = this.$session.get('target-quote')
  1534. var total = 0
  1535. var count = 0
  1536.  
  1537. // Apply discounts to products in this.sessionProductsData
  1538. for (var index in this.sessionProductsData) {
  1539. var categories = this.sessionProductsData[index].data.categories
  1540. var matches = []
  1541. this.categoriesDiscounts.map((discount, j) => {
  1542. categories.map((category, k) => {
  1543. if (discount.scope[discount.scope.length - 1] === category) {
  1544. matches.push(discount)
  1545. }
  1546. })
  1547. })
  1548. var specificity = 0
  1549. matches.map((match) => {
  1550. if (match.scope.length > specificity) {
  1551. this.sessionProductsData[index].data.discount_category = match.discount
  1552. specificity = match.scope.length
  1553. }
  1554. })
  1555. if (this.sessionProductsData[index].data.discount_product > 0) {
  1556. 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
  1557. 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
  1558. } else if (this.sessionProductsData[index].data.discount_category > 0) {
  1559. 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
  1560. sessionProducts.order.line_items[count].total = this.sessionProductsData[index].data.subtotal
  1561. total += this.sessionProductsData[index].data.subtotal
  1562. } else {
  1563. this.sessionProductsData[index].data.subtotal = 0
  1564. total += this.sessionProductsData[index].data.price * this.sessionProductsData[index].data.qty
  1565. }
  1566. count++
  1567. }
  1568.  
  1569. sessionProducts.total = total
  1570. this.totalCart = total
  1571. this.$session.set('target-quote', sessionProducts)
  1572.  
  1573. this.$forceUpdate()
  1574. },
  1575. changeColor: function (event) {
  1576. console.log('cateeeeee', this.categories)
  1577. let targetId = event.replace(/\s/g, '')
  1578. console.log('eventooo', targetId)
  1579. // let targetId = event.currentTarget.id
  1580. $('#products-content ul').css('color', '#000 !important')
  1581. $('.dropdown li').css('color', '#000 !important')
  1582. $('.dropdown div').css('color', '#000 !important')
  1583. $('#' + targetId).css('color', '#f2696c')
  1584. console.log('CHANGECOLOR', targetId)
  1585. return 'esteId'
  1586. },
  1587. setUsersSessions: function () {
  1588. let self = this
  1589. store.findByTypeInSession('user_session').then(function (usersInDB) {
  1590. self.usersSessionsList = usersInDB
  1591. console.log('usersInDB ->>>>>->>->>', usersInDB)
  1592. if (usersInDB.docs.length > 0) {
  1593. self.showUsersSessions = true
  1594. }
  1595. console.log('usersInDB LENGH ->>>>>->>->>', usersInDB.docs.length)
  1596. })
  1597. },
  1598. usePreviousUser: function (email) {
  1599. console.log('EMAILLLLL', email)
  1600. this.username = email
  1601. },
  1602. initSetup: function (event) {
  1603. event.disabled = true
  1604. this.setupInit = 'Ha comenzado la instalación ...'
  1605. this.productsInit = 'Sincronizando productos'
  1606. var p1 = new Promise((resolve, reject) => {
  1607. Syncprocess.countSyncWC('products').then((result) => {
  1608. var numProducts = result
  1609. Syncprocess.initProductsWC(numProducts).then((result) => {
  1610. this.productsComplete = 'Productos sincronizados'
  1611. this.directoriesInit = 'Creando directorios de imágenes'
  1612. Syncprocess.initProductImages().then((result) => {
  1613. this.directoriesComplete = 'Directorios creados'
  1614. this.imagesInit = 'Sincronizando imágenes'
  1615. Syncprocess.downloadProductImages().then((result) => {
  1616. this.imagesComplete = 'Imágenes sincronizadas'
  1617. this.appInstalled = true
  1618. resolve('OK')
  1619. }).catch((err) => {
  1620. console.log('ERROR get Images', err)
  1621. })
  1622. }).catch((err) => {
  1623. console.log('ERROR create Images Directories', err)
  1624. })
  1625. }).catch((err) => {
  1626. console.log('ERROR get Products', err)
  1627. })
  1628. }).catch((err) => {
  1629. console.log('ERROR count Products', err)
  1630. })
  1631. })
  1632. var p2 = new Promise((resolve, reject) => {
  1633. this.categoriesInit = 'Sincronizando categorías'
  1634. Syncprocess.initCategoriesWC().then((result) => {
  1635. this.categoriesComplete = 'Categorías sincronizadas'
  1636. resolve('OK')
  1637. }).catch((err) => {
  1638. console.log('ERROR get Categories:', err)
  1639. })
  1640. })
  1641. var p3 = new Promise((resolve, reject) => {
  1642. this.customersInit = 'Sincronizando clientes'
  1643. var sellerId = this.$session.get('user-session')._id
  1644. Syncprocess.initCustomersWC(sellerId).then((result) => {
  1645. this.sellerCustomers = result.docs
  1646. this.customersComplete = 'Clientes sincronizados'
  1647. resolve('OK')
  1648. }).catch((err) => {
  1649. console.log('ERROR get Customers:', err)
  1650. })
  1651. })
  1652. Promise.all([p1, p2, p3]).then(data => {
  1653. console.log('Install COMPLETE')
  1654. Syncprocess.setupComplete().then((result) => {
  1655. this.setupComplete = 'Instalación finalizada con éxito'
  1656. this.appInstalled = true
  1657. this.isUserLoggedAttr = true
  1658. })
  1659. }).catch((err) => {
  1660. console.log('ERROR install complete:', err)
  1661. })
  1662. },
  1663. handler: function (arg1) {
  1664. this.goToSection(arg1)
  1665. this.setCartItems()
  1666. this.getCartSessionItems()
  1667. },
  1668. logout: function () {
  1669. var window = remote.getCurrentWindow()
  1670. let user = this.$session.get('user-session')
  1671. let userId = user._id
  1672. store.logout(userId)
  1673. store.logout('customers_seller_' + userId)
  1674. console.log(this.$session.get('user-session'))
  1675. this.$session.destroy('user-session')
  1676. console.log(this.$session.get('user-session'))
  1677. window.close()
  1678. // customers_seller_
  1679. // id
  1680. },
  1681. badgeItems: function (qty) {
  1682. this.badge = qty
  1683. },
  1684. getSellerCustomers: function () {
  1685. var self = this
  1686. store.findByType('seller_customer').then((result) => {
  1687. console.log('seller customerssss', result)
  1688. self.sellerCustomers = result.docs
  1689. })
  1690. },
  1691. setCustomer: function (customerId) {
  1692. this.sellerCustomerSelected = customerId
  1693. },
  1694. setCartItems: function () {
  1695. console.log('entro set cartitmes!')
  1696. this.sessionProductsData = this.$session.get('target-cart')
  1697. },
  1698. setCartQtyItems: function (cartSession) {
  1699. let qty = 0
  1700. console.log(typeof cartSession)
  1701. Object.keys(cartSession).map(function (objectKey, index) {
  1702. var value = cartSession[objectKey]
  1703. console.log('nav bar QTY---->', value)
  1704. qty += parseInt(value.data.qty)
  1705. console.log('nav bar QTY---->', value.data.qty)
  1706. })
  1707. console.log('var QTY navbar!!!!', qty)
  1708. this.badgeItems(qty)
  1709. },
  1710. itemQty: function (item) {
  1711. if (typeof item.qty === 'undefined') {
  1712. return item.step
  1713. }
  1714. return item.qty
  1715. },
  1716. decQty: function (item) {
  1717. item.qty -= item.step
  1718. if (item.qty <= 0) {
  1719. item.qty = item.step
  1720. }
  1721. this.$forceUpdate()
  1722. },
  1723. addQty: function (item) {
  1724. if (typeof item.qty === 'undefined') {
  1725. item.qty = item.step
  1726. }
  1727. item.qty += item.step
  1728. this.$forceUpdate()
  1729. },
  1730. emptyQuoute: function () {
  1731. this.$session.set('target-cart', {})
  1732. this.$session.set('target-quote', {})
  1733. },
  1734. goToSection: function (to) {
  1735. for (var section in this.sections) {
  1736. this.sections[section] = false
  1737. if (section === to) {
  1738. this.sections[section] = true
  1739. }
  1740. }
  1741. if (this.appInstalled && this.isUserLoggedAttr) {
  1742. this.sections.navbar = true
  1743. }
  1744. },
  1745. setCurrentStep: function (section, to = null) {
  1746. console.log('section', section)
  1747. console.log('TO', to)
  1748. $(section).hide()
  1749. if (to !== null) {
  1750. $(to).show()
  1751. if (this.appInstalled) {
  1752. $('#navbar').show()
  1753. }
  1754. }
  1755. },
  1756. // customer sellers
  1757. getCustomersBySellerId: function () {
  1758. let self = this
  1759. let userSession = this.$session.get('user-session')
  1760. // if (typeof userSession === 'undefined') {
  1761. // this.$session.set('user-session', {})
  1762. // console.log('user session no definida la crea', userSession)
  1763. // }
  1764. // let sellerId = userSession._id
  1765. let sellerId = userSession._id
  1766. store.getDataSessionById('customers_seller_' + sellerId).then(function (customerSellerRes) {
  1767. console.log('STOREEEE data sesuib get', customerSellerRes)
  1768. console.log('66666666lo tengo en sesion customerSeller ', customerSellerRes.data)
  1769. self.sellerCustomers = customerSellerRes.data
  1770. })
  1771. },
  1772. setCustomerSeller: function (id) {
  1773. let self = this
  1774. let addCustomerSeller = {}
  1775. addCustomerSeller = self.sessionUserData
  1776. console.log('addCustomerSellerDDDDDDDD', addCustomerSeller)
  1777. let clientToSeller = addCustomerSeller
  1778. clientToSeller['customer_seller_id'] = id
  1779. self.$session.set('user-session', addCustomerSeller)
  1780. console.log('ADD CUSTOMER', this.sessionUserData)
  1781. // store.createSession(userSession)
  1782. },
  1783. dataBind: function (id, item) {
  1784. // item.qty = 0
  1785. let itemString = JSON.stringify(item)
  1786. // console.log(id)
  1787. return {
  1788. [`data-product-${id}`]: itemString
  1789. }
  1790. },
  1791. jQuerySetBadge: function (cartSession) {
  1792. let qty = 0
  1793. Object.keys(cartSession).map(function (objectKey, index) {
  1794. var value = cartSession[objectKey]
  1795. qty += value.data.qty
  1796. })
  1797. if (qty === 0) {
  1798. this.totalCart = 0
  1799. }
  1800. $(document).ready(function () {
  1801. $('.badge').text(qty)
  1802. })
  1803. },
  1804. getDataBind: function (event, id) {
  1805. // let self = this
  1806. $('#success-add-to-cart').fadeIn(500)
  1807. let element = event.currentTarget
  1808. let data = element.getAttribute('data-product-' + id)
  1809. let productById = this.$session.get('target-cart')
  1810. data = JSON.parse(data)
  1811. console.log('data producto', data)
  1812. console.log('data productById', productById)
  1813. console.log('data EL ID', id)
  1814. if (typeof productById[id] !== 'undefined' || productById.length > 0) {
  1815. // let insertData = []
  1816. console.log('ProductId', productById)
  1817. console.log('Id', id)
  1818. if (typeof data.qty === 'undefined') {
  1819. console.log('cantidad no definida', productById[id].data.qty)
  1820. data.qty = data.step
  1821. }
  1822. data.qty += productById[id].data.qty
  1823. productById[id] = {data}
  1824. this.$session.set('target-cart', productById)
  1825. this.jQuerySetBadge(this.$session.get('target-cart'))
  1826. } else {
  1827. if (typeof data.qty === 'undefined') {
  1828. data.qty = data.step
  1829. }
  1830. productById[id] = {data}
  1831. console.log('entra al else EL ID', id)
  1832. this.$session.set('target-cart', productById)
  1833. this.jQuerySetBadge(this.$session.get('target-cart'))
  1834. }
  1835. console.log('CART OBJECT', productById)
  1836. var cart = $('#cart-badge')
  1837. setTimeout(function () {
  1838. cart.addClass('shake-cart')
  1839. }, 50)
  1840. cart.removeClass('shake-cart')
  1841. $('#success-add-to-cart').fadeIn().delay(1000).fadeOut(2000)
  1842. },
  1843. cb: function (val) {
  1844. setTimeout(() => {
  1845. this.pagination(val, 'price')
  1846. }, 2000)
  1847. console.log(val)
  1848. },
  1849. incrementTotal: function () {
  1850. this.total++
  1851. },
  1852. // end products
  1853. // login
  1854. isFormValid: function () {
  1855. return this.username !== '' && this.password !== ''
  1856. },
  1857. decodeHtml: function (html) {
  1858. var txt = unescape(html)
  1859. return txt
  1860. },
  1861. submitForm: function () {
  1862. if (!this.isFormValid()) {
  1863. return false
  1864. } else {
  1865. this.authUser()
  1866. // this.logged = true
  1867. }
  1868. },
  1869. // end login
  1870. // images
  1871. initImages: function () {
  1872. Syncprocess.initProductImages().then((result) => {
  1873. console.log('Init Images Promise:', result)
  1874. }).catch(function (err) {
  1875. console.log(err)
  1876. })
  1877. },
  1878. getImages: function () {
  1879. Syncprocess.getProductImages().then((result) => {
  1880. console.log('Get Images Promise:', result)
  1881. }).catch(function (err) {
  1882. console.log(err)
  1883. })
  1884. },
  1885. downloadImages: function () {
  1886. Syncprocess.downloadProductImages().then((result) => {
  1887. console.log('Download Images Promise:', result)
  1888. }).catch(function (err) {
  1889. console.log(err)
  1890. })
  1891. },
  1892. // end images
  1893. getProducts: function () {
  1894. Syncprocess.getProducts().then((result) => {
  1895. console.log('Get Products:', result)
  1896. }).catch((err) => {
  1897. console.log(err)
  1898. })
  1899. },
  1900. // orders - Quote
  1901. cartQty: function (id) {
  1902. let qtyClass = 'cart-qty-' + id
  1903. return qtyClass
  1904. },
  1905. cartSubtotal: function (id) {
  1906. let subTotalClass = 'cart-subtotal-' + id
  1907. return subTotalClass
  1908. },
  1909. updateCartProductById: function (id) {
  1910. console.log('UPDATE CART PRODUCT', id)
  1911. let cartQty = $('.cart-qty-' + id).val()
  1912. let sessionProducts = this.$session.get('target-cart')
  1913. sessionProducts[id].data.qty = parseInt(cartQty)
  1914. console.log('UPDATE CART sessionProducts', sessionProducts)
  1915. this.$session.set('target-cart', sessionProducts)
  1916. this.setCartItems()
  1917. this.getCartSessionItems()
  1918. this.sessionProductsData = this.$session.get('target-cart')
  1919. this.jQuerySetBadge(sessionProducts)
  1920. },
  1921. deleteCartProductById: function (id) {
  1922. // let cartQty = $('.cart-qty-' + id).val()
  1923. let productsToDelete = {}
  1924. let sessionProducts = this.$session.get('target-cart')
  1925. delete sessionProducts[id]
  1926. productsToDelete = sessionProducts
  1927. this.$session.set('target-cart', {})
  1928. this.$session.set('target-cart', productsToDelete)
  1929. // this.setCartItems()
  1930. this.getCartSessionItems()
  1931. this.jQuerySetBadge(sessionProducts)
  1932. this.sessionProductsData = this.$session.get('target-cart')
  1933. // $('.cart-qty-' + id).parent().parent().hide('fade')
  1934. },
  1935. saveQuoteToSession: function () {
  1936. // let sessionProducts = this.sessionProductsData
  1937. let sessionProducts = this.$session.get('target-cart')
  1938. let quote = this.$session.get('target-quote')
  1939. let data = {}
  1940. let user = this.$session.get('user-session')
  1941.  
  1942. if (typeof quote === 'undefined') {
  1943. this.$session.set('target-quote', {})
  1944. }
  1945. let lineItems = []
  1946. Object.keys(sessionProducts).map(function (objectKey, index) {
  1947. var value = sessionProducts[objectKey]
  1948. lineItems.push({ product_id: value.data.id, quantity: value.data.qty })
  1949. console.log('PRODUCTOS EN EL CARRITO--->', value.data.id)
  1950. })
  1951. console.log('lineitemssss', lineItems)
  1952. console.log('USER - SESSION', user.customer_seller_id)
  1953. var customerId = this.sellerCustomerSelected
  1954. var customerObj
  1955. store.getDoc(customerId).then((result) => {
  1956. if (!result) {
  1957. customerId = user.customer_seller_id
  1958. customerObj = {display_name: 'No especificado'}
  1959. } else {
  1960. customerId = result.ID
  1961. customerObj = result
  1962. }
  1963. console.log('Find Customer by ID:', result)
  1964. console.log('Total Cart:', this.totalCart)
  1965. data = {
  1966. order: {
  1967. payment_details: {
  1968. method_id: 'bacs',
  1969. method_title: 'Pago a coordinar',
  1970. paid: true
  1971. },
  1972. billing_address: {
  1973. first_name: '',
  1974. last_name: '',
  1975. address_1: '',
  1976. address_2: '',
  1977. city: '',
  1978. state: '',
  1979. postcode: '',
  1980. country: '',
  1981. email: '',
  1982. phone: ''
  1983. },
  1984. shipping_address: {
  1985. first_name: '',
  1986. last_name: '',
  1987. address_1: '',
  1988. address_2: '',
  1989. city: '',
  1990. state: '',
  1991. postcode: '',
  1992. country: ''
  1993. },
  1994. customer_id: customerId,
  1995. line_items: lineItems,
  1996. shipping_lines: []
  1997. },
  1998. user: user,
  1999. customer: customerObj,
  2000. total: this.totalCart,
  2001. authorized: false,
  2002. pushed: false,
  2003. created: new Date()
  2004. }
  2005. this.$session.set('target-quote', data)
  2006. console.log(data)
  2007. })
  2008. this.goToSection('checkout')
  2009. },
  2010. placeLocalOrder: function () {
  2011. let self = this
  2012. console.log('placeORder', self.quoteProducts)
  2013. // self.saveOrders(self.quoteProducts)
  2014. var totalCart = this.$session.get('target-quote')
  2015. totalCart.totalCart = this.totalCart
  2016. self.saveOrders(totalCart)
  2017. // vaciar el quote y el cart
  2018. self.$session.set('target-cart', {})
  2019. self.$session.set('target-quote', {})
  2020. $(document).ready(function () {
  2021. $('.badge').text(0)
  2022. })
  2023. // redirección a thanks
  2024. // self.$router.push('/thanks')
  2025. this.goToSection('thanks')
  2026. },
  2027. fetchOrders: function () {
  2028. store.findAllOrders().then((result) => {
  2029. var orders = result.rows
  2030. var pushedOrders = []
  2031. var pendingOrders = []
  2032. orders.map((order) => {
  2033. if (order.doc.pushed) {
  2034. pushedOrders.push(order.doc)
  2035. } else {
  2036. pendingOrders.push(order.doc)
  2037. }
  2038. })
  2039. this.pushedOrders = pushedOrders
  2040. this.pendingOrders = pendingOrders
  2041. console.log('GET pendingOrders:', this.pendingOrders)
  2042. console.log('GET pushedOrders:', this.pushedOrders)
  2043. })
  2044. },
  2045. saveOrders: function (data) {
  2046. Syncprocess.saveOrders(data).then((result) => {
  2047. console.log('Saved Order:', result)
  2048. this.fetchOrders()
  2049. }).catch((err) => {
  2050. console.log(err)
  2051. })
  2052. },
  2053. pushOrders: function () {
  2054. this.loading = true
  2055. Syncprocess.pushOrders().then((result) => {
  2056. console.log('Pushed Orders:', result)
  2057. this.fetchOrders()
  2058. this.loading = false
  2059. }).catch((err) => {
  2060. this.loading = false
  2061. console.log(err)
  2062. })
  2063. },
  2064. removeOrder: function (id, rev) {
  2065. store.removeOrder(id, rev).then((result) => {
  2066. console.log('Removed Order:', result)
  2067. this.fetchOrders()
  2068. }).catch((err) => {
  2069. console.log(err)
  2070. })
  2071. },
  2072. pushOrder: function (order) {
  2073. this.loading = true
  2074. Syncprocess.pushOrder(order).then((result) => {
  2075. console.log('Pushed Order:', result)
  2076. this.fetchOrders()
  2077. this.loading = false
  2078. }).catch((err) => {
  2079. this.loading = false
  2080. console.log(err)
  2081. })
  2082. },
  2083. viewOrder: function (order) {
  2084. this.orderProducts = []
  2085. console.log('Order:', order)
  2086. order.order.line_items.map((product) => {
  2087. store.getDoc(product.product_id.toString()).then((result) => {
  2088. console.log('Order Product:', result)
  2089. result.quantity = product.quantity
  2090. result.subtotal = product.subtotal
  2091. this.orderProducts.push(result)
  2092. })
  2093. })
  2094. this.orderDetail = order
  2095. this.goToSection('orderDetail')
  2096. },
  2097. authorizeOrder: function (authorization, pos) {
  2098. this.pendingOrders[pos].authorized = authorization
  2099. store.updateOrder(this.pendingOrders[pos]).then((result) => {
  2100. this.fetchOrders()
  2101. console.log(result)
  2102. }).catch((err) => {
  2103. console.log('ERROR:', err)
  2104. })
  2105. },
  2106. // end orders
  2107. isUserLogged: function () {
  2108. let self = this
  2109. return store.findByTypeInSession('user_session').then(function (resSessionUser) {
  2110. console.log('lo tengo en sesion LOGIN ', resSessionUser.docs.length)
  2111. if (resSessionUser.docs.length) {
  2112. let userSession = self.$session.get('user-session')
  2113. if (typeof userSession === 'undefined') {
  2114. self.$session.set('user-session', resSessionUser)
  2115. }
  2116. console.log('lo tengo en sesion ', userSession)
  2117. // self.$router.push('/products')
  2118. self.isUserLoggedAttr = true
  2119. $(document).ready(function () {
  2120. $('.products').show()
  2121. $('#navbar').show()
  2122. // $('#thanks').hide()
  2123. // $('#checkout').hide()
  2124. // $('#cart').hide()
  2125. // $('#navbar').show()
  2126. // $('#login-container').show()
  2127. })
  2128. // return Promise.resolve(true)
  2129. // oculto login
  2130. // redirijo
  2131. } else {
  2132. // muestro login
  2133. // return Promise.resolve(false)
  2134. self.isUserLoggedAttr = false
  2135. }
  2136. })
  2137. },
  2138. authUser: function () {
  2139. let self = this
  2140. let userSession = {}
  2141. if (!self.isFormValid()) {
  2142. return false
  2143. } else {
  2144. // chequearlo en sesion primero
  2145. // store.findByTypeInSession('user_session').then(function (resSessionUser) {
  2146. // console.log('busca al usuario en la db de la sesion', resSessionUser)
  2147. // })
  2148. // self.setCurrentStep('products')
  2149. // store.findByTypeInSession('user_session').then(function (resSessionUser) {
  2150. store.findUserSessionByEmail(self.username).then(function (resSessionUser) {
  2151. console.log('busca al usuario en la db de la sesion', resSessionUser)
  2152. // if (typeof resSessionUser === 'undefined' || resSessionUser.docs.length === 0) {
  2153. if (typeof resSessionUser === 'undefined' || resSessionUser.length === 0) {
  2154. store.findUserByEmail(self.username).then(function (result) {
  2155. console.log('resultado ', result)
  2156. if (result != null && result.status === 'ok') {
  2157. // utilizo la data del usuario y lo logueo internamente
  2158. // guardarlo en sesiòn
  2159. console.log(result.status)
  2160. console.log(result)
  2161. var userData = result.user
  2162. // result._id = userData.id.toString()
  2163. userSession._id = userData.id.toString()
  2164. userSession.nickname = userData.nickname
  2165. userSession.nicename = userData.nicename
  2166. userSession.username = userData.username
  2167. userSession.password = SHA256(self.password).toString()
  2168. userSession.email = userData.email
  2169. userSession.displayname = userData.displayname
  2170. userSession.session_type = 'user_session'
  2171. userSession.customer_seller_id = ''
  2172. self.$session.set('user-session', userSession)
  2173. store.createSession(userSession)
  2174.  
  2175. if (!self.appInstalled) {
  2176. console.log('App no instalada')
  2177. self.goToSection('setup')
  2178. } else {
  2179. self.isUserLoggedAttr = true
  2180. self.syncApp()
  2181. self.goToSection('products')
  2182. }
  2183. // self.isUserLoggedAttr = true
  2184. // self.syncApp()
  2185. // self.goToSection('login', 'products')
  2186. } else {
  2187. console.log('entra acá si el usuario no está en la DB')
  2188. self.$http.get('http://targetmoda2.braintlylabs.com/home/carrito/api/user/generate_auth_cookie/?insecure=cool&username=' + self.username + '&password=' + self.password)
  2189. .then(function (response) {
  2190. // logica de guardado del usuario en la DB
  2191. var userObj = response.data
  2192. console.log(userObj)
  2193. if (userObj.status === 'ok') {
  2194. var userData = userObj.user
  2195. console.log('UserData', userData)
  2196. console.log('userObj', userObj)
  2197. userObj._id = userData.id.toString()
  2198. userSession._id = userData.id.toString()
  2199. userSession.nickname = userData.nickname
  2200. userSession.nicename = userData.nicename
  2201. userSession.username = userData.username
  2202. userSession.password = SHA256(self.password).toString()
  2203. userSession.email = userData.email
  2204. userSession.displayname = userData.displayname
  2205. self.$session.set('user-session', userSession)
  2206. userSession.session_type = 'user_session'
  2207. userSession.customer_seller_id = ''
  2208. store.createSession(userSession)
  2209. console.log('App instalada:', self.appInstalled)
  2210. if (!self.appInstalled) {
  2211. console.log('App no instalada')
  2212. self.goToSection('setup')
  2213. } else {
  2214. self.isUserLoggedAttr = true
  2215. self.syncApp()
  2216. self.goToSection('products')
  2217. }
  2218. // console.log('check user', store.findUserByEmail(userData.id.email))
  2219. // guardarlo en sesión
  2220. // store.create(userObj)
  2221. // store.createSession(userSession)
  2222. }
  2223. self.auth = response.data
  2224. setTimeout(() => {
  2225. // this.logged = true
  2226. // #/register tener en cuenta esto
  2227. // self.$router.push('/products')
  2228. }, 1000)
  2229. })
  2230. }
  2231. })
  2232. } else {
  2233. let userSession = self.$session.get('user-session')
  2234. if (typeof userSession === 'undefined') {
  2235. self.$session.set('user-session', resSessionUser)
  2236. }
  2237.  
  2238. console.log('DATA SESSION DB ->>>>>>>', resSessionUser)
  2239. console.log('lo tengo en sesion else! ', userSession)
  2240. if (!self.appInstalled) {
  2241. console.log('App no instalada')
  2242. self.goToSection('setup')
  2243. } else {
  2244. console.log('Entra aca para loguearse y luego ir aproductos')
  2245. console.log('RECIBO EL USUARIO ->>>>>>>', resSessionUser)
  2246. console.log('RECIBO EL passowrd del form->>>>>>>', self.password)
  2247. if (SHA256(self.password).toString() === resSessionUser.password) {
  2248. self.isUserLoggedAttr = true
  2249. self.loginError = false
  2250. self.syncApp()
  2251. self.goToSection('products')
  2252. } else {
  2253. self.loginError = true
  2254. console.log('password incorrecto')
  2255. }
  2256. }
  2257. // self.isUserLoggedAttr = true
  2258. // self.syncApp()
  2259. // self.goToSection('login', 'products')
  2260. // oculto login
  2261. // redirijo
  2262. }
  2263. })
  2264. }
  2265. },
  2266. syncApp: function () {
  2267. this.pagination()
  2268. this.fetchCategories()
  2269. this.fetchOrders()
  2270. this.getSellerCustomers()
  2271. this.pushOrders()
  2272. console.log('Products:', this.sessionProductsData)
  2273. // this.getSeller()
  2274. let cartSession = this.$session.get('target-cart')
  2275. let userSession = this.$session.get('user-session')
  2276. // this.$session.remove('target-cart')
  2277. if (typeof cartSession === 'undefined') {
  2278. console.log('session no definida la crea')
  2279. this.$session.start()
  2280. this.$session.set('target-cart', {})
  2281. } else if (typeof userSession === 'undefined') {
  2282. console.log('user session no definida la crea')
  2283. // this.$session.start()
  2284. this.$session.set('user-session', {})
  2285. }
  2286. this.getCartSessionItems()
  2287. Syncprocess.init().then(function (result) {
  2288. console.log('iniiiit', result)
  2289. })
  2290. },
  2291. // end auth users
  2292. // FILTERS BEGINS
  2293. isEmpty: function (element) {
  2294. let check
  2295. Object.keys(element).length === 0 ? check = true : check = false
  2296. // console.log('check vacio', check)
  2297. return check
  2298. },
  2299. // pagination: function () {
  2300. // var self = this
  2301. // store.filters({categories: {$all: ['Anillos']}}).then(function (result) {
  2302. // console.log('FILTROS', result.docs)
  2303. // self.items = result.docs
  2304. // self.products = result.docs
  2305. // })
  2306. // },
  2307. pagination: function (id, type = 'categories') {
  2308. // let self = this
  2309. console.log(id)
  2310. if (type === 'categories') {
  2311. this.filterCategories(id)
  2312. } else {
  2313. this.filterPrice(id)
  2314. }
  2315. // store.filters({categories: {$all: [id]}}).then(function (result) {
  2316. // console.log('ESTA EMPTY', self.isEmpty(result.docs))
  2317. // if (self.isEmpty(result.docs)) {
  2318. // self.pagination('Anillos')
  2319. // }
  2320. // self.items = result.docs
  2321. // self.products = result.docs
  2322. // })
  2323. },
  2324. filterPrice: function (value) {
  2325. let self = this
  2326. self.loading = true
  2327. store.productFiltByPrice(value).then(function (result) {
  2328. console.log('priceeee', result)
  2329. self.items = result.docs
  2330. self.products = result.docs
  2331. self.loading = false
  2332. })
  2333. },
  2334. filterSearch: function () {
  2335. let self = this
  2336. // $('.loading').show()
  2337. self.loading = true
  2338. store.filterSearch(self.sku).then(function (result) {
  2339. if (self.isEmpty(result.docs)) {
  2340. console.log('esta vacio!!!!')
  2341. // $('.loading').hide()
  2342. self.loading = false
  2343. self.productsAlert = true
  2344. } else {
  2345. self.loading = false
  2346. self.productsAlert = false
  2347. console.log('FILTER SKU!!', result.docs)
  2348. // $('.loading').hide()
  2349. }
  2350. self.items = result.docs
  2351. self.products = result.docs
  2352. })
  2353. },
  2354. filterCategories: function (id) {
  2355. console.log('FILTER CATES', id)
  2356. let self = this
  2357. store.filters({categories: {$all: [id]}}).then(function (result) {
  2358. if (self.isEmpty(result.docs)) {
  2359. console.log('esta vacio')
  2360. // self.pagination('Anillos')
  2361. // $('#pages').hide()
  2362. // $('#products-alert').show()
  2363. self.productsAlert = true
  2364. } else {
  2365. // $('#products-alert').hide()
  2366. self.productsAlert = false
  2367. $('#pages').show()
  2368. }
  2369. self.items = result.docs
  2370. self.products = result.docs
  2371. })
  2372. },
  2373. fetchCategories: function () {
  2374. var self = this
  2375. self.loading = true
  2376. store.findByType('category').then(function (catsWC) {
  2377. // let categoriesWC = catsWC.docs
  2378. self.categories = self.arrangeCategories(catsWC.docs)
  2379. self.loading = false
  2380. })
  2381. },
  2382. arrangeCategories: function (categories, parent = 0) {
  2383. let self = this
  2384. let result = {}
  2385. categories.filter(function (category) {
  2386. if (category.parent === parent) {
  2387. result[category.name] = self.arrangeCategories(categories, category.id)
  2388. }
  2389. })
  2390. return result
  2391. },
  2392. // CATEGORIES - DROPDOWN
  2393. catDropdown: function (classTo) {
  2394. console.log('hizo click!!!!!!')
  2395. console.log('tocaaaaaa', classTo)
  2396. $('.dropdown-submenu a.' + classTo).next('ul').toggle(function (e) {
  2397. e.stopPropagation()
  2398. e.preventDefault()
  2399. })
  2400. // e.stopPropagation()
  2401. // e.preventDefault()
  2402. },
  2403. // FILTERS ENDS
  2404. // CART
  2405. setTotal: function (value, qty) {
  2406. let total = value * qty
  2407. this.totalCart = total
  2408. console.log('TOTAL EN SET TOTAL', total)
  2409. },
  2410. getCartSessionItems: function () {
  2411. let self = this
  2412. let cartSession = this.$session.get('target-cart')
  2413. let qty = 0
  2414. let total = 0
  2415. // let price = 0
  2416. Object.keys(cartSession).map(function (objectKey, index) {
  2417. var value = cartSession[objectKey]
  2418. console.log('PRODUCTOS EN EL CARRITO--->', cartSession[objectKey])
  2419. qty += parseInt(value.data.qty)
  2420. total = self.setTotal(parseInt(value.data.price), qty)
  2421. })
  2422. // total = price
  2423. console.log('var QTY !!!!', qty)
  2424. console.log('var TOTAL !!!!', total)
  2425. // self.totalCart = total
  2426. // this.badgeItems(qty)
  2427. },
  2428. dataBindCartProducts: function (id, name, item = null) {
  2429. return {
  2430. [`data-${name}-product-${id}`]: id
  2431. }
  2432. },
  2433. // CART ENDS
  2434. wooAuth () {
  2435. }
  2436. },
  2437. created: function () {
  2438. console.log('SHAAAA', SHA256('Message').toString())
  2439. // this.fetchProductsWC()
  2440. // this.wooAuth()
  2441. // this.fetchCustomersWC()
  2442. // this.authUser()
  2443. // console.log('VuePaginate --->', VuePaginate)
  2444. // this.$session.remove('user-session')
  2445. // store.findByTypeInSession('user_session').then(function (usersInDB) {
  2446. // console.log('usersInDB ->>>>>->>->>', usersInDB)
  2447. // })
  2448. this.loading = false
  2449. this.setUsersSessions()
  2450. let cartSession = this.$session.get('target-cart')
  2451. let userSession = this.$session.get('user-session')
  2452. store.findById('app_setup').then((result) => {
  2453. console.log('App installed:', result)
  2454. if (result) {
  2455. this.appInstalled = true
  2456. }
  2457. })
  2458. if (this.appInstalled) {
  2459. this.pagination()
  2460. this.fetchCategories()
  2461. // this.$session.remove('user-session')
  2462. if (typeof cartSession === 'undefined') {
  2463. console.log('session no definida la crea')
  2464. this.$session.start()
  2465. this.$session.set('target-cart', {})
  2466. } else if (typeof userSession === 'undefined') {
  2467. console.log('user session no definida la crea')
  2468. // this.$session.start()
  2469. this.$session.set('user-session', {})
  2470. }
  2471. // this.setCartQtyItems(cartSession)
  2472. this.getCartSessionItems()
  2473. Syncprocess.init().then(function (result) {
  2474. console.log('iniiiit', result)
  2475. })
  2476. }
  2477. console.log('cart sesiooo', this.$session.get('target-cart'))
  2478. if (typeof cartSession !== 'undefined') {
  2479. this.setCartQtyItems(cartSession)
  2480. }
  2481. // PRODUCTS & FILTERS
  2482. console.log('SESION ALL', this.$session.getAll())
  2483. }
  2484. }
  2485. </script>
  2486.  
  2487. <!-- Add "scoped" attribute to limit CSS to this component only -->
  2488. <style scoped>
  2489. ul{
  2490. list-style-type: none !important;
  2491. }
  2492. #checkout .btn-make-order{
  2493. width: 100%;
  2494. }
  2495. .last-child-cat{
  2496. border-color:transparent !important;
  2497. background-color:transparent !important;
  2498. padding-left:5%;
  2499. }
  2500. .discount-box {margin-left:2%;display: inline;}
  2501. .discount-box input{width: 10%;}
  2502. .checkbox{margin-right: 2%;}
  2503. #thanks-keep {background-color: #000 !important}
  2504.  
  2505. .flash-message{display:none}
  2506. .shake-cart {
  2507. animation: shake 0.82s cubic-bezier(.36,.07,.19,.97) both;
  2508. transform: translate3d(0, 0, 0);
  2509. backface-visibility: hidden;
  2510. perspective: 1000px;
  2511. }
  2512.  
  2513. @keyframes shake {
  2514. 10%, 90% {
  2515. transform: translate3d(-1px, 0, 0);
  2516. }
  2517.  
  2518. 20%, 80% {
  2519. transform: translate3d(2px, 0, 0);
  2520. }
  2521.  
  2522. 30%, 50%, 70% {
  2523. transform: translate3d(-4px, 0, 0);
  2524. }
  2525.  
  2526. 40%, 60% {
  2527. transform: translate3d(4px, 0, 0);
  2528. }
  2529.  
  2530. }
  2531. .panel-default>.panel-heading{
  2532. background: none;
  2533. }
  2534. .total-order{
  2535. float: right;
  2536. height: 60px;
  2537. margin: 0px 40px 0px 0px;
  2538. /* border-top:1px solid #ccc; */
  2539. /* width: 100%; */
  2540. }
  2541. .panel {
  2542. border:none;
  2543. -webkit-box-shadow: none;
  2544. }
  2545. .price-table{
  2546. border:none !important;
  2547. padding-top:40%;
  2548. -webkit-box-shadow: none !important;
  2549. }
  2550. .table td {
  2551. font-family: 'Montserrat-Light' !important;
  2552. }
  2553. .title-table{
  2554. margin-top:21%;
  2555. }
  2556. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement