forked from justsso/wx-util
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
57 lines (43 loc) · 1.16 KB
/
test.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
var axios = require('axios');
var config = require('./config');
// function User(name){
// this.name = name || 'dada';
// }
//
// User.prototype.getName = function () {
// return this.name;
// };
//实例对象
// let user = new User();
// let user2 = new User('user2');
//
// console.log(user.getName());
// console.log(user2.getName());
//class写法
class User {
constructor(firstName, lastName){
this.firstName = firstName;
this.lastName = lastName;
}
getFullName(){
return this.firstName + this.lastName;
}
}
class Basic {
static async get_access_token() {
var appId = config.appId;
var appSecret = config.appSerect;
var tokenObj = await axios.get(`https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${appId}&secret=${appSecret}`);
if(!tokenObj.data){
return null;
}else {
if (tokenObj.data.access_token) {
var access_token = tokenObj.data.access_token;
return access_token;
}
}
}
}
module.exports = Basic;
let user3 = new User('ji','shuya');
console.log(user3.getFullName());