<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" mode="" class=""></image>
				</view>
				<view class="store-name ellipsis">
					{{type == 5?item.staffName:item.name }}
				</view>
				<!-- 员工 -->
				<template v-if="type == 5">
					<view class="info">
						<view class="info-tit">
							职务:
						</view>
						<view class="info-val">
							{{item.departmentName}}
						</view>
					</view>
					<view class="info">
						<view class="info-tit">
							工号:
						</view>
						<view class="info-val">
							{{item.staffCode}}
						</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>
		<u-loadmore :status="loadingType" />
	</view>
</template>

<script>
	export default {
		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 = 'getAllygList'
				}
				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
				if (that.loadingType == 'nomore' || that.loadingType == 'loading') {
					return
				}
				that.loadingType = 'loading'
				this.$u.api[that.typename]({
					page: that.page,
					pageSize: that.limit,
					type: that.type
				}).then(res => {
					console.log(res)
					that.list = that.list.concat(res.data)
					that.page++
					if (res.data.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;
				border-bottom: 1px #C7C7C7 solid;
			}
		}

	}
</style>