Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2cb4853
commit e04a28f
Showing
6 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
$$(document).on('page:init', '.page[data-name="store"]', function () { | ||
let storeProductAPIEndpointURL = API + '/store_products'; | ||
|
||
$.getJSON(storeProductAPIEndpointURL) | ||
.done(function(resp) { | ||
initStore(resp); | ||
}) | ||
.fail(function(resp) { | ||
console.log(resp.statusText); | ||
}); | ||
|
||
function initStore(resp) { | ||
let products = resp.store_products; | ||
products.forEach(function(product) { | ||
product.price /= 100; | ||
if (product.image_url === "") { | ||
product.image_url = "img/missing_thumb.png"; | ||
} | ||
}); | ||
|
||
let templateHTML = app.templates.storeTemplate({products: products}); | ||
let storeContainer = $('.store-content'); | ||
storeContainer.html(templateHTML); | ||
|
||
$('.buy-product').on('click', function() { | ||
productId = $('.buy-product').attr('data-id'); | ||
buyProduct(productId); | ||
}); | ||
} | ||
|
||
function buyProduct(id) { | ||
$.ajax({ | ||
url: API + '/store_orders', | ||
type: 'POST', | ||
dataType: 'json', | ||
data: { | ||
"item": { | ||
"id": id, | ||
"quantity": 1 | ||
} | ||
}, | ||
success: function(resp) { | ||
app.dialog.alert(resp.success, 'Varan är köpt'); | ||
}, | ||
error: function(resp) { | ||
app.dialog.alert(resp.responseJSON.error); | ||
} | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ | |
@import 'partials/album'; | ||
@import 'partials/about_app'; | ||
@import 'partials/cafe'; | ||
@import 'partials/store'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
.store-content { | ||
.card:nth-child(-n+2) { | ||
margin-top: 16px; | ||
} | ||
|
||
.card { | ||
width: calc(50% - 18px); | ||
float: left; | ||
box-shadow: none; | ||
margin-left: 8px | ||
} | ||
|
||
.card-header { | ||
background-size: cover; | ||
background-repeat: no-repeat; | ||
background-position: center; | ||
background-color: #f8f8f8; | ||
height: 37vh; | ||
} | ||
|
||
.card-content { | ||
text-align: center; | ||
} | ||
|
||
.product-name { | ||
font-size: 19px; | ||
font-weight: bold; | ||
} | ||
|
||
.buy-product { | ||
background-color: $fsek-orange; | ||
margin-top: 10px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<div data-name="store" class="page no-toolbar"> | ||
<div class="navbar"> | ||
<div class="navbar-inner sliding"> | ||
<div class="left"> | ||
<a href="#" class="back link"> | ||
<i class="icon icon-back"></i> | ||
<span class="ios-only">Tillbaka</span> | ||
</a> | ||
</div> | ||
<div class="title">F-shoppen</div> | ||
</div> | ||
</div> | ||
<div class="page-content store-content"> | ||
<div class="infinite-scroll-preloader"> | ||
<div class="preloader"></div> | ||
</div> | ||
</div> | ||
</div> |