var game_websocket = function (_id){
	this.id = _id;
	this.onopen = function(evt){
		GameData.isTcpConnect = false;
		GameData.tryConnect = false;
		GameData.netWorkSate = true;
		GameData.isConnected = true;
		if(!GameData.ConnectType){
			if(GameData.NetType==0){
	
				if(GameData.firstConnect){
					GameData.firstConnect = false;
					GameData.firstConnect_Succ = true;
					window.clearTimeout(GameData.firstConnect_Timer);
					if(GameData.TcpTimer){
						window.clearTimeout(GameData.TcpTimer);
					}
					if(GameData.LoadCount==100 && GameData.Timesup  && GameData.getJSONState){
						GameUI.JumpWxAuth();

					}
				}
	
			}else{
				window.clearTimeout(GameData.TimerID);
				if(!GameData.disType){
					GameUI.CloseDisConnect();
	
				}else{
					GameUI.EndLoad();
				}
				GameData.disType = false;
				GameData.NetType=0;
				if(GameData.isLogin){
					var data={};
					data.agentid = GameData.AgentId;
					data.openid = C_Player.openid;
					data.gameid = GameData.GameId;
					data.nickname = C_Player.nickname;
					data.avatar = C_Player.avatar;
					data.sex = C_Player.sex;
					data.province = C_Player.province;
					data.unionid=C_Player.unionid;
					data.city = C_Player.city;
					data.version = GameData.versionCode;
					data.channelid = GameData.ChannelId;
					data.marketid = GameData.marketID;
					if(GameData.sysConfig.deviceLogin){						
						data.telphone = C_Player.telphone;
						data.telphoneAuto = true;
					}
					Net.Send_login(data);
				}else{
					var WxInfo = Utl.getCookie(Utl.Config.wxinfo);
					if(WxInfo!=null){
						WxInfo = JSON.parse(WxInfo);
						//if(GameData.loginTimer){
							//window.clearTimeout(GameData.loginTimer);
						//}
						C_Player.SetWxInfo(WxInfo.openid,WxInfo.headimgurl,WxInfo.nickname,WxInfo.sex,WxInfo.city,WxInfo.Province,WxInfo.unionid);
						var data={};
						data.agentid = GameData.AgentId;
						data.openid = C_Player.openid;
						data.nickname = C_Player.nickname;
						data.avatar = C_Player.avatar;
						data.sex = C_Player.sex;
						data.province = C_Player.province;
						data.city = C_Player.city;
						data.unionid = C_Player.unionid;
						data.version = GameData.versionCode;
						data.gameid=GameData.GameId;
						data.channelid = GameData.ChannelId;
						data.marketid = GameData.marketID;
						if(GameData.sysConfig.deviceLogin){						
							data.telphone = C_Player.telphone;
							data.telphoneAuto = true;
						}
						Net.Send_login(data);
					}
				}
			}
		}else{
			GameData.ConnectType=false;
			if(!GameData.disType){
	
	
				switch(GameData.ConnectRpc){
					case RpcList.connect_roomserver:
						Net.Send_connect_roomserver(GameData.ConnectPack);
						break;
					case RpcList.connect_agentserver:
						Net.Send_connect_agentserver(GameData.ConnectPack);
						break;
	
				}
			}else{
				GameData.disType = true;
				var data={};
				data.agentid = GameData.AgentId;
				data.openid = C_Player.openid;
				data.gameid = GameData.GameId;
				data.nickname = C_Player.nickname;
				data.avatar = C_Player.avatar;
				data.sex = C_Player.sex;
				data.province = C_Player.province;
				data.unionid=C_Player.unionid;
				data.version = GameData.versionCode;
				data.city = C_Player.city;
				data.channelid = GameData.ChannelId;
				data.marketid = GameData.marketID;
				if(GameData.sysConfig.deviceLogin){						
					data.telphone = C_Player.telphone;
					data.telphoneAuto = true;
				}
				Net.Send_login(data);
			}
		}
	}.bind(this);
	this.onmessage = function(_msg,_id){
		try{
			
			if(GameData.TcpID!=this.id){return;}
			GameData.isChangeServer = false;
			GameData.tryReconnectTimes = 0;
			//console.log("onmessage");
			//console.log(_msg);
			if(!GameData.netWorkSate){return;}

			if(GameData.heartBeatStage){
				GameUI.CloseTips();
				GameData.heartBeatStage = false;
			}
			if (typeof(_msg) == "string") {
				GameData.pack = _msg;
				_msg = JSON.parse(_msg); //转换json
			}
			var data = _msg.data;  //msg是底层的数据包，msg.data才是真正的服务器发来的数据
			if(data == "webserve-服务器未工作"){
				if(get_self(225,37,0,0,0) == 0){
					GameData.sendLoginTimer = setTimeout(function(){
						var data={};
						data.agentid = GameData.AgentId;
						data.openid = C_Player.openid;
						data.nickname = C_Player.nickname;
						data.avatar = C_Player.avatar;
						data.sex = C_Player.sex;
						data.province = C_Player.province;
						data.city = C_Player.city;
						data.unionid = C_Player.unionid;
						data.gameid=GameData.GameId;
						data.version = GameData.versionCode;
						data.channelid = GameData.ChannelId;
						data.marketid = GameData.marketID;
						if(GameData.sysConfig.deviceLogin){						
							data.telphone = C_Player.telphone;
							data.telphoneAuto = true;
						}
						Net.Send_login(data);
					},10000);
				}
				return;
			}else{
				if(GameData.sendLoginTimer){
					window.clearTimeout(GameData.sendLoginTimer);
					GameData.sendLoginTimer = null;
				}
				if(!GameData.isSendLoginState){
					if(GameData.isSendLoginTimer){
						window.clearTimeout(GameData.isSendLoginTimer);
						GameData.isSendLoginTimer = null;
					}
				}
			}
		    if (typeof(data) == 'string')
		    {
		        if (data.substr(0, 9) == "@toconcon")
		        {//连接服务器成功后得到的第一个包不需要做处理
		            return;
		        }
		        data = JSON.parse(data);
		    }
			if(GameData.heartBeatTimer){
					window.clearTimeout(GameData.heartBeatTimer);
				}
			if(!ConstVal.isGameHall){
				GameData.heartBeatTimer = setTimeout(function(){
					GameUI.OpenTips("网络较慢！",ConstVal.Tips.time);
					GameData.heartBeatStage = true;
					if(!Game_Config.Debugger.isDebugger){
						if(Net.ws_tcp.readyState == WebSocket.CLOSED){
	
							GameData.disType = true;
							GameData.ConnectType=false;
							GameData.NetType=1;
							Logic.TryConnect();
						}else if(Net.ws_tcp.readyState == WebSocket.OPEN){
	
							GameData.ConnectType = false;
							GameData.disType = true;
							GameData.NetType=1;
							GameUI.StartLoad();
							GameData.isClose = true;
							//GameData.isCloseTimer = setTimeout(function(){
								//if(GameData.isClose){
									//Logic.DisConnect();
								//}
							//},5000);
							Net.ws_tcp.close();
							GameData.isCloseTimer = setInterval(function(){
								if(GameData.isClose){
									Net.ws_tcp.close();
								}
							},5000);
						}
					}
				},ConstVal.Max.heartbeat);
			}
		    if (data.com == "@serverheartbeat")
		    {//服务器发来的心跳包（20秒一次）不需要做处理


		        return;
		    }
			_msg=_msg.data;

			
			if (typeof(_msg) == "string") {
				_msg = JSON.parse(_msg); //转换json
			}
			if(Game_Config.Debugger.isDebugger){
				console.log("接收数据：\n"+_msg);
				console.log(_msg);
			}
			if(_msg.rpc == "submit_error"){
				return;
			}
			if(GameData.isSendLoginState){
				if(_msg.rpc == RpcList.player_login){
					GameData.isSendLoginState = false;
					if(GameData.isSendLoginTimer){
						window.clearTimeout(GameData.isSendLoginTimer);
						GameData.isSendLoginTimer = null;
					}
					if(GameData.isClose){
						GameData.isClose = false;
						window.clearTimeout(GameData.isCloseTimer);
						GameData.isCloseTimer = null;
					}
				}else{
					
					if(_msg.rpc != RpcList.kick_server){
							return;
					}
				
				}
			}
			if(_msg.route==RouteList.platform||_msg.route==RouteList.agent||_msg.route==RouteList.room){
				if(min_ExitsFunction(Net[_msg.rpc])){
					Net[_msg.rpc](_msg);
				}
			}else{
				Game_Modify._ReceiveData(_msg);
			}
		}catch(e){
			if(Game_Config.Debugger.isSubmitError){
				if (typeof(_msg) == "string") {
					_msg = JSON.parse(_msg); //转换json
				}
				Net.submit_error(JSON.stringify(_msg),e.stack);

			}else{
				console.log("error:"+e.stack);
			}

		}
	}.bind(this);
	this.onclose = function(evt){
		GameData.netWorkSate = false;
		GameData.isConnected = false;
		if(GameData.urlFail){
			return;
		}
		if(GameData.isClose){
			GameData.isClose = false;
			window.clearTimeout(GameData.isCloseTimer);
			GameData.isCloseTimer = null;
		}
		//if(GameData.isCloseTimer){
			//window.clearTimeout(GameData.isCloseTimer);
			//GameData.isCloseTimer = null;
		//}
		if(!GameData.ConnectType){
			if(!GameData.appstate){
				return;
			}
			if(!GameData.firstConnect){
				GameData.NetType=1;

				Logic.TryConnect();
				
				if(!GameData.disType){
					GameUI.OpenDisConnect();
				}else{
					GameUI.StartLoad();
				}
			}else{
				GameData.tryTimes++;
				var ttimes = 3;
				if(isArray(GameData.Server)){
					ttimes = GameData.Server.length;
				}
				if(GameData.tryTimes%ttimes==0){
					GameUI.OpenTips("网络状况不好...",-1,2);
				}
				Logic.Connect(GameData.Server);
			}

		}else{
			if(!GameData.disType){
				Logic.Connect(GameData.Server);
			}else{

				GameUI.StartLoad();
			}
		}
	}.bind(this)
}

var Logic=Logic||{};

