-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathapp.js
71 lines (59 loc) · 1.55 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
//app.js
const AV = require('./lib/av-weapp-min.js')
var language = require('./utils/language.js')
const config = require('./config.js')
const template = require('./stencils.js')
var data = {
userInfo: null,
language: null,
systemInfo: null,
stencils: null
}
AV.init({
appId: config.appId,
appKey: config.appKey
})
App({
globalData: data,
onLaunch: function () {
// 根据系统语言来显示对应语言
var systemInfo = wx.getSystemInfoSync()
if (systemInfo.language == 'zh_CN') {
this.globalData.language = language.zh
} else {
this.globalData.language = language.en
}
this.globalData.systemInfo = systemInfo
},
getUserInfo: function(cb){
var that = this
if(this.globalData.userInfo){
typeof cb == "function" && cb(this.globalData.userInfo)
}else{
//调用登录接口
wx.login({
success: function () {
wx.getUserInfo({
success: function (res) {
that.globalData.userInfo = res.userInfo
typeof cb == "function" && cb(res.userInfo)
}
})
}
})
}
},
getStencils: function(callBack) {
var that = this
if (this.globalData.stencils) {
typeof callBack === "function" && callBack(this.globalData.stencils)
} else {
AV.Cloud.run('stencils', {}).then(function (result) {
that.globalData.stencils = result
typeof callBack === "function" && callBack(result)
}, function (error) {
that.globalData.stencils = template
})
}
}
})