Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div class="container">
  3. <div class="container">
  4. <div class="row">
  5. <div class="col-md-12 col-lg-8">
  6. <div class="title-box-d">
  7. <br />
  8. <h1 class="title-d" style="text-align:left; font-size: 250%">My Cart</h1>
  9. </div>
  10. </div>
  11. </div>
  12. <!-- ListView -->
  13. <ListView
  14. :items="cartItems"
  15. :displayColumns="columns"
  16. :displayFormats="formats"
  17. :editable="true"
  18. :deleteable="true"
  19. @onEdit="Edit"
  20. @onDelete="Delete"
  21. />
  22. <div class="row">
  23. <div class="col-md-12" style="margin-bottomL 1em">
  24. <!-- RestaurantFeeDel -->
  25. </div>
  26. </div>
  27. <div class="row">
  28. <div class="col-md-2 offset-md-8" style="margin-bottomL 1em">
  29. <label style="margin-top: 0.5em">
  30. <b>Delivery Fee:</b>
  31. </label>
  32. </div>
  33. <div class="col-md-2" style="margin-bottomL 1em">
  34. <label style="margin-top: 0.5em">
  35. <b>{{deliveryFee | toCurrency}}</b>
  36. </label>
  37. </div>
  38. </div>
  39. <div class="row">
  40. <div class="col-md-2 offset-md-8" style="margin-bottomL 1em">
  41. <label style="margin-top: 0.5em">
  42. <b>Order Total:</b>
  43. </label>
  44. </div>
  45. <div class="col-md-2" style="margin-bottomL 1em">
  46. <label style="margin-top: 0.5em">
  47. <b>{{OrderTotal | toCurrency}}</b>
  48. </label>
  49. </div>
  50. </div>
  51. <modal name="menu" :width="800" :height="600">
  52. <Cart :showItem="CurrentItem" @Close="CloseItem" />
  53. </modal>
  54. <br />
  55. <div class="row">
  56. <div class="col-md-12" style="margin-bottomL 1em">
  57. <div class="row offset-md-4">
  58. <div class="col-md-3">
  59. <button
  60. @click="CheckOut()"
  61. class="btn btn-b-n"
  62. type="button"
  63. data-dismiss="modal"
  64. :disabled="cartItems.length == 0"
  65. >Check Out</button>
  66. </div>
  67. <div class="col-md-3">
  68. <button
  69. @click="ClearCart()"
  70. class="btn btn-b-n"
  71. type="button"
  72. data-dismiss="modal"
  73. :disabled="cartItems.length == 0"
  74. >Clear Cart</button>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </template>
  82. <script>
  83. import { mapState, mapActions } from "vuex";
  84. import ListView from "../shared/listView";
  85. import Cart from "./cartItem";
  86. export default {
  87. name: "MyCart",
  88. components: {
  89. ListView,
  90. Cart,
  91. },
  92. data() {
  93. return {
  94. wait: true,
  95. columns: ["image", "name", "description", "qty", "subTotal"],
  96. formats: ["image", "", "", "", "money"],
  97. item: {},
  98. };
  99. },
  100. methods: {
  101. ...mapActions("cart", ["getDeliveryFee"]),
  102. New() {},
  103. Edit(item) {
  104. this.item = item;
  105. this.$modal.show("menu");
  106. },
  107. Delete(item) {
  108. this.cartItems.pop(item);
  109. },
  110. CloseItem(value) {
  111. if (value) {
  112. this.$modal.hide("menu");
  113. }
  114. },
  115. CheckOut() {
  116. this.$router.push("/ConfirmOrder");
  117. },
  118. ClearCart() {
  119. this.deliveryFee = 0;
  120. this.cartItems.splice(0, this.cartItems.length);
  121. },
  122. },
  123. computed: {
  124. ...mapState("cart", ["cartItems", "deliveryFee"]),
  125. CurrentItem() {
  126. return this.item;
  127. },
  128. OrderTotal() {
  129. var tot = 0;
  130. for (let i = 0; i < this.cartItems.length; i++) {
  131. tot = tot + this.cartItems[i].subTotal;
  132. }
  133. return tot + this.deliveryFee;
  134. },
  135. },
  136. mounted() {
  137. if (this.cartItems.length > 0) {
  138. this.getDeliveryFee(this.cartItems[0].restaurantId);
  139. }
  140. },
  141. };
  142. </script>