<style>
	.contanctMain {
		background-color: #F3F5F7;
	}

	.contanctIn {
		padding: 15px;
		display: flex;
		flex-wrap: wrap;
	}

	.contancList {
		width: 48%;
		background-color: #fff;
		margin:0 3.5% 13px 0;
		display: inline-block;
		text-align: center;
		border-radius: 6px;
		overflow: hidden;
		box-shadow:0 2px 10px 1px #D2D2D2;
	}

	.contancList:nth-child(2n+2) {
		margin-right: 0;
	}

	.contanctImg {
		width: 100%;
		height: 190px;
		overflow: hidden;
		border-top-right-radius: 6px;
		border-top-left-radius: 6px;
	}

	.contanctImg img {
		width: 100%;
		height: 100%;
	}

	.contancName {
		color: #111111;
		font-size: 18px;
		margin:10px 0 8px 0;
	}

	.contactNum {
		color: #666666;
		font-size: 12px;
		display: flex;
		align-items: center;
		justify-content: center;
		padding-bottom:10px;
	}
	.contancPosition{
		padding:2px 5px;
		background-color: #E0E0EB;
		color:#000450;
		font-size: 12px;
		max-width: 100px;
		display: inline-block;
		white-space: nowrap; 
	    overflow: hidden;
	    text-overflow:ellipsis;
		margin-bottom:5px;
	}
</style>
<template>
	<view class="contanctMain" style="height:100vh;">
		<u-empty v-if="dataList.length==0" text="暂无数据" mode="data"></u-empty>
		<scroll-view v-else :scroll-y="true" style="background-color: #f0f4f7;" :enable-back-to-top="true" :enable-flex="true"
		 @scrolltolower="lower" :style="{ 'height': `calc(100%)`}">
			<view class="contanctIn">
				<view class="contancList" v-for="(item,index) in dataList" @click="goDetail(item.Id)" :key="index">
					<view class="contanctImg">
						<img :src="item.HeadIcon" mode="widthFix" alt="" />
					</view>
					<view>
						<view class="contancName">{{item.Name}}</view>
						<view class="contancPosition">{{item.Position}}</view>
						<view class="contactNum">
							<image style="width:20px;height:20px;" src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/kotra-call.png"></image>{{item.Tel}}
						</view>
					</view>
				</view>
			</view>
			<view style="margin-bottom:80px;">
				<u-loadmore :status="status" :load-text="loadText" :font-size="24" :margin-top="0" :margin-bottom="0" bg-color="#f0f4f7" />
			</view>
		</scroll-view>
		<tabbar></tabbar>
	</view>
</template>

<script>
	import tabbar from "@/components/tabbar/index";
	export default {
		data() {
			return {
				pageTitle: "联系我们",
				msg:{
					pageIndex:1,
					pageSize:15
				},
				pageCount: 1,
				dataList: [],
				loadText: {
					loadmore: "轻轻上拉，加载更多",
					loading: "努力加载中",
					nomore: "没有更多了",
				},
			};
		},
		components: {
			tabbar
		},
		mounted() {
			uni.setNavigationBarTitle({
				title: this.pageTitle,
			});
		},
		onLoad(options) {
			this.getList(1);
		},
		created() {},
		onShow() {
			this.mainColor = this.$uiConfig.mainColor;
		},
		methods: {
			//获取数据
			getList(num) {
				if (num == 1) {
					this.dataList = [];
				}
				uni.showLoading({
					title: '加载中'
				});
				this.request2({
						url: "/api/Trade/GetContractPageList",
						data: this.msg,
					},
					(res) => {
						uni.hideLoading();
						if (res.resultCode == 1) {
							this.dataList = this.dataList.concat(res.data.pageData);
							this.pageCount = res.data.pageCount;
						}
					}
				);
			},
			//滚动加载
			lower(e) {
				if (this.msg.pageIndex < this.pageCount) {
					this.msg.pageIndex++;
					this.status = "loading";
					this.getList();
				} else {
					this.status = "nomore";
				}
			},
			//跳转
			goDetail(Id) {
				uni.navigateTo({
					url: '/pages/kotra/contanctDetail?Id='+Id
				})
			},
		},
	}
</script>

<style>
</style>
