点点券优化,显示可兑换多少无门槛红包,云端在大于10元无门槛红包时进行通知推送,平时默认不通知
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
* @Author: lxk0301 https://github.com/lxk0301
|
||||
* @Date: 2020-11-20 11:42:03
|
||||
* @Last Modified by: lxk0301
|
||||
* @Last Modified time: 2020-11-23 12:27:14
|
||||
* @Last Modified time: 2020-12-12 12:27:14
|
||||
*/
|
||||
/*
|
||||
点点券,可以兑换无门槛红包(1元,5元,10元,100元,部分红包需抢购)
|
||||
@ -30,7 +30,8 @@ const $ = new Env('点点券');
|
||||
const notify = $.isNode() ? require('./sendNotify') : '';
|
||||
//Node.js用户请在jdCookie.js处填写京东ck;
|
||||
const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
|
||||
|
||||
const openUrl = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/41Lkp7DumXYCFmPYtU3LTcnTTXTX/index.html%22%20%7D`
|
||||
let message = '';
|
||||
//IOS等用户直接用NobyDa的jd cookie
|
||||
let cookiesArr = [], cookie = '';
|
||||
if ($.isNode()) {
|
||||
@ -60,6 +61,7 @@ const JD_API_HOST = 'https://api.m.jd.com/api';
|
||||
$.index = i + 1;
|
||||
$.isLogin = true;
|
||||
$.nickName = '';
|
||||
message = '';
|
||||
await TotalBean();
|
||||
console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`);
|
||||
if (!$.isLogin) {
|
||||
@ -89,11 +91,14 @@ async function jd_necklace() {
|
||||
await receiveBubbles();
|
||||
await sign();
|
||||
await necklace_homePage();
|
||||
// await necklace_exchangeGift(10);//自动兑换多少钱的无门槛红包,1000代表1元
|
||||
await showMsg();
|
||||
}
|
||||
function showMsg() {
|
||||
return new Promise(resolve => {
|
||||
$.msg($.name, '', `京东账号 ${$.index} ${$.nickName}\n当前${$.name}${$.totalScore}个`);
|
||||
return new Promise(async resolve => {
|
||||
$.msg($.name, '', `京东账号${$.index} ${$.nickName}\n当前${$.name}:${$.totalScore}个\n可兑换无门槛红包:${$.totalScore / 1000}元\n点击弹窗即可去兑换(注:此红包具有时效性)`, { 'open-url': openUrl});
|
||||
// 云端大于10元无门槛红包时进行通知推送
|
||||
if ($.isNode() && $.totalScore >= 10000) await notify.sendNotify(`${$.name} - 京东账号${$.index} - ${$.nickName}`, `京东账号${$.index} ${$.nickName}\n当前${$.name}:${$.totalScore}个\n可兑换无门槛红包:${$.totalScore / 1000}元\n点击链接即可去兑换(注:此红包具有时效性)\n↓↓↓ \n\n ${openUrl} \n\n ↑↑↑`, { url: openUrl })
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
@ -108,6 +113,8 @@ async function doTask() {
|
||||
console.log(`${item.taskName}任务已做完,奖励未领取`);
|
||||
} else if (item.taskStage === 3) {
|
||||
console.log(`${item.taskName}奖励已领取`);
|
||||
} else if (item.taskStage === 1) {
|
||||
console.log(`${item.taskName}任务未完成\n`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -136,7 +143,6 @@ function necklace_sign() {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`${$.name} API请求失败,请检查网路重试`)
|
||||
} else {
|
||||
console.log(data);
|
||||
if (safeGet(data)) {
|
||||
data = JSON.parse(data);
|
||||
if (data.rtn_code === 0) {
|
||||
@ -156,6 +162,40 @@ function necklace_sign() {
|
||||
})
|
||||
})
|
||||
}
|
||||
//兑换无门槛红包
|
||||
function necklace_exchangeGift(scoreNums) {
|
||||
return new Promise(resolve => {
|
||||
const body = {
|
||||
scoreNums,
|
||||
"giftConfigId": 31,
|
||||
currentDate: $.lastRequestTime.replace(/:/g, "%3A"),
|
||||
}
|
||||
$.post(taskPostUrl("necklace_exchangeGift", body), async (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`${$.name} API请求失败,请检查网路重试`)
|
||||
} else {
|
||||
if (safeGet(data)) {
|
||||
data = JSON.parse(data);
|
||||
if (data.rtn_code === 0) {
|
||||
if (data.data.biz_code === 0) {
|
||||
const { result } = data.data;
|
||||
message += `${result.redpacketTitle}:${result.redpacketAmount}元兑换成功\n`;
|
||||
message += `红包有效期:${new Date(result.endTime + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000).toLocaleString('zh', {hour12: false})}`;
|
||||
console.log(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e, resp)
|
||||
} finally {
|
||||
resolve(data);
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
//领取奖励
|
||||
function necklace_chargeScores(bubleId) {
|
||||
return new Promise(resolve => {
|
||||
@ -169,7 +209,6 @@ function necklace_chargeScores(bubleId) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`${$.name} API请求失败,请检查网路重试`)
|
||||
} else {
|
||||
console.log(data);
|
||||
if (safeGet(data)) {
|
||||
data = JSON.parse(data);
|
||||
if (data.rtn_code === 0) {
|
||||
@ -200,7 +239,6 @@ function necklace_startTask(taskId) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`${$.name} API请求失败,请检查网路重试`)
|
||||
} else {
|
||||
console.log(data);
|
||||
if (safeGet(data)) {
|
||||
data = JSON.parse(data);
|
||||
if (data.rtn_code === 0) {
|
||||
|
Reference in New Issue
Block a user