Views/Cart/Index.cshtml
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
@model List<MvcShopping.Models.Cart>
@{
var ajax = new AjaxOptions() { OnSuccess="success",OnFailure="fail",HttpMethod="post",Confirm="确定要删除?" };
}
@section Scripts{
@Scripts.Render("~/bundles/jqueryval");
<script>
function success() {
alert("success");
window.location.reload();
}
function fail(xhr) {
alert("fail"+xhr.status);
}
</script>
}
<h2>购物车列表</h2>
@using (Html.BeginForm("UpdateAmount", "Cart"))
{
<table>
<tr>
<th>名称</th>
<th>单价</th>
<th>数量</th>
<th>小计</th>
<th></th>
</tr>
@{int totalPrice = 0;}
@if (Model!=null)
{
for (int i = 0; i < Model.Count; i++)
{
totalPrice += Model[i].Product.Price * Model[i].Amount;
var ddlAmount = new SelectList(Enumerable.Range(1, 10), Model[i].Amount);
@Html.HiddenFor(modelitem => Model[i].Product.Id)
<tr>
<td>@Html.DisplayFor(modelitem => Model[i].Product.Name)</td>
<td>@(Model[i].Product.Price)</td>
<td>@Html.DropDownListFor(modelitem => Model[i].Amount, ddlAmount)</td>
<td>@(Model[i].Product.Price * Model[i].Amount)</td>
<td>@Ajax.ActionLink("删除", "Remove", "Cart", new { ProductId = Model[i].Product.Id }, ajax)</td>
</tr>
}
}
<tr>
<th></th>
<th></th>
<th>总价</th>
<th id="totalprice">@totalPrice</th>
<th></th>
</tr>
</table>
<p>
<input type="submit" value="更新数量" />
<input type="button" value="完成订单" onclick="location.href='@Url.Action("Complete","Order")'" />
后面还有 2 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。