<template>
	<block>
		<view class="item" v-for="(item,index) in list" :key='index' @click="opMap(item.lat,item.lng)">
			<image class="sImg" :src="item.image"
				mode=""></image>
			<view class="info">

				<view class="ititle">

					<view>{{item.storename}}</view>
					<image
						src="https://ymyun-oss.oss-cn-hangzhou.aliyuncs.com/yidu_tc/public/upload/12/8/758f62af7f9f4e5b1d96b51619d07b19.png"
						mode=""></image>

				</view>


				<view class="iphone">
					<image
						src="https://ymyun-oss.oss-cn-hangzhou.aliyuncs.com/yidu_tc/public/upload/12/8/658f859a103b4c4f20e3645fa557b592.png"
						mode=""></image>
					<view>{{item.phone}}</view>
				</view>

				<view class="iaddress">

					<view class="addressLeft">
						<image
							src="https://ymyun-oss.oss-cn-hangzhou.aliyuncs.com/yidu_tc/public/upload/12/8/f598a75a5fcbbcb06f90f2858fbf08af.png"
							mode=""></image>
						<view>{{item.storeaddress}}</view>
					</view>

					<view class="addressRight">
						{{item.distance||0}}m
					</view>

				</view>

			</view>
		</view>
    <view v-if="!list.length" style='color:#999;text-align:center;margin:150rpx 0;font-size:30rpx'>暂无数据</view>

	</block>
</template>
<script module="parse" lang="wxs">
	module.exports = {

		filterNum: function(value) {


			var value = value + ''

			console.log(value)


			var card = value.replace(getRegExp('(/^(\d{4})\d+(\d{4})$/)', 'g'), '$1 **** **** $2')

			return card


		}


	}
</script>
<script>
	// pages/tabbar/index/index.js
	var app = getApp();

	export default {
		data() {
			return {
				navIndex: 0,
				list: [

					// {
					// 	account: "hhD",
					// 	bank_name: "农业银行",
					// 	card_no: "6228481561378773113",
					// 	card_no_end: "3113",
					// 	create_time: "1659088920",
					// 	id: "7",
					// 	is_default: "0",
					// 	status: "1",
					// 	uniacid: "3",
					// 	update_time: "1659088920",
					// 	user_id: "1"
					// }
				],
				loaded: false,
				page: 1,
				type: '',
				pageSize: 10
			};
		},
		onLoad: function(options) {
			var that = this;
			uni.getLocation({
				 type: 'gcj02',
				 success (res) {
					 
				  that.latitude = res.latitude
				   that.longitude = res.longitude
				   
				   that.getlist();
				
				 }
			})
			
		},

		onShow() {
		},
		onPullDownRefresh: function() {},
		onReachBottom: function() {
			this.loaded || this.getlist();
		},
		onShareAppMessage: function() {},
		methods: {
			opMap(lat,lng) {
				uni.openLocation({
					latitude: lat,
					longitude: lng,
					success(e) {

					}
				})
			},
			toPage(e) {
				app.globalData.toPage(e);
			},

			init() {

				this.page = 1
				this.loaded = false
				this.list = []

			},

			async getlist() {
				var that = this;
				let res = await this.$api.request('/Store/index', 'GET', {
					page: this.page,
					pagesize: this.pageSize,
					lat: this.latitude,
					lng: this.longitude,
				});

				console.log(res.list)
				if (res) {
					if (res.list.length > 0) {

						this.list = this.list.concat(res.list);

						this.page++;

					} else {
						this.loaded = true
						this.$api.msg('没有更多数据');
					}
				}
			}
		}
	};
</script>
<style>
	page {
		background: #F5F5F5;
	}


	.item {
		background: #fff;
		border-radius: 12rpx;
		overflow: hidden;
		margin: 30rpx;
		display: flex;
		align-items: center;
		padding: 30rpx 22rpx;
		box-sizing: border-box;
	}


	.sImg {
		width: 120rpx;
		height: 120rpx;
		border-radius: 12rpx;
	}


	.info {
		margin-left: 17rpx;
		flex: 1;
	}

	.ititle {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.ititle>image {
		width: 30rpx;
		height: 30rpx;
	}

	.ititle>view {
		color: #010101;
		font-size: 32rpx;
	}


	.iphone {
		display: flex;
		align-items: center;
		margin: 12rpx 0;
	}

	.iphone>image {
		width: 36rpx;
		height: 36rpx;
	}

	.iphone>view {
		font-size: 26rpx;
		color: #8E8E8E;
		margin-left: 4rpx;
	}

	.iaddress {
		display: flex;
		align-items: flex-start;
		justify-content: space-between;

	}

	.addressLeft {
		display: flex;
		align-items: center;
		align-items: flex-start;
	}

	.addressLeft>image {
		width: 36rpx;  
		height: 36rpx;
	}

	.addressLeft>view {
		font-size: 26rpx;
		width: 326rpx;  
		color: #8E8E8E;
		display: -webkit-box;
		overflow: hidden;
		text-overflow: ellipsis;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		margin-left: 4rpx;
	}

	.addressRight {
		font-size: 26rpx;
		color: #8E8E8E;
	}
</style>
