Просмотр исходного кода

购物车,立即购买跳转

chao 4 лет назад
Родитель
Сommit
f844859930

+ 1 - 1
src/main/resources/static/css/shopping/cart.css

@@ -83,7 +83,7 @@ li{list-style:none}
     .summaryWrap.fixed{position:fixed;bottom:0;left:0;margin:0;z-index:99999;box-shadow:20px 20px 102px rgba(0,0,0,0.1)}
     .pageTitle .step label.line{width: 50px;height: 1px;background: #707070;display: inline-block; margin: 0px 10px}
     .summaryWrap .summary .item .del{position:absolute;right:0;top:-20px;cursor:pointer;height:24px;font-size:14px}
-    .summaryWrap .summary .item .del em{position:absolute;top:-20px;height:24px;white-space:nowrap;right:0;background:#ff4500;line-height:24px;color:#FFF;padding:0 12px;border-radius:2px}
+    .summaryWrap .summary .item .del em{position:absolute;top:-12px;height:24px;white-space:nowrap;right:0;background:#ff4500;line-height:24px;color:#FFF;padding:0 12px;border-radius:2px}
     .summaryWrap .summary .item .del em:before{content:'';width:0;height:0;border-width:5px 5px 0 5px;border-style:solid;border-color:#ff4500 transparent;position:absolute;top:24px;left:50%}
 
 

+ 14 - 30
src/main/resources/static/js/product/detail.js

@@ -188,37 +188,21 @@ var productDetail = new Vue({
                                 _this.cartAlert = false;
                             }
                 })
-                // request.addCart(params,function (res) {
-                //         if(res.code==0){
-                //             _this.cartAlert = true;
-                //             _this.typedata = res.data;//商品种数
-                //         }else {
-                //
-                //             _this.cartAlert = false;
-                //         }
-                // })
-			},
-		buyShopCart:function(){//立即购买
-			    var _this = this;
-                var productid = _this.productId;
-                    allCount =  _this.number;
-                var confirmorder ={
-                        allPrice:_this.allTotalPrice,
-                        productID:productid,
-                        productCount:allCount,
-                        type:1
-                    };
-                   _util.setStorageItem('confirmGoodsInfo',JSON.stringify({data:confirmorder}));
-                    window.location.href = '/order/confirmOrder.jsp?type=1';
-			},
+		},
 		Continueshop:function(){ //继续购物
-			 var _this = this;
-			    _this.cartAlert = false;
-			     location.reload()
-			},
-			settlement:function(){//去结算
-			   window.location.href = "/shopping/cart.html"
-			},
+            var _this = this;
+            _this.cartAlert = false;
+             location.reload()
+        },
+        settlement:function(){//去结算
+           window.location.href = "/shopping/cart.html"
+        },
+        buyNowSubmit: function(){
+            if(this.productId && this.number){
+                // type:(1购物车提交[对应表cm_cart],2直接购买提交, 3协销下单)
+                window.location.href = '/shopping/confirm.html?type=2&id='+this.productId+'&count='+this.number;
+            }
+        },
         getRecommends: function(){
             var _self = this;
             if(!this.productId){return;}

+ 12 - 2
src/main/resources/static/js/shopping/cart.js

@@ -217,12 +217,22 @@ var shoppingCart = new Vue({
                 console.log(res);
             });
         },
-        deleteCart: function(cartId){
+        deleteCart: function(productIds){
+            var _self = this;
             alertInfo("确定要删除该商品?",function(){
                 // 删除逻辑
-                alert("test")
+                tokenAjax("post", "/shoppingCart/delete", {
+                    userID: _self.userId,
+                    productIDs: productIds
+                },function (res) {
+                    window.location.reload();
+                });
             })
         },
+        deleteSelected: function(){
+            var productIds = this.submitIds.join(",");
+            this.deleteCart(productIds);
+        },
         submitCart: function(){
             if (this.submitIds.length>0){
                 var productIds = this.submitIds.join(",");

+ 9 - 0
src/main/resources/static/js/shopping/confirm.js

@@ -57,6 +57,15 @@ var shoppingCart = new Vue({
                 var productIds = window.localStorage.getItem("shoppingProductIds");
                 // 获取列表数据
                 this.getConfirmList(productIds, null);
+            }else if(this.type === 2){
+                var productId = getUrlParam("id");
+                var count = getUrlParam("count");
+                if(productId && count) {
+                    // 获取列表数据
+                    this.getConfirmList(productId, count);
+                }else{
+                    alertInfo("参数错误,请重新提交订单!");
+                }
             }
         }
     },

+ 4 - 4
src/main/resources/templates/product/detail.html

@@ -151,12 +151,12 @@
                     </div>
                 </div>
                <template v-if="userId && userId>0">
-               <div  class="btnBox" v-if="priceFlag==2 && userIdentity!=2">
-                  <a class="upgrade" @click="clubupgrade" href="javascript:0">升级会员查看价格</a>
-               </div>
+                   <div  class="btnBox" v-if="priceFlag==2 && userIdentity!=2">
+                      <a class="upgrade" @click="clubupgrade" href="javascript:0">升级会员查看价格</a>
+                   </div>
                     <div class="btnBox" v-else-if="priceFlag==0">
                         <a href="javascript:void(0);" class="cart icon" @click='addShopCart'>加入购物车</a>
-                        <a href="javascript:void(0);" class="buy" @click="buyShopCart">立即购买</a>
+                        <a href="javascript:void(0);" class="buy" @click="buyNowSubmit()">立即购买</a>
                     </div>
                 </template>
                 <template v-else>

+ 2 - 2
src/main/resources/templates/shopping/cart.html

@@ -152,7 +152,7 @@
                         </span>
                         <input type="hidden" :value="cart.step"></div>
                         <div v-if="isPC" class="c6"><span v-text="'¥'+toFloat(cart.price*cart.number)"></span></div>
-                        <div v-if="isPC" class="c7"><span class="del" @click="deleteCart(cart.id)">×<em class="tips">删除</em></span></div>
+                        <div v-if="isPC" class="c7"><span class="del" @click="deleteCart(cart.productId)">×<em class="tips">删除</em></span></div>
                     </div>
                 <div class="supplierBtn">
                     <span>合计:<em v-text="'¥'+toFloat(supplier.totalPrice)"></em></span>
@@ -192,7 +192,7 @@
                 <div class="item">
                     <input class="check" type="checkbox" @change="ckeckAll()" v-model="allChecked">
                     <span>全选</span>
-                    <a class="delete" href="javascript:void(0);">删除</a>
+                    <a class="delete" href="javascript:void(0);" @click="deleteSelected()">删除</a>
                 </div>
                 <div class="item">商品种类:<em v-text="kindCount"></em></div>
                 <div class="item">商品数量:<em v-text="totalCount"></em></div>