commit | author | age
|
7ee3f4
|
1 |
# 小程序核心功能文档 |
Z |
2 |
|
|
3 |
## 用户 this.$user |
|
4 |
|
|
5 |
### this.$user.getAccessToken(options) |
|
6 |
|
|
7 |
获取用户Access Token |
|
8 |
|
|
9 |
```javascript |
|
10 |
this.$user.getAccessToken({ |
|
11 |
cacheOnly: false, // 是否只从缓存读取,是的话即使缓存是空的也会返回空 |
|
12 |
}).then(accessToken => { |
|
13 |
|
|
14 |
}).catch(error => { |
|
15 |
|
|
16 |
}); |
|
17 |
``` |
|
18 |
|
|
19 |
### this.$user.getInfo() |
|
20 |
|
|
21 |
获取用户信息 |
|
22 |
|
|
23 |
```javascript |
|
24 |
this.$user.getInfo().then(info => { |
|
25 |
|
|
26 |
}).catch(error => { |
|
27 |
|
|
28 |
}); |
|
29 |
``` |
|
30 |
|
|
31 |
## 支付 this.$payment |
|
32 |
|
|
33 |
### this.$payment.pay(id); |
|
34 |
|
|
35 |
调用支付 |
|
36 |
|
|
37 |
```javascript |
|
38 |
// id: 后台支付接口返回的待支付id |
|
39 |
this.$payment.pay(id).then(msg => { |
|
40 |
// 支付成功 |
|
41 |
}).catch(msg => { |
|
42 |
// 支付失败 |
|
43 |
|
|
44 |
}); |
|
45 |
``` |