<template>
	<view class="content">
		<view>
			<scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="reachBottom"
			@scroll="scroll">
				<view class="">
					
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	
	export default {
		components: {},
		data() {
			return {
				storeList: [],
				currentPosition: {
				  lat: '0',
				  lng: '0'
				},
				pageNo: 1,
				pageSize: 10
			}
		},
		onShow() {
			 
		},
	    onLoad() {
		    // 获取当前经纬度
		    let _this = this
		    uni.getLocation({
				 type: 'wgs84', // 默认wgs84
				 success: function(res) {
				   _this.currentPosition.lat = res.latitude;
				   _this.currentPosition.lng = res.longitude;
				   _this.gpsCompletion = true;
				   // 查询门店信息
				   // _this.getStoresList()
				 },
				 fail: function(res) { 
					 console.log(res)
					 // 查询门店信息
					 // _this.getStoresList()
				 },
		    });
	    },
		
		computed: {
		},
		methods:{
			getStoresList () {
				uni.showLoading({
					title: '正在加载...'
				})
				let lat = this.currentPosition.lat
				let lng = this.currentPosition.lng
				getStoresList({pageNo:this.pageNo,pageSize:this.pageSize,lat:lat,lng:lng}).then(res => {
					console.log(res)
					if(res.status == 200){
						let list = res.data.list
						if(list&&list.length){
							list.map(item => {
								if (item.addrDetail.indexOf("省")>0 && item.addrDetail.indexOf("市")>0 && item.addrDetail.indexOf("区")>0){
									item.addrDetail = item.addrDetail
								} else {
									if (item.addrDetail.indexOf("市")>0 && item.addrDetail.indexOf("区")>0){
										item.addrDetail = item.addrProvinceName + item.addrDetail
									} else if (item.addrDetail.indexOf("区")>0) {
										item.addrDetail = item.addrProvinceName + item.addrCityName + item.addrDetail
									} else {
										item.addrDetail = item.addrProvinceName + item.addrCityName + item.addrDistrictName + item.addrDetail
									}
								}
								item.distance = item.distance ? Math.round(item.distance/1000) : ''
								item.star = getStarNum(item.level)
							})
							this.storeList = this.storeList.concat(list)
						}else{
							if(this.pageNo!=1){
								uni.showToast({
									title: '已经是最后一页'
								})
								this.isLastPage = true
							}
						}
					}
					uni.hideLoading()
				})
			},
			// 到达底部
			reachBottom () {
				
			}
			
		}
	}
</script>

<style lang="scss" scoped>
	
</style>