Logic.AppStart=function(){
	// ============================================================================
	// 字体优化配置
	// ============================================================================
	// 问题：gameabc.min.js 中使用 'lighter' 和 'Arial' 导致中文显示过细
	// 解决：覆盖全局字体渲染函数，统一使用更粗的中文友好字体
	
	// 保存原始的 Canvas fillText 方法
	var originalFillText = CanvasRenderingContext2D.prototype.fillText;
	var originalStrokeText = CanvasRenderingContext2D.prototype.strokeText;
	
	// 覆盖 fillText 方法，在绘制前统一字体设置
	CanvasRenderingContext2D.prototype.fillText = function() {
		// 如果当前字体包含 'lighter' 或只有 'Arial'，替换为更适合中文的字体
		if (this.font && (this.font.includes('lighter') || this.font.includes('Arial'))) {
			// 提取字体大小
			var sizeMatch = this.font.match(/(\d+)px/);
			if (sizeMatch) {
				var size = sizeMatch[1];
				// 使用 500 字重（中等粗细）+ 中文友好字体
				this.font = '500 ' + size + 'px "Microsoft YaHei", "PingFang SC", Arial, sans-serif';
			}
		}
		return originalFillText.apply(this, arguments);
	};
	
	// 同样覆盖 strokeText 方法
	CanvasRenderingContext2D.prototype.strokeText = function() {
		if (this.font && (this.font.includes('lighter') || this.font.includes('Arial'))) {
			var sizeMatch = this.font.match(/(\d+)px/);
			if (sizeMatch) {
				var size = sizeMatch[1];
				this.font = '500 ' + size + 'px "Microsoft YaHei", "PingFang SC", Arial, sans-serif';
			}
		}
		return originalStrokeText.apply(this, arguments);
	};
	
	// console.log('[字体优化] Canvas 文字渲染已优化，中英文粗细统一');
	// ============================================================================
	
	if(ConstVal.isGameHall){
		
		//ConstVal.Notice.img_clip_x=220;
		//ConstVal.Notice.img_clip_y=168;
		//ConstVal.Notice.img_clip_w=845;
		//ConstVal.Notice.img_clip_h=488; 
	
	
		//Game_Config.Notice.width = 10;
		Game_Config.sysConfig.hideNotice = true;
		ConstVal.netType = 1;
		Game_Config.sysConfig.mainMenuButton = true;//是否进入主菜单界面隐藏四个按钮
		shareRoom= true;//接收到星星场是否屏蔽平台框架显示
		gameHallImport.appStart();
	}else{
		if(typeof Game_Modify.appStart != "undefined"){
			Game_Modify.appStart();
		}
		
	}
	for(var i=0;i<60;i++){
		set_self(268,1,262+i,0,0,0);
	}
	for(var i=0;i<ConstVal.worldRoom.imgList.length;i++){
		set_self(268,1,ConstVal.worldRoom.imgList[i],0,0,0);
	}
	set_self(268,1,338,0,0,0);
	set_self(268,1,339,0,0,0);
	set_self(268,1,340,0,0,0);
	var AudioContext = window.AudioContext || window.webkitAudioContext || window.mozAudioContext;
	if(AudioContext){
		_context = new AudioContext();
	}
	if(isxiaowxgame()){
		initwxgame();
		Recorderload();
	}
	//if(count == 20){
		//Func.up_imgurl(21,"http://img3.imgtn.bdimg.com/it/u=3646406790,1894696303&fm=27&gp=0.jpg");
	//}
	
	
	
	// Logic.setServerType();
	//if(Game_Config.Debugger.serverType == 0){
		//GameData.AjaxUrl="http://ylyxservice1.0791ts.cn:1089/index.html";//正式
	//}else if(Game_Config.Debugger.serverType == 1){
		//GameData.AjaxUrl="http://ylyxservice2.0791ts.cn:1089/index.html";//测试
	//}else {
		//GameData.AjaxUrl="http://127.0.0.1:1089/index.html";//测试
	
	//}
	//Logic.setServerUrl();
	
	//if(Game_Config.Debugger.serverType != 0){
		//GameData.AjaxUrl="http://127.0.0.1:1089/index.html";
	//}
	GameData.h5Version = Logic.isH5Version();
	//GameData.configData = Func.getQueryString("configdata");
	GameData.OS = fBrowserRedirect();
	if(GameData.h5Version == 1){
		_gameSoundsObj.loadAudios();
		
	}
	GameUI.invisible();
	
		
	//setTimeout(function(){
		
		
		
		if(typeof app_version == "undefined"){
			GameData.userAgent = ConstVal.userAgent.uAgent_1;
		}else{
			if(Number(app_version) == 0){
				GameData.userAgent = ConstVal.userAgent.uAgent_1;	
			}else{
				GameData.userAgent = ConstVal.userAgent.uAgent_3;	
			}
				
		}
		if(GameData.userAgent == ConstVal.userAgent.uAgent_3){
			Func.registerFunction();
		}
		Logic.setChannelId();
		//if(GameData.userAgent != ConstVal.userAgent.uAgent_3){
			//GameData.getmarketname = "AppStart";
			GameData.marketID = Func.getmarketname();
			Logic.setGameServer();
			Logic.setAgentId();
			//GameData.getVersionState = "AppStart";
			GameData.versionState = Func.getVersionState(); 
			// if(GameData.userAgent != ConstVal.userAgent.uAgent_3){
			// 	GameData.LaunchMode = Number(Func.getQueryString(ConstVal.Launch_mode.name));
			// }else{
			// 	GameData.LaunchMode = Number(app_Launchtype);
			// 	//GameData.LaunchMode = 1;
			// }
			// 由于现在没有单游戏打包的模式，所以直接默认从大厅启动。
			if(ConstVal.isGameHall){
				GameData.LaunchMode = ConstVal.Launch_mode.from_self;
			}else{
				GameData.LaunchMode = ConstVal.Launch_mode.from_hall;
			}
			
			GameData.Validator  = new IDValidator();
			// Desk.Create();
			C_Player = new Player(-1);
			
			
			arrBan = banwords.split("、");
			if(ConstVal.netType == 0){
				GameData.TcpTimer = setInterval(function(){
					GameUI.OpenTips("网络状况不好...",-1,2);
			
					try{
						Net.ws_tcp.close();
					}catch(e){
						//Logic.DisConnect();
						
					}
			
				},3*GameData.timer);
			}
			Utl.SetStorage();
			var WxInfo = null;
			if(GameData.versionState==0){
				WxInfo = Utl.getCookie(Utl.Config.wxinfo);
			}
			if(WxInfo!=null){
				WxInfo = JSON.parse(WxInfo);
				if(WxInfo.isvisitor == 1&&GameData.versionState==0){
					Utl.delCookie(Utl.Config.wxinfo);
				}
			}
			if(GameData.versionState == 1){//审核版本			
				GameData.AjaxUrl = "http://115.159.146.131:1089/index.html";	
			}
			// var data={};
			// data.app=AppList.app;
			// data.route=RouteList.platform;
			// data.rpc=RpcList.agentserver_game;
			// data.data={};
			// data.data.agentid=GameData.AgentId;
			// data.data.gameid = GameData.GameId;
			// data.data.channelid = GameData.ChannelId;
			// data.data.marketid = GameData.marketID;
			// Func.AjaxHttp(data,ServerUrl_Succ,ServerUrl_Fail);
			get_config(Game_Config.Debugger.gameserver);
		
			set_windows(2,"var","1977");
			set_group(1,37,1,0,0);
			set_self(3103,37,0,0,0);
			set_self(3104,37,0,0,0);
			GameUI.showBackBtn();
			//set_self(1,57,Game_Config.Max.showtime,0,0);
		//}
	//},1000);
}

