<template>
	<view class="">
		<view class="company_list">


			<!-- 			<view class="info_card" v-for="item in companyList" :key="item.id">
				<view class="top" @click="navTo('/subpkg/companySign/companySign?id='+item.id)">
					<view>
						<view class="info_name" :class="item.is_contract?'have':'no'">{{item.company_name}}</view>
						<view class="info_type">{{item.company_type_name}}</view>
					</view>
					<view class="btn">详情<uni-icons type="forward" color="#666666"></uni-icons></view>
				</view>
				<u-line></u-line>
				<view class="bottom">
					<image src="../../static/img/contract/company.png"></image>
					<view class="text">
						<view>主要联系人：{{item.master_name}}</view>
						<view @click="copyPhone(item.master_phone)">联系方式：{{item.master_phone}}</view>
						<view style="display: flex;">
							<view class="">区县乡镇：</view>
							<view>{{c_address(item)}}</view>
						</view>

					</view>
				</view>
			</view> -->


			<view class="personnel_list" v-for="item in companyList" :key="item.id">
				<view class="cards">
					<view class="cards_head" @click="navTo('/subpkg/companySign/companySign?id='+item.id)">
						<!-- <text style="font-size: 32rpx">{{item.company_name}}</text> -->
						<view style="display: flex;">
							<text><u--image src="../../static/img/company/company.png" width="33.29rpx"
									height="33.29rpx" style="margin-right:20rpx"></u--image></text>
							<text>{{item.company_name}}</text>
						</view>

						<text>选择<u-icon style="display: inline-block;margin-left: 10rpx;" color="white"
								name="arrow-right"></u-icon></text>
					</view>
					<view class="cards_content">
						<view class="right">
							<view class="" style="width: 80vw;">
								<text>法人姓名 :</text>
								<text> {{item.master_name}}</text>

								<text style="float: right;">{{item.is_contract?"已签约":"未签约"}}</text>
							</view>
							<view class="">
								<text>担任职务 :</text>
								<text>{{item.master_position}}</text>
							</view>
							<view class="" @click="copyPhone(item.master_phone)">
								<text>联系电话 :</text>
								<text> {{item.master_phone}} </text>
							</view>
							<view class="">
								<text>负责区域 :</text>
								<text> {{c_address(item)}} </text>
							</view>
						</view>


					</view>
				</view>
			</view>



			<u-empty v-if="loadConfig.status=='nomore'&& companyList.length==0" text="没有更多公司"
				icon="/static/img/empty/data.png"></u-empty>
			<u-loadmore v-else :status="loadConfig.status" :loading-text="loadConfig.loadingText"
				:loadmore-text="loadConfig.loadmoreText" :nomore-text="loadConfig.nomoreText" />
		</view>
	</view>
</template>

<script>
	import {
		companyUnsigned
	} from "@/api/company.js"
	import {
		Toast
	} from '@/libs/uniApi.js'
	export default {
		data() {
			return {
				loadConfig: {
					page: 1,
					limit: 15,
					lastpage: '',
					loadingText: '努力加载中',
					loadmoreText: '轻轻上拉',
					nomoreText: '我也是有底线的~~',
					status: 'loadmore'
				},
				companyList: []
			}
		},
		onShow() {
			this.loadCompanyList();
		},
		onReachBottom() {
			this.loadCompanyList();
		},
		methods: {
			initLoad() {
				this.loadConfig.page = 1;
				this.loadConfig.status = "loadmore";
				this.companyList = [];
				this.loadCompanyList();
			},
			// 加载公司列表
			async loadCompanyList() {
				if (this.loadConfig.status == "nomore") return;
				this.loadConfig.status = "loading";
				let res = await companyUnsigned({
					page: this.loadConfig.page,
					limit: this.loadConfig.limit
				})
				this.loadConfig.status = "loadmore"
				if (res.data.data.length < this.loadConfig.limit) {
					this.loadConfig.status = "nomore"
				} else {
					this.loadConfig.page++;
				}
				this.companyList = [...this.companyList, ...res.data?.data]
			},
			navTo(url) {
				if(url){
          uni.showLoading({
            title: '加载中',
            mask: true
          });
          uni.navigateTo({
          	url: url,
            success() {
              uni.hideLoading()
            }
          })
        }else Toast('暂未开放')
			},
			copyPhone(str = "", type = "号码") {
				if (str) uni.setClipboardData({
					data: str + "",
					success: (e) => {
						Toast(type + '已复制')
					},
					fail: (e) => {
						Toast('复制失败')
					}
				})
			},
			// 根据公司类型显示地区
			c_address(company) {
				let str = '';
				if (company.company_type == 16) {
					company?.province_name ? str += company?.province_name : null;
					company?.city_name ? str += company?.city_name : null;
					company?.area_name ? str += company?.area_name : null;
					company?.street_name ? str += company?.street_name : null;
				} else {
					company?.street_name ? str += company?.street_name : null;
					company?.village_name ? str += company?.village_name : null;
					company?.brigade_name ? str += company?.brigade_name : null;
				}
				return str;
			}
		},
		onPullDownRefresh() {
			uni.stopPullDownRefresh()
		}
	}
