|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
-
-
-
- var app = new Vue({
- el: '#app-subscription-form',
- data: {
- showLoading: false,
- loading: true,
- products: [],
- units: []
- },
-
- mounted: function() {
- this.init() ;
- this.loading = false ;
- },
-
- methods: {
- init: function() {
- var app = this ;
- this.showLoading = true ;
-
- axios.get("ajax-infos",{params: {idSubscription: $('#subscriptionform-id').val()}})
- .then(function(response) {
- app.products = response.data.products ;
- app.units = response.data.units ;
- app.showLoading = false ;
- }) ;
- },
- changeUnitProductSubscription: function(event) {
- for(var i = 0; i < this.products.length ; i++) {
- if(this.products[i].id == event.currentTarget.getAttribute('data-id-product')) {
- this.products[i].quantity = '' ;
- for(var j = 0; j < this.products[i].units.length ; j ++) {
- if(this.products[i].unit == this.products[i].units[j].unit) {
- this.products[i].step = this.products[i].units[j].step ;
- this.products[i].price = this.products[i].units[j].price ;
- }
- }
- }
- }
- },
- changeQuantityProductSubscription: function(increase, product) {
- var step = parseFloat(product.step) ;
- if(!product.quantity) product.quantity = 0 ;
- var quantity = parseFloat(product.quantity) ;
- if(!increase) {
- step = -step ;
- }
- if(quantity + step >= 0) {
- product.quantity = quantity + step ;
- }
- if(!product.quantity) product.quantity = '' ;
- }
- }
- });
|