<template>
	<view style="background-color: #F0F2F5;">
		<!-- <view style="height: var(--status-bar-height);background-color: red;height: 10vh;">dsfdsfsdfds</view> -->
		<view class='productList' :style="viewColor">
			<!-- 顶部 -->
			<view class="top">


				<view class="head_tit">
					<view class="" style="display: flex;align-items: center;">
						<!-- 	<u--image :showLoading="true" src="/static/images/LHYC/PFH.png" width="50.82rpx"
							height="50.82rpx" @click='backjJump'></u--image> -->
						<i class="iconfont icon-xiangzuo" style="font-size: 40rpx;text-align: left;"
							@click='backjJump'></i>
						<view class=""
							style="font-size: 36.8rpx;font-weight: 700;transform: skewX(-10deg);margin-left: 20rpx;color: #F84221;">
							供销综合云市场
						</view>
						<view class=""
							@click="navGoto(`/pages/nongKe/cloud_entrepot/indexa?street=${street_id}&town=${street}&location=${latitude},${longitude}`)"
							style="font-size: 36.8rpx;font-weight: 700;transform: skewX(-10deg);margin-left: 60rpx;">
							供销综合云商品
						</view>
						<!-- <view style="margin-left: 20rpx;transition: 0.3s;" @click="showSelect=!showSelect"
							:class="{selects:showSelect}">
							<u--image :showLoading="true" src="/static/images/GXSC/XL.png" width="33.29rpx"
								height="33.29rpx"></u--image>
						</view> -->
					</view>

					<!-- 搜索框 -->
					<!-- <view style="position: relative;width: 289.14rpx;" v-if="showSerch">
						<u-search borderColor="#FF6D20" bgColor="white" @change="test" :showAction="false"
							placeholder="请输入..." v-model="sotreParam.keyword" @search="onInputConfirm"
							class="serch_cls"></u-search>
						<u--image @tap="searchSubmit" class="img_cls" :showLoading="true"
							src="/static/images/GXSC/SSBT.png" width="115.65rpx" height="56.82rpx"></u--image>
					</view> -->
					<!-- 位置 -->
					<!-- <view v-else style="display: flex;align-items: center;">
						<u--image @tap="showSerch=!showSerch" style="margin-right: 30rpx;" :showLoading="true"
							src="/static/images/GXSC/SS.png" width="49rpx" height="49rpx"></u--image>
						<u--image @click="showPicker=!showPicker" :showLoading="true" src="/static/images/GXSC/DW1.png"
							width="50.82rpx" height="50.82rpx"></u--image>
						<view class="town_name">{{street}}</view>
					</view> -->
				</view>

				<view class="sswz">
					<view style="position: relative;width: 501.17rpx;">
						<u-search borderColor="#FF6D20" bgColor="white" @change="test" :showAction="false"
							placeholder="搜索店铺或者名称" v-model="sotreParam.keyword" @search="onInputConfirm"
							class="serch_cls"></u-search>
						<u--image @tap="searchSubmit" class="img_cls" :showLoading="true"
							src="/static/images/GXSC/SSBT.png" width="115.65rpx" height="56.82rpx"></u--image>
					</view>
					<view style="display: flex;align-items: center;" @click="showPicker=!showPicker">
						<u--image :showLoading="true" src="/static/images/GXSC/DW1.png" width="50.82rpx"
							height="50.82rpx"></u--image>
						<view class="town_name">{{street}}</view>
					</view>
				</view>
				<!-- <view class="selected-list" :class="{actSel:showSelect}">
					<div class="triangle-up"></div>
					<view class="selected-li">
						供销综合云市场 <text> <u--image style="margin-left: 40rpx;" :showLoading="true"
								src="/static/images/GXSC/XZ.png" width="24.53rpx" height="24.53rpx"></u--image> </text>
					</view>
					<view class=""
						@click="navGoto(`/pages/nongKe/cloud_entrepot/indexa?street=${street_id}&town=${street}`)">
						供销综合云商品
					</view>
				</view> -->

				<view class="flags">

				</view>
			</view>


			<view class="content">
				<view class="" :style="`height:${headTop}px`">

				</view>
				<view class="hot_serch">
					<!-- <text>热搜:</text>
					<text @click="hotSerchFn('小张副食')">小张副食</text>
					<text @click="hotSerchFn('正新酒店')">正新酒店</text>
					<text @click="hotSerchFn('麻辣鸡')">麻辣鸡</text>
					<text @click="hotSerchFn('手撕椒麻鸡')">手撕椒麻鸡</text> -->
				</view>

				<view class="menu_cls">
					<u-scroll-list indicatorActiveColor='#FF6D20'>
						<view class="menu_li" @click="navGo(item.merchant_category_id)" v-for="item,index in menuList"
							:key="index">
							<!-- {{item.merchant_category_id}} -->
							<u--image :showLoading="true" :src="item.background" width="94.63rpx" height="99.63rpx"
								></u--image>
							<text
								style="display: block;font-size: 26.29rpx;">{{item.category_name}}</text>
						</view>
					</u-scroll-list>
				</view>

				<view class="goods_list">
					<view class="goods_card" @click="goStore(item.mer_id)" v-for="(item,index) in storeList"
						:key="index">
						<view class="left">
							<u--image :showLoading="true" :src="item.mer_avatar" width="157.71rpx"
								height="157.71rpx"></u--image>
						</view>
						<view class="right">
							<view class="li head">
								<text class="com_name">{{item.mer_name}}</text>
								<text v-if="item.type_id==17"
									style="font-weight: normal;font-size: 19.28rpx;color: red;padding:0 10rpx; border-radius: 10rpx; border: 1px solid red;">{{item.type_name}}</text>
							</view>
							<view class="li">
								<!-- <u--image v-for="item,index in [1,1,1,1,1]" :key="index" :showLoading="true"
									src="/static/images/GXSC/PF.png" width="20.85rpx" height="19.85rpx"></u--image> -->
                <view class="score">
                	<view class="star">
                		<view
                			:style="{width: `${(item.service_score / 5 * 100).toFixed(0)}%`, backgroundImage: `url(${domain}/static/diy/score1${keyColor}.png)`}">
                		</view>
                	</view>
                </view>
								<text style="margin-left: 20rpx;color: #FF6D20; ">{{item.service_score}}</text>
								<text>月销{{item.sales}}</text>
								<text v-if="item.distance" style="font-size: 24rpx;color: #aaa;">{{item.distance}}</text>
								
							</view>
							<view class="li" style="align-items: center;">
								<u--image :showLoading="true" src="/static/images/GXSC/DH.png" width="33.85rpx"
									height="33.85rpx"></u--image>
								<text> {{item.service_phone}}</text>
							</view>
							<view class="li" style="align-items: center;">
								<u--image :showLoading="true" src="/static/images/GXSC/SJ.png" width="33.85rpx"
									height="33.85rpx"></u--image>
								<text>{{item.mer_take_time[0]}}-{{item.mer_take_time[1]}}</text>
							</view>
							<view class="li" style="align-items: center;">
								<u--image :showLoading="true" src="/static/images/GXSC/DW.png" width="33.85rpx"
									height="33.85rpx"></u--image>
								<text class="address">{{item.mer_address}}</text>
							</view>
						</view>

					</view>

				</view>

				<u-loadmore :status="status" />
			</view>

			<!-- 热搜 -->



			<!-- <view class="nav-wrapper" :class="'styleType'+store_street_theme">
				<view class='nav acea-row row-middle' :class="'styleType'+store_street_theme">
					<view v-for="item in downMenus" :key="item.key" class='item'
						:class="{'font-colors':firstKey == item.key}" @click='set_where(item.key)'>
						<view class="">
							{{item.title}}
						</view>
						<view class="line" :class="{'font-line':firstKey == item.key}">
						</view>
					</view>

				</view>
			</view>
			
			 -->

			<!-- 店铺 -->
			<!-- 
			<block>
				<view class="store-wrapper">
					<view class="store-item" v-for="(item,index) in storeList" :key="index">
						<view class="head">
							<view class="bgc_img" :style="{ backgroundImage: `url(${item.mini_banner})`}">
							</view>
							<view class="zhezhao">
							</view>
							<view class="zhezhao1" @click="goStore(item.mer_id)">
								<view class="title">
									<view>{{item.mer_name}}
									</view>
									<span>
										{{item.type_name}}
									</span>
								</view>
								<view class="coent">
									<view class="avater">
										<image :src="item.mer_avatar" mode=""></image>
									</view>
									<view class=" text">
										<view class="text_one">
											<view class="">
												<image src="@/static/images/phone.png" mode=""></image>
												{{item.service_phone}}
											</view>
											<view class="text_one_r">
												<image src="@/static/images/clock.png" mode=""></image>
												{{item.mer_take_time[0]}}-{{item.mer_take_time[1]}}
											</view>
										</view>
										<view class="text_two">
											<image src="@/static/images/shangpu.png" mode=""></image>
											{{item.mer_info}}
										</view>
										<view class="text_three">
											<image src="@/static/images/dingwei.png" mode=""></image>
											{{item.mer_address}}
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</block>
			<block v-if="store_street_theme == 2">
				<view class="mer-item2" v-for="(item,index) in storeList" :key='index'>
					<view class="mer-hd mer-shop-count" @click="goStore(item.mer_id)">
						<image class="mer-avatar" :src="item.mer_avatar"></image>
						<view class="mer-shop-right">
							<view class="mer-count">
								<view class="mer-top">
									<view class="txt line1">{{item.mer_name}}</view>
									<text v-if="item.type_name" class="font-bg-red ml8">{{item.type_name}}</text>
									<text v-else-if="item.is_trader" class="font-bg-red ml8">自营</text>
								</view>
								<view class="mer-btn">
									<view class="">
										{{item.care_count<10000 ? item.care_count : (item.care_count/10000).toFixed(2)+'万'}}人关注
									</view>
									<view class="line" v-if="item.distance"></view>
									<view class="distance" v-if="item.distance" @click.stop="showStoreLocation(item)">
										<view class="">
											{{item.distance}}
										</view>
										<view class="iconfont icon-xiangyou"></view>
									</view>
								</view>
							</view>
							<view class="pro-box">
								<navigator :url="`/pages/goods_details/index?id=${itemn.product_id}`" hover-class="none"
									class="pro-item" v-for="(itemn,indexn) in item.recommend" :key='indexn'>
									<view class="picture">
										<easy-loadimage mode="widthFix" :image-src="itemn.image"></easy-loadimage>
										<view v-if="itemn.border_pic"
											:style="{ backgroundImage: `url(${itemn.border_pic})` }"
											class="border-picture"></view>
									</view>
									<view class="price">
										<text>￥</text>{{itemn.price}}
									</view>
								</navigator>
							</view>
						</view>
					</view>
				</view>
			</block>
			<block v-if="store_street_theme == 3">
				<view class="mer-item mer-item3" v-for="(item,index) in storeList" :key='index'
					:style="'background-image:url('+item.mini_banner+')'">
					<view class="mer-hd" @click="goStore(item.mer_id)">
						<view class="mer-name">
							<image :src="item.mer_avatar"></image>
							<view class="">
								<view class="mer-top">
									<view class="txt line1">{{item.mer_name}}</view>
									<text v-if="item.type_name" class="font-bg-red ml8">{{item.type_name}}</text>
									<text v-else-if="item.is_trader" class="font-bg-red ml8">自营</text>
								</view>
								<view class="mer-btn">
									<view class="">
										{{item.care_count<10000 ? item.care_count : (item.care_count/10000).toFixed(2)+'万'}}人关注
									</view>
									<view class="line" v-if="item.distance"></view>
									<view class="distance" v-if="item.distance" @click.stop="showStoreLocation(item)">
										<view class="">
											{{item.distance}}
										</view>
										<view class="iconfont icon-xiangyou"></view>
									</view>
								</view>
							</view>
						</view>
					</view>
					<view class="pro-box" :class="'styleType'+store_street_theme">
						<view class="pro-item" v-for="(itemn,indexn) in item.recommend" :key='indexn' v-if="indexn<=2">
							<view @click="go_details(itemn.product_type,itemn.product_id)">
								<view class="picture">
									<image :src="itemn.image"></image>
									<view v-if="itemn.border_pic"
										:style="{ backgroundImage: `url(${itemn.border_pic})` }" class="border-picture">
									</view>
								</view>
								<view class="price">
									<text>￥</text>{{itemn.price}}
								</view>
							</view>
						</view>
					</view>
				</view>
			</block>
			<view class='loadingicon acea-row row-center-wrapper' v-if="loading">
				<text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
			</view>
		 -->


		</view>
		<view class='no-shop' v-if="!storeList.length && !loading && !loadingIcon" v-cloak>
			<view class='pictrue' style="margin: 0 auto;background-color: #F5F5F5;">
				<image src='../../../static/images/noCart.png'></image>
				<text>暂无店铺，快去搜索其他店铺吧</text>
			</view>
		</view>
		</block>
		<u-popup class="pop" :show="show" @close="close" mode="center" bgColor='transparent'>
			<image :src="image"></image>
			<image src="@/static/images/guanbi.png" class="guanbi" @click="close"></image>
		</u-popup>
		<view class="">
			<u-picker :defaultIndex="defaInd" :show="showPicker" ref="uPicker" :columns="columnData" @confirm="confirm"
				@cancel="showPicker = false" @change="changeHandler" keyName="name"></u-picker>
		</view>

	</view>

	</view>
