Explorar o código

购物车价格计算

qihanjiao %!s(int64=7) %!d(string=hai) anos
pai
achega
e0e5aea5e5
Modificáronse 2 ficheiros con 21 adicións e 11 borrados
  1. 3 0
      aiberle/css/main.css
  2. 18 11
      aiberle/shopping-cart.html

+ 3 - 0
aiberle/css/main.css

@@ -128,8 +128,11 @@ p{color: #999;font-size: 12px;}
 .count_price_box {color: #e4004d;}
 .cl-red{color: #ff3b3b;}
 .gift{padding-top: 5px;margin-bottom: 0;font-size: 12px;}
+.xiajia{position: absolute;width: 100%;height: 100%;left: 0;top: 0;background: rgba(255,255,255,.6);padding-top: 43px;padding-left: 60px;}
+.xiajia:before{content: '';background: rgba(0,0,0,.1);position: absolute;left: 25px;top: 0;width: 100px;height: 100px;opacity: .5;}
 .clearing-box{margin: 14px;padding-bottom: 50px;}
 .clearing-box .center{margin-left: 25%;}
+.shopping-cart-list .mui-table-view-cell.mui-active{background-color: #fff;}
 .my-view-no-top:before{display: none;}
 .my-view-no-top .mui-navigate-right:after{right: 0;font-size: 22px;}
 			input[name=checkbox] {

+ 18 - 11
aiberle/shopping-cart.html

@@ -126,9 +126,9 @@
 							<td class="quanxuan">
 								<input type="checkbox" name="checkbox" class="all_check" /> 全选
 							</td>
-							<td class="mui-text-center">合计:<span class="count_price_box">¥<span class="count_price">165.06</span></span>元</td>
+							<td class="mui-text-center">合计:<span class="count_price_box">¥<span class="count_price">0.0</span></span>元</td>
 							<td>
-								<a id="go-clearing" class="mui-btn mui-pull-right add_gwc go-clearing">去结算(3)</a>
+								<a id="go-clearing" class="mui-btn mui-pull-right add_gwc1 go-clearing">去结算(0)</a>
 							</td>
 						</tr>
 					</table>
@@ -187,7 +187,7 @@
 									$("#go-clearing").removeClass("add_gwc1").addClass("add_gwc").text('去结算('+$(".shopping-cart-list input[type=checkbox]:not(:disabled):checked").length+')');//点亮结算按钮
 								}
 									mui(".mui-numbox").numbox(); //激活加减按钮组合
-									$(".shopping-box,.buy-footer1").show();
+//									$(".shopping-box,.buy-footer1").show();
 									$(".gwc_null").hide();
 									calculator();
 								}
@@ -339,8 +339,10 @@
 				if($(this).hasClass("all_check")) {
 					if($(this).prop("checked") == true) {
 						console.log("全选")
-						$("input[type='checkbox']").prop('checked', true);
-						$("#go-clearing").removeClass('add_gwc1').addClass('add_gwc').text("去结算(" + $(".shopping-cart-list input[type='checkbox']:checked").length + ")");
+						if($(".shopping-cart-list input[type='checkbox']:not(:disabled)").length>0){
+							$(".shopping-cart-list input[type='checkbox']:not(:disabled)").prop('checked', true);
+							$("#go-clearing").removeClass('add_gwc1').addClass('add_gwc').text("去结算(" + $(".shopping-cart-list input[type='checkbox']:checked").length + ")");
+						}
 					} else {
 						console.log("取消全选")
 						$("input[type='checkbox']").prop('checked', false);
@@ -348,7 +350,7 @@
 					}
 				} else {
 					$(".all_check").prop('checked', false);
-					if($("input[type='checkbox']:checked").length > 0) {
+					if($(".shopping-cart-list input[type='checkbox']:checked").length > 0) {
 						$("#go-clearing").removeClass('add_gwc1').addClass('add_gwc').text("去结算(" + $(".shopping-cart-list input[type='checkbox']:checked").length + ")");
 						if(($("input[type='checkbox']:checked").length + 1) == $("input[type='checkbox']").length) {
 							$("input[type='checkbox']").prop('checked', true);
@@ -368,10 +370,10 @@
 			
 			//结算事件
 			mui('body').on('tap', '.go-clearing', function() {
-				if($("input[type='checkbox']:checked").length > 0) {
+				if($(".shopping-cart-list input[type='checkbox']:checked").length > 0) {
 					var cartidList = ''; //购物项id集合
-					$.each($(".shopping-cart-list .mui-input-numbox"), function(index) {
-						var th = $(this);
+					$.each($(".shopping-cart-list input[type='checkbox']:not(:disabled):checked"), function(index) {
+						var th = $(this).parent().find('.mui-input-numbox');
 						if(typeof(th.attr("cartid")) != "undefined") {
 							var a = '';
 							if(index != 0) {
@@ -409,13 +411,18 @@
 				var count = 0;
 				var num = 0;
 				$(".mui-table-view li").each(function() {
-					if($(this).find("input[type='checkbox']").prop('checked') == true) {
+					if($(this).find("input[type='checkbox']:not(:disabled)").prop('checked') == true) {
 						num = parseFloat($(this).find(".price_sp").text().replace(/¥/g, "") * $(this).find(".mui-input-numbox").val()).toFixed(2);
 						count = accAdd(count, num);
 					}
 				});
 				$(".count_price").text(accAdd(count, 0).toFixed(2));
-				$("#go-clearing").text('去结算('+$(".shopping-cart-list input[type=checkbox]:checked").length+')');
+				$("#go-clearing").text('去结算('+$(".shopping-cart-list input[type=checkbox]:not(:disabled):checked").length+')');
+				if($(".shopping-cart-list input[type='checkbox']:not(:disabled):checked").length<1){
+					$("#go-clearing").removeClass("add_gwc").addClass("add_gwc1");
+				}else{
+					$("#go-clearing").removeClass("add_gwc1").addClass("add_gwc");
+				}
 			}
 		</script>
 	</body>