|
|
@@ -92,6 +92,7 @@ var app = new Vue({
|
|
|
},
|
|
|
},
|
|
|
created: function () {
|
|
|
+ var _this = this
|
|
|
var reset = getParam('rs');
|
|
|
var slideIndex = sessionStorage.getItem('slideIndex');
|
|
|
var total = sessionStorage.getItem('total');
|
|
|
@@ -111,7 +112,9 @@ var app = new Vue({
|
|
|
this.getDataList(false);
|
|
|
}
|
|
|
|
|
|
- this.getMeal();
|
|
|
+ setTimeout(function(){
|
|
|
+ _this.getMeal();
|
|
|
+ }, 300)
|
|
|
this.getInfo();
|
|
|
this.getTopList();
|
|
|
this.getParams();
|
|
|
@@ -464,91 +467,94 @@ var app = new Vue({
|
|
|
},
|
|
|
initSwiper: function(){
|
|
|
var _this = this;
|
|
|
- // this.$nextTick(()=>{
|
|
|
+ // $(".box").css('height', $(window).clientHeight - 134+'px')
|
|
|
+ this.$nextTick(()=>{
|
|
|
console.log(65)
|
|
|
console.log(_this.dataList)
|
|
|
- if(_this.swiper || _this.dataList.length<=0){
|
|
|
- return false;
|
|
|
- }
|
|
|
- console.log(_this.slideIndex+'+dd+')
|
|
|
- // 单身推荐列表
|
|
|
- _this.swiper = new Swiper('.hearts', {
|
|
|
- loop: false, // 循环模式选项
|
|
|
- autoplay: false,
|
|
|
- speed: 100,
|
|
|
- direction : 'vertical',
|
|
|
- initialSlide: _this.slideIndex,// 默认显示
|
|
|
- freeMode : true,//是否滑动
|
|
|
- observer: true,//修改swiper自己或子元素时,自动初始化swiper
|
|
|
- observeParents: true,//修改swiper的父元素时,自动初始化swiper
|
|
|
- slidesPerView: 'auto',
|
|
|
-
|
|
|
- onSlideChangeEnd: function(swiper) {
|
|
|
- swiper.update();
|
|
|
- swiper.startAutoplay();
|
|
|
- swiper.reLoop();
|
|
|
- },
|
|
|
+ setTimeout(function (){
|
|
|
+ if(_this.swiper || _this.dataList.length<=0){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ console.log(_this.slideIndex+'+dd+')
|
|
|
+ // 单身推荐列表
|
|
|
+ _this.swiper = new Swiper('.hearts', {
|
|
|
+ loop: false, // 循环模式选项
|
|
|
+ autoplay: false,
|
|
|
+ speed: 100,
|
|
|
+ direction : 'vertical',
|
|
|
+ initialSlide: _this.slideIndex,// 默认显示
|
|
|
+ freeMode : true,//是否滑动
|
|
|
+ observer: true,//修改swiper自己或子元素时,自动初始化swiper
|
|
|
+ observeParents: true,//修改swiper的父元素时,自动初始化swiper
|
|
|
+ slidesPerView: 'auto',
|
|
|
+
|
|
|
+ onSlideChangeEnd: function(swiper) {
|
|
|
+ swiper.update();
|
|
|
+ swiper.startAutoplay();
|
|
|
+ swiper.reLoop();
|
|
|
+ },
|
|
|
|
|
|
on: {
|
|
|
- slideChange:function(event){
|
|
|
- if(_this.switchStatus){
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- _this.switchStatus = true;
|
|
|
- let count = _this.dataList.length-1
|
|
|
- let swipeDirection = typeof(this.swipeDirection) != 'undefined'? this.swipeDirection : '';
|
|
|
- if(!swipeDirection){
|
|
|
- console.log('未触发'+this.swipeDirection)
|
|
|
- _this.switchStatus = false;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- if(swipeDirection == 'next'){
|
|
|
- console.log(_this.total+'++'+count+'++'+_this.slideIndex)
|
|
|
- if(this.realIndex >= count || _this.slideIndex>=count){
|
|
|
- if(_this.total >= (_this.params.page+1*_this.params.pageSize) && !_this.loadSlide){
|
|
|
+ slideChange:function(event){
|
|
|
+ if(_this.switchStatus){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ _this.switchStatus = true;
|
|
|
+ let count = _this.dataList.length-1
|
|
|
+ let swipeDirection = typeof(this.swipeDirection) != 'undefined'? this.swipeDirection : '';
|
|
|
+ if(!swipeDirection){
|
|
|
+ console.log('未触发'+this.swipeDirection)
|
|
|
+ _this.switchStatus = false;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(swipeDirection == 'next'){
|
|
|
+ console.log(_this.total+'++'+count+'++'+_this.slideIndex)
|
|
|
+ if(this.realIndex >= count || _this.slideIndex>=count){
|
|
|
+ if(_this.total >= (_this.params.page+1*_this.params.pageSize) && !_this.loadSlide){
|
|
|
+ _this.switchStatus = false;
|
|
|
+ _this.loadSlide = true;
|
|
|
+ _this.slideIndex++;
|
|
|
+ console.log(_this.slideIndex+'+++')
|
|
|
+ sessionStorage.setItem('slideIndex', _this.slideIndex);
|
|
|
+ sessionStorage.setItem('dataList', null);
|
|
|
+
|
|
|
+ _this.params.page++;
|
|
|
+ console.log(_this.dataList)
|
|
|
+ _this.getDataList(true)
|
|
|
+ }
|
|
|
_this.switchStatus = false;
|
|
|
- _this.loadSlide = true;
|
|
|
+ return false;
|
|
|
+ }else if(count>0){
|
|
|
_this.slideIndex++;
|
|
|
- console.log(_this.slideIndex+'+++')
|
|
|
sessionStorage.setItem('slideIndex', _this.slideIndex);
|
|
|
- sessionStorage.setItem('dataList', null);
|
|
|
-
|
|
|
- _this.params.page++;
|
|
|
- console.log(_this.dataList)
|
|
|
- _this.getDataList(true)
|
|
|
+ this.slideTo(_this.slideIndex)
|
|
|
+ _this.switchStatus = false;
|
|
|
}
|
|
|
- _this.switchStatus = false;
|
|
|
- return false;
|
|
|
- }else if(count>0){
|
|
|
- _this.slideIndex++;
|
|
|
+ }else{
|
|
|
+ if(this.realIndex <=0 || _this.slideIndex<=0){
|
|
|
+ _this.slideIndex = 0;
|
|
|
+ }else{
|
|
|
+ _this.slideIndex = _this.slideIndex-1<=0? 0 : _this.slideIndex-1;
|
|
|
+ }
|
|
|
+ console.log('记录')
|
|
|
+ _this.slideIndex = this.realIndex
|
|
|
sessionStorage.setItem('slideIndex', _this.slideIndex);
|
|
|
this.slideTo(_this.slideIndex)
|
|
|
_this.switchStatus = false;
|
|
|
}
|
|
|
- }else{
|
|
|
- if(this.realIndex <=0 || _this.slideIndex<=0){
|
|
|
- _this.slideIndex = 0;
|
|
|
- }else{
|
|
|
- _this.slideIndex = _this.slideIndex-1<=0? 0 : _this.slideIndex-1;
|
|
|
- }
|
|
|
- console.log('记录')
|
|
|
- _this.slideIndex = this.realIndex
|
|
|
- sessionStorage.setItem('slideIndex', _this.slideIndex);
|
|
|
- this.slideTo(_this.slideIndex)
|
|
|
- _this.switchStatus = false;
|
|
|
- }
|
|
|
- console.log('触摸停止');
|
|
|
- console.log(this.swipeDirection)
|
|
|
+ console.log('触摸停止');
|
|
|
+ console.log(this.swipeDirection)
|
|
|
+ },
|
|
|
},
|
|
|
- },
|
|
|
- })
|
|
|
+ })
|
|
|
|
|
|
- if(_this.slideIndex>0){
|
|
|
- _this.swiper.slideTo(_this.slideIndex)
|
|
|
- }
|
|
|
- // })
|
|
|
+ if(_this.slideIndex>0){
|
|
|
+ _this.swiper.slideTo(_this.slideIndex)
|
|
|
+ }
|
|
|
+ }, 50)
|
|
|
+ })
|
|
|
|
|
|
// 懒加载
|
|
|
//this.lazyload();
|