<template>
	<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>

		
		<view :style="[{top:CustomBar + 'px'}]">
					
			
			<view class="search-box1">
				<view class="choose-box">
															
					<jp-picker2 class="choose-boxp" v-model="searchForm.des2" empty="选择政策类型" rangeKey="label" rangeValue="value"
						:range="parkList2" @change="picker2change" >						
					</jp-picker2>

					
				</view>
				<view class="choose-box">
																				
					<jp-picker2 class="choose-boxp" v-model="searchForm.des3" empty="选择政策级别" rangeKey="label" rangeValue="value"
						:range="parkList"  @change="picker2change">
					</jp-picker2>
					
				</view>
			</view>
			
			
					
			<view class="choose-box2" style="margin-top: 20rpx;margin-left: 20rpx;margin-right: 20rpx;">
				<view style="width: 560rpx;">
					<input type="text"  placeholder="输入政策标题关键词" v-model="searchForm.des1" confirm-type="search"
					></input>
				</view>
				
				<text style="padding-left: 40rpx;flex: 1;" class="cuIcon-search color-white" @click="doSearch"></text>
			</view>
			
			<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" :up="upOption" @up="upCallback">
				<view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
					v-for="(item, index) in dataList" :key="index" @touchstart="ListTouchStart"
					@touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
					
					
					<view class="item-box" @click="gotoBuildInfo(item.id)">
						
						
						<view class="item-title-L">
							
							<view class="item-title">
								
								<span class="color-cheng" v-if="item.des2 === '1'">【工业】</span>
								<span class="color-cheng" v-else-if="item.des2 === '2'">【科技】</span>
								<span class="color-cheng" v-else-if="item.des2 === '3'">【发改】</span>
								<span class="color-cheng" v-else-if="item.des2 === '4'">【商务】</span>
								<span class="color-cheng" v-else-if="item.des2 === '5'">【人才政策】</span>
								
								<span class="color-lan" v-if="item.des3 === '1'">【国家】</span>
								<span class="color-lan" v-else-if="item.des3 === '2'">【省级】</span>
								<span class="color-lan" v-else-if="item.des3 === '3'">【市级】</span>
								<span class="color-lan" v-else-if="item.des3 === '4'">【区级】</span>
								{{item.des1}}
							</view>

							<view class="item-des">									
								政策发文日期:{{item.stime}}
							</view>
						</view>
						

					</view>
										
					
				</view>
			</mescroll-body>

		</view>
	</view>
</template>

