diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-08-31 14:53:08 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-08-31 14:53:08 +0200 |
| commit | 28b7ef196eaca6b9e455846cf6233bbabd9e4513 (patch) | |
| tree | eaf3fa41bed3a4988997587c865e2a6e1ceb45dd /StoneIsland/platforms/android/assets/www/js/lib/cart | |
| parent | 189eccc46edd09e78c9683580ccf078c28d5b34e (diff) | |
deploy android
Diffstat (limited to 'StoneIsland/platforms/android/assets/www/js/lib/cart')
3 files changed, 64 insertions, 18 deletions
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartConfirm.js b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartConfirm.js index a82509af..031e3359 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartConfirm.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartConfirm.js @@ -110,20 +110,31 @@ var CartConfirm = FormView.extend({ this.$tax.html( as_cash(tax) ) this.$total.html( as_cash(total) ) - var street = data.Receiver.StreetWithNumber.replace(/\n$/,"").replace("\n", ", ") - var address = data.Receiver.Name.toUpperCase() + " " + data.Receiver.Surname.toUpperCase() + "<br>" + street + ", " - address += data.Receiver.City + ", " + data.Receiver.Region + " " + data.Receiver.PostalCode + if (data.Receiver) { + var street = data.Receiver.StreetWithNumber.replace(/\n$/,"").replace("\n", ", ") + var address = data.Receiver.Name.toUpperCase() + " " + data.Receiver.Surname.toUpperCase() + "<br>" + street + ", " + address += data.Receiver.City + ", " + data.Receiver.Region + " " + data.Receiver.PostalCode - this.$shipping_address.html(address) - this.$shipping_method.html(data.DeliveryMethod.Selected.Type == 1 ? "* STANDARD SHIPPING" : "* EXPRESS SHIPPING") + this.$shipping_address.html(address) + this.$shipping_method.html(data.DeliveryMethod.Selected.Type == 1 ? "* STANDARD SHIPPING" : "* EXPRESS SHIPPING") + } else { + this.$shipping_address.html( "Please enter your shipping information." ) + this.$shipping_method.html( "" ) + } var cc = data.Payment.CreditCard - var cc_street = cc.HolderAddress.replace(/\n$/,"").replace("\n", ", ") - var cc_type = cc.Type == "AmericanExpress" ? "American Express" : cc.Type + if (cc) { + var cc_street = cc.HolderAddress.replace(/\n$/,"").replace("\n", ", ") + var cc_type = cc.Type == "AmericanExpress" ? "American Express" : cc.Type + var cc_name = cc.HolderName.toUpperCase() + " " + cc.HolderSurname.toUpperCase() + var cc_eNcrYpTed = cc_type.toUpperCase() + " XXXX-XXXX-XXXX-" + cc.Last4 + this.$payment_name.html( cc_name ) + this.$payment_method.html( cc_eNcrYpTed ) + } else { + this.$payment_name.html( "Please enter your credit card information." ) + this.$payment_method.html( "" ) + } - this.$payment_name.html( cc.HolderName.toUpperCase() + " " + cc.HolderSurname.toUpperCase() ) - this.$payment_method.html( cc_type.toUpperCase() + " XXXX-XXXX-XXXX-" + cc.Last4 ) - app.curtain.hide("loading") }, @@ -132,7 +143,9 @@ var CartConfirm = FormView.extend({ promise(sdk.cart.finalize, {}).then(function(){ app.curtain.hide("loading") app.router.go('cart/thanks') - }.bind(this)).error(function(data){ + }.bind(this)).error(function(res){ + const data = res.responseJSON + console.log(data) app.curtain.hide("loading") // {"Header":{"StatusCode":403,"Description":"403 Forbidden"},"Error":{"Description":"GenericApiError:CartAlreadyClosed"}} // {"Header":{"StatusCode":409,"Description":"304 NotModified"},"Error":{"Description":"FinalizationError:\\"Item has been removed from cart because it is no longer available.\\"\\n235"}}' @@ -140,7 +153,7 @@ var CartConfirm = FormView.extend({ // {"Header":{"StatusCode":409,"Description":"304 NotModified"},"Error":{"Description":"FinalizationError:\"The reciever validation fails."}} // {"Header":{"StatusCode":440,"Description":"304 NotModified"},"Error":{"Description":"GenericApiError:CartFinalizationNotYetCompleted"}} // {"Header":{"StatusCode":441,"Description":"304 NotModified"},"Error":{"Description":"GenericApiError:EmptyCreditCard"}} - switch (data.StatusCode) { + switch (data.StatusCode || data.Header.StatusCode) { case 403: // cart already closed auth.clear_cart(auth.create_cart) app.router.go('thanks') @@ -158,14 +171,17 @@ var CartConfirm = FormView.extend({ }, finalization_error: function(data){ - if (data['Error']['Description'].match(/receiver validation fails/)) { - app.router.go('cart/shipping') + if (data['Error']['Description'].match(/receiver validation fails/i)) { + console.log('cc error') + app.router.go('cart/billing') app.cart.payment.show_errors([["Number","There was a problem with your credit card."]]) } - else if (data['Error']['Description'].match(/cart cannot be empty/)) { + else if (data['Error']['Description'].match(/cart cannot be empty/i)) { + console.log('cart empty') app.router.go('cart/summary') } - else if (data['Error']['Description'].match(/Item has been removed/)) { + else if (data['Error']['Description'].match(/Item has been removed/i)) { + console.log('item does not exist') app.router.go('cart/error') app.cart.error.show_error("We're sorry, but one or more items was out of stock. Please check your cart and try again.") } diff --git a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartPayment.js b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartPayment.js index 31c371a5..3a9e6412 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartPayment.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartPayment.js @@ -15,6 +15,7 @@ var CartPayment = FormView.extend({ "change [name=SameAsShipping]": "toggle_shipping", "click .address_dropdown": "toggle_address", "click .cc_dropdown": "toggle_cc", + "focus [name=Number]": "focus_on_cc", }, initialize: function(opt){ @@ -34,6 +35,11 @@ var CartPayment = FormView.extend({ this.address = new AddressView ({ parent: this, checkPhone: false }) this.cc = new CreditCardView ({ parent: this }) this.scroller = new IScroll('#cart_payment', app.iscroll_options) + this.scroller.on('scrollStart', function(){ + if (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'SELECT') { + document.activeElement.blur() + } + }) this.address.disabled = true this.cc.disabled = true }, @@ -63,7 +69,7 @@ var CartPayment = FormView.extend({ } // this.$address_dropdown.toggle( !! app.account.ccs.length ) - this.address_list_mode = typeof state == "boolean" ? state : ! this.list_mode + this.address_list_mode = typeof state == "boolean" ? state : ! this.address_list_mode this.address.disabled = this.address_list_mode this.$address_form.toggle(! this.address_list_mode) this.$address_list.toggle(this.address_list_mode) @@ -82,6 +88,15 @@ var CartPayment = FormView.extend({ this.$cc_confirm.toggle(this.cc_list_mode) }, + focus_on_cc: function(e){ + this.scroller.scrollToElement(e.currentTarget) + if (e.currentTarget.textShadow === '') { + e.currentTarget.textShadow = 'rgba(0,0,0,0) 0 0 0'; + } else { + e.currentTarget.textShadow = ''; + } + }, + populate: function(){ this.$(".save_as_default").show() this.$address_list.empty() diff --git a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartShipping.js b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartShipping.js index 536b5161..ef8f94b7 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartShipping.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartShipping.js @@ -129,7 +129,22 @@ var CartShipping = FormView.extend({ success: function(){ app.router.go('cart/payment') }, - + + error: function(res){ + console.log('error', res.responseJSON) + var data = res.responseJSON || { 'Error': { 'Description': 'Unknown' } } + const errors = [] + switch(data['Error']['Description']) { + case 'InvalidFormatParameterException:AddressPostalCode': + errors.push(['ZipCode', 'Please enter a valid US/Canada Zip Code.']) + break + default: + errors.push(['', 'An unknown error occured.']) + break + } + this.show_errors(errors) + }, + cancel: function(){ app.router.go('cart/summary') }, |
