<template>
	<view class="userListPage">
		<u-navbar autoBack placeholder bgColor="#FFFFFF">
			<view class="navSlot" slot="center">
				<!-- <u-icon name="arrow-left" size="19"></u-icon> -->
				<view class="title">用户管理</view>
			</view>
		</u-navbar>
		<view class="search">
			<u-search placeholder="搜索用户姓名/昵称，手机号" :showAction="false" v-model="field" @search="search" bgColor="#FAF7F6"
				:animation="false">
			</u-search>
		</view>
		<view class="bgMain">
			<view class="userList" v-for="(item,index) in dataList" :key="index">
					<view class="userItem" >
						<view style="display: flex;">
							<view>
								<image class="img" :src="item.avatarUrl"></image>
							</view>
							<view class="userinfo">
								<view style="font-size: 28rpx;color: #333333; ">{{item.nickName}}</view>
								<view style="font-size: 24rpx;color: #999999; padding-top: 5rpx;">手机号：{{item.phoneNumber}}</view>
								<view style="font-size: 24rpx;color: #999999; padding-top: 5rpx;">注册时间：{{item.createTime}}
								</view>
							</view>
						</view>
					
						<view class="butgarage" @click="garageList(item)">
							TA的车库
						</view>
					</view>
					<u-line class="line" length="100%"></u-line>
					<view class="detailsOrder">
						<view class="historicalOrders" @click="startHistoricalOrders(item)">历史订单</view>
						<!-- <view>	<u-line class="line" direction="col"></u-line></view> -->
						<view class="sleDetail" @click="startUserDetail(item)">查看详情</view>
					</view>
				
			</view>
		</view>
		<!-- <tabBar :pageIndex="1" :textType="1" @toTab="toTab"></tabBar> -->
	</view>
</template>

<script>
	// import tabBar from '@/components/Madman-tabBar/tabBar.nvue';
	export default {
		components: {
			// tabBar
		},
		data() {
			return {
				pageNum: 1,
				total: 0,
				dataList: [],
				field:''
			}
		},

		mounted() {
			this.pageNum = 1
			this.getAfterSalesOrderList()
		},

		onReachBottom() {
			console.log(this.total, this.dataList.length);
			if (this.total > this.dataList.length) {
				this.pageNum = this.pageNum + 1
				this.getAfterSalesOrderList(true)
			} else {
				wx.showToast({
					title: '没有更多啦！',
					icon: 'none'
				})
			}
		},

		methods: {
			
			search(){
				this.pageNum = 1
				this.getAfterSalesOrderList()
			},

			getAfterSalesOrderList(flag) {
				this.$http.post("/api/store/clientUser/list", {
					pageNum: this.pageNum,
					pageSize: '20',
					field: this.field
				}).then(res => {
					if (res.code == 200)
						console.log(res.data.rows)
					this.dataList = !flag ? res.data.rows : this.dataList.concat(res.data.rows)
					this.total = res.data.total

				})
			},


			toTab(data) {
				uni.switchTab({
					url: data.pageUrl
				})
			},
			garageList(item) {
				uni.navigateTo({
					url: '/pages/garageList/garageList?id='+item.id
				})
			},
			startUserDetail(item) {
				uni.navigateTo({
					url: '/pages/userDetails/userDetails?id=' + item.id
				})
			},
			startHistoricalOrders(item) {
				uni.navigateTo({
					url: '/pages/historicalOrders/historicalOrders?id=' + item.id
				})
			}

		}
	}
</script>

<style lang="scss">
	
	.userListPage{
		padding-bottom: 200rpx;
	}
	page{
		padding-bottom: 200rpx;
	}
	

	.butgarage {
		width: 166rpx;
		height: 60rpx;
		text-align: center;
		font-size: 28rpx;
		line-height: 60rpx;
		background: linear-gradient(90deg, #FF4502 0%, #FF8903 100%);
		border-radius: 30rpx 30rpx 30rpx 30rpx;
		color: white;
	}

	.userList {
		margin-top: 20rpx;
		background: #FFFFFF;
		border-radius: 14rpx 14rpx 14rpx 14rpx;
		padding: 24rpx;

		.detailsOrder {
			display: flex;
			align-items: center;
			padding-top: 15rpx;

			.historicalOrders {
				width: 50%;
				font-size: 28rpx;
				color: #0278FF;
				text-align: center;
			}

			.sleDetail {
				width: 50%;
				font-size: 28rpx;
				color: #FF4502;
				text-align: center;
			}
		}

		.line {
			padding-top: 10rpx;
		}

		.userItem {
			
			justify-content: space-between;
			display: flex;

			.userinfo {
				padding-left: 10rpx;
			}

			.img {
				width: 120rpx;
				height: 120rpx;
			}
		}
	}

	.search {
		padding: 24rpx;
	}
</style>