diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-11-21 15:57:50 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-11-21 15:57:50 -0500 |
| commit | c223032bbd67fe5b6ad1334ce81a3f51a7631bfc (patch) | |
| tree | 9f832d23e348a3b92030ec7da6053d7eece24254 /StoneIsland/www/js | |
| parent | 29380aa560c05186aa67b7b36d4a40c65e570d35 (diff) | |
cart empty warning
Diffstat (limited to 'StoneIsland/www/js')
| -rw-r--r-- | StoneIsland/www/js/lib/cart/CartConfirm.js | 3 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/cart/CartPayment.js | 3 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/cart/CartShipping.js | 3 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/cart/CartSummary.js | 28 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/cart/CartThanks.js | 3 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/cart/CartView.js | 18 | ||||
| -rw-r--r-- | StoneIsland/www/js/sdk/auth.js | 6 | ||||
| -rw-r--r-- | StoneIsland/www/js/sdk/cart.js | 13 |
8 files changed, 60 insertions, 17 deletions
diff --git a/StoneIsland/www/js/lib/cart/CartConfirm.js b/StoneIsland/www/js/lib/cart/CartConfirm.js index 7d8c6568..687f3a93 100644 --- a/StoneIsland/www/js/lib/cart/CartConfirm.js +++ b/StoneIsland/www/js/lib/cart/CartConfirm.js @@ -5,7 +5,8 @@ var CartConfirm = FormView.extend({ events: { }, - initialize: function(){ + initialize: function(opt){ + this.parent = opt.parent this.scroller = new IScroll('#cart_confirm', app.iscroll_options) }, diff --git a/StoneIsland/www/js/lib/cart/CartPayment.js b/StoneIsland/www/js/lib/cart/CartPayment.js index bcca1915..a9772ffe 100644 --- a/StoneIsland/www/js/lib/cart/CartPayment.js +++ b/StoneIsland/www/js/lib/cart/CartPayment.js @@ -5,7 +5,8 @@ var CartPayment = FormView.extend({ events: { }, - initialize: function(){ + initialize: function(opt){ + this.parent = opt.parent this.$form = this.$("form") this.$msg = this.$(".msg") this.address = new AddressView ({ parent: this }) diff --git a/StoneIsland/www/js/lib/cart/CartShipping.js b/StoneIsland/www/js/lib/cart/CartShipping.js index 65e2cb65..c0c21b4d 100644 --- a/StoneIsland/www/js/lib/cart/CartShipping.js +++ b/StoneIsland/www/js/lib/cart/CartShipping.js @@ -5,7 +5,8 @@ var CartShipping = FormView.extend({ events: { }, - initialize: function(){ + initialize: function(opt){ + this.parent = opt.parent this.$form = this.$("form") this.$msg = this.$(".msg") this.address = new AddressView ({ parent: this }) diff --git a/StoneIsland/www/js/lib/cart/CartSummary.js b/StoneIsland/www/js/lib/cart/CartSummary.js index d8619990..290627d3 100644 --- a/StoneIsland/www/js/lib/cart/CartSummary.js +++ b/StoneIsland/www/js/lib/cart/CartSummary.js @@ -5,18 +5,42 @@ var CartSummary = ScrollableView.extend({ events: { }, - initialize: function(){ + initialize: function(opt){ + this.parent = opt.parent + this.$loader = this.$(".loader") + this.$cart_body = this.$(".cart_body") + this.$cart_empty = this.$(".cart_empty") this.scroller = new IScroll('#cart_summary', app.iscroll_options) }, show: function(){ document.body.className = "cart" app.cart.el.className = "summary" + this.$loader.show() + + sdk.cart.get_status({ + success: this.populate.bind(this), + error: this.error.bind(this), + }) + }, + + populate: function(data){ + this.$loader.hide() app.footer.show("SHIPPING >", "CANCEL") + + console.log(data) + + this.parent.$itemcount.html("1 ITEM") + + this.$el.removeClass("empty").addClass("full") this.deferScrollToTop() }, - populate: function(){ + error: function(){ + this.$loader.hide() + app.footer.hide() + this.parent.$itemcount.html("0 ITEMS") + this.$el.addClass("empty").removeClass("full") }, ok: function(){ diff --git a/StoneIsland/www/js/lib/cart/CartThanks.js b/StoneIsland/www/js/lib/cart/CartThanks.js index 9524ab83..993fd9ac 100644 --- a/StoneIsland/www/js/lib/cart/CartThanks.js +++ b/StoneIsland/www/js/lib/cart/CartThanks.js @@ -5,7 +5,8 @@ var CartThanks = View.extend({ events: { }, - initialize: function(){ + initialize: function(opt){ + this.parent = opt.parent }, show: function(){ diff --git a/StoneIsland/www/js/lib/cart/CartView.js b/StoneIsland/www/js/lib/cart/CartView.js index 43dc7dd4..fdad3a07 100644 --- a/StoneIsland/www/js/lib/cart/CartView.js +++ b/StoneIsland/www/js/lib/cart/CartView.js @@ -3,17 +3,19 @@ var CartView = View.extend({ el: "#cart", events: { - "click .summary": "show_summary", - "click .shipping": "show_shipping", - "click .payment": "show_payment", + "click .summary_step": "show_summary", + "click .shipping_step": "show_shipping", + "click .payment_step": "show_payment", }, initialize: function(){ - this.summary = new CartSummary () - this.payment = new CartPayment () - this.shipping = new CartShipping () - this.confirm = new CartConfirm () - this.thanks = new CartThanks () + this.summary = new CartSummary ({ parent: this }) + this.payment = new CartPayment ({ parent: this }) + this.shipping = new CartShipping ({ parent: this }) + this.confirm = new CartConfirm ({ parent: this }) + this.thanks = new CartThanks ({ parent: this }) + + this.$itemcount = this.$(".itemcount") }, show: function(){ diff --git a/StoneIsland/www/js/sdk/auth.js b/StoneIsland/www/js/sdk/auth.js index fe7acc5c..66dd81e8 100644 --- a/StoneIsland/www/js/sdk/auth.js +++ b/StoneIsland/www/js/sdk/auth.js @@ -82,6 +82,12 @@ var auth = sdk.auth = (function(){ } auth.defer_add_to_cart = function(){ // auth.deferred_product + sdk.cart.add_item({ + data: { + Code10: auth.deferred_product.code, + Size: auth.deferred_product.size, + } + }) } auth.log_out = function(){ auth.clear_user() diff --git a/StoneIsland/www/js/sdk/cart.js b/StoneIsland/www/js/sdk/cart.js index cfa997cb..308231ff 100644 --- a/StoneIsland/www/js/sdk/cart.js +++ b/StoneIsland/www/js/sdk/cart.js @@ -90,8 +90,12 @@ sdk.cart = (function(){ "x-yoox-device": auth.device, }, success: function(data){ - // console.log(data) - opt.success(data) + if (data['Error']) { + opt.error && opt.error(data) + } + else { + opt.success(data) + } }, error: opt.error, }) @@ -106,7 +110,10 @@ sdk.cart = (function(){ "x-yoox-appname": auth.appname, "x-yoox-cart-token": cart.token, }, - data: opt.data, + data: { + "UserId": auth.user_id, + "UserToken": auth.access_token, + }, success: function(data){ // console.log(data) opt.success(data) |
