码迷,mamicode.com
首页 > 其他好文 > 详细

(三十二)订单管理-查询订单详情

时间:2017-10-19 00:16:40      阅读:281      评论:0      收藏:0      [点我收藏+]

标签:layer   logs   open   tps   response   from   function   pre   https   

查询订单详情
        点击每一个订单后面的订单详情,将该订单的oid通过ajax传递到后台查询
    步骤分析:
        给按钮添加事件

 /store/WebContent/admin/order/list.jsp

技术分享

        <script type="text/javascript">
                function showDetail(oid){
                    //alert(oid);
                    $.post("${pageContext.request.contextPath}/adminOrder",{"method":"getDetailByOid","oid":oid},function(data){
                        var s="<table width=‘99%‘ border=‘1‘><tr><th>商品名称</th><th>购买数量</th></tr>";
                        $(data).each(function(){
                            s+=("<tr><td>"+this.product.pname+"</td><td>"+this.count+"</td></tr>");
                        });
                        s+="</table>";
                        
                        layer.open({
                             type: 1,//0:信息框; 1:页面; 2:iframe层;    3:加载层;    4:tip层
                             title:"订单详情",//标题
                             area: [‘450px‘, ‘300px‘],//大小
                             shadeClose: true, //点击弹层外区域 遮罩关闭
                             content: s//内容
                        });
                    },"json");
                }
        </script>

/store/src/com/louis/web/servlet/AdminOrderServlet.java

/**
     * 查询订单详情
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public  String getDetailByOid(HttpServletRequest request, HttpServletResponse response) throws Exception {
        response.setContentType("text/html;charset=utf-8");
        
        //1.接受oid
        String oid = request.getParameter("oid");
        
        
        //2.调用serivce查询订单详情 返回值 list<OrderItem>
        OrderService os=(OrderService) BeanFactory.getBean("OrderService");
        List<OrderItem> items = os.getById(oid).getItems();
        
        
        //3.将list转成json 写回
        //排除不用写回去的数据
        JsonConfig config = JsonUtil.configJson(new String[]{"class","itemid","order"});
        JSONArray json = JSONArray.fromObject(items,config);
        //System.out.println(json);
        response.getWriter().println(json);
        return null;
    }    

导入layer

效果

技术分享

问题:

json数据转化

 

(三十二)订单管理-查询订单详情

标签:layer   logs   open   tps   response   from   function   pre   https   

原文地址:http://www.cnblogs.com/Michael2397/p/7689898.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!