<template>
	<view class="container">
		<view class="search-user flex-y-center ">
			<view class="search-content flex-y-center">
				<icon type="search" size="18" />
				<input confirm-type="search" v-model="seTval" @confirm="confirm" @input="getSearch" class="flex-grow-1"
					type="text" placeholder-style="font-size:26rpx" placeholder="请输入搜索内容" />
				<view class="flex-center" style="margin-left: 10rpx;" @click.stop="onDel" v-if="seTval">
					<icon type="clear" size="18" />
				</view>
			</view>
			<view class="search-btn" @click="search">
				搜索
			</view>
		</view>
		
		<view class="hg100rpx">
		</view>
		
		<view class="list">
			<view class="item" v-for="(item,index) in list" :key="index" @click="toDetail(item.id)">
				<view class="name">账号:{{item.name}}</view>
				<view class="content">
					<view class="cell flex flex-y-center">
						<view class="title">名称：</view>
						<view class="desc">{{item.nickname}}</view>
					</view>
					<view class="cell flex flex-y-center">
						<view class="title">所属门店：</view>
						<view class="desc">{{item.storename}}</view>
					</view>
					<view class="cell flex flex-y-center">
						<view class="title">创建时间：</view>
						<view class="desc">{{item.create_time}}</view>
					</view>
				</view>
			</view>
			<view class="no-more">没有更多内容了~</view>
		</view>

		<view class="footer-bar">
			<view class="content flex flex-center">
				<navigator url="./addstorenumber" class="btn">+新增账号</navigator>
			</view>
		</view>
		
			
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				admin_id:"",
				list: [],
				page: 1,
				is_bottom: false,
				keywords:'',
			}
		},
		
		onLoad(options) {
			this.admin_id = uni.getStorageSync("admin_id");
		},
		onShow() {
			this.getData(1)
		},
		
		onReachBottom() {
			if (!this.is_bottom) {
				this.getData(this.page + 1)
			}
		},
		
		methods: {
	
			getSearch(e) {
				if (!e.detail.value) {
					this.page = 1;
					this.list = [];
					this.keywords = "";
					this.getData(1);
				}
				this.keywords = e.detail.value;
			},
			
			onDel() {
				this.list = [];
				this.keywords = "";
				this.getData(1);
			},
			
			confirm(e) {
				this.list = [];
				this.keywords = e.detail.value;
				this.getData(1);
			},
			
			search(e) {
				this.page = 1;
				this.list = [];
				this.getData(1);
			},
			
			toDetail(id){
				// let info = JSON.stringify(this.list[index])
				uni.navigateTo({
					url:`./storeNumberdetail?id=${id}`
				})
			},
			
			getData(page) {
				if (page == 1) {
					this.list = []
					this.page = 1
					this.is_bottom = false
				}
				this.request({
					url: 'Smdcshop/store_user_index',
					data: {
						page,
						limit: 10,
						admin_id: this.admin_id,
						serch:this.keywords,
					}
				}).then(res => {
					if (res.code == 200 && res.data.length) {
						this.list = this.list.concat(res.data)
						this.page = page
					} else {
						this.is_bottom = true
					}
				})
			}
		}
	}
</script>

<style>
	@import url("../static/css/common.css");

	page {
		background-color: #F4F5F7;
	}

	.list {
		padding: 30rpx 25rpx;
	}

	.list .item {
		border-radius: 8rpx;
		overflow: hidden;
		padding-left: 30rpx;
		border-left: 8rpx solid #247EFF;
		background-color: #fff;
		margin-bottom: 30rpx;
	}

	.list .item .name {
		height: 80rpx;
		border-bottom: 1rpx solid #f5f5f5;
		font-size: 30rpx;
		line-height: 80rpx;
		font-weight: bold;
	}

	.list .item .content {
		padding: 20rpx 0 24rpx;
	}

	.list .item .content .cell {
		flex: none;
		width: 100%;
		box-sizing: border-box;
		padding-right: 30rpx;
		font-size: 26rpx;
		line-height: 37rpx;
		color: #666;
	}

	.list .item .content .cell .title {
		color: #99A0AD;
	}
	.hg100rpx{
		height: 100rpx;
	}
</style>
