-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.js
93 lines (87 loc) · 2.21 KB
/
app.js
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
89
90
91
92
93
//app.js
App({
data: {
username: "未知",
avatar:
"https://github.com/topdeoo/topdeoo.github.io/blob/main/img/avatar.png",
code: 0,
},
onLaunch: function (e) {
console.log(e);
console.log(wx.getStorageSync('token'))
wx.getShareInfo({
shareTicket: e.shareTicket,
success: (res)=>{
wx.setStorageSync('isLeader', e.query.isLeader);
wx.request({
url: "https://hangout.wang/hangout/travel/share",
method: "POST",
data: {
token: wx.getStorageSync("token"),
activityId: e.query.activityId
},
success: (res) => {
console.log(res)
console.log("travelId = " + res.data.travelId);
wx.setStorageSync("travelId", res.data.travelId);
},
});
}
})
wx.authorize({
scope: "scope.userInfo",
success: () => {
wx.getUserProfile({
desc: "用户登录",
success: (res) => {
this.username = res.userInfo.nickName;
this.avatar = res.userInfo.avatarUrl;
this.globalData.userInfo = res.userInfo;
},
fail: (res) => {
console.log("11111");
},
});
},
});
console.log(this.data.username);
// wx.checkSession({
// success: (res) => {},
// fail: () => {
// },
// });
wx.login({
timeout: 3000,
success: (res) => {
this.data.code = res.code;
console.log(this.data.code);
wx.request({
url: "https://hangout.wang/hangout/user/login",
method: "POST",
data: {
username: this.data.username,
avatar: this.data.avatar,
code: this.data.code,
phoneCode: "",
},
dataType: "json",
success: (res) => {
console.log(res.data);
wx.setStorageSync("token", res.data.token);
this.globalData.token = res.token;
},
fail: (res) => {
console.log(res.errMsg);
},
});
},
fail: (res) => {
console.log("0000");
},
});
},
globalData: {
userInfo: null,
token: null,
},
});