Skip to content

Commit bba41b4

Browse files
authored
Merge pull request #308 from fanhengkui/main
任务修复
2 parents c80f260 + d2ac30e commit bba41b4

2 files changed

Lines changed: 218 additions & 44 deletions

File tree

‎daily/xinxi.js‎

Lines changed: 176 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,23 @@ class Task {
3434
this.user = env.split(strSplitor);
3535
this.token = this.user[0];
3636
this.posts = []
37+
this.goods = []
38+
this.pageNum = 1
3739

3840
}
3941

4042
async run() {
4143
await this.userInfo()
44+
await this.signStatus();
4245
await this.tasklist()
46+
47+
if (this.goods) {
48+
$.log(`===========积分物品统计===========`)
49+
for (let item of this.goods) {
50+
$.log(`积分物品【${item.name}】,库存:${item.stock}`)
51+
}
52+
$.log(`===========积分物品统计===========`)
53+
}
4354
}
4455

4556
generateMd5Signature = function (e) {
@@ -82,6 +93,36 @@ class Task {
8293
}
8394

8495
}
96+
97+
async signStatus() {
98+
try {
99+
let options = {
100+
method: 'GET',
101+
url: `https://api.xinc818.com/mini/sign/status`,
102+
headers: {
103+
"Content-Type": "application/json",
104+
}
105+
106+
};
107+
let { data: result } = await this.request(options);
108+
if (result.code == 0) {
109+
if (result.data) {
110+
$.log(`✅账号[${this.index}] 签到状态【${result.data}】已签到🎉`)
111+
} else {
112+
$.log(`✅账号[${this.index}] 签到状态【${result.data}】未签到🎉`)
113+
await $.wait(2000)
114+
await this.signIn()
115+
}
116+
await $.wait(1000)
117+
await this.signContinuous()
118+
} else {
119+
$.log(`❌账号[${this.index}] 签到状态查询失败`);
120+
}
121+
} catch (error) {
122+
$.log(`❌账号[${this.index}] 签到状态查询异常:${error}`);
123+
}
124+
}
125+
85126
async signIn() {
86127
let options = {
87128
method: 'GET',
@@ -100,6 +141,28 @@ class Task {
100141
}
101142

102143
}
144+
145+
async signContinuous() {
146+
147+
try {
148+
let options = {
149+
method: 'GET',
150+
url: `https://api.xinc818.com/mini/sign/continuous`,
151+
headers: {
152+
"Content-Type": "application/json",
153+
}
154+
155+
156+
};
157+
let { data: result } = await this.request(options);
158+
if (result.code == 0) {
159+
$.log(`✅账号[${this.index}] 连续签到【${result.data}】天🎉`)
160+
}
161+
} catch (e) {
162+
$.log(`❌账号[${this.index}] 查询连续签到天数异常:${e}`);
163+
}
164+
}
165+
103166
async share() {
104167
let options = {
105168
method: 'GET',
@@ -126,11 +189,13 @@ class Task {
126189
};
127190
let { data: result } = await this.request(options);
128191
if (result.code == 0) {
192+
await this.getPosts()
193+
await this.getGoods()
129194
for (let task of result.data) {
130-
await this.getPosts()
195+
131196
if (task.status == false) {
132-
// console.log(`${task.taskName}[${task.code}]--${task.annotation} -- ${task.finishNum}`)
133-
if (task.code == 'BROWSE_PRODUC1TS') {
197+
console.log(`${task.taskName}[${task.code}]--${task.annotation} -- ${task.finishNum}`)
198+
if (task.code == 'BROWSE_PRODUCTS') {
134199
await this.browseGoods()
135200
}
136201
if (task.code == 'COMMENT_POSTS') {
@@ -140,10 +205,29 @@ class Task {
140205
await this.likePosts(this.posts[0].id)
141206
}
142207
if (task.code == 'FOCUS_USER') {
143-
await this.followUser(this.posts[0].publisherId)
208+
let _posts = "";
209+
while (true) {
210+
_posts = this.posts.filter(item => item.concernSign == 1)
211+
if (_posts) {
212+
break
213+
}
214+
await $.wait(2000)
215+
this.pageNum++;
216+
if (this.pageNum > 100) {
217+
218+
}
219+
await this.getPosts()
220+
}
221+
if (_posts) {
222+
await this.followUser(_posts[0].publisherId)
223+
} else {
224+
225+
}
144226
}
145227
if (task.code == 'WANT_GOODS') {
146-
await this.likeGoods()
228+
var good_id = this.goods[1].id;
229+
await this.getGoodDetail(good_id)
230+
await this.likeGoods(this.goodDetail.outerId)
147231
}
148232
if (task.code == 'SHARE') {
149233
await this.share()
@@ -195,68 +279,127 @@ class Task {
195279
async getPosts() {
196280
let options = {
197281
method: 'GET',
198-
url: `https://api.xinc818.com/mini/community/home/posts?pageNum=1&pageSize=10&queryType=3&position=2`,
282+
url: `https://api.xinc818.com/mini/community/home/posts?pageNum=${this.pageNum}&pageSize=100&queryType=3&position=2`,
199283
headers: {}
200284

201285
};
202286
let { data: result } = await this.request(options);
203287
if (result.code == 0) {
204288
this.posts = result.data.list
289+
// console.log(this.posts)
205290
}
206291
}
207-
async likePosts() {
208-
//找到posts里面liked为false的
209-
let posts = this.posts.filter(item => item.liked == false)
292+
293+
async getGoods() {
210294
let options = {
211-
method: 'PUT',
212-
url: `https://api.xinc818.com/mini/posts/like`,
213-
headers: {
214-
"Content-Type": "application/json",
215-
},
216-
data: { "postsId": posts[0].id, "decision": true }
295+
method: 'GET',
296+
url: `https://cdn-api.xinc818.com/mini/integralGoods?miniIs=1&orderField=sort&orderScheme=DESC&pageSize=50&pageNum=1`,
297+
headers: {}
217298

218299
};
219-
220300
let { data: result } = await this.request(options);
221301
if (result.code == 0) {
222-
// console.log(result);
223-
$.log(`✅账号[${this.index}] 【点赞帖子】成功 获得积分【${result.data.singleReward}】🎉`)
224-
}else{
225-
$.log(`❎账号[${this.index}] 【点赞帖子】失败,原因【${result.msg}】🎉`)
302+
this.goods = result.data.list
226303
}
227304
}
228305

229-
async followUser(publisherId) {
306+
async getGoodDetail(id) {
230307
let options = {
231-
method: 'PUT',
232-
url: `https://api.xinc818.com/mini/user/follow`,
233-
headers: {
234-
"Content-Type": "application/json",
235-
},
236-
data: { "followUserId": publisherId, "decision": true }
308+
method: 'GET',
309+
url: `https://api.xinc818.com/mini/integralGoods/${id}`,
310+
headers: {}
237311

238312
};
239313
let { data: result } = await this.request(options);
240314
if (result.code == 0) {
241-
$.log(`✅账号[${this.index}] 【关注用户】成功 获得积分【${result.data.singleReward}】🎉`)
242-
}else{
243-
$.log(`❎账号[${this.index}] 【关注用户】失败,原因【${result.msg}】🎉`)
315+
//用户商品详情的outerId点赞商品
316+
this.goodDetail = result.data
317+
}
318+
}
319+
320+
async likePosts() {
321+
//找到posts里面liked为false的
322+
try {
323+
let posts = this.posts.filter(item => item.liked == false)
324+
let options = {
325+
method: 'PUT',
326+
url: `https://api.xinc818.com/mini/posts/like`,
327+
headers: {
328+
"Content-Type": "application/json",
329+
},
330+
data: { "postsId": posts[0].id, "decision": true }
331+
332+
};
333+
334+
let { data: result } = await this.request(options);
335+
if (result.code == 0) {
336+
// console.log(result);
337+
$.log(`✅账号[${this.index}] 【点赞帖子】成功 获得积分【${result.data.singleReward}】🎉`)
338+
} else {
339+
$.log(`❎账号[${this.index}] 【点赞帖子】失败,原因【${result.msg}】🎉`)
340+
}
341+
} catch (err) {
342+
$.log(`❎账号[${this.index}] 【点赞帖子】失败:${err}`)
343+
}
344+
}
345+
346+
async followUser(publisherId, decision = true) {
347+
try {
348+
let options = {
349+
method: 'PUT',
350+
url: `https://api.xinc818.com/mini/user/follow`,
351+
headers: {
352+
"Content-Type": "application/json",
353+
},
354+
data: { "followUserId": publisherId, "decision": decision }
355+
356+
};
357+
let { data: result } = await this.request(options);
358+
// console.log(result)
359+
if (result.code == 0) {
360+
if (decision) {
361+
$.log(`✅账号[${this.index}] 【关注用户】成功 获得积分【${result.data.singleReward}】🎉`)
362+
//await $.wait(3000)
363+
//await this.followUser(publisherId, false)
364+
} else {
365+
$.log(`✅账号[${this.index}] 【取消关注用户】成功 `)
366+
}
367+
} else {
368+
$.log(`❎账号[${this.index}] 【关注用户】失败,原因【${result.msg}】🎉`)
369+
if (result.msg.match("重复")) {
370+
371+
//await this.followUser(publisherId, false)
372+
}
373+
}
374+
} catch (err) {
375+
$.log(`❎账号[${this.index}] 【关注用户】失败:${err}`)
244376
}
245377
}
246-
async likeGoods(goodsId = "210000904376") {
378+
async likeGoods(goodsId = "210000904376", isLike = true) {
247379
try {
248380
let options = {
249381
method: 'POST',
250382
url: `https://api.xinc818.com/mini/live/likeLiveItem`,
251383
headers: {
252384
"Content-Type": "application/json",
253385
},
254-
data: { "isLike": true, "dailyTaskId": 20, "productId": goodsId }
386+
data: { "isLike": isLike, "dailyTaskId": 20, "productId": goodsId }
255387

256388
};
389+
// console.log(options)
257390
let { data: result } = await this.request(options);
391+
// console.log(result)
258392
if (result.code == 0) {
259-
$.log(`✅账号[${this.index}] 【点赞商品】成功 获得积分【${result.data.singleReward}】🎉`)
393+
if (isLike) {
394+
$.log(`✅账号[${this.index}] 【点赞商品】成功 获得积分【${result.data.singleReward}】🎉`)
395+
await $.wait(3000)
396+
await this.likeGoods(goodsId, false)
397+
} else {
398+
$.log(`✅账号[${this.index}] 【点赞商品】取消成功🎉`)
399+
}
400+
401+
} else {
402+
$.log(`❎账号[${this.index}] 【点赞商品】失败,原因【${result.msg}】🎉`)
260403
}
261404
} catch (err) {
262405
$.log(`❎账号[${this.index}] 【点赞商品】失败:${err}`)

‎wxapp/jyk.js‎

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ const USER_AGENT =
4343

4444
const EP_LOGIN = "/api/index/get_openid";
4545
const EP_HOME = "/api/checkin/home";
46-
const EP_PREPARE = "/api/checkin/prepare";
46+
const EP_PREPARE = "/api/checkin/ad/prepare";
4747
const EP_SIGN = "/api/checkin/sign";
48+
const EP_AD_SIGN = "/api/checkin/ad/sign";
4849

4950
const wechat = new WeChatServer({
5051
url: process.env.wx_server_url || "http://192.168.31.196:8787",
@@ -134,20 +135,33 @@ class Task {
134135
if (Number(res?.errno) !== 0) throw new Error(`home失败: ${res?.errmsg || short(res)}`);
135136
return res.data || {};
136137
}
138+
async sign() {
139+
const signed = await this.request("POST", EP_SIGN, {});
140+
if (Number(signed?.errno) === 0) {
141+
const d = signed.data || {};
142+
return this.log(`✅ 签到成功${d.score !== undefined ? `,获得 ${d.score} 积分` : ""}${d.integral !== undefined ? `,积分 ${d.integral}` : ""}`);
143+
}
144+
if (/已签|签到过|重复|已完成/.test(String(signed?.errmsg || signed?.msg || ""))) return this.log(`✅ 今日已签到(${signed.errmsg || signed.msg})`);
145+
this.log(`❌ 签到失败: ${signed?.errmsg || signed?.msg || short(signed)}`);
146+
}
137147
async prepareAndSign() {
138148
const prepared = await this.request("POST", EP_PREPARE);
139-
if (Number(prepared?.errno) !== 0) return this.log(`❌ 普通签到 prepare 失败: ${short(prepared)}`);
149+
if (Number(prepared?.errno) !== 0) return this.log(`❌ 广告签到 prepare 失败: ${short(prepared)}`);
140150
const adToken = String((prepared.data || {}).ad_token || "");
141-
if (!adToken) return this.log("❌ 普通签到 prepare 未返回 ad_token");
142-
const signed = await this.request("POST", EP_SIGN, { ad_token: adToken });
151+
if (!adToken) return this.log("❌ 广告签到 prepare 未返回 ad_token");
152+
await $.wait(10 * 1000)
153+
const signed = await this.request("POST", EP_AD_SIGN, { ad_token: adToken });
143154
if (Number(signed?.errno) === 0) {
144155
const d = signed.data || {};
145-
return this.log(`✅ 签到成功${d.score !== undefined ? `,获得 ${d.score} 积分` : ""}${d.integral !== undefined ? `,积分 ${d.integral}` : ""}`);
156+
this.log(`✅ 广告签到成功${d.score !== undefined ? `,获得 ${d.score} 积分` : ""}${d.integral !== undefined ? `,积分 ${d.integral}` : ""}`);
157+
await $.wait(30 * 1000)
158+
await this.checkin_sign('ad');
159+
return
146160
}
147161
if (/已签|签到过|重复|已完成/.test(String(signed?.errmsg || signed?.msg || ""))) return this.log(`✅ 今日已签到(${signed.errmsg || signed.msg})`);
148-
this.log(`❌ 签到失败: ${signed?.errmsg || signed?.msg || short(signed)}`);
162+
this.log(`❌ 广告签到失败: ${signed?.errmsg || signed?.msg || short(signed)}`);
149163
}
150-
async sign() {
164+
async checkin_sign(type) {
151165
let home;
152166
try {
153167
home = await this.home();
@@ -158,9 +172,26 @@ class Task {
158172
home = await this.home();
159173
} else throw e;
160174
}
161-
if (!home.enabled) return this.log("普通签到未开启");
162-
if (home.today_signed || !home.can_sign) return this.log("✅ 今日已签到或不可签");
163-
await this.prepareAndSign();
175+
if (type == 'ad') {
176+
if (home.ad && home.ad.today_count < home.ad.daily_limit) {
177+
await this.prepareAndSign();
178+
} else {
179+
this.log("✅ 今日广告签到已完成签到或不可签")
180+
}
181+
182+
} else {
183+
if (!home.enabled) return this.log("普通签到未开启");
184+
if (home.today_signed || !home.can_sign) {
185+
this.log("✅ 今日普通签到已签到或不可签")
186+
} else {
187+
await this.sign();
188+
}
189+
if (home.ad && home.ad.today_count < home.ad.daily_limit) {
190+
await this.prepareAndSign();
191+
} else {
192+
this.log("✅ 今日广告签到已完成签到或不可签")
193+
}
194+
}
164195
}
165196
async ensureLogin() {
166197
const cached = readCache()[this.account.openid] || {};
@@ -171,7 +202,7 @@ class Task {
171202
if (!this.account.openid) { this.log("跳过:变量值里没有 openid"); return; }
172203
try {
173204
await this.ensureLogin();
174-
await this.sign();
205+
await this.checkin_sign();
175206
} catch (e) {
176207
this.log(`执行失败: ${e.message || e}`);
177208
}

0 commit comments

Comments
 (0)