<template>
	<view class="content">
		<view class="gq-list">
			<view class="gq-item" v-for="item in list" @click="gotoDetail(item)">
				<view class="gq-logo">
					<image :src="item.avatar || '../../../static/images/avt.png'" mode="" class=""></image>
				</view>
				<view class="store-name ellipsis">
					{{type == 5?item.name:item.name }}
				</view>
				<!-- 员工 -->
				<template v-if="type == 5">
					<view class="info">
						<view class="info-tit">
							职务：
						</view>
						<view class="info-val">
							{{item.position||'暂无'}}
						</view>
					</view>
					<view class="info">
						<view class="info-tit">
							工号：
						</view>
						<view class="info-val">
							{{item.userid}}
						</view>
					</view>
				</template>
				<!-- 高管 -->
				<template v-if="type == 4">
					<view class="info">
						<view class="info-tit">
							职务：
						</view>
						<view class="info-val">
							{{item.duties}}
						</view>
					</view>
					<view class="info">
						<view class="info-tit">
							工号：
						</view>
						<view class="info-val">
							{{item.job_no}}
						</view>
					</view>
					<view class="info">
						<view class="info-tit">
							业务：
						</view>
						<view class="info-val">
							{{item.business}}
						</view>
					</view>
				</template>
				<template v-if="type == 3">
					<view class="info">
						<view class="info-tit">
							职务：
						</view>
						<view class="info-val">
							{{item.duties}}
						</view>
					</view>
					<view class="info">
						<view class="info-tit">
							联系：
						</view>
						<view class="info-val">
							{{item.phone}}
						</view>
					</view>
					<view class="info">
						<view class="info-tit">
							地址：
						</view>
						<view class="info-val clamp">
							{{item.address}}
						</view>
					</view>
				</template>
				<!-- <view class="info">
					<view class="info-tit">
						业务：
					</view>
					<view class="info-val">
						创始人
					</view>
				</view> -->

			</view>
		</view>
		<view v-if="list.length == 0 && loadingType=='nomore'">
			<emptyPage title="暂无订单信息~"></emptyPage>
		</view>
	</view>
</template>

<script>
	import { getMen} from "@/api/store.js"
	import emptyPage from '@/components/emptyPage.vue';
	export default {
		components: {
			emptyPage
		},
		data() {
			return {
				type: '',
				list: [],
				loadingType: 'loadmore',
				page: 1,
				limit: 12,
				typename: ''
			}
		},
		onLoad(opt) {
			if (opt.type) {
				this.type = opt.type
				if (this.type == 1) {
					uni.setNavigationBarTitle({
						title: '高管'
					})
					this.typename = 'getOtherList'
				} else if (this.type == 3) {
					uni.setNavigationBarTitle({
						title: '共享股东商家'
					})
					this.typename = 'getOtherList'
				} else if (this.type == 4) {
				 	uni.setNavigationBarTitle({
				 		title: '高管'
				 	})
				 	this.typename = 'getOtherList'
				 }else if (this.type == 5) {
					uni.setNavigationBarTitle({
						title: '员工'
					})
					this.typename = 'getMen'
				}
				this.getList()
			}
		},
		onShow() {

		},
		onReachBottom() {
			this.getList()
		},
		onReady() {

		},
		methods: {
			navto(url) {
				uni.navigateTo({
					url
				})
			},
			gotoDetail(item) {
				// 员工详情
				if (this.type == 5) {
					this.navto('/pagesT/unit/ygdetail?id=' + item.id)
				}

			},
			getList() {
				let that = this;
				let getList;
				if (that.loadingType == 'nomore' || that.loadingType == 'loading') {
					return
				}
				that.loadingType = 'loading'
				if(that.type== 5) {
					getList = getMen
				}
				getList({
					page: that.page,
					limit: that.limit,
				}).then(res => {
					that.list = that.list.concat(res.data.list)
					that.page++
					if (res.data.list.length == that.limit) {
						that.loadingType = 'loadmore'
					} else {
						that.loadingType = 'nomore'
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.gq-list {
		display: flex;
		flex-wrap: wrap;
		justify-content: flex-start;
		// justify-content: space-between;
		padding: 20rpx 0 20rpx 20rpx;
	}

	.gq-item {
		margin: 0 0 20rpx 14rpx;
		width: 227rpx;
		min-height: 351rpx;
		background: #FFFFFF;
		box-shadow: 0px 5rpx 5rpx 0px rgba(35, 24, 21, 0.06);
		border-radius: 10rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: space-between;
		padding: 30rpx 14rpx 20rpx;

		.gq-logo {
			width: 140rpx;
			height: 140rpx;
			border-radius: 50%;
			border: 1px solid #262261;
			display: flex;
			justify-content: center;
			align-items: center;

			image {
				width: 135rpx;
				height: 135rpx;
				background-color: #eee;
				border-radius: 50%;
			}
		}

		.store-name {
			padding-top: 10rpx;
			text-align: center;
			width: 100%;
			font-size: 26rpx;
			font-weight: 500;
			color: #262261;
			overflow: hidden;
		}

		.info {
			width: 100%;
			display: flex;
			padding: 5rpx 0;

			.info-tit {
				font-size: 18rpx;
				flex-shrink: 0;
			}

			.info-val {
				text-align: center;
				font-size: 20rpx;
				width: 140rpx;
				min-width: 140rpx;
				border-bottom: 1px #C7C7C7 solid;
				white-space: nowrap;
				        overflow: hidden;
				        text-overflow: ellipsis;
			}
		}

	}
</style>
