<template>
	<view>
		<view class="width100 backcorfff">
			<image mode="widthFix" class=" flleft sear mart15" src="../../../static/img/btjy.png"></image>
			<uSearchBar @confirm="getGasStoreList" v-model="searname"  @input="getGasStoreList"></uSearchBar>
		</view>
		<slFilter :independence="true" :color="titleColor" :themeColor="themeColor" :menuList.sync="menuList"
			@result="result"></slFilter>
		<view class="width90 height100p backcorfff border-r mart10" v-for="(item,index) in refuelList" :key="index"
			@click="goDetails(item.store_key)">
			<image mode="widthFix" :src="item.store_logo" class="recontleft flleft mart10 border-r" style="max-height: 80px;">
			</image>
			<view class="recontright">
				<view class="text1 width100 font15 fontwig6  paddtop10">{{item.store_name}}</view>
				<view class="width100 mart10 height22">
					<view class="width70 flleft text1 font13 fcor999">
						{{item.address}}
					</view>
					<view class="width30 flright font13 fcor666 fotct">
						<image mode="widthFix" src="../../../static/img/dh.png" style="width: 10px;"></image>1.9km
					</view>
				</view>
				<view class="font14 width100 fcoreb5 mart5 height22">
					<text class="font18 fontwig6">{{item.price_vip}}</text>起<text class="fcor999 margle">油站价￥{{item.price_gun}}</text>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		getGasStoreList
	} from '../../../Utils/Api.js';
	import slFilter from '@/components/sl-filter/sl-filter.vue';
	import uSearchBar from '../../../components/uni-search-bar/components/uni-search-bar/uni-search-bar.vue';
	let app = getApp();
	export default {
		components: {
			slFilter,
			uSearchBar
		},
		data() {
			return {
				themeColor: '#089bf5',
				titleColor: '#666666',
				filterResult: '',
				menuList: [
					// {
					// 	'title': '品牌',
					// 	'key': 'single',
					// 	'isMutiple': false,
					// 	'detailTitle': '请选择（单选）',
					// 	'reflexTitle': true,
					// 	'defaultSelectedIndex': 0,
					// 	'detailList': [{
					// 			'title': '全部品牌',
					// 			'value': ''
					// 		}, {
					// 			'title': '中石化',
					// 			'value': '中石化'
					// 		}, {
					// 			'title': '中石油',
					// 			'value': '中石油'
					// 		}, {
					// 			'title': '亮牌',
					// 			'value': '亮牌'
					// 		}, {
					// 			'title': '其他',
					// 			'value': '其他'
					// 		},

					// 	]

					// },

					{
						'title': '油号',
						'key': 'single2',
						'isMutiple': false,
						'detailTitle': '',
						'reflexTitle': true,
						'defaultSelectedIndex': 0,
						'detailList': [
							{
							'detatitle': '汽油',
							'dataList': [{
								'title': '90#',
								'value': ''
							}, {
								'title': '92#',
								'value': '92#'
							}, {
								'title': '95#',
								'value': '95#'
							}, {
								'title': '98#',
								'value': '98#'
							}, {
								'title': '101#',
								'value': '101#'
							}]
						},
						 ]
					},
					{
						'title': '距离',
						'key': 'single3',
						'isMutiple': false,
						'detailTitle': '',
						'reflexTitle': true,
						'defaultSelectedIndex': 0,
						'detailList': [{
								'title': '6km内',
								'value': ''
							},
							{
								'title': '10km内',
								'value': '10km内'
							},
							{
								'title': '15km内',
								'value': '15km内'
							},
							{
								'title': '20km内',
								'value': '20km内'
							},
							{
								'title': '50km内',
								'value': '50km内'
							}
						]
					}, {
						'title': '距离',
						'key': 'single1',
						'isMutiple': false,
						'detailTitle': '',
						'reflexTitle': true,
						'defaultSelectedIndex': 0,
						'detailList': [{
							'title': '距离最近',
							'value': ''
						}]

					}
				],
				refuelList: [],
				pageNum: 1,
				pageSize: 10,
				isNoMoreData: false,
				searname:''
			}
		},
		onLoad() {
			this.getGasStoreList();
		},
		methods: {
			//查询列表
			getGasStoreList() {
				uni.showLoading({
					title: '加载中...'
				})
				if (this.isNoMoreData) {
					uni.hideLoading()
					return false;
				}
				let pagenum = this.pageNum;
				let params = {
					storeName : this.searname,
					distance: '999',
					regionId: '110000',
					oilNoName: '92#',
					latitude: app.globalData.latitude,
					longitude: app.globalData.longitude,
					pageNum: pagenum,
					pageSize: this.pageSize
				}
				getGasStoreList(params).then(res => {
					if (res.return_code == '000000') {
						uni.hideLoading();
						this.isNoMoreData = res.return_data.list.length == this.pageSize ? false : true;
						if (res.return_data.total == (this.pageNum * this.pageSize)) {
							this.isNoMoreData = true;
						}
						this.refuelList = this.refuelList.concat(res.return_data.list);
						this.pageNum = res.return_data.list.length == this.pageSize ? ++pagenum : pagenum;
					} else {
						this.refuelList = [];
						uni.hideLoading()
					}
				})
			},
			//跳转详情
			goDetails(items) {
				uni.navigateTo({
					url: '../refuel-details/refuel-details?id='+items
				})
			},
			result(val) {
				console.log('filter_result:' + JSON.stringify(val));
				this.filterResult = JSON.stringify(val, null, 2)
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f6f6f6;
	}

	.sear {
		margin-left: 10px;
		width: 50px;
	}

	.searImg {
		margin-left: 55px;
	}

	.recontleft {
		width: 80px;
		margin-left: 10px;
	}

	.recontright {
		margin-left: 95px;
	}

	.text {
		margin-top: 50px;
		margin-left: 20px;
		width: 100%;
	}
</style>
