<template>
	<view class="xkl-com-bg">
		<view style="height: 20rpx;"></view>
		<navigator url="/pages/admin/shop/create">
			<u-button type="primary">添加</u-button>
		</navigator>
		<view style="height: 20rpx;"></view>
		<u-search placeholder="请输入手机号" shape="square" v-model="search.mobile" @search="onsearch"></u-search>
		<view style="height: 20rpx;"></view>
		<view>
			<navigator :url="`/pages/team/detail?team_shop_id=${item.id}`" v-for="(item,index) in shopItems"
				:key="index"
				style="background-color: #ffffff;color: #666666;padding: 20rpx;font-size: 28rpx; margin-bottom: 20rpx;border-radius: 12rpx;">
				<view class="u-flex">
					<view>
						<view>用户名：{{item.username}}</view>
						<view style="height: 10rpx;"></view>
						<view>手机号：{{item.mobile}}</view>
						<view style="height: 10rpx;"></view>
						<view>余额：{{item.money}}</view>
					</view>
					<view style="width: 100rpx;"></view>
					<view>
						<view>等级：v{{item.vip}}</view>
						<view style="height: 10rpx;"></view>
						<view>充电桩：{{item.device_num}}</view>
						<view style="height: 10rpx;"></view>
						<view>已安装：{{item.install_num}}</view>
					</view>
				</view>
				<view style="height: 20rpx;"></view>
				<view>注册时间：{{item.created_at}}</view>
				<!-- <view class="u-flex u-flex-between">
					<view>用户名：{{item.username}}</view>
					<view>手机号：{{item.mobile}}</view>
				</view>
				<view style="height: 10rpx;"></view>
				<view class="u-flex u-flex-between">
					<view>等级：v{{item.vip}}</view>
					<view>余额：{{item.money}}</view>
				</view>
				<view style="height: 10rpx;"></view>
				<view class="u-flex u-flex-between">
					<view>充电桩：{{item.device_num}}</view>
					<view>已安装：{{item.install_num}}</view>
				</view>
				<view style="height: 10rpx;"></view>
				<view>注册时间：{{item.created_at}}</view> -->
			</navigator>
		</view>
		<u-loadmore :status="loadStatus" />
		<view style="height: 100rpx;"></view>
	</view>
</template>

<script>
	let self;
	export default {
		data() {
			return {
				shopItems: [],
				status: [],
				type: [],
				loadStatus: 'loadmore',
				search: {
					page: 1,
					status: 0,
					mobile: ''
				},
				page: {
					current: 0,
					last_page: 1
				}
			}
		},
		onLoad() {
			self = this;
		},
		onShow() {
			self.shopItems = [];
			self.getShopItems();
		},
		onPullDownRefresh() {
			self.search.page = 1;
			self.shopItems = [];
			self.getShopItems();
			uni.stopPullDownRefresh();
		},
		onReachBottom() {
			if (!self.pageStatus()) {
				return;
			}
			self.loadStatus = 'loading';
			self.search.page = ++self.search.page;
			self.getShopItems();
		},
		methods: {
			onsearch() {
				self.shopItems = [];
				self.getShopItems();
			},
			pageStatus() {
				self.loadStatus = 'loadmore';
				if (self.search.page >= self.page.last_page) {
					self.loadStatus = 'nomore';
					return false;
				}
				return true;
			},


			getShopItems() {
				self.$http.get('/shop/admin/shop/items', self.search).then(({
					data,
					success
				}) => {
					self.shopItems = self.shopItems.concat(data.data);
					self.page.last_page = data.last_page;
					self.pageStatus();
				})
			},
		}
	}
</script>

<style lang="scss">

</style>