Browse Source

Merge remote-tracking branch 'origin/developerB' into developerB

喻文俊 3 years ago
parent
commit
48ddf4bb8d

+ 12 - 4
src/main/resources/static/js/common/serviceapi/utils.service.js

@@ -27,10 +27,6 @@ var PublicApi = {
                 });
         },
         GetHomeData:function(params,callback){ //首页数据
-            // Http.AjaxService({ url:'/home/data', type:'get', data:params, json:false})
-            //     .then(function(res){
-            //         callback(res)
-            //     });
             Http.AjaxService({
                 url:'/commodity/home/floor',
                 type:'get',
@@ -42,6 +38,18 @@ var PublicApi = {
                 callback(res)
             });
         },
+        GetHomeInit:function(params,callback){ //首页数据
+            Http.AjaxService({
+                url:'/commodity/home/init',
+                type:'get',
+                data:params,
+                json:false,
+                isHost:true
+            })
+            .then(function(res){
+                callback(res)
+            });
+        },
         GetHomeBanner:function(params,callback){ //首页bnner
             Http.AjaxService({
                 url:'/home/banner',

+ 25 - 13
src/main/resources/static/js/index.js

@@ -9,6 +9,7 @@ var homeData = new Vue({
         cmImageList:[],//右侧活动模块
         infoList:[],//右侧文章模块
         popupFlag:false,
+        couponEntry:2,// 活动优惠券弹窗显示控制
         homePageFloor:[]//楼层
     },
     filters: {
@@ -17,7 +18,6 @@ var homeData = new Vue({
         },
     },
     methods: {
-
         popupPage:function(){  // 弹窗点击跳转链接
             var _self = this;
             this.popupFlag=false;
@@ -72,7 +72,29 @@ var homeData = new Vue({
                 }
             },300);
         },
-        GetHomeRightData: function(){
+        GetHomeInit: function(){// 初始化
+            var _self = this;
+            PublicApi.GetHomeInit({ source: 1 },function(response){
+                if(response.code == 0){
+                    _self.couponEntry = response.data.couponEntry
+                    console.log('couponEntry', _self.couponEntry)
+                    console.log('GLOBAL_USER_ID', GLOBAL_USER_ID)
+                    if(GLOBAL_USER_ID == 0 &&_self.couponEntry == 1){
+                        var isActivityStatus =  localStorage.getItem('isActivityStatus');
+                        //新加优惠券弹窗
+                        if(isActivityStatus){
+                            var  lockTime = localStorage.getItem('lockTime');
+                            _self.popupFlag = this.diffTime(lockTime);
+                        }else{
+                            setTimeout(function () {
+                                _self.popupFlag = true;
+                            },1000);
+                        }
+                    }
+                }
+            });
+        },
+        GetHomeRightData: function(){//模块加载
             var _self = this;
             PublicApi.GetHomeRightData({ source: 1 },function(response){
                 if(response.code == 0){
@@ -293,6 +315,7 @@ var homeData = new Vue({
             this.setAsideNav();
             // 推荐专区商品轮播
             this.swiperFloor();
+            this.GetHomeInit();
         }
         // Dom加载后
         this.$nextTick(function(){
@@ -352,16 +375,5 @@ var homeData = new Vue({
         // $('#advertising').on('click','.close',function () {
         //     $(this).parents('.item').hide();
         // });
-        // var isActivityStatus =  localStorage.getItem('isActivityStatus');
-        var isActivityStatus =  true;
-        //新加优惠券弹窗
-        if(isActivityStatus){
-            var  lockTime = localStorage.getItem('lockTime');
-            _this.popupFlag = this.diffTime(lockTime);
-        }else{
-            setTimeout(function () {
-                 _this.popupFlag = true;
-            },1000);
-        }
     }
 });

+ 7 - 13
src/main/resources/static/js/shopping/cart.js

@@ -255,7 +255,7 @@ var shoppingCart = new Vue({
                 }
                 // 最后满减金额 = 店铺减去金额 + 单品减去金额 + 凑单减去金额
                 _self.totalDiscountAmount = _self.reducedPrice + _self.couponPrice;
-                console.log('totalDiscountAmount',_self.totalDiscountAmount);
+                console.log('最终优惠金额',_self.totalDiscountAmount);
                 // 控制显示优惠明细
                 if(_self.totalDiscountAmount > 0 ){
                     _self.isDiscount = true;
@@ -275,12 +275,12 @@ var shoppingCart = new Vue({
                                 case 0:// 活动券
                                     if(coupon.productType == 1){// 活动券-全商城商品
                                         if(_self.totalPrice >= coupon.touchPrice){
-                                            eligibleCoupons = _self.setCouponsArr(coupon)
+                                            eligibleCoupons.push(coupon)
                                         }
                                     }else if(coupon.productType == 2){// 活动券-指定商品
                                         if(coupon.productIds && coupon.productIds.includes(pros.productId)){
                                             if(_self.totalPrice >= coupon.touchPrice){
-                                                eligibleCoupons = _self.setCouponsArr(coupon)
+                                                eligibleCoupons.push(coupon)
                                             }
                                         }
                                     }
@@ -288,25 +288,25 @@ var shoppingCart = new Vue({
                                 case 1:// 品类券适用于产品或者仪器 categoryType(commodityType) : 1 产品  2 仪器
                                     if( coupon.categoryType && coupon.categoryType == pros.commodityType){
                                         if(_self.totalPrice >= coupon.touchPrice){
-                                            eligibleCoupons = _self.setCouponsArr(coupon)
+                                            eligibleCoupons.push(coupon)
                                         }
                                     }
                                     break;
                                 case 2:// 用户专享券 适用于商城全部商品
                                     if(_self.totalPrice >= coupon.touchPrice){
-                                        eligibleCoupons = _self.setCouponsArr(coupon)
+                                        eligibleCoupons.push(coupon)
                                     }
                                     break;
                                 case 3:// 店铺券适用于某个供应商的全部商品
                                     if(coupon.shopId && pros.supplierId == coupon.shopId){
                                         if(_self.totalPrice >= coupon.touchPrice){
-                                            eligibleCoupons = _self.setCouponsArr(coupon)
+                                            eligibleCoupons.push(coupon)
                                         }
                                     }
                                     break;
                                 case 4://新用户券 适用于商城全部商品
                                     if(_self.totalPrice >= coupon.touchPrice){
-                                        eligibleCoupons = _self.setCouponsArr(coupon)
+                                        eligibleCoupons.push(coupon)
                                     }
                                     break;
                             }
@@ -318,12 +318,6 @@ var shoppingCart = new Vue({
             })
             return eligibleCoupons;
         },
-        setCouponsArr: function(coupon){//处理
-            var list = [];
-            list.push(coupon)
-            list.sort((a,b)=> b.couponAmount - a.couponAmount )
-            return list
-        },
         cartNumberSub: function(cart){
             cart.number -= cart.step;
             if (cart.number<cart.min){

+ 0 - 1
src/main/resources/templates/index.html

@@ -290,7 +290,6 @@
                                                             <!-- 正常商品 -->
                                                             <th:block th:if="*{productCategory}==1">
                                                                 <div class="price_text_tag">
-                                                                    <p class="couponTag" th:if="*{couponsLogo}">优惠券</p>
                                                                     <p class="listTag" th:if="*{actStatus}==1 and ${pros.get('product').get('promotions')}!=null">
                                                                         <template th:text="*{promotions.name}"></template>
                                                                         <th:block th:if="*{promotions.type}==1 and *{promotions.mode}==1">