popupLogin.js
2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
var PassportPopupLogin = {
settings: {
callbackFn : null
},
init : function(){
var self = this;
var intInterval = null;
var oldHashVal = "";
if(window.postMessage && ((typeof document.documentMode==='undefined') || document.documentMode > 8)){
window.onmessage = function(e){
self.switchCenter(e.data);
};
}else if( ('onhashchange' in window) && ((typeof document.documentMode==='undefined') || document.documentMode==8)) {
// 浏览器支持onhashchange事件
window.onhashchange = function(){
self.switchCenter(location.hash.substring(1)); // 对应新的hash执行的操作函数
};
} else {
// 不支持则用定时器检测的办法
intInterval = setInterval(function() {
var ischanged = isHashChanged(); // 检测hash值或其中某一段是否更改的函数
if(ischanged) {
intInterval = clearInterval(intInterval);
self.switchCenter(location.hash.substring(1)); // 对应新的hash执行的操作函数
}
}, 300);
}
var isHashChanged = function (){
return (location.hash != "#" && oldHashVal != location.hash);
};
return self;
},
tbClose: function () {
0 != $('.n-popup').length && jQuery(".n-popup").remove();
},
login: function () {
var self = this;
self.tbClose();
return Popup.start({
title : '登录地利',
url : "https://passport.nong12.com/uc/popup/login.aspx?referUrl=" + location.href,
width:530,
height:400,
hideheaderBar:false,
hidefooterBar:false
});
},
regist: function () {
var self = this;
self.tbClose(),
window.location = "https://passport.nong12.com/regedit/regedit.aspx";
},
lostPassword: function () {
var self = this;
self.tbClose(),
window.location = "https://passport.nong12.com/forgot/forgot.aspx";
},
switchCenter : function (val) {
var self = this;
self._clear();
switch(val){
case 'login_success':
self.callFunc();
break;
case 'passport_register':
self.regist();
break;
case 'passpor_lostPwd':
self.lostPassword();
break;
default :
break;
}
},
callFunc: function () {
var self = this;
self.tbClose();
if(self.settings.callbackFn && $.isFunction(self.settings.callbackFn)){
self.settings.callbackFn();
}
},
_clear : function(){
location.hash = "";
}
};