|
|
@ -6,7 +6,7 @@ |
|
|
<div class="content"> |
|
|
<div class="content"> |
|
|
<div class="left" ref="menuWrapper"> |
|
|
<div class="left" ref="menuWrapper"> |
|
|
<ul> |
|
|
<ul> |
|
|
<li v-if="goodsList.length != 0" v-for="(item,index) in goodsList" :key="index" :class="{'on': currentIndex === index}" @click="selectMenu(index,$event)"> |
|
|
|
|
|
|
|
|
<li v-if="goodsList.length != 0" :class="{'on': (currentIndex < 0 ? 0 : currentIndex) === index}" v-for="(item,index) in goodsList" :key="index" @click="selectMenu(index,$event)"> |
|
|
<a href="javascript:void(0)"> |
|
|
<a href="javascript:void(0)"> |
|
|
{{item.combinationName}} |
|
|
{{item.combinationName}} |
|
|
<img src="../assets/images/icon/hot.png" class="i-hot" v-if="item.label == '2'" /> |
|
|
<img src="../assets/images/icon/hot.png" class="i-hot" v-if="item.label == '2'" /> |
|
|
@ -62,22 +62,30 @@ |
|
|
imghost: "http://medou.oss-cn-shenzhen.aliyuncs.com/", |
|
|
imghost: "http://medou.oss-cn-shenzhen.aliyuncs.com/", |
|
|
listHeight: [], //存储区块的高度 |
|
|
listHeight: [], //存储区块的高度 |
|
|
scrollY: {}, |
|
|
scrollY: {}, |
|
|
|
|
|
clickTrue: false, |
|
|
currentNum: 0 |
|
|
currentNum: 0 |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
computed: { |
|
|
computed: { |
|
|
/*currentIndex () { |
|
|
|
|
|
const { scrollY, listHeight } = this |
|
|
|
|
|
|
|
|
currentIndex () { |
|
|
|
|
|
const { scrollY, listHeight, clickTrue, currentNum } = this |
|
|
let index = listHeight.findIndex((height, index) => { |
|
|
let index = listHeight.findIndex((height, index) => { |
|
|
return scrollY >= listHeight[index] && scrollY < listHeight[index + 1] |
|
|
return scrollY >= listHeight[index] && scrollY < listHeight[index + 1] |
|
|
}) |
|
|
}) |
|
|
if (scrollY > listHeight[index] + 50) { |
|
|
if (scrollY > listHeight[index] + 50) { |
|
|
index++ |
|
|
index++ |
|
|
} |
|
|
} |
|
|
|
|
|
if(listHeight[listHeight.length-1] - this.$refs.foodWrapper.clientHeight <= scrollY ) { |
|
|
|
|
|
if(clickTrue) { |
|
|
|
|
|
return currentNum |
|
|
|
|
|
} else { |
|
|
|
|
|
return (listHeight.length-1) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
return index |
|
|
return index |
|
|
}*/ |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
currentIndex(){ |
|
|
|
|
|
|
|
|
/*currentIndex() { |
|
|
for (let i = 0; i < this.listHeight.length; i++){ |
|
|
for (let i = 0; i < this.listHeight.length; i++){ |
|
|
let height = this.listHeight[i] |
|
|
let height = this.listHeight[i] |
|
|
let height2 = this.listHeight[i + 1] |
|
|
let height2 = this.listHeight[i + 1] |
|
|
@ -95,7 +103,7 @@ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return 0 |
|
|
return 0 |
|
|
} |
|
|
|
|
|
|
|
|
}*/ |
|
|
}, |
|
|
}, |
|
|
components: { |
|
|
components: { |
|
|
Toast, |
|
|
Toast, |
|
|
@ -129,13 +137,20 @@ |
|
|
that.showLoading = false |
|
|
that.showLoading = false |
|
|
if ( res.code == 0 ){ |
|
|
if ( res.code == 0 ){ |
|
|
this.goodsList = res.data || [] |
|
|
this.goodsList = res.data || [] |
|
|
|
|
|
let list = [] |
|
|
|
|
|
for (var i = 0; i < this.goodsList.length; i++) { |
|
|
|
|
|
if (this.goodsList[i].goodsList.length != 0) { |
|
|
|
|
|
list.push(this.goodsList[i]) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
this.goodsList = list |
|
|
this.$nextTick(function(){ |
|
|
this.$nextTick(function(){ |
|
|
//调用scroll函数,实现滚动 |
|
|
//调用scroll函数,实现滚动 |
|
|
this._initScroll() |
|
|
this._initScroll() |
|
|
//拿到数据以后计算高度 |
|
|
//拿到数据以后计算高度 |
|
|
this._calculateHeight(); |
|
|
this._calculateHeight(); |
|
|
// 自动选中 |
|
|
// 自动选中 |
|
|
this.autoSelect() |
|
|
|
|
|
|
|
|
this.autoSelect(list, this.c_no) |
|
|
}) |
|
|
}) |
|
|
} else { |
|
|
} else { |
|
|
this.$vux.toast.text(res.msg,"middle"); |
|
|
this.$vux.toast.text(res.msg,"middle"); |
|
|
@ -182,24 +197,25 @@ |
|
|
this.foodsScroll.scrollToElement(el,300) |
|
|
this.foodsScroll.scrollToElement(el,300) |
|
|
},*/ |
|
|
},*/ |
|
|
selectMenu(index, event){ |
|
|
selectMenu(index, event){ |
|
|
this.clickTrue = true //触发过剑姬事件之后,clickTrue的值变为true |
|
|
|
|
|
|
|
|
this.clickTrue = true //触发过事件之后,clickTrue的值变为true |
|
|
this.currentNum = index |
|
|
this.currentNum = index |
|
|
|
|
|
|
|
|
//在better-scroll的派发事件的event和普通浏览器的点击事件event有个属性区别_constructed |
|
|
//在better-scroll的派发事件的event和普通浏览器的点击事件event有个属性区别_constructed |
|
|
// 浏览器原生点击事件没有_constructed所以当时浏览器监听到该属性的时候return掉 |
|
|
// 浏览器原生点击事件没有_constructed所以当时浏览器监听到该属性的时候return掉 |
|
|
if (event && !event._constructed){ |
|
|
if (event && !event._constructed){ |
|
|
return |
|
|
return |
|
|
} else { |
|
|
} else { |
|
|
let foodList = this.$refs.foodWrapper.getElementsByClassName("food-list-hook"); |
|
|
|
|
|
|
|
|
let foodList = this.$refs.foodWrapper.getElementsByClassName("food-list-hook"); |
|
|
let el = foodList[index]; |
|
|
let el = foodList[index]; |
|
|
this.foodsScroll.scrollToElement(el,300) |
|
|
this.foodsScroll.scrollToElement(el,300) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
autoSelect() { |
|
|
|
|
|
for (let i = 0; i < this.goodsList.length; i++) { |
|
|
|
|
|
if(this.goodsList[i].combinationNo == this.c_no) { |
|
|
|
|
|
|
|
|
autoSelect(list, no) { |
|
|
|
|
|
list.forEach((v, i, a) => { |
|
|
|
|
|
if(v.combinationNo === no) { |
|
|
this.selectMenu(i) |
|
|
this.selectMenu(i) |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}) |
|
|
}, |
|
|
}, |
|
|
ShareWenXin (){ |
|
|
ShareWenXin (){ |
|
|
var merchantNo = this.no |
|
|
var merchantNo = this.no |
|
|
|