mirror of
				https://gitee.com/coder-xiaomo/flashsale
				synced 2025-11-04 14:13:14 +08:00 
			
		
		
		
	商品详情页面
This commit is contained in:
		@@ -45,7 +45,6 @@
 | 
				
			|||||||
        <button class="btn blue" id="create" type="submit">
 | 
					        <button class="btn blue" id="create" type="submit">
 | 
				
			||||||
            创建商品
 | 
					            创建商品
 | 
				
			||||||
        </button>
 | 
					        </button>
 | 
				
			||||||
        <a href="getotp.html?quickDebug">获取验证码</a>
 | 
					 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										97
									
								
								frontend/getitem.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										97
									
								
								frontend/getitem.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,97 @@
 | 
				
			|||||||
 | 
					<!DOCTYPE html>
 | 
				
			||||||
 | 
					<html lang="en">
 | 
				
			||||||
 | 
					<head>
 | 
				
			||||||
 | 
					    <meta charset="UTF-8">
 | 
				
			||||||
 | 
					    <title>Title</title>
 | 
				
			||||||
 | 
					    <link href="static/assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
 | 
				
			||||||
 | 
					    <link href="static/assets/global/css/components.css" rel="stylesheet" type="text/css"/>
 | 
				
			||||||
 | 
					    <link href="static/assets/admin/pages/css/login.css" rel="stylesheet" type="text/css"/>
 | 
				
			||||||
 | 
					    <script src="./static/assets/global/plugins/jquery-1.11.0.min.js" type="text/javascript"></script>
 | 
				
			||||||
 | 
					</head>
 | 
				
			||||||
 | 
					<body class="login">
 | 
				
			||||||
 | 
					<div class="content">
 | 
				
			||||||
 | 
					    <h3 class="form-title">商品详情</h3>
 | 
				
			||||||
 | 
					    <div class="from-group">
 | 
				
			||||||
 | 
					        <div>
 | 
				
			||||||
 | 
					            <label class="control-label" id="title">
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					    <div class="from-group">
 | 
				
			||||||
 | 
					        <label class="control-label">商品描述</label>
 | 
				
			||||||
 | 
					        <div>
 | 
				
			||||||
 | 
					            <label class="control-label" id="description">
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					    <div class="from-group">
 | 
				
			||||||
 | 
					        <label class="control-label">价格</label>
 | 
				
			||||||
 | 
					        <div>
 | 
				
			||||||
 | 
					            <label class="control-label" id="price">
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					    <div class="from-group">
 | 
				
			||||||
 | 
					            <img id="imgUrl" src="" style="width: 200px; height: auto;"/>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					    <div class="from-group">
 | 
				
			||||||
 | 
					        <label class="control-label">库存</label>
 | 
				
			||||||
 | 
					        <div>
 | 
				
			||||||
 | 
					            <label class="control-label" id="stock">
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					    <div class="from-group">
 | 
				
			||||||
 | 
					        <label class="control-label">销量</label>
 | 
				
			||||||
 | 
					        <div>
 | 
				
			||||||
 | 
					            <label class="control-label" id="sales">
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					    <div>
 | 
				
			||||||
 | 
					        <a href="listitem.html">返回</a>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<script>
 | 
				
			||||||
 | 
					    //获取url中的参数
 | 
				
			||||||
 | 
					    function getUrlParam(name) {
 | 
				
			||||||
 | 
					        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
 | 
				
			||||||
 | 
					        var r = window.location.search.substring(1).match(reg); //匹配目标参数
 | 
				
			||||||
 | 
					        if (r != null) return decodeURIComponent(r[2]);
 | 
				
			||||||
 | 
					        return null; //返回参数值
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    var itemId = getUrlParam("id");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    var g_itemVO = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    jQuery(document).ready(function () {
 | 
				
			||||||
 | 
					        // 获取商品详情
 | 
				
			||||||
 | 
					        $.ajax({
 | 
				
			||||||
 | 
					            type: "GET",
 | 
				
			||||||
 | 
					            url: "http://localhost:8090/item/get",
 | 
				
			||||||
 | 
					            data: {
 | 
				
			||||||
 | 
					                "id": itemId,
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            xhrFields: {withCredentials: true},
 | 
				
			||||||
 | 
					            success: function (data) {
 | 
				
			||||||
 | 
					                if (data.status == "success") {
 | 
				
			||||||
 | 
					                    g_itemVO = data.data;
 | 
				
			||||||
 | 
					                    reloadDom();
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    alert("获取信息失败,原因为" + data.data.errMsg);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            error: function (data) {
 | 
				
			||||||
 | 
					                alert("获取信息失败,原因为" + data.responseText);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    function reloadDom() {
 | 
				
			||||||
 | 
					        $("#title").text(g_itemVO.title);
 | 
				
			||||||
 | 
					        $("#description").text(g_itemVO.description);
 | 
				
			||||||
 | 
					        $("#stock").text(g_itemVO.stock);
 | 
				
			||||||
 | 
					        $("#price").text(g_itemVO.price);
 | 
				
			||||||
 | 
					        $("#imgUrl").attr("src", g_itemVO.imgUrl);
 | 
				
			||||||
 | 
					        $("#sales").text(g_itemVO.sales);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
					</body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
@@ -75,7 +75,7 @@
 | 
				
			|||||||
            $("#container").append($(dom));
 | 
					            $("#container").append($(dom));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $("#itemDetail" + itemVO.id).on("click", function (e) {
 | 
					            $("#itemDetail" + itemVO.id).on("click", function (e) {
 | 
				
			||||||
                window.location.href = "getItem.html?id=" + $(this).data("id");
 | 
					                window.location.href = "getitem.html?id=" + $(this).data("id");
 | 
				
			||||||
            })
 | 
					            })
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user