排版页面的

input id="Button1" type="button" value="查看我的收藏商品" onclick="location.href='/ShangPin/AddShow'" />
<input id="Button1" type="button" value="查看我的收藏店铺" onclick="location.href='/ShangPin/DPShow'"/>
<div style="width:100%;height:100%" id="Body">
</div>
<table class="table">
    <tr>
        <td>总共<span id="totalCount"></span>条记录</td>
        <td>第<span id="currentPage"></span>页</td>
        <td>共<span id="totalPage"></span>页</td>
        <td><a href="javascript:;" onclick="show(1)">首页</a></td>
        <td><a href="javascript:;" onclick="show(currentPage-1)">上一页</a></td>
        <td><a href="javascript:;" onclick="show(currentPage+1)">下一页</a></td>
        <td><a href="javascript:;" onclick="show(totalPage)">尾页</a></td>
    </tr>
</table>
<script>
    $(function () {
        Show();
    })
    function Show() {
        $.ajax({
            url: "http://localhost:62506/api/ChanPin",
            type: "get",
            dataType: "json",
            success: function (i) {
                $("#Body").empty();
                $(i).each(function () {
                    var line = `<div style="width:300px;height:430px;border:1px dashed #000;border-right:1px dashed #000;Margin:10px;float:left">
                        <div style="width:300px;height:350px">
                            <img style="width:280px;height:300px" src="/${this.SpTP}" alt="" />
                        </div>
                        <div style="margin-top:-50px">
                            <h4 style="color:orange">¥<span>${this.SpDj}</span><span style="包邮</span></h4>
                            <h5><a href="#" style="color:black">${this.SpGn}</a></h5>
                            <h5 style="color:darkgray">
                                <u>${this.DPlx}</u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <u>79人购买</u>
                            </h5>
                            <h5>
                                图&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    <select id="Select1">
                                    //<option>如实描述4.5</option>
                                    //<option>4.5</option>
                                    //<option>4.5</option>
                            <input id="Button1" type="button" value="收藏商品" onclick ="GouWu(${this.id})"/>
<input id="Button1" type="button" value="查看店铺" onclick = "ChaKan(${this.DPid})" />
<input id="Button1" type="button" value="收藏店铺" onclick="GouWu(${this.DPid})"/>
                                </select>
                            </h5>
                        </div>
                    </div>`
                    $("#Body").append(line);
                })
            }
        })
    }

    function GouWu(id) {
        $.ajax({
            url: "http://localhost:62506/api/GetId",
            Type: "get",
            data: { id: id },
            DataType: "json",
            success: function (i) {
                if (i) {
                    alert("添加成功");
                    Fenye();
                }
                else {
                    alert("添加失败");
                }
            }
        }
        )
    }
    function DPSC(id) {
        $.ajax({
            url: "http://localhost:62506/api/ADDdp",
            Type: "get",
            data: { id: id },
            DataType: "json",
            success: function (i) {
                if (i) {
                    alert("收藏店铺成功");
                    Fenye();
                }
                else {
                    alert("收藏店铺失败");
                }
            }
        }
        )
    }
</script>
 
posted @ 2020-07-09 20:31  G蠢蠢  阅读(152)  评论(0编辑  收藏  举报