<!DOCTYPE HTML>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/app.css" />
		<link rel="stylesheet" type="text/css" href="../../css/aui.2.0.css" />
		<style>
			body {
				background-color: #fff;
			}
			.left{
          float: left !important;
      }
      .right{
          float: right !important;
      }
	    .clearf{
	      clear: both;
	      line-height: 0;
	      height: 0%;
	      font: 0px Arial;
	      overflow: hidden;
	    }
			h1 {
				position: relative;
				width: 100%;
				height: 50px;
				line-height: 50px;
				color: #FFF;
				font-size: 20px;
				text-align: center;
			}

			.f10 {
				font-size: 10px;
			}

			.f13 {
				font-size: 13px;
			}

			.f15 {
				font-size: 15px;
			}

			.pf {
				position: fixed;
			}

			.fl {
				float: left;
			}

			.z10 {
				z-index: 10;
			}

			.fb {
				font-weight: bold;
			}

			.c000 {
				color: #000;
			}

			.lh30 {
				line-height: 30px;
			}

			.lh20 {
				line-height: 20px;
			}

			.caflbtn {
				padding: 2px 10px 2px 15px;
				display: inline-block;
				width: 80px;
				min-height: 30px;
			}

			.pa {
				position: absolute;
			}

			.ml60 {
				margin-left: 60px;
			}

			.mr20 {
				margin-right: 20px;
			}

			.mr40 {
				margin-right: 40px;
			}

			.fr {
				float: right;
			}

			.f11 {
				font-size: 11px;
			}

			.bgeee {
				background-color: #eeeeee;
			}

			.c666 {
				color: #666666;
			}

			.pb55 {
				padding-bottom: 55px;
			}

			.bottom0 {
				bottom: 0px;
			}

			.wp100 {
				width: 100%;
			}

			.bgcfff {
				background-color: #fff;
			}

			.h50 {
				height: 50px;
			}

			.lh50 {
				line-height: 50px;
			}

			.cfff {
				color: #fff;
			}

			.pt20 {
				padding-top: 20px;
			}

			.ml55 {
				margin-left: 55px;
			}

			.wp70 {
				width: 70%;
			}

			.cblue-app {
				color: #519ade;
			}

			.li-swid {
				width: 20%;
				position: relative;
			}

			.ming-list {
				position: relative;
			}

			.ming-list-xf {
				position: absolute;
				width: 100%;
				z-index: 10;
				padding: 0.5rem;
			}

			.ming-list-xf .aui-pull-right,
			.ming-bg-b30 {
				background-color: rgba(0, 0, 0, 0.3);
			}

			.ming-list-xf .ming-bg-app,
			.ming-bg-b30 {
				padding: 0.25rem;
				font-size: 0.5rem;
			}

			.w14 {
				width: 14px;
			}

			#content_img {
				overflow: hidden;
			}

			#content_img img {
				max-width: 100%;
			}

			.ms-controller,
			[ms-controller] {
				display: none
			}

			.bgcfbf69c {
				background-color: #a4bed2 !important;
			}

			.disablecolor {
				background-color: #cee1ef !important;
				color: #666;
			}

			.aui-active {
				color: #039be5;
			}
			.ming-text-app {
				/*color:#fed159 !important;*/
				color:#5fa5e2;
			}
		</style>
	</head>
	<body>
		<div ms-controller="activity_detail_main" ms-if="actajax">
			<div class="aui-content">
				<div class="aui-card-list" style="margin-bottom: 0.25rem;">
					<div class="ming-list-xf">
						<div class="ming-text-white aui-pull-left aui-font-size-10">
							<span class="ming-bg-app bgcfbf69c" ms-visible="detailist.ticket_count == 0">无票</span>
							<span class="ming-bg-app" ms-visible="detailist.is_open == 1 && detailist.ticket_count >0">可预约</span>
							<span class="ming-bg-b30" ms-visible="detailist.is_open == 1 && detailist.ticket_count >0 ">余票<span>{{detailist.ticket_count}}</span>张</span>
						</div>
					</div>
					<div class="aui-card-list-content">
						<img class="wp100" ms-attr-src="detailist.banner"  />
					</div>
					<div class="aui-padded-l-10 lh20">
						<p class="f15 aui-padded-t-10 fb c000 aui-padded-b-5" ms-text="detailist.title"></p>
						<p class="aui-font-size-12" style="color: #519ade;"><i class="aui-iconfont aui-icon-date aui-padded-r-5 ming-text-app" style="font-size:14px;font-weight: bold;"></i><span style="display:inline-block;margin:-2px 2px 0 2px;font-size:12px;">活动时间:</span><span style="color:#666;">{{detailist.hddate*1000|date("yyyy-MM-dd")}} {{detailist.hdtime}} <span ms-if="detailist.show_end == '1'">至 {{detailist.end_time*1000|date("yyyy-MM-dd HH:mm")}}</span></span></p>
						<div class="aui-pull-left" style="color: #519ade;">
							<i class="aui-iconfont aui-icon-location aui-padded-r-5 ming-text-app" style="font-size:14px;font-weight: bold;"></i><span style="display:inline-block;margin:-2px 2px 0 2px;font-size:12px;">活动地点:</span>
						</div>
						<div class="f12 ming-text-app aui-padded-r-10" id="address"><span style="display:inline-block;color:#666;margin-top:2px;">{{detailist.place}}</span></div>
						<p ms-click="open_call()" class="aui-font-size-12 cblue-app aui-clearfix"><i class="aui-iconfont aui-icon-mobile aui-padded-r-5 ming-text-app" style="font-size:14px;font-weight: bold;"></i><span style="display:inline-block;margin:-2px 2px 0 2px;font-size:12px;">联系电话:</span><span style="color:#666;">{{detailist.tel}}</span></p>
						<p class="aui-font-size-12 cblue-app aui-clearfix"><i class="left aui-iconfont aui-icon-clock aui-padded-r-5 ming-text-app" style="display:inline-block;font-size:17px;"></i><span class="left" style="display:inline-block;margin:0 2px 0 -1px;font-size:12px;">兑票截止时间:</span><span class="left" style="color:#666;">{{fmtDate(detailist.get_ticket_endtime,'s')}}</span></p>
						<div class="clearf"></div>
			  	</div>
				</div>
				<div class="aui-padded-t-10 bgeee"></div>
				<div class="aui-padded-l-10 aui-padded-r-10 aui-padded-b-10 aui-padded-t-10">
					<p id="content_img" class="c666">&nbsp;&nbsp;{{detailist.content |html}}</p>
				</div>
				<div class="aui-padded-t-10 bgeee"></div>
			</div>
			<div style="height: 55px"></div>
			<div class="pf bottom0 wp100 bgcfff aui-text-center">
				<ul class="lh50 aui-text-center f15">
					<li class="fl li-swid" ms-click="actzan(detailist.id,0)">
						<i ms-class="aui-active:detailist.is_zan" class="aui-iconfont aui-icon-laud aui-font-size-18"></i>
					</li>
					<li class="fl li-swid" ms-click="actzan(detailist.id,1)">
						<i ms-class="aui-active:detailist.is_fav" class="aui-iconfont aui-icon-star aui-font-size-18"></i>
					</li>
					<li class="fl li-swid" tapmode onclick="open_share()">
						<i class="aui-iconfont aui-icon-share aui-font-size-18"></i>
					</li>
					<li class="fl" style="width: 40%;position: relative;" ms-visible="detailist.is_open == 1 && detailist.ticket_count > 0" tapmode onclick="open_yuyue()">
						<span style="display: inline-block;" class="h50 wp100 cfff ming-bg-app">立即预约</span>
					</li>
					<li class="fl" style="width: 40%;position: relative;" ms-visible="detailist.ticket_count == 0 || detailist.is_open == 0">
						<span style="display: inline-block;" class="h50 wp100 cfff ming-bg-app disablecolor">预约已结束</span>
					</li>
				</ul>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/common.js"></script>
	<script type="text/javascript" src="../../script/avalon.js"></script>
	<script type="text/javascript">
		apiready = function() {
			init();
		};

		function open_call() {
			if(activity_detail_main.detailist.tel == '') {
				api.toast({
					msg: '该场馆暂未提供电话！'
				})
			} else {
				call(activity_detail_main.detailist.tel)
			}
		}

		function init() {
			activity_detail_main.atclist();
		};

		function open_yuyue() {
			if(activity_detail_main.detailist.is_open == 0) {
				return;
			}
			$api.setStorage('yuyue', {
				//				type: '场馆预定',
				id: $api.getStorage('activity_id'),
				name: activity_detail_main.detailist.title,
				address: activity_detail_main.detailist.place,
				pic: activity_detail_main.detailist.banner,
				hddate: activity_detail_main.detailist.hddate,
				hdtime: activity_detail_main.detailist.hdtime
			});
			openWin_yuyue()
		}
		avalon.ready(function() {
			window.activity_detail_main = avalon.define({
				$id: 'activity_detail_main',
				id: 0,
				token: '',
				type: 0,
				detailist: {},
				is_fav: false,
				is_zan: false,
				actajax: false,
				atclist: function() {
					activity_detail_main.token = $api.getStorage('token');
					activity_detail_main.id = $api.getStorage('activity_id');
					get_data('/api/Party/detail', 'post', {
						id: activity_detail_main.id,
						deviceId :api.deviceId,
						token: activity_detail_main.token,
					}, function(ret) {
						// console.info("---naozhong---")
						// console.info(JSON.stringify(ret));
						if(ret.status == 1) {
							// console.log(JSON.stringify(ret))
							activity_detail_main.actajax = true;
							activity_detail_main.detailist = ret.data;
							activity_detail_main.is_zan = ret.data.is_zan;
							activity_detail_main.is_fav = ret.data.is_fav;
						}
					});
				},
				//点赞,收藏
				actzan: function(id, type) {
					activity_detail_main.type = type;
					get_data('/api/interact/opera', 'post', {
						token: activity_detail_main.token,
						data_id: activity_detail_main.id,
						type: activity_detail_main.type,
						data_type: 2,
						from: 1,
					}, function(ret) {
						// console.log(ret)
						if(ret.status == 1) {
							if(activity_detail_main.type == 1) {
								api.toast({
									msg: ret.msg
								});
								activity_detail_main.is_fav = ret.data.result == 0 ? false : true;
								activity_detail_main.detailist.is_fav = ret.data.result == 0 ? false : true;
							} else {
								//点赞，奖励积分
								// console.log($api.getStorage('points'));
								if(ret.data.points){
									$api.setStorage('points', ret.data.points);
								}
								// console.log($api.getStorage('points'));
								api.toast({
									msg: ret.msg
								});
								activity_detail_main.is_zan = ret.data.result == 0 ? false : true;
								activity_detail_main.detailist.is_zan = ret.data.result == 0 ? false : true;
							}
						} else {
							api.toast({
								msg: ret.msg
							});
						}

					});
				},
			});
			avalon.scan();
		});

		function open_share() {
			$api.setStorage('behavior', 'share_link');
			$api.setStorage('share_field', 'party');
			$api.setStorage('share_id', $api.getStorage('activity_id'));
			var article = activity_detail_main.detailist;
			var url = window.config.dev_path+'/weixin/Party/detail?id=' + $api.getStorage('activity_id');
			var title = article.title;
			var img = 'widget://res/icon.png';
			share(function(ret) {
				if(ret == 1) {
					//朋友圈
					var data = {
						scene: 'timeline',
						title: '【文化随行】活动推荐-' + title,
						des: title,
						url: url,
						thumb: img
					}
					share_wechat(data);
				}
				if(ret == 0) {
					//微信会话
					var data = {
						scene: 'session',
						title: '【文化随行】活动推荐-' + title,
						des: title,
						url: url,
						thumb: img
					}
					share_wechat(data);
				}
				if(ret == 3) {
					var data = {
						title: '【文化随行】活动推荐-' + title,
						img: img,
						des: title,
						url: url,
						type: 'QFriend'
					}
					share_qq(data);
				}
				if(ret == 2) {
					var data = {
						text: '我在【文化随行】发现了一个很好的活动，推荐给大家看看！',
						title: '【文化随行】活动推荐-' + title,
						description: title,
						thumb: img,
						contentUrl: url
					}
					share_weibo(data);
				}
			})
		}
		// 转换时间的格式
		function fmtDate(date,type){
			var dateNum = parseInt(date) * 1000
			var dateStr = new Date(dateNum);
			var year = 1900+dateStr.getYear();
			var month = dateStr.getMonth() + 1;
			month = month < 10 ? ('0' + month) : month;
			var day = dateStr.getDate();
			day = day < 10 ? ('0' + day) : day;
			var hour = dateStr.getHours();
			hour = hour < 10 ? ('0' + hour) : hour;
			var minute = dateStr.getMinutes();
			var second = dateStr.getSeconds();
			minute = minute < 10 ? ('0' + minute) : minute;
			second = second < 10 ? ('0' + second) : second;
			if(type == 'h'){
				return year + '-' + month + '-' + day +' '+ hour;
			}else if(type == 'm'){
				return year + '-' + month + '-' + day +' '+ hour + ':' + minute;
			}else if(type == 's'){
				return year + '-' + month + '-' + day +' '+ hour + ':' + minute + ':' + second;
			}else{
				return year + '-' + month + '-' + day;
			}
		}
	</script>

</html>
