$(function(){

	var user = fetchUSER();
	var hostId = user.hostId;

	orderlist = function(target,status){
		if(user.hostId==''||user.hostId=='0'){
			gotoLogin();
			return;
		}
		var _path=buildHTTP("/order/user.shtml?hostId="+hostId+"&status="+status);
		$.ajax({
			url: _path, 
			type: "get", 
			dataType: "json",
			contentType:"application/json",
			success: function(data) { 
				if(data.code=='01'){
					var vhtml = template('orderTemplate', data);
					$(target).html(vhtml);
				}else{
					$.toast("查询订单失败");
				}			
			}
		});
	}; 

	orderlist('#tab1',''); // 全部订单
	orderlist('#tab2','UnPay'); // 未支付
	orderlist('#tab3','UnFinished'); // 未完成订单

	$.init();

});