</template>

<script>
	import {
		storeMerchantList,
		getGeocoder,
	} from '@/api/store.js';
	import {
		supMenuApi
	} from '@/api/requesta.js';
	import recommend from './component/recommend';
	import rightSlider from './component/rightSlider';
	import {
		merClassifly,
		getStoreTypeApi
	} from '@/api/store.js';
	import {
		mapGetters
	} from "vuex";
	import {
		goShopDetail
	} from '@/libs/order.js'
	import {
		configMap
	} from '@/utils';
	import easyLoadimage from '@/components/easy-loadimage/easy-loadimage.vue';
	import {
		getArea,
		getStreet
	} from '@/api/article.js';
	import {
		getIndexData,
		getDiy
	} from '@/api/api.js'

	import {
		HTTP_REQUEST_URL
	} from '@/config/app';

	import Cache from '@/utils/cache';
	const app = getApp();
	export default {
		components: {
			recommend,
			rightSlider,
			easyLoadimage
		},
		data() {
			return {
				domain: HTTP_REQUEST_URL,
				defaInd: [0, 0],
				columnData: [],
				showSerch: false,
				headTop: 0,
				imgList: [
					"/static/images/GXSC/BBY.png",
					"/static/images/GXSC/NYSC.png",
					"/static/images/GXSC/SHFW.png",
					"/static/images/GXSC/SCFW.png",
					"/static/images/GXSC/NFCP.png",
					"/static/images/GXSC/WLSY.png",
					"/static/images/GXSC/WYLY.png",
					"/static/images/GXSC/MSGY.png",
					"/static/images/GXSC/YLBJ.png",
					"/static/images/GXSC/JYPX.png",
					"/static/images/GXSC/JJRB.png",
					"/static/images/GXSC/ZXJZ.png",
					"/static/images/GXSC/NMJD.png",
					"/static/images/GXSC/GXZH.png",
					"/static/images/GXSC/DFTC.png",
					"/static/images/GXSC/JDMS.png",
				],
				street_id: "",
				showSelect: false,
				price: 0,
				stock: 0,
				nows: false,
				loading: false,
				loadingIcon: true,
				loadTitle: '加载更多',
				title: '',
				hotPage: 1,
				hotLimit: 10,
				hotScroll: false,
				// 筛选框
				rightBox: false,
				//品牌列表
				brandList: [],
				downKey: 0,
				downStatus: false,
				menuList: [],
				street: "",
				showPicker: false,
				status: "loadmore",
				// 下拉菜单
				downMenu: [{
						title: '默认',
						key: 0,
						order: ""
					},
					{
						title: '销量',
						key: 1,
						order: 'sales'
					},
					{
						title: '好评',
						key: 2,
						order: 'rate'
					},
					{
						title: '距离',
						key: 3,
						order: 'location'
					}
				],
				// 是否第一个
				firstKey: 0,
				// 商铺列表
				storeList: [],
				sotreParam: {
					keyword: '',
					page: 1,
					limit: 10,
					order: '',
					category_id: '',
					type_id: '',
					street_id: ''
				},
				storeKey: 0,
				storeScroll: true,
				mer_id: '',
				sortId: '',
				price_on: '',
				price_off: '',
				detaile_address: "",
				recommend_address: "",
				location_address: "",
				latitude: "",
				longitude: "",
				count: 0,
				storeTypeArr: [], //店铺类型
				merList: [], //商户分类
				product_type: 0,
				show: false,
				image: '', //图片,
				credit_buy: '', //支持先货后款
			};
		},
		onLoad(options) {
			// console.log(options);
			this.street_id = options.street_id
			this.street = options.townName
			this.product_type = options.product_type ?? 0
      if(this.$store.state.storage?.location?.lat){
        this.latitude = this.$store.state.storage.location.lat;
        this.longitude = this.$store.state.storage.location.long;
      }
			if (options.street_id != undefined) {
				this.sotreParam.street_id = options.street_id
			}
			this.credit_buy = options.credit_buy
			this.sotreParam.type_id = options.type_id
			this.sotreParam.type_id = options.type_id && options.type_id.split(',').toString() || ''
			this.sotreParam.category_id = options.cate_id && options.cate_id.split(',').toString() || ''
			this.storeList = [];
			if (this.mer_location == 1) {
				this.selfLocation()
			}
			this.storeMerchantList();
			this.getClassfication();
			this.getStoreType();
			supMenuApi().then(res => {
				this.menuList = res.data
			})
			this.Area()
			let that = this
			setTimeout(() => {
				uni.createSelectorQuery()
					.in(this)
					.select('.flags')
					.boundingClientRect(rect => {
						// console.log(this.cartTagInfo, 6666)
						// that.cartTagInfo = rect
						that.headTop = rect.top
						console.log(that.headTop)
					})
					.exec();
			}, 100)
		},
		computed: {
			downMenus: function() {
				return this.downMenu.filter((item) => {
					if (this.mer_location) {
						return item
					} else {
						return item.key < 3
					}
				})
			},
			...configMap({
				margin_ico_switch: 0,
				margin_ico: '',
				mer_location: 0,
				store_street_theme: 1,
				hide_mer_status: '',
			}, mapGetters(['viewColor', 'keyColor'])),
		},
		methods: {
			selectLocation() {
				this.isSelectPlace ? this.showPicker = true : ''

			},
			confirm(e) {
				this.showPicker = false
				this.$emit('selectPlce', e)
				this.$emit('change', e)
				this.street = e.value[1].name
				this.$nextTick(() => {
					this.$bus.$emit('value-updated', e.value[1].name + ',' + e.value[1].code);

				})
				this.sotreParam.street_id = e.value[1].code
				this.street_id = e.value[1].code
				this.storeMerchantList()
			},
			changeHandler(e) {
				const {
					columnIndex,
					value,
					values,
					index,
					picker = this.$refs.uPicker
				} = e;
				if (columnIndex === 0) {
					getStreet({
						area_code: value[0]['code']
					}).then(res => {
						picker.setColumnValues(1, res.data);
					});
				}
			},
			Area() {
				getArea({
					city_code: 510500
				}).then(res => {
					this.$refs.uPicker.setColumnValues(0, res.data);
					this.Street(res.data[0]['code']);
					// console.log(res.data, 66666)
				});
			},
			Street(code) {
				getStreet({
					area_code: code
				}).then(res => {
					this.$refs.uPicker.setColumnValues(1, res.data);

				});
			},

			swiperChange(e) {
				let {
					current,
					source
				} = e.detail;
				if (source === 'autoplay' || source === 'touch') {
					this.bgColor = this.swiper.url[e.detail.current]['img']
					this.$emit('kkchange', this.bgColor)
				}
			},

			onInputConfirm() {

				this.showSerch = false
				this.searchSubmit()

			},
			// 对象转数组
			objToArr(data) {
				let obj = Object.keys(data).sort();
				let m = obj.map(key => data[key]);
				return m;
			},
			async getBanner(id) {
				let that = this;
				const {
					data
				} = await getDiy({
					id: 0
				})
				that.styleConfig = that.objToArr(data.value);
				/* 循环数组得到数据*/
				that.styleConfig.forEach((item, index, arr) => {
					if (item.name == 'headerSerch' || item.name == 'homeComb') {
						if (item.name == 'homeComb') {
							that.swiper.url = item.swiperConfig.list
						}
					}
				})
				this.bgColor = this.swiper.url[0].img
			},

			test() {
				// if (this.sotreParam.keyword.length > 3) {
				// 	this.sotreParam.keyword.slice(0, 3)
				// 	this.sotreParam.keyword = this.sotreParam.keyword.slice(0, 3) + "..."
				// }
				// console.log(this.sotreParam.keyword.length)
			},
			hotSerchFn(keywords) {
				this.sotreParam.keyword = keywords
				this.searchSubmit()
			},
			goMap(url) {
				uni.navigateTo({
					url
				})
			},
			navGoto(url) {
				uni.redirectTo({
					url
				})
			},
			navGo(id) {
				uni.navigateTo({
					url: `/pages/nongKe/supply_chain/supplierA?type_id=10,17&merchant_category_id=${id}&street_id=${this.street_id}`
				})
			},
			go_details: function(product_type, product_id) {
				if (product_type == 98) {
					uni.navigateTo({
						url: `/pages/admin/goods_details/index?product_id=${product_id}&product_type=${product_type}`
					})
				}
				if (product_type == 0) {
					uni.navigateTo({
						url: `/pages/goods_details/index?id=${product_id}`
					})
				}
			},
			// 获取商户分类
			getClassfication: function() {
				let temp = []
				merClassifly()
					.then(res => {
						temp = res.data.map(item => {
							return {
								...item,
								check: false
							}
						})
						if (this.sotreParam.category_id.length > 0) {
							this.sotreParam.category_id.forEach((ids, index) => {
								temp.forEach(el => {
									if (ids == el.merchant_category_id) {
										el.check = true
									}
								})
							})
						}
						this.merList = temp
					})
					.catch(res => {
						this.$util.Tips({
							title: res
						});
					});
			},
			// 获取店铺类型
			getStoreType: function() {
				let temp = []
				getStoreTypeApi().then(res => {
						res.data.forEach(item => {
							if (item.mer_type_id == this.sotreParam.type_id) {
								temp.push({
									...item,
									check: true
								})
							}
						})
						this.storeTypeArr = temp
					})
					.catch(res => {
						this.$util.Tips({
							title: res
						});
					});
			},
			/** 打开地图**/
			showMaoLocation(lat, long) {
				if (!lat || !long) return this.$util.Tips({
					title: '请设置允许商城访问您的位置！'
				});
				//#ifdef H5
				if (this.$wechat.isWeixin() === true) {
					this.$wechat.seeLocation({
						latitude: Number(lat),
						longitude: Number(long),
						name: '当前位置',
						address: this.location_address
					}).then(res => {
						// console.log('success');
					})
				} else {
					//#endif
					uni.openLocation({
						latitude: parseFloat(lat),
						longitude: parseFloat(long),
						name: '当前位置',
						address: this.location_address,
						scale: 8,
						success: function(res) {
							// console.log(res)
						},
					});
					// #ifdef H5
				}
				//#endif	
			},
			showStoreLocation(item) {
				if (!item.lat || !item.long) return this.$util.Tips({
					title: '请设置允许商城访问您的位置！'
				});
				//#ifdef H5
				if (this.$wechat.isWeixin() === true) {
					this.$wechat.seeLocation({
						latitude: Number(item.lat),
						longitude: Number(item.long),
						name: item.mer_name,
						address: item.mer_address ? item.mer_address : '',
					}).then(res => {
						// console.log('success');
					})
				} else {
					//#endif
					uni.openLocation({
						latitude: parseFloat(item.lat),
						longitude: parseFloat(item.long),
						scale: 8,
						name: item.mer_name,
						address: item.mer_address ? item.mer_address : '',
						success: function(res) {
							// console.log(res)
						},
					});
					// #ifdef H5
				}
				//#endif	
			},
			selfLocation() {
				let self = this
				if (uni.getStorageSync('RejectTarget')) return;
        if(this.$store?.state?.storage?.location?.lat){
          this.latitude = this.$store?.state?.storage?.location?.lat;
          this.longitude = this.$store?.state?.storage?.location?.long;
          getGeocoder({
          	lat: this.latitude,
          	long: this.longitude
          }).then(res => {
          	// console.log(res)
          	this.detaile_address = res.data.address;
          	this.location_address = res.data.address;
          	this.recommend_address = res.data.address.length > 4 ? res.data.address
          		.slice(0, 4) + '...' :
          		res.data.address
          }).catch(err => {
          	uni.showToast({
          		title: err,
          		icon: 'none'
          	})
          })
        }
				else uni.getLocation({
					type: 'gcj02',
					success: (res) => {
            console.log('定位');
						let latitude, longitude;
						latitude = res.latitude.toString();
						longitude = res.longitude.toString();
						this.latitude = res.latitude.toFixed(6);
						this.longitude = res.longitude.toFixed(6);
            this.$store.commit('setLocation', {
              lat: res.latitude.toFixed(6), 
              long: res.longitude.toFixed(6),
            });
						getGeocoder({
							lat: latitude,
							long: longitude
						}).then(res => {
							// console.log(res)
							this.detaile_address = res.data.address;
							this.location_address = res.data.address;
							this.recommend_address = res.data.address.length > 4 ? res.data.address
								.slice(0, 4) + '...' :
								res.data.address
						}).catch(err => {
							uni.showToast({
								title: err,
								icon: 'none'
							})
						})
					},
					fail: (res) => {
						uni.showToast({
							title: res,
							icon: 'none',
							duration: 1000
						});
					},
				});
			},
			// 查找店铺
			storeMerchantList() {
				if (this.loading) return
				this.loading = true
				let rqData = {
					keyword: this.sotreParam.keyword,
					page: this.sotreParam.page,
					limit: 10,
					order: this.sotreParam.order,
					category_id: this.sotreParam.category_id,
					type_id: this.sotreParam.type_id,
					street_id: this.sotreParam.street_id,
					credit_buy: this.credit_buy,
				}
				if (this.latitude) {
					rqData.location = this.latitude + ',' + this.longitude
				}
				// console.log(rqData)
				storeMerchantList(rqData).then(res => {
					this.count = res.data.count
					this.storeList = (res.data.list)
					this.loading = false
					this.loadingIcon = false
				})
			},
			// 进店
			goStore(id) {
				if (this.sotreParam.type_id == 12) {
					uni.navigateTo({
						url: `/pages/nongKe/supply_chain/merchant?id=${id}`
					})
				} else {
					if (this.hide_mer_status != 1) {
						uni.navigateTo({
							url: `/pages/store/home/index?id=${id}&type=7`
						})
					}
				}
			},
			searchSubmit: function() {
				let that = this;
				that.$set(that.sotreParam, 'keyword', this.sotreParam.keyword);
				this.set_where(this.firstKey)
				this.showSerch = false
			},
			// 右侧切换
			bindRight() {
				this.sotreParam.page = 1
				this.rightBox = true
			},
			// 组件确定
			confirm1(data) {
				let arr1 = [],
					arr2 = []
				if (data.storeTypeArr.length == 0) {
					// this.sotreParam.type_id = ''
				} else {
					data.storeTypeArr.forEach(item => {
						arr1.push(item.mer_type_id)
					})
					this.sotreParam.type_id = arr1.toString();
				}
				if (data.merList.length == 0) {
					this.sotreParam.category_id = ''
				} else {
					data.merList.forEach(item => {
						arr2.push(item.merchant_category_id)
					})
					this.sotreParam.category_id = arr2.toString();
				}
				this.rightBox = data.status
				this.loadend = false;
				this.$set(this.sotreParam, 'page', 1)
				this.storeList = [];
				this.storeMerchantList();
			},
			// 组件关闭
			close() {
				this.rightBox = false
				this.show = false
			},
			//点击事件处理
			set_where: function(e) {
				if (this.loading) return
				this.storeList = []
				this.firstKey = e
				this.sotreParam.page = 1
				this.sotreParam.order = this.downMenu[e].order
				this.storeMerchantList();
			},
			backjJump() {
				uni.navigateBack({
					delta: 1
				})
			},
			// 滚动监听
			onPageScroll(e) {
				// 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
				uni.$emit('scroll');
			},
			qctail(item) {
				// console.log(item);
				if (item.mer_certificate == '') {
					return
				}
				this.show = true
				this.image = item.mer_certificate[0]
				// console.log(this.show);
			},
		},
		//刷新
		onPullDownRefresh() {
			uni.stopPullDownRefresh()
		},
		onShow() {
			this.showSelect = false
		},
		//上划加载更多
		onReachBottom() {
			this.sotreParam.page += 1

			let rqData = {
				keyword: this.sotreParam.keyword,
				page: this.sotreParam.page,
				limit: 10,
				order: this.sotreParam.order,
				category_id: this.sotreParam.category_id,
				type_id: this.sotreParam.type_id,
				street_id: this.sotreParam.street_id,
				credit_buy: this.credit_buy
			}
			if (this.latitude) {
				rqData.location = this.latitude + ',' + this.longitude
			}
			// console.log(rqData)
			storeMerchantList(rqData).then(res => {
				if (res.data.list == 0) {
					this.status = "nomore"
					return
				}
				this.count = res.data.count
				this.storeList.push(...res.data.list)

			})


		}

	}
