<!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 >
								<div class="tongzhi_div2" style="word-wrap:break-word;overflow:hidden; text-overflow:ellipsis;display:-webkit-box; -webkit-box-orient:vertical;-webkit-line-clamp:3;background: url(../../images/dubanneirong.png) no-repeat;background-size:13px 13px;background-position-y: 2px;text-indent: 1em;margin-bottom: 8px;width: 99%;">{{item.content}}</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_list";
				var state = app.getState(); //获取登陆信息
				var staffId = state.user.useId;
				var obj = {
					currentUser: staffId,
					p: pageNo,
					pSize: APP.PageSize

				};
				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_type:          item.meeting_type,
						 meeting_audit_user:    item.meeting_audit_user, 
						 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,
						 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();
				var title1 = mui('#title');
					title1[0].innerHTML = self.name;
					type = self.type;
				//接收上个界面传递的参数
				window.addEventListener('listEvent', function(event) {
					
				});
			});

			/**
			 * 打开详情  item--当前点击对象，包含基本信息
			 */
			function open_detail(item) {
				//触发子窗口变更详情
				mui.openWindow({
					url: 'meetingInfoMypublish.html',
					id: 'meetingInfoMypublish.html',
					extras:{'meeting_id':item.meeting_id,
							'meeting_user_id':item.meeting_user_id,
							'type':'1'						//详情type=1           签收详情type！=1
							}
				})
			}
		</script>
	</body>
</html>