(s, key, title, acData)
| 715 | } |
| 716 | |
| 717 | function JDUserSignPre2(s, key, title, acData) { |
| 718 | return new Promise((resolve, reject) => { |
| 719 | if (disable(key, title, 1)) return reject() |
| 720 | const JDUrl = { |
| 721 | url: `https://pro.m.jd.com/mall/active/${acData}/index.html`, |
| 722 | headers: { |
| 723 | Cookie: KEY, |
| 724 | } |
| 725 | }; |
| 726 | $nobyda.get(JDUrl, async function(error, response, data) { |
| 727 | try { |
| 728 | if (error) { |
| 729 | throw new Error(error) |
| 730 | } else { |
| 731 | const act = data.match(/\"params\":\"\{\\\"enActK.+?\\\"\}\"/) |
| 732 | const turnTable = data.match(/\"turnTableId\":\"(\d+)\"/) |
| 733 | const page = data.match(/\"paginationFlrs\":\"(\[\[.+?\]\])\"/) |
| 734 | if (act) { // 含有签到活动数据 |
| 735 | return resolve(act) |
| 736 | } else if (turnTable) { // 无签到数据, 但含有关注店铺签到 |
| 737 | const boxds = $nobyda.read("JD_Follow_disable") === "false" ? false : true |
| 738 | if (boxds) { |
| 739 | console.log(`\n${title}关注店铺`) |
| 740 | return resolve(parseInt(turnTable[1])) |
| 741 | } else { |
| 742 | merge[key].notify = `${title}: 失败, 需要关注店铺 ⚠️` |
| 743 | merge[key].fail = 1 |
| 744 | } |
| 745 | } else if (page) { // 无签到数据, 尝试带参查询 |
| 746 | const boxds = $nobyda.read("JD_Retry_disable") === "false" ? false : true |
| 747 | if (boxds) { |
| 748 | console.log(`\n${title}二次查询`) |
| 749 | return resolve(page[1]) |
| 750 | } else { |
| 751 | merge[key].notify = `${title}: 失败, 请尝试开启增强 ⚠️` |
| 752 | merge[key].fail = 1 |
| 753 | } |
| 754 | } else { |
| 755 | merge[key].notify = `${title}: 失败, ${!data ? `需要手动执行` : `不含活动数据`} ⚠️` |
| 756 | merge[key].fail = 1 |
| 757 | } |
| 758 | } |
| 759 | reject() |
| 760 | } catch (eor) { |
| 761 | $nobyda.AnError(title, key, eor, response, data) |
| 762 | reject() |
| 763 | } |
| 764 | }) |
| 765 | if (out) setTimeout(reject, out + s) |
| 766 | }).then(data => { |
| 767 | disable(key, title, 2) |
| 768 | if (typeof(data) == "object") return JDUserSign1(s, key, title, encodeURIComponent(`{${data}}`)); |
| 769 | if (typeof(data) == "number") return JDUserSign2(s, key, title, data) |
| 770 | if (typeof(data) == "string") return JDUserSignPre1(s, key, title, acData, data) |
| 771 | }, () => disable(key, title, 2)) |
| 772 | } |
| 773 | |
| 774 | function JDUserSign1(s, key, title, body) { |
no test coverage detected