榆山数据端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
3.0 KiB

var utils = require('../../../../utils/util');
Page({
data: {
floorstatus: false,
pageSize: 10,
pageIndex: 1,
currenttab: 'new',
date: utils.formatTimestamp(new Date()),
loadVisible: true,
loadType: 'more',
isShow: false,
listLength:0,
loading:true
},
onLoad: function (options) {
const eventId = options.eventId;//事件id
const pageName = options.pageName;//页面名称
this.setData({
eventId: eventId,
pageName: pageName,
date: utils.formatTimestamp(new Date())
})
this.selectComponent("#state-1").getCommentList(this.data)
},
onGetCode: function (e: { detail: { val: any } }) {
this.setData({
listLength: e.detail.listLength,
loadType: e.detail.loadType,
loading:false
})
console.log('::::::::::::::::::::' + e.detail)
if (e.detail.listLength == 0) {
this.setData({
loadVisible: false,
isShow: true
})
}
else if (e.detail.listLength < 10) {
this.setData({
loadVisible: true,
loadType:'none',
isShow: false
})
}
},
onReachBottom: function () {//上拉
// 判断是否需要在加载数据
if (this.data.listLength !== this.data.pageSize) {
this.setData({
loadType: 'none',
})
return
}
this.setData({
loadType: 'more',
})
let obj = {
pageIndex: ++this.data.pageIndex,
pageSize: this.data.pageSize
}
// this.setData({
// pageIndex: this.data.pageIndex + 1,
// })
this.selectComponent("#state-1").getCommentList(this.data)
},
/**
* --
*/
onPullDownRefresh: function () {
if(this.data.loading==true){
}else{
this.setData({
loading:true,
loadType:'more',
loadVisible:true,
pageIndex: 1,
date: utils.formatTimestamp(new Date())
})
wx.stopPullDownRefresh();
this.selectComponent("#state-1").getCommentList(this.data)
}
},
newhot: function (e) {
console.log(this.data.loading)
if(this.data.loading==true){
}else{
let currenttab = e.currentTarget.dataset.case
this.setData({
loading:true,
currenttab: currenttab,
pageSize: 10,
pageIndex: 1,
date: utils.formatTimestamp(new Date()),
loadType: 'more',
isShow: false,
})
this.selectComponent("#state-1").getCommentList(this.data)
}
},
// 获取滚动条当前位置
onPageScroll: function (e) {
if (e.scrollTop > 100) {
this.setData({
floorstatus: true
});
} else {
this.setData({
floorstatus: false
});
}
},
//回到顶部
goTop: function (e) { // 一键回到顶部
if (wx.pageScrollTo) {
wx.pageScrollTo({
scrollTop: 0
})
} else {
wx.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
})
}
}
})