<template>
	<view>
		
		<view class="bg-white echo-agent-list">
			<block v-for="(item,index) in plist" :key="index">
				<view class="flex solid-bottom padding justify-between echo-item" @tap="goDetail(item.id)">
					<image class="radius echo-tilpic" mode="aspectFill" :src="item.tilpic"></image>
					<view class="echo-content">
						<view class="echo-title text-lg text-black text-bold text-cut">{{item.title}}</view>
						<view class="echo-tags text-gray text-cut">
							<text class="cuIcon-location padding-right-xs"></text> {{item.address}}
						</view>
						<view class="flex justify-between align-end text-gray">
							<view class="echo-wagall">距离：{{item.juli}} Km</view>
						</view>
					</view>
				</view>
			</block>
		</view>
		
		<view class="padding-tb-lg text-center text-gray">
			线下服务店过多，仅显示附近{{psize}}个门店。
		</view>
		
		<!-- <uni-load-more :status="pstatus"></uni-load-more> -->
		
	</view>
</template>

<script>
	import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue";
	var _this;
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				pstatus: 'more',
				psize: 5,
				plist: [],
				lat: 0.00,
				lng: 0.00
			};
		},
		onLoad: function(){
			_this = this;
			uni.getLocation({
				type: 'gcj02',
				success: function(res) {
					_this.lat = res.latitude;
					_this.lng = res.longitude;
					_this.getMore();
				}
			});
		},
		onPullDownRefresh: function() {
			_this.pstatus = 'more';
			_this.plist = [];
			_this.getMore();
		},
		onShareAppMessage: function(res) {
			return {
				title: "代理门店",
				path: "/pages/agent/agent"
		    }
		},
		methods: {
			getMore: function() {
				_this.$req.ajax({
					path: "agent/listagent",
					data: {
						psize: _this.psize,
						lat: _this.lat,
						lng: _this.lng
					}
				}).then((data) => {
					_this.pstatus = data.pstatus;
					_this.plist = _this.plist.concat(data.plist);
					uni.stopPullDownRefresh();
				}).catch((err) => {
					uni.showModal({
						title: '信息提示',
						content: err,
						showCancel: false
					});
				});
			},
			goDetail: function(agentid) {
				uni.navigateTo({
					url: '/pages/agent/detail?agentid=' + agentid
				});
			}
		}
	}
</script>

<style>
</style>
