Browse Source

优惠券

zhengjinyi 3 years ago
parent
commit
78ec4fec6c

+ 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 - 15
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,18 +375,5 @@ var homeData = new Vue({
         // $('#advertising').on('click','.close',function () {
         //     $(this).parents('.item').hide();
         // });
-        // var isActivityStatus =  localStorage.getItem('isActivityStatus');
-        if(GLOBAL_USER_ID>0){
-            var isActivityStatus =  true;
-            //新加优惠券弹窗
-            if(isActivityStatus){
-                var  lockTime = localStorage.getItem('lockTime');
-                _this.popupFlag = this.diffTime(lockTime);
-            }else{
-                setTimeout(function () {
-                    _this.popupFlag = true;
-                },1000);
-            }
-        }
     }
 });