<?php
	header('Content-Type:text/html; charset=utf-8;');
	require_once("init.php");
	require_once("HttpClient.class.php");
	
	libxml_use_internal_errors(true);   // Disable libxml errors and allow user to fetch error information as needed
	
	$client = new HttpClient($apihost);
	$client->max_redirects = 50;
	
	//加载商店配置
	$url	= 'http://b2b.dong24.com/api/dw/custInfo.jsp?custId=122137';
	
	if ( ! $client->get($url)) {
		redir('/'. $base_api_dir .'/', '服务器错误！');
		exit();
	}
	try{
		$shopconfig	= new SimpleXMLElement($client->getContent());
	} catch (Exception $e){
		redir('/'. $base_api_dir .'/', '文件解析失败');
		exit();
	}
	
	$url = $prefix_dir . '/detail.jsp?custId='.$cust_id.'&apikey='.$apikey;
	if( ! isset($_GET['info_id'])){
		redir("index.php", '服务器错误！');
		exit();
	}
	$url .= "&productNo=".$_GET['info_id'];
	if ( ! $client->get($url)) {
		redir("index.php", '服务器错误！');
		exit();
	}
	try{
		$proXml = new SimpleXMLElement(trim($client->getContent())); // sometimes don't forget to trim xml blank
	} catch (Exception $e){
		echo '文件解析失败';
		exit();
	}
	if( ! $proXml->status){
		redir("index.php", '服务器错误！');
		exit();
	}
	$product=$proXml->product;

	$seo = array();
	$seo['title']		= '仅'.(string)$product->salePrice.'元享原价'.(string)$product->marketPrice.'元的'.(string)$product->productName;
	$seo['keywords']	= (string)$product->productName.',产品查询,产品预订,电子产品,特价产品,打折产品,优惠产品,运动健身,动网';
	$seo['description'] = (string)$product->viewName.'位于'.(string)$product->viewAddress.$seo['title'].'。动网产品预订频道提供1千多个商家的特价产品，打折产品预订，价格最低优惠至2折，以电子票和产品快递形式为主，动网产品是您运动健身，旅游休闲，商务出行，家庭聚会的最佳选择。同时动网还提供大量的产品组合套餐和团体票供您选择！';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php echo $seo['title'] ?></title>
	<meta name="Keywords" content="<?php echo $seo['keywords'] ?>"/>
	<meta name="Description" content="<?php echo $seo['description'] ?>"/>
	<link rel="stylesheet" type="text/css" media="screen" href="./css/mp-gl.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="./css/mp-order.css" />
	<script type="text/javascript" src="/public/js/jquery.js"></script>
	<script type="text/javascript" src="/public/js/dsport.core.js"></script>
    <script type="text/javascript" src="/public/js/jquery.fancybox.js"></script>
	<link rel="shortcut icon" href="/favicon.ico" />
	<script src="./js/area.js" type="text/javascript"></script>
