<template>
	<view class="container">
	
		<view class="attention-h">
			<view class="nav-bar">
				<view class="nav_max" :style="{'width': titleWidth}">
					<view class="attention-scarch flex al-item-center">
						<view class="input_box"  @click="goto" data-url='/diary/search/search'>
						  <text  class="iconfont icon-search"></text>	
						 <!-- <input disabled=""  placeholder="大家都在搜..." type="text" /> -->
						</view>
					</view>
					<view class="flex flex1 j-center">
						<view class="item position-r" @tap="goto" data-url='/diary/attention/attention' data-opentype="redirectTo">
							<text class="txt n-tv">关注</text>
						</view>
						<view class="item position-r" @tap="goto" data-url='/diary/evernote/evernote' data-opentype="redirectTo">
							<text class="txt font-w">笔记</text>
							<text class="heng position-a"></text>
						</view>
						<view class="item position-r" @tap="goto" data-url='/diary/video/video' data-opentype="redirectTo">
							<text class="txt n-tv">视频</text>
						</view>
						<!-- #ifdef MP -->
						<view class="item position-r" @tap="goto" data-url='/diary/live/live' data-opentype="redirectTo">
							<text class="txt n-tv">直播</text>
						</view>
						<!-- #endif -->
					</view>
				</view>
			</view>
		</view>
		<view class="" :style="{'height': hearHeight + 'px'}"></view>
		<view class="info_box">
			<view class="list_box">
				<view class="content">				
					<diary-falls-list @listZanFn='listZanFn' :datalist='datalist' v-if="datalist && datalist.length>0"> </diary-falls-list>
					<nomore text="没有更多内容了" v-if="nomore"></nomore>
					<nodata text="没有查找到相关内容" v-if="nodata"></nodata>
					
				</view>
			</view>
		</view>
		<view :style="{'background-color': t('color1')}" class="add" @click=" addFn">
		</view>
		<view class="add_box" @click="addShow = false" v-if="addShow">
			<view class="content" @click.stop="">
				<view class="item" @click="toAdd('diary')">
				发布笔记
				</view>
				<view class="item" @click="toAdd('video')">
				发布视频 
				</view>
				<view class="item" @click="addShow= false">
				取消
				</view>
			</view>
		</view>
		<dp-tabbar></dp-tabbar>
		<view class="tsinfo"  v-show='!info.isNote' >
			<!-- :style="{'background-image': 'url('+ event_rul +'/static/img/static/icon/9d3ab5fa33dedcde23ba05c8e9cdf999.png)'}" -->
			<text>发布笔记,让大家开始认识你吧</text>
		</view>
		<!-- 悬浮按钮 -->
		<drag-button></drag-button>
	</view>
</template>

<script>
	var app = getApp();
	export default{
		onLoad() {
			let elemetn
			// #ifdef MP-WEIXIN
			let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
			uni.getSystemInfo({
				success: res => {
					elemetn = res.statusBarHeight
				}
			})
			this.titleWidth = menuButtonInfo.left + 'px'
			 // #endif
			// #ifdef MP-WEIXIN
			this.navHeight = ((menuButtonInfo.bottom + menuButtonInfo.top) - elemetn) + 'px'
			// console.log(menuButtonInfo,elemetn,this.titleWidth, 'navheight')
			// #endif
			 // #ifndef MP 
			this.navHeight = 45 + 'px'
			this.titleWidth = '100vw'
			 // #endif 
			this.getRecList	()
		
		},
		onReady() {
			let query = uni.createSelectorQuery().in(this)
			query.select('.attention-h').boundingClientRect()
			query.exec(res => {
				this.hearHeight = res[0].height
			})
		},
		onShow(){
			this.getInfo()
		},
		data(){
			return{
				hearHeight:0,
				navHeight: 0,
				titleWidth: 0,
				addShow:false,
				info:{
					isNote:1,
				},
				pagenum:1,
				keyword:'',
				loading:false,
				isload: false,
				nomore:false,
				nodata:false,
				datalist:[],
				
				event_rul: app.globalData.event_url,
			}
		},
		 onReachBottom: function () {
		   if (!this.nodata && !this.nomore) {
		     this.pagenum = this.pagenum + 1;
		 	 this.getRecList()
		   }
		 },
		methods:{

			listZanFn(e){
				this.datalist[e.index].iszan = e.show;
				if(this.datalist[e.index].binfo){
					this.datalist[e.index].zan_num = e.num;
				}else{
					this.datalist[e.index].zan = e.num;
				}
			
			},
			addFn(){
				if(app.globalData.mid == 0){
					uni.showModal({
						title: '提示',
						content: '发布需要先登录',
						success: function (res) {
							if (res.confirm) {
								app.goto('/pages/index/login')
							} else if (res.cancel) {
								
							}
						}
					});
				}else{
					this.addShow= true
				
				}
			},
			searchFn(){
				uni.navigateTo({
					url:'/diary/search/search?keyword='+this.keyword
				})
			},
			toAdd(e){
				this.addShow = false;
				
				uni.navigateTo({
					url:'/diary/issue/issue?type='+e
				})
			},
	
			resetList(){
				this.pagenum = 1;
				this.getRecList()
				
			},

			getRecList() {
				let that = this;
			    var page = that.pagenum;
				that.loading = true;
				that.nomore = false;
				that.nodata = false;
			   app.get('ApiZhiwei/appNotVideoListIndex', {page: page,type_field:1,type:1}, function (res) {
				 that.loading = false;
			     var data = res.data;
			     if (page == 1) {
			       that.datalist = data;
			       if (data.length == 0) {
			         that.nodata = true;
			       }
			     }else{
			       if (data.length == 0) {
			         that.nomore = true;
			       } else {
			         var datalist = that.datalist;
			         var newdata = datalist.concat(data);
			         that.datalist = newdata;
			       }
			     }
				  	that.loaded();
			   });
			 },
			getInfo(){
				app.post('ApiZhiwei/appIndex',{},(res)=>{
					this.info = res.data
				})
			},
			
		},
	}
