<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8" />
	<title>我的订单</title>
	<link rel="stylesheet" href="../css/main.css" />
	<script src="../js/flexible.js"></script>
	<script src="../js/api.js"></script>
	<script src="../js/checkLanguage.js"></script>
</head>

<body>

<ul id="evaluation" class="orderList">

</ul>
<script type="text/javascript">
	try {
		var text=languages.orderAll;
	}catch (e){
		alert(languages.all.list5)
	}
</script>
<script src="../js/doT.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/publicData.js"></script>
<script src="../js/jquery-3.1.0.min.js"></script>
<script id="evaluationtmpl" type="text/x-dot-template">
    
	{{ for(var prop in it["amount"]) { }}
	<li class="bb bgff mb20" rel='{{= it["amount"][prop]["id"] }}'>
		<div class="ub  ub-pj p25 p-te fz22  ptb26 ">
			<p class="fz22 c81 p-te orderGSW">{{=it['languages']['list11']}}：{{= it["amount"][prop]["Carrier"] }}</p>
			<p class="fz22 c81 plr20">{{= it["amount"][prop]["addDate"] }}</p>
		</div>
		<div class="bgfa fz24 info-txt orderContent" id='{{= it["amount"][prop]["id"] }}'>
			<p class="blue fz24 p-te">{{=it['languages']['list3']}}：{{= it["amount"][prop]["startArea"] }}</p>
			<p class="blue fz24 p-te">{{=it['languages']['list4']}}：{{= it["amount"][prop]["endArea"] }}</p>
			<p class="fz24 c98">{{=it['languages']['list1']}}：{{= it["amount"][prop]["nameCn"] }} </p>
			<p class="fz24 c98"> {{ if(it["amount"][prop]["nameOfboard"]!=""){}} &nbsp;{{=it['languages']['list17']}}：{{= it["amount"][prop]["nameOfboard"] }}{{ } }}</p>
			<p class="fz24 c98">{{=it['languages']['list12']}}：{{ if(it["amount"][prop]["timeSpendDay"]!=0){}}{{= it["amount"][prop]["timeSpendDay"] }}{{=it['languages']['list18']}}{{ } }}{{ if(it["amount"][prop]["timeSpendHour"]!=0){}}{{= it["amount"][prop]["timeSpendHour"] }}{{=it['languages']['list19']}}{{ } }} </p>
			<p class="fz24 c98">{{=it['languages']['list13']}}：{{= it["amount"][prop]["dateOfStart"] }} &nbsp;{{=it['languages']['list14']}}：{{= it["amount"][prop]["dateOfEndGate"] }} </p>
			<p class="fz24 c28 clear">
				{{ for(var i in it["amount"][prop]['res']){ }}
				{{ if(it["amount"][prop]['res'][i]["buyCount"]!=0){ }}
				<span class="fl mr20">{{= it["amount"][prop]['res'][i]['code'] }}{{= it["amount"][prop]['res'][i]['perPrice'] }}/{{= it["amount"][prop]['res'][i]['theCode'] }} *{{= it["amount"][prop]['res'][i]["buyCount"] }} </span>
				{{ } }}
				{{ } }}
			</p>
			<p class="fz24 c28 ub">
				{{=it['languages']['list15']}}：{{= it["amount"][prop]["additionalPrice"] }} 
			</p>
			<p class="fz24 c28 ub">
				<span class="ub-f1">{{=it['languages']['list7']}}：{{= it["amount"][prop]["code"] }}{{= it["amount"][prop]["allPrice"] }}</span>
				<span class="ub-f1">{{=it['languages']['list9']}}：{{= it["amount"][prop]["payMethod"] }}</span>
			</p>
			<p class="fz24 c65 ub">
				<span class="ub-f1">{{=it['languages']['list6']}}：{{= it["amount"][prop]["sysOrderNo"] }}</span>
			</p>
		</div>
		<div class="ptb20 plr25 ub ub-pe buttonContent">
			<span class="ub-f1 pt10">{{=it['languages']['list2']}}：{{=it['languages']['list10']}}</span>
			<a href="javascript:;" class="red revise-btn  fz24 ml10" id="recover">{{=it['languages']['btn1']}}</a>
			<!--{{? it["amount"][prop].stateOfOrcer==1 }}-->
				<!--<span class="ub-f1 pt10">订单状态：未处理</span>-->
			<!--{{?? it["amount"][prop].stateOfOrcer == 4}}-->
				<!--<span class="ub-f1 pt10">订单状态：已完成</span>-->
			<!--{{?? it["amount"][prop].stateOfOrcer == 3}}-->
				<!--<span class="ub-f1 pt10">订单状态：运输中</span>-->
			<!--{{?}}-->
			<!--{{? it["amount"][prop].stateOfOrcer==1 }}-->
				<!--<a href="javascript:;" class="red revise-btn fz24" id="accept">接受</a>-->
				<!--<a href="javascript:;" class="delete-btn fz24 ml10" id="refuse">拒绝</a>-->
			<!--{{?? it["amount"][prop].stateOfOrcer == 4}}-->
				<!--<a href="javascript:;" class="red revise-btn fz24 ml10" id="sureBtn">开发票</a>-->
			<!--{{?? it["amount"][prop].stateOfOrcer == 3}}-->
				<!--<a href="javascript:;" class="red revise-btn fz24" id="lookVoucher">查看运单</a>-->
				<!--<a href="javascript:;" class="red revise-btn fz24 ml10" id="lookMaterial">运输状态</a>-->
			<!--{{?}}-->
		</div>

	</li>

	{{ } }}

