<template>
	<view class="container-main">
		<u-sticky>
			<u-tabs :list="tabList" :is-scroll="false" :current="current" @change="change"></u-tabs>
		</u-sticky>
		<view class="list">
			<view class="list-item"  @click="getInfo(item.id)">
				<view class="item-title">222</view>
				<view class="data-row">
					<view class="data-lable">企业类型:</view>
					<view class="data-value">333</view>
				</view>
				<view class="data-row">
					<view class="data-lable">负责人:</view>
					<view class="data-value">2323</view>
				</view>
				<view class="data-row">
					<view class="data-lable">生产地址:</view>
					<view class="data-value">2323</view>
				</view>
			</view>
			<u-loadmore :status="status" :load-text="loadText" />
		</view>
	</view>
</template>

<script>
	import {
		getList,
		getblackList
	} from '@/api/shianliaoning/bangdan.js'
	export default {
		data() {
			return {
				code: undefined,
				status: "nomore",
				loadText: {
					loading: "努力加载中",
					nomore: "已经到底了~",
				},
				list: [],
				tabList: [{
						name: '红榜'
					},
					{
						name: '黑榜'
					}
				],
				current: 0,
				total: 0,
				queryParams: {
					pageNum: 1,
					pageSize: 10
				}
			}
		},
		onLoad(option) {
			if (option.code) {
				this.code = option.code
			}
			this.getList()
		},
		onReachBottom() {
			if (this.queryParams.pageNum < this.total) {
				if (this.status == 'loading') return
				this.queryParams.pageNum = this.queryParams.pageNum + 1;
				this.getList()
			}
		},
		methods: {
			// tab页变化
			change(e) {
				this.reset()
				this.current = e
				this.getList()
			},
			//详情
			getInfo(id) {
				uni.navigateTo({
					url: `/sub-interaction/bang-dan/info?id=${id}&current=${this.current}`
				})
			},
			//获取数据
			getList() {
				this.status = 'loading'
				if (this.current == 0) {
						this.list = [];
						this.total = 1;
						this.status = 'nomore'
				} else {
						this.list = [];
						this.total =  1;
						this.status = 'nomore'
				}

			},
			//重置
			reset() {
				this.list = []
				this.total = 0
				this.queryParams = {
					pageNum: 1,
					pageSize: 10
				}
			},
		},
	}
</script>

<style lang="scss" scoped>
	.list {
		box-sizing: border-box;
		padding: 20rpx;

		&>.list-item {
			min-height: 20rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			margin-bottom: 20rpx;
			box-sizing: border-box;
			padding: 20rpx;

			.item-title {
				font-size: 30rpx;
				font-weight: 550;
			}

			.data-row {
				margin-top: 20rpx;
				display: flex;
				align-items: center;

				.data-lable {
					width: 130rpx;
					font-size: 28rpx;
					font-weight: 400;
					color: #9DA2AB;
				}

				.data-value {
					flex: 1;
					font-size: 28rpx;
					font-weight: 400;
					color: #34373B;
					box-sizing: border-box;
					padding-left: 20rpx;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
				}
			}
		}

		.list-item:active {
			background-color: rgba(196, 204, 216, 0.2);
		}
	}
</style>