$(function(){

	var user = fetchUSER();

	orderlist = function(target,status){
		if(user.hostId==''||user.hostId=='0'){
			gotoLogin();
			return;
		}
		var params={
				hostId:user.hostId,
				status:status,
				size:30
		};
		var _path=buildHTTP("/fastord/find.shtml");
		$.ajax({
			url: _path, 
			type: "post", 
			dataType: "json",
			data:$.toJSON(params),   
			contentType:"application/json",
			success: function(data) { 
				if(data.rowCount==0){
					var vhtml = template('noorderHtml', data);
					$(target).html(vhtml);
				}else{
					var vhtml = template('fastordHtml', data);
					$(target).html(vhtml);
				}
			}
		});
	}; 

	orderlist("#tab1",''); // 全部订单
	orderlist("#tab2",'UnFinished'); // 全部订单

	remind = function(ordId){ // 提醒商家
		var _path=buildHTTP("/fastord/remind.shtml?ordId="+ordId);
		$.ajax({
			url: _path, 
			type: "get", 
			dataType: "json",
			contentType:"application/json",
			success: function(data) { 
				if(data.code=='01'){
					$.toast("已成功提醒商家");
				}else{
					$.toast(data.msg);
				}
			}
		});

	};

	showFlow = function(ordId){ // 查看流程
		
	};
	
	removeOrd = function(ordId){ // 删除订单
		var _path=buildHTTP("/fastord/remove.shtml");
		var params={
				hostId:user.hostId,
				ordId:ordId
		};
		$.ajax({
			url: _path, 
			type: "post", 
			dataType: "json",
			data:$.toJSON(params),  
			contentType:"application/json",
			success: function(data) { 
				if(data.code=='01'){
					$("#"+ordId).remove();
					$.toast("成功删除");
				}else{
					$.toast(data.msg);
				}
			}
		});
	};

	$.init();
});