<!-- 默认复制 -->

<template>
	<view class="content">
		<view class="c-top">
			<view class="" @click="getback()">
				<uni-icons type="left" size="18"></uni-icons>
			</view>
			<view class="c-title">行业公告</view>
			<view class=""></view>
		</view>
<!-- 		<view class="c-tap">
			<view class="tap-box" v-for="(item,index) in taplist" :key="index" @click="gettap(index,item)">
				<view :class="{'lan' : actindex == index}" >{{item.dictLabel}}</view>
				<view class="gang" v-if="actindex == index"></view>
			</view>
		</view> -->
		<!-- <view class="c-tap" v-if="type == 'zflm'" >
		<u-subsection font-size="15px"  :list="typeList" :current="typeIndex" @change="sectionChange"></u-subsection>
		</view> -->
		<view class="cont">
		<view class="bjimg" v-if="arrlist == ''">
			<image src="http://www.nuoyunr.com/lananRsc/detection/qs.png" mode=""></image>
		</view>
		<view class="c-box" v-for="(item,index) in arrlist" :key="index" @click="getdetails(item.id)">
			<view class="c-b-top">
				<view class="t-left">
					<image :src="imgs + item.newsCover" mode="scaleToFill"></image>
				</view>
				<view class="t-right">
					<view class="t-tilte">{{item.newsTitle}}</view>
						<view class="tw-tilte">一{{item.publishUnit}}</view>
						<view class="t-zi" v-html="item.newsContent"></view>
				</view>
			</view>

			<view class="c-b-bom">
				<view class="b-left">{{item.createTime.substring(0,item.createTime.length - 3)}}</view>
				<view class="b-right">
					<view class="z-lv">
							<u-icon name="eye-fill" color="#0D2E8D" size="28"></u-icon>
						<text>{{item.readNum}}</text>
					</view>
					<view class="y-hong">
							<u-icon name="thumb-up-fill" color="#fa3534" size="28"></u-icon>
						<text>{{item.likeNum}}</text>
					</view>
				</view>
			</view>
		</view>
		</view>
		<!--&lt;!&ndash; 悬浮按钮 &ndash;&gt;-->
		<!--<view class="fab-z1"  v-if="fab == true">-->
		<!--	<image src="http://www.nuoyunr.com/lananRsc/detection/fw.png"  @click="getnewadd()"></image>-->
		<!--</view>-->
		<!--<view class="fab-z2"  v-if="fab == true">-->
		<!--	<image src="http://www.nuoyunr.com/lananRsc/detection/gl.png" @click="getguanli()"></image>-->
		<!--</view>-->
		<!--<view class="q-fab">-->
		<!--	<image src="http://www.nuoyunr.com/lananRsc/detection/fab.png" v-if="fab == false" @click="getfab()"></image>-->
		<!--	<image src="http://www.nuoyunr.com/lananRsc/detection/xz.png" v-if="fab == true" @click="getfab()"></image>-->
		<!--</view>-->

		<!-- 悬浮按钮 结束-->
	<!-- 	<tabBar></tabBar> -->
	</view>
</template>

<script>
	import config from '@/config'
	import request from '../../utils/request';
	import tabBar from'../../components/detection/tabBar.vue'
	export default{
		data(){
			return{
				roles:[],
				jcshopRole:false,
				jcgfRole:false,
				isOpen: false,
				fab:false,
				imgs:'',
				type:'zflm',
				animationData: {},
				isRote: false,
				animation: null,
				actindex:0,
				arrlist:[],
				taplist:[],
				pageNum: 1,//第几页
				pageSize: 20,//一页多少张
				totalPages: 0,//总数
				typeList:[],
				unit:'',
				typeIndex:0,
			}
		},
		components:{
			tabBar,
		},
		onLoad(option) {
			this.unit = option.unit
		},
		onShow() {
			this.getlistindex()
			// this.getTypeList()
			this.imgs = this.$baseUrl
			this.roles = uni.getStorageSync('role')
			if(this.roles){
				this.roles.forEach(item=>{
					if(item =='jcshop'){
						this.jcgfRole = true
					}
					if(item =='jcgf'){
						this.jcgfRole = true
					}
				})
			}
		},
		onReachBottom() {
			console.log(111)
			if (this.pageNum >= this.totalPages) {
				uni.showToast({
					title: '没有下一页数据',
					icon: 'none'
				})

			} else {
				this.pageNum++
				this.arrlist=[]
				this.getList()
			}
		},
		methods:{
			async getTypeList(){
				let typeRes = await request({
					url: '/appInspection/news/listGfClass',
					method: 'get'
				})

				this.typeList = typeRes.data
			},
			getfab() {
			this.fab = !this.fab
					},
			gettap(index,item){
				this.actindex = index
				this.type = item.dictValue
				console.log(this.type);
				this.getlistindex()
			},
			getback(){
			uni.navigateBack({
					delta:1,
				})
			},
			async getlistindex(){
					//行业公告分类
				let ress = await request({
					url: '/appInspection/news/listType',
					method: 'get',
				})
				console.log(ress);
				this.taplist = ress.data
				let res = await request({
					url: '/appInspection/news/list',
					method: 'get',
					data: {
						type:"hygg",
						category:this.type,
						publishUnit:this.unit,
						pageSize:this.pageSize,
						pageNum:this.pageNum
					}
				})
				// this.arrlist = res.rows
				if (this.pageNum != 1){
					this.arrlist = this.arrlist.concat(res.rows)
				}else{
					this.arrlist = res.rows
					}
				let total =  res.total
				this.totalPages = Math.ceil(total / this.pageSize);

			},
			getdetails(id){
				uni.navigateTo({
					url:'/pages/detection/detedetails?id='+id
				})
			},
			getnewadd(){
				//发布行业公告
				uni.navigateTo({
					url:'/pages/detection/newsadd?type=hygg'
				})
			},
			// getdetails(id){
			// 	//编辑行业公告
			// 	uni.navigateTo({
			// 		url:'/pages/detection/detedetails?id='+id
			// 	})
			// },
			getguanli(){
				uni.navigateTo({
					url:'/pages/detection/managelist?type=hygg'
				})
			}

		}

	}
