diff --git a/src/view/goods-classify.vue b/src/view/goods-classify.vue
index 20bf3d6..eb3b0ac 100644
--- a/src/view/goods-classify.vue
+++ b/src/view/goods-classify.vue
@@ -6,7 +6,7 @@
- -
+
-
{{item.combinationName}}
@@ -62,22 +62,30 @@
imghost: "http://medou.oss-cn-shenzhen.aliyuncs.com/",
listHeight: [], //存储区块的高度
scrollY: {},
+ clickTrue: false,
currentNum: 0
}
},
computed: {
- /*currentIndex () {
- const { scrollY, listHeight } = this
+ currentIndex () {
+ const { scrollY, listHeight, clickTrue, currentNum } = this
let index = listHeight.findIndex((height, index) => {
return scrollY >= listHeight[index] && scrollY < listHeight[index + 1]
})
if (scrollY > listHeight[index] + 50) {
index++
}
+ if(listHeight[listHeight.length-1] - this.$refs.foodWrapper.clientHeight <= scrollY ) {
+ if(clickTrue) {
+ return currentNum
+ } else {
+ return (listHeight.length-1)
+ }
+ }
return index
- }*/
+ }
- currentIndex(){
+ /*currentIndex() {
for (let i = 0; i < this.listHeight.length; i++){
let height = this.listHeight[i]
let height2 = this.listHeight[i + 1]
@@ -95,7 +103,7 @@
}
}
return 0
- }
+ }*/
},
components: {
Toast,
@@ -129,13 +137,20 @@
that.showLoading = false
if ( res.code == 0 ){
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(){
//调用scroll函数,实现滚动
this._initScroll()
//拿到数据以后计算高度
this._calculateHeight();
// 自动选中
- this.autoSelect()
+ this.autoSelect(list, this.c_no)
})
} else {
this.$vux.toast.text(res.msg,"middle");
@@ -182,24 +197,25 @@
this.foodsScroll.scrollToElement(el,300)
},*/
selectMenu(index, event){
- this.clickTrue = true //触发过剑姬事件之后,clickTrue的值变为true
+ this.clickTrue = true //触发过事件之后,clickTrue的值变为true
this.currentNum = index
+
//在better-scroll的派发事件的event和普通浏览器的点击事件event有个属性区别_constructed
// 浏览器原生点击事件没有_constructed所以当时浏览器监听到该属性的时候return掉
if (event && !event._constructed){
return
} else {
- let foodList = this.$refs.foodWrapper.getElementsByClassName("food-list-hook");
+ let foodList = this.$refs.foodWrapper.getElementsByClassName("food-list-hook");
let el = foodList[index];
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)
}
- }
+ })
},
ShareWenXin (){
var merchantNo = this.no