</script>

<style lang="scss">
	.tsinfo{
		    position: fixed;
		    right: 140rpx;
		    top: 66%;
			z-index: 10;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			height: 76rpx;
			border-radius: 8rpx;
			background-size: 100%;
			background-color: rgba(255,255,255, .8);
			border: 2rpx solid #0A5D3B;
			animation: tsinfo 1.2s infinite;
		text{
			position: relative;
			padding:0 16rpx;
			color: #0A5D3B;
			font-size: 26rpx;
			letter-spacing:2rpx;
		}
	}
	
	.tsinfo::after {
		content: '';
		width: 10rpx;
		height: 10rpx;
		border-top: 2rpx solid #0A5D3B;
		border-right: 2rpx solid #0A5D3B;
		background-color: rgba(255,255,255, .8);
		position: absolute;
		top: 50%;
		right: -8rpx;
		transform: translateY(-50%) rotate(45deg);
	}
	
	.nav-bar{
		display: flex;
		align-items: center;
		z-index:9;
		padding: 20rpx 72rpx 20rpx 24rpx;
		box-sizing: border-box;
	}
	.attention-h {
		width: 100%;
		background-color: #fff;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 3;
	}

	.add {
		width: 100rpx;
		height: 100rpx;
		line-height: 100rpx;
		text-align: center;
		border-radius: 28rpx;
		border:6rpx solid #fff;
		background-image: linear-gradient(to bottom right, #00AE68, #096742);
		position: fixed;
		right: 20rpx;
		top: 65%;
	}
	.add:after {
		content: '';
		width: 50%;
		height: 4rpx;
		background-color: #fff;
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
	}
	.add:before {
		content: '';
		width: 4rpx;
		height: 50%;
		background-color: #fff;
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
	}
	.add_box{
		position: fixed;
		top: 0;
		bottom: 0;
		right: 0;
		left: 0;
		background-color: rgba($color: #000000, $alpha: 0.4);
		z-index: 9999999;
	
		.content{
			background-color: #fff;
			padding-bottom: 20rpx;
			position: absolute;
			bottom: 0;
			left: 0;
			right: 0;
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;
			.item{
				padding: 30rpx;
				// border-bottom: 1px solid red;
			}
		}
	}
	.list_box{
	.content{
		padding: 20rpx;
		// margin-top: 20rpx;
		background-color: #f8f9fa;
		.nav_min{
			display: flex;
			margin-bottom: 20rpx;
			.item{
				margin-right: 20rpx;
			}
			.itemz{
				font-weight: bold;
			}
		}
	}
	}
	.nav_max{
		display: flex;
		justify-content: space-around;
       .item{
		   display: flex;
		   align-items: center;
		   justify-content: center;
		   flex-direction: column;
		   font-size: 30rpx;
			 margin: 0 18rpx;
		   .txt{
			   font-size: 32rpx;
			   color: #333333;
			   z-index: 2;
		   }
		   .n-tv {
			   color: #999;
		   }
		   .heng{
			   bottom: -6rpx;
			   width: 44rpx;
			   border-radius: 4rpx;
			   height: 6rpx;
			   background-color: #0A5D3B;
			   
		   }
	   }
	}
	
	.info_box{

		.content {
			
		}
	}
	.attention-scarch {
		
		padding-left: 4rpx;
	}
	.input_box{
		display: flex;
	
		.iconfont{
			font-size: 50rpx;
		}
		input{
			flex: 1;
		}
	
	}
	.container{
		background-color: #fff;
		min-height: 100vh;
	}
	
	@keyframes tsinfo {
		0% {transform:  translateX(8rpx);}
		50% {transform:  translateX(-8rpx);}
		100% {transform: translateX(8rpx);}
	}
</style>
