...
|
...
|
@@ -23,19 +23,32 @@ Page({ |
|
|
send: 0,
|
|
|
it_tue: false,
|
|
|
newindex: '',
|
|
|
top_true: true
|
|
|
top_true: true,
|
|
|
scrollH: '', //滚动高度
|
|
|
windowH:'',//屏幕高度
|
|
|
},
|
|
|
|
|
|
onShow: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
onLoad: function (options) {
|
|
|
// console.log(options);
|
|
|
this.setData({
|
|
|
id: options.id || '',
|
|
|
})
|
|
|
this.getLeftCates()
|
|
|
|
|
|
wx.getSystemInfo({
|
|
|
success: (result) => {
|
|
|
console.log(result,'屏幕样式')
|
|
|
this.setData({
|
|
|
windowH:result.windowHeight
|
|
|
})
|
|
|
},
|
|
|
})
|
|
|
},
|
|
|
onPageScroll: function (e) { // 获取滚动条当前位置
|
|
|
console.log(e, '滚动条高度')
|
|
|
},
|
|
|
getLeftCates() { // 左分类数据
|
|
|
let that = this;
|
...
|
...
|
@@ -49,13 +62,12 @@ Page({ |
|
|
that.setData({
|
|
|
leftCates: res.data.data,
|
|
|
})
|
|
|
// console.log(res.data.data);
|
|
|
that.data.leftCates.forEach((value, indexone) => {
|
|
|
if (value.id == that.data.id) {
|
|
|
that.setData({
|
|
|
cateList2: value.cate2,
|
|
|
currentIndex: indexone,
|
|
|
newindex: indexone + 1
|
|
|
newindex: indexone + 1,
|
|
|
})
|
|
|
}
|
|
|
})
|
...
|
...
|
@@ -64,7 +76,7 @@ Page({ |
|
|
that.setData({
|
|
|
cateList2: res.data.data[0].cate2,
|
|
|
id: res.data.data[0].id,
|
|
|
newindex: 1
|
|
|
newindex: 1,
|
|
|
})
|
|
|
// console.log(that.data.id, "id22222");
|
|
|
}
|
...
|
...
|
@@ -117,62 +129,71 @@ Page({ |
|
|
url: '/pages/cate3List/cate3List?id=' + id
|
|
|
})
|
|
|
},
|
|
|
watchScr(e) {
|
|
|
// console.log(e.detail,'监听滚动')
|
|
|
this.setData({
|
|
|
scrollH: e.detail.scrollHeight,
|
|
|
})
|
|
|
},
|
|
|
|
|
|
lower(e) {
|
|
|
// console.log(e);
|
|
|
let that = this
|
|
|
let leftCates = that.data.leftCates
|
|
|
let indexnum = Number(that.data.leftCates.length)
|
|
|
let id = that.data.id
|
|
|
let send = ''
|
|
|
// console.log(id);
|
|
|
leftCates.forEach((item, index) => {
|
|
|
if (item.id == id) {
|
|
|
// console.log(index);
|
|
|
send = index + 1
|
|
|
// console.log(e,'向下');
|
|
|
if (that.data.scrollH > that.data.windowH + 100 ) {
|
|
|
let leftCates = that.data.leftCates
|
|
|
let indexnum = Number(that.data.leftCates.length)
|
|
|
let id = that.data.id
|
|
|
let send = ''
|
|
|
// console.log(id,'id');
|
|
|
// console.log(indexnum,'左侧length')
|
|
|
leftCates.forEach((item, index) => {
|
|
|
if (item.id == id) {
|
|
|
// console.log(index);
|
|
|
send = index + 1
|
|
|
}
|
|
|
})
|
|
|
// console.log(send);
|
|
|
if (send != indexnum) {
|
|
|
let idt = leftCates[send].id
|
|
|
that.setData({
|
|
|
id: idt,
|
|
|
it_tue: false,
|
|
|
})
|
|
|
that.getLeftCates()
|
|
|
} else {
|
|
|
that.setData({
|
|
|
id,
|
|
|
it_tue: true,
|
|
|
})
|
|
|
|
|
|
}
|
|
|
})
|
|
|
// console.log(send);
|
|
|
if (send != indexnum) {
|
|
|
}
|
|
|
},
|
|
|
upper(e) {
|
|
|
let that = this
|
|
|
// console.log(e, '向上',);
|
|
|
console.log(that.data.scrollH,that.data.windowH+100,'比较')
|
|
|
if (that.data.scrollH > that.data.windowH + 100 ) {
|
|
|
let leftCates = that.data.leftCates
|
|
|
let id = that.data.id
|
|
|
let send = ''
|
|
|
// console.log(id,'id');
|
|
|
leftCates.forEach((item, index) => {
|
|
|
if (item.id == id) {
|
|
|
if (index != 0) {
|
|
|
send = index - 1
|
|
|
} else {
|
|
|
send = index
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
// console.log(send);
|
|
|
let idt = leftCates[send].id
|
|
|
// console.log(idt);
|
|
|
that.setData({
|
|
|
id: idt,
|
|
|
it_tue: false
|
|
|
})
|
|
|
that.getLeftCates()
|
|
|
} else {
|
|
|
that.setData({
|
|
|
id,
|
|
|
it_tue: true
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
},
|
|
|
upper(e) {
|
|
|
// console.log(e);
|
|
|
let that = this
|
|
|
let leftCates = that.data.leftCates
|
|
|
let id = that.data.id
|
|
|
let send = ''
|
|
|
// console.log(id);
|
|
|
leftCates.forEach((item, index) => {
|
|
|
if (item.id == id) {
|
|
|
if (index != 0) {
|
|
|
send = index - 1
|
|
|
} else {
|
|
|
send = index
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
// console.log(send);
|
|
|
let idt = leftCates[send].id
|
|
|
// console.log(idt);
|
|
|
that.setData({
|
|
|
id: idt,
|
|
|
})
|
|
|
that.getLeftCates()
|
|
|
|
|
|
},
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|