angularjs购物车

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />

<style>
tbody tr:nth-child(even){
background: aqua;
}
tbody tr:nth-child(odd){
background: aliceblue;
}
thead tr{
background: #474747;
}


</style>

<title></title>
<script type="text/javascript" src="js/jquery-2.1.0.js" ></script>
<script type="text/javascript" src="js/angular-route.js" ></script>
<script type="text/javascript" src="js/angular.min.js" ></script>
<script>
var app=angular.module("myapp",[]);
app.filter("guolv",function(){

return function(input){
return input.replace(/米/g,"*");
}
});



app.controller("tres",["$scope","$filter",function($scope,$filter){
$scope.detes=[{"sid":1,"key1":false,"spin":"小米 R9sk","name":"刘备","tel":13733205441,"pric":2999,"cid":"天津","xon":"发货","time":"03-09 10:30"},{"sid":2,"key1":false,"spin":"OppO R9sk","name":"刘秀","tel":15633205441,"pric":2999,"cid":"北京","xon":"发货","time":"03-09 10:30"},
{"sid":3,"key1":false,"spin":"努比亚Z17","name":"张飞","tel":13645454545,"pric":1999,"cid":"呼和浩特","xon":"发货","time":"04-15 09:25"},
{"sid":4,"key1":false,"spin":"黑莓","name":"赵四","tel":13550058945,"pric":899,"cid":"安阳","xon":"发货","time":"06-19 10:20"},
{"sid":5,"key1":false,"spin":"华为 ment10 pro","name":"白起","tel":13544567894,"pric":7999,"cid":"舟山","xon":"发货","time":"08-23 10:00"},
{"sid":6,"key1":false,"spin":"华为 P10","name":"陈胜","tel":17845617894,"pric":4199,"cid":"南京","xon":"发货","time":"07-25 10:30"},
{"sid":7,"key1":false,"spin":"HUAWEI mete10保时捷","name":"王五","tel":15688886666,"pric":9899,"cid":"北京","xon":"发货","time":"05-29 10:50"},{"sid":8,"key1":false,"spin":"OppO R9sk","name":"刘章","tel":13633205441,"pric":2999,"cid":"天津","xon":"发货","time":"03-09 10:30"},{"sid":9,"key1":false,"spin":"OppO R9sk","name":"刘表","tel":13833205441,"pric":2999,"cid":"石家庄","xon":"发货","time":"03-09 10:30"}];
$scope.dete=$scope.detes;
$scope.yi=1;
$scope.zhuang="选择状态";
$scope.chengshi="选择城市";
$scope.yue="开始月份";
$scope.jie="结束月份";
$scope.shu=[];//判断手机号的
$scope.zu=[];//判断城市的
$scope.tai=[];//判断状态的
$scope.fen=[];

$scope.chaxun=function(){
var fc=$filter("filter");
if($scope.ming!=null&&$scope.ming!=""&&$scope.hao!=0&&$scope.hao!=""&&$scope.chengshi!="选择城市"&&$scope.zhuang!="选择状态"&&$scope.yue!="开始月份"&&$scope.jie!="结束月份"){
$scope.shu=[];
$scope.shu=fc($scope.detes,{"name":$scope.ming});
$scope.dete=[];
$scope.dete=fc($scope.shu,{"tel":$scope.hao});
$scope.zu=[];
$scope.zu=fc($scope.dete,{"cid":$scope.chengshi});
$scope.tai=[];
$scope.tai=fc($scope.zu,{"xon":$scope.zhuang});
$scope.dete=[];
$scope.dete=$scope.tai;



}else if($scope.ming!=null&&$scope.ming!=""&&$scope.hao!=0&&$scope.hao!=""&&$scope.chengshi!="选择城市"&&$scope.zhuang!="选择状态"){
$scope.shu=[];
$scope.shu=fc($scope.detes,{"name":$scope.ming});
$scope.dete=[];
$scope.dete=fc($scope.shu,{"tel":$scope.hao});
$scope.zu=[];
$scope.zu=fc($scope.dete,{"cid":$scope.chengshi});
$scope.tai=[];
$scope.tai=fc($scope.zu,{"xon":$scope.zhuang});
$scope.dete=[];
$scope.dete=$scope.tai;
}

//判断姓名+城市+手机号
else if($scope.ming!=null&&$scope.ming!=""&&$scope.hao!=0&&$scope.hao!=""&&$scope.chengshi!="选择城市"){
$scope.shu=[];
$scope.shu=fc($scope.detes,{"name":$scope.ming});
$scope.dete=[];
$scope.dete=fc($scope.shu,{"tel":$scope.hao});
$scope.zu=[];
$scope.zu=fc($scope.dete,{"cid":$scope.chengshi});
$scope.dete=[];
$scope.dete=$scope.zu;

}

//判断姓名+手机号
else if($scope.ming!=null&&$scope.ming!=""&&$scope.hao!=0&&$scope.hao!=""){$scope.shu=[];
$scope.shu=fc($scope.detes,{"name":$scope.ming});
$scope.dete=[];
$scope.dete=fc($scope.shu,{"tel":$scope.hao});
}

//判断姓名的
else if($scope.ming!=null&&$scope.ming!=""){
$scope.shu=[];
$scope.shu=fc($scope.detes,{"name":$scope.ming});
$scope.dete=[];
$scope.dete=$scope.shu;
}else{
alert("用户名不能为空");
}
}
$scope.su=0;
$scope.idpai=function(){
if($scope.su!=0){
$scope.su=0;
$scope.dete=[];
$scope.dete=$scope.detes;
}else{
$scope.su=1;
var fc=$filter("orderBy");
$scope.dete=[];
$scope.dete=fc($scope.detes,"sid",true);
}
}

$scope.su1=0;
$scope.idpai1=function(){
if($scope.su1!=0){
$scope.su1=0;
$scope.dete=[];
$scope.dete=$scope.detes;
}else{
$scope.su1=1;
var fc=$filter("orderBy");
$scope.dete=[];
$scope.dete=fc($scope.detes,"spin",true);
}
}

$scope.su2=0;
$scope.idpai2=function(){
if($scope.su2!=0){
$scope.su2=0;
$scope.dete=[];
$scope.dete=$scope.detes;
}else{
$scope.su2=1;
var fc=$filter("orderBy");
$scope.dete=[];
$scope.dete=fc($scope.detes,"name",true);
}
}
$scope.su3=0;
$scope.idpai3=function(){
if($scope.su3!=0){
$scope.su3=0;
$scope.dete=[];
$scope.dete=$scope.detes;
}else{
$scope.su3=1;
var fc=$filter("orderBy");
$scope.dete=[];
$scope.dete=fc($scope.detes,"tel",true);
}
}
$scope.su4=0;
$scope.idpai4=function(){
if($scope.su4!=0){
$scope.su4=0;
$scope.dete=[];
$scope.dete=$scope.detes;
}else{
$scope.su4=1;
var fc=$filter("orderBy");
$scope.dete=[];
$scope.dete=fc($scope.detes,"pric",true);
}
}
$scope.su5=0;
$scope.idpai5=function(){
if($scope.su5!=0){
$scope.su5=0;
$scope.dete=[];
$scope.dete=$scope.detes;
}else{
$scope.su5=1;
var fc=$filter("orderBy");
$scope.dete=[];
$scope.dete=fc($scope.detes,"cid",true);
}
}
$scope.su6=0;
$scope.idpai6=function(){
if($scope.su6!=0){
$scope.su6=0;
$scope.dete=[];
$scope.dete=$scope.detes;
}else{
$scope.su6=1;
var fc=$filter("orderBy");
$scope.dete=[];
$scope.dete=fc($scope.detes,"time",true);
}
}

$scope.gaibian=function($index){

if($scope.detes[$index].xon=="发货"){
$scope.detes[$index].xon="已发货"
}else{
$scope.detes[$index].xon="发货"
}



}

//全选反选

$scope.zi=0;
$scope.xuan=function(){
var dc=document.getElementsByName("ns");
if($scope.zi==0){
$scope.zi=1;
for (var i=0;i<$scope.detes.length;i++) {
dc[i].checked=true;
$scope.detes[i].key1=true;
}
}else{
$scope.zi=0;
for (var i=0;i<$scope.detes.length;i++) {
dc[i].checked=false;
$scope.detes[i].key1=false;
}
}
$scope.dete=[];
$scope.dete=$scope.detes;
}








//单个删除
$scope.dele=function(nt){
for (var i=0;i<$scope.detes.length;i++) {
if($scope.detes[i].sid==nt.sid){
$scope.detes.splice(i,1);
}
}
$scope.dete=[];
$scope.dete=$scope.detes;

}

//单个选取
$scope.pu=function(nd){


for (var i=0;i<$scope.detes.length;i++) {
if($scope.detes[i].sid==nd.sid){
if($scope.detes[i].key1==true){
$scope.detes[i].key1=false;
}else{
$scope.detes[i].key1=true;
}

}
}
$scope.dete=[];
$scope.dete=$scope.detes;
}







$scope.sql=0;
$scope.loi=0;
//批量删除
$scope.pidelet=function(sy){
//批量删除
$scope.sql=0;
$scope.sql=$scope.detes.length;
if(sy==1){
for(var j=0;j<=$scope.detes.length;j++) {
for (var i=0;i<$scope.detes.length;i++) {
if($scope.detes[i].key1==true){
$scope.detes.splice(i,1);
}
}
for (var i=0;i<$scope.detes.length;i++) {
if($scope.detes[i].key1==true){
$scope.detes.splice(i,1);
}
}
}

if($scope.sql==$scope.detes.length){
alert("请选中");
}

//批量发货
}else if(sy==2){
for(var j=0;j<=$scope.detes.length;j++) {
for (var i=0;i<$scope.detes.length;i++) {
if($scope.detes[i].key1==true){
$scope.detes[i].xon="已发货";
$scope.sql=$scope.sql-1;
$scope.loi=$scope.sql;
}else{
$scope.detes[i].xon="发货";
}
}
for (var i=0;i<$scope.detes.length;i++) {
if($scope.detes[i].key1==true){
$scope.detes[i].xon="已发货";

$scope.loi=$scope.loi-1;
$scope.sql=$scope.loi;
}else{
$scope.detes[i].xon="发货";
}
}
}


if($scope.sql==$scope.detes.length){
alert("请选中");
}
}
$scope.dete=[];
$scope.dete=$scope.detes;
}


$scope.xia=0;
$scope.dian=function(){
$scope.xia=1;
}
$scope.stun=[];
$scope.add=function(){
$scope.mi;



}

}]);
</script>


