<template>
  <view >
	  <view class="notbox">
		   <meet-list :datalist="list" :wtdt="wtdt"   :type='type' @getDetail="getDetail" @getTuiFn="getTuiFn"></meet-list>
	  </view>
	 <pop-up :type='ptype' :codeQr="codeQr" @getClose="getClose" @getupSubmit="getupSubmit" :qjlxlist="qjlxlist"></pop-up>
	<footers v-if="isfootflag" :footlist="footlist" :footerindex="footerindex" :color_checked="color_checked" :color_nochecked="color_nochecked" :isHomeIndex="true"></footers>
 </view>
</template>

<script>
	import popUp from "@/work/components/popup/popup.vue"
	import footers from '@/components/footer/footer.vue'
  import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  import {getMeetListFn,getzxActivityReplyFn,getupdateReplyFn} from "@/api/mine/meeting.js"
  import {getDictionaryFn} from "@/api/mine/register.js"
  import meetList from "@/work/components/meeting/list.vue"
  export default {
	components:{footers,meetList,popUp},
    data() {
      return {
		  footlist:[
		  	{module:'home',title:'潜山政协',icon_checked:require('@/static/images/tabbar/home_.png'),icon_nochecked:require('@/static/images/tabbar/home.png')},
		  	{module:'report',title:'履职报告',icon_checked:require('@/static/images/tabbar/report_.png'),icon_nochecked:require('@/static/images/tabbar/report.png')},
		  	{module:'notice',title:'会议通知',icon_checked:require('@/static/images/tabbar/notice_.png'),icon_nochecked:require('@/static/images/tabbar/notice.png')},
		  	{module:'mine',title:'个人中心',icon_checked:require('@/static/images/tabbar/mine_.png'),icon_nochecked:require('@/static/images/tabbar/mine.png')},
		  	],
		  color_checked :'222327',
		  color_nochecked :'AAAAAA',
		  footerindex:'notice',
		  isfootflag:true,
		  list:[],
		  pageSize: 10,
		  pageNum: 1,
		  reachflag: true,
		  wtdt:'',
		  type:'hytz',
		  ptype:'',
		  codeQr:"",
		  qjlxlist:[],
		  userId:this.$store.state.user.userId,
      }
    },
	onUnload(){
		uni.$off('refreshlist')
	},
	onShow() {
	},
	onLoad() {
		this.getDataFn()
		this.init()
		uni.$on('refreshlist', (e) => {
			this.pageNum=1;
			this.list=[];
			this.reachflag=true;
			this.getDataFn()
		})
	},
	// 上拉触底加载更多触发事件
	onReachBottom() {
		if (this.reachflag) {
			this.pageNum++
			this.getDataFn()
		}
	},
    methods: {
		checkPermi, checkRole,
		getClose(){
			this.ptype=""
		},
		getDetail(data){
			var type=this.tabidx;
			this.$tab.navigateTo('/work/pages/meeting/details?id='+data+"&pt=hytz")		
		},
		getTuiFn(ite){
			if(ite.type=='hyqd'){
				this.$tab.navigateTo('/work/pages/meeting/signin?id='+ite.id)
			}else{
				this.codeQr=ite.item.conferenceQr
				this.ptype=ite.type;
				this.id=ite.id
			}
		},
		init(){
			// 请假类型
			getDictionaryFn('leave').then(res=>{
				if(res.code==200&&res.data.length){
					this.qjlxlist = res.data.map(v => {
						return {
							text: v.dictLabel,
							value: v.dictValue
						}
					})
					this.aqjlxlist = res.data.map(v => {
						return {
							label: v.dictLabel,
							value: v.dictValue
						}
					})
				}
			})
		},
		getupSubmit(e){
			var that=this;
			var type=this.type;
			var params=JSON.parse(JSON.stringify(e))
			params.userId=this.userId;
			params.conferenceId=this.id;
			getupdateReplyFn(params).then(res=>{
				if(res.code==200){
					this.$toast("答复成功");
					setTimeout(function(){
						that.ptype='';
						that.pageNum=1;
						that.list=[];
						that.reachflag=true;
						that.getDataFn()
					},1200)
					
				}
			})
			
			
		},
		getDataFn(){
			var params={
				pageSize:this.pageSize,
				pageNum: this.pageNum,
				// visitType:3
			}
			params.userId=this.userId
			getMeetListFn(params).then(res=>{
				if(res.code==200){
					if (res.rows.length < this.pageSize) {
						this.reachflag = false
						this.wtdt = '到底了~';
					} else {
						var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum -	1)
						if (num < res.total) {
							this.reachflag = true
							this.wtdt = '上拉加载更多'
						} else {
							this.reachflag = false
							this.wtdt = '到底了~';
						}
					}
					if (this.pageNum == 1) {
						this.list = res.rows;
					} else {
						this.list = this.list.concat(res.rows)
					}
				}else{
					this.$toast(res.msg)
				}
			})
	
		},
    }
  }
</script>

<style lang="scss" scoped>
  page {
    background-color: #f5f6f7;
  }
  .notbox{padding: 24rpx;}
</style>
