var that;
var app=new Vue({
	el:"#App",
	data:function(){
		return {
			pageLoad:false,
			userList:[],
			line:{},
			order:{},
			driver:{},
			group:{},
			msgContent:"",
			msgList:[]
		}
	},
	created:function(){
		that=this;
		this.getPage()
	},
	methods:{
		getPage:function(){
			$.ajax({
				url:"/module.php?m=pinche&a=houche&ajax=1",
				dataType:"json",
				success:function(res){
					that.pageLoad=true;
					that.order=res.data.order;
					that.line=res.data.line;
					that.driver=res.data.driver;
					that.group=res.data.group;
					that.userList=res.data.userList;
					that.getMsgList();
					setInterval(function(){
						that.getMsgList();
					},10000)
				}
			})
		},
		getMsgList:function(){
			$.ajax({
				url:"/module.php?m=pinche_group_msg&gid="+that.group.gid+"&ajax=1",
				dataType:"json",
				success:function(res){
					that.msgList=res.data.list;
					setTimeout(function(){
						$(window).scrollTop($("body").height());
					},100)
					
				}
			})
		},
		sendMsg:function(){
			if(!postCheck.canPost()){
				return false;
			}
			if(that.msgContent==''){
				return false;
			}
			$.ajax({
				url:"/module.php?m=pinche_group_msg&a=save&ajax=1",
				dataType:"json",
				data:{
					gid:that.group.gid,
					content:that.msgContent
				},
				type:"POST",
				success:function(res){
					if(res.error){
						skyToast(res.message);
					}else{
						that.msgContent="";
						that.getMsgList();
					}
					
				}
			})
		}
	}
})