diff --git a/pages/device/device.vue b/pages/device/device.vue
index aea7136..fdeea1e 100644
--- a/pages/device/device.vue
+++ b/pages/device/device.vue
@@ -2,7 +2,7 @@
-
+
- ----------------底线----------------
+ ----------------底线----------------
@@ -73,7 +73,7 @@ export default {
},
onLoad(){
this.getUserInfo();
- this.search();
+ this.search(false);
},
filters:{
dateFilter(msg,flag){
@@ -86,10 +86,16 @@ export default {
}
},
methods: {
- fetchDeviceList(content,limit,offset){
+ fetchDeviceList(content,limit,offset,isAppend){
getDevice(content,limit,offset).then(response => {
- this.deviceList = response.data.data.result
this.total = response.data.data.total
+ if(isAppend){
+ if(this.deviceList.length < this.total){
+ this.deviceList.push(...response.data.data.result)
+ }
+ }else{
+ this.deviceList = response.data.data.result
+ }
})
},
handleDeleteItem(id,index){
@@ -110,7 +116,9 @@ export default {
},
isRefresh(){
setTimeout(() => {
- this.search()
+ this.offset = 0
+ this.pageNum = 1
+ this.search(false)
uni.showToast({
icon: 'success',
title: '刷新成功'
@@ -120,10 +128,14 @@ export default {
},
setSearch(val) {
this.query = val
- this.search()
+ this.offset = 0
+ this.pageNum = 1
+ this.search(false)
},
- search(){
- this.fetchDeviceList(this.query,this.limit,this.offset)
+ search(isAppend){
+ this.fetchDeviceList(this.query,this.limit,this.offset,isAppend)
+ this.pageNum ++
+ this.offset = (this.pageNum - 1) * this.limit
},
getUserInfo() {
uni.getUserInfo({
@@ -157,29 +169,14 @@ export default {
this.listTouchDirection = null
},
scrolltolower(e){
- console.log(e)
- this.offset = (this.pageNum - 1) * this.limit
- if(this.offset > this.total) {
+ if(this.offset >= this.total) {
uni.showToast({
icon: 'none',
title: '已经到底啦'
})
return;
}
- setTimeout(() => {
- this.search()
- this.$refs.refresh.endAfter()
- }, 1000)
- this.pageNum ++
- },
- scrolltoupper(e){
- console.log(e)
- this.offset = 0
- this.pageNum = 1
- setTimeout(() => {
- this.search()
- this.$refs.refresh.endAfter()
- }, 1000)
+ this.search(true)
},
trigger(e) {
console.log(e);
@@ -199,7 +196,7 @@ export default {
postDevice(dev).then(response => {
if(response.data){
if(response.data.code == 0){
- that.search()
+ that.search(false)
uni.showToast({
icon: 'success',
title: '添加终端成功'