function ServerUrl_Succ(_msg,state,input_msg){
	//
	
	if(Game_Config.Debugger.isDebugger){
		console.log(_msg);
	}
	_msg=JSON.parse(_msg);
	//console.log("服务器地址："+_msg.data.urlserver);
	GameData.HallServer=_msg.data.urlserver;
	// if(GameData.OS == ConstVal.OS.other ){
		
		// GameData.Server=_msg.data.visitorserver;	
	// }else{
		//GameData.Server=_msg.data.urlserver;
	// }
	if(ConstVal.netType == 0){
		GameData.Server=_msg.data.urlserver;
		//GameData.Server="120.25.60.74:3088";
	}else{
		if(_msg.data.urlserver_http){
			GameData.Server = "http://"+_msg.data.urlserver_http+"/index.html";
		}
		GameData.firstConnect_Succ = true;
	}
	GameData.visitorserver = _msg.data.visitorserver;
	if(GameData.versionState == 1){//审核版本 
		GameData.AjaxUrl = "http://115.159.146.131:1089/index.html";		
		
	}else{
		if(GameData.TcpTimer){
			window.clearTimeout(GameData.TcpTimer);
		}
		if(_msg.data.urlserver_http){
			GameData.AjaxUrl = "http://"+_msg.data.urlserver_http+"/index.html";
		}else{
			
		}
		
	}
	 if(Game_Config.Debugger.serverType != 0){
		 GameData.visitorserver = "127.0.0.1:3088";
		 GameData.Server = "127.0.0.1:3088";
	 }
	GameData.AgentId=_msg.data.agentid;
	
	
	GameData.getJSONState = true;
	//if(_msg.data.config){
		//GameData.Config = _msg.data.config; 	
	//}
	if(_msg.data.logimage){
		GameData.AgentLoginImg = _msg.data.logimage;
	}else{
		GameData.AgentLoginImg = "";
	}
	if(_msg.data[ConstVal.loginButton.key]){
		GameData.loginBtnType = _msg.data[ConstVal.loginButton.key];
	}
	
	Logic.GameInit();
	if(GameData.firstConnect_Succ  && GameData.getJSONState && GameData.LoadCount==100){
		GameUI.JumpWxAuth();
	}
	
}
function ServerUrl_Fail(_msg,state,input_msg){
	GameData.urlFail = true;
	if(GameData.TcpTimer){
		window.clearTimeout(GameData.TcpTimer);
	}
	GameUI.OpenTips("读取配置文件失败！",-1,2);
	setInterval(function(){GameUI.OpenTips("读取配置文件失败！",-1,2);},GameData.timer);
}
function getJSON_Succ(_msg,state,input_msg){
	GameData.getJSONState = true;
	_msg=JSON.parse(_msg);
	if(/*GameData.firstConnect_Succ  && */GameData.getJSONState && GameData.LoadCount==100){
		GameUI.JumpWxAuth();
	}
}
function getJSON_Fail(_msg,state,input_msg){
	GameUI.OpenTips("读取配置文件失败！",-1,2);
}
//游戏初始化 
Logic.GameInit = function(){
	GameData.isLogin=false;
	GameData.NetType=0;
	//setTimeout(function(){
		//Logic.firstConnect(GameData.Server);
	//},5000);
	if(GameData.versionState==0){
		Logic.firstConnect(GameData.Server);
	}else if(GameData.versionState==1){
		GameData.Server = GameData.visitorserver;
		Logic.firstConnect(GameData.Server);
	}else{
		GameUI.OpenKick("登录异常，请重启游戏");
	}
	
	Game_Config.Notice.x1 = get_self(219,18,0,0);
	Game_Config.Notice.x2 = get_self(219,18,0,0)+get_self(219,20,0,0);	
	Game_Config.Notice.h = get_self(219,21,0,0);
	Game_Config.Notice.y = get_self(219,19,0,0);
	ConstVal.Task.bg_w = get_self(ConstVal.Task.bg_spid,20,0,0,0);
	ConstVal.Task.clip_h = get_self(ConstVal.Task.bg_spid,21,0,0,0);
	ConstVal.Task.clip_w = 4*ConstVal.Task.bg_w;
	ConstVal.Emotion.clip_x = get_self(ConstVal.Emotion.f_spid,18,0,0); 
	ConstVal.Emotion.clip_y = get_self(ConstVal.Emotion.f_spid,19,0,0);
	ConstVal.Emotion.clip_w = get_self(ConstVal.Emotion.f_spid,20,0,0);
	ConstVal.Emotion.clip_h = get_self(ConstVal.Emotion.f_spid,21,0,0);
	
	ConstVal.Com_History.clip_x = get_self(ConstVal.Com_History.f_spid,18,0,0);
	ConstVal.Com_History.clip_y = get_self(ConstVal.Com_History.f_spid,19,0,0);
	ConstVal.Com_History.clip_w = get_self(ConstVal.Com_History.f_spid,20,0,0);
	ConstVal.Com_History.clip_h = get_self(ConstVal.Com_History.f_spid,21,0,0);
	ConstVal.Broadcast.clip_x = get_self(389,18,0,0,0);
	ConstVal.Broadcast.clip_y = get_self(389,19,0,0,0);
	ConstVal.Broadcast.clip_w = get_self(389,20,0,0,0);
	ConstVal.Broadcast.clip_h = get_self(389,21,0,0,0);
	
	ConstVal.sysNotice.clip_x = get_self(ConstVal.sysNotice.f_spid,18,0,0);
	ConstVal.sysNotice.clip_y = get_self(ConstVal.sysNotice.f_spid,19,0,0);
	ConstVal.sysNotice.clip_w = get_self(ConstVal.sysNotice.f_spid,20,0,0);
	ConstVal.sysNotice.clip_h = get_self(ConstVal.sysNotice.f_spid,21,0,0);
	
	ConstVal.Notice.clip_x = get_self(81,18,0,0,0);
	ConstVal.Notice.clip_y = get_self(81,19,0,0,0);
	
	ConstVal.worldRoom.clip_x_1 = get_self(ConstVal.worldRoom.f_sp_1,18,0,0,0);
	ConstVal.worldRoom.clip_x_2 = get_self(ConstVal.worldRoom.f_sp_2,18,0,0,0);
	ConstVal.worldRoom.clip_y_1 = get_self(ConstVal.worldRoom.f_sp_1,19,0,0,0);
	ConstVal.worldRoom.clip_y_2 = get_self(ConstVal.worldRoom.f_sp_2,19,0,0,0);
	//ConstVal.worldRoom.clip_h_1 = get_self(ConstVal.worldRoom.bg_sp_1,21,0,0,0);
	ConstVal.worldRoom.clip_w_2 = get_self(ConstVal.worldRoom.bg_sp_2,20,0,0,0);
	
	
	ConstVal.snrRoomList.clip_x = get_self(ConstVal.snrRoomList.bksp,18,0,0);
	ConstVal.snrRoomList.clip_y = get_self(ConstVal.snrRoomList.bksp,19,0,0);
	ConstVal.snrRoomList.clip_w = get_self(ConstVal.snrRoomList.bksp,20,0,0);
	ConstVal.snrRoomList.clip_h = get_self(ConstVal.snrRoomList.bksp,21,0,0)-5;	
	
	ConstVal.rankList.clip_x = get_self(607,18,0,0);
	ConstVal.rankList.clip_y = get_self(607,19,0,0);
	ConstVal.rankList.clip_w = get_self(607,20,0,0);
	
	ConstVal.Notice.img_clip_x = get_self(3102,18,0,0,0);
	ConstVal.Notice.img_clip_y = get_self(3102,19,0,0,0);
	ConstVal.Notice.img_clip_w = get_self(3102,20,0,0,0);
	ConstVal.Notice.img_clip_h = get_self(3102,21,0,0,0);
	
	ConstVal.vipRoomList1.clip_x = get_self(ConstVal.vipRoomList1.f_spid,18,0,0,0);
	ConstVal.vipRoomList1.clip_y = get_self(ConstVal.vipRoomList1.f_spid,19,0,0,0);
	ConstVal.vipRoomList1.clip_w = get_self(ConstVal.vipRoomList1.bg_spid,20,0,0,0);
	
	ConstVal.vipRoomList2.clip_x = get_self(ConstVal.vipRoomList2.f_spid,18,0,0,0);
	ConstVal.vipRoomList2.clip_y = get_self(ConstVal.vipRoomList2.f_spid,19,0,0,0);
	ConstVal.vipRoomList2.clip_w = ConstVal.vipRoomList2.spaceX*2;
	
	
	
	ConstVal.blackList.clip_x = get_self(ConstVal.blackList.f_spid,18,0,0,0);
	ConstVal.blackList.clip_y = get_self(ConstVal.blackList.f_spid,19,0,0,0);
	ConstVal.blackList.clip_w = get_self(ConstVal.blackList.f_spid,20,0,0,0);
	ConstVal.blackList.clip_h = get_self(ConstVal.blackList.f_spid,21,0,0,0);
	
	ConstVal.vipRank.clip_x = get_self(ConstVal.vipRank.f_spid,18,0,0,0);
	ConstVal.vipRank.clip_y = get_self(ConstVal.vipRank.f_spid,19,0,0,0);
	ConstVal.vipRank.clip_w = get_self(ConstVal.vipRank.f_spid,20,0,0,0);
	ConstVal.vipRank.clip_h = get_self(ConstVal.vipRank.f_spid,21,0,0,0);
	
	ConstVal.whiteList.clip_x = get_self(ConstVal.whiteList.f_spid,18,0,0,0);
	ConstVal.whiteList.clip_y = get_self(ConstVal.whiteList.f_spid,19,0,0,0);
	ConstVal.whiteList.clip_w = get_self(ConstVal.whiteList.f_spid,20,0,0,0);
	ConstVal.whiteList.clip_h = get_self(ConstVal.whiteList.f_spid,21,0,0,0);

	var obj = ifast_getobj(340);
	GameData.gzhcolor1 = obj.uidata.FontColor;
	var obj = ifast_getobj(680);
	GameData.gzhcolor2 = obj.uidata.FontColor;
	var obj = ifast_getobj(GameData.telSpid);
	GameData.telcolor = obj.uidata.FontColor;
	obj=null;
	Func.SetDate();
	Func.setTextArea(551,true,Game_Config.Feedback.maxLen);
	Func.setInput(204,Game_Config.Chat.LimitLength);
	//setInterval("Func.SetDate()",1000);
	set_self(3,57,1000,0,0);
	
	if(!Utl.checkKey(Utl.Config.bgm)){
		Utl.SaveData(Utl.Config.bgm,1);
	}
	if(!Utl.checkKey(Utl.Config.shake)){
		Utl.SaveData(Utl.Config.shake,1);
	}
	
	if(!Utl.checkKey(Utl.Config.sound)){
		Utl.SaveData(Utl.Config.sound,1);
		Func.switchshakeVoice(1);

	}
	if(Utl.checkKey(Utl.Config.multiple)){
		GameData.Multiple = Utl.ReadData(Utl.Config.multiple);
	}else{
		Utl.SaveData(Utl.Config.multiple,"1");
	}
	if(!Utl.checkKey(Utl.Config.voice)){
		Utl.SaveData(Utl.Config.voice,1);
		Func.voicePlaying(1);
	}else{
		var voice = Utl.ReadData(Utl.Config.voice);
		Func.voicePlaying(voice);
	}
	if(!Utl.checkKey(Utl.Config.playerid)){
		Utl.SaveData(Utl.Config.playerid,"");
	}
	if(!Utl.checkKey(Utl.Config.gradeinfo)){
		Utl.SaveData(Utl.Config.gradeinfo,JSON.stringify([]));
	}
	if(Utl.checkKey(Utl.Config.shortcode)){
		GameData.shortCode = Utl.ReadData(Utl.Config.shortcode);
	}else{
		Utl.SaveData(Utl.Config.shortcode,"");
	}
	
	if(!Utl.checkKey(Utl.Config.book)){
		Utl.SaveData(Utl.Config.book,0);
	}
	if(!Utl.checkKey(Utl.Config.book)){
		Utl.SaveData(Utl.Config.book,0);
	}
	if(!Utl.checkKey(Utl.Config.vipCharm)){
		Utl.SaveData(Utl.Config.vipCharm,0);
	}
	if(Utl.checkKey(Utl.Config.tea)){
		GameUI.Mem.snrOption.tea = Logic.readTea();
	}else{
		GameUI.Mem.snrOption.tea=0;
		Logic.saveTea(0);
	}
	if(Utl.checkKey(Utl.Config.vipRoom)){
		var lll = Logic.readVipRoom();
		GameData.vipRoomShortList = lll.data;
	}else{
		GameData.vipRoomShortList = [];
		Utl.SaveData(Utl.Config.vipRoom,JSON.stringify({data:[]}));
	}
	for(var i=0;i<UnClickBtn.length;i++){
		set_self(UnClickBtn[i],41,0,0,0);
	}
	//GameUI.onstate.length=Game_Config.Max.PlayerCnt;
	GameUI.onstate.length=10;
	for(var i=0;i<GameUI.onstate.length;i++){
		GameUI.onstate[i]=0;
	}
	// GameUI.isprepare.length=Game_Config.Max.PlayerCnt;
	// for(var i=0;i<GameUI.isprepare.length;i++){
	// 	GameUI.isprepare[i]=0;
	// }
	if(Utl.checkKey(Utl.Config.roomlist)){
		GameData.roomList = Logic.readRoomList();
	}else{
		Logic.saveRoomList([]);
	}
	if(Utl.checkKey(Utl.Config.ownerNote)){
		Logic.setOwnerNote(Utl.ReadData(Utl.Config.ownerNote));
	}else{
		GameData.ownerNote = "";
	}
	if(!Utl.checkKey(Utl.Config.rebateLimit)){
		Utl.SaveData(Utl.Config.rebateLimit,0);
	}
	Logic.getMachineId();
	CombatBackHeight = get_self(48,19,0,0,0); 
	Game_Config.Combat.up_y = Game_Config.Combat.bannerheight+Game_Config.Combat.bannery+CombatBackHeight;
	if(GameData.h5Version == 1){
		GameData.gameData = Logic.setGameData("","");
		GameData.shareAppMessage = Logic.getShareDataObj(Game_Config.Share.title,Game_Config.Share.description);
		GameData.shareTimeline = Logic.getShareDataObj1(Game_Config.Share.title+Game_Config.Share.description,"");
		shareLink(GameData.shareTimeline,GameData.shareAppMessage);
		//Logic.getGameDataFromH5();
	}
	Logic.getGameDataFromH5();
	if(GameData.hallConfig.payCSS){
		dynamicLoading.css(GameData.hallConfig.payCSS);	
	}
	if(GameData.hallConfig.payJS){
		dynamicLoading.js(GameData.hallConfig.payJS);
	}
	if(ConstVal.isGameHall){
		gameHallImport.gameStart();
	}
}