<script>
	import uniFab from '@/components/uni-fab/uni-fab.vue';
	import loginService from '@/api/auth/loginService.js'
	import DoublePicker from '@/components/DoublePicker/DoublePicker.vue'
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import MescrollMoreItemMixin from "@/components/mescroll-uni/mixins/mescroll-more-item.js";
	export default {
		mixins: [MescrollMixin, MescrollMoreItemMixin], // 使用mixin (在main.js注册全局组件)
		onShow(option) {
			//this.$auth.checkLogin()
			
			
			this.isLogin=this.$auth.checkisLogin();
		},
		components: {
			uniFab
		},
		data() {
			return {
				isBack: true, // 是否显示返回按钮
				backText: '返回', // 返回按钮的文本
				bgColor: 'bg-blue', // 背景颜色
				
				isLogin:"",
				searchForm: {
					des1:"",
					des2:"",
					des3:"",
				},
				picture:["https://miniapp.huidutech.com.cn/yd_qycpfbH5/bg1.jpg",
				"https://miniapp.huidutech.com.cn/yd_qycpfbH5/bg2.jpg",
				"https://miniapp.huidutech.com.cn/yd_qycpfbH5/bg3.jpg",
				"https://miniapp.huidutech.com.cn/yd_qycpfbH5/bg4.jpg"],
				parkList2: [ {label: '全部',value: ''},{label: '工业',value: '1'},{label: '科技',value: '2'}
				,{label: '发改',value: '3'},{label: '商务',value: '4'},{label: '人才政策',value: '5'}
				],
				curWord: "", //当前搜索关键词
				dataList: [], // 数据列表
				modalName: null,
				tablePage: {
					total: 0,
					currentPage: 1,
					pageSize: 10,
					orders: []
				},
				loading: false,
				parkId: '',
				parkList: [{label: '全部',value: ''},{label: '国家',value: '1'},{label: '省级',value: '2'}
				,{label: '市级',value: '3'},{label: '区级',value: '4'}],
			}
		},
		created() {

			//this.getParkList()
			//this.getParkList2()			
		},
		methods: {
			
			// //选择属地
			// getParkList2() {
			// 	loginService.getAreaList({
			// 	}).then(({
			// 		data
			// 	}) => {
			// 		this.parkList2 = data.map((item) => {
			// 			return {
			// 				label: item.des1,
			// 				value: item.des1
			// 			}
			// 		})
			// 	}).catch(e => {
			// 		console.log(e)
			// 	})
			// },
			
			//选择行业
			// getParkList() {
			// 	loginService.getHyList({
			// 	}).then(({
			// 		data
			// 	}) => {
			// 		this.parkList = data.map((item) => {
			// 			return {
			// 				label: item.industry,
			// 				value: item.industry
			// 			}
			// 		})
			// 	}).catch(e => {
			// 		console.log(e)
			// 	})
			// },
			
			
			// 新增
			add() {
				uni.navigateTo({
					url: '/pages/comEdit/comEdit'
				})
			},
			// 修改
			edit(id) {
				uni.navigateTo({
					url: '/pages/comEdit/comEdit?id=' + id
				})
			},
			gotoBuildInfo(id) {
				uni.navigateTo({
					url: `/pages/policy/policyInfo?id=${id}&ischeck=1`
				})
			},
			// 删除
			del(id) {
				uni.showModal({
					title: '提示',
					content: '您确认要删除数据吗',
					showCancel: true,
					success: (res) => {
						if (res.confirm) {
							loginService.deleteCom(id).then(({
								data
							}) => {
								uni.showToast({
									title: data,
									icon: "success"
								})
								this.doSearch()
							})
						}
					}
				});
			},
			/*获取数据列表 */
			upCallback(page) {
				this.loading = true
				loginService.policyList({
					current: page.num,
					size: page.size,
					orders: [{ column: 'a.create_date', asc: false }],
					...this.searchForm
				}).then(({
					data
				}) => {
					
					
					
					let curPageData = data.records
					this.mescroll.endBySize(curPageData.length, data.total);
					//如果是第一页需手动制空列表
					if (page.num == 1)
						this.dataList = [];
					//追加新数据
					this.dataList = this.dataList.concat(curPageData);
				}).catch(e => {
					//联网失败, 结束加载
					this.mescroll.endErr();
				})
			},
			
			remoteMethod  (query) {
			  if (query) {
			    this.loading = true
			    setTimeout(() => {
			      this.loading = false
			      this.parkList = this.parkList.filter((item) => {
			        return item.label.toLowerCase().includes(query.toLowerCase())
			      })
			    }, 200)
			  } else {
			    this.parkList = []
			  }
			},
			
			picker2change(e) {
				this.doSearch() ;
			},
			
			// 输入监听
			inputWord(e) {
				
			},
			// 搜索
			doSearch() {
				this.dataList = []; // 先清空列表,显示加载进度
				this.mescroll.resetUpScroll();
			},
			// ListTouch触摸开始
			ListTouchStart(e) {
				this.listTouchStart = e.touches[0].pageX
			},

			// ListTouch计算方向
			ListTouchMove(e) {
				this.listTouchDirection = e.touches[0].pageX - this.listTouchStart > -60 ? 'right' : 'left'
			},

			// ListTouch计算滚动
			ListTouchEnd(e) {
				if (this.listTouchDirection == 'left') {
					this.modalName = e.currentTarget.dataset.target
				} else {
					this.modalName = null
				}
				this.listTouchDirection = null
			},
			handleBack() {
			      // 返回逻辑,比如跳转至上一页
				  this.$router.go(-1);
			}
		}
	}
</script>

