<!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>
	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 ?>
<div class="wrapper">
    <?# header ?>
	<div id="BannerBox">
		<?# banner ?>
		<div class="bar">
			<div class="waylink">
				<h1><?# OrderName ?></h1>
				<ol>
					<li><a title="首頁" href="/">首頁</a></li>
					<li><?# OrderName ?></li>
				</ol>
			</div>
		</div>
	</div>
	<div class="wrap">
		<div class="workframe">
			<div id="order">
				<div class="orderWrap">
					<div class="list title">
						<div class="img">名稱</div>
						<div class="info">
							<p>數量</p>
							<p>單價</p>
							<p>小計</p>
							<p></p>
						</div>
					</div>
					<php:repeater id="listCP">
					<template>
					<div class="list">
						<div class="img"><a href="<?# link ?>" target="_blank" title="<?# name ?>"><font style="background-image: url(<?# image ?>);"></font><b class="text-clamp"><?# name ?></b></a></div>
						<div class="info">
							<p class="qBox"><input type="text" data-id="<?# id ?>" data-action="chgQ" name="q" value="<?# q ?>"></p>
							<p class="pBox"><?# price ?></p>
							<p class="tBox"><?# amount ?></p>
							<p class="remove"><a href="javascript:void(0);" data-id="<?# id ?>" data-action="delI" title="刪除"><i class="far fa-trash-alt"></i></a></p>
						</div>
					</div>
					</template>
					</php:repeater>
				</div>
				<div class="btns">
					<a id="btnClean" href="javascript:void('0');" title="清空購物車">清空購物車</a>
					<a class="backP" href="<?# htLink4 ?>" title="繼續購物">繼續購物</a>
				</div>
				<div id="orderTotal">
					<p id="price1"><font>產品金額</font><span><?# ProductPrice ?></span></p>
					<p id="price2"><font>運費</font><span><?# TransPrice ?></span></p>
					<p id="price3"><font>總計</font><span><?# OrderPrice ?></span></p>
				</div>
			</div>
			<article><?# webOrder ?></article>
			<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 ?>" />
				<p class="col col-2"><label>姓名<b>*</b></label><input type="text" id="Name" name="Name"></p>
				<p class="col col-2"><label>手機<b>*</b></label><input type="text" id="Mobile" name="Mobile"></p>
				<p class="col col-2"><label>信箱<b>*</b></label><input type="text" id="Email" name="Email"></p>
				<p class="col col-2"><label>地址<b>*</b></label><input type="text" id="Address" name="Address"></p>
				<p class="col"><textarea name="Content" id="Content" cols="45" rows="5" placeholder="詳細說明"></textarea></[div]>
				<p class="col col-2">
					<label>驗證碼<b>*</b></label>
					<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+'?'">
				</p>
				<p class="col col-2 send"><a id="btnOK" href="javascript:void(0);">送出</a></p>
			</form>
			<div id="community">
				<ul>
					<li class="fbb"><div class="fb-like" data-href="<?# RelLink ?><?# REQUESTURI ?>" data-layout="button_count" data-action="like" data-size="small" data-show-faces="true" data-share="true"></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>
				<?# GoogleSearch ?>
			</div>
		</div>
	</div>
	<?# footer ?>
</div>
</div>
</body>
</html>
<script>
	function sumPrice(){
		$.ajax({
			url: '/ajax/cart.php',
			async: false,
			type: 'POST',
			data: {'do':'sum'},
			dataType: 'json',
			success: function(obj){
				if(obj.err == "0"){
					$('#price1').children('span').text(obj.pprice);
					$('#price2').children('span').text(obj.tprice);
					$('#price3').children('span').text(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(){
		$('input:text[data-action="chgQ"]').change(function(){
			$.ajax({
				url: '/ajax/cart.php',
				async: false,
				type: 'POST',
				data: {'do':'chg','id':$(this).data('id'),'q':$(this).val()},
				dataType: 'json',
				context: $(this).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;
				}
			});
		});
		$('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($('#Checknum').val() == ''){
				alert('請輸入驗證碼!');
				$('#Checknum').focus();
				return false;
			}
			if($('#Address').val() == ''){
				alert('請輸入地址!');
				$('#Address').focus();
				return false;
			}
			$(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);
		}
	};
</script>