MVC商品详情

2021-01-16 02:11

阅读:710

标签:api   function   NPU   checked   length   cal   oca   efault   url   

//MVC显示

GetList(1);
function GetList(index) {
$.ajax({
url: ‘http://localhost:4480/api/Default/GetShopShow‘,
type: ‘get‘,
data: { pageindex: index,pagesize:3 },
dataType: ‘json‘,
success: function (d) {
$("#bod").empty();
$("#fen").empty();
$(d.ShoppingProduct).each(function () {
$("#bod").append(

‘ +
‘‘ + this.SPid + ‘‘ +
‘ +
‘‘ + this.SPname + ‘‘ +
‘‘ + this.SPrice + ‘‘ +
‘详情‘ +
‘‘
)
})
for (var i = 1; i $("#fen").append(
‘【‘ + i + ‘】‘
)
}
}
})
}

function Lo(id) {
location.href = "http://localhost:13891/Default/Xshow?ID=" + id;
}

//详情

















 

 

 

 

 

 


@{
ViewBag.Title = "Detail";
}

Detail

























 

function load() {
var id = @ViewBag.Id;
$.ajax({
url: ‘http://localhost:56334/api/Default/GetONe/‘+id,
type: ‘get‘,
dataType: ‘json‘,
success: function (data) {
$("#img1").attr("src", data.Imgs[0].ImageUrl);
$("#td1").text(data.Goods.Name);
$("#td2").text(data.Goods.Price);
OldPrice = data.Goods.Price;
sku = data.Sku;

$(data.Attr).each(function () {
$("#td3").append( this.AName +":"+this.Value +"
");
});


$(data.SKUAttr).each(function () {
var str = "";
var check = "checked";
var values = $(this.AValue).each(function () {
str += " " + this.Value
check = "";
});
$("#td4").append(

‘+ this.AName+
‘ :‘+ str+
‘)
});
}
});


}
load();

function changePrice() {
var price = "";

var s = [];
$(":radio:checked").each(function () {
s.push( $(this).val());
});

$(sku).each(function () {
var sign = 1;
for (var i = 0; i if (this.AttrStr.indexOf(s[i]) == -1) {
sign = 0;
}
}
if (sign == 1) {
price = this.Price + "";
currentSku = this;
}
});

if (price != "")
$("#td2").text(price);
else
$("#td2").text(OldPrice);
}

MVC商品详情

标签:api   function   NPU   checked   length   cal   oca   efault   url   

原文地址:https://www.cnblogs.com/hualiang/p/13382987.html


评论


亲,登录后才可以留言!