소스 검색

购物车数量统计功能修复

git-svn-id: svn://svn7.apicloud.com/A6007457911931/%E5%9C%88%E5%A4%9A%E5%A4%9A@660 0e1a2743-8d03-4e5a-a60c-7e26af42b145
1149931599@qq.com 4 년 전
부모
커밋
f0132d2600
3개의 변경된 파일21개의 추가작업 그리고 22개의 파일을 삭제
  1. 1 1
      html/frame0.html
  2. 1 1
      html/home/buycar.html
  3. 19 20
      html/home/showgoods.html

+ 1 - 1
html/frame0.html

@@ -297,7 +297,6 @@
 			});
 		};
 		$(".msg-list").on("tap", function() {
-			console.log("1")
 			api.openWin({
 				name: 'msglist',
 				url: './home/msglist.html',
@@ -507,6 +506,7 @@
 				dataType: 'json',
 				type: 'post',
 				success: function(datas) {
+					console.log(datas.data.total)
 					if (datas.result) {
 						if (datas.data.total > 0) {
 							$(".msg-total").text(datas.data.total);

+ 1 - 1
html/home/buycar.html

@@ -264,7 +264,7 @@ function changenum(recid, num) {
     
 }
 
-// chkfavorite()
+//触发更新购物车数的函数
 function push_car_num (){
     api.execScript({
         name: 'showgoods',

+ 19 - 20
html/home/showgoods.html

@@ -508,7 +508,7 @@
             <li class="add-buycar" style="width: 2.2rem">加入购物车</li>
             <li style="width: 1rem;" class="go-buycar">
                 <img src="../../image/goods_buy_car.png" />
-                <span class="msg-total mask-hidden" style="position: absolute;transform: translateY(75%) translateX(-37%);animation: bounceOut 2s;">10</span>
+                <span class="msg-total mask-hidden" style="position: absolute;transform: translateY(75%) translateX(-37%);animation: bounceOut 2s;">0</span>
             </li>
             <li style="width: 1rem;" class="add-favorite"><img id="favorite" src="../../image/goods_buy_favorite.png" /></li>
             <li style="width: 1rem;" class="go-home"><img src="../../image/goods_buy_home.png" /></li>
@@ -546,16 +546,19 @@ var imgUrl="";
 apiready = function() {
     _keyid = api.pageParam.keyid;
     _storeid = api.pageParam.storeid;
-    // _spot = api.pageParam.spot;
     setIosTopBar();
     getRouteData(_keyid, _storeid);
-    // chkfavorite();
     getfeed();
     api.addEventListener({
         name: 'longpress'
     }, function(ret, err) {
         save_img();
     });
+	api.addEventListener({
+		name: 'viewappear'
+	}, function(ret, err) {
+		// getRouteData(_keyid, _storeid);
+	});
 };
 
 function getRouteData(_keyid, _storeid) {
@@ -589,7 +592,6 @@ function getRouteData(_keyid, _storeid) {
                 $("#goods-content").html('<p></p>'+datas.data.goods_body);
                 $("#goods-issue").html(datas.data.issue);
                 if ( datas.data.cart > 0 ) {//调用赋值给购物车数量方法
-					// getCar();
 					$(".msg-total").html(datas.data.cart);
                     $(".msg-total").removeClass("mask-hidden");
                 }
@@ -717,7 +719,6 @@ $(function() {
     }
     $("img").click(function() {
         var index = $('img').index(this);
-        // imagePreview(src[index],src);
     });
 })
 
@@ -809,15 +810,9 @@ function spec_map_check(goods_list, spec_map, line, key, checked_list) {
 
 
 $(".home-ads").on("tap", "img", function() {
-    // console.log($(this).attr("src"));
     gallery_qz($(this).attr("src"));
 });
-// $(".feed-list").on("tap", "img", function() {
-//     // console.log($(this).attr("src"));
-//     gallery_qz($(this).attr("src"));
-// });
 $(".goods-content").on("tap", "img", function() {
-    // console.log($(this).attr("src"));
     gallery_qz($(this).attr("src"));
 });
 
@@ -1033,9 +1028,6 @@ $(".goods-size-item").on("tap", ".goods-tag", function() {
             _size_item.push(_item);
         }
     })
-    // console.log(_sku_spec_map_index)
-    // console.log(_sku_spec_map[_sku_spec_map_index])
-    // console.log(_sku_data[_sku_spec_map[_sku_spec_map_index]].spec_img)
     set_checked_list();
     if (_size_item.length == $(".size-item").length) {
         _single_price = _sku_data[_sku_spec_map[_sku_spec_map_index]].goods_price;//$(this).attr("spec_goods_price");
@@ -1259,8 +1251,10 @@ $(".add-buycar").on("tap", function() {
         type: 'post',
         success: function(datas) {
             if (datas.result) {
+				$(".msg-total").show();
                 $(".msg-total").css("animation", "bounceOut 2s");
                 var num_car = $(".msg-total").html()*1 + $("#buy-num").val()*1;
+				console.log(num_car);
                 $(".msg-total").removeClass("mask-hidden");
                 $(".msg-total").html(num_car);
                 api.toast({ msg: datas.msg });
@@ -1391,20 +1385,25 @@ function touch() {
 function chkfavorite() {
     $(".msg-total").addClass("mask-hidden");
     $.ajax({
-        url: rooturl + '?do=chkfavorite',
+        url: siteurl + 'v2/goods/detail',
         data: {
-            goods_id: _keyid,
-            store_id: _storeid,
-            buyer_id: $api.getStorage("memberid")
+            goods_commonid: _keyid,
+            store_id: _storeid
         },
+        headers: { "X-TOKEN": $api.getStorage("accesstoken") },
         dataType: 'json',
         type: 'post',
         success: function(datas) {
-            if (datas.fav) {
+            if (datas.data) {
                 _isfavorite = true;
                 $("#favorite").attr("src", "../../image/favorite2.png");
             }
-            $(".msg-total").html(datas.cart);
+			if(datas.data.cart==0||!datas.data.cart){
+				$(".msg-total").empty();
+				$(".msg-total").hide();
+			}else{
+				$(".msg-total").html(datas.data.cart);
+			}
             $(".msg-total").removeClass("mask-hidden");
         }
     });