<template>
	<view class="center">
		<view v-for="(item, index) in list" class="item flex" @click="navTo(item)">
			<view class="item-left">
				<view class="item-avator"><image :src="item.image" mode=""></image></view>
				<view class="item-info">
					<view class="item-name">{{ item.name }}</view>
					<view class="address">{{ item.detailed_address }}</view>
				</view>
			</view>
			<view class="item-right"><image src="../../static/img/shop2.png" mode=""></image></view>
		</view>
	</view>
</template>

<script>
import { store_list } from '@/api/info.js';
import { mapState, mapMutations } from 'vuex';
export default {
	data() {
		return {
			list: [],
			pages: 1,
			limit: 1000,
			loadType: 'more'
		};
	},
	computed: {
		...mapState(['userInfo'])
	},
	onLoad() {
		this.loadData();
	},
	methods: {
		loadData() {
			const obj = this;
			if (obj.loadType == 'nomore' || obj.loadType == 'loading') {
				return;
			}
			obj.loadType = 'loading';
			store_list({
				pages: obj.pages,
				limit: obj.limit
			}).then(({ data }) => {
				console.log(data);
				this.list = this.list.concat(data.list);
				if (data.list.length == obj.limit) {
					obj.loadType = 'more';
				} else {
					obj.loadType = 'nomore';
				}
			});
		},
		navTo(item) {
			console.log(item);
			uni.navigateTo({
				url: '/pages/shop/subordinate?id=' + item.id
			});
		}
	}
};
</script>

<style lang="scss">
.item {
	width: 710rpx;
	background: #ffffff;
	box-shadow: 0px 5rpx 5rpx 0px rgba(35, 24, 21, 0.06);
	border-radius: 10rpx;
	margin: 20rpx auto 0;
	padding: 26rpx 30rpx 26rpx 20rpx;
	.item-left {
		display: flex;
		justify-content: start;
		align-items: center;
		.item-avator {
			width: 120rpx;
			height: 120rpx;
			image {
				width: 100%;
				height: 100%;
			}
		}
		.item-info {
			margin-left: 10rpx;
			line-height: 1;
			.item-name {
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #333333;
			}
			.address {
				font-size: 21rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #666666;
				margin-top: 20rpx;
			}
		}
	}
	.item-right {
		width: 16rpx;
		height: 32rpx;
		image {
			width: 100%;
			height: 100%;
		}
	}
}
</style>
