1- const cookieName = '顺丰速运'
2- const cookieKey = 'chavy_cookie_sfexpress'
31const chavy = init ( )
4- let cookieVal = chavy . getdata ( cookieKey )
2+ const cookieName = '顺丰速运'
3+ const KEY_loginurl = 'chavy_loginurl_sfexpress'
4+ const KEY_loginheader = 'chavy_loginheader_sfexpress'
5+
6+ const signinfo = { }
7+ let VAL_loginurl = chavy . getdata ( KEY_loginurl )
8+ let VAL_loginheader = chavy . getdata ( KEY_loginheader )
59
6- sign ( )
10+ ; ( sign = async ( ) => {
11+ chavy . log ( `🔔 ${ cookieName } ` )
12+ await loginapp ( )
13+ await signapp ( )
14+ await getinfo ( )
15+ showmsg ( )
16+ } ) ( ) . catch ( ( e ) => chavy . log ( `❌ ${ cookieName } 签到失败: ${ e } ` ) )
17+
18+ function loginapp ( ) {
19+ return new Promise ( ( resolve , reject ) => {
20+ const url = { url : VAL_loginurl , headers : { Cookie : '' } , opts : { redirection : false } }
21+ chavy . get ( url , ( error , response , data ) => {
22+ try {
23+ chavy . log ( `❕ ${ cookieName } loginapp - response: ${ JSON . stringify ( response ) } ` )
24+ const respcookie = response . headers [ 'Set-Cookie' ]
25+ if ( respcookie && respcookie . indexOf ( 'SESSION=' ) >= 0 ) {
26+ signinfo . SESSION = response . headers [ 'Set-Cookie' ] . match ( / S E S S I O N = ( [ ^ ; ] * ) / ) [ 0 ]
27+ } else {
28+ chavy . msg ( cookieName , `登录结果: 失败` , `说明: 请尝试杀掉 APP 重新获取Cookie` )
29+ }
30+ resolve ( )
31+ } catch ( e ) {
32+ chavy . msg ( cookieName , `登录结果: 失败` , `说明: ${ e } ` )
33+ chavy . log ( `❌ ${ cookieName } loginapp - 登录失败: ${ e } ` )
34+ chavy . log ( `❌ ${ cookieName } loginapp - response: ${ JSON . stringify ( response ) } ` )
35+ resolve ( )
36+ }
37+ } )
38+ } )
39+ }
740
8- function sign ( ) {
9- chavy . log ( `${ cookieName } , Cookie: ${ cookieVal } ` )
10- let url = { url : `https://sf-integral-sign-in.weixinjia.net/app/signin` , headers : { Cookie : cookieVal } }
11- url . headers [ 'Origin' ] = `https://sf-integral-sign-in.weixinjia.net`
12- url . headers [ 'Connection' ] = `keep-alive`
13- url . headers [ 'Content-Type' ] = `application/x-www-form-urlencoded`
14- url . headers [ 'Accept' ] = `application/json, text/plain, */*`
15- url . headers [ 'Host' ] = `sf-integral-sign-in.weixinjia.net`
16- url . headers [ 'User-Agent' ] = `Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 mediaCode=SFEXPRESSAPP-iOS-ML`
17- url . headers [ 'ontent-Length' ] = `15`
18- url . headers [ 'Accept-Language' ] = `zh-cn`
19- url . headers [ 'Accept-Encoding' ] = `gzip, deflate, br`
20- url . body = `date=${ new Date ( ) . getFullYear ( ) } -${ new Date ( ) . getMonth ( ) + 1 } -${ new Date ( ) . getDate ( ) } `
21- chavy . log ( `${ cookieName } , body: ${ url . body } ` )
22- chavy . post ( url , ( error , response , data ) => {
23- chavy . log ( `${ cookieName } , data: ${ data } ` )
24- const result = JSON . parse ( data )
25- const title = `${ cookieName } `
26- let subTitle = ``
27- let detail = ``
28- if ( result . code == 0 && result . msg == 'success' ) {
29- subTitle = `签到结果: 成功`
30- } else if ( result . code == - 1 ) {
31- if ( result . msg == 'ALREADY_CHECK' ) {
32- subTitle = `签到结果: 成功 (重复签到)`
33- } else {
34- subTitle = `签到结果: 失败`
41+ function signapp ( ) {
42+ return new Promise ( ( resolve , reject ) => {
43+ let url = { url : `https://sf-integral-sign-in.weixinjia.net/app/signin` , headers : JSON . parse ( VAL_loginheader ) }
44+ delete url . headers [ 'Cookie' ]
45+ url . headers [ 'Origin' ] = 'https://sf-integral-sign-in.weixinjia.net'
46+ url . headers [ 'Connection' ] = 'keep-alive'
47+ url . headers [ 'Content-Type' ] = 'application/x-www-form-urlencoded'
48+ url . headers [ 'Accept' ] = 'application/json, text/plain, */*'
49+ url . headers [ 'Host' ] = 'sf-integral-sign-in.weixinjia.net'
50+ url . headers [ 'Content-Length' ] = '15'
51+ url . headers [ 'Accept-Language' ] = 'zh-cn'
52+ url . headers [ 'Accept-Encoding' ] = 'gzip, deflate, br'
53+ url . body = `date=${ new Date ( ) . getFullYear ( ) } -${ new Date ( ) . getMonth ( ) + 1 } -${ new Date ( ) . getDate ( ) } `
54+ chavy . post ( url , ( error , response , data ) => {
55+ try {
56+ chavy . log ( `❕ ${ cookieName } signapp - response: ${ JSON . stringify ( response ) } ` )
57+ signinfo . signapp = JSON . parse ( data )
58+ resolve ( )
59+ } catch ( e ) {
60+ chavy . msg ( cookieName , `签到结果: 失败` , `说明: ${ e } ` )
61+ chavy . log ( `❌ ${ cookieName } signapp - 签到失败: ${ e } ` )
62+ chavy . log ( `❌ ${ cookieName } signapp - response: ${ JSON . stringify ( response ) } ` )
63+ resolve ( )
3564 }
65+ } )
66+ } )
67+ }
68+
69+ function getinfo ( ) {
70+ return new Promise ( ( resolve , reject ) => {
71+ let url = { url : `https://sf-integral-sign-in.weixinjia.net/app/init` , headers : JSON . parse ( VAL_loginheader ) }
72+ delete url . headers [ 'Cookie' ]
73+ url . headers [ 'Origin' ] = 'https://sf-integral-sign-in.weixinjia.net'
74+ url . headers [ 'Connection' ] = 'keep-alive'
75+ url . headers [ 'Content-Type' ] = 'application/x-www-form-urlencoded'
76+ url . headers [ 'Accept' ] = 'application/json, text/plain, */*'
77+ url . headers [ 'Host' ] = 'sf-integral-sign-in.weixinjia.net'
78+ url . headers [ 'Accept-Encoding' ] = 'gzip, deflate, br'
79+ url . headers [ 'Accept-Language' ] = 'zh-cn'
80+ url . headers [ 'Content-Length' ] = '0'
81+
82+ chavy . post ( url , ( error , response , data ) => {
83+ try {
84+ chavy . log ( `❕ ${ cookieName } getinfo - response: ${ JSON . stringify ( response ) } ` )
85+ signinfo . info = JSON . parse ( data )
86+ resolve ( )
87+ } catch ( e ) {
88+ chavy . msg ( cookieName , `获取信息: 失败` , `说明: ${ e } ` )
89+ chavy . log ( `❌ ${ cookieName } getinfo - 获取信息失败: ${ e } ` )
90+ chavy . log ( `❌ ${ cookieName } getinfo - response: ${ JSON . stringify ( response ) } ` )
91+ resolve ( )
92+ }
93+ } )
94+ } )
95+ }
96+
97+ function showmsg ( ) {
98+ let subTitle = ''
99+ let detail = ''
100+ if ( signinfo . signapp . code == 0 && signinfo . signapp . msg == 'success' ) {
101+ subTitle = `签到结果: 成功`
102+ } else if ( signinfo . signapp . code == - 1 ) {
103+ if ( signinfo . signapp . msg == 'ALREADY_CHECK' ) {
104+ subTitle = `签到结果: 成功 (重复签到)`
36105 } else {
37- subTitle = `签到结果: 未知`
38- detail = `说明: ${ result . msg } `
106+ subTitle = `签到结果: 失败`
39107 }
40- chavy . msg ( title , subTitle , detail )
41- } )
42- chavy . done ( )
108+ } else {
109+ subTitle = `签到结果: 未知`
110+ detail = `说明: ${ signinfo . signapp . msg } `
111+ }
112+
113+ if ( signinfo . info && signinfo . info . code == 0 ) {
114+ detail = `积分: ${ signinfo . info . data . member_info . integral } , 本周连签: ${ signinfo . info . data . check_count } 天`
115+ }
116+ chavy . msg ( cookieName , subTitle , detail )
43117}
44118
45119function init ( ) {
@@ -68,7 +142,7 @@ function init() {
68142 }
69143 if ( isQuanX ( ) ) {
70144 url . method = 'GET'
71- $task . fetch ( url ) . then ( ( resp ) => cb ( null , { } , resp . body ) )
145+ $task . fetch ( url ) . then ( ( resp ) => cb ( null , resp , resp . body ) )
72146 }
73147 }
74148 post = ( url , cb ) => {
@@ -77,7 +151,7 @@ function init() {
77151 }
78152 if ( isQuanX ( ) ) {
79153 url . method = 'POST'
80- $task . fetch ( url ) . then ( ( resp ) => cb ( null , { } , resp . body ) )
154+ $task . fetch ( url ) . then ( ( resp ) => cb ( null , resp , resp . body ) )
81155 }
82156 }
83157 done = ( value = { } ) => {
0 commit comments