-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
111 lines (102 loc) · 2.75 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// app.js
wx.cloud.init()
const db = wx.cloud.database();
App({
appData: {
_id: null,
stu_name: null,
class: null,
sno: 'null',
academy: null,
phone: null,
userName: null,
passWord: null,
userInfo: null,
people: "student",
leavepeople: null,
dakapeople: null,
tch_name: null,
tch_type: null,
leaveSubmitState: null,
backSubmitState: null,
<<<<<<< HEAD
=======
>>>>>>> 18f71a72837f7eced68e10696c7dd1583246b481
},
onLaunch: function () {
if (!wx.cloud) {
console.error('使用更高的基础库')
} else {
wx.cloud.init({
env: 'cloud1-3g2hjwqc511b3694',
traceUser: true,
})
}
let token = wx.getStorageSync('token')
console.log(token.sno)
db.collection('student').where({
sno: token.sno
})
.get({
success: function (res) {
app._id = res.data[0]._id
app.class = res.data[0].class
app.stu_name = res.data[0].stu_name
app.sno = res.data[0].sno
app.academy = res.data[0].academy
app.phone = res.data[0].phone
app.passWord = res.data[0].passWord
wx.reLaunch({
url: '../main/main',
})
console.log('here')
}
})
this.globalData = {}
var userInfo = wx.getStorageSync('userInfo')
console.log('首页加载完毕', userInfo)
if (userInfo.people == 'student') {
wx.showLoading()
var that = this;
db.collection('student').where({
sno: userInfo.sno,
passWord: userInfo.passWord
}).get({
success: function () {
that.appData._id = userInfo._id
that.appData.class = userInfo.class
that.appData.stu_name = userInfo.stu_name
that.appData.sno = userInfo.sno
that.appData.academy = userInfo.academy
that.appData.phone = userInfo.phone
that.appData.passWord = userInfo.passWord
that.appData.people = userInfo.people
wx.redirectTo({
url: '/pages/main/main',
})
}
})
}
if (userInfo.people == 'teacher') {
wx.showLoading()
var that = this;
db.collection('teacher').where({
sno: userInfo.sno,
passWord: userInfo.passWord
}).get({
success: function () {
that.appData.tch_type = userInfo.tch_type
that.appData.tch_name = userInfo.tch_name
that.appData.sno = userInfo.sno
that.appData.academy = userInfo.academy
that.appData.phone = userInfo.phone
that.appData.passWord = userInfo.passWord
that.appData.people = userInfo.people
wx.switchTab({
url: '../check/check',
})
}
})
}
}
})