-
Notifications
You must be signed in to change notification settings - Fork 13
/
jd_dwapp.ts
65 lines (55 loc) · 1.61 KB
/
jd_dwapp.ts
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
/**
* 京东-生活积分
*/
import {User, JDHelloWorld} from "./TS_JDHelloWorld"
class Jd_dwapp extends JDHelloWorld {
cookie: string
constructor() {
super();
}
async init() {
await this.run(this)
}
async api(fn: string, body: object = {}) {
if (['dwList', 'dwRecord', 'dwReceive'].includes(fn))
fn = `task/${fn}`
body = this.getEncStr(fn, body)
await this.wait(2000)
return await this.post(`https://dwapp.jd.com/user/${fn}`, JSON.stringify(body), {
'Host': 'dwapp.jd.com',
'Cookie': this.cookie,
'content-type': 'application/json',
'origin': 'https://prodev.m.jd.com',
'user-agent': 'jdapp;',
'referer': 'https://prodev.m.jd.com/'
})
}
async main(user: User) {
this.cookie = user.cookie
let res: any
res = await this.api('dwSignInfo')
if (res.data.signInfo.signStatus === 0) {
res = await this.api('dwSign')
console.log('签到成功', res.data.signInfo.signNum)
} else {
console.log('已签到')
}
res = await this.api('dwList')
for (let t of res.data) {
if (t.viewStatus === 0) {
res = await this.api('dwRecord', {id: t.id, "taskType": t.taskType, "agentNum": "m", "followChannelStatus": "",})
console.log(res.msg)
res = await this.api('dwReceive', {id: t.id})
console.log(res?.data?.giveScoreNum)
}
}
res = await this.api('dwList')
for (let t of res.data) {
if (t.viewStatus === 2) {
res = await this.api('dwReceive', {id: t.id})
console.log(res?.data?.giveScoreNum)
}
}
}
}
new Jd_dwapp().init().then()