ahyd_DIB/pages/suggestion/suggestion.vue
2023-10-07 11:20:52 +08:00

153 lines
3.1 KiB
Vue

<template>
<view class="suggestion-body" v-show="isShow">
<view style="flex: 1;width: 750upx;overflow: hidden;">
<scroll-view enableBackToTop="true" scroll-y style="height: 100%;" @scrolltolower="loadMore()">
<view v-if="pageList.length>0">
<ListUnit @tap="goDetail(item)" v-for="(item,i) in pageList" :key="i" :item="item"></ListUnit>
<view class="load-more mt20" >
<text>{{!pageData.isEnd ? '正在加载,请稍后...':'——— 我是有底线的 ———'}}</text>
</view>
</view>
<view v-else-if="!pageData.isLoading" >
<noFound :nodata="pageList.length>0 ? false : true"/>
</view>
</scroll-view >
</view>
</view>
</template>
<script>
import { mapGetters,mapMutations } from 'vuex'
import ListUnit from './components/listUnit.vue'
export default {
data() {
return {
pageData: {
pageIndex:1,
pageSize: 8,
isEnd: false,
isLoading: true
},
isShow:false,
pageList:[]
}
},
components: {
ListUnit
},
computed: {
...mapGetters({
isReloading:'shouldReLoadingList'
}),
},
methods: {
...mapMutations(['shouldReLoadingList']),
getList() {
let _this = this
_this.$request.$get( 'GetSuggestionList',{
suggestionType: '1000,2000,4000',
pageIndex: this.pageData.pageIndex,
pageSize: this.pageData.pageSize,
}).then(res => {
if(!res.ResultCode ||res.ResultCode!='100'){
_this.isShow = false
_this.pageList = []
}else{
let list = res.Data.List
if (list.length > 0) {
_this.pageList = this.pageData.pageIndex==1 ? list : [..._this.pageList,...list,]
}
if (list.length < _this.pageData.pageSize) { // 返回条数小于每页条数
_this.pageData.isEnd = true
}
// _this.$forceUpdate()
}
uni.hideLoading()
_this.isShow = true
_this.pageData.isLoading = false
})
},
loadMore(){
if(!this.pageData.isEnd) {
this.pageData.pageIndex += 1
this.getList()
}
},
goDetail(item) {
console.log('item',item)
this.$util.toNextRoute('navigateTo', "/pages/suggestion/suggestionDetail?SUGGESTION_ID=" + item.SUGGESTION_ID+"&type="+item.SUGGESTION_STATE)
},
},
onPullDownRefresh() {
this.pageData.pageIndex = 1
this.pageData.isEnd = false
uni.showLoading({
title:'正在加载'
})
this.getList()
setTimeout(function() {
uni.stopPullDownRefresh()
}, 1000)
},
onReachBottom(){
this.loadMore()
},
onLoad() {
this.pageData.isLoading= true
uni.showLoading({
title:'正在加载'
})
this.getList()
},
onShow() {
let _this = this
if(this.isReloading) {
uni.showLoading({
title:'正在加载'
})
_this.pageData.pageIndex = 1
_this.pageData.isEnd = false
_this.getList()
_this.shouldReLoadingList(false)
}
},
onUnload() {
this.$util.addUserBehavior()
}
}
</script>
<style scoped>
.suggestion-body {
display: flex;
flex-direction: column;
overflow: hidden;
height: 100%;
width: 750upx;
}
.mt20 {
margin-top: 30rpx;
}
</style>