</head>
<body ng-app="myapp" ng-controller="tres">
<br />
<br />
<input type="text" ng-model="ming" placeholder="用户名搜索"/>
<input type="number" ng-model="hao" placeholder="手机号搜索"/>
<select ng-model="chengshi">
<option>选择城市</option>
<option>天津</option>
<option>呼和浩特</option>
<option>北京</option>
<option>安阳</option>
<option>南京</option>
<option>舟山</option>
</select>

<select ng-model="zhuang">
<option>选择状态</option>
<option>发货</option>
<option>已发货</option>
</select>

<select ng-model="yue">
<option>开始月份</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>

<select ng-model="jie">
<option>结束月份</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>

<button ng-click="chaxun()">查询</button>

<br />

<button ng-click="dian()">新增订单</button>
<button ng-click="pidelet(2)">批量发货</button>
<button ng-click="pidelet(1)">批量删除</button>

<br />
<table style="width: 800px;" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th><input ng-click="xuan()"  type="checkbox"/></th>
<th ng-click="idpai()">ID</th>
<th ng-click="idpai1()">商品名</th>
<th ng-click="idpai2()">用户名</th>
<th ng-click="idpai3()">手机号</th>
<th ng-click="idpai4()">价格</th>
<th ng-click="idpai5()">城市</th>
<th ng-click="idpai6()">下单时间</th>
<th>状态</th>
<th>操作</th>

