购物车主要逻辑

<!DOCTYPE html>
<html>


<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript" src="js/angular.min.js"></script>
<style>
span {
color: orange;
}
</style>
</head>


<body ng-app="MyApp" ng-controller="MyCont">
<table>
<tr>
<td><input type="checkbox" ng-model="q1" ng-checked="ck" ng-click="dian()" /></td>
<td><img src="img/aa.png" /></td>
<td>哈哈阿斯达所大所多<br/><span>150</span><br/><input type="button" value="+" ng-click="aa()" />{{one}}<input type="button" value="-" ng-click="dd()" /></td>
</tr>
<tr>
<td><input type="checkbox" ng-model="q2" ng-checked="ck" ng-click="dian1()" /></td>
<td><img src="img/bb.png" /></td>
<td>嘿嘿都大傻吊阿萨德<br/><span>119</span><br/><input type="button" value="+" ng-click="bb()" />{{two}}<input type="button" value="-" ng-click="ee()" /></td>
</tr>
<tr>
<td><input type="checkbox" ng-model="q3" ng-checked="ck" ng-click="dian2()" /></td>
<td><img src="img/cc.png" /></td>
<td>呵呵阿收到了吗sad<br/><span>120</span><br/><input type="button" value="+" ng-click="cc()" />{{three}}<input type="button" value="-" ng-click="ff()" /></td>
</tr>
</table>
<br />
<input type="checkbox" ng-model="ck" ng-click="quan()"/>全选&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 合计:¥
<span>{{one*150+two*119+three*120}}</span><input type="button" value="结算" />
<script>
var mo = angular.module("MyApp", []);
mo.controller("MyCont", function($scope) {
$scope.one = 0;
$scope.two = 0;
$scope.three = 0;
$scope.dian = function() {
if($scope.q1) {
haha();
}else{
$scope.one = 0;
}

}
$scope.dian1 = function() {
if($scope.q2) {
hehe();
}else{
$scope.two = 0;
}
}
$scope.dian2 = function() {
if($scope.q3) {
xixi();
}else{
$scope.three = 0;
}
}
$scope.quan=function(){
if($scope.ck){
$scope.one = 1;
$scope.two = 1;
$scope.three = 1;
haha();
hehe();
xixi();
}else{
$scope.one = 0;
$scope.two = 0;
$scope.three = 0;
}
}
function haha(){
$scope.one = 1;
$scope.aa = function() {
$scope.one = $scope.one + 1;
}
$scope.dd = function() {
if($scope.one > 0) {
$scope.one = $scope.one - 1;
}
}
}
function hehe(){
$scope.two = 1;
$scope.bb = function() {
$scope.two = $scope.two + 1;
}
$scope.ee = function() {
if($scope.two > 0) {
$scope.two = $scope.two - 1;
}
}
}
function xixi(){
$scope.three = 1;
$scope.cc = function() {
$scope.three = $scope.three + 1;
}
$scope.ff = function() {
if($scope.three > 0) {
$scope.three = $scope.three - 1;
}
}
}
})

</script>
</body>


</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值