10 changed files with 102 additions and 22 deletions
@ -0,0 +1,21 @@ |
|||||
|
@using EShopOnAbp.Localization |
||||
|
@using EShopOnAbp.PublicWeb.Components.Purchase |
||||
|
@using Microsoft.Extensions.Localization |
||||
|
@model PurchaseWidgetViewComponent.PurchaseViewModel |
||||
|
@inject IStringLocalizer<EShopOnAbpResource> L |
||||
|
|
||||
|
<div> |
||||
|
<div class="row"> |
||||
|
<h4>Total Selected (@Model.Basket.Items.Count)</h4> |
||||
|
</div> |
||||
|
<div class="row"> |
||||
|
<h3>$@Model.Basket.TotalPrice.ToString("0.00")</h3> |
||||
|
</div> |
||||
|
<div class="row"> |
||||
|
<form method="post"> |
||||
|
@Html.AntiForgeryToken() |
||||
|
<abp-button type="submit" size="Large" class="basket-purchase-button" text="@L[Model.ButtonDescription]" button-type="Primary"/> |
||||
|
</form> |
||||
|
|
||||
|
</div> |
||||
|
</div> |
||||
@ -0,0 +1,15 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Packages.SignalR; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace EShopOnAbp.PublicWeb.Components.Purchase; |
||||
|
|
||||
|
[DependsOn(typeof(SignalRBrowserScriptContributor))] |
||||
|
public class PurchaseWidgetScriptContributor : BundleContributor |
||||
|
{ |
||||
|
public override void ConfigureBundle(BundleConfigurationContext context) |
||||
|
{ |
||||
|
context.Files.AddIfNotContains("/components/purchase/purchase-widget.js"); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
|
||||
|
namespace EShopOnAbp.PublicWeb.Components.Purchase; |
||||
|
|
||||
|
public class PurchaseWidgetStyleContributor : BundleContributor |
||||
|
{ |
||||
|
public override void ConfigureBundle(BundleConfigurationContext context) |
||||
|
{ |
||||
|
context.Files.AddIfNotContains("/components/purchase/purchase-widget.css"); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,37 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using EShopOnAbp.BasketService; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Widgets; |
||||
|
|
||||
|
namespace EShopOnAbp.PublicWeb.Components.Purchase; |
||||
|
|
||||
|
[Widget( |
||||
|
AutoInitialize = true, |
||||
|
RefreshUrl = "/Widgets/Basket", |
||||
|
StyleTypes = new[] {typeof(PurchaseWidgetStyleContributor)}, |
||||
|
ScriptTypes = new[] {typeof(PurchaseWidgetScriptContributor)} |
||||
|
)] |
||||
|
public class PurchaseWidgetViewComponent : AbpViewComponent |
||||
|
{ |
||||
|
public PurchaseViewModel ViewModel { get; set; } |
||||
|
|
||||
|
public Task<IViewComponentResult> InvokeAsync(string buttonDescription, BasketDto basket) |
||||
|
{ |
||||
|
ViewModel = new PurchaseViewModel |
||||
|
{ |
||||
|
ButtonDescription = buttonDescription, |
||||
|
Basket = basket |
||||
|
}; |
||||
|
|
||||
|
return Task.FromResult<IViewComponentResult>( |
||||
|
View("~/Components/Purchase/Default.cshtml", ViewModel) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
public class PurchaseViewModel |
||||
|
{ |
||||
|
public string ButtonDescription { get; set; } |
||||
|
public BasketDto Basket { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
(function () { |
||||
|
|
||||
|
})(); |
||||
Loading…
Reference in new issue