<template>
	<view>
		<view class="overlay" v-if="showfx" @click="showwx">
			<image style="height: 100%;width: 100%;" src="/static/img/zz.png"></image>
						
			
		</view>
		
		<!-- <cu-custom bgColor="bg-blue" :isBack="true" v-if="title == '新建企业信息'">
			<block slot="backText">返回</block>
			<block slot="content">新建企业信息</block>
		</cu-custom>
		<cu-custom bgColor="bg-blue" :isBack="true" v-if="title == '修改企业信息'">
			<block slot="backText">返回</block>
			<block slot="content">修改企业信息</block>
		</cu-custom>
		<cu-custom bgColor="bg-blue" :isBack="true" v-if="title == '查看企业信息'">
			<block slot="backText">返回</block>
			<block slot="content">查看企业信息</block>
		</cu-custom> -->
		
		<!-- <view :class="['custom-header', { 'is-back': isBack }, bgColor]">
			<view class="back-container" @click="handleBack">
			  <view class="back-text">返回</view>
			</view>
			<view class="content-container">
			  <view class="content-text">{{title}}</view>
			</view>
		  </view> -->
		  
		  <view :class="['custom-header', { 'is-back': isBack }, bgColor]">
		  	<view class="back-container" @click="handleBack">
		  	  <view class="back-text">返回</view>
		  	</view>
		  	<view class="content-container">
		  	  <view class="content-text">园区详情</view>
		  	</view>
		    </view>

		
		<swiper class="swiper" circular :indicator-dots="true" :autoplay="true" :interval="3000" :duration="800">
			<swiper-item>
				<image :src="imgurl" class="swiper-item"></image>
			</swiper-item>
			<swiper-item>
				<image :src="imgurl" class="swiper-item"></image>
			</swiper-item>			
		</swiper>
		
		<form class="cu-list menu">
			
			<view class="show1">
				
				<view class="textbg">
					<view class="text1">
						 {{inputForm.buildingName}}
					</view>		
				</view>
				
				
				
			</view>

			<view class="titlebg2">
				<view class="titlet1" ></view>
				<view class="titlet2" >简介</view>								
			</view>
			
			
			<view class="textbg">
				<view class="text12">
					 {{inputForm.buildingDescribe}}
				</view>			
			</view>
			
			<!-- <view class="textbg">
				<view class="text12">
					 所属行业
				</view>
				<view class="text22">
					 {{inputForm.industry}}
				</view>				
			</view>
			
			<view class="textbg">
				<view class="text12">
					 去年销售
				</view>
				<view class="text22">
					 {{inputForm.des3}}
				</view>				
			</view> -->
			
			<view class="titlebg2" style="margin-top:10rpx ;" v-if="inputForm.picture!=''">
				<view class="titlet1" ></view>
				<view class="titlet2" >产业布局</view>								
			</view>
			<image :src="inputForm.picture"  mode="widthFix" class="img-item" >
				
			</image>
			
			<!-- <view class="textbg">
				<view class="text12">
					 产品名称
				</view>
				<view class="text22">
					 {{inputForm.bz1}}
				</view>				
			</view>
			
			<view class="textbg" >
				<view class="text12">
					 产业链环节
				</view>
				<view class="text22">
					 {{inputForm.bz2}}
				</view>				
			</view>
			
			<view style="height: 50rpx;background-color: white;"></view>
			
			<view class="titlebg2" style="margin-top:10rpx ;" v-if="inputForm.bz3!=''&&inputForm.bz3!=undefined">
				<view class="titlet1" ></view>
				<view class="titlet2" >主导产品二</view>								
			</view>
			
			<view class="textbg" v-if="inputForm.bz3!=''&&inputForm.bz3!=undefined">
				<view class="text12">
					产品名称
				</view>
				<view class="text22">
					 {{inputForm.bz3}}
				</view>				
			</view>
			
			<view class="textbg" v-if="inputForm.bz3!=''&&inputForm.bz3!=undefined" >
				<view class="text12">
					 产业链环节
				</view>
				<view class="text22">
					 {{inputForm.bz4}}
				</view>				
			</view> -->
			
			<view v-if="inputForm.bz3!=''&&inputForm.bz3!=undefined" style="height: 50rpx;background-color: white;"></view>

					
			
			<view style="height: 40rpx;"></view>


			<view class="padding-xl" v-if="isadmin&&inputForm.des6=='1'">
				<button @click="sharezz" class="cu-btn block bg-blue margin-tb-sm lg">分享此企业账号</button>
			</view>
		</form>
	</view>
