<template>
	<view>
		<view class="overlay" v-if="showfx" @click="showwx">
			<image style="height: 100%;width: 100%;" src="/static/img/zz.png"></image>
						
		</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>

		
		<form class="cu-list menu">
			
			<view class="show1">
				
				<view class="textbg">
					<view class="text1">
						 {{inputForm.des1}}
					</view>		
				</view>
								
				<view class="textbg">
					<view class="text2">
						政策发文日期：{{inputForm.stime}}
					</view>		
				</view>
				
				<view class="textbg">
					<view class="text2">
						政策类型：{{inputForm.des2}}
					</view>		
				</view>
				
				<view class="textbg">
					<view class="text2">
						政策级别：{{inputForm.des3}}
					</view>		
				</view>
			</view>

			<view class="titlebg2">
				<view class="titlet1" ></view>
				<view class="titlet2" >政策内容</view>								
			</view>
			
			
			<view class="textbg">
				<view class="text12">
					 <rich-text :nodes="inputForm.des4"></rich-text>
				</view>			
			</view>
			
			<view class="titlebg2">
				<view class="titlet1" ></view>
				<view class="titlet2" >政策要点</view>								
			</view>
			
			
			<view class="textbg">
				<view class="text12">
					 <rich-text :nodes="inputForm.des6"></rich-text>
				</view>			
			</view>
			
				
			<view  style="height: 50rpx;background-color: white;"></view>

					
			
			<view style="height: 40rpx;"></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: '',
					stime: '',
					des1: '',
					des2: '',
					des3: '',
					des4: '',
					des6: '',
				},
				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.policyInfo({
					id: 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){
				

				if(data.des2=="1"){
					data.des2="工业";
				}else if(data.des2=="2"){
					data.des2="科技";
				}else if(data.des2=="3"){
					data.des2="发改";
				}else if(data.des2=="4"){
					data.des2="商务";
				}else if(data.des2=="5"){
					data.des2="人才政策";
				}
				
				
				if(data.des3=="1"){
					data.des3="国家";
				}else if(data.des3=="2"){
					data.des3="省级";
				}else if(data.des3=="3"){
					data.des3="市级";
				}else if(data.des3=="4"){
					data.des3="区级";
				}
				
				//替换图片样式
				if(data.des6!=undefined){
					data.des6=data.des6.replace(/\<img/gi, '<img style="max-width:100%;height:auto" ')
				}else{
					data.des6="";
				}
				
				if(data.des4!=undefined){
					data.des4=data.des4.replace(/\<img/gi, '<img style="max-width:100%;height:auto" ')
				}
				console.log(data.des4)
				
				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: 28rpx;
		color: #333;
		font-weight: bold;
	}
	.text2{
		width: 100%;
		margin-left: 30rpx;
		font-size: 28rpx;
		color: #333;
	}
	
	.text12{
		width: 100%;
		margin-left: 30rpx;
		color: #000000;
		margin-bottom: 20rpx;
		font-size: 29rpx;
	}
	
	.img-item {
		width: 100%;
		
	}
</style>