<template>
	<view class="content">
		<view class="flex-start">
			<view class="onecontent_oen flex-start">
				<input class="onecontent_oen_input" type="text" v-model="like" placeholder="请输入员工姓名">
				<text class="onecontent_oen_text" @click="inif">搜索</text>
			</view>
			<view class="onecontent_oen_right flex-start" @click="showpickerclick">
				<view class="onecontent_oen_rightimageview">员工分类</view>
			</view>
		</view>

		<view class="towcontent">
			<view class="towcontentitem flex-between" v-for="(item,index) in list" :key="index"
				@click="contentfixedclick(item)">
				<view class="towcontentitem_one flex-colum-start">
					<text class="towcontentitem_onetext">{{item.nickname}}</text>
					<text class="towcontentitem_towtext">{{item.mobile}}</text>
				</view>
				<u-icon name="arrow-right" color="#999999" size="18"></u-icon>
			</view>
		</view>
		<view v-if="list.length==0 && is_end == true" class="flex-colum">
			<image style="margin-top:100rpx;"
				src="https://ointmentweapp.oss-cn-beijing.aliyuncs.com/image/my/order/nothave.png" mode="">
			</image>
		</view>
		<u-loadmore :status="form.status" />
		<view class="contentfixed" @click="contentfixedclick">
			+
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				list: [],
				is_end: false,
				like: '',
				form: {
					page: 1,
					status: 'loadmore',
				},
			}
		},
		onShow() {
			this.inif()
		},
		onReachBottom() {
			this.stafflist()
		},
		methods: {
			showpickerclick() {
				uni.pro.navigateTo('staff/createcap')
			},
			inif() {
				this.list = []
				this.is_end = false,
					this.form = {
						page: 1,
						status: 'loadmore',
					},
					this.stafflist()
			},
			contentfixedclick(e) {
				uni.pro.navigateTo('staff/add', {
					id: e.staff_id
				})
			},
			async stafflist() { //
				let res = await this.api.stafflist({
					like: this.like,
					page: this.form.page
				});
				if (res.code == 1) {
					if (res.data.length == 0) {
						this.is_end = true
						this.form.status = 'nomore'
						return false;
					} else {
						this.form.status = 'loading';
						this.form.page = ++this.form.page;
						setTimeout(() => {
							this.list = [...this.list, ...res.data];
							if (res.data.length == 10) {
								this.form.status = 'loading';
							} else {
								this.is_end = true;
								this.form.status = 'nomore';
							}
						}, 500)

					}
				}
			},

		}
	}
</script>

<style lang="scss">
	page {
		background: #FBFBFA;
	}

	.content {
		margin: 28rpx 30rpx;
		position: relative;
		top: 0;
		right: 0;

		.contentfixed {
			position: fixed;
			background: #2F87FD;
			bottom: 16%;
			right: 5%;
			font-size: 52rpx;
			color: #FFFFFF;
			width: 100rpx;
			height: 100rpx;
			line-height: 100rpx;
			text-align: center;
			border-radius: 50%;
		}

		.flex-start {
			flex-wrap: nowrap;

			.onecontent_oen {
				margin: 0 auto;
				flex: auto;
				height: 70rpx;
				border-radius: 36rpx;
				border: 2rpx solid #6699FF;
				padding-right: 8rpx;

				.onecontent_oen_input {
					padding-left: 32rpx;
					flex: 1;
				}

				.onecontent_oen_text {
					font-size: 28rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #FFFFFF;
					text-align: center;
					line-height: 56rpx;
					width: 116rpx;
					height: 56rpx;
					background: #6699FF;
					border-radius: 36rpx;
				}
			}

			.onecontent_oen_right {
				margin-left: 26rpx;

				.onecontent_oen_rightimage {
					width: 17.9rpx;
					height: 19.34rpx;
				}

				.onecontent_oen_rightimageview {
					text-align: center;
					margin-left: 10rpx;
					font-size: 28rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #333333;
				}
			}
		}


		.towcontent {
			width: 100%;

			.towcontentitem {
				margin-top: 30rpx;
				padding-bottom: 14rpx;
				border-bottom: 2rpx solid #E5E5E5;

				.towcontentitem_one {
					font-size: 32rpx;
					font-family: SourceHanSansCN-Regular, SourceHanSansCN;
					font-weight: 400;
					color: #000000;
				}

				.towcontentitem_towtext {
					margin-top: 10rpx;
					font-size: 24rpx;
					font-family: SourceHanSansCN-Regular, SourceHanSansCN;
					font-weight: 400;
					color: #999999;
				}
			}
		}
	}
</style>