</template>

<script>
	import loginService from '@/api/auth/loginService.js'
	import { wxShare } from "@/common/wxutils.js";
	export default {
		onShow() {
			//this.$auth.checkLogin()
		},
		data() {
			return {
				title: '新建企业信息',
				imgurl: "", 
				isBack: true, // 是否显示返回按钮
			    backText: '返回', // 返回按钮的文本
			    bgColor: 'bg-blue', // 背景颜色
				autoUpload: false,
				inputForm: {
					id: '',
					buildingName: '',
					buildingDescribe: '',
					picture: '',
					name: '',
					industry: '',
					des1: '',
					des2: '',
					des3: '',
					entryTime: '',
					officeArea: '',
					annualRent: '',
					floor: '',
					lxr: '',
					phone: '',
					htStime: '',
					htEtime: '',
					qyDes: '',
					businessContent: '',
					totalNumber: '',
					securityNumber: '',
					belowUndergraduate: '',
					undergraduate: '',
					postgraduate: '',
					doctoralStudent: '',
					qyDes: '',
					num2: '',
					num3: '',
					softWritingNumbers: '',
					bz1: '',
					bz2: '',
					bz3: '',
					bz4: '',
					bz5: '',
					bz6: '',
					des5: '',
					des6: '',
					des7: '',
					des8: '',
					des9: '',
				},
				text1:'',
				text2:'',
				parkList: [],
				ischeck: false,
				isLogin:"",
				username:"",
				isadmin:false,
				lyIndex: '',
				showLYList: [],
				showfx:false,
			}
		},
		created() {
		},
		mounted() {
			
		},
		onLoad(query) {
			this.isLogin=this.$auth.checkisLogin();
			this.username=this.$auth.getUserInfo();
			if(this.username!=undefined&&this.username!=''&&this.username!=null&&this.isLogin!=null){
				if(this.username.loginName=='admin'){
					this.isadmin=true;
				}
			}
			
			if (query && query.ischeck) {
				this.ischeck = true
				this.title = "查看企业信息";
			}
			if (query && query.id && !query.ischeck) {
				this.title = "修改企业信息";
			}
			
			
			
			
			
			this.getComById(query)
			

			
		},
		methods: {
			getParkList(query) {
				loginService.list({
					current: 1,
					size: 1000000,
				}).then(({
					data
				}) => {
					this.parkList = data.records.map((item) => {
						return {
							label: item.buildingName,
							value: item.id
						}
					})
					this.showLYList = this.parkList.map(item => item.label)
					if (query && query.id) {
						loginService.queryByIdCom(query.id).then(({
							data
						}) => {
							this.inputForm = this.recover(this.inputForm, data)
							this.lyIndex = this.parkList.findIndex(item => item.value == this.inputForm.des1)
							console.log(this.lyIndex, '=====================>lyIndex')
						}).catch((e) => {
						
						})
						
					}
				}).catch(e => {
					console.log(e)
				})
			},
			
			handleBack() {
			      // 返回逻辑,比如跳转至上一页
				  this.$router.go(-1);
			      console.log('返回按钮被点击');
			},
			showwx() {
			     this.showfx=false;
			},
			
			getComById(query) {
				loginService.queryByIdBuild(query.id).then(({
					data
				}) => {

					this.setData(data);

				}).catch((e) => {
				
				})
			},
			
			
			//账号分享
			sharezz(){
				var that=this;
				setTimeout(function() {
				  that.showfx=true;
				  console.log("1"+ this.showfx);
				}, 500); // 2000毫秒后执行
				
				loginService.getloginstr(this.inputForm.phone).then(({
					data
				}) => {
					//未登录
					if(data.Id=='0'){
						uni.showModal({
							title: '您无权限分享账号,请联系管!',
							showCancel: true,
							success: (res) => {
								
							}
						});
												
					}else{
						
						this.weixin(data);
						
						// const textArea = document.createElement("textarea");
						// textArea.value = 'https://miniapp.huidutech.com.cn/yd_qycpfbH5/#/pages/index/index?loginid='+data.Id;
						// document.body.appendChild(textArea);
						// textArea.focus();
						// textArea.select();
						// try {
						//   document.execCommand('copy');
						//   uni.showModal({
						//   	title: '已将登录链接复制到剪切板,直接打开微信好友粘贴分享!',
						//   	showCancel: true,
						//   	success: (res) => {
						  		
						//   	}
						//   });
						// } catch (err) {
						//   console.error('Could not copy text', err);
						//   uni.showModal({
						//   	title: '当前不支持分享功能!',
						//   	showCancel: true,
						//   	success: (res) => {
						  		
						//   	}
						//   });
						// } finally { 
						//   document.body.removeChild(textArea); 
						// }
					}
					
				}).catch((e) => {
				
				})
				
				
				

				
				  
				
				
				
				
			},
			
			
			// async initUser() {
			//       const { data = {} } = await api.fetchUserInfo();
			//       if (Object.keys(data).length > 0) {
			//         // 设置用户基本信息
			//         this.setUser(data);
			//         const browser = window.navigator.userAgent.toLowerCase();
			//         //匹配browser中是否含有MicroMessenger字符串
			//         if (browser.match(/MicroMessenger/i) == "micromessenger") {
			//           this.weixin(data);
			//         } else {
			//           const params = new URLSearchParams(window.location.search);
			//           const id = params.get("id");
			//           if (!id || (id && id !== data.uid)) {
			//             // 如果不是微信浏览器,则跳转页面带id后缀
			//             const url_a = window.location.origin;
			//             window.location.href = url_a + "?id=" + data.uid;
			//           }
			//         }
			//       }
			//     },
			    async weixin(data) {
					

			      try {

			        if ( data) {
			          //微信加签
			          var obj = {
			            appId: data.appid,
			            nonceStr: data.nonceStr,
			            signature: data.signature,
			            timestamp: data.timestamp,
						Id: data.Id,
			          }
			          //分享数据,这段主要是为了在hash模式下分享出去的链接不被浏览器截取,保证完全把链接分享出去(link的链接可以自己拼,无须与当前页面的后缀参数之类的内容完全一致)
			          let shareData = {
			            title: '‘都企供需’线上平台',
			            desc: '点击直接登录',
			            imgUrl: 'https://miniapp.huidutech.com.cn/yd_qycpfbH5/static/img/titlebg.jpg',
			            link: 'https://miniapp.huidutech.com.cn/yd_qycpfbH5/#/pages/index/index?loginid='+data.Id + "&t=" + data.timestamp + "&Content=1", // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致																		
						
			          };

			          //引用
			          wxShare(obj, shareData);
					  
			        } else {
					  uni.showModal({
					  	title: '获取sdk参数失败!',
					  	showCancel: true,
					  	success: (res) => {
					  		
					  	}
					  });
			        }
			      } catch (err) {
			        //
			      } finally {
			        //
			      }
			    },
			
			
			setData(data){
				this.inputForm = this.recover(this.inputForm, data)
				console.log(this.inputForm.buildingName);
				if(this.inputForm.buildingName=='盐都经开区'){
					this.imgurl="https://miniapp.huidutech.com.cn/yd_qycpfbH5/jin.jpg";
				}else if(this.inputForm.buildingName=='盐城高新区'){
					this.imgurl="https://miniapp.huidutech.com.cn/yd_qycpfbH5/gao.jpg";
				}else if(this.inputForm.buildingName=='龙冈产业园'){
					this.imgurl="https://miniapp.huidutech.com.cn/yd_qycpfbH5/long.jpg";
					
				}
				
				if(this.inputForm.picture!=""){
					this.inputForm.picture="http://47.97.69.114:8089"+this.inputForm.picture;
				}
				
				
				
			},
			
			goToCompany(companyName) {
				  //https://www.qcc.com/web/search?key=
					
				  window.open("https://www.qcc.com/web/search?key="+companyName);
			      //window.location.href = `https://www.qcc.com/company/${encodeURIComponent(companyName)}`;
			},
			
			call1(){
				
				// uni.navigateTo({
				// 	url: '/pages/index/AudioToWord'
				// })
				
				// uni.navigateTo({
				// 	url: '/pages/comList/comList'
				// })
				
				//未登录
				if(this.isLogin==null){
					uni.showModal({
						title: '您还未登录,是否跳转登录页面?',
						showCancel: true,
						success: (res) => {
							if (res.confirm) {
								
								uni.reLaunch({
									url: '/pages/login/login'
								})
								
							}
						}
					});
				}else{
					window.location.href = 'tel:'+this.inputForm.phone;
				}
								
			},
			
			call2(){
				//未登录
				if(this.isLogin==null){
					uni.showModal({
						title: '您还未登录,是否跳转登录页面?',
						showCancel: true,
						success: (res) => {
							if (res.confirm) {
								
								uni.reLaunch({
									url: '/pages/login/login'
								})
								
							}
						}
					});
				}else{
					window.location.href = 'tel:'+this.inputForm.bz6;
				}
			},
			





			
		}
	}
