<!doctype html>
<!--[if IE 6]><html id="ie6" dir="ltr" lang="zh-TW"><![endif]-->
<!--[if IE 7]><html id="ie7" dir="ltr" lang="zh-TW"><![endif]-->
<!--[if IE 8]><html id="ie8" dir="ltr" lang="zh-TW"><![endif]-->
<!--[if !(IE 6) | !(IE 7) | !(IE 8)  ]><!-->
<html dir="ltr" lang="zh-TW">
<!--<![endif]-->
<head>
<!--[if lt IE 9]><script src="/js/html5.js"></script><![endif]-->
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
<title><?# webTitle ?></title>	
<meta name="author" content="<?# webTitle ?>" />
<meta name="copyright" content="<?# webName ?>版權所有" />
<meta name="description" content="<?# webDescription ?>" />
<meta name="distribution" content="Taiwan" /> 
<meta name="keywords" content="<?# webKeyword ?>" />
<meta name="format-detection" content="telephone=no" />
<meta property="og:url" content="<?# RelLink ?><?# REQUESTURI ?>" />
<meta property="og:type" content="website" />
<meta property="og:title" content="<?# ogTitle ?>" />
<meta property="og:description" content="<?# ogDescription ?>" />
<meta property="og:image" content="<?# ogImage ?>" />
<link href="/css/<?# webTemplates ?>/main.css" rel="stylesheet">
<link href="/css/<?# webTemplates ?>/layout.css" rel="stylesheet">
<link href="/css/<?# webTemplates ?>/order.css" rel="stylesheet">
<script src="/jquery/jquery-1.10.js"></script>
<script src="/jquery/jaliswall.js"></script>
<script>
	if('<?# alertMsg ?>' != ''){
		alert('<?# alertMsg ?>');
		if('<?# goBack ?>' == 'Y'){
			history.back();
		}
	}
	if('<?# locationHref ?>' != ''){
		location.href = '<?# locationHref ?>';
	}
