@@ -85,20 +85,45 @@ async function doTask() {
8585 var detailBody = { "groupId" : item . matGrpId , "stageId" : stageId , "subTitleId" : item . subTitleId , "batchId" : item . batchId , "skuId" : "" , "taskId" : Number ( item . taskId ) }
8686 var goldCreatorDetail = await doGet ( "https://api.m.jd.com/client.action?functionId=goldCreatorDetail&body=" + encodeURIComponent ( JSON . stringify ( detailBody ) ) + "&appid=content_ecology&clientVersion=10.0.0&client=wh5" )
8787 if ( goldCreatorDetail . isSuccess == true ) {
88- var sku = goldCreatorDetail . result . skuList [ 0 ] ;
89- var taskbody = { "stageId" : stageId , "subTitleId" : item . subTitleId , "skuId" : sku . skuId , "taskId" : Number ( item . taskId ) , "itemId" : "3" , "rankId" : sku . rankId , "type" : 1 , "batchId" : item . batchId }
90- var goldCreatorDoTask = await doGet ( "https://api.m.jd.com/client.action?functionId=goldCreatorDoTask&body=" + encodeURIComponent ( JSON . stringify ( taskbody ) ) + "&appid=content_ecology&clientVersion=10.0.0&client=wh5" ) ;
91- await $ . wait ( 1000 ) ;
92- if ( goldCreatorDoTask . isSuccess == true ) {
93- message += item . shortTitle + "---" + sku . name + "---" + JSON . stringify ( goldCreatorDoTask . result ) + "\n"
88+ //主题投票
89+ if ( goldCreatorDetail . result . skuList [ 0 ] != undefined ) {
90+ var sku = goldCreatorDetail . result . skuList [ 0 ] ;
91+ var taskBody = { "stageId" : stageId , "subTitleId" : item . subTitleId , "skuId" : sku . skuId , "taskId" : Number ( item . taskId ) , "itemId" : "3" , "rankId" : sku . rankId , "type" : 1 , "batchId" : item . batchId }
92+ var goldCreatorDoTask = await doGet ( "https://api.m.jd.com/client.action?functionId=goldCreatorDoTask&body=" + encodeURIComponent ( JSON . stringify ( taskBody ) ) + "&appid=content_ecology&clientVersion=10.0.0&client=wh5" ) ;
93+ await $ . wait ( 500 ) ;
94+ if ( goldCreatorDoTask . isSuccess == true ) {
95+ message += "主题:" + item . shortTitle + "---投票:" + sku . name + "\n" ;
96+ message += "投票结果:" + JSON . stringify ( goldCreatorDoTask . result ) + "\n" ;
97+ }
98+ else {
99+ console . log ( '执行投票任务失败' ) ;
100+ }
94101 }
95- else {
96- console . log ( '获取goldCreatorDoTask失败' ) ;
102+ //额外任务
103+ if ( goldCreatorDetail . result . taskList != undefined ) {
104+ for ( let task of taskList ) {
105+ if ( task . taskStatus == 1 ) {
106+ var taskBody = { "taskId" : Number ( task . taskId ) , "itemId" : task . taskItemInfo . itemId , "taskType" : task . taskType , "batchId" : "1" }
107+ var goldCreatorDoTask = await doGet ( "https://api.m.jd.com/client.action?functionId=goldCreatorDoTask&body=" + encodeURIComponent ( JSON . stringify ( taskBody ) ) + "&appid=content_ecology&clientVersion=10.0.0&client=wh5" ) ;
108+ await $ . wait ( 500 ) ;
109+ if ( goldCreatorDoTask . isSuccess == true ) {
110+ message += "执行任务:" + task . taskName + "----" + task . taskItemInfo . title + "\n" ;
111+ message += "执行结果:" + JSON . stringify ( goldCreatorDoTask . result ) + "\n" ;
112+ }
113+ else {
114+ console . log ( '执行额外任务失败' ) ;
115+ }
116+ } else if ( task . taskStatus == 2 ) {
117+ message += task . taskName + "----" + task . taskItemInfo . title + "---" + "任务已完成\n" ;
118+
119+ }
120+ }
97121 }
98122 }
99123 }
124+
100125 } else {
101- console . log ( '获取goldCreatorTab失败 ' ) ;
126+ console . log ( '获取主题tab失败 ' ) ;
102127 }
103128 await showMsg ( )
104129 } catch ( e ) {
@@ -138,7 +163,6 @@ function doGet(url) {
138163 } )
139164
140165}
141-
142166function doPost ( url , headers , body ) {
143167 return new Promise ( async resolve => {
144168 //console.log(body);
0 commit comments