</head>
<body>
	<!-- 头部:S -->
		<?php echo $shopconfig->cust->siteHead ?>
	<!-- 头部:E -->
	
	<!-- 面包屑:S -->
		<div class="mp-bread">
			<p class="mp-recom">当前位置： <a href="index.php" class="c9">门票</a> > 门票详情</p>
			<div class="process01"></div>
		</div>
	<!-- 面包屑:E -->

	<div class="mp-wrap">
			<div class="mp-col-left">
				<div class="tuanWrap">
					<div class="tuan">
						<h1>
							<span class="cf00">最实惠：</span><?php echo $product->productName?>
						</h1>
						<div class="priceL">
							<div style="height:68px"></div>
							<div class="price">
								<span class="sign">￥</span>
								<span class="priceN"><?php echo $product->salePrice?></span>
							</div>
							<div class="bTuan">
								<a href="<?php echo $server_url.'/order.php?info_id='.$product->productNo ?>" target="_blank"><img src="images/bTuan.gif"/></a>
							</div>
							<div class="showPrice">
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td width="33%">原价</td>
										<td width="33%">折扣</td>
										<td>节省</td>
									</tr>
									<tr>
										<td><span>￥</span><strong class="mp-c0"><?php echo $product->marketPrice?></strong></td>
										<td><strong class="cf60"><?php echo getZK($product->marketPrice,$product->salePrice)?></strong>折</td>
										<td><span>￥</span><strong class="c007b43"><?php echo $product->marketPrice-$product->salePrice?></strong></td>
									</tr>
								</table>
							</div>
							<div class="listFunc" style="border-bottom:1px dotted #d6d6d6; margin-bottom:10px; padding-bottom:10px">
								<?php
									if($product->ticketCount + $product->attentCount > 10){
								?>
									<p><span class="f20 cf60 fht"><?php echo $product->ticketCount + $product->attentCount ?></span>人已购买</p>
								<?php
									}
									if($product->num>0){
								?>
									<p>一共还剩 <span class="c007b43"><?php echo $product->num?></span> 张，需者从速</p>
								<?php
									}
								?>
							</div>
							<div class="listFunc">
								<p>支付方式： <span class="cf60 mp-fb"><?php echo (int)$product->isOnlinepay == 1 ? '在线支付' : '景点支付' ?></span> </p>
								<p>人群要求：<?php echo $product->peoples?></p>
								<p>营业时间：<?php echo $product->businessHours?></p>
							</div>
							<table width="100%" border="0" cellspacing="0" cellpadding="0" class="kjjd">
								<tr>
									<td width="65" valign="top">可以进入：</td>
									<td width="141" valign="top" class="cf00"><?php echo $product->viewName?></td>
								</tr>
							</table>
							<h4>公告</h4>
							<p class="ggsm">
								<?php echo $product->orderPolicy ?>
							</p>
						</div>
						<div class="priceR">
							<?php $imgs = explode(',', (string)$product->img); ?>
							<img src="<?php echo $imgs[0]; ?>" width="489" height="300" alt="<?php echo $product->productName; ?>"/>
							<div class="func">
								<div class="t"></div>
								<div class="c">
									<div class="mp-sel-date-1" id="ticketPrice"></div>
								</div>
							</div>
						</div>
						<p class="clear"></p>
					</div>
				</div>
				<div class="tuanWrap">
						<div class="mp-pro-detail">
							<?php
								$img_node = $proXml->product->imgs;
								if (strpos($img_node, ','))
								{
									$imgs = explode(',', $img_node);
								}
							?>
							<?php if ( ! empty($imgs)) { ?>
							<div class="tips">
								<img src="images/mp_sm_3.jpg" />
								<p>
									<div style="width:720px; height:100%; overflow:hidden;">
										<div class="mp-img-la1">
											<a href="<?php echo $imgs[0]; ?>" rel="fancy">
												<img src="<?php echo $imgs[0]; ?>" width="289" height="208"/>
											</a>
										</div>
										<?php 
											$imgs_num = count($imgs);
											array_shift($imgs);
										?>
										<div class="mp-img-la2" style="height: 208px; overflow:hidden;">
											<?php 
												foreach ($imgs as $key => $value){
											?>
											<div class="mp-img-la3" style="height:86px; width: 114px; overflow:hidden; display:<?php echo $key > 5 ? 'none': ''; ?>">
												<a rel="fancy" href="<?php echo $value; ?>">
													<img src="<?php echo $value; ?>" width="114" height="82"/>
												</a>
											</div>
											<?php
												}
											?>
											<div style="width:380px; text-align:center; font-size:12px; clear:left">
												<a href="###" style="color:#656565" id="show-all-fancy">
													点击查看全部大图.共<?php echo $imgs_num ?>张图片
												</a>
											</div>
										</div>
									</div>
								</p>
							</div>
							<?php } ?>
							<div class="tips">
								<img src="images/mp_sm_2.jpg" />
								<p><?php echo $product->orderDesc?></p>
							</div>

							<div class="tips">
								<img src="images/mp_sm_1.jpg" />
								<div>
									<p><?php echo $product->content?></p>
								</div>
								<p>&nbsp;</p>
							</div>
							<?php 
								if($product->orderPolicy){
							?>
								<div class="tips">
									<h2>配送说明</h2>
									<p><?php $product->orderPolicy ?></p>
								</div>
							<?php
								}
							?>
						</div>
				</div>
				<?php
					$cityName=$product->cityName;
					$url = $prefix_dir . '/list.jsp?custId='.$cust_id.'&apikey='.$apikey.'&pageNo=1&pageNum=6&cityName='.urlencode($cityName);
					if ( ! $client->get($url)) {
						redir("index.php", '服务器错误！');
						exit();
					}
					try{
						$proXml = new SimpleXMLElement(trim($client->getContent())); // sometimes don't forget to trim xml blank
					} catch (Exception $e){
						echo '文件解析失败';
						exit();
					}
					if((int)$proXml->status == 1){
				?>
					<div class="boxbgy">
						<div class="t">
							<h2>相关推荐产品</h2>
							<p><a href="./list.php">更多></a></p>
						</div>
						<div class="c" style="padding-bottom:0">
							<?php foreach($proXml->products->product as $assoc){ ?>
								<div class="briefmp"> 
									<a href="<?php echo '/piao/'.$assoc->productNo.'.html' ?>" target="_blank">
										<img src="<?php echo $assoc->img ?>" width="67" height="67" class="left">
									</a>
									<h5>
										<a class="mp-fb" href="<?php echo '/piao/'.$assoc->productNo.'.html' ?>" target="_blank" title="<?php echo $assoc->productName ?>"><?php echo $assoc->productName ?></a>
									</h5>
									<p>优惠价：<span class="cf60 mp-fb">￥<?php echo $assoc->salePrice ?></span></p>
									<p>门市价：<span class="c6 f_scx">￥<?php echo $assoc->marketPrice ?></span></p>
								</div>
							<?php } ?>
							<p class="clear"></p>
						</div>
					</div>
				<?php
					}
				?>
			</div>
			<div class="mp-col-right">
				<div class="mp-sep-block bBm">
					<div class="t">
						<h2>无忧购票保障服务</h2>
					</div>
					<div class="c">
						<div class="mp-safe-tip">
							<div class="mp-tip-box">
								<h3 class="f1">安全可靠</h3>
								<p>每个产品都经过动网运营人员的验证,确保您能顺利尽兴游玩。</p>
							</div>
						</div>
						<div class="mp-safe-tip">
							<div class="mp-tip-box">
								<h3 class="f2">无条件退款</h3>
								<p>电子票和窗口现票提前一天无条件退款；快递票在快递出去之前，无条件退款。</p>
							</div>
						</div>
						<div class="mp-safe-tip">
							<div class="mp-tip-box">
								<h3 class="f3">先行赔付</h3>
								<p>如果游客无法进园，动网全额赔付；如果游客没有按照预订价格进入，而是按照窗口价购票，动网赔偿差价。</p>
							</div>
						</div>
					</div>
				</div>
				<div class="mp-sep-block bBm">
					<div class="t">
						<h2>他们正在订...</h2>
					</div>
					<div class="c" style="padding:10px;height: 205px; overflow: hidden;">
						<ul id="order_list_scroll" class="mp-order-his" style="">
						<?php
							$startDate = date('Y-m-d', strtotime('-2 days'));
							$endDate = date('Y-m-d');
							$url	= $prefix_dir . '/history.jsp?custId='.$cust_id.'&apikey='.$apikey.'&limit=15';
							//$url	= $prefix_dir . '/orderList.jsp?custId='.$cust_id.'&apikey='.$apikey.'&startDate='.$startDate.'&endDate='.$endDate;

							$client = new HttpClient($apihost);
							if ($client->get($url)){
								try{
									$proXml = new SimpleXMLElement(trim($client->getContent())); // sometimes don't forget to trim xml blank
									if($proXml->status == 1){
										foreach($proXml->orders->order as $order){
											echo '
												<li>
													<div class="mp-order-his-name">
														<a href="/piao/'.$order->productNo.'.html">'.$order->productName.'</a>
													</div>
													<div class="cf60" style="width:27px; ">
														<b>'.$order->num.'</b>
													</div>
													<div style="width:60px; color: #999">
														'.substr($order->orderDate, 2, 8).'
													</div>
												</li>
												';
										}
									}
								} catch (Exception $e){
									echo '文件解析失败';
								}
							} else {
								echo '服务器错误！';
							}
						?>
						</ul>
					</div>
				</div>
			</div>
			<div class="clear"></div>
		</div>
		
	<!-- 底部:S -->
		<?php echo $shopconfig->cust->siteFoot ?>
	<!-- 底部:E -->
	
	<script type="text/javascript">
		setInterval(function(){
			$('#order_list_scroll li:last').css({'height':'0px','opacity': '0'}).insertBefore('#order_list_scroll li:first').animate({'height':'16px','opacity': '1'}, 'slow', function() {
				$(this).removeAttr('style');
			});
		},2000);
		function checkLogin() {
			$.ajax({ url: '/sync/login/checkIn',data: '',dataType: 'html',
				success: function(data) {
					$("#loginbar").append(data).find('.cklinit').remove();
					$("a[rel=login]").unbind('click').fancybox({
						'width': '40',
						'height': '30',
						'padding': '0',
						'type': 'iframe',
						'autoDimensions': false,
						'scrolling': 'no'
					});
				}
			});
		}
		function locate() {
			$.ajax({url: '/sync/city/locate',data: '',dataType: 'html',success: function(data) {
					if (data !== '') {
						$("#citylocate").html(data);
					}
				}
			});
		}
		$(function(){
			$('a[rel=fancy]').fancybox({
				'transitionIn'	: 'none',
				'transitionOut'	: 'none',
				'titlePosition'	: 'outside',
				'overlayColor'	: '#000',
				'cyclic'		: 'true',
				'titleFormat'	: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">' + (currentIndex + 1) + ' / ' + (currentArray.length - 1) + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
			$("#show-all-fancy").click(function (){
				$('a[rel=fancy]').trigger('click');
			});
		});

		$(function (){
			$(".city-bottom").bind({'mouseover':function(){  
				$('.cityLine').show();
			}, 'mouseout':function(){
				$('.cityLine').hide();
			}});
		});
	</script>
	<script language="javascript" type="text/javascript">
		checkLogin();
	</script>
	<script type="text/javascript">
		$(function(){
			var today = new Date();
			var year= today.getFullYear()
			var month=today.getMonth()
			getTicketPrice(year,(month+1));
		});

		var cacheTicket=new Object();
		function getTicketPrice(year,month)
		{
			if(cacheTicket[year+month]){
				$("#ticketPrice").html(cacheTicket[year+month]);
			}else{
				$.ajax({type: "get",url: "ajax/ticket_calendar_ajax.php",data: "year="+year+"&month="+month+"&info_id=<?php echo $product->productNo ?>&rnd="+Math.random(),
					beforeSend:function(){
							$("#ticketPrice").html("<img src='./images/loading.gif' width='27' height='26' align='absmiddle'/>门票正在加载... ...");
					},
					success: function(msg){
						$("#ticketPrice").html(msg);
						cacheTicket[year+month]=msg;
					}
				});
			}
		}

		function openPage(obj,info_id,travelDate,custId)
		{
			$(".checkin").attr("class","");
			$(obj).attr("class","checkin");
			var url="<?php echo $server_url ?>/order.php?info_id="+info_id+"&travel_date="+travelDate;
			window.open(url);
		}
	</script>
	<script type="text/javascript">
		var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
		document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F81abdadfb5d3537c41730c6e6e304eff' type='text/javascript'%3E%3C/script%3E"));
	</script>

</body>
</html>