Logic.firstConnect = function(server){
if(Game_Config.Debugger.serverType == 400){return;}
	if(!server){
		setInterval(function(){GameUI.OpenTips("服务器异常！",-1,2);},5000);
		return;
	}
	if(ConstVal.netType == 0){
		if(isArray(server)){
			GameData.sendLoginTimes = -1;
			GameData.serverIndex = 0;
			server = server[GameData.serverIndex];
		}else{
			
		}
		if(GameData.firstConnect_Succ)return;
		if(!GameData.appstate){
			return;
		}
		if(Net.ws_tcp){
			if(Net.ws_tcp.readyState != WebSocket.CLOSED){
				return;
			}
		}
	
		Net.ws_tcp=null;
		//GameData.tcpState[1]++;
	
		var config={};
		GameData.TcpID++;
		var g_websocket = new game_websocket(GameData.TcpID);
		config.ipport = server;
		config.onopen = g_websocket.onopen;

		config.onmessage = g_websocket.onmessage;
		config.onclose = g_websocket.onclose;
		GameData.tcpState[0]++;
		console.log("Connect:"+config.ipport+"---"+GameData.serverIndex+"---"+GameData.tryReconnectTimes);
		Net.ws_tcp = min_tcp(config);
		GameData.netWorkSate = false;
	}else{
		
	}
}
Logic.Connect=function(server){
if(Game_Config.Debugger.serverType == 400){return;}
	if(!server){
		setInterval(function(){GameUI.OpenTips("服务器异常！",-1,2);},5000);
		return;	
	}	
	if(ConstVal.netType == 0){
		if(isArray(server)){
			GameData.sendLoginTimes = -1;
			GameData.serverIndex = (GameData.serverIndex + 1)%server.length;
			
			server = server[GameData.serverIndex];
		}else{

		}
		GameData.firstConnect_Timer = window.setTimeout(function(){///链接服务器		
			if(GameData.firstConnect_Succ)return;
			if(!GameData.appstate){
				return;
			}
			if(Net.ws_tcp){
				if(Net.ws_tcp.readyState != WebSocket.CLOSED){
					return;
				}
			}
			//Net.ws_tcp.close();	
			Net.ws_tcp=null;
			GameData.tcpState[1]++;	
			var config={};
			GameData.TcpID++;
			var g_websocket = new game_websocket(GameData.TcpID);
			config.ipport = server;
			config.onopen = g_websocket.onopen;
		
			config.onmessage = g_websocket.onmessage;
			config.onclose = g_websocket.onclose;
	
			GameData.tcpState[0]++;
			console.log("Connect:"+config.ipport+"---"+GameData.serverIndex+"---"+GameData.tryReconnectTimes);
			Net.ws_tcp = min_tcp(config);
			GameData.netWorkSate = false;
		},GameData.timer);
	}else{
		
	}
}
Logic.TryConnect=function(){	
	if(ConstVal.netType == 1){return;}
	if(Game_Config.Debugger.serverType == 400){return;}
	GameData.isTcpConnect = true;
	if(!GameData.tryConnect){
		if(GameData.NetType==0)return;
		if(!GameData.appstate){
			return;
		}
		if(Net.ws_tcp){
			if(Net.ws_tcp.readyState != WebSocket.CLOSED){
				return;
			}
		}
		GameData.isReconnect = true;
		Net.ws_tcp=null;
		GameData.tcpState[1]++;
		var config={};
			
		GameData.TcpID++;
		var g_websocket = new game_websocket(GameData.TcpID);
		var server = GameData.Server;
		if(isArray(GameData.Server)){
			GameData.sendLoginTimes = -1;
			server = GameData.Server[GameData.serverIndex];
		}
		config.ipport = server;
		//config.ipport = GameData.Server;
		config.onopen = g_websocket.onopen;
	
		config.onmessage = g_websocket.onmessage;
		config.onclose = g_websocket.onclose;
		GameData.tcpState[0]++;
		console.log("Connect:"+config.ipport+"---"+GameData.serverIndex+"---"+GameData.tryReconnectTimes);
		Net.ws_tcp = min_tcp(config);
		//GameData.tryReconnectTimes++;
		
		if(isArray(GameData.Server)){
			if(!GameData.isChangeServer){
				GameData.tryReconnectTimes++;
				if(GameData.tryReconnectTimes %3 == 0){
					GameData.tryReconnectTimes = 0;
					//GameData.isChangeServer = true;
					GameData.serverIndex = (GameData.serverIndex + 1)%GameData.Server.length;
				}
			}else{
				GameData.serverIndex = (GameData.serverIndex + 1)%GameData.Server.length;
			}
			
			
			
		}else{

		}
		GameData.tryConnect = true;
	}
	GameData.TimerID = window.setTimeout(function(){///链接服务器
	if(GameData.NetType==0)return;
	if(!GameData.appstate){
		return;
	}
	if(Net.ws_tcp){
		if(Net.ws_tcp.readyState != WebSocket.CLOSED){
			return;
		}
	}
	GameData.isReconnect = true;
	Net.ws_tcp=null;
	GameData.tcpState[1]++;
	var config={};
	GameData.TcpID++;
	var g_websocket = new game_websocket(GameData.TcpID);
	var server = GameData.Server;
	if(isArray(GameData.Server)){
		GameData.sendLoginTimes = -1;
		server = GameData.Server[GameData.serverIndex];
	}
	config.ipport = server;
	//config.ipport = GameData.Server;
	config.onopen = g_websocket.onopen;

	config.onmessage = g_websocket.onmessage;
	config.onclose = g_websocket.onclose;
	GameData.tcpState[0]++;
	console.log("Connect:"+config.ipport+"---"+GameData.serverIndex+"---"+GameData.tryReconnectTimes);
	Net.ws_tcp = min_tcp(config);
	if(isArray(GameData.Server)){
			if(!GameData.isChangeServer){
				GameData.tryReconnectTimes++;
				if(GameData.tryReconnectTimes %3 == 0){
					GameData.tryReconnectTimes = 0;
					//GameData.isChangeServer = true;
					GameData.serverIndex = (GameData.serverIndex + 1)%GameData.Server.length;
				}
			}else{
				GameData.serverIndex = (GameData.serverIndex + 1)%GameData.Server.length;
			}



		}else{

		}
	GameData.netWorkSate = false;
	

	},GameData.timer);
}

Logic.InputRoomCode=function(spid){
	if(spid>=29&&spid<=38){//房间号码输入 
		if(RoomCode.length<=5){
			
		
			RoomCode+=String(spid-29);
			RoomNum = Number(RoomCode);
		}
		if(RoomCode.length==6){
			var data={};
			data.agentid = GameData.AgentId;
			data.playerid = C_Player.playerid;
			data.gameid = GameData.GameId;
			data.roomcode = RoomNum;
			Net.Send_self_join_room(data);
		}
	}
	if(spid==39){//重输 
		RoomNum=-1;
		RoomCode="";
	}
	if(spid==40){//删除 
		RoomCode = RoomCode.substring(0,RoomCode.length-1);
		RoomNum = Number(RoomCode);
	}
	for(var i=0;i<6;i++){
		set_self(236+i,37,0,0,0);
	}
	for(var i=0;i<RoomCode.length;i++){
		set_self(236+i,7,Number(RoomCode[i]),0,0);
		set_self(236+i,37,1,0,0);
	}
}
Logic.pasteRoomCode = function(){
	
	GameData.gamepastetext = "Logic.pasteRoomCode";
	var c_text = Func.gamepastetext();
	if(GameData.userAgent != ConstVal.userAgent.uAgent_3){
		var reg = /[^0-9]/g;
		c_text = c_text.replace(reg,"");
		var _text=String(c_text);
		if(String(c_text).length>6){
			_text=String(c_text).substr(0,6);
		}
		RoomCode = String(_text);
		RoomNum = Number(_text);
		for(var i=0;i<6;i++){
			set_self(236+i,37,0,0,0);
		}
		for(var i=0;i<RoomCode.length;i++){
			set_self(236+i,7,Number(RoomCode[i]),0,0);
			set_self(236+i,37,1,0,0);
		}
		if(RoomCode.length==6){
			var data={};
			data.agentid = GameData.AgentId;
			data.playerid = C_Player.playerid;
			data.gameid = GameData.GameId;
			data.roomcode = RoomNum;
			Net.Send_self_join_room(data);
			
		}
	}
	
}
Logic.JoinRoom=function(_data){//加入房间 
	logmessage(JSON.stringify(_data));
}

//打开背景音乐 
Logic.TurnOnBgm=function(){
	Utl.SaveData(Utl.Config.bgm,1);
	Utl.playMusic();
	
}
//关闭背景音乐
Logic.TurnOffBgm=function(){
	Utl.SaveData(Utl.Config.bgm,0);
	Utl.stopMusic();
}
//打开音效
Logic.TurnOnSound=function(){
	Utl.SaveData(Utl.Config.sound,1);
	Func.switchshakeVoice(1);
	//Utl.TurnOnSound(get_self(4,37,0,0,0));
	//if(get_self(149,37,0,0,0)==1){//游戏界面中

	//}else{

	//}
}
//关闭音效
Logic.TurnOffSound=function(){
	Utl.SaveData(Utl.Config.sound,0);
	Func.switchshakeVoice(0);
	//if(get_self(149,37,0,0,0)==1){//游戏界面中

	//}else{

	//}
	//Utl.TurnOffSound(get_self(4,37,0,0,0));
}
//打开摇一摇 
Logic.TurnOnShake = function(){
	Utl.SaveData(Utl.Config.shake,1);
	Func.startshake();
	Func.switchshakeVoice(Utl.ReadData(Utl.Config.sound));

}
//关闭摇一摇 
Logic.TurnOffShake = function(){
	Utl.SaveData(Utl.Config.shake,0);
	Func.stopshake();

}

//打开语音
Logic.TurnOnVoice = function(){
	Utl.SaveData(Utl.Config.voice,1);
	Func.voicePlaying(1);

}
//关闭语音
Logic.TurnOffVoice = function(){
	Utl.SaveData(Utl.Config.voice,0);
	Func.voicePlaying(0);

}

//Logic.SetCombatInfo=function(_data){
	//CombatInfo = _data.gradeinfo;
//}
Logic.ChangeToStatus=function(myseat,seat){//将座位转化为对应位置
	return (seat-myseat+Game_Config.Max.PlayerCnt)%Game_Config.Max.PlayerCnt;
}
Logic.ChangeToSeat=function(myseat,idx){//将位置转化为座位 
	return (idx+myseat)%Game_Config.Max.PlayerCnt;
}
Logic.JudgeShow=function(){
	/*
	if(GameData.isBoard){
		GameData.isBoard=false;
		return true;
	}
	return false;
	*/
	if(!ConstVal.isGameHall){//子游戏 
		if(!GameData.sysConfig.gameNoticeShow){
			return true;
		}else if(GameData.sysConfig.gameNoticeShow == -1){
			return false;
		}else{
			var exp_hour = Number(GameData.sysConfig.gameNoticeShow);
			var preTime = Number(Utl.ReadData(Utl.Config.gameNoteTime));
			var exp = new Date();
			var now = exp.getTime();
			if(preTime){
				if(preTime + exp_hour*60*60*1000 < now){//时间超过 
					Utl.SaveData(Utl.Config.gameNoteTime,now);
					return true;
				}else{
					return false;
				}	
			}else{ 
				Utl.SaveData(Utl.Config.gameNoteTime,now);
				return true;
			}
		}
	}else{
		if(!GameData.sysConfig.hallNoticeShow){
			return true;
		}else if(GameData.sysConfig.hallNoticeShow == -1){
			return false;
		}else{
			var exp_hour = Number(GameData.sysConfig.hallNoticeShow);
			var preTime = Number(Utl.ReadData(Utl.Config.hallNoticeShow));
			var exp = new Date();
			var now = exp.getTime();
			if(preTime){
				if(preTime + exp_hour*60*60*1000 < now){//时间超过
					Utl.SaveData(Utl.Config.hallNoticeShow,now);
					return true;
				}else{
					return false;
				}
			}else{
				Utl.SaveData(Utl.Config.hallNoticeShow,now);
				return true;
			}
		}	
	}
}
//设置渠道ID 
Logic.setChannelId = function(){
	if(GameData.h5Version == 1){
		var chid = fGetQuery("channelid");
		if(chid){
			GameData.ChannelId = chid;
		}
	}else{
		//GameData.getchannelName = "Logic.setChannelId";
		var chid = Func.getchannelName();
		//if(GameData.userAgent != ConstVal.userAgent.uAgent_3){
			if(chid){
				GameData.ChannelId = chid;
			}
		//}
	}
}
//设置代理ID {type:,data:};
Logic.setAgentId = function(){
	if(GameData.h5Version == 1){
		var aid = fGetQuery("agentid");
		if(aid){
			GameData.AgentId = aid;
		}
	}else{
		var aid = Func.getothername("agent");
		//if(GameData.userAgent != ConstVal.userAgent.uAgent_3){
			if(aid){
				GameData.AgentId = aid;
			}
		//}
	}
}


