<template>
	<view class="a-page">
		<view class='a-main' v-show="list && list.length>0">
			<scroll-view
				class='box-at-home'
				scroll-y="true" 
				refresher-default-style="none"
				@scrolltoupper="toupperTop"
				@scrolltolower="lowerMore">
				<view class='main-item' v-for="items in list"  :key="items.id">
					<view class='item-top'>申请时间:{{items.gmtCreated}}</view>
					<view class='item-box'> 
						<image class='box-img' :src='items.imagesUrl[0]'></image>
						<view class='box-con'>
							<view class='cont-top'>{{items.name}}</view>
							<view class='cont-footer'>{{items.type}}</view>
						</view>
						<image class='box-icon' v-show="items.status=='CREATED'" src='https://ddh.yyhock.com/ddhMall/application-icon.png'></image>
					</view>
					<view class='item-btn' @click="goIndex">返回</view>
				</view>
			</scroll-view>
		
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				pageNum: 1,
				pageSize: 10,
				total: 0,
				hasNextText:'上拉加载更多',
				loadFlag:true,
				hasNextPage:false,
			}
		},
		onLoad() {
			this.init()
			this.buryingPoint('app:application_pageView')
		},
		methods: {
			init(){
				const self=this
				const { sort,pageSize,pageNum}=self
				const params={
					 
					  "current":pageNum,
					  "size":pageSize,
					  "sort":sort
				}
				self.$request('/pawn/authenticate/selectLists','POST',params).then((res)=>{
					
			
					const {current,total,size,records }=res.result
					const hasNextPage=total-self.pageSize*self.pageNum>0?true:false //是否有下一页
					records.map(item=>{
						const newUrl=JSON.parse(item.imagesUrl)
						item.imagesUrl=newUrl
					})
					if(self.loadFlag){
						
						console.log(res.result,'023')
						self.list=self.list.concat(records)
					}else{
						
						self.list=records
					}
					self.hasNextPage=hasNextPage
					self.loadFlag=false
									
					
				})
			},
			goIndex(){
				this.Go('uni:/pages/index/index','tab')
			},
			toupperTop:function(e){
				console.log(e,'到顶了');
			},
			lowerMore:function(e){
				console.log(e,'触底了');
				if(!this.hasNextPage){
					uni.showToast({
						icon: 'none',
						title: '到底了',
					})
					return false;
				} 
				if(this.loadFlag) return;
				this.loadFlag=true,
				this.pageNum=this.pageNum+1
				this.init();
			},
		},
		onShow() {
			this.init()
		}
	}
</script>
<style src='./index.less' lang="less" scoped></style>