</script>

<style lang="scss" scoped>
	* {
		margin: 0;
		padding: 0;
	}

	.com_name {
		font-size: 33.29rpx;
		// background-color: red;
		// max-width: 45vw;
		max-width: 40vw;
		white-space: nowrap;
		/* 防止文字换行 */
		overflow: hidden;
		/* 超出部分隐藏 */
		text-overflow: ellipsis;
		/* 使用省略号表示溢出的内容 */
		// width: 200px;
		/* 可根据实际情况调整容器宽度 */
	}

	.head_tit {
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-sizing: border-box;
		padding: 0 20rpx;

	}

	.productList {
		// padding-top: 50rpx;
		// padding: 0 20rpx 0;

		.top {
			padding-top: var(--status-bar-height);

			// padding-top: 80rpx;
			background-color: #F0F2F5;
			position: fixed;
			z-index: 999;
			width: 100%;
			// margin-top: 10px;
		}

		.content {
			padding: 20rpx;
			padding-top: 0;
		}

		.menu_cls {
			background-color: white;
			// height: 199.77rpx;
			border-radius: 21.03rpx 21.03rpx 21.03rpx 21.03rpx;
			padding: 20rpx 20rpx 0 20rpx;

			.menu_li {
				margin-right: 50rpx;
				// background-color: red;
				// width: 50vw;
        display: flex;
        flex-direction: column;
        align-items: center;
        min-width: 15vw;
				// width: 120rpx;
				// display: inline-block;
			}


		}

		.goods_list {
			margin-top: 20rpx;

			.goods_card {
				margin-top: 20rpx;
				height: auto;
				background-color: white;
				padding: 20rpx;
				// border-radius: 20rpx;
				display: flex;
				// align-items: center;

				.left {
					margin-right: 20rpx;
					width: 158rpx;
					height: 158rpx;
					border-radius: 20rpx;
					overflow: hidden;
				}

				.right {
					.head {
						font-weight: bold;
						// color: red;

					}

					.li {
						display: flex;
						font-size: 26.29rpx;
						margin-bottom: 10rpx;
						align-items: center;

						text {
							margin: 0 20rpx 0 5rpx;
						}
					}
				}
			}
		}

		.address {
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
			width: 200px;
		}
	}

	.selects {
		transform: rotate(180deg);
	}



	.search-right.styleType2 .right-text,
	.search-right.styleType3 .right-text {
		color: #282828;
	}

	.search-right.styleType2 .icon-xiangyou,
	.search-right.styleType3 .icon-xiangyou {
		color: #999999;
	}

	.search-right.styleType2 .icon-dingwei,
	.search-right.styleType3 .icon-dingwei {
		color: #8A8A8A;
	}

	.productList .search .back {
		display: flex;
		align-items: center;
		width: 40rpx;
		height: 60rpx;

		.iconfont {
			color: #fff;
			font-size: 36rpx;
		}
	}

	.town_name {
		overflow: hidden;
		white-space: nowrap;
		/* 设置文本不换行 */
		text-overflow: ellipsis;
		max-width: 25vw;
		font-size: 14px;
		/* 设置溢出文本为省略号 */
	}

	.hot_serch {
		height: 20rpx;
	}

	.productList .search .input {
		flex: 1;
		height: 60rpx;
		background-color: #fff;
		border-radius: 50rpx;
		padding: 0 20rpx;
		box-sizing: border-box;
	}

	.productList .search.styleType2 .input,
	.productList .search.styleType3 .input {
		background: #EDEDED;
	}

	.productList .search .input input {
		flex: 1;
		height: 100%;
		font-size: 26rpx;
		margin-left: 10rpx;
	}

	.productList .search .input .placeholder {
		color: #999;
	}

	.productList .search .input .iconfont {
		font-size: 35rpx;
		color: #555;
	}

	.productList .search .icon-pailie,
	.productList .search .icon-tupianpailie {
		color: #fff;
		width: 62rpx;
		font-size: 40rpx;
		height: 86rpx;
		line-height: 86rpx;
	}

	.productList .nav-wrapper {
		z-index: 9;
		position: fixed;
		left: 0;
		top: 25px;
		width: 100%;
		margin-top: 86rpx;
		background-color: #fff;

		&.styleType1 {
			background-color: var(--view-theme);
		}

		.tab-bar {
			display: flex;
			align-items: center;

			.tab-item {
				position: relative;
				flex: 1;
				display: flex;
				justify-content: center;
				align-items: center;
				padding: 8rpx 0 20rpx;
				color: #fff;
				font-size: 28rpx;
				font-weight: bold;

				&::after {
					content: ' ';
					position: absolute;
					left: 50%;
					bottom: 18rpx;
					width: 30rpx;
					height: 3rpx;
					background: transparent;
					transform: translateX(-50%);
				}

				&.on {
					&::after {
						background: #fff;
					}
				}
			}
		}
	}

	.border-picture {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background: center/cover no-repeat;
	}

	.productList .nav {
		height: 86rpx;
		color: #454545;
		font-size: 28rpx;
		display: flex;
		justify-content: space-between;
		padding: 0 28rpx;
	}

	.productList .nav .item {
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		color: #FFFFFF;
		flex: 1;
	}

	.productList .nav.styleType2 .item,
	.productList .nav.styleType3 .item {
		color: #282828;
	}

	.productList .nav .item.font-colors {
		font-weight: 500;
		color: #FFFFFF;
	}

	.productList .nav.styleType2 .item.font-colors,
	.productList .nav.styleType3 .item.font-colors {
		color: var(--view-theme);
	}

	.productList .nav .item .font-line {
		height: 4rpx;
		background-color: #fff;
		margin-top: 3rpx;
		width: 28rpx;
		animation: line 0.3s;
		-moz-animation: line 0.3s;
		/* Firefox */
		-webkit-animation: line 0.3s;
		/* Safari 和 Chrome */
		-o-animation: line 0.3s;
		/* Opera */
	}

	.productList .nav.styleType2 .item .font-line,
	.productList .nav.styleType3 .item .font-line {
		background-color: var(--view-theme);
	}

	@keyframes line {
		from {
			width: 0rpx;
		}

		to {
			width: 28rpx;
		}
	}

	.productList .nav .item image {
		width: 15rpx;
		height: 19rpx;
		margin-left: 10rpx;
	}

	.selected-list {
		padding: 24rpx 14rpx;
		border-radius: 10.51rpx 10.51rpx 10.51rpx 10.51rpx;
		background-color: #fff;
		position: absolute;
		left: 100rpx;
		font-size: 29.79rpx;
		opacity: 0;
		transition: 0.5s;
		height: 0;


		.triangle-up {
			width: 0;
			height: 0;
			border-left: 10rpx solid transparent;
			border-right: 10rpx solid transparent;
			border-bottom: 10rpx solid white;
			position: absolute;
			top: -10rpx;
		}

		.selected-li {
			margin-bottom: 35rpx;
			color: #F84221;
			display: flex;
			align-items: center;
		}
	}

	.actSel {
		opacity: 1;
		height: auto;
		// transform: translateX(100rpx);

	}

	.store-wrapper {
		margin-top: 235rpx;
		border-top: 1px solid #F6F6F6;

		.store-item {
			margin: 20rpx auto;

			.head {
				display: flex;
				align-items: center;
				justify-content: center;
				color: #fff;

				.zhezhao {
					position: absolute;
					width: 95%;
					height: 150px;
					border-radius: 20rpx;
					z-index: 0;
					opacity: 0.5;
					background-color: #999;
				}

				.bgc_img {
					position: absolute;
					width: 95%;
					height: 150px;
					background-size: cover;
					border-radius: 20rpx;
					z-index: 0;
				}

				.zhezhao1 {
					width: 100%;
					height: 150px;
					border-radius: 20rpx;
					z-index: 1;

					.title {
						display: flex;
						height: 50px;
						align-items: center;
						margin-left: 20px;
						z-index: 1;

						span {
							background-color: #F84221;
							color: white;
							font-size: 12px;
							padding: 3px;
							border-radius: 5px;
							margin-left: 5px;
						}
					}

					.coent {
						display: flex;
						margin-left: 20px;

						.avater {
							width: 60px;
							height: 80px;

							image {
								width: 60px;
								height: 80px;
							}
						}

						.text {
							.text_one {
								display: flex;
								height: 30px;
								line-height: 30px;
								padding-left: 10px;

								image {
									width: 20px;
									height: 20px;
									margin-right: 10px;
								}

								.text_one_r {
									margin-left: 10px;
								}
							}

							.text_two {
								width: 270px;
								height: 30px;
								line-height: 30px;
								padding-left: 10px;
								white-space: nowrap;
								overflow: hidden;
								text-overflow: ellipsis;

								image {
									width: 20px;
									height: 20px;
									margin-right: 10px;
								}
							}

							.text_three {
								width: 270px;
								height: 30px;
								line-height: 30px;
								padding-left: 10px;
								white-space: nowrap;
								overflow: hidden;
								text-overflow: ellipsis;

								image {
									width: 20px;
									height: 20px;
									margin-right: 10px;
								}
							}
						}

					}
				}


			}

			.pro-box {
				white-space: nowrap;
				display: flex;
				align-items: center;
				padding: 20rpx 20rpx 30rpx;

				.pro-item {
					display: inline-block;
					width: 218rpx;
					margin-right: 14rpx;

					.picture,
					/deep/image,
					uni-image {
						width: 100%;
						height: 214rpx;
						border-radius: 8rpx;
						position: relative;
					}

					.price {
						margin-top: 5rpx;
						font-size: 28rpx;
						color: var(--view-priceColor);
						font-weight: bold;

						text {
							font-size: 28rpx;
						}
					}

					&:last-child {
						margin-right: 0;
					}
				}

				&.styleType3 {
					padding: 20rpx;

					.pro-item {
						display: inline-block;
						background-color: #fff;
						border-radius: 16rpx;
						text-align: center;
						padding: 10rpx 0 20rpx;

						.picture,
						/deep/image,
						uni-image {
							width: 194rpx;
							height: 194rpx;
							text-align: center;
							border-radius: 8rpx;
							position: relative;
							margin: 0 auto;
						}
					}
				}
			}
		}
	}

	.mer-item2 {
		padding: 20rpx;
		background: #fff;
		margin-bottom: 20rpx;
		border-radius: 16rpx;

		.mer-shop-count {
			display: flex;

			.mer-avatar {
				width: 100rpx;
				height: 100rpx;
			}

			.mer-top {
				color: #282828;
			}

			.mer-shop-right {
				margin-left: 20rpx;

				.mer-btn {
					color: #666666;
				}

			}

			.pro-box {
				white-space: nowrap;
				display: flex;
				align-items: center;
				margin-top: 20rpx;

				.pro-item {
					display: inline-block;
					width: 170rpx;
					margin-right: 20rpx;

					.picture,
					/deep/image,
					uni-image,
					/deep/.easy-loadimage {
						width: 100%;
						height: 170rpx;
						border-radius: 8rpx;
						position: relative;
					}

					.price {
						margin-top: 5rpx;
						font-size: 28rpx;
						color: var(--view-priceColor);
						font-weight: bold;

						text {
							font-size: 28rpx;
						}
					}

					&:last-child {
						margin-right: 0;
					}
				}
			}
		}

	}

	.no-shop {
		background-color: #fff;
		// padding-bottom: calc(100% - 176rpx);

		.pictrue {
			display: flex;
			flex-direction: column;
			align-items: center;
			color: $uni-nothing-text;

			image {
				width: 414rpx;
				height: 380rpx;
			}
		}
	}

	.guanbi {
		width: 20px;
		height: 20px;
		margin: 30px auto;
	}

	.img_cls {
		position: absolute;
		top: 50%;
		right: 7rpx;
		transform: translateY(-50%);

	}

	.pop {
		z-index: 1;
	}

	.sswz {
		margin-top: 30rpx;
		display: flex;
		justify-content: space-between;
		box-sizing: border-box;
		padding: 0 20rpx;
	}
  .score {
  	display: flex;
  	align-items: center;
  	font-weight: 500;
  	font-size: 24rpx;
  	line-height: 1;
  	color: #000;
  
  	.score-title {
  		margin-right: 15rpx;
  
  	}
    .score_text{
      color: #fd5d2e;
    }
  
  	.star {
  		position: relative;
  		width: 111rpx;
  		height: 19rpx;
  		margin-right: 10rpx;
  		background: url(../../columnGoods/images/star.png) left top/100% 100% no-repeat;
  		overflow: hidden;
  
  		view {
  			position: absolute;
  			top: 0;
  			left: 0;
  			width: 100%;
  			height: 100%;
  			background: url(../../columnGoods/images/star_active.png) left top/111rpx 19rpx no-repeat;
  
  			&.star_purple {
  				background: url(../../columnGoods/images/star_active_purple.png) left top/111rpx 19rpx no-repeat;
  			}
  		}
  	}
  }
</style>