MVC添加页面
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<script src="~/Scripts/jquery-3.3.1.js"></script>
<script src="~/Scripts/bootstrap.js"></script>
<link href="~/Scripts/bootstrap.css" rel="stylesheet" />
<div>
<a onclick="Yan()">我的订单</a>
</div>
<table class="table table-bordered">
<thead>
<tr>
<td>序号</td>
<td>
商品展示
</td>
<td>商品名称</td>
<td>商品价格</td>
<td>商品库存</td>
</tr>
</thead>
<tbody id="body"></tbody>
</table>
<script>
Shopping();
function Shopping() {
$.ajax({
url: 'http://localhost:7202/api/Default/GetShopShow',
type: 'get',
dataType: 'json',
success: function (d) {
$("#body").empty();
$(d).each(function () {
$("#body").append(
"<tr>" +
"<td>" + this.ShopId + "</td>" +
"<td><img src='http://localhost:8691/image/aaaaaa.png' width='180' height='120'/></td>" +
"<td>" + this.ShopName + "</td>" +
"<td>" + this.ShopPrice + "</td>" +
"<td>" + this.ShoNum + "</td>" +
"</tr>"
)
})
}
})
}
function Yan() {
if (getCookie('user') == null) {
location.href = "http://localhost:8691/Default/DengL"
}
else {
location.href = "http://localhost:8691/Default/Order"
}
}
/**
* cookie中取值
* */
function getCookie(name) {
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); //匹配字段
if (arr = document.cookie.match(reg)) {
return unescape(arr[2]);
} else {
return null;
}
}
</script>
浙公网安备 33010602011771号