</script>

<style lang="scss">
	.company_list {
    padding-top: 28rpx;
		padding-bottom: 32rpx;
		// margin-top: 190rpx;
		display: flex;
		flex-direction: column;
		align-items: center;

		.personnel_list {

			.cards {
				margin: 0 auto;
				margin-bottom: 28rpx;
				width: 694rpx;
				background: #ffffff;
				border-radius: 30rpx;
				opacity: 1;
				overflow: hidden;
				// box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.6);

				.cards_head {
					padding: 28rpx;
					background-color: $theme-oa-color;
					color: white;
					height: 100rpx;
					display: flex;
					justify-content: space-between;
				}

				.cards_content {
					padding: 28rpx;
					display: flex;
					justify-content: space-between;

					.left {
						text-align: center;
						// padding: 15rpx 25rpx;
						padding-top: 20rpx;

						width: 160rpx;
						background-color: $theme-oa-color;
						color: white;
						border-radius: 40rpx;

						.cir {
							width: 120rpx;
							height: 120rpx;
							background-color: #ffffff;
							margin-left: 25rpx;
							border-radius: 120rpx;
							position: relative;
						}
					}

					.right {
						display: flex;
						flex-direction: column;
						justify-content: space-between;

						view {
							margin: 10rpx 0;

							text:nth-child(2) {
								margin-left: 20rpx;
							}
						}
					}
				}

				.u_avatar {
					position: absolute;
					top: 50%;
					left: 50%;

					transform: translate(-50%, -50%);
				}
			}
		}

		// .info_card {
		// 	width: 694rpx;
		// 	// height: 300rpx;
		// 	background: #FFFFFF;
		// 	border-radius: 21rpx 21rpx 21rpx 21rpx;
		// 	margin-top: 28rpx;
		// 	padding: 24rpx;

		// 	.top {
		// 		display: flex;
		// 		justify-content: space-between;
		// 		align-items: center;
		// 		margin-bottom: 28rpx;

		// 		.info_name {
		// 			font-size: 32rpx;
		// 			font-weight: 500;
		// 			color: #333333;
		// 		}

		// 		.have {
		// 			&::before {
		// 				content: "已签约";
		// 				border-radius: 14rpx;
		// 				border: 5rpx solid #5ac725;
		// 				color: #5ac725;
		// 				padding: 3rpx 6rpx;
		// 				font-size: 28rpx;
		// 				margin-right: 10rpx;
		// 			}
		// 		}

		// 		.no {
		// 			&::before {
		// 				content: "未签约";
		// 				border-radius: 14rpx;
		// 				border: 5rpx solid #f56c6c;
		// 				color: #f56c6c;
		// 				padding: 3rpx 6rpx;
		// 				font-size: 28rpx;
		// 				margin-right: 10rpx;
		// 			}
		// 		}

		// 		.info_type {
		// 			font-size: 25rpx;
		// 			font-weight: 500;
		// 			color: $theme-oa-color;
		// 			margin-top: 10rpx;
		// 		}

		// 		.btn {
		// 			flex-shrink: 0;
		// 			font-size: 25rpx;
		// 			font-weight: 400;
		// 			color: #666666;
		// 			display: flex;
		// 			align-items: center;
		// 			justify-content: right;
		// 		}
		// 	}

		// 	.bottom {
		// 		display: flex;
		// 		margin-top: 28rpx;

		// 		image {
		// 			height: 140rpx;
		// 			width: 140rpx;
		// 			margin-right: 28rpx;
		// 		}

		// 		.text {
		// 			display: flex;
		// 			flex-direction: column;
		// 			justify-content: space-between;
		// 		}
		// 	}
		// }


	}
</style>