Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ecommerce #13

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"git.ignoreLimitWarning": true
}
2 changes: 0 additions & 2 deletions README.md

This file was deleted.

Binary file added client/car.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
218 changes: 218 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>E-commerce</title>

<!-- Import vue.js -->

<!-- Font Awesome -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Bootstrap core CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
<!-- Material Design Bootstrap -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.5.0/css/mdb.min.css" rel="stylesheet">
<script defer src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<!-- JQuery -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Bootstrap tooltips -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.13.0/umd/popper.min.js"></script>
<!-- Bootstrap core JavaScript -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/js/bootstrap.min.js"></script>
<!-- MDB core JavaScript -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.5.0/js/mdb.min.js"></script>
</head>
<body>
<div id="app">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Logo</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Hotels</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Destination
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Flight</a>
</li>
</ul>
<div v-if="totalCart > 0">
<button class="btn btn-danger">{{totalCart}}</button>
</div>
<a style="margin-right:10px; color:lightslategrey; font-size:25px" data-toggle="modal" data-target=".bd-example-modal-lg"><i class="fas fa-shopping-bag"></i></a>
<!-- Modal -->
<div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Cart Shopping</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body" >
<div class="row" style ="margin-bottom:20px"v-for="item in cart">
<img style="width:200px;height:180px;margin-left:10px;border-radius:8px;" v-bind:src="item.image" alt="">
<div style="padding-left:20px; padding-top:10px;">
<p >Destination: {{item.destination}}</p>
<p>Price: ${{item.price}}</p>
<p>{{item.days}}</p>
<p>Package: {{item.quantity}}
<a style="margin-left:10px" v-on:click="addItem(item)"><i class="fas fa-plus"></i></a>
<a style="margin-left:5px;" v-on:click="minItem(item)" ><i class="fas fa-minus"></i></a>
</p>
</div>
<div style="padding-top:2px; margin-left:280px;">
<p><button class="btn btn-danger btn-sm" v-on:click="deleteItem(item)"><i class="fa fa-trash"></i></button></p>
</div>
</div>
<h4>Total Price : ${{totalPrice}}</h4>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Checkout</button>
</div>
</div>
</div>
</div>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-success my-2 my-sm-0" type="submit"><i class="fas fa-search"></i></button>
</form>
</div>
</nav>
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" >
<div class="carousel-item active">
<img height="600px" class="d-block w-100" src="https://images.wallpaperscraft.com/image/zenit_retro_camera_photos_map_107245_2048x1152.jpg" alt="First slide">
</div>
<div class="carousel-item" v-for="image in carousels">
<img height="600px" class="d-block w-100" v-bind:src="image.images" alt="First slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<div class="container" style="text-align: center;
font-weight: bold;
opacity: 0.75;
font-size: 1em;
padding-bottom: 5px;
margin-top:50px;
margin-bottom:65px;
letter-spacing: 1px;">
<div>
<p style="display: block;
-webkit-margin-before: 1em;
-webkit-margin-after: 1em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;">I don't know where I'm going, but I'm on my way</p>
</div>
<div style="margin: auto;width: 30px;height: 3px;bottom: 0;left: 0;right: 0;background: black; opacity: 0.2">
</div>
</div>
<div style="text-align: center;
font-weight: bold;
font-size: 0.88em;
padding-bottom: 5px;
margin-top:50px;
margin-bottom:65px;
letter-spacing: 1px;" class="container">
<div style="margin-bottom:40px"class="row">
<div class="col-md-4" v-for="item in contents">
<div class="img-content">
<img style="width:300px;height:250px; border-radius:8px" v-bind:src="item.image" alt="">
</div>
<div class="content">
<p style="margin-top:10px">Destination: {{item.destination}}</p>
<p>starting from: ${{item.price}}</p>
<p>{{item.days}}</p>
<p>Package Available: {{item.quantity}} pax</p>
</div>
<button v-on:click="addCart(item)" style="margin-bottom:40px;" class="btn red"type="submit"><i style="margin-right:6px;"class="fas fa-shopping-cart"></i>Add to Cart</button>
</div>
</div>
</div>
<footer class="page-footer font-small blue pt-4 mt-4">

<!--Footer Links-->
<div class="container-fluid text-center text-md-left">
<div class="row">

<!--First column-->
<div class="col-md-6">
<h5 class="text-uppercase">Footer Content</h5>
<p>Here you can use rows and columns here to organize your footer content.</p>
</div>
<!--/.First column-->

<!--Second column-->
<div class="col-md-6">
<h5 class="text-uppercase">Links</h5>
<ul class="list-unstyled">
<li>
<a href="#!">Link 1</a>
</li>
<li>
<a href="#!">Link 2</a>
</li>
<li>
<a href="#!">Link 3</a>
</li>
<li>
<a href="#!">Link 4</a>
</li>
</ul>
</div>
<!--/.Second column-->
</div>
</div>
<!--/.Footer Links-->

