<template>
	<!-- 贷款 -->
	<view class="container">
		<view class="top">
			<view class="s u-flex u-col-center u-row-between">
				<view class="l">
					<image src="@/static/images/credit/s.png" mode="aspectFill"></image>
				</view>
				<view class="c">
					<input type="text" v-model="submitDate.baseName" placeholder="搜索名称">
				</view>
				<view class="r" @click="getdata(true)">
					查询
				</view>
			</view>
		</view>
		<view class="list">
			<view scroll-y="true" class="scroll-Y">

				<view class="item u-flex u-col-center u-row-between">
					<view class="l">
						主体名称
					</view>
					<view class="r">
						级别
					</view>
				</view>
				<view class="item u-flex u-col-center u-row-between" v-for="(item,index) in list" :key="index">
					<view class="l">
						{{item.baseName}}
					</view>
					<view class="r">
						{{item.level}}
					</view>
				</view>
				<view class="nolist" v-if="nolist">
					暂无信息！
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import { creditRating } from '@/api/home.js'
 	export default {
		data() {
			return {
				
				list: [],
				nolist: false,
				submitDate: {
					baseName: '', //搜索条件
					//放你自己的参数
					pageNum: 1,//页数
					pageSize: 20//每页条数
				},
				total: 0,//数据总条数
			}
		},
		onLoad() {
			this.getdata(false)
		},
		       onReachBottom() {
					let that = this
					if (that.total <= that.list.length) {
						uni.showToast({
							title: '已加载全部数据',
							icon: "none"
						});
					} else {
						that.submitDate.pageNum++;
						that.getdata(false)
					}
				},

		methods: {
			getdata(off){
				creditRating(this.submitDate).then(res=>{
					
					if (res.code == 200) {
						if(off){
							this.submitDate.pageNum = 1
							this.list = res.rows
						}else{
							this.list.push(...res.rows);
						}
						this.total = res.total
					} else {
						uni.showToast({
							title: res.msg,
							icon: "none",
							duration: 1500
						});
					}
				})
			}

		}
	}
</script>

<style lang="scss" scoped>
	$color: #FCAA30;

	.container {
		background-color: #fff;
		height: 100vh;
		box-sizing: border-box;
		width: 100%;
		display: flex;
		flex-direction: column;

		.nolist {
			padding: 30rpx;
			text-align: center;
			font-size: 24rpx;
			color: #666;
		}

		.list {
			flex: 1;
			width: 100%;
			margin-top: 20rpx;
			height: 1rpx;

			.scroll-Y {
				width: 100%;
				height: 100%;
				// padding: 0 30rpx;
				box-sizing: border-box;
			}

			.item {
				padding: 34rpx 30rpx;
				border-bottom: 2rpx solid #eee;
				background: #fff;

				.l {
					flex: 1;
					width: 1rpx;
					margin-right: 20rpx;
					font-size: 28rpx;
					font-weight: 500;
					color: #333333;
					line-height: 44rpx;
				}

				.r {
					width: 100rpx;
					font-size: 28rpx;
					font-weight: 500;
					color: #666;
					line-height: 44rpx;
				}
			}
		}

		.top {
			padding: 20rpx 30rpx;
			border-bottom: 2rpx solid #eee;
			background-color: #fff;
			z-index: 9999;
      width: 100%;

			.s {
				height: 72rpx;
				background: #F4F5F7;
				border-radius: 36rpx;
				padding-left: 30rpx;
			}

			.l {
				width: 28rpx;
				height: 28rpx;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.c {
				flex: 1;
				padding: 0 20rpx;
				width: 1rpx;

				input {
					width: 100%;
					height: 70rpx;
					line-height: 70rpx;
					font-size: 28rpx;
					color: #333;
				}
			}

			.r {
				width: 140rpx;
				height: 65rpx;
				background: #FFFFFF;
				border: 1px solid #4595FE;
				border-radius: 33rpx;
				line-height: 65rpx;
				color: #4595FE;
				font-size: 28rpx;
				text-align: center;
			}
		}
	}
</style>