<template>
  <view class="container">
    <!-- 顶部标题 -->

    <view class="header">
	 <view class="header_info">
		 <text class="header_texts" :title="title">{{title}}</text>
		 <text class="header_info_icon">|</text>
		 <view @click="change_text" class="header_change">
			 <text >切换</text>
			  <uni-icons type="right" size="30" color="#c2d4de" ></uni-icons>
		 </view>
	 </view>
    </view>
	
	<view  class="swiper">
		<image  class="swiper-image"  src="/static/image/组 71699.png"></image>
	</view>


<view class="order_Entry_container" @click="orderEntry">
 <image class="order_Entry_image" src="/static/image/组 71699_1@3x.png"></image>
 <text style="color: #115881;font-weight: bold;margin-left: 1rem;">录入订单</text>
 <uni-icons class="order_Entry_end" type="right" :size="25" color="#306e91"></uni-icons>
</view>

<view v-if="isshow" class="show_container"> 
<view class="isshow-header">
	<uni-icons class=" isshow-header-content-icon" type="search" :size="20"></uni-icons>
	<uni-easyinput :inputBorder="false" @input="handleSearch" class=" isshow-header-content-input" v-model="ServiceName" placeholder="请输入服务名称"  />
	<text class="isshow-header-content-text" @click="searchName">搜索</text>
</view>
<view class="isshow-content" >
	<text class="isshow-content-text" v-for="(item, index) in textcontent" :key="index"  @click="change_city(item.storeName,item.address)">{{item.storeName}}</text>
</view>
</view>

<view v-if="isshow_1" class="show_container_1"> 
<image class="show_container_1_image" src="/static/image/图层_6.png"></image>
<view class="show_container_1_footer">
	<text>门店已经切换为{{title}}</text>
	<button class="show_container_1_footer_button" @click="close_view">好的</button>
</view>
</view>

</view>
</template>

<script>
	import {getStoreName,isToken} from '@/api.uts'
export default {
  data() {
    return {
	  ServiceName:'',
	  title:"北京汽车有限公司",
	  isshow:false,
	  isshow_1:false,
	  newListData:[],
	  textcontent: [],
    };
  },
  mounted() {
	  isToken();
	  getStoreName().then((res)=>{
		   getApp().allMsg=res.result;
		    this.textcontent = res.result;
			this.title = res.result[0].storeName;
			getApp().storeName = res.result[0].storeName;
			getApp().dealerAddress = res.result[0].address;
	  }
	  );
   },
  methods: {

	  change_text(){
		  
		  if(this.isshow){
			  this.isshow=false;
		  }else{
			  this.isshow=true;

		  }
	  },
	  orderEntry(){
		  uni.navigateTo(
		  { url: '/pages/views/dingDanCreate' }
		  )
	  },
	  // 搜索城市名字
	  searchName(){
		  if(this.ServiceName){
		  				  this.textcontent = [];
		  				 getApp().allMsg.map(item => {
		  				    if (item.storeName.indexOf(this.ServiceName) !== -1) {
		  				      this.textcontent.push(item);
		  				    }
		  				  });
		  }else {
		  				  this.textcontent=[];
		  				  this.textcontent =  getApp().allMsg;
		  }
	  },
	  change_city(name,address){
		  this.title = name;
		  this.change_text();
		  this.isshow_1 = true;
		  getApp().storeName = this.title;
		  getApp().dealerAddress = address;
	  },
	  close_view(){
		  this.isshow_1 = false;
	  },
	  // 模糊匹配
	  // 右上角搜索框--模糊查询
	      handleSearch(event) {
			  console.log(event);
			  if(event){
				  this.textcontent = [];
				 getApp().allMsg.map(item => {
				    if (item.storeName.indexOf(event) !== -1) {
				      this.textcontent.push(item);
				    }
				  });
			  }else {
				  this.textcontent=[];
				  this.textcontent =  getApp().allMsg;
			  }
	      }
  }
};
</script>

<style>


/* 订单录入 */
.order_Entry_container{
	width: 90%;
	height: 8%;
	background-color: #d9e5eb;
	border-radius: 0.6rem;
	margin-left:5%;
	display: flex;
	flex-direction: row;
	align-items: center;
	margin-top: 10%;
}
.order_Entry_image{
	width: 10%;
	height: 70%;
	margin-left: 3%;
}
.order_Entry_end{
	  margin-left: auto;
	  margin-right: 7%;
}
/* 轮播图 */
.swiper {
  height: 30%;
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  overflow: hidden;
}

.swiper-image {
  width: 100%;
 height: 100%;
  margin: 0 auto;
}

.form {
  flex: 1;
  padding: 1rem;
}


.submit-button {
  width: 100%;
  height: 3rem;
  background-color: #007aff;
  color: #fff;
  border: none;
  border-radius: 0.3rem;
  font-size: 1rem;
}

.footer {
  display: flex;
  justify-content: space-around;
  padding: 0.8rem;
  background-color: #fff;
  border-top: 1rem solid #ccc;
}

.nav-item {
  text-align: center;
}

.nav-item text {
  font-size: 0.9rem;
}

.icon-image{
	width: 30%;
	height: 10rem;
	margin: 0 auto;
	margin-top:  1rem;
}

/* 遮罩层 */
.show_container{
	width: 60%;
	height: 36%;
	background-color: #ffffff;
	position: absolute;
	border-radius: 1rem;
	/* border: 1rem solid; */
	box-shadow: 0rem 0.2rem 0rem #e4e4e4;
	left:5%;
	top: 13%;
	z-index:999;
	display: flex;
	flex-direction: column;
	align-items: center;
}
.isshow-header{
	width: 90%;
	height: 30%;
	display: flex; 
	justify-content: center;
	align-items: center;
	flex-direction: row;
	color: #3c7697;
}
.isshow-header-content-icon{
	width: 10%;
	height: 30%;
}
.isshow-header-content-input{
	width: 80%;
	height: 40%;
	margin: 0 1rem 0 1rem;
	border:none;
	outline:none;
}
.isshow-content{
	height: 70%;
	display: flex;
	flex-direction: column;
	align-items: center;
	overflow-y:scroll;
}
.isshow-content-text{
	color: #414141;
	height: 1.5rem;
	width: 100%;
	line-height: 1.5rem;
	margin: 1rem 0 1rem 0;
	font-size: 0.8rem;
}
.isshow-content::-webkit-scrollbar {
    display: none;
}
/* 提示框*/
.show_container_1{
	width: 80%;
	height: 50%;
	background-color: #ffffff;
	position: absolute;
	border-radius: 1rem;
	/* border: 1rem solid; */
	box-shadow: 0rem 0.2rem 0rem #e4e4e4;
	left:10%;
	top:25%;
	z-index:999;
	display: flex;
	flex-direction: column;
	align-items: center;
}
.show_container_1_image{
	height: 40%;
	width: 60%;
	top: 5%;
}
.show_container_1_footer{
	height: 50%;
	width: 100%;
	color:#0b5583;
	display: flex;
	flex-direction: column;
	align-items: center;
	font-weight: bold;
	font-size: 0.7rem;
}
.show_container_1_footer text{
	margin-top: 10%;
}
.show_container_1_footer_button{
	background-color: #ffffff;
	color:#0b5583;
	height: 30%;
	border-radius: 1.8rem;
	width: 80%;
	margin-top: 5%;
	border: 0.1rem solid #0c547e;
	display: flex;
	justify-content: center;
	align-items: center; 
}


</style>