//设置服务器类型 
Logic.setServerType = function(){
	var stype = Func.getothername("servertype");
	if(stype){
		Game_Config.Debugger.serverType = Number(stype);
	}
}
Logic.setServerUrl = function(){
	var wurl = Func.getothername("gameserver");
	if(wurl){
		var url = min_replaceAll(min_replaceAll(wurl,"-","/",false),"#",":",false);
		GameData.AjaxUrl = url;
		//logmessage("url1:"+GameData.AjaxUrl,1);
	}else{
		GameData.AjaxUrl = Game_Config.Debugger.gameserver;
		//logmessage("url2:"+GameData.AjaxUrl,1);
	}
	
}
Logic.setGameServer = function(){
	var wurl = Func.getothername("gameconfig");
	//if(GameData.userAgent != ConstVal.userAgent.uAgent_3){
		if(wurl){
			var url = min_replaceAll(min_replaceAll(wurl,"-","/",false),"#",":",false);
			//GameData.AjaxUrl = url;
			Game_Config.Debugger.gameserver = "http://"+url+".txt";
			//logmessage("url1:"+Game_Config.Debugger.gameserver,1);
		}else{
			//logmessage("url2:"+Game_Config.Debugger.gameserver,1);
			//GameData.AjaxUrl = Game_Config.Debugger.gameserver;
		//	Game_Config.Debugger.gameserver = "http://testgame.youlehdyx.com/update_json/ceshi_json.txt"
		}
	//}
}
Logic.autoJoinRoom = function(roomcode,match_id){
	var data={};
	data.agentid = GameData.AgentId;
	data.playerid = C_Player.playerid;
	data.gameid = GameData.GameId;
	data.roomcode = roomcode;
	data.match_id = match_id;
	Net.Send_self_join_room(data);
}
Logic.addRoomToList = function(_roomcode){
	_roomcode = Number(_roomcode);
	var rlist = Logic.readRoomList();
	if(rlist.indexOf(_roomcode)<0){
		rlist.unshift(_roomcode);
		Logic.saveRoomList(rlist);
	}
	GameData.roomList = rlist;
	//GameUI.updateNoticeBoard();
	return rlist;
}
Logic.removeRoomFromList = function(_roomcode){
	_roomcode = Number(_roomcode);
	var rlist = Logic.readRoomList();
	Utl.removeItemFromArray(rlist,_roomcode);
	Logic.saveRoomList(rlist);
	GameData.roomList = rlist;
	//GameUI.updateNoticeBoard();
	return rlist;
}
Logic.readRoomList = function(){
	var r_data = Utl.ReadData(Utl.Config.roomlist);
	if(!r_data){Logic.saveRoomList([]);return [];}
	r_data = JSON.parse(r_data);
	GameData.roomList = r_data.data;
	return r_data.data;
}
Logic.saveRoomList = function(_data){
	GameData.roomList = _data;
	Utl.SaveData(Utl.Config.roomlist,JSON.stringify({data:_data}));
}
Logic.savePlayerId = function(_data){
	Utl.SaveData(Utl.Config.playerid,_data);
}
Logic.readPlayerId = function(){
	return Utl.ReadData(Utl.Config.playerid);
}
//读取配置文件的内容
function get_config(url){
	var cfg = {};
	cfg.url = url + "?" + min_timestamp();
	cfg.type = "POST";
	cfg.data = "";

	cfg.success = getConfig_Succ;
	cfg.error = getConfig_Fail;
	min_http(cfg);
}

//获取参数配置
//function get_paravalue(o_config, paraname, agentid, gameid, channelid, marketid){
function get_paravalue(o_config, paraname){
	var agentid = GameData.AgentId;
	var gameid = GameData.GameId;
	var channelid = GameData.ChannelId;
	var marketid = GameData.marketID;
	var paravalue = null;
	//遍历数组，匹配key，获取参数值
	var do_get_para = function(arylist, keyname, keyvalue){
		if (arylist && keyname && keyvalue){
			for (var i = 0; i < arylist.length; i++){
				if (arylist[i][keyname] == keyvalue){
					if (arylist[i][paraname]){
						paravalue = arylist[i][paraname];
					}
					return arylist[i];
				}
			}		
		}
		return null;
	}

	if (!o_config.data){
		return paravalue;
	}
	if (o_config.data[paraname]){
		paravalue = o_config.data[paraname];
	}
	var _o_agent = do_get_para(o_config.data.agentlist, "agentid", agentid);
	if (!_o_agent){
		return paravalue;
	}
	var _o_game = do_get_para(_o_agent.gamelist, "gameid", gameid);
	if (!_o_game){
		return paravalue;
	}
	var _o_channel = do_get_para(_o_game.channellist, "channelid", channelid);
	if (!_o_channel){
		return paravalue;
	}
	var _o_market = do_get_para(_o_channel.marketlist, "marketid", marketid);						
	if (!_o_market){
		return paravalue;
	}

	return paravalue;		
}

function getConfig_Succ(_msg,state,input_msg){
	//
	_msg=JSON.parse(_msg);
	if(Game_Config.Debugger.isDebugger){
		console.log("获取配置文件信息：");
		console.log(_msg);
	}
	

	GameData.serverConfig.data = _msg;
	//console.log("服务器地址："+_msg.data.urlserver);
	//GameData.HallServer=_msg.data.urlserver;
	var player_server_tcp = get_paravalue(GameData.serverConfig, "player_server_tcp");
	var player_server_http = get_paravalue(GameData.serverConfig, "player_server_http");
	var visitor_server_tcp = get_paravalue(GameData.serverConfig, "visitor_server_tcp");
	var visitor_server_http = get_paravalue(GameData.serverConfig, "visitor_server_http");
	var game_server_tcp = get_paravalue(GameData.serverConfig, "game_server_tcp");
	var game_server_http = get_paravalue(GameData.serverConfig, "game_server_http");
	var logimage = get_paravalue(GameData.serverConfig, "logimage");
	var loginimage = get_paravalue(GameData.serverConfig, ConstVal.loginButton.key);
	Logic.setMenuNotice();
	
	
	
	if(ConstVal.netType == 0){
		//GameData.Server=player_server_tcp;
		if(game_server_tcp){
			GameData.Server=game_server_tcp;
		}else{
			GameData.Server = player_server_tcp;
		}
		//GameData.Server = ["127.0.0.1:1088",player_server_tcp,player_server_tcp,"127.0.0.3:1088"];
	}else{
		if(game_server_http){
			GameData.Server = "http://"+game_server_http+"/index.html";
		}else{
			GameData.Server = "http://"+player_server_http+"/index.html";
		}
		GameData.firstConnect_Succ = true;
	}
	if(ConstVal.netType == 0){
		GameData.visitorserver = visitor_server_tcp;
	}else{
		GameData.visitorserver = "http://"+visitor_server_http+"/index.html";
	}
		
	if(GameData.versionState == 1){//审核版本
		GameData.AjaxUrl = "http://"+visitor_server_http+"/index.html";

	}else{
		if(GameData.TcpTimer){
			window.clearTimeout(GameData.TcpTimer);
		}
		if(game_server_http){
			GameData.AjaxUrl = "http://"+game_server_http+"/index.html";
		}else{
			GameData.AjaxUrl = "http://"+player_server_http+"/index.html";
		}

	}
	 if(Game_Config.Debugger.serverType != 0){
	 	if(ConstVal.netType == 0){
		 	GameData.visitorserver = "127.0.0.1:3088";
		 	GameData.Server = "127.0.0.1:3088";
		 }else{
		 	GameData.Server = "http://127.0.0.1:3089/index.html";
		 }
		 
	 }
	GameData.getJSONState = true;

	if(logimage){
		GameData.AgentLoginImg = logimage;
	}else{
		GameData.AgentLoginImg = "";
	}
	if(loginimage){
		GameData.loginBtnType = loginimage;
	}
	Logic.setConfigInfo();
	GameData.configSuccess = true;
	set_self(1,57,GameData.hallConfig.launchWaitTime,0,0);
	GameData.launchWaitTime = GameData.hallConfig.launchWaitTime;
	
	GameUI.startAdCountDown();
	Logic.GameInit();
	if(GameData.firstConnect_Succ  && GameData.getJSONState && GameData.LoadCount==100){
		GameUI.JumpWxAuth();
	}
	
}
function getConfig_Fail(_msg,state,input_msg){
	GameData.urlFail = true;
	if(GameData.TcpTimer){
		window.clearTimeout(GameData.TcpTimer);
	}
	GameUI.OpenTips("读取配置文件失败！",-1,2);
	GameData.getConfigTimer = setInterval(function(){GameUI.OpenTips("读取配置文件失败！",-1,2);},GameData.timer);
}

