()
| 624 | } |
| 625 | //助力好友 |
| 626 | async function masterHelpShare() { |
| 627 | console.log('开始助力好友') |
| 628 | let salveHelpAddWater = 0; |
| 629 | let remainTimes = 3;//今日剩余助力次数,默认3次(京东农场每人每天3次助力机会)。 |
| 630 | let helpSuccessPeoples = '';//成功助力好友 |
| 631 | console.log(`格式化后的助力码::${JSON.stringify(newShareCodes)}\n`); |
| 632 | |
| 633 | for (let code of newShareCodes) { |
| 634 | console.log(`开始助力京东账号${$.index} - ${$.nickName}的好友: ${code}`); |
| 635 | if (!code) continue; |
| 636 | if (code === $.farmInfo.farmUserPro.shareCode) { |
| 637 | console.log('不能为自己助力哦,跳过自己的shareCode\n') |
| 638 | continue |
| 639 | } |
| 640 | await masterHelp(code); |
| 641 | if ($.helpResult.code === '0') { |
| 642 | if ($.helpResult.helpResult.code === '0') { |
| 643 | //助力成功 |
| 644 | salveHelpAddWater += $.helpResult.helpResult.salveHelpAddWater; |
| 645 | console.log(`【助力好友结果】: 已成功给【${$.helpResult.helpResult.masterUserInfo.nickName}】助力`); |
| 646 | console.log(`给好友【${$.helpResult.helpResult.masterUserInfo.nickName}】助力获得${$.helpResult.helpResult.salveHelpAddWater}g水滴`) |
| 647 | helpSuccessPeoples += ($.helpResult.helpResult.masterUserInfo.nickName || '匿名用户') + ','; |
| 648 | } else if ($.helpResult.helpResult.code === '8') { |
| 649 | console.log(`【助力好友结果】: 助力【${$.helpResult.helpResult.masterUserInfo.nickName}】失败,您今天助力次数已耗尽`); |
| 650 | } else if ($.helpResult.helpResult.code === '9') { |
| 651 | console.log(`【助力好友结果】: 之前给【${$.helpResult.helpResult.masterUserInfo.nickName}】助力过了`); |
| 652 | } else if ($.helpResult.helpResult.code === '10') { |
| 653 | console.log(`【助力好友结果】: 好友【${$.helpResult.helpResult.masterUserInfo.nickName}】已满五人助力`); |
| 654 | } else { |
| 655 | console.log(`助力其他情况:${JSON.stringify($.helpResult.helpResult)}`); |
| 656 | } |
| 657 | console.log(`【今日助力次数还剩】${$.helpResult.helpResult.remainTimes}次\n`); |
| 658 | remainTimes = $.helpResult.helpResult.remainTimes; |
| 659 | if ($.helpResult.helpResult.remainTimes === 0) { |
| 660 | console.log(`您当前助力次数已耗尽,跳出助力`); |
| 661 | break |
| 662 | } |
| 663 | } else { |
| 664 | console.log(`助力失败::${JSON.stringify($.helpResult)}`); |
| 665 | } |
| 666 | } |
| 667 | if ($.isLoon() || $.isQuanX() || $.isSurge()) { |
| 668 | let helpSuccessPeoplesKey = timeFormat() + $.farmInfo.farmUserPro.shareCode; |
| 669 | if (!$.getdata(helpSuccessPeoplesKey)) { |
| 670 | //把前一天的清除 |
| 671 | $.setdata('', timeFormat(Date.now() - 24 * 60 * 60 * 1000) + $.farmInfo.farmUserPro.shareCode); |
| 672 | $.setdata('', helpSuccessPeoplesKey); |
| 673 | } |
| 674 | if (helpSuccessPeoples) { |
| 675 | if ($.getdata(helpSuccessPeoplesKey)) { |
| 676 | $.setdata($.getdata(helpSuccessPeoplesKey) + ',' + helpSuccessPeoples, helpSuccessPeoplesKey); |
| 677 | } else { |
| 678 | $.setdata(helpSuccessPeoples, helpSuccessPeoplesKey); |
| 679 | } |
| 680 | } |
| 681 | helpSuccessPeoples = $.getdata(helpSuccessPeoplesKey); |
| 682 | } |
| 683 | if (helpSuccessPeoples && helpSuccessPeoples.length > 0) { |
no test coverage detected