</tr>
</thead>
<tbody>

<tr ng-repeat=" na in dete">
<td><input name="ns" ng-click="pu(na)" type="checkbox"/></td>
<td>{{na.sid}}</td>
<td>{{na.spin|guolv}}</td>
<td>{{na.name}}</td>
<td>{{na.tel}}</td>
<td>{{na.pric|currency:"¥"}}</td>
<td>{{na.cid}}</td>
<td>{{na.time|date:"MM-dd HH:mm:ss"}}</td>
<th><span ng-hide="na.xon=='已发货'"><a ng-click="gaibian($index)" href="#">{{na.xon}}</a></span>
<span ng-hide="na.xon=='发货'" ng-click="gaibian($index)">{{na.xon}}</span>
</th>
<td><a href="#">修改</a><a ng-click="dele(na)" href="#">删除</a></td>
</tr>


</tbody>

</table>


<div ng-hide="xia!=1" style="width: 300px;">
商品名:<input type="text" ng-model="mi" /><br />
用     户:<input type="text" ng-model="yong" /><br />
手机号:<input type="text" ng-model="ha" /><br />
价      格:<input type="text" ng-model="jia" /><br />
城       市:<input type="text" ng-model="che" /><br />

<ul ng-hide="stun.length==0">
<li ng-repeat=" cu in cuo">{{cu}}</li>
</ul>

<button ng-click="add()">提交 </button>


</div>

</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值