<template>
	<view>
		<view class="align-items" style="margin-top: 80rpx;">
			<back></back>
		</view>
		<view v-for="(item,index) in list" :key="index">
			<view  @click="gotopage(item)">
				<view class="type">
					<view class="justify-content">
						<view class="font-forty blue" >
							类别：{{name}}
						</view>
						<view class="font-twenty-eight gray">
							{{item.time}} 
						</view>
					</view>
					<view class="font-thirty-six black" style="margin: 30rpx 0;">
						{{item.house}}
					</view>
					<view class="font-thirty-six black" style="margin: 30rpx 0;">
						备注：
						<text v-if="item.remark != null">
							{{item.remark}}
						</text>
						<text v-else>
							无
						</text>
					</view>
				</view>
			</view>
			<view class="main-list-icon"></view>
		</view>
	</view>

</template>

<script>
	import service from '@/api/index.js'
	export default { 
		data(){
			return {
				list:[],
				name:'',
				params: {
					pageNum: 1,
					pageSize: 10,
				},
			}
		},
		onLoad(e) {
			console.log('e',e)
			this.id = e.id;
			this.name = e.name;
			this.address = e.address;
			this.getListAll();
		},
		onReachBottom() {
			this.getNextListFn()
		},
		onPullDownRefresh() {
			this.getListAll();
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods:{
			getListAll() {
				let that = this;
				let params ={
					serviceType: this.id,
					pageSize: 10,
					pageNum: 1,
				}
				service.getListAll(params).then(res => {
					this.list = res.records;
					that.total = res.total || 0;
					that.params.pageNum = res.current + 1;
				})
			},
			getNextListFn() {
				let that = this;
				let params ={
					serviceType: this.id,
					pageSize: this.params.pageSize,
					pageNum: this.params.pageNum,
				}
				if (this.list.length < this.total) {
					service.getListAll(params).then(response => {
						that.params.pageNum = response.current + 1
						response.records.forEach(item =>{
							that.list.push(item)
						})
					})
				}
			},
			gotopage(item){
				uni.navigateTo({
					url:`/pages/noLogin/Myphoto?id=${item.id}`,
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.type {
		margin: 20rpx;
		padding: 20rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 8rpx 17rpx 0rpx rgba(0, 0, 0, 0.04);
		border-radius: 10rpx;
	}
</style>
