初始化
This commit is contained in:
144
components/logscom/logscom.js
Normal file
144
components/logscom/logscom.js
Normal file
@@ -0,0 +1,144 @@
|
||||
// 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()获取设备及页面高度windowHeight(px)
|
||||
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)
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
4
components/logscom/logscom.json
Normal file
4
components/logscom/logscom.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
30
components/logscom/logscom.wxml
Normal file
30
components/logscom/logscom.wxml
Normal file
@@ -0,0 +1,30 @@
|
||||
<!-- 过滤器 -->
|
||||
<wxs module="filter" src="../../utils/filters.wxs"></wxs>
|
||||
<view class="padding-sm bg-white radius shadow shadow-lg" style="padding-bottom:0;">
|
||||
<view class="flex flex-wrap">
|
||||
<view class="basis-xl">
|
||||
操作日志共{{sum}}条
|
||||
</view>
|
||||
<!-- <view class="basis-sm">当前第{{page}}页</view> -->
|
||||
</view>
|
||||
<view class="bg-gray margin-xs" style="padding:2rpx" ></view>
|
||||
<view id="scroll">
|
||||
<scroll-view wx:if="{{topheight>0}}" style="height:{{topheight==null?'600rpx':topheight+'px'}} ;padding-bottom:10rpx" refresher-background="white" refresher-default-style="black" scroll-y refresher-enabled="{{true}}"
|
||||
refresher-triggered="{{refresher}}" bindscrolltolower="MoreData" bindrefresherrefresh="toupper">
|
||||
<view wx:for="{{logsdata}}" class="flex flex-wrap border-bottom">
|
||||
<view class="basis-lg">{{item.Id}}<text class="margin-left-xs"></text>{{item.uid}}<text class="margin-left-xs"></text> {{filter.TimeFormat(item.createtime)}}</view>
|
||||
<view class="basis-sm text-right">{{item.ActionId}}<text class='margin-left-xs text-{{item.type==0?"green":"red"}}'>{{item.AppType==0?"RCU":"人脸机"}}{{item.type==0?"绑定":"解绑"}}</text></view>
|
||||
<!-- <view class="basis-df">行为:{{item.type==0?"绑定":"解绑"}}</view> -->
|
||||
<view class="basis-xl">酒店:<text class='text-{{item.type==0?"green":"red"}}'>{{item.Name}}</text></view>
|
||||
<view class="basis-sm">房间号:<text class='text-{{item.type==0?"green":"red"}}'>{{item.roomNumber}} - {{item.roomID}}</text></view>
|
||||
<view class="basis-lg">{{item.AppType==0?"MAC":"SN"}}:<text class='text-{{item.type==0?"green":"red"}}'>{{item.MAC}}</text></view>
|
||||
<view class="basis-xl">地点:{{item.location}}</view>
|
||||
<view class="bg-gray margin-xs" style="padding:2rpx; width:100%" ></view>
|
||||
</view>
|
||||
<view class="cu-load bg-blue light loading" wx:if="{{status==1}}"></view>
|
||||
<view class="cu-load bg-blue light over" wx:if="{{status==3}}"></view>
|
||||
<view class="cu-load bg-red light erro " wx:if="{{status==2}}"></view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
2
components/logscom/logscom.wxss
Normal file
2
components/logscom/logscom.wxss
Normal file
@@ -0,0 +1,2 @@
|
||||
@import "../../colorui/main.wxss";
|
||||
@import "../../colorui/icon.wxss";
|
||||
Reference in New Issue
Block a user