<!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="/less/<?# webTemplates ?>/main.less" rel="stylesheet/less">
<link href="/less/<?# webTemplates ?>/layout.less" rel="stylesheet/less">
<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="/js/less.min.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="<?# JumpStyle ?>">
<?# JumpHTML ?>
<?# JumpScript ?>
<div class="wrapper">
    <?# header ?>
    <?# banner ?>
	<div class="pos_rel" id="wrap">
        <div class="workframe">
			<div id="top_title">
                <h1 class="pag_tit txt_white_5"><?# OrderName ?></h1>
                <div class="waylink">
                    <ol>
                        <li class="d_inblock"><a class="d_inblock" title="首頁" href="/">首頁</a></li>
                        <li class="d_inblock"><?# OrderName ?></li>
                    </ol>
                </div>
                <div class="m_title">
                    <p class="note"><span class="txt_primary_5">*</span>代表必填欄位</p>
                    <div class="description_box"><?# webContact ?></div>
                </div>
			</div>
			<div id="content_wrap">
				<div class="bg_secondary_4" id="order">
					<div class="bg_black_4">
						<div class="orderWrap">
							<div class="d_lg_block d_none nowrap_box list title">
								<div class="col_6 d_inblock img">名稱</div>
								<div class="col_6 d_inblock nowrap_box info">
									<p class="col_4 d_inblock talign_center">數量</p>
									<p class="col_4 d_inblock talign_center">單價</p>
									<p class="col_4 d_inblock talign_center">小計</p>
								</div>
							</div>
							<php:repeater id="listCP">
							<template>
							<div class="pos_rel nowrap_box list">
								<div class="col_lg_6 d_lg_inblock nowrap_box img">
									<a class="d_lg_flex d_block nowrap_box" href="<?# link ?>" target="_blank" title="<?# name ?>">
										<font class="pos_lg_rel pos_xs_abs d_lg_inblock d_block talign_xs_left talign_center"><img src="<?# image ?>" alt="<?# name ?>" /></font>
										<b class="d_inblock txt_clamp talign_xs_left talign_center"><?# name ?></b>
                                    </a>
								</div>
								<div class="col_lg_6 d_lg_inblock nowrap_box info">
									<p class="pos_lg_rel pos_abs col_lg_4 d_lg_inblock talign_center nowrap_box qBox">
										<a class="d_inblock bg_black_3 txt_white_4 talign_center limit" href="javascript:void(0);" data-action="plusBtn" data-type="1">-</a>
										<input class="d_inblock talign_center" type="text" data-id="<?# id ?>" data-sp="<?# spid ?>" data-action="chgQ" name="q" value="<?# q ?>">
										<a class="d_inblock bg_black_3 txt_white_4 talign_center" href="javascript:void(0);" data-action="plusBtn" data-type="2">+</a>
									</p>
									<p class="col_4 d_lg_inblock d_none talign_center pBox"><?# price ?></p>
									<p class="col_lg_4 d_lg_inblock talign_lg_center talign_xs_left talign_center tBox"><?# amount ?></p>
								</div>
								<a class="pos_abs" href="javascript:void(0);" data-id="<?# id ?>" data-sp="<?# spid ?>" data-action="delI" title="刪除"><i class="far fa-times-circle"></i></a>
							</div>
							</template>
							</php:repeater>
						</div>
						<div id="orderTotal">
							<p class="talign_right nowrap_box" id="price1"><font class="d_inblock">產品金額</font><span class="d_inblock talign_right">NT&#36;<?# ProductPrice ?></span></p>
							<p class="talign_right nowrap_box" id="price2"><font class="d_inblock">運費</font><span class="d_inblock talign_right">NT&#36;<?# TransPrice ?></span></p>
							<p class="talign_right nowrap_box" id="price3"><font class="d_inblock">總計</font><span class="d_inblock talign_right txt_primary_5">NT&#36;<?# OrderPrice ?></span></p>
						</div>
					</div>
				</div>
				<div class="talign_right nowrap_box orderbtns">
					<a class="col_md_2 col_6 d_inblock talign_center bg_primary_5 txt_white_5 backP" href="<?# htLink4 ?>" title="繼續選購">← 繼續選購</a>
					<a class="col_md_2 col_6 d_inblock talign_center bg_complement_5 txt_white_5" id="btnClean" href="javascript:void('0');" title="清空購物車">清空購物車</a>
				</div>
				<div class="form_box">
                    <form class="nowrap_box" 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><label class="d_block txt_white_5">姓名 <span class="txt_primary_5">*</span></label><input type="text" id="Name" name="Name" /></p>
                        <p><label class="d_block txt_white_5">手機 <span class="txt_primary_5">*</span></label><input type="text" id="Mobile" name="Mobile" /></p>
                        <p><label class="d_block txt_white_5">信箱 <span class="txt_primary_5">*</span></label><input type="text" id="Email" name="Email" /></p>
                        <p><label class="d_block txt_white_5">地址 <span class="txt_primary_5">*</span></label><input type="text" id="Address" name="Address" /></p>
                        <p><label class="d_block txt_white_5">詳細說明</label><textarea name="Content" id="Content" cols="45" rows="5"><?# askProduct ?></textarea></p>
                        <p class="col_md_6 d_md_inblock checknum">
                            <label class="d_block txt_white_5">驗證碼 <span class="txt_primary_5">*</span></label>
                            <font class="nowrap_box">
                                <input class="d_inblock" type="text" id="Checknum" name="Checknum" onKeyUp="this.value=this.value.toUpperCase();" maxlength="4" />
                                <img class="d_inblock" id="rand-img"src="/vdimgck.php" alt="看不清楚？ 點圖更換新圖片" align="absmiddle" style="cursor:pointer;border:none; width:auto;" onClick="this.src=this.src+'?'">
                            </font>
                        </p>
                        <p class="col_md_6 d_md_inblock talign_md_right talign_center"><a class="d_inblock talign_center bg_primary_5 txt_white_5" id="btnOK" href="javascript:void(0);" title="送出">送出</a></p>
                    </form>
                </div>
			</div>
		</div>
        <?# sidePage ?>
	</div>
    <?# footer ?>
	<div class="pos_fix wrapper_lines"><div class="workframe center_box talign_center"><div class="col_md_4 d_inblock center_box"></div></div></div>
	<div data-action="loader"><div class="loader-circle"></div></div>
</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('NT$'+obj.pprice);
					$('#price2').children('span').text('NT$'+obj.tprice);
					$('#price3').children('span').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($('#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>