您的位置:首页 > 运维架构

shoppingcart基础页面

2017-08-24 07:36 204 查看
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">

<meta http-equiv="cache-control" content="no-cache">

<meta http-equiv="expires" content="0">

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

<meta http-equiv="description" content="This is my page">

<!--

    <link rel="stylesheet" type="text/css" href="styles.css">

    

    -->

<link rel="stylesheet" href="css/bootstrap.css" />

<script type="text/javascript"

    src="${pageContext.request.contextPath}/js/jquery-1.8.3.js"></script>

<script type="application/javascript"

    src="${pageContext.request.contextPath}/js/angularjs.js"></script>

<script>

               /*控制区 */

    angular.module('myapp', [])

    .controller(

            'controller',

            function($scope, $http) {

                $http.get("${pageContext.request.contextPath}/shop/all")

                        .success(function(a) {

                            $scope.cart = a;

                        });

                        /* 减按钮 */

                 $scope.reduce=function(index)

                 {

                 $scope.cart[index].count= $scope.cart[index].count-1;

                     var ssid= $scope.cart[index].ssid;

                 var count=  $scope.cart[index].count;

                 $.post("${pageContext.request.contextPath}/shop/update",{"ssid":ssid,"count":count});

                 

                 };

                 

                     /* 加按钮 */

                  $scope.add=function(index)

                 {

                 $scope.cart[index].count= $scope.cart[index].count+1;

                     var ssid= $scope.cart[index].ssid;

                 var count=  $scope.cart[index].count;

                 $.post("${pageContext.request.contextPath}/shop/update",{"ssid":ssid,"count":count});

                 

                 }

                  /* 全选按钮 */

                $("#all").click(function(){                

                  $("input[type='checkbox']:gt(0)").prop("checked",$(this).prop("checked"));

                })

                var array=new Array();

                 /* 批量删除 */

                $("#delete").click(function(){

                    

                    $("input[type='checkbox']:gt(0):checked").each(function(){                    

                     array.push($(this).val());        

                                

                    });

                 $.post("${pageContext.request.contextPath}/shop/delete?array="+array+"",function(a)

                 {

                   location.reload();

                 

                 });

              });

            });

</script>

</head>

<body ng-app="myapp">

<div class="row" ng-controller="controller">

 <div class="col-md-1 col-md-offset-9">

 <button class="btn btn-danger" id="delete">批量删除</button>

 

 </div>

<div class="col-md-7 col-md-offset-3">

   

     <table class="table nth-child table-bordered table-hover table-condensed">

     <thead>

     <tr>

     <td><input type="checkbox" id="all"></td>

      <td>用户名</td>

      <td>商品名</td>

      <td>单价</td>

      <td>数量</td>

      <td>小计</td>

     </tr>

     </thead>

     <tbody>

     <tr ng-repeat="x in cart">

        <td><input type="checkbox"  value="{{x.ssid}}"></td>

        <td>{{x.tuser.uname}}</td>

           <td>{{x.tproduct.name}}</td>

              <td>{{x.tproduct.price | number:2 | currency:"¥ "}}</td>

                 <td>

                 <button ng-click="reduce($index)">-</button>

                 <input value="{{x.count}}" style="width: 30px">

                  <button  ng-click="add($index)" >+</button>

                 </td>

                    <td>{{x.tproduct.price *x.count | number:2 | currency:"¥ " }}</td>

     </tr>

     </tbody>

     </table>

</div>

</div>

</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息