forked from skyvow/m-mall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
44 lines (43 loc) · 1.13 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
import WxValidate from './assets/plugins/wx-validate/WxValidate'
import WxService from './assets/plugins/wx-service/WxService'
import HttpResource from './helpers/HttpResource'
import HttpService from './helpers/HttpService'
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.domain}${path}`
},
WxValidate: (rules, messages) => new WxValidate(rules, messages),
HttpResource: (url, paramDefaults, actions, options) => new HttpResource(url, paramDefaults, actions, options).init(),
HttpService: new HttpService({
baseURL: __config.basePath,
}),
WxService: new WxService,
__config,
})