Sfoglia il codice sorgente

修复轮播图bug

yuwenjun 4 anni fa
parent
commit
df821b6239
1 ha cambiato i file con 90 aggiunte e 78 eliminazioni
  1. 90 78
      src/main/resources/static/js/activity/activityTopic.js

+ 90 - 78
src/main/resources/static/js/activity/activityTopic.js

@@ -109,91 +109,97 @@ var activity = new Vue({
         initFloorListPc: function (floorList) {
             var _that = this
             floorList.forEach(function (list) {
-                var tempType = list.floorContent.templateType
-                switch (tempType) {
-                    case '1':
-                        list.floorImageList = _that.swiperDataFormat(
-                            list.floorImageList,
-                            12
-                        )
-                        break
-                    case '2':
-                    case '6':
-                        list.floorImageList = _that.swiperDataFormat(list.floorImageList, 6)
-                        break
-                    case '3':
-                    case '9':
-                        list.floorImageList = _that.swiperDataFormat(list.floorImageList, 4)
-                        break
-                    case '11':
-                    case '12':
-                    case '13':
-                    case '15':
-                    case '17':
-                    case '19':
-                    case '20':
-                        list.floorImageList.length > 5 && (list.isPageMore = true)
-                        break
-                    case '14':
-                        list.floorImageList.length > 10 && (list.isPageMore = true)
-                        break
-                    case '16':
-                    case '18':
-                        list.floorImageList.length > 7 && (list.isPageMore = true)
-                        break
-                    default:
-                        break
+                if (list.floorContent) {
+
+                    var tempType = list.floorContent.templateType
+                    switch (tempType) {
+                        case '1':
+                            list.floorImageList = _that.swiperDataFormat(
+                                list.floorImageList,
+                                12
+                            )
+                            break
+                        case '2':
+                        case '6':
+                            list.floorImageList = _that.swiperDataFormat(list.floorImageList, 6)
+                            break
+                        case '3':
+                        case '9':
+                            list.floorImageList = _that.swiperDataFormat(list.floorImageList, 4)
+                            break
+                        case '11':
+                        case '12':
+                        case '13':
+                        case '15':
+                        case '17':
+                        case '19':
+                        case '20':
+                            list.floorImageList.length > 5 && (list.isPageMore = true)
+                            break
+                        case '14':
+                            list.floorImageList.length > 10 && (list.isPageMore = true)
+                            break
+                        case '16':
+                        case '18':
+                            list.floorImageList.length > 7 && (list.isPageMore = true)
+                            break
+                        default:
+                            break
+                    }
                 }
+
             })
         },
         // 移动端楼层数据处理
         initFloorListMobile: function (floorList) {
             var _that = this
             floorList.forEach(function (list) {
-                var tempType = list.floorContent.templateType
-                switch (tempType) {
-                    case '1':
-                        list.floorImageList = _that.swiperDataFormat(list.floorImageList, 8)
-                        break
-                    case '2':
-                        list.floorImageList = _that.swiperDataFormat(list.floorImageList, 6)
-                        break
-                    case '9':
-                        list.floorImageList.length > 2 && (list.isPageMore = true)
-                        list.floorImageList = _that.swiperDataFormat(list.floorImageList, 4)
-                        break
-                    case '21':
-                        list.floorImageList = _that.swiperDataFormat(list.floorImageList, 4)
-                        break
-                    case '3':
-                    case '6':
-                        list.floorImageList.length > 4 && (list.isPageMore = true)
-                        break
-                    case '4':
-                    case '8':
-                        list.floorImageList.length > 2 && (list.isPageMore = true)
-                        break
-                    case '10':
-                        list.floorImageList.length > 1 && (list.isPageMore = true)
-                        break
-                    case '11':
-                    case '12':
-                    case '13':
-                    case '15':
-                        list.floorImageList.length > 2 && (list.isPageMore = true)
-                        break
-                    case '14':
-                    case '19':
-                    case '20':
-                        list.floorImageList.length > 4 && (list.isPageMore = true)
-                        break
-                    case '16':
-                    case '17':
-                    case '18':
-                        list.floorImageList.length > 3 && (list.isPageMore = true)
-                        break
-                    default:
-                        break
+                if (list.floorContent) {
+                    var tempType = list.floorContent.templateType
+                    switch (tempType) {
+                        case '1':
+                            list.floorImageList = _that.swiperDataFormat(list.floorImageList, 8)
+                            break
+                        case '2':
+                            list.floorImageList = _that.swiperDataFormat(list.floorImageList, 6)
+                            break
+                        case '9':
+                            list.floorImageList.length > 2 && (list.isPageMore = true)
+                            list.floorImageList = _that.swiperDataFormat(list.floorImageList, 4)
+                            break
+                        case '21':
+                            list.floorImageList = _that.swiperDataFormat(list.floorImageList, 4)
+                            break
+                        case '3':
+                        case '6':
+                            list.floorImageList.length > 4 && (list.isPageMore = true)
+                            break
+                        case '4':
+                        case '8':
+                            list.floorImageList.length > 2 && (list.isPageMore = true)
+                            break
+                        case '10':
+                            list.floorImageList.length > 1 && (list.isPageMore = true)
+                            break
+                        case '11':
+                        case '12':
+                        case '13':
+                        case '15':
+                            list.floorImageList.length > 2 && (list.isPageMore = true)
+                            break
+                        case '14':
+                        case '19':
+                        case '20':
+                            list.floorImageList.length > 4 && (list.isPageMore = true)
+                            break
+                        case '16':
+                        case '17':
+                        case '18':
+                            list.floorImageList.length > 3 && (list.isPageMore = true)
+                            break
+                        default:
+                            break
+                    }
                 }
             })
         },
@@ -277,6 +283,11 @@ var activity = new Vue({
                         slidesPerGroup: 5,
                         spaceBetween: 16,
                     }
+                    if(slides <= 5){
+                        myOption1.autoplay=false;
+                        option.loop = false;
+                        myOption1.pagination = false;
+                    }
                     Object.assign(option, myOption2);
                 }
                 Object.assign(option, myOption1);
@@ -388,6 +399,7 @@ var activity = new Vue({
                         btns.next = '.' + btnList[1].classList[2];
                     }
                     if (swiperTemps.indexOf(tempType) !== -1) {
+                        console.log(tempType)
                         _that.swiperStyle(tempType, swiperEl, btns)();
                     }
                 });