<template>
<view>
<!--components/store_options/store_options.wxml-->
<template name="store_options_new">
	<view class="tcon">
		<image src="/static/pages/images/mbg.png" class="tcbg"></image>
		<view class="merchant ddflex"  v-if="storeTemplate&&storeTemplate.state==0">
			<image :src="merchant.logo ? merchant.logo : about.CONFIG_INDEX_LOGO" mode="aspectFit" class="logo r50 bgfff"></image>
			<view class="fflex">
				<view class="ddflex">
					<view class="merchant-name tover">{{merchant.title ? merchant.title : '请选择门店'}}</view>
					<view class="change ddflex" @tap="merchantFun()" v-if="about.User_Limit_Store!=1&&about.Many_Store!=0">切换<image src="../../static/pages/images/change.png"></image></view>
				</view>
				<view class="merchant-info ddflex">
					<view class="li ddflex">
						<image src="../../static/pages/images/pinzhi.png"></image>高品低价
					</view>
					<view class="li ddflex">
						<image src="../../static/pages/images/pinzhi.png"></image>售后无忧
					</view>
				</view>
			</view>
			<button open-type="share" class="m-share"><image src="../../static/pages/images/share1.png"></image>分享</button>
		</view>
		<!-- <view class="topcon pdlr20"  v-if="storeTemplate&&storeTemplate.state==0">
			<image :src="merchant.logo ? merchant.logo : about.CONFIG_INDEX_LOGO" mode="aspectFit" class="logo r50 bgfff mr20"></image>
			<view class="area flex" @tap="cloud=='default'?'':merchantFun()">
				<view class="areas f28 dflex">{{merchant.title ? merchant.title : '请选择门店'}}
					<image src="/static/pages/images/sanjiao.png" v-if="cloud!='default'&&about.User_Limit_Store!=1&&about.Many_Store!=0"></image>
				</view>
				<view class="cont dflex" v-if="cloud=='default'||about.User_Limit_Store==1">
					<view v-for="(item, index) in guarantee" :key="index" class="dflex li" v-if="index<3">
						<image src="/static/pages/images/guarantee.png"></image>{{item}}
					</view>
				</view> 
				<view class="recent dflex" v-else>
					<text class="scolor bgfff">最近门店</text>
					<block v-if="merchant.range!=50000">
						{{merchant.range ? merchant.mDistance < 1000 ? merchant.mDistance+'m' : merchant.range+'km' : ''}}</block>
				</view>
			</view>
			<view class="renqi">{{merchant.person}}<text>人气</text></view>
		</view> -->
		<view class="top-nav" v-if="categoryList.length>0 && typeDistrictTemplate && typeDistrictTemplate.state==0">
			<scroll-view scroll-x="true">
				<block v-for="(item, index) in categoryList" :key="index">
				<navigator :url="'/product/list/list?id=' + item.id + '&title=' + item.title  + '' + web" hover-class="none" class="li">{{item.title}}</navigator>
				</block>
			</scroll-view>
			<navigator url="/pages/sort/sort" open-type="switchTab" hover-class="none" class="column dflex"><image src="../../static/pages/images/nav.png"></image></navigator>
		</view>
		<view class="box1 bgfff pdlr20">
			<view v-if="sousuoTemplate&&sousuoTemplate.state==0" class="search dflex">
				<view class="dflex flex" @tap="search">
					<image src="/static/pages/images/ssico.png" class="ssico"></image>
					<view class="flex">搜索你想要的商品</view>
				</view>
				<!-- #ifndef H5 -->
				<image src="/static/pages/images/sao.png" @tap="saoma" class="sao"></image>
				<!-- #endif -->
			</view>
		</view>
	</view>
	<!-- <view class="box1 bgfff pdlr20"
		style="margin-top: {{merchant.id&&storeTemplate&&storeTemplate.state==0? '-52rpx' : 0}}">
		<view wx:if="{{sousuoTemplate&&sousuoTemplate.state==0}}" class="search dflex">
			<view class="dflex flex" bindtap="search">
				<image src="/pages/images/ssico.png" class="ssico"></image>
				<view class="flex">搜索你想要的商品</view>
			</view>
			<image src="/pages/images/sao.png" bindtap="saoma" class="sao"></image>
		</view>
	</view> -->
	<!-- <view class="box1 bgfff pdlr20" style="{{souShow?'margin-top: -28px':''}}" wx:if="{{souShow}}">
	</view> -->
</template>
</view>
</template>

<script>
	// components/store_options/store_options.js
	// 门店选择
	const app = getApp();
	const req = require("../../utils/request.js");
	const api = require("../../utils/api.js");
	const route = require("../../utils/route.js");

	export default {
		data() {
			return {
				categoryList: []
			};
		},

		components: {},
		props: {
			storeTemplate: Object,  //门店配置
			merchant: Object, //门店
			about: Object, //参数配置
			// timelyTemplate: Object,
			guarantee: Array, //配置商城服务保障
			sousuoTemplate: Object, //搜索配置
			cloud:String, //荣康的是否默认门店
			web:String, //路由跳转
			url:String ,//路由跳转
			typeDistrictTemplate: Object //分类导航
		},
		watch: {

		},

		beforeMount() {},

		mounted() { // this.init()
			this.getCategory();
		// console.log(this.merchant,this.cloud,this.guarantee,this.storeTemplate,this.sousuoTemplate,this.timelyTemplate)
		},

		onPageShow() {},

		methods: {

			search() {
				// app.openPage('pages/search/search')
				app.globalData.openPage('pages/search/search'+this.url)
			},
			merchantFun() {
				if(this.about.User_Limit_Store==1||this.about.Many_Store==0){
					
				}else{
				app.globalData.openPage('pages/nearby/nearby')	
				}
				
			},
			saoma() {
				var _this = this;
				// #ifndef H5
				// 允许从相机和相册扫码
				uni.scanCode({
					success: (res) => {
						uni.navigateTo({
							url: '/' + res.path,
						})
						// this.scene = '1290926887903780865';
						this.loadCodeParams();
					}
				})
				// #endif 
			},
			loadCodeParams() {
				let _ts = this;

				return new Promise((resolve, reject) => {
					if (!_ts.scene) {
						resolve();
						return false;
					}

					req.getRequest('/api/code/params', {
						scene: _ts.scene
					}, data => {
						req.setStorage('pidCode', data.userId);
						resolve();
					});
				});
			},
			getCategory() {
				//产品分类
				let that = this;
				route.getCategory({
					pid: 0
				}, res => {
					this.categoryList = res;
				});
			},
		}
	};
</script>
<style>
	@import "./store_options.css";
</style>
