Browse Source

修改下拉刷新

master
lihua 5 years ago
parent
commit
68a6fa3130
  1. 51
      pages/device/device.vue

51
pages/device/device.vue

@ -2,7 +2,7 @@
<view @touchstart="refreshStart" @touchmove="refreshMove" @touchend="refreshEnd">
<refresh ref="refresh" @isRefresh='isRefresh'></refresh>
<mSearch :mode="2" button="inside" @search="setSearch($event)" ></mSearch>
<scroll-view scroll-y="true" style="height:1000upx" @scrolltolower="scrolltolower" @scrolltoupper="scrolltoupper" show-scrollbar="true">
<scroll-view scroll-y="true" style="height:1000upx" @scrolltolower="scrolltolower" show-scrollbar="true">
<view class="cu-list menu-avatar margin-top">
<view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''" v-for="(item,index) in deviceList" :key="index"
@touchstart="ListTouchStart" @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
@ -25,7 +25,7 @@
</view>
</view>
</view>
<view style="text-align: center;">----------------底线----------------</view>
<view v-if="offset > total" style="text-align: center;">----------------底线----------------</view>
</scroll-view>
<uni-fab :pattern="pattern" :content="content" horizontal="right" vertical="bottom" direction="vertical" @trigger="trigger"></uni-fab>
</view>
@ -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: '添加终端成功'

Loading…
Cancel
Save