<template>
	<view class="">
		<view class="">
			<view style="position: fixed;z-index: 100;">
				<uni-nav-bar @clickRight="clickRight" left-icon="back" left-text="返回" right-icon="plus" title="用户管理"></uni-nav-bar>
			</view>
			<view class="uinput-box">
				<view class="uinputs">
					<u-input v-model="argument.username" :type="type" :border="border" placeholder="请输入用户名称" input-align="center"
					 :clearable="border" :custom-style="uinputstyle" @input="searchinput" />
					<u-icon name="search" class="search" size="30" @click="search"></u-icon>
				</view>
			</view>
			<view class="userlists">
				<view class="userlist-li" v-for="(item,index) in userlists" :kex="index" @click="userOperation(userlists[index])">
					<image src="../../../static/image/fourMoodBase/touxiang.png" mode=""></image>
					<p class="userlist-li-city">{{item.username}}</p>
					<p class="userlist-li-eamil">{{item.mobile}}</p>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		Debounce,
		Throttle
	} from "../../../util/anitthro.js"
	export default {
		data() {
			return {
				value: '',
				type: 'text',
				border: false,
				uinputstyle: {
					"margin": "16rpx 0",
					'background': "#f3f3f3",
					"border-radius": "25px"
				},
				userlists: [],
				argument: {
					page: 1,
					page_size: 10,
					username: ''
				}
			}
		},
		methods: {
			async getState(argument) {
				const res = await this.$myRequest({
					url: '/api/api_gateway?method=user.login.users_info',
					data: {
						page: argument.page,
						page_size: argument.page_size,
						username: argument.username
					}
				})
				this.userlists = this.userlists.concat(res.data)
			},
			clickRight() { //跳转增加用户页面
				uni.navigateTo({
					url: './addusers',
				})
			},
			userOperation(item) { //跳转用户信息页面
				item = JSON.stringify(item)
				uni.navigateTo({
					url: './useroperation?item=' + item,
				})
			},
			search() { //搜索用户
				this.userlists = []
				this.getState(this.argument)
			},
			searchinput() {
				this.argument.page=1
				Debounce(() => {
					this.userlists = []
					this.getState(this.argument)
				}, 1000)()
			}
		}, //user.login.users_info
		onLoad() {
			this.getState(this.argument)
		},
		onReachBottom() {
			this.argument.page++
			this.getState(this.argument)
		},
		onPullDownRefresh() {
			this.getState(this.argument)
			setTimeout(function() {
				uni.stopPullDownRefresh(); //停止下拉刷新动画
			}, 1000);
		}
	}
</script>
1
<style lang="scss">
	.uinput-box {
		position: fixed;
		top: 89rpx;
		z-index: 100;
		background-color: white;
		width: 100%;
		display: flex;
		justify-content: center;
		align-items: center;

		.uinputs {
			width: 95%;
			position: relative;

			.search {
				position: absolute;
				top: 40rpx;
				left: 200rpx;
			}
		}
	}

	.userlists {
		width: 100%;
		position: relative;
		top: 180rpx;

		.userlist-li {
			width: 46%;
			height: 270rpx;
			margin: 20rpx 0 0 20rpx;
			float: left;
			box-shadow: 0 0 10rpx #bcb9ca;
			text-align: center;

			image {
				width: 80rpx;
				height: 80rpx;
				margin: 40rpx 0 20rpx;
			}
		}
	}
</style>
