Files
2025-12-11 09:50:02 +08:00

145 lines
3.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// components/logscom.js
//导入日志信息请求发方法
import {
Logsinfo
} from '../../lib/RequestingCenter.js'
Component({
/**
* 组件的属性列表
*/
properties: {
hotelsid:{
type:String,
value:null
}
},
/**
* 组件的初始数据
*/
data: {
//正加载
status: 0,
page: 1,
logsdata: [],
sum: 0,
pagelength:10,
refresher: false
},
lifetimes: {
// 生命周期函数可以为函数或一个在methods段中定义的方法名
detached: function () { },
ready:function(){this.onLoad()}
},
/**
* 组件的方法列表
*/
methods: {
onLoad: function () {
let that = this;
setTimeout(function () {
try {
// 1.使用wx.createSelectorQuery()查询到需要滚动到的元素位置
that.createSelectorQuery().select('#scroll').boundingClientRect(res => {
console.log(res)
// 2.使用wx.getSysTemInfo()获取设备及页面高度windowHeightpx
wx.getSystemInfo({
success(ress) {
console.log(ress)
that.setData({
topheight: ress.windowHeight - res.top
})
}
})
}).exec(function (params) {
console.log(params)
})
} catch (error) {
console.log(error)
}
}, 500)
this.init()},
// 下拉刷新
toupper: function () {
if (this.data.refresher) {
return;
}
this.setData({
refresher: true,
})
var that = this;
that.setData({
page: 1,
})
that.init();
},
// 下拉加载
MoreData: function (params) {
if (this.data.status == 1 || this.data.status == 3) {
return;
}
this.setData({
status: 1,
page: this.data.page + 1
})
this.init();
},
//加载数据
init:async function () {
try {
if(this.data.page<1){
this.setData({
page:1
})
}
let that = this;
await Logsinfo({
page:that.data.page,
search:{ hotelsid:that.data.hotelsid,name:'',endtime:'',starttime:''},
length:that.data.pagelength
}).then(res => {
if (res.Status == 200) {
let newdata = res.Data.data
if(that.data.page>1){
newdata = that.data.logsdata.concat(newdata);
}
//判断是否有更多
let more = 0;
if((that.data.page * that.data.pagelength)>=res.Data.filtcount){
more = 3;
}
that.setData({
refresher: false,
logsdata: newdata,
status: more,
//过滤后总数
sum: res.Data.filtcount
})
} else {
that.setData({
status:2,
page:that.data.page-1
})
app.toast(2, res.Message || "网络繁忙")
}
}, err => {
that.setData({
status:2,
page:that.data.page-1
})
app.toast(2 ,"网络繁忙")
}).catch(err => {
that.setData({
status:2,
page:that.data.page-1
})
console.log(err)
app.toast(2 ,"网络繁忙")
});
} catch (error) {
console.log(error)
}
},
}
})