<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title>公告列表</title>
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link href="../../css/OA-style.css" rel="stylesheet" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav ">
			<a href="" class="mui-action-back back mui-pull-left"><img src="../../images/back.png"></a>
			<h1 id="title" class="mui-title">签收会议</h1>
		</header>
		
		
		<div class="mui-content" >
			<div id="pullrefresh" class="mui-content mui-scroll-wrapper" style="">

				<div class="mui-card" v-for="item in items">
					<a href="javascript:;" :data-id="item.id" @tap="open_detail(item)">
					<div class="mui-card-header tongzhi_title"><b>{{item.meeting_title}}</b></div>
					<div class="mui-card-content">
						<div class="mui-card-content-inner">
							<div >
								<span class="tongzhi_div"><img class="tongzhi_img" src="../../images/zhibanshijian.png"></span>
								<span class="tongzhi_div1">参会开始时间:{{item.meeting_start_date}}</span>
								<br />
								<span class="tongzhi_div1">会议室:{{item.meeting_room_name}}</span>
								<br />
								<span class="tongzhi_div1">紧急程度:{{item.meeting_level}}</span>
								<br />
								<span class="tongzhi_div1">发布人:{{item.name}}</span>
								<br />
								<span class="tongzhi_div1">参会结束时间:{{item.meeting_end_date}}</span> 
								<br />
								<span class="tongzhi_div1">内容:{{item.meeting_content}}</span> 
							</div>
						</div>
					</div>
					</a>
				</div>
				<div></div>
			</div>
		</div>
		

		<script type="text/javascript" src="../../js/jquery-1.11.2.min.js"></script>
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/config.js"></script>
		<script src="../../js/app.js"></script>
		<script src="../../js/dj/article/list.js"></script>
		<script src="../../js/vue.min.js"></script>

		<script>
			var pageDetail = null;
			mui.init({
				pullRefresh: {
					container: '#pullrefresh',
					down: {
						style: 'circle', 		//必选，下拉刷新样式，目前支持原生5+ ‘circle’ 样式
						color: '#2BD009', 		//可选，默认“#2BD009” 下拉刷新控件颜色
						height: '50px', 		//可选,默认50px.下拉刷新控件的高度,
						range: '100px', 		//可选 默认100px,控件可下拉拖拽的范围
						offset: '0px', 			//可选 默认0px,下拉刷新控件的起始位置
												//auto: true, //可选,默认false.首次加载自动上拉刷新一次
						callback: reloadNews 	//必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据；
					},
					up: {
						contentrefresh: '正在加载...',
						auto: true, 			//可选,默认false.自动上拉加载一次
						callback: pullupRefresh
					}
				}
			});


			var vmA = new Vue({
				el: '#pullrefresh',
				data: {
					items: [] //列表信息流数据
				}
			});

			/**
			 * 下拉刷新具体业务实现
			 */
			function reloadNews() {
				pageNo = 1;
				vmA.items = [];
				//				var table = document.body.querySelector('.mui-table-view');
				//				table.innerHTML = "";
				addData();
			}

			var pageNo = 1;
			var type = 0;
			/**
			 * 上拉加载具体业务实现
			 */
			function pullupRefresh() {
				addData();
			}

			function addData() {
				var url = API.API_URL();
				var serviceId = "oa_2014V002PHONE_userList";
				var state = app.getState(); //获取登陆信息
				var staffId = state.user.useId;
				var unitId = state.user.unitId;
				var obj = {
					currentUser: staffId,
					p: pageNo,
					pSize: APP.PageSize,
					type: type,
					isRead : '1',
					unit_id: unitId

				};
				app.ajax(serviceId,obj, function(data) {
					//服务器返回响应
					console.log(JSON.stringify(data))					

					var totalRow = data.total;
					var totalPage = Math.ceil(totalRow / APP.PageSize);
					var list = data.list;
					if(totalPage == 0){
						totalPage =1;
					}		
					if(list.length > 0) {
						vmA.items = vmA.items.concat(convert(list));
					}
					mui('#pullrefresh').pullRefresh().endPullupToRefresh(totalPage == pageNo); //参数为true代表没有更多数据了。

					if(pageNo == 1 && totalPage>1) {
					    mui('#pullrefresh').pullRefresh().endPulldown();
						mui('#pullrefresh').pullRefresh().refresh(true);
					}
					if(totalPage == 1 ){
						mui('#pullrefresh').pullRefresh().endPulldown();
					}						
					pageNo = pageNo + 1;
				});
			}

			/**
			 * 1、将服务端返回数据，转换成前端需要的格式
			 * 2、若服务端返回格式和前端所需格式相同，则不需要改功能
			 * 
			 * @param {Array} items 
			 */
			function convert(items) {
				var newItems = [];
				items.forEach(function(item) {
					newItems.push({
	 						 meeting_user_id:		item.meeting_user_id,
							 meeting_user:	 		item.meeting_user,
							 desc: 					item.desc,
							 meeting_create_date:  	item.meeting_create_date, 
							 meeting_address:  		item.meeting_address,
							 meeting_send_user: 	item.meeting_send_user,
							 meeting_issms: 		item.meeting_issms,
							 meeting_doc: 			item.meeting_doc,
							 meeting_start_date: 	item.meeting_start_date,
							 name: 					item.name,
							 meeting_end_date:	 	item.meeting_end_date,
							 meeting_title:		 	item.meeting_title,
							 user_id: 				item.user_id,
							 meeting_user_type:		item.meeting_user_type,
							 meeting_room_name: 	item.meeting_room_name, 
							 meeting_id:			item.meeting_id,
							 meeting_level:			item.meeting_level,
							 meeting_content:		item.meeting_content
					});
				});
				return newItems;
			}

			mui.plusReady(function() {
				var self = plus.webview.currentWebview();
				type = self.type;			//{type":0,"name":"待签收会议"}{"type":1,"name":"已签收会议"}
				var title1 = mui('#title');
				title1[0].innerHTML = self.name;
				//接收上个界面传递的参数
				window.addEventListener('listEvent', function(event) {
					
				});
				 //addData();
			});

			/**
			 * 打开详情
			 * 
			 * @param {Object} item 
			 */
			function open_detail(item) {
				//触发子窗口变更详情
				if(type == 1){			//前往查看已签收页面
					mui.openWindow({
					url: 'meetingInfoSignYet.html',
					id: 'meetingInfoSignYet.html',
					extras:{'meeting_id':item.meeting_id,
							'meeting_user_id':item.meeting_user_id,
							'type':'1'
							}
					});
				}else if(type == 0){	//前往查看未签收页面，可执行签收
					mui.openWindow({
					url: 'meetingInfoDoSign.html',
					id: 'meetingInfoDoSign.html',
					extras:{'meeting_id':item.meeting_id,
							'meeting_user_id':item.meeting_user_id,
							'type':'0'
							}
					});
				}
				
			}
		</script>
	</body>
</html>