login.js
1.02 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
var common = require('../utils/common');
var base = require('./base');
function login(obj) {
var _this = this;
_this.env = obj.env;
_this.url = obj.loginUrl;
_this.goLogin = function () {
if (_this.env === 'miniprogram') {
wx.miniProgram.switchTab({url: _this.url});
} else if (_this.env === 'app') {
var loginButton = document.getElementById('yosdk-login');
if (!loginButton) {
loginButton = common.createLinkButton(_this.url, 'yosdk-login');
}
loginButton.click();
} else {
window.location.href = _this.url;
}
return false;
};
_this.auth = function (nodeList, user) {
if (!user.uid) {
[].forEach.call(nodeList, function(value) {
value.onclick = function (event) {
event.preventDefault();
_this.goLogin();
}
});
return true;
}
}
}
module.exports = login;