<!--Copyright-->
<div class="footer-copyright py-3 text-center">
© 2018 Copyright:
<a href="https://mdbootstrap.com/material-design-for-bootstrap/"> MDBootstrap.com </a>
</div>
<!--/.Copyright-->

</footer>
</div>
<!-- Vue -->
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.15/dist/vue.js"></script>
<script src="vue.js"></script>
</body>
</html>
145 changes: 145 additions & 0 deletions client/vue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
new Vue({
el: '#app',
data: {
carousels: [{
images: "https://images.wallpaperscraft.com/image/night_city_panorama_river_120786_3840x2160.jpg"
},{
images: "https://images.wallpaperscraft.com/image/night_city_panorama_sea_shore_119801_3840x2160.jpg"
}],
contents:[{
image: "http://06.img.avito.st/640x480/4140232806.jpg",
destination: "Bali Island",
price: 1000,
days:"5 days",
quantity: 100
},{
image: "http://justglobetrotting.com/wp-content/uploads/2015/09/budapest-hungary-1080x675.jpg",
destination: "Budapest",
price: 2000,
days:"4 days",
quantity: 50
},{
image: "//do9f0cpkv689t.cloudfront.net/SFImage/Images/swissf273ffe313a06dce84b1ff000062a8f2.png",
destination: "Switzerland",
price: 1750,
days:"3 days",
quantity: 75
},{
image: "https://cuhsxov73uxte8o3fsfcl91m-wpengine.netdna-ssl.com/wp-content/uploads/2015/02/VIENNA.jpg",
destination: "Vienna,austria",
price: 1250,
days:"2 days",
quantity: 60
},{
image: "http://www.nuarthatours.com/wp-content/uploads/2017/10/paket-wisata-malang-bromo-murah-1024x576.jpg",
destination: "Bromo Mountain",
price: 1750,
days:"10 days",
quantity: 50
},{
image:"http://www.aljannahwisata.com/wp-content/uploads/2016/12/wisata-muslim-jepang-1.jpg",
destination: "Tokyo,japan",
price: 3000,
days:"6 days",
quantity: 4
}],
cart:[],
cartTotal:0,
totalPrice:0
},
methods:{
addCart: function(item){
for(let i = 0 ; i < this.contents.length ; i++){
if(this.contents[i].destination === item.destination){
if(this.contents[i].quantity === 0){
alert(`Soory journey to ${item.destination} SOLD OUT`)
this.contents[i].quantity = 0
return
}else if(this.contents[i].quantity >= 1){
alert(`add journey to ${item.destination} to cart`)
this.contents[i].quantity -= 1
}
for(let j = 0 ; j < this.cart.length ; j++){
if(this.cart[j].destination === item.destination){
this.cart[j].quantity ++
this.cart[j].price += item.price
this.cartTotal += item.price
this.totalPrice += item.price
return
}
}
}
}
const package = {
image: item.image,
destination: item.destination,
price: item.price,
days:item.days,
quantity: 1
}
this.cart.push(package)
this.cartTotal += item.price
this.totalPrice += item.price
},
deleteItem: function(item){
for(let i=0; i<this.cart.length; i++){
if(this.cart[i].destination == item.destination){
let x = confirm('Are you sure want to delete this item?')
if(x == true){
this.cart.splice(i, 1)
this.cartTotal -= item.price
this.totalPrice -= item.price
}
}
}
},
addItem: function(item){
for(let i = 0 ; i < this.contents.length ; i++){
if(this.contents[i].destination === item.destination){
if(this.contents[i].quantity === 0){
this.contents[i].quantity = 0
return
}else if(this.contents[i].quantity >= 1){
this.contents[i].quantity -= 1
}
for(let j = 0 ; j < this.cart.length ; j++){
if(this.cart[j].destination === item.destination){
this.cart[j].quantity ++
this.cart[j].price += this.contents[i].price
this.cartTotal += this.contents[i].price
this.totalPrice += this.contents[i].price
return
}
}
}
}
},
minItem: function(item){
for(let i = 0 ; i < this.contents.length ; i++){
if(this.contents[i].destination === item.destination){
if(item.quantity < 1){
return
}else{
this.contents[i].quantity += 1
}
for(let j = 0 ; j < this.cart.length ; j++){
if(this.cart[j].destination === item.destination){
this.cart[j].quantity --
this.cart[j].price -= this.contents[i].price
this.cartTotal -= this.contents[i].price
this.totalPrice -= this.contents[i].price
return
}
}
}
}
}
},
computed:{
totalCart:function(){
return this.cart.length
}
}
})


1 change: 1 addition & 0 deletions server
Submodule server added at 616fad