1 line
9.2 KiB
JavaScript
1 line
9.2 KiB
JavaScript
define(function(){
|
|
var GW_JS = function(){};
|
|
|
|
GW_JS.prototype.SendAjax = function(url,callback){
|
|
$.ajax({
|
|
type : 'GET',
|
|
cache : true,
|
|
url : url,
|
|
dataType : "jsonp",
|
|
jsonp:'jsonpCallback',
|
|
async:false,
|
|
success:callback
|
|
})
|
|
};
|
|
|
|
var GW = new GW_JS();
|
|
|
|
GW.config = function(obj){
|
|
var defaultConfig = {
|
|
GameId : "",
|
|
GameName :"",
|
|
Slide:{
|
|
SlideId : "",
|
|
SlideBox : ""
|
|
},
|
|
Login:{
|
|
LoginBox:"",
|
|
LoginUser:"",
|
|
LoginPass:"",
|
|
LoginSubmit:""
|
|
},
|
|
SwitchTab:{
|
|
TabNav:"",
|
|
TabContent:"",
|
|
TabCurrent:"",
|
|
TabActive:"",
|
|
TabEvent:"",
|
|
TabFind:"",
|
|
TabMore:""
|
|
},
|
|
Server:{
|
|
ServerTemplate:"",
|
|
ServerBox:"",
|
|
ServerL:0
|
|
}
|
|
};
|
|
GW.extend = obj?$.extend(defaultConfig,obj):defaultConfig;
|
|
};
|
|
|
|
GW.slide = function(){
|
|
var D = GW.extend.Slide;
|
|
var id = D.SlideId;
|
|
var obj = D.SlideBox;
|
|
if(id && obj){
|
|
/*GW.SendAjax('//' + location.host + '/index.php?m=poster&c=index&a=show_poster&type=JSON&id=' + id, function(result){
|
|
var list = result.Data;
|
|
var str="<div class='hd'><ul>";
|
|
for (var i in list){
|
|
str += "<li>"+(++i)+"</li>";
|
|
}
|
|
str += "</ul></div><div class='bd'><ul>";
|
|
for (var i in list){
|
|
str += "<li><a href='"+list[i].url+"' target='_blank'><img src='"+list[i].src+"' /></a></li>";
|
|
}
|
|
str += "</ul></div>";
|
|
$(obj).html(str);
|
|
$(obj).slide({mainCell:".bd ul",effect:"fade",autoPlay:true});
|
|
});*/
|
|
var str = '';
|
|
str += '<div class="hd">';
|
|
str += ' <ul>';
|
|
str += ' <li class="on">1</li>';
|
|
str += ' <li>2</li>';
|
|
str += ' <li>3</li>';
|
|
str += ' <li>4</li>';
|
|
str += ' <li>5</li>';
|
|
str += ' </ul>';
|
|
str += '</div>';
|
|
str += '<div class="bd">';
|
|
str += ' <ul>';
|
|
str += ' <li><a href="javascript:void(0);"><img src="static/home/img/slide_1.jpg"></a></li>';
|
|
str += ' <li><a href="javascript:void(0);"><img src="static/home/img/slide_2.jpg"></a></li>';
|
|
str += ' <li><a href="javascript:void(0);"><img src="static/home/img/slide_3.jpg"></a></li>';
|
|
str += ' <li><a href="javascript:void(0);"><img src="static/home/img/slide_4.jpg"></a></li>';
|
|
str += ' <li><a href="javascript:void(0);"><img src="static/home/img/slide_5.jpg"></a></li>';
|
|
str += ' </ul>';
|
|
str += '</div>';
|
|
$(obj).html(str);
|
|
$(obj).slide({mainCell:".bd ul",effect:"fade",autoPlay:true});
|
|
}
|
|
};
|
|
|
|
/*GW.login = function(){
|
|
var D = GW.extend.Login;
|
|
var LoginBox = D.LoginBox||"";
|
|
var LoginSubmit = D.LoginSubmit||"";
|
|
function loginSubmit(UserName,PassWord){
|
|
GW.SendAjax('//' + location.host + '/index.php?m=member&c=email&a=checkUsername&service=login&cn=' + UserName + '&pwd=' + PassWord, function(data){
|
|
if (data.result == 'err0001') {
|
|
alert('用户名或密码错误');
|
|
return false;
|
|
}
|
|
if (data.result == 'pwderror') {
|
|
alert('密码错误');
|
|
return false;
|
|
}
|
|
if (data.result == 'success') {
|
|
GW.loginSuccess(data);
|
|
GW.loginSuccessTOP(data)
|
|
}
|
|
})
|
|
};
|
|
|
|
function regLogin (){
|
|
var UserName = D.LoginUser.val()||"";
|
|
var PassWord = D.LoginPass.val()||"";
|
|
if(!UserName){
|
|
alert("请输入用户名!");
|
|
D.LoginUser.focus();
|
|
}
|
|
else if(!PassWord){
|
|
alert("请输入密码!");
|
|
D.LoginPass.focus();
|
|
}
|
|
else if(UserName&&PassWord){
|
|
loginSubmit(UserName,PassWord);
|
|
}
|
|
}
|
|
|
|
LoginSubmit.click(function(){
|
|
regLogin();
|
|
});
|
|
|
|
(LoginBox!="")&&LoginBox.keydown(function(e){
|
|
var eCode = e.keyCode;
|
|
(eCode==13)&®Login();
|
|
})
|
|
};
|
|
|
|
GW.loginSuccess = function(d){
|
|
var name = d.username||d;
|
|
var href = location.href;
|
|
var html = '<div class="loged"><div class="loged-panel"><ul><li>欢迎您:</li>';
|
|
html += '<li><a href="//' + location.host + '/member/s/account_manage/" target="_blank" class="colored">' + name + '</a></li>';
|
|
html += '<li><a href="//' + location.host + '/member/s/account_manage/" class="colored" target="_blank">完善密保资料</a></li>';
|
|
html += '<li><a class="chongzhi" target="_blank" href="http://' + location.host + '/?g=' + GW.extend.GameName + '">充值中心</a>';
|
|
html += '<span> | </span><a class="logout" href="//' + location.host + '/index.php?m=mymember&c=index&a=public_logout&forward=' + href + '">注销</a></li>'
|
|
html += '</ul></div></div>';
|
|
(GW.extend.Login.LoginBox !="")? GW.extend.Login.LoginBox.html(html):"";
|
|
};
|
|
|
|
GW.loginSuccessTOP = function (d){
|
|
var name = d.username||d;
|
|
var html = '<a href="//' + location.host + '/member/s/account_manage/" target="_blank" class="colored">'+name+'</a>';
|
|
html += '<a style="color: red;margin:0 10px;" class="logout" href="//' + location.host + '/index.php?m=mymember&c=index&a=public_logout&forward='+location.href+'">注销</a>'
|
|
$(".top-other").prepend(html);
|
|
$("#top .top-register,#top .fenge,#top .top-login").remove();
|
|
};*/
|
|
|
|
GW.tab = function(d){
|
|
var c =d||GW.extend.SwitchTab;
|
|
var TabNav = c.TabNav;
|
|
var TabCon = c.TabContent;
|
|
var TabCurrent = c.TabCurrent;
|
|
var TabEvent = c.TabEvent;
|
|
var TabFind = c.TabFind;
|
|
var main_acive = c.main_acive;
|
|
var TabMore = c.TabMore;
|
|
var TabChilden = TabFind!="" ? TabNav.find(TabFind) : TabNav.children();
|
|
TabChilden.bind(TabEvent,function(){
|
|
var i = $(this).index();
|
|
var more = $(this).attr('data-url');
|
|
TabChilden.removeClass(TabCurrent).eq(i).addClass(TabCurrent);
|
|
TabMore.attr({href:more});
|
|
if(main_acive){
|
|
TabCon.children().removeClass(main_acive).eq(i).addClass(main_acive);
|
|
}else{
|
|
TabCon.children().hide().eq(i).show()
|
|
}
|
|
})
|
|
};
|
|
|
|
/*GW.serverList = function(){
|
|
var D = GW.extend;
|
|
var GameId = D.GameId;
|
|
var ServerBox = D.Server.ServerBox;
|
|
var ServerTemplate = D.Server.ServerTemplate;
|
|
var showLength = D.Server.ServerL;
|
|
|
|
!function getServerList(){
|
|
var url = '//' + location.host + '/index.php?m=game&c=ajax&a=fuwuqi&gid=' + GameId+"&Math="+Math.random();
|
|
GW.SendAjax(url,function(resopons){
|
|
dataController(resopons);
|
|
});
|
|
}();
|
|
|
|
function dataController (d){
|
|
var list = d.f_list;
|
|
var num = 0;
|
|
var arr = [];
|
|
for(var i in list){
|
|
if(num < showLength-1){
|
|
if(list[i].f_zhuantai == "即将开启"){
|
|
arr.push(i);
|
|
}else{
|
|
var a = TemplateHtml(list[i],ServerTemplate);
|
|
ServerBox.append(a);
|
|
num++;
|
|
}
|
|
}
|
|
}
|
|
if(arr.length>0){
|
|
var b = TemplateHtml(list[arr[arr.length-1]],ServerTemplate);
|
|
ServerBox.prepend(b);
|
|
}
|
|
}
|
|
|
|
function TemplateHtml (d,t){
|
|
var list = d;
|
|
var Gid = GW.extend.GameId;
|
|
var htmlArr = t.split("%");
|
|
for(var b in htmlArr){
|
|
(htmlArr[b]=="url")?htmlArr[b]= 'http://' + location.host + '/game/show/' + Gid + "/" + list.f_id + ".html":"";
|
|
(htmlArr[b]=="serverName")?htmlArr[b]= list.f_name:"";
|
|
(htmlArr[b]=="serverState")?list.f_zhuantai=="推荐"?htmlArr[b]="新服推荐" : htmlArr[b]="即将开启":""
|
|
}
|
|
return htmlArr.join("");
|
|
}
|
|
};
|
|
|
|
GW.userInfo = function(){
|
|
var url = '//' + location.host + '/index.php?m=member&c=email&a=checkUsername&service=islogin&Math' + Math.random();
|
|
GW.SendAjax(url,function(respons){
|
|
if(respons.username){
|
|
GW.loginSuccessTOP(respons);
|
|
GW.loginSuccess(respons);
|
|
}
|
|
})
|
|
};*/
|
|
|
|
return GW.Init = function(obj){
|
|
GW.config(obj);
|
|
//GW.userInfo();
|
|
GW.slide();
|
|
//GW.login();
|
|
GW.tab();
|
|
//GW.serverList();
|
|
};
|
|
}); |