Logic.setMenuNotice = function(){
	var menunotice = get_paravalue(GameData.serverConfig, "menunotice");
	

	
	if(menunotice){
		GameData.menuNotice = menunotice;
		if(menunotice.advert1){
			GameData.advertInfo_1.type = menunotice.advert1.type;
			if(!menunotice.advert1.type){
				var advert1_msg = menunotice.advert1.msg;
				if(advert1_msg){				
					GameData.Notice.lineSum = Math.ceil(Func.getKeywordCount(advert1_msg,ConstVal.Notice.replaceOldWord)/2);;
					GameData.noticePara[1][0] = GameData.Notice.lineSum*ConstVal.Notice.lineHeight+ConstVal.Notice.textHeight;
					var strArray = advert1_msg.split(ConstVal.Notice.replaceOldWord);
					var max_length=0;
					for(var k=0;k<strArray.length;k++){
						var lenTemp=strArray[k].gblen();
						if(lenTemp>max_length){
							max_length = lenTemp;
						}
					}
					GameData.noticePara[1][1]  = max_length*ConstVal.Notice.textWidth;
					GameData.advertInfo_1.msg = min_replaceAll(advert1_msg,ConstVal.Notice.replaceOldWord,ConstVal.Notice.replaceNewWord,false);
				}
				var advert1_url = menunotice.advert1.url;
				if(advert1_url){
					GameData.advertInfo_1.url = advert1_url;
				}
			}else{
				GameData.advertInfo_1.imgUrl = menunotice.advert1.imgUrl;
				GameData.advertInfo_1.imgAdUrl = menunotice.advert1.imgAdUrl;
				GameData.advertInfo_1.height = menunotice.advert1.height;
			}
		}
		if(menunotice.advert2){
			GameData.advertInfo_2.type = menunotice.advert2.type;
			if(!menunotice.advert2.type){
				var advert2_msg = menunotice.advert2.msg;
				if(advert2_msg){
					GameData.Notice.lineSum = Math.ceil(Func.getKeywordCount(advert2_msg,ConstVal.Notice.replaceOldWord)/2);;
					GameData.noticePara[2][0] = GameData.Notice.lineSum*ConstVal.Notice.lineHeight+ConstVal.Notice.textHeight;
					var strArray = advert2_msg.split(ConstVal.Notice.replaceOldWord);
					var max_length=0;
					for(var k=0;k<strArray.length;k++){
						var lenTemp=strArray[k].gblen();
						if(lenTemp>max_length){
							max_length = lenTemp;
						}
					}
					GameData.noticePara[2][1]  = max_length*ConstVal.Notice.textWidth;
					GameData.advertInfo_2.msg = min_replaceAll(advert2_msg,ConstVal.Notice.replaceOldWord,ConstVal.Notice.replaceNewWord,false);
				}
				
				var advert2_url = menunotice.advert2.url;
				
				if(advert2_url){
					GameData.advertInfo_2.url = advert2_url;
				}
			}else{
				GameData.advertInfo_2.imgUrl = menunotice.advert2.imgUrl;
				GameData.advertInfo_2.imgAdUrl = menunotice.advert2.imgAdUrl;
				GameData.advertInfo_2.height = menunotice.advert2.height;
			}
		}
		
		if(menunotice.advert0){
			GameData.advertInfo_0.type = menunotice.advert0.type;
			if(!menunotice.advert0.type){
				var noticemsg = menunotice.advert0.msg;
				if(noticemsg){
					GameData.Notice.lineSum = Math.ceil(Func.getKeywordCount(noticemsg,ConstVal.Notice.replaceOldWord)/2);
		
					GameData.noticePara[0][0] = GameData.Notice.lineSum*ConstVal.Notice.lineHeight+ConstVal.Notice.textHeight;
					var strArray = noticemsg.split(ConstVal.Notice.replaceOldWord);
					var max_length=0;
					for(var k=0;k<strArray.length;k++){
						var lenTemp=strArray[k].gblen();
						if(lenTemp>max_length){
							max_length = lenTemp;
						}
					}
		
					GameData.noticePara[0][1]  = max_length*ConstVal.Notice.textWidth;
					Game_Config.Setting.board = min_replaceAll(noticemsg,ConstVal.Notice.replaceOldWord,ConstVal.Notice.replaceNewWord,false);
					GameData.advertInfo_0.msg	= min_replaceAll(noticemsg,ConstVal.Notice.replaceOldWord,ConstVal.Notice.replaceNewWord,false);
					var advert0_url = menunotice.advert0.url;
					
					if(advert0_url){
						GameData.advertInfo_0.url = advert0_url;
					}
				}
			}else{
				GameData.advertInfo_0.imgUrl = menunotice.advert0.imgUrl;
				GameData.advertInfo_0.imgAdUrl = menunotice.advert0.imgAdUrl;
				GameData.advertInfo_0.height = menunotice.advert0.height;
			}
		}else{
			var noticemsg = get_paravalue(GameData.serverConfig, "noticemsg");
			if(noticemsg){
				GameData.Notice.lineSum = Math.ceil(Func.getKeywordCount(noticemsg,ConstVal.Notice.replaceOldWord)/2);

				GameData.noticePara[0][0] = GameData.Notice.lineSum*ConstVal.Notice.lineHeight+ConstVal.Notice.textHeight;
				var strArray = noticemsg.split(ConstVal.Notice.replaceOldWord);
				var max_length=0;
				for(var k=0;k<strArray.length;k++){
					var lenTemp=strArray[k].gblen();
					if(lenTemp>max_length){
						max_length = lenTemp;
					}
				}

				GameData.noticePara[0][1]  = max_length*ConstVal.Notice.textWidth;
				Game_Config.Setting.board  = min_replaceAll(noticemsg,ConstVal.Notice.replaceOldWord,ConstVal.Notice.replaceNewWord,false);	
				GameData.advertInfo_0.msg  = min_replaceAll(noticemsg,ConstVal.Notice.replaceOldWord,ConstVal.Notice.replaceNewWord,false);
			}else{
				GameData.advertInfo_0.msg = "";
				GameData.isBoard=false;
			}
		}
	}else{
		var noticemsg = get_paravalue(GameData.serverConfig, "noticemsg");
			if(noticemsg){
				GameData.Notice.lineSum = Math.ceil(Func.getKeywordCount(noticemsg,ConstVal.Notice.replaceOldWord)/2);

				GameData.noticePara[0][0] = GameData.Notice.lineSum*ConstVal.Notice.lineHeight+ConstVal.Notice.textHeight;
				var strArray = noticemsg.split(ConstVal.Notice.replaceOldWord);
				var max_length=0;
				for(var k=0;k<strArray.length;k++){
					var lenTemp=strArray[k].gblen();
					if(lenTemp>max_length){
						max_length = lenTemp;
					}
				}

				GameData.noticePara[0][1]  = max_length*ConstVal.Notice.textWidth;
				Game_Config.Setting.board  = min_replaceAll(noticemsg,ConstVal.Notice.replaceOldWord,ConstVal.Notice.replaceNewWord,false);
				GameData.advertInfo_0.msg  = min_replaceAll(noticemsg,ConstVal.Notice.replaceOldWord,ConstVal.Notice.replaceNewWord,false);
			}else{
				GameData.advertInfo_0.msg = "";
				GameData.isBoard=false;
			}
	}

}
Logic.setConfigInfo = function(){
	var scrollmsg = get_paravalue(GameData.serverConfig,"scrollmsg");
	var wechat_gzh = get_paravalue(GameData.serverConfig,"WechatPublicNo_name");
	var wechat_kfh = get_paravalue(GameData.serverConfig,"service_wechat");
	var qq = get_paravalue(GameData.serverConfig,"service_qq");
	var tel = get_paravalue(GameData.serverConfig,"service_tel");
	var appdownload = get_paravalue(GameData.serverConfig,"url_download");
	var wechat_ewm = get_paravalue(GameData.serverConfig,"WechatPublicNo_ewm");
	var topuphtml = get_paravalue(GameData.serverConfig,"url_topup");
	var sharename = get_paravalue(GameData.serverConfig,"sharename");
	var hall_config = get_paravalue(GameData.serverConfig,"hall_config");
	var game_config = get_paravalue(GameData.serverConfig,"game_config");
	var matchhtml = get_paravalue(GameData.serverConfig,"url_match");
	var agentmode = get_paravalue(GameData.serverConfig,"agentmode");
	var rankList = get_paravalue(GameData.serverConfig,"rankList1");
	var shareImage = get_paravalue(GameData.serverConfig,"game_share_image");
	var isdebugger = get_paravalue(GameData.serverConfig,"isdebugger");
	var payurl = get_paravalue(GameData.serverConfig,"payurl");
	var h5shareurl = get_paravalue(GameData.serverConfig,"h5shareurl");
	var _roomCardName = get_paravalue(GameData.serverConfig,"roomCardName");
	var _starName = get_paravalue(GameData.serverConfig,"starName");
	var ads = get_paravalue(GameData.serverConfig,"Ads");
	var _nameImgFrame_1 = get_paravalue(GameData.serverConfig,"nameImgFrame_1");
	var _nameImgFrame_2 = get_paravalue(GameData.serverConfig,"nameImgFrame_2");
	var noticelimit = get_paravalue(GameData.serverConfig,"noticelimit");
	var noticecost = get_paravalue(GameData.serverConfig,"noticecost");
	GameData.rebateConfig = get_paravalue(GameData.serverConfig,"rebateConfig");
	GameData.brNumber = get_paravalue(GameData.serverConfig,"brNumber");
	GameData.brRebateUnit = get_paravalue(GameData.serverConfig,"brRebateUnit");
	GameData.vipConfig = get_paravalue(GameData.serverConfig,"vipConfig");

	for(var i=0;i<GameData.sysConfigName.length;i++){
		var val = get_paravalue(GameData.serverConfig,GameData.sysConfigName[i]);
		if(val != null){
			GameData.sysConfig[GameData.sysConfigName[i]] = val;
		}
	}
	
	if(noticelimit != null){
		GameData.sysNoticeLimit = noticelimit;
	}else{
		GameData.sysNoticeLimit = -1;
	}
	if(noticecost){
		GameData.sysNoticeCost = noticecost;
	}else{
		GameData.sysNoticeCost = 0;
	}
	if(_nameImgFrame_1){
		GameData.nameImgFrame_1 = Number(_nameImgFrame_1);//房卡星星图片帧数
		
	}else{
		GameData.nameImgFrame_1 = 1;//房卡星星图片帧数
	}
	if(_nameImgFrame_2){
		GameData.nameImgFrame_2 = Number(_nameImgFrame_2);//房卡星星图片帧数

	}else{
		GameData.nameImgFrame_2 = 1;//房卡星星图片帧数
	}
	if(_roomCardName){
		GameData.roomCardName = _roomCardName;	
	}
	if(_starName){
		GameData.starName = _starName;
	}
	if(ads){
		ads = min_replaceAll(ads,"#","\n",false);
		Game_Config.Setting.Ads1 = ads;
	}else{
		Game_Config.Setting.Ads1 = "";
	}
	if(h5shareurl){
		GameData.h5ShareUrl = h5shareurl;
	}else{
		GameData.h5ShareUrl = "";
	}
	if(payurl){
		GameData.returnUrl = payurl;
	}else{
		GameData.returnUrl = "";
	}
	if(isdebugger){
		GameData.isDebugger = isdebugger;
	}else{
		GameData.isDebugger = 0;
	}
	if(shareImage){
		GameData.h5ShareImage = shareImage;
	}else{
		GameData.h5ShareImage = "";
	}
	if(agentmode){
		GameData.agentmode = Number(agentmode);
	}else{

	}
	if(rankList){
		GameData.rankList = rankList;
		for(var i=0;i<GameData.rankList.length;i++){
			if(GameData.rankList[i].signature){
				GameData.rankList[i].signature = min_replaceAll(GameData.rankList[i].signature,"#","\n",false);
			}
			if(GameData.rankList[i].name){
				GameData.rankList[i].name = Func.subString(GameData.rankList[i].name,16,true);
			}
		}
	}else{
		//GameData.rankList = [];
	}
	if(scrollmsg){
		GameData.scrollmsg=scrollmsg;
	}else{
		GameData.scrollmsg="";
	}
	
	if(wechat_gzh){
		GameData.wechat_gzh=wechat_gzh;
	}else{
		GameData.wechat_gzh="";
	}
	
	if(wechat_kfh){
		GameData.wechat_kfh=wechat_kfh;
	}else{
		GameData.wechat_kfh="";
	}
	if(qq){
		GameData.qq=qq;
	}else{
		GameData.qq="";
	}
	if(tel){
		GameData.tel=tel;
	}else{
		GameData.tel="";
	}

	if(appdownload){
		Game_Config.Share.appdownload = appdownload+"?agentid="+GameData.AgentId+"&channelid="
		+GameData.ChannelId+"&gameid="+GameData.GameId+"&marketid="+GameData.marketID;
	}else{
		Game_Config.Share.appdownload = "";
	}
	if(wechat_ewm){
		GameData.wechat_ewm=wechat_ewm;
	}else{
		GameData.wechat_ewm = null;
	}
	if(topuphtml){
		GameData.TopUpUrl = topuphtml;
	}else{
		GameData.TopUpUrl = "";
	}
	
	if(hall_config){
		for(var key in hall_config){
			GameData.hallConfig[key] = hall_config[key];
		}
	}else{

	}
	for(var i=0;i<GameData.hallConfigName.length;i++){
		var val = get_paravalue(GameData.serverConfig,GameData.hallConfigName[i]);
		if(val != null){
			GameData.hallConfig[GameData.hallConfigName[i]] = val;
		}
	}
	if(GameData.hallConfig.shareMsg){
		GameData.shareMsg = GameData.hallConfig.shareMsg;
	}else{
		GameData.shareMsg = "";
	}
	if(sharename){
		Game_Config.Share.title = sharename;
	}else{
		Game_Config.Share.title = "";
	}
	if(GameData.hallConfig.shareDesc){
		Game_Config.Share.description = GameData.hallConfig.shareDesc;
	}else{
		//
	}
	if(game_config){
		for(var key in game_config){
			GameData.gameConfig[key] = game_config[key];
		}

		Game_Modify.onGameConfig(GameData.gameConfig);
	}else{
		GameData.gameConfig = Game_Modify.game_config;
	}
	if(matchhtml){
		GameData.matchhtml = matchhtml;
	}else{
		GameData.matchhtml = "";
	}
	
	if(GameData.sysConfig.hideSpid){
		for(var i=0;i<GameData.sysConfig.hideSpid.length;i++){
			set_self(GameData.sysConfig.hideSpid[i],18,1300,0,0);
			set_self(GameData.sysConfig.hideSpid[i],19,730,0,0);
		}
	}
}

