11const $ = new Env ( '万达电影' )
22$ . _mi_ = 'senku_wanda_mi_'
33$ . desc = [ ]
4- const ts = new Date ( ) . getTime ( )
5- const date = tTime ( ts )
6- const key = 'Wanda1_3B3AA12B0145E1982F282BEDD8A3305B89A9811280C0B8CC3A6A60D81022E4903' + ts
4+ const date = tTime ( new Date ( ) . getTime ( ) )
5+
6+ function getKey ( ) {
7+ const ts = new Date ( ) . getTime ( )
8+ const key = 'Wanda1_3B3AA12B0145E1982F282BEDD8A3305B89A9811280C0B8CC3A6A60D81022E4903' + ts
9+ return { 'key' :key , 'ts' :ts }
10+ }
711const mx_api = {
812 "ver" :"v1.0.0" ,
913 "sCode" :"Wanda" ,
@@ -12,18 +16,22 @@ const mx_api = {
1216 "json" :true ,
1317 "cCode" :"1_3" ,
1418 "check" :'' ,
15- "ts" :ts ,
19+ "ts" :0 ,
1620 "heigth" :720 ,
1721 "appId" :"3"
1822}
1923
2024! ( async ( ) => {
2125 await sign ( )
2226 await signRecord ( )
27+ await question_ ( )
2328 await question ( )
2429 await answer ( )
2530 await drawprize_ans ( )
2631 await drawprize_ans ( )
32+ if ( $ . signRecord . data . remainMedal >= 50 ) {
33+ await lottery ( )
34+ }
2735 await showmsg ( )
2836 } ) ( )
2937 . catch ( ( e ) => $ . logErr ( e ) )
@@ -33,7 +41,8 @@ const mx_api = {
3341
3442function sign ( ) {
3543 return new Promise ( ( resolve ) => {
36- const signVal = key + '/activityWholeSign/wholeSignUp.apiactivityCode=12786638&signDate=' + date
44+ const signVal = getKey ( ) [ 'key' ] + '/activityWholeSign/wholeSignUp.apiactivityCode=12786638&signDate=' + date
45+ mx_api [ 'ts' ] = getKey ( ) [ 'ts' ]
3746 mx_api [ 'check' ] = hex_md5 ( signVal )
3847 const url = {
3948 url :'https://activity-api-mx.wandafilm.com/activityWholeSign/wholeSignUp.api' ,
@@ -56,7 +65,8 @@ function sign() {
5665
5766function signRecord ( ) {
5867 return new Promise ( ( resolve ) => {
59- const signRecordVal = key + '/activityWholeSign/getSignRecord.apiactivityCode=12786638'
68+ const signRecordVal = getKey ( ) [ 'key' ] + '/activityWholeSign/getSignRecord.apiactivityCode=12786638'
69+ mx_api [ 'ts' ] = getKey ( ) [ 'ts' ]
6070 mx_api [ 'check' ] = hex_md5 ( signRecordVal )
6171 const url = {
6272 url :'https://activity-api-mx.wandafilm.com/activityWholeSign/getSignRecord.api' ,
@@ -77,10 +87,60 @@ function signRecord() {
7787 } )
7888}
7989
90+ function lottery ( ) {
91+ return new Promise ( ( resolve ) => {
92+ const signVal = getKey ( ) [ 'key' ] + '/activityWholeSign/prize/lottery.apiactivityCode=12786638&vcode=&requestId='
93+ mx_api [ 'ts' ] = getKey ( ) [ 'ts' ]
94+ mx_api [ 'check' ] = hex_md5 ( signVal )
95+ const url = {
96+ url :'https://activity-api-mx.wandafilm.com/activityWholeSign/prize/lottery.api' ,
97+ headers :{
98+ 'MX-API' :JSON . stringify ( mx_api ) ,
99+ } ,
100+ body : 'activityCode=12786638&vcode=&requestId='
101+ }
102+ $ . post ( url , ( err , resp , data ) => {
103+ try {
104+ $ . lottery = JSON . parse ( data )
105+ console . log ( data )
106+ } catch ( e ) {
107+ $ . logErr ( e , resp )
108+ } finally {
109+ resolve ( )
110+ }
111+ } )
112+ } )
113+ }
114+
115+ function question_ ( ) {
116+ return new Promise ( ( resolve ) => {
117+ const questionVal = getKey ( ) [ 'key' ] + '/question/qustion/strength.apiactivityCode=15884027'
118+ mx_api [ 'ts' ] = getKey ( ) [ 'ts' ]
119+ mx_api [ 'check' ] = hex_md5 ( questionVal )
120+ const url = {
121+ url :'https://activity-api-mx.wandafilm.com/question/qustion/strength.api' ,
122+ headers :{
123+ 'MX-API' :JSON . stringify ( mx_api ) ,
124+ } ,
125+ body : 'activityCode=15884027'
126+ }
127+ $ . post ( url , ( err , resp , data ) => {
128+ try {
129+ $ . log ( `尝试性报名答题` )
130+ } catch ( e ) {
131+ $ . logErr ( e , resp )
132+ } finally {
133+ resolve ( )
134+ }
135+ } )
136+ } )
137+ }
138+
80139// 获取题目答案
81140function question ( ) {
82141 return new Promise ( ( resolve ) => {
83- const questionVal = key + '/question/question_list.apiactivityCode=15884027'
142+ const questionVal = getKey ( ) [ 'key' ] + '/question/question_list.apiactivityCode=15884027'
143+ mx_api [ 'ts' ] = getKey ( ) [ 'ts' ]
84144 mx_api [ 'check' ] = hex_md5 ( questionVal )
85145 const url = {
86146 url :'https://activity-api-mx.wandafilm.com/question/question_list.api' ,
@@ -105,7 +165,8 @@ function question() {
105165// 答题
106166function answer ( ) {
107167 return new Promise ( ( resolve ) => {
108- const answerVal = key + '/question/qustion/answer.apiactivityCode=15884027&answer=%7b%221%22%3a%22' + escape ( `${ $ . answer } ` ) . toLowerCase ( ) + '%22%7d'
168+ const answerVal = getKey ( ) [ 'key' ] + '/question/qustion/answer.apiactivityCode=15884027&answer=%7b%221%22%3a%22' + escape ( `${ $ . answer } ` ) . toLowerCase ( ) + '%22%7d'
169+ mx_api [ 'ts' ] = getKey ( ) [ 'ts' ]
109170 mx_api [ 'check' ] = hex_md5 ( answerVal )
110171 const url = {
111172 url :'https://activity-api-mx.wandafilm.com/question/qustion/answer.api' ,
@@ -129,7 +190,8 @@ function answer() {
129190// 答题后抽奖
130191function drawprize_ans ( ) {
131192 return new Promise ( ( resolve ) => {
132- const drawprizeVal = key + '/question/prize/lottery.apiactivityCode=15884027'
193+ const drawprizeVal = getKey ( ) [ 'key' ] + '/question/prize/lottery.apiactivityCode=15884027'
194+ mx_api [ 'ts' ] = getKey ( ) [ 'ts' ]
133195 mx_api [ 'check' ] = hex_md5 ( drawprizeVal )
134196 const url = {
135197 url :'https://activity-api-mx.wandafilm.com/question/prize/lottery.api' ,
@@ -158,9 +220,10 @@ function showmsg() {
158220 if ( $ . signRecord . code == 1 ) {
159221 const totalMedal = $ . signRecord . data . totalMedal
160222 const remainMedal = $ . signRecord . data . remainMedal
161- $ . desc . push ( `本次获得 ${ totalMedal } 能量,剩余可用${ remainMedal } 能量` )
223+ $ . desc . push ( `总计获得 ${ totalMedal } 能量,剩余可用${ remainMedal } 能量` )
162224 }
163225 $ . subt += ` 答题详情:${ $ . answer . code == 1 ? `答案:${ $ . answer . data . answer } ,获得:${ $ . answer . data . remainChance } 次抽奖` :$ . answer . msg } `
226+ $ . lottery ? $ . desc . push ( `签到抽奖:${ $ . lottery . data . prize . prizeName } ` ) : ``
164227 $ . msg ( $ . name , $ . subt , $ . desc . join ( '\n' ) )
165228 resolve ( )
166229 } )
0 commit comments