created () {
Vue.prototype.$http.get('/api/goods')
.then(res => {
this.goods = res.data.data;
this.$nextTick(() => {//
this._initScroll();
this._calculateHeight();
});
});
this.classMap = ['decrease', 'discount', 'special', 'invoice', 'guarantee'];
},
methods: {
selectMenu (index, event) {
if (!event._constructed) {
return;
}
let foodList = this.$refs.foodsWrap.getElementsByClassName('food-list-hook');
let el = foodList[index];
this.foodsScroll.scrollToElement(el, 300);
},
_initScroll () {
this.menuScroll = new BScroll(this.$refs.menuWrap, {
click: true
});
this.foodsScroll = new BScroll(this.$refs.foodsWrap, {probeType: 3
});
this.foodsScroll.on('scroll', (pos) => {
this.scrollY = Math.abs(Math.round(pos.y));
console.log(this.scrollY);
});
},
_calculateHeight () {
let foodList = this.$refs.foodsWrap.getElementsByClassName('food-list-hook');
let height = 0;
this.listHeight.push(height);
for (let i = 0; i < foodList.length; i++) {
let item = foodList[i];
height += item.clientHeight;
this.listHeight.push(height);
}
}
}
};
</script>










