filter.js
2.44 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
86
87
88
function a(a, e) {
wx.getSetting({
success: function(o) {
wx.login({
success: function(o) {
n.globalData.code = o.code, t(a, e);
}
});
},
fail: function(a) {
console.log(a);
}
});
}
function t(a, t) {
n.globalData.authUserInfo ? n.globalData.authPhone ? o.checkLogin(function(t) {
switch (t.returnCode) {
case "0":
t.data ? a() : wx.showToast({
icon: "none",
title: "账号已在其他地方退出",
success: function() {
wx.login({
success: function(a) {
n.globalData.code = a.code, n.globalData.userInfo = null, wx.reLaunch({
url: "/pages/tab/index/index"
});
}
});
}
});
break;
default:
a();
}
}) : t(!1) : o.jscodeLogin(n.globalData.code, n.globalData.appId, function(e) {
switch (console.log(e), e.returnCode) {
case "0":
n.globalData.userInfo = e.data, n.globalData.authUserInfo = !0, e.data.accountId ? (n.globalData.authPhone = !0,
n.globalData.loginSuccessCallback(e.data), a()) : t(!1);
break;
case "-1":
"200205" == e.errId && t(!0), "100207" == e.errId && wx.reLaunch({
url: "/pages/tab/index/index"
});
break;
default:
wx.showToast({
title: e.message
});
}
});
}
function e() {
var a = getCurrentPages();
return a[a.length - 1];
}
var o = require("restapi.js"), n = getApp();
exports.identityFilter = function(t) {
if (t.onShow) {
var o = t.onShow;
t.onShow = function() {
var t = e();
a(function() {
t.setData({
authToast: !1
}), t.onLogin(), o.call(t);
}, function(a) {
wx.redirectTo({
url: "/pages/index/index"
}), t.setData({
authToast: !0,
authType: a
}), n.userInfoReadyCallback = function(a) {
t.onLogin(), o.call(t);
};
});
};
}
return t;
};