-
Notifications
You must be signed in to change notification settings - Fork 14
/
app.js
45 lines (44 loc) · 1.14 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
import polyfill from 'assets/plugins/polyfill'
import WxValidate from 'helpers/WxValidate'
import HttpResource from 'helpers/HttpResource'
import HttpService from 'helpers/HttpService'
import WxService from 'helpers/WxService'
import Tools from 'helpers/Tools'
import Config from 'etc/config'
App({
onLaunch() {
console.log('onLaunch')
},
onShow() {
console.log('onShow')
},
onHide() {
console.log('onHide')
},
getUserInfo() {
return this.WxService.login()
.then(data => {
console.log(data)
return this.WxService.getUserInfo()
})
.then(data => {
console.log(data)
this.globalData.userInfo = data.userInfo
return this.globalData.userInfo
})
},
globalData: {
userInfo: null
},
renderImage(path) {
if (!path) return ''
if (path.indexOf('http') !== -1) return path
return `${this.Config.fileBasePath}${path}`
},
WxValidate: (rules, messages) => new WxValidate(rules, messages),
HttpResource: (url, paramDefaults, actions, options) => new HttpResource(url, paramDefaults, actions, options).init(),
HttpService: new HttpService,
WxService: new WxService,
Tools: new Tools,
Config: Config,
})