authorize-comp.js
1.8 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
let app = getApp();
Component({
properties: {
// 这里定义了innerText属性,属性值可以在组件使用时指定
innerText: {
type: String,
value: 'default value',
}
},
data: {
// 这里是一些组件内部数据
someData: {}
},
methods: {
// 这里是一个自定义方法
customMethod() {
this.triggerEvent('evtcomp', {
name: "_evt_custom"
})
},
// 隐藏蒙层
hideMask() {
this.triggerEvent('evtcomp', {
name: "_evt_hide_mask"
});
},
authComplete() {
this.triggerEvent('evtcomp', {
name: "_evt_auth_complete"
});
},
bindGetUserInfo(e) {
wx.showLoading();
this.getUserInfo(e.detail);
},
getUserInfo(e) {
let _this = this;
// app.globalData.userInfo = e.userInfo;
app.post({
url: app.api.register,
sid: false,
data: {
encryptedData: e.encryptedData,
iv: e.iv,
code: app.store.getItem("wxcode"),
tlMemberCode: app.globalData.tlMemberCode
}
}).then((res2) => {
wx.hideLoading();
if (res2 && res2.sessionId) {
app.store.setItem('sessionId', res2.sessionId);
}
_this.hideMask();
_this.authComplete();
_this.initPage();
}).catch((err) => {})
},
/**
* 尝试重拉信息
*/
initPage() {
let pages = getCurrentPages();
let view = pages[pages.length - 1];
console.log("@authorize-comp view:", view);
if (view) {
try {
view.hideMask();
console.log("@authorize-comp || hideMask");
} catch (error) {}
try {
view.initData();
console.log("@authorize-comp || initData");
} catch (error) {}
}
}
}
})