|
|
@@ -249,11 +249,12 @@ var app = new Vue({ |
|
|
|
|
|
|
|
if(response.data.categories) { |
|
|
|
app.categories = response.data.categories ; |
|
|
|
if(app.countProductsByCategory(response.data.categories[0])) { |
|
|
|
app.setCategoryCurrent(response.data.categories[0], true) ; |
|
|
|
} |
|
|
|
else { |
|
|
|
app.setCategoryCurrent(response.data.categories[1], true) ; |
|
|
|
for(keyCategory in response.data.categories) { |
|
|
|
var category = response.data.categories[keyCategory]; |
|
|
|
if(category.id && app.countProductsByCategory(category)) { |
|
|
|
app.setCategoryCurrent(category, true) ; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -599,10 +600,13 @@ var app = new Vue({ |
|
|
|
} |
|
|
|
return this.producer.credit_limit == null || (this.producer.credit_limit != null && (this.user.credit - total >= this.producer.credit_limit)) ; |
|
|
|
}, |
|
|
|
isProductAvailable: function(product) { |
|
|
|
return product.productDistribution && product.productDistribution[0] && product.productDistribution[0].active == 1; |
|
|
|
}, |
|
|
|
countProductsByCategory: function(category) { |
|
|
|
var count = 0 ; |
|
|
|
for(var i = 0 ; i < this.products.length ; i++) { |
|
|
|
if(this.products[i].id_product_category == category.id) { |
|
|
|
if(this.products[i].id_product_category == category.id && this.isProductAvailable(this.products[i])) { |
|
|
|
count ++ ; |
|
|
|
} |
|
|
|
} |