8 changed files with 98 additions and 39 deletions
@ -0,0 +1,16 @@ |
|||
using EShopOnAbp.PublicWeb.Components.Basket; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
|
|||
namespace EShopOnAbp.PublicWeb.Controllers; |
|||
|
|||
[Route("Widgets")] |
|||
public class WidgetsController : AbpController |
|||
{ |
|||
[HttpGet] |
|||
[Route("Basket")] |
|||
public IActionResult Counters() |
|||
{ |
|||
return ViewComponent(typeof(BasketWidgetViewComponent)); |
|||
} |
|||
} |
|||
@ -1,13 +1,17 @@ |
|||
(function(){ |
|||
$(function(){ |
|||
|
|||
var basketWidget = new abp.WidgetManager('#BasketArea'); |
|||
|
|||
$('.product-list-item').click(function(){ |
|||
var $this = $(this); |
|||
var productId = $this.attr('data-product-id'); |
|||
eShopOnAbp.basketService.basket.addProduct({ |
|||
productId: productId |
|||
}).then(function(){ |
|||
basketWidget.refresh(); |
|||
abp.notify.success("Added product to your basket.", "Successfully added"); |
|||
}); |
|||
}); |
|||
}) |
|||
}); |
|||
})(); |
|||
@ -0,0 +1,42 @@ |
|||
.basket-list |
|||
{ |
|||
background-color: #fff; |
|||
padding: 1em; |
|||
border: 1px solid #666; |
|||
border-radius: 3px; |
|||
box-shadow: 0 0 10px rgba(0, 0, 0, .05); |
|||
margin-bottom: 0.5em; |
|||
transition: all .2s; |
|||
} |
|||
|
|||
.basket-list:hover { |
|||
box-shadow: 0 0 20px rgba(0, 0, 0, .1); |
|||
} |
|||
|
|||
.basket-list-item { |
|||
margin-top: 1em; |
|||
} |
|||
|
|||
.basket-list-item:first-child{ |
|||
margin-top: 0; |
|||
} |
|||
|
|||
.basket-list-item img { |
|||
height: 1em; |
|||
} |
|||
|
|||
.basket-total-area |
|||
{ |
|||
margin-bottom: 1em; |
|||
font-weight: bold; |
|||
} |
|||
|
|||
.basket-item-remove { |
|||
cursor: pointer; |
|||
color: red; |
|||
opacity: 0.25; |
|||
} |
|||
|
|||
.basket-list-item:hover .basket-item-remove { |
|||
opacity: 1.0; |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
(function (){ |
|||
abp.widgets.BasketWidget = function ($wrapper) { |
|||
var widgetManager = $wrapper.data('abp-widget-manager'); |
|||
|
|||
var init = function (filters) { |
|||
$wrapper |
|||
.find('.basket-item-remove') |
|||
.click(function(){ |
|||
var $this = $(this); |
|||
var productId = $this.parent('.basket-list-item').attr('data-product-id'); |
|||
eShopOnAbp.basketService.basket.removeProduct({ |
|||
productId: productId |
|||
}).then(function(){ |
|||
widgetManager.refresh(); |
|||
abp.notify.info("Removed the product from your basket.", "Removed basket item"); |
|||
}); |
|||
}); |
|||
}; |
|||
|
|||
return { |
|||
init: init |
|||
}; |
|||
}; |
|||
|
|||
})(); |
|||
Loading…
Reference in new issue