Advertisement
Guest User

Untitled

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