147 lines
3.0 KiB
Vue
147 lines
3.0 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 ListUnit from './components/listUnit.vue'
|
|
export default {
|
|
data() {
|
|
return {
|
|
pageData: {
|
|
pageIndex:1,
|
|
pageSize: 8,
|
|
isEnd: false,
|
|
isLoading: true
|
|
},
|
|
|
|
isShow:false,
|
|
|
|
pageList:[]
|
|
}
|
|
},
|
|
components: {
|
|
ListUnit
|
|
},
|
|
|
|
onLoad() {
|
|
this.pageData.isLoading= true
|
|
uni.showLoading({
|
|
title:'正在加载'
|
|
})
|
|
this.getList()
|
|
},
|
|
methods: {
|
|
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.concat(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) {
|
|
this.$util.toNextRoute('navigateTo', "/pages/suggestion/suggestionDetail?SUGGESTION_ID=" + item.SUGGESTION_ID)
|
|
|
|
},
|
|
},
|
|
onPullDownRefresh() {
|
|
this.pageData.pageIndex = 1
|
|
this.pageData.isEnd = false
|
|
uni.showLoading({
|
|
title:'正在加载'
|
|
})
|
|
this.getList()
|
|
setTimeout(function() {
|
|
uni.stopPullDownRefresh()
|
|
}, 1000)
|
|
},
|
|
onReachBottom(){
|
|
this.loadMore()
|
|
},
|
|
onShow() {
|
|
let _this = this
|
|
this.$eventHub.$once('suggestion', function (data){
|
|
if(data) {
|
|
uni.showLoading({
|
|
title:'正在加载'
|
|
})
|
|
_this.pageData.pageIndex = 1
|
|
_this.pageData.isEnd = false
|
|
_this.getList()
|
|
|
|
}
|
|
});
|
|
},
|
|
onUnload() {
|
|
this.$util.addUserBehavior()
|
|
},
|
|
onHide() {
|
|
this.$eventHub.$off('suggestion', function (data) {
|
|
// console.log('scanResult - '+data);
|
|
});
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.suggestion-body {
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
height: 100%;
|
|
width: 750upx;
|
|
|
|
}
|
|
.mt20 {
|
|
margin-top: 30rpx;
|
|
}
|
|
|
|
</style>
|