</script>

<style scoped lang="scss">
	.content{
		width: 100%;
		height: calc(100vh);
		background-color: #F6F6F6;
		box-sizing: border-box;
		// padding-top: 45px;
	}
	.top-icon{
		margin-bottom: 45px;
	}
	.q-fab{
		position: fixed;
		bottom: 50px;
		right: 15px;
		width: 55px;
		height: 55px;
		border-radius: 50%;
		overflow: hidden;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.fab-z1{
		position: fixed;
		bottom: 115px;
		right: 15px;
		width: 50px;
		height: 50px;
		border-radius: 50%;
		overflow: hidden;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.fab-z2{
		position: fixed;
		bottom: 50px;
		right: 80px;
		width: 50px;
		height: 50px;
		border-radius: 50%;
		overflow: hidden;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.c-tap{
		width: 100%;
		height: 40px;
		box-sizing: border-box;
		padding: 15px;
		display: flex;
		background-color: white;
		align-items: center;
	}
	.c-top{
		width: 100%;
		box-sizing: border-box;
		padding: 15px;
		padding-top: 15%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		background-color: white;
	}
	.c-title{
		font-size: 18px;
		font-weight: bold
	}
	.cont{
		width: 100%;
		padding: 15px;
		padding-top: 0px ;
		box-sizing: border-box;
			background-color: #F6F6F6;
	}
	.c-box{
		width: 100%;
		box-sizing: border-box;
		padding: 7px;
		background-color: white;
		margin-top: 10px;
		border-radius: 10px;
	}
	.c-b-top{
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.t-left{
		width: 40%;
		height: 100px;
		border-radius: 7px;
		margin-right: 10px;
		overflow: hidden;
		image{
			width: 100%;
			height: 100%;
		}

	}
	.t-right{
		width: 60%;
	}
	.t-tilte{
		font-size: 20px;
		font-weight: bold;
		color: #333333;
		 white-space: nowrap;
		 overflow: hidden;
		 text-overflow: ellipsis;

	}
	.tw-tilte{
		width: 100%;
		text-align: right;
		font-size: 16px;
		font-weight: bold;
		color: #5e5e5e;
		 white-space: nowrap;
		 overflow: hidden;
		 text-overflow: ellipsis;

	}
	.t-zi{
		font-size: 14px;
		font-weight: 400;
		color: #666666;
		 overflow: hidden;
		  text-overflow: ellipsis;
		  display: -webkit-box;
		  -webkit-line-clamp: 3;
		  -webkit-box-orient: vertical;

	}
	.bjimg{
		width: 255px;
		height: 236px;
		margin: 0px auto;
		margin-top: 100px;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.c-b-bom{
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 5px;
	}
	.b-left{
		color: #0D2E8D;
		font-size: 14px;
	}
	.b-right{
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.z-lv{
		display: flex;
		align-items: center;
		color: #0D2E8D;
		font-size: 15px;
		margin-right: 10px;
	}
	.y-hong{
		display: flex;
		align-items: center;
		color: #fa3534;
		font-size: 15px;
		margin-right: 15px;
	}
	.z-img{
		width: 20px;
		height: 15px;
		image{
			width: 100%;
			height: 100%;
		}
		margin-right: 2px;
	}
	.tap-box{
		width: 30%;
		text-align: center;
	}
	.gang{
		height: 4px;
		background: #0D2E8D;
		width: 80%;
		margin: 0px auto;
	}
	.lan{
		color: #0D2E8D;
	}
	.secondClass{
		padding: 3px;
		color: #0D2E8D;
		border-style:solid;
		border-width:2px;
		font-size: 15px;

	}
</style>
