<template>
	<view>
		<view class="width90 stoCont" v-for="(store,i) in storeList" :key="i">
			<view class="width80p flleft mart10">
				<view class="font16 fcor333 fontwig6 text1">{{store.storeName}}</view>
				<view class="font13 fcor666 mart10 text1">{{store.address}}</view>
			</view>
			<view class="width20 flright mart10 fotrt" @click="seeloaction(store)">
				<image mode="widthFix" style="width: 25px;height: 25px;" :src="imagewxUrl+imgadres1">
				</image>
				<view class="mart5 fcor999 font13">{{store.distance}}km</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getStoreListByCoupon
	} from '../../Utils/Api.js';
	let app = getApp();
	export default {
		data() {
			return {
				storeList: [],
				couDesId: '',
				imagewxUrl: app.globalData.imageWxImg,
				imgadres1: 'dhl.png',
				pageNum: 1,
				pageSize: 15,
				isNoMoreData: false
			}
		},
		onLoad(options) {
			this.couDesId = options.id;
			this.getStoreListByCoupon();
		},
		onReachBottom() {
			this.getStoreListByCoupon();
		},
		methods: {
			/**
			 * 查询门店列表
			 */
			getStoreListByCoupon() {
				uni.showLoading({
					title: '加载中...'
				})
				if (this.isNoMoreData) {
					uni.hideLoading()
					return false;
				}
				let pagenum = this.pageNum;
				let params = {
					couponId: this.couDesId,
					longitude: app.globalData.longitude,
					latitude: app.globalData.latitude,
					pageNum: pagenum,
					pageSize: this.pageSize
				}
				getStoreListByCoupon(params).then(res => {
					if (res.return_code == '000000' && res.return_data.list != '') {
						uni.hideLoading();
						this.isNoMoreData = res.return_data.list.length == this.pageSize ? false : true;
						this.storeList = this.storeList.concat(res.return_data.list);
						if (res.return_data.total == (this.pageNum * this.pageSize)) {
							this.isNoMoreData = true;
						}
						this.pageNum = res.return_data.list.length == this.pageSize ? ++pagenum : pagenum;
					} else {
						this.storeList = [];
						uni.hideLoading()
					}
				})
			},
			//导航
			seeloaction(e) {
				uni.openLocation({
					latitude: Number(e.latitude), //目的地的定位
					longitude: Number(e.longitude), //目的地的定位
					name: e.storeName,
					address: e.address
				})
			},

		}
	}
</script>

<style lang="scss">
	.stoCont {
		border-bottom: 1px solid #f6f6f6;
		height: 140rpx;
	}
</style>