<style>
	.ellipsis-description {
		font-size: 12px;
		line-height: $line-height-base;
		display: -webkit-box;
		/*作为弹性伸缩盒子模型显示*/
		-webkit-line-clamp: 1;
		/*显示的行数;如果要设置2行加...则设置为2*/
		overflow: hidden;
		/*超出的文本隐藏*/
		text-overflow: ellipsis;
		/* 溢出用省略号*/
		-webkit-box-orient: vertical;
		/*伸缩盒子的子元素排列:从上到下*/
	}

	.cu-bar .search-form {
		background-color: white;
	}
	
	
	
	
	.item-line{
		display: flex;
		height: 48rpx;
		margin-top: 20rpx;
	}
	
	.item-line2{
		
		height: 48rpx;
		margin-top: 20rpx;
	}
	
	.subtitle{
		color: #E5880E;
	}
	
	.item-name{
		margin-top: 5rpx;
		font-size: 30rpx;
		color: #333;
	}
	
	.item-name2{
		font-size: 29rpx;
		color: #8387AA;
	}
	
	.item-name3{
		display: flex;
		width: 100%;
		padding-right: 30rpx;
		flex: 1;
		justify-content: flex-end;
		font-size: 29rpx;
		color: #8387AA;
	}
	
	.item-content{
		color: #1497EF;
		font-size: 30rpx;
	}
	
	.btn-box{
		display: flex;
	}
	
	.line-zs{
		width: 2rpx;
		height: 30rpx;
		background: #36A7F3;
	}
	
	.edit-botton{
		width: 100rpx;
		height: 48rpx;
		line-height: 48rpx;
		color: #fff;
		font-size: 28rpx;
		margin-right: 20rpx;
		border-radius: 10rpx;
		background: #5A9EE9;
		text-align: center;
	}
	
	.del-botton{
		width: 100rpx;
		height: 48rpx;
		line-height: 48rpx;
		color: #fff;
		font-size: 28rpx;
		margin-right: 20rpx;
		border-radius: 10rpx;
		background: #F27C85;
		text-align: center;
	}
	
	.color-white{
		color: #fff;
		font-size: 40rpx;
		line-height: 60rpx;
	}
	
	.search-box{
		background: #36A7F3;
		display: flex;
		padding-left: 20rpx;
		padding-right: 20rpx;
		padding-bottom: 10rpx;
	}
	
	.input-box{
		background: #fff;
		height: 65rpx;
		width: 640rpx;
		display: flex;
		align-items: center;
		border-radius: 30rpx;
		padding-left: 30rpx;
		margin-right: 20rpx;
	}
	
	.input-boxinput{
		height: 75rpx;
		font-size: 15rpx;
	}
	
	
	
	.choose-box{
		background: #fff;
		width: 350rpx;
		border-radius: 30rpx;
		height: 60rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-right: 20rpx;
	}
	
	.choose-boxp{
		font-size: 32rpx;
		width: 80%;
	}
	
	
	.swiper {
		width: 750rpx;
		height: 310rpx;
	}
	
	.swiper-item {
		width: 750rpx;
		height: 310rpx;
		background-color: aliceblue;
	}
	
	
	
	
	.item-box{
		
		display: flex;
		
		width: 710rpx;
		margin-left: 20rpx;
		background: #FFFFFF;
		box-shadow: 0px 1px 3px 0px rgba(9,2,4,0.1);
		border-radius: 10px;
		padding-top: 20rpx;
		padding-left: 20rpx;
		padding-right: 10rpx;
		padding-bottom: 20rpx;
		margin-top: 20rpx;
	}
	
	.item-title-L{
		display: flex;
		width: 100%;
		margin-left: 10rpx;
		flex-direction: column;
	}
	
	.item-title{
		font-size: 29rpx;
		color: #333;
		font-weight: bold;
		align-items: center;
	}
	.item-des{
		margin-top: 10rpx;
		color: #565656;		
			
		font-size: 24rpx;
		overflow: hidden; /* 超出部分隐藏 */
		text-overflow: ellipsis; /* 超出部分显示省略号 */
		display: -webkit-box; /* 使用Webkit的行盒模型 */
		-webkit-line-clamp: 3; /* 限制最多显示2行 */
		-webkit-box-orient: vertical; /* 垂直排列 */
		
	}
	/* 返回 */
	.item-img {
		width: 160rpx;
		height: 160rpx;
	}
	
	.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; /* 返回按钮文本颜色 */
	}
	.back-text {
	  color: white; /* 返回按钮文本颜色 */
	}
	
	.content-container {
	  flex: 1;
	  text-align: center;
	}
	
	.content-text {
	  color: white; /* 标题文本颜色 */
	  font-weight: bold;
	}
	
	/* 背景颜色 */
	.bg-blue {
	  background-color: #4285f4; /* 假设这是一个蓝色背景 */
	}
	
	.choose-box2{
		background: #fff;
		width: 94%;
		border-radius: 23rpx;
		height: 70rpx;
		display: flex;
		padding-left: 29rpx;
		align-items: center;
		border: 1rpx  solid #808080;
	}
	
	.choose-box3{
		display: flex;
	}
	
	.search-box1{
		display: flex;
		margin-top: 20rpx;
		margin-left: 20rpx;
		margin-right: 12rpx;
	}
	
	
	
	.input-box{
		background: #fff;
		height: 65rpx;
		width: 640rpx;
		display: flex;
		align-items: center;
		border-radius: 30rpx;
		padding-left: 30rpx;
		margin-right: 20rpx;
	}
	
	.input-boxinput{
		height: 75rpx;
		font-size: 15rpx;
	}
	.color-white{
		color: #808080;
		font-size: 40rpx;
		line-height: 60rpx;
	}
	.color-cheng{
		color: #f47920;
		
	}
	.color-lan{
		color: #4285f4;
		
	}
</style>