</script>
<script>
	
	 $(this).attr("rel")	
	del(".btn")
	function del (obj){
		$(obj).click(function(){
			$('#deom1 img')[index].remove()
			document.getElementById('demo1').children
			
			
//			$(this).parent().html('')
			
		})
	}
	var pageIndex=1,isReload=false;
	apiready = function() {
		
		
		getdata(true);
		api.setRefreshHeaderInfo({
			loadingImg: 'widget://image/refresh.png',
			bgColor: '#efefef',
			textColor: '#818181',
			textDown: languages.all.list34+'...',
			textUp: languages.all.list35+'...'
		}, function(ret, err) {
			//在这里从服务器加载数据，加载完成后调用api.refreshHeaderLoadDone()方法恢复组件到默认状态
			getdata(true,1);
		});
		api.addEventListener({
			name:"loginInit"
		},function (ret,err) {
			api.closeFrame({
				name: 'orderAll'
			});
		})
		api.addEventListener({
			name: 'scrolltobottom',
			extra: {
				threshold: 0 //设置距离底部多少距离时触发，默认值为0，数字类型
			}
		}, function(ret, err) {
			if(isReload) return;
			getdata(false);

		});
	}
	function getdata(bl,thisPage) {
		isReload=true;
		api.ajax({
			url: pageUrl + "order/my_order",
			method: 'get',
			timeout: 30,
			dataType: 'json',
			returnAll: false,
			headers: {
				"Content-Type": "application/json"
			},
			data: {
				body: {
					stateOfOrcer:5,
					page:thisPage||pageIndex
				}
			}
		}, function(ret, err) {
			console.log(JSON.stringify(ret))
			if(thisPage) pageIndex=thisPage;
			if(ret.data.page<pageIndex){
				if(bl){
					api.refreshHeaderLoadDone();
					$("#evaluation").html(" <p style='padding-top: 5.3rem;font-size: .5rem;text-align: center;color: #818181'>"+languages.orderAll.remind1+"</p>");
				}else {
					api.toast({
						msg: languages.all.list19,
						duration: 2000,
						location: 'bottom'
					});
				}
				isReload=false;
				return;
			}
			var  dataEval  =  ret.data;
			dataEval.languages=languages.orderAll;
			var  evalText  =  doT.template($("#evaluationtmpl").text());
			$("#evaluation").html(evalText(dataEval));
			buttonclick();
			orderclick();
			api.refreshHeaderLoadDone();
			pageIndex++;
			isReload=false;
		})
	}
	// 操作按键点击
	function buttonclick() {
		var orderUl = $api.dom(".orderList"),
				buttonList = $api.domAll(orderUl, ".buttonContent a");

		for(var orderNum = 0, len = buttonList.length; orderNum < len; orderNum++) {
			! function(i) {
				buttonList[i].onclick = function() {
					var id=$(this).parent().parent().attr("rel"); //订单id

					switch($(this).attr("id")) {
						case "accept":
							popups(languages.orderAll.remind3,function (ret,dialogBox) {
								if(ret.eventType == 'right')  {
									buttons(3,id);
									dialogBox.close({
										dialogName: 'alert'
									});
								}else if (ret.eventType == 'left') {
									dialogBox.close({
										dialogName: 'alert'
									});
								}
							})
							break;
						case "refuse":
							popups(languages.orderAll.remind4,function (ret,dialogBox) {
								if(ret.eventType == 'right')  {
									buttons(5,id);
									dialogBox.close({
										dialogName: 'alert'
									});
								}else if (ret.eventType == 'left') {
									dialogBox.close({
										dialogName: 'alert'
									});
								}
							})
							break;
						case "recover":
							popups(languages.orderAll.remind5,function (ret,dialogBox) {
								if(ret.eventType == 'right')  {
									buttons(3,id);
									dialogBox.close({
										dialogName: 'alert'
									});
								}else if (ret.eventType == 'left') {
									dialogBox.close({
										dialogName: 'alert'
									});
								}
							})
							break;
						case "sureBtn":
							api.openWin({
								name: 'invoice',
								url: 'invoice.html',
								pageParam: {name: 'pageparamname',
									id: id}
							});
							break;
						case "lookVoucher":
							api.openWin({
								name: 'Voucher',
								url: 'Voucher.html',
								pageParam: {name: 'pageparamname',
									id: id}
							});
							break;
						case "lookMaterial":
							api.openWin({
								name: 'lookMaterial',
								url: 'lookMaterial.html',
								pageParam: {name: 'pageparamname',
									id:id}
							});
							break;
						default:
							break;
					}


				}
			}(orderNum)
		}
	}
	// 				操作按钮具体操作
	function buttons(statu,ids) {
		api.ajax({
			url: pageUrl + "order/accept",
			method: 'get',
			timeout: 30,
			dataType: 'json',
			returnAll: false,
			headers: {
				"Content-Type": "application/json"
			},
			data: {
				values: {
					id: ids,
					status: statu
				}
			}
		}, function(ret, err) {
			if(ret.status=="200"){
				api.execScript({
					frameName: 'orderNav',
					script: 'getTotal();'
				});
			}
			api.toast({
				msg: ret.message,
				duration: 2000,
				location: 'bottom'
			});
			getdata(true,1)
		})

	}

	function orderclick() {
		var orderUl = $api.dom(".orderList"),
				orderList = $api.domAll(orderUl, ".orderContent");

		for(var orderNum = 0, len = orderList.length; orderNum < len; orderNum++) {
			! function(i) {
				orderList[i].onclick = function() {

					api.openWin({
						name: 'orderDetails',
						url: 'orderDetails.html',
						pageParam: {
							name: 'pageparamname',
							id: $(this).parent().attr("rel")
						}
					});
				}
			}(orderNum)
		}
	}
	function popups(val,fn) {
		var dialogBox = api.require('dialogBox');
		dialogBox.alert({
			texts: {
				title: languages.all.list18,
				content: val,
				leftBtnTitle: languages.all.list2,
				rightBtnTitle: languages.all.list18
			},
			styles: {
				bg: '#fff',
				w: 300,
				title: {
					marginT: 20,
					icon: 'widget://res/gou.png',
					iconSize: 40,
					titleSize: 13,
					titleColor: '#000'
				},
				content: {
					color: '#000',
					size: 16
				},
				left: {
					marginB: 0,
					marginL: 0,
					w: 150,
					h: 60,
					corner: 2,
					bg: '#f9f9f9',
					color: '#818181',
					size: 12
				},
				right: {
					marginB: 0,
					marginL: 0,
					w: 150,
					h:60,
					corner: 2,
					bg: '#51c4d4',
					color: '#fff',
					size: 12
				}
			}
		}, function(ret) {
			fn(ret,dialogBox)
		});
	}
</script>
</body>

</html>