Browse Source

商品收藏

zhengjinyi 3 years ago
parent
commit
6c076263f8

+ 17 - 0
src/main/resources/static/js/common/serviceapi/shopping.service.js

@@ -86,5 +86,22 @@ var ShoppingApi = {
             .then(function(res){
                 callback(res);
             });
+        },
+        /**
+         * @购物车-批量加入购物车
+         * @param:userID 用户userId
+         * @param:productID 商品Id
+         * @param:productCount 商品数量
+         */
+        ShoppingAddCarts:function (params, callback) {
+            Http.AjaxService({
+                url:'/shoppingCart/addCarts',
+                type:'post',
+                data:params,
+                json:false
+            })
+            .then(function(res){
+                callback(res);
+            });
         }
 };

+ 39 - 4
src/main/resources/static/js/user-center/collection/collection.js

@@ -74,7 +74,6 @@ var orderPage = new Vue({
                     }else{
                         _self.listData = _self.listData.concat(list);
                     }
-                    console.log('listData',_self.listData)
                     setTimeout(function(){
                         // 图片懒加载
                         $("img[data-original]").lazyload();
@@ -96,13 +95,13 @@ var orderPage = new Vue({
             }
             return false
         },
-        shoppingCart:function (pros) {
+        shoppingCart:function (pros) {// 加入购物车
             var _self = this;
             ShoppingApi.ShoppingAddCart(
                 {
                     userID:_self.listQuery.userId,
                     productID:pros.productId,
-                    productCount:1
+                    productCount:pros.minBuyNumber
                 },
                 function (response) {
                     if(response.code === 0){
@@ -148,10 +147,46 @@ var orderPage = new Vue({
         },
         hanldAllAddCart:function () {// 批量加入购物车
             var _self = this;
+            var checkedList = [];
             if(!_self.isProductChecked){
                 CAIMEI.dialog('请先选择商品',false);
             }
-            _self.productIds = _self.checkedList.join(",")
+            _self.listData.forEach((el)=>{
+                if(el.isChecked){
+                    checkedList.push(el.productId);
+                }
+            })
+            ShoppingApi.ShoppingAddCarts({userId:_self.listQuery.userId,productIds:checkedList.join(",")},function(response){
+                if(response.code === 0){
+                    globalHead.getHeadCart(_self.listQuery.userId);
+                    $.confirm({
+                        useBootstrap: false,
+                        boxWidth: (isPC?'338px':'74.6vw'),
+                        title: false,
+                        content:'<div class="cartAlert"><h6>商品已成功加入购物车!</h6><p>当前购物车共<em>'+response.data+'</em>种商品</p></div>',
+                        closeIcon: true,
+                        animation: 'opacity',
+                        closeAnimation: 'opacity',
+                        animateFromElement: false,
+                        scrollToPreviousElement: false,
+                        buttons: {
+                            login: {
+                                text: '去结算',
+                                btnClass: 'btn-to-cart',
+                                action: function(){
+                                    window.location.href = '/shopping/cart.html';
+                                }
+                            },
+                            close: {
+                                text: '继续购物',
+                                btnClass: 'btn-to-goon'
+                            }
+                        }
+                    });
+                } else {
+                    dialog("加入购物车失败!");
+                }
+            })
         },
         hanldCancel:function (pros) {// 取消收藏
             var _self = this;

+ 3 - 3
src/main/resources/templates/supplier/index.html

@@ -18,9 +18,9 @@
         <div id="supplierBanner" class="swiper-container">
             <ul class="swiper-wrapper">
             <template v-if="supplierBanner.length>0">
-                <li class="swiper-slide mfc" v-for="imgUrl in supplierBanner">
-                    <a href="">
-                        <img src="/img/base/placeholder.png" :data-original="imgUrl">
+                <li class="swiper-slide mfc" v-for="banner in supplierBanner">
+                    <a :href="banner.link" target="_blank">
+                        <img src="/img/base/placeholder.png" :data-original="banner.image">
                     </a>
                 </li>
             </template>