psyduck/parse/jd/jd_task_chatReward.js
2025-02-11 21:55:02 +08:00

54 lines
1.5 KiB
JavaScript

import {Template} from '../../template.js'
export class Main extends Template {
constructor() {
super()
this.profile = {
title: '京东社群红包',
prompt: {
activityId: "活动id1|id2"
},
sync: 1,
verify: true,
crontab: 3
}
}
async prepare() {
await this.field('activityId')
}
async main(p) {
let user = p.data.user;
let s = await this.curl({
'url': `https://api.m.jd.com/client.action?functionId=chatReward_doReward&appid=wechat_activity&client=h5&body={"activityId":"${p.context.activityId}"}`,
user
}
)
let reward = await this.curl({
'url': `https://api.m.jd.com/client.action?functionId=chatReward_mainPage&appid=wechat_activity&client=h5&body={"activityId":"${p.context.activityId}"}`,
user,
algo: {
appId: "323f1",
}
}
)
if (this.haskey(reward, 'data.rewardInfo.rewardValue')) {
if (reward.data.rewardInfo.rewardType == 1) {
// p.msg(p.context.activityId)
p.msg(`红包: ${reward.data.rewardInfo.rewardValue}`)
}
else {
p.log(`优惠券: ${reward.data.rewardInfo.rewardValue}`)
}
}
else {
p.log("什么也没有")
}
if (this.haskey(reward, 'data')) {
p.info.work = true
}
}
}