</script>
<?# headHTML ?>
</head>
<body<?# JumpBody ?>>
<?# bodyTopHTML ?>
<div class="webBox" style="margin: 0; padding: 0; border: 0; width: 100%;<?# JumpStyle ?>">
<?# JumpHTML ?>
<?# JumpScript ?>
<h1 class="pageh1"><?# OrderName ?></h1>
<div class="wrapper">
	<?# header ?>
	<div id="banner_layout" class="relat_box">
		<div class="waylink">
			<ol class="workframe">
				<li><a title="首頁" href="/">首頁</a></li>
				<li><?# OrderName ?></li>
			</ol>
		</div>
		<?# banner ?>
	</div>
	<div id="wrap">
		<div id="content-wrap">
			<div class="workframe">
				<div class="order_box" id="order">
					<h5><?# OrderName ?></h5>
					<div>
						<div class="orderWrap">
							<div class="list title">
								<div class="img">名稱</div>
								<div class="info">
									<p>數量</p>
									<p>單價</p>
									<p>小計</p>
									<p class="remove"></p>
								</div>
							</div>
							<php:repeater id="listCP">
							<template>
							<div class="list">
								<div class="img"><a href="<?# link ?>" target="_blank" title="<?# name ?>"><font><img src="<?# image ?>" alt="<?# name ?>" /></font><b class="text-clamp"><?# name ?></b></a></div>
								<div class="info">
									<p class="qBox">
										<a class="limit" href="javascript:void(0);" data-action="plusBtn" data-type="1"></a>
										<input class="numtxt" type="text" data-id="<?# id ?>" data-sp="<?# spid ?>" data-action="chgQ" name="q" value="<?# q ?>">
										<a href="javascript:void(0);" data-action="plusBtn" data-type="2"></a>
									</p>
									<p class="pBox numtxt"><?# price ?></p>
									<p class="tBox numtxt"><?# amount ?></p>
									<p class="remove"><a href="javascript:void(0);" data-id="<?# id ?>" data-sp="<?# spid ?>" data-action="delI" title="刪除"><i class="far fa-times-circle"></i></a></p>
								</div>
							</div>
							</template>
							</php:repeater>
						</div>
						<div class="btns">
							<a class="backP" href="<?# htLink4 ?>" title="繼續選購">← 繼續選購</a>
							<a id="btnClean" href="javascript:void('0');" title="清空購物車">清空購物車</a>
						</div>
					</div>
				</div>
				<form id="form1" name="form1" method="post">
					<input type="hidden" id="PPrice" name="PPrice" value="<?# ProductPrice ?>" />
					<input type="hidden" id="TPrice" name="TPrice" value="<?# TransPrice ?>" />
					<input type="hidden" id="OPrice" name="OPrice" value="<?# OrderPrice ?>" />
					<div class="order_box">
						<h5><b>*</b>顧客資料</h5>
						<div class="input_list">
							<p class="nowrap_box"><label>姓名 *</label><font><input type="text" id="Name" name="Name" /></font></p>
							<p class="nowrap_box"><label>手機 *</label><font><input type="text" id="Mobile" name="Mobile" /></font></p>
							<p class="nowrap_box"><label>信箱 *</label><font><input type="text" id="Email" name="Email" /></font></p>
							<p class="nowrap_box"><label>地址 *</label><font><input type="text" id="Address" name="Address" /></font></p>
							<p class="nowrap_box"><label>詳細說明</label><font><textarea name="Content" id="Content" cols="45" rows="5" placeholder="詳細說明"><?# askProduct ?></textarea></font></p>
							<p class="nowrap_box checknum">
								<label>驗證碼 *</label>
								<font class="nowrap_box">
									<input name="Checknum" type="text" id="Checknum" onKeyUp="this.value=this.value.toUpperCase();" placeholder="驗證碼" maxlength="4" />
									<img src="/vdimgck.php" id="rand-img" alt="看不清楚？ 點圖更換新圖片" align="absmiddle" style="cursor:pointer;border:none; width:auto;" onClick="this.src=this.src+'?'">
								</font>
							</p>
						</div>
					</div>
				</form>
				<div id="community">
					<ul>
						<li class="fbb">
							<div class="fb-like" data-href="<?# RelLink ?><?# REQUESTURI ?>" data-width="" data-layout="button" data-action="like" data-size="small" data-share="false"></div>
							<div class="fb-share-button" data-href="<?# RelLink ?><?# REQUESTURI ?>" data-layout="button" data-size="small"><a target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?# RelLink ?><?# REQUESTURI ?>&amp;src=sdkpreparse" class="fb-xfbml-parse-ignore">分享</a></div>
						</li>
						<li><a href="https://twitter.com/share" class="twitter-share-button" data-lang="zh-tw" data-dnt="true">推文</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script></li>
						<li><div class="line-it-button" data-lang="zh_Hant" data-type="like" data-url="<?# RelLink ?><?# REQUESTURI ?>" data-share="true" style="display: none;"></div></li>
					</ul>
				</div>
				<?# GoogleSearch ?>
			</div>
			<div class="order-content-end"></div>
			<div class="order_bottom_txt">
				<div class="workframe">
					<p>
						<label>金額總計 ：</label>
						<font id="totaltxt" class="numtxt">NT&#36;<?# OrderPrice ?></font>
						<font id="bot_note">(商品合計金額 ：<span id="freetxt" class="numtxt">NT&#36;<?# ProductPrice ?></span> + 運費 ：<span id="transtxt" class="numtxt">NT&#36;<?# TransPrice ?></span>)</font>
					</p>
					<p class="send"><a id="btnOK" href="javascript:void(0);" title="送出訂單">送出訂單</a></p>
				</div>
			</div>
        </div>
	</div>
	<?# footer ?>
	<div data-action="loader"><div class="loader-circle"></div></div>
</div>
</div>
</body>
</html>
<script src="/jquery/main-jquery.js"></script>
<script>
	function sumPrice(){
		$.ajax({
			url: '/ajax/cart.php',
			async: false,
			type: 'POST',
			data: {'do':'sum'},
			dataType: 'json',
			success: function(obj){
				if(obj.err == "0"){
					$('#freetxt').text('NT$'+obj.pprice);
					$('#transtxt').text('NT$'+obj.tprice);
					$('#totaltxt').text('NT$'+obj.oprice);
					$('#ProductPrice').val(obj.pprice);
					$('#TransPrice').val(obj.tprice);
					$('#OrderPrice').val(obj.oprice);
				}else{
					alert(obj.msg);
					location.href = location.href;
				}
			},
			error: function(){
				alert('系統異常!請重新整理頁面再試一次!');
				location.href = location.href;
			}
		});
	}
	function chgQ(a){
		$.ajax({
			url: '/ajax/cart.php',
			async: false,
			type: 'POST',
			data: {'do':'chg','id':a.data('id'),'q':a.val()},
			dataType: 'json',
			context: a.parent('p').next().next().eq(0),
			success: function(obj){
				alert(obj.msg);
				if(obj.err == "0"){
					$(this).text(obj.amount);
					sumPrice();
				}else{
					location.href = location.href;
				}
			},
			error: function(){
				alert('系統異常!請重新整理頁面再試一次!');
				location.href = location.href;
			}
		});
	}
	$(function(){
		$('a[data-action="plusBtn"]').click(function(){
			var num = $(this).parent().children('input').val();
			if($(this).data('type') == '1'){
				num = parseInt(num) - 1;
			}else{
				num = parseInt(num) + 1;
			}
			if(num < 1) num = 1;
			
			$(this).parent().children('input').val(num);
			chgQ($(this).parent().children('input'));
		});
		$('input:text[data-action="chgQ"]').change(function(){
			chgQ($(this));
		});
		$('a[data-action="delI"]').click(function(){
			if(confirm('確定要刪除此項產品?')){
				$.ajax({
					url: '/ajax/cart.php',
					async: false,
					type: 'POST',
					data: {'do':'del','id':$(this).data('id')},
					dataType: 'json',
					context: $(this).parent('p').parent('div').parent('div'),
					success: function(obj){
						alert(obj.msg);
						if(obj.err == "0"){
							$(this).remove();
							sumPrice();
						}else{
							location.href = location.href;
						}
					},
					error: function(){
						alert('系統異常!請重新整理頁面再試一次!!');
						location.href = location.href;
					}
				});
			}else{
				return false;
			}
		});
		$('#btnClean').click(function(){
			if(confirm('確定要清空購物車?')){
				$.ajax({
					url: '/ajax/cart.php',
					async: false,
					type: 'POST',
					data: {'do':'cln'},
					dataType: 'json',
					success: function(obj){
						alert(obj.msg);
						location.href = "/";
					},
					error: function(){
						alert('系統異常!請重新整理頁面再試一次!');
						location.href = location.href;
					}
				});
			}else{
				return false;
			}
		});
		$('#btnOK').click(function(){
			if($('#Name').val() == ''){
				alert('請輸入姓名!');
				$('#Name').focus();
				return false;
			}
			if($('#Mobile').val() == ''){
				alert('請輸入手機!');
				$('#Mobile').focus();
				return false;
			}
			if($('#Email').val() == ''){
				alert('請輸入信箱!');
				$('#Email').focus();
				return false;
			}
			var reEmail = /^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9_\-]+(\.[a-zA-Z0-9_\-]+)+$/;
			if(!reEmail.test($('#Email').val())){
				alert('信箱不合法!');
				$('#Email').focus();
				return false;
			}
			if($('#Address').val() == ''){
				alert('請輸入地址!');
				$('#Address').focus();
				return false;
			}
			if($('#Checknum').val() == ''){
				alert('請輸入驗證碼!');
				$('#Checknum').focus();
				return false;
			}else{
				$('div[data-action="loader"]').attr('id', 'lodbg');
				$(this).attr('disabled','disabled');
				$('#form1').submit();
			}
		});
	});
	
	document.body.oncopy = event => {
		event.preventDefault();
		let textFont,
		copyFont = window.getSelection(0).toString();
		if(copyFont.length > 10){
			textFont = copyFont + '\n\n' + '原文網址: <?# webTitle ?> <?# RelLink ?><?# REQUESTURI ?>\n' + '著作權歸作者所有。商業轉載請聯絡作者獲得授權，非商業轉載請註明出處。';
		}else{
			textFont = copyFont;
		}
		if(event.clipboardData){
			return event.clipboardData.setData('text', textFont);
		}else{// 相容IE
			return window.clipboardData.setData('text', textFont);
		}
	};
	
	orderFixed();
	$(window).scroll(orderFixed);
	function orderFixed(){
		var docHeight = $(document).height();
		var headerHeight = $('header').height() + 20;
		var footerHeight = $('footer').height();
		var windowHeight = $(window).height();
		var windowScrollTop = $(window).scrollTop();
		var itemWrap = $('.order_bottom_txt');
		var endPoint = docHeight - footerHeight;
		
		if(windowScrollTop > 50){
			itemWrap.addClass('fixed').removeClass('absolute-bt');
			if(windowScrollTop + windowHeight >= endPoint){
				itemWrap.removeClass('fixed').addClass('absolute-bt');
			}
		}else{
			itemWrap.removeClass('fixed').removeClass('absolute-bt');
		}
		$('#content-wrap').css('padding-bottom', (itemWrap.height() + 30)+'px');
	}
</script>