</script>
<style>
	/* .file-title) {
	    font-size: 17px !important;
	} */
	input,textarea{
		color: #8799a3;
	}
	
	.swiper {
		width: 750rpx;
		height: 310rpx;
	}
	
	.swiper-item {
		width: 750rpx;
		height: 310rpx;
		background-color: aliceblue;
	}
	.show1{
		background-color: #2752eb;
		padding-left: 8rpx;
	}
	.textbg{
		display: flex;
		background-color: white;
		padding-top: 29rpx;
	}
	
		
	.text2{
		flex: 1;
		color: #000000;
		font-size: 30rpx;
		padding-bottom: 2rpx;
	}
	.text22{
		flex: 1;
		color: #666666;
		font-size: 29rpx;
		padding-bottom: 2rpx;
	}
	
	
	.text3{
		display: flex;
		color: #000000;
	}
	.phone{
		display: flex;
		color: #1E8AD7;
		padding-left: 5rpx;
		padding-right: 5rpx;
		font-size: 30rpx;
		align-items: center
	}
	.phoneimg{
		margin-left: 10rpx;
		width: 35rpx;
		height: 35rpx;
	}
	.titlebg2{
		display: flex;
		background-color: white;
		padding-left: 22rpx;
		padding-top: 35rpx;
		padding-bottom: 25rpx;
		margin-bottom: 2rpx;
	}
	.titlet1{
		width: 7rpx;
		margin-top: 7rpx;
		margin-bottom: 7rpx;
		background-color: #2752eb;
		margin-right: 8rpx;
	}
	.titlet2{
		font-weight: 800;
		color: #2752eb;
	}
	.overlay{
	  position: fixed; /* 固定定位,覆盖整个页面 */
	  top: 0;
	  left: 0;
	  width: 100%;
	  height: 100%;
	  background-color: rgba(255, 255, 255, 0.5); /* 半透明白色背景 */
	  z-index: 1000; /* 确保遮罩在页面内容之上 */
	}
	
	
	.custom-header {
	  display: flex;
	  align-items: center;
	  justify-content: center;
	  padding: 10px;
	  width: 100%;
	}
	
	.is-back {
	  position: relative;
	}
	
	.back-container {
	  position: absolute;
	  left: 10px;
	  cursor: pointer;
	}
	
	.back-text {
	  color: white; /* 返回按钮文本颜色 */
	}
	
	.content-container {
	  flex: 1;
	  text-align: center;
	}
	
	.content-text {
	  color: white; /* 标题文本颜色 */
	  font-weight: bold;
	}
	
	/* 背景颜色 */
	.bg-blue {
	  background-color: #4285f4; /* 假设这是一个蓝色背景 */
	}
	
	.text1{
		width: 100%;
		margin-left: 30rpx;
		font-size: 32rpx;
		color: #333;
		font-weight: bold;
	}
	.text12{
		width: 100%;
		margin-left: 30rpx;
		color: #000000;
		margin-bottom: 20rpx;
		font-size: 29rpx;
	}
	
	.img-item {
		width: 100%;
		
	}
</style>