123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <template>
- <div class="container">
- <div class="container">
- <div class="row">
- <div class="col-md-12 col-lg-8">
- <div class="title-box-d">
- <br />
- <h1 class="title-d" style="text-align:left; font-size: 250%">My Cart</h1>
- </div>
- </div>
- </div>
- <!-- ListView -->
- <ListView
- :items="cartItems"
- :displayColumns="columns"
- :displayFormats="formats"
- :editable="true"
- :deleteable="true"
- @onEdit="Edit"
- @onDelete="Delete"
- />
- <div class="row">
- <div class="col-md-12" style="margin-bottomL 1em">
- <!-- RestaurantFeeDel -->
- </div>
- </div>
- <div class="row">
- <div class="col-md-2 offset-md-8" style="margin-bottomL 1em">
- <label style="margin-top: 0.5em">
- <b>Delivery Fee:</b>
- </label>
- </div>
- <div class="col-md-2" style="margin-bottomL 1em">
- <label style="margin-top: 0.5em">
- <b>{{deliveryFee | toCurrency}}</b>
- </label>
- </div>
- </div>
- <div class="row">
- <div class="col-md-2 offset-md-8" style="margin-bottomL 1em">
- <label style="margin-top: 0.5em">
- <b>Order Total:</b>
- </label>
- </div>
- <div class="col-md-2" style="margin-bottomL 1em">
- <label style="margin-top: 0.5em">
- <b>{{OrderTotal | toCurrency}}</b>
- </label>
- </div>
- </div>
- <modal name="menu" :width="800" :height="600">
- <Cart :showItem="CurrentItem" @Close="CloseItem" />
- </modal>
- <br />
- <div class="row">
- <div class="col-md-12" style="margin-bottomL 1em">
- <div class="row offset-md-4">
- <div class="col-md-3">
- <button
- @click="CheckOut()"
- class="btn btn-b-n"
- type="button"
- data-dismiss="modal"
- :disabled="cartItems.length == 0"
- >Check Out</button>
- </div>
- <div class="col-md-3">
- <button
- @click="ClearCart()"
- class="btn btn-b-n"
- type="button"
- data-dismiss="modal"
- :disabled="cartItems.length == 0"
- >Clear Cart</button>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
-
- <script>
- import { mapState, mapActions } from "vuex";
- import ListView from "../shared/listView";
- import Cart from "./cartItem";
-
- export default {
- name: "MyCart",
- components: {
- ListView,
- Cart,
- },
- data() {
- return {
- wait: true,
- columns: ["image", "name", "description", "qty", "subTotal"],
- formats: ["image", "", "", "", "money"],
- item: {},
- };
- },
- methods: {
- ...mapActions("cart", ["getDeliveryFee"]),
- New() {},
- Edit(item) {
- this.item = item;
- this.$modal.show("menu");
- },
- Delete(item) {
- this.cartItems.pop(item);
- },
- CloseItem(value) {
- if (value) {
- this.$modal.hide("menu");
- }
- },
- CheckOut() {
- this.$router.push("/ConfirmOrder");
- },
- ClearCart() {
- this.deliveryFee = 0;
- this.cartItems.splice(0, this.cartItems.length);
- },
- },
- computed: {
- ...mapState("cart", ["cartItems", "deliveryFee"]),
- CurrentItem() {
- return this.item;
- },
- OrderTotal() {
- var tot = 0;
- for (let i = 0; i < this.cartItems.length; i++) {
- tot = tot + this.cartItems[i].subTotal;
- }
- return tot + this.deliveryFee;
- },
- },
- mounted() {
- if (this.cartItems.length > 0) {
- this.getDeliveryFee(this.cartItems[0].restaurantId);
- }
- },
- };
- </script>
|