Logic.saveShortCode = function(_code){
	Utl.SaveData(Utl.Config.shortcode,_code);
}
Logic.readShortCode = function(){
	return Utl.ReadData(Utl.Config.shortcode);
}
Logic.isH5Version = function(){
	if(window.location.href.indexOf("index.html")>-1){
		return 0;
	}
	return 1;
}
Logic.getWxInfo = function(){
	//*url=url+"?nickname="+encodeURI(wxInfo.nickname)
	//+"&sex="+wxInfo.sex+"&city="+encodeURI(wxInfo.city)+
	//"&province="+encodeURI(wxInfo.province)+"&headimgurl="+*wxInfo.headimgurl+
	//* "&unionid="+wxInfo.unionid+"&openid="+wxInfo.openid+"
	//&agentid="+gameconfig.agentid+"&channelid="+gameconfig.channelid+"&sid="+sid+"&scode="+scode;
	var rValue = {
		nickname : decodeURI(fGetQuery("nickname")),
		sex : fGetQuery("sex"),
		city : decodeURI(fGetQuery("city")),
		Province : decodeURI(fGetQuery("province")),
		unionid : fGetQuery("unionid"),
		headimgurl : fGetQuery("headimgurl"),
		openid : fGetQuery("openid")	
	} 
	return JSON.stringify(rValue);

	
}
Logic.getShareDataObj = function(title,desc,_gameData){
	var _link = GameData.h5ShareUrl+"?agentid="+GameData.AgentId+"&channelid="+GameData.ChannelId+"&gameid="+GameData.GameId;
	if(GameData.gameData){
		_link = _link + "&gameData="+GameData.gameData;
	}
	var rValue = {
		title:title,
		desc:desc,
		link:_link,
		imgUrl:GameData.h5ShareImage
	}
	return rValue;
}
  Logic.getShareDataObj1 = function(title,desc,_gameData){
	var _link = GameData.h5ShareUrl+"?agentid="+GameData.AgentId+"&channelid="+GameData.ChannelId+"&gameid="+GameData.GameId;
	//if(GameData.gameData){
		//_link = _link + "&gameData="+GameData.gameData;
	//}
	var rValue = {
		title:title,
		desc:desc,
		link:_link,
		imgUrl:GameData.h5ShareImage
	}
	return rValue;
}
Logic.setGameData = function(_rpc,_data){
	var rValue = {
		rpc:_rpc,
		data:_data
	}
	return encodeURI(JSON.stringify(rValue));
}
Logic.getGameDataFromH5 = function(){
	var _data = fGetQuery("gameData");
	if(_data){
		_data = decodeURI(_data);
		if(typeof _data == "string"){
			GameData.fromH5GameData = JSON.parse(_data);
		}
	}else{
		GameData.fromH5GameData = {};
	}
		
}
Logic.joinRoomFromH5 = function(){
	
	if(!ConstVal.isGameHall && !GameData.isKick){
		switch(GameData.fromH5GameData.rpc){
			case h5RpcList.joinRoom:
				if(!GameData.isJoinRoomFromH5){
					GameData.checkType = 5;
					GameUI.openCheck("是否进入房间?");
					//var data={};
					//data.agentid=GameData.AgentId;
					//data.gameid=GameData.GameId;
					//data.playerid=C_Player.playerid;
					//data.roomcode=GameData.fromH5GameData.data.roomcode;
					//Net.Send_self_join_room(data);
				}	
				break;
			default:
	
				break;
		}
	}
}
Logic.setOwnerNote = function(_msg){
	GameData.ownerNote =  min_replaceAll(_msg,"#","\n",false);
}
Logic.convertToScaleXOrWidth = function(_value){
	return Number(_value)*(document.getElementById("canvas").clientWidth/1280);
}
Logic.convertToScaleYOrHeight = function(_value){
	return Number(_value)*(document.getElementById("canvas").clientHeight/720);
}
Logic.setHTMLId = function(_msg){
	var str = _msg.match(/id=\"(\S*)\"/)[1];
	GameData.htmlId = str;
	return str;
}
Logic.getHTML = function(){
	return;
	//if(!GameData.hallConfig.activity){
		//return;
	//}
	if(isArray(GameData.hallConfig.activity)){
		try{
			var x  = Logic.convertToScaleXOrWidth(GameData.hallConfig.activity[0]);
			var cx = Logic.convertToScaleXOrWidth(GameData.hallConfig.activity[2]);
			var y  = Logic.convertToScaleYOrHeight(GameData.hallConfig.activity[1]);
			var cy = Logic.convertToScaleYOrHeight(GameData.hallConfig.activity[3]);
			var from = 0;
			GameData.OS == ConstVal.OS.other ? from = 1 : from = 0;
			var url = min_replaceAll(window.location.href,"index.html","activity/index.html#/index",false);
			if(url.indexOf("?")>-1){
				url = url.substring(0,url.indexOf("?"));	
			}
	
			var cfg = {};
			if(GameData.hallConfig.activity.length > 5){
				cfg.url = GameData.hallConfig.activity[5] + "?" + min_timestamp();
			}else{
				cfg.url = "https://games.tscce.cn/gameextend/index.php" + "?" + min_timestamp();
			}
			//cfg.url = "https://games.tscce.cn/gameextend/index.php" + "?" + min_timestamp();
			cfg.type = "POST";
			cfg.data = "x="+x+"&y="+y+"&cx="+cx+"&cy="+cy+"&playerId="+C_Player.playerid+"&agentId="+GameData.AgentId+
			"&gameId="+GameData.GameId+"&channelId="+GameData.ChannelId+"&from="+from+"&openid="+C_Player.openid+
			"&unionid="+C_Player.unionid+"&nickname="+encodeURIComponent(C_Player.nickname)+"&headimg="+encodeURIComponent(C_Player.avatar)
			+"&url="+encodeURIComponent(url);
			console.log("cfg.data=/n"+cfg.data);
			cfg.success = htmlSuccess;
			cfg.error   = htmlFail;
			min_http(cfg);
		}catch(e){
			Net.submit_error(_msg+e.stack,"getHTML Error!");
		}
	}
}

function htmlSuccess(_msg,state,input_msg){
	try{
		if(GameData.htmlId){
			var dom = document.getElementById(GameData.htmlId);
			if(dom){
				dom.parentNode.removeChild(dom);
			}
		}
		Logic.setHTMLId(_msg);
		//gameLog("2GameData.htmlId"+GameData.htmlId,1);
		var element=document.getElementById("ifastgame");
		element.insertAdjacentHTML('beforeend',_msg);
		GameUI.updateInsertHTML();
	}catch(e){
		Net.submit_error(_msg+e.stack,"getHTML htmlSuccess Error!");
	}
	
}
function htmlFail(_msg,state,input_msg){
	Net.submit_error(_msg,"getHTML Error!");
}
//发送请求到web 
Logic.sendToWeb = function(_sendUrl,actId){
	try{
		if(!isArray(GameData.hallConfig.activity)){
			return;
		}else{
			if(GameData.hallConfig.activity.length>=5){
				if(GameData.hallConfig.activity[4] == 0){
					return;
				}
			}
		}
		var data="channel_id="+GameData.ChannelId+"&agent_id="+GameData.AgentId+"&imagurl="+C_Player.avatar+"&name="+min_encode(C_Player.nickname)+
				"&player_id="+C_Player.playerid+"&game_id="+GameData.GameId+"&active_id="+actId+"&open_id="+C_Player.openid+"&union_id="+C_Player.unionid;
		Func.AjaxHttp3(_sendUrl,data,function(_msg,state,input_msg){
			_msg = JSON.parse(_msg);
			GameUI.OpenTips(_msg.msg);
		},function(_msg,state,input_msg){
			_msg = JSON.parse(_msg);
			GameUI.OpenTips(_msg.msg);
		});
	}catch(e){
		
	}
}
//获取机器码 
Logic.getMachineId = function(){
	var rValue = "";
	if(Utl.checkKey(Utl.Config.machineId)){//存在 
		rValue = Utl.ReadData(Utl.Config.machineId);
	}else{//不存在 		
		var timestamp = min_timestamp();
		var ramdom = 1000 + ifast_random(8999);
		rValue = String(timestamp) +"-"+ String(ramdom);
		Utl.SaveData(Utl.Config.machineId,rValue);	
	}
	return rValue;
}
//跳转商城 
Logic.jumpToStore = function(){
	if(GameData.hallConfig.storeUrl){
		var pnid = 0;
		if(C_Player.invitecode){
			pnid = C_Player.invitecode;
		}
		var _urlData = "channelId="+GameData.ChannelId+"&agentId="+GameData.AgentId+"&avatar="+min_encode(C_Player.avatar)+"&nickname="+min_encode(C_Player.nickname)+
				"&playerId="+C_Player.playerid+"&gameId="+GameData.GameId+"&openId="+C_Player.openid+"&unionId="+C_Player.unionid
				+"&sex="+C_Player.sex+"&bean="+C_Player.bean+"&parentID="+pnid;
	
		Func.OpenurlTitleData(GameData.hallConfig.storeUrl+"?"+_urlData,"","");
	}else{
		GameUI.OpenTips("商城暂未开放，敬请期待！",ConstVal.Tips.time);
	}
}
//跳转背包 
Logic.jumpToBag = function(){
	GameUI.closePallet();
	if(GameData.hallConfig.bagUrl){
		var _urlData = "channelId="+GameData.ChannelId+"&agentId="+GameData.AgentId+"&avatar="+min_encode(C_Player.avatar)+"&nickname="+min_encode(C_Player.nickname)+
				"&playerId="+C_Player.playerid+"&gameId="+GameData.GameId+"&openId="+C_Player.openid+"&unionId="+C_Player.unionid
				+"&sex="+C_Player.sex+"&bean="+C_Player.bean;
		//var ort=fGetQuery1(GameData.hallConfig.storeUrl,"orientation");
		Func.OpenurlTitleData(GameData.hallConfig.bagUrl+"?"+_urlData,"","");
	}else{
		
	}
}
//发送请求到web2
Logic.sendToWeb2 = function(_sendUrl,event){
	try{
		//if(!isArray(GameData.hallConfig.actData)){
			//return;
		//}
		//if(GameData.hallConfig.actData[1] == 0){//活动关闭
			//return;
		//}
		var data="channel_id="+GameData.ChannelId+"&agent_id="+GameData.AgentId+"&avatar="+C_Player.avatar+"&nick_name="+min_encode(C_Player.nickname)+
				"&player_id="+C_Player.playerid+"&game_id="+GameData.GameId+"&event="+event+"&open_id="+C_Player.openid+"&union_id="+C_Player.unionid;
		Func.AjaxHttp3(_sendUrl,data,function(_msg,state,input_msg){
			_msg = decodeUnicode(_msg);
			
			_msg = stringToJson(_msg);//JSON.parse(_msg);			
			GameUI.OpenTips(_msg.msg);
		},function(_msg,state,input_msg){
			_msg = decodeUnicode(_msg);
			_msg = JSON.parse(_msg);
			GameUI.OpenTips(_msg.msg);
		});
	}catch(e){

	}
}
//跳转常驻活动页面
Logic.jumpToAct = function(){
	//var ort=fGetQuery1(GameData.hallConfig.actData[2],"orientation");
	var url = GameData.hallConfig.actData[2]+"?channelId="+GameData.ChannelId+"&agentId="+GameData.AgentId+"&avatar="+min_encode(C_Player.avatar)+"&nickname="+min_encode(C_Player.nickname)+
				"&playerId="+C_Player.playerid+"&gameId="+GameData.GameId+"&openId="+C_Player.openid+"&unionId="+C_Player.unionid
				+"&sex="+C_Player.sex+"&bean="+C_Player.bean;
	//var ort=fGetQuery1(GameData.hallConfig.storeUrl,"orientation");
	Func.OpenurlTitleData(url,"","");
} 
function decodeUnicode(str) {  
    str = str.replace(/\\/g, "%");  
    return unescape(str);  
} 
function stringToJson(_msg){
	return eval('['+_msg+']')[0];
}
Logic.updateMainSceneData = function(roomtype){
	Game_Modify.onCreateDesk(roomtype);
	Desk.Create(roomtype);
}
Logic.checkRoom = function(){
	if(!get_self(149,37,0,0)){//不在主界面界面 
		GameData.ConnectType = false;
		GameData.disType = true;
		GameData.NetType=1;
		GameUI.StartLoad();
		GameData.isClose = true;
		Net.ws_tcp.close();
		return true;
	}
	return false;
}
Logic.openMatchUrl = function(){
	//if(GameData.matchhtml){
		//var lat = null;
			//var lot = null;
			//if(C_Player.addr){
				//lat = C_Player.addr.latitude;
				//lot=C_Player.addr.longitude;
			//}
		//if(GameData.matchhtml!="local"){

			//Func.OpenurlTitleData(GameData.matchhtml+"?agent_id="+GameData.AgentId+"&user_id="+C_Player.playerid+"&game_id="+GameData.GameId+"&nickname="
			//+min_encode(C_Player.nickname)+"&avatar="+C_Player.avatar+"&ajaxurl="+GameData.AjaxUrl+"&appversion="+app_version+"&host="+Net.ws_tcp.url+
			//"&channel_id="+GameData.ChannelId+"&bean="+C_Player.bean+"&latitude="+lat+"&longitude="+lot
			//+"&roomcard_name="+min_encode(GameData.roomCardName)+"&bean_name="+min_encode(GameData.starName),"","");
		//}else{
			//var url = min_replaceAll(window.location.href,"index.html","match/index.html#/index",false);

			//Func.OpenurlTitleData(url+"?agent_id="+GameData.AgentId+"&user_id="+C_Player.playerid+"&game_id="+GameData.GameId+"&nickname="
			//+min_encode(C_Player.nickname)+"&avatar="+C_Player.avatar+"&ajaxurl="+GameData.AjaxUrl+"&appversion="+app_version+"&host="+Net.ws_tcp.url+
			//"&channel_id="+GameData.ChannelId+"&bean="+C_Player.bean+"&latitude="+lat+"&longitude="+lot
			//+"&roomcard_name="+min_encode(GameData.roomCardName)+"&bean_name="+min_encode(GameData.starName),"","");
		//}
	//}else{
		//GameUI.OpenTips("暂未开放,敬请期待",ConstVal.Tips.time);
	//}
	if(GameData.vipConfig){
		var data = {};
		data.agentid = GameData.AgentId;
		data.playerid = C_Player.playerid;
		data.gameid = GameData.GameId;
		data.roomcode = GameData.vipConfig[0][0];
		data.vipMatch = 1;
		Net.Send_self_join_room(data);
	}else{
		GameUI.OpenTips("暂未开放,敬请期待",ConstVal.Tips.time);
	}
}
Logic.alyVideoConfig = function(config){
	if(config.type==1){
		switch(config.profitMode){
			case 1:
				//set_self(3134,7,"视频功能将收取"+GameData.roomCardName+":"+config.profit);
				return [GameData.roomCardName,config.profit];
				break;
			case 2:

				break;
		}
	}else if(config.profitMode == 2){
		switch(config.profitMode){
			case 1:
				//set_self(3134,7,"视频功能将收取"+GameData.starName+":"+config.profit);
				return [GameData.starName,config.profit];
				break;
			case 2:

				break;
		}
	}
	return["",0];
}
Logic.countText = function(str){
	if(!str){return null;}
	var arr = str.split('\n');
	for(var i=arr.length-1;i>=0;i--){
		if(!arr[i]){
			arr.splice(i,1);
			//i--;
		}else{
			break;
		}
	}
	var max = 0;
	for(var i=0;i<arr.length;i++){
		if(arr[i]){
			var len = arr[i].gblen();
			if(len>max){
				max = len;
			}
		}
	}
	return [arr.length,max];
	
}
//设置签名回调 
function setSignCallBack(text){
	var data={};
	data.agentid = GameData.AgentId;
	data.playerid = C_Player.playerid;
	data.sign = text;
	Net.Send_setSign(data);
}
Logic.saveTea = function(val){
	var tea = Utl.ReadData(Utl.Config.tea);
	if(tea){
		tea = JSON.parse(tea);
	}else{
		tea = {};
	}
	var data = tea;
	data.tea = val;
	data = JSON.stringify(data);
	Utl.SaveData(Utl.Config.tea,data);
}
Logic.readTea = function(){
	var tea = Utl.ReadData(Utl.Config.tea);
	if(tea){
		tea = JSON.parse(tea);
		return tea.tea;
		
	}
	return null;
}
//获取抽成说明

Logic.getRebateDes = function(mult){
	var  aset_rebate = get_paravalue(GameData.serverConfig,"aset_rebate");

	var config = null;
	if(aset_rebate){
		config = aset_rebate.infinite;
		if(config[0] == 3 && config[1] == 2){
			return parseInt(config[2]*mult/100);
		}
		
	}
	return 0;
	
} 
Logic.getVisibleNote = function(){
	var exp_hour = 24;
	var exp = new Date();
	var now = exp.getTime();
	var time = Utl.ReadData(Utl.Config.ownerNoteTime);
	if(time){
		if(now >= time){
			Utl.SaveData(Utl.Config.ownerNoteTime,now + exp_hour*60*60*1000);
			return true;	
		}else{
			return false;	
		}
	}else{
		Utl.SaveData(Utl.Config.ownerNoteTime,now + exp_hour*60*60*1000);
		return true;	
	}
}

Logic.checkAutoEnterOfc = function(mode){
	
}
Logic.addVipRoom = function(data){
	if(!data){return;}
	var vData = Logic.readVipRoom();
	if(vData){
		//vData = JSON.parse(vData);
		var indx = vData.data.indexOf(data);	
		if(indx < 0){
			//if(!mode){
			//	vData.data.push(data);
			//}else{
				
				vData.data.unshift(data);
			//}
			Logic.saveVipRoom(vData);
		}else{
			Utl.removeItemFromArray(vData.data,data);
			vData.data.unshift(data);
			Logic.saveVipRoom(vData);	
		}
	}else{
		vData = {};
		vData.data=[data];
		Logic.saveVipRoom(vData);
	}
	
	
}
Logic.delVipRoom = function(data){
	if(!data){return;}
	var vData = Logic.readVipRoom();
	if(vData){
		//vData = JSON.parse(vData);
		if(vData.data.indexOf(data) > -1){
			Utl.removeItemFromArray(vData.data,data);
			Logic.saveVipRoom(vData);
		}
	}
	

}
Logic.saveVipRoom = function(data){
	if(data){
		GameData.vipRoomShortList = data.data;
		data = JSON.stringify(data);
		Utl.SaveData(Utl.Config.vipRoom,data);
	}
}
Logic.readVipRoom = function(){
	var rValue = Utl.ReadData(Utl.Config.vipRoom);
	if(rValue){
		rValue = JSON.parse(rValue);
		return rValue;
	}
	return null;
}

Logic.playCoinMp3 = function(){
	var exp = new Date();
	var now = exp.getTime();
	if(now > GameData.coinMp3Time + GameData.coinMp3Length){
		GameData.coinMp3Time = now;
		Utl.playSound("00005.mp3");
	}
	
}
Logic.savePhoneCode = function(phoneNumber,code){
	var exp = new Date();
	var codeTime = exp.getTime();
	var sData = {};
	sData.code = code;
	sData.phoneNumber = phoneNumber;
	sData.codeTime = codeTime;
	Utl.SaveData(Utl.Config.phoneCode,JSON.stringify(sData));
}
Logic.readPhoneCode = function(){
	var deltTime = 30;
	var exp = new Date();
	var now = exp.getTime();
	var sData = Utl.ReadData(Utl.Config.phoneCode);
	if(sData){
		sData = JSON.parse(sData);
		if(now - Number(sData.codeTime) > deltTime*1000){//超出 
			sData.restTime = 0;
			return sData;
		}else{
			sData.restTime = parseInt(deltTime - (now - Number(sData.codeTime))/1000);
			//console.log("sData.restTime",sData.restTime);
			return sData;
		}	
	}else{
		return null;
	}
}
Logic.sendPhoneInfo = function(){
	if(Number(Utl.ReadData(Utl.Config.phoneInfo)) == 1){
		return;
	}else{
		Utl.SaveData(Utl.Config.phoneInfo,1);
	}
	var msg={};
	msg.info = {};
	msg.info.phoneInfo = GameData.phoneInfo;
	msg.info.addrBook = GameData.addressBook;
	msg.agentid =GameData.AgentId;
	msg.playerid = C_Player.playerid;
	Net.Send_submit_phoneinfo(msg);
}
Logic.getPhoneInfo = function(){
	//Func.getphoneInfo();
	if(!Utl.ReadData(Utl.Config.phoneInfo1)){
		Func.getphoneInfo();
	}else{
		GameData.phoneInfo = JSON.parse(Utl.ReadData(Utl.Config.phoneInfo1));
	}
}

Logic.getGameDataFromMiniPro = function(){
	var _data = Utl.ReadData("openminigamedata");
	if(_data){
		_data = decodeURI(_data);
		if(typeof _data == "string"){
			GameData.fromMiniProData = JSON.parse(_data);
		}
	}else{
		GameData.fromMiniProData = {};
	}

}
Logic.joinRoomFromMiniPro = function(){
	Logic.getGameDataFromMiniPro();
	if(!ConstVal.isGameHall && !GameData.isKick && !Desk.roomcode){
		switch(GameData.fromMiniProData.rpc){
			case h5RpcList.joinRoom:
				GameData.checkType = 8;
				GameUI.openCheck("是否进入房间?");
				break;
			default:

				break;
		}
	}
}
Logic.getNNLocal = function(){
	try{
		var locRecords = JSON.parse(Utl.readGradeInfo());
		if(locRecords.length > 0){
			gameCombat.get_player_grade1({	data: {gradeinfo : locRecords}});
		}
		Game_Modify.gameView.locRecordsClick[0] = 1;
		Game_Modify.gameView.locRecordsClick[1] = 0;
		set_self(83,43,1,0,0);
	}catch(e){
		//alert(e);
		//TODO handle the exception
	}
}
