@@ -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 } ` )
0 commit comments