@@ -42,18 +42,18 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
42
42
exports . __esModule = true ;
43
43
var axios_1 = require ( "axios" ) ;
44
44
var path = require ( "path" ) ;
45
- var sendNotify_1 = require ( "./sendNotify" ) ;
46
45
var fs_1 = require ( "fs" ) ;
47
46
var TS_USER_AGENTS_1 = require ( "./TS_USER_AGENTS" ) ;
48
- var cookie = '' , UserName , index , allMessage = '' , res = '' , message = '' ;
47
+ var pushplus_1 = require ( "./utils/pushplus" ) ;
48
+ var cookie = '' , UserName , allMessage = '' , res = '' , message = '' ;
49
49
! ( function ( ) { return __awaiter ( void 0 , void 0 , void 0 , function ( ) {
50
- var cookiesArr , except , orders , i , _i , _a , order , orderId , orderType , title , t , status_1 , carrier , carriageId , account , _b , account_1 , acc ;
51
- var _c , _d ;
52
- return __generator ( this , function ( _e ) {
53
- switch ( _e . label ) {
50
+ var cookiesArr , except , orders , _i , _a , _b , index , value , markdown , i , _c , _d , order , orderId , orderType , title , t , status_1 , carrier , carriageId , account , _e , account_1 , acc ;
51
+ var _f , _g ;
52
+ return __generator ( this , function ( _h ) {
53
+ switch ( _h . label ) {
54
54
case 0 : return [ 4 /*yield*/ , ( 0 , TS_USER_AGENTS_1 . requireConfig ) ( ) ] ;
55
55
case 1 :
56
- cookiesArr = _e . sent ( ) ;
56
+ cookiesArr = _h . sent ( ) ;
57
57
except = ( 0 , TS_USER_AGENTS_1 . exceptCookie ) ( path . basename ( __filename ) ) ;
58
58
orders = { } ;
59
59
if ( ( 0 , fs_1 . existsSync ) ( './json' ) ) {
@@ -68,38 +68,39 @@ var cookie = '', UserName, index, allMessage = '', res = '', message = '';
68
68
( 0 , fs_1 . mkdirSync ) ( './json' ) ;
69
69
( 0 , fs_1 . writeFileSync ) ( './json/jd_track.json' , '{}' ) ;
70
70
}
71
- i = 0 ;
72
- _e . label = 2 ;
71
+ _i = 0 , _a = cookiesArr . entries ( ) ;
72
+ _h . label = 2 ;
73
73
case 2 :
74
- if ( ! ( i < cookiesArr . length ) ) return [ 3 /*break*/ , 11 ] ;
75
- cookie = cookiesArr [ i ] ;
74
+ if ( ! ( _i < _a . length ) ) return [ 3 /*break*/ , 13 ] ;
75
+ _b = _a [ _i ] , index = _b [ 0 ] , value = _b [ 1 ] ;
76
+ cookie = value ;
76
77
UserName = decodeURIComponent ( cookie . match ( / p t _ p i n = ( [ ^ ; ] * ) / ) [ 1 ] ) ;
77
- index = i + 1 ;
78
- console . log ( "\n\u5F00\u59CB\u3010\u4EAC\u4E1C\u8D26\u53F7" . concat ( index , "\u3011" ) . concat ( UserName , "\n" ) ) ;
78
+ console . log ( "\n\u5F00\u59CB\u3010\u4EAC\u4E1C\u8D26\u53F7" . concat ( index + 1 , "\u3011" ) . concat ( UserName , "\n" ) ) ;
79
79
if ( except . includes ( encodeURIComponent ( UserName ) ) ) {
80
80
console . log ( '已设置跳过' ) ;
81
- return [ 3 /*break*/ , 10 ] ;
81
+ return [ 3 /*break*/ , 12 ] ;
82
82
}
83
83
message = '' ;
84
+ markdown = "" , i = 1 ;
84
85
return [ 4 /*yield*/ , getOrderList ( ) ] ;
85
86
case 3 :
86
- res = _e . sent ( ) ;
87
+ res = _h . sent ( ) ;
87
88
return [ 4 /*yield*/ , ( 0 , TS_USER_AGENTS_1 . wait ) ( 2000 ) ] ;
88
89
case 4 :
89
- _e . sent ( ) ;
90
- _i = 0 , _a = res . orderList ;
91
- _e . label = 5 ;
90
+ _h . sent ( ) ;
91
+ _c = 0 , _d = res . orderList ;
92
+ _h . label = 5 ;
92
93
case 5 :
93
- if ( ! ( _i < _a . length ) ) return [ 3 /*break*/ , 8 ] ;
94
- order = _a [ _i ] ;
94
+ if ( ! ( _c < _d . length ) ) return [ 3 /*break*/ , 8 ] ;
95
+ order = _d [ _c ] ;
95
96
orderId = order . orderId ;
96
97
orderType = order . orderType ;
97
98
title = order . productList [ 0 ] . title ;
98
- t = ( ( _c = order . progressInfo ) === null || _c === void 0 ? void 0 : _c . tip ) || null ;
99
- status_1 = ( ( _d = order . progressInfo ) === null || _d === void 0 ? void 0 : _d . content ) || null ;
99
+ t = ( ( _f = order . progressInfo ) === null || _f === void 0 ? void 0 : _f . tip ) || null ;
100
+ status_1 = ( ( _g = order . progressInfo ) === null || _g === void 0 ? void 0 : _g . content ) || null ;
100
101
return [ 4 /*yield*/ , getWuliu ( orderId , orderType ) ] ;
101
102
case 6 :
102
- res = _e . sent ( ) ;
103
+ res = _h . sent ( ) ;
103
104
carrier = res . carrier , carriageId = res . carriageId ;
104
105
if ( t && status_1 ) {
105
106
if ( status_1 . match ( / (? = 签 收 | 已 取 走 | 已 暂 存 ) / ) )
@@ -109,6 +110,7 @@ var cookie = '', UserName, index, allMessage = '', res = '', message = '';
109
110
console . log ( ) ;
110
111
if ( Object . keys ( orders ) . indexOf ( orderId ) > - 1 && orders [ orderId ] [ 'status' ] !== status_1 ) {
111
112
message += "" . concat ( title , "\n" ) . concat ( carrier , " " ) . concat ( carriageId , "\n" ) . concat ( t , " " ) . concat ( status_1 , "\n\n" ) ;
113
+ markdown += "" . concat ( i ++ , ". " ) . concat ( title , "\n\t- " ) . concat ( carrier , " " ) . concat ( carriageId , "\n\t- " ) . concat ( t , " " ) . concat ( status_1 , "\n" ) ;
112
114
}
113
115
orders [ orderId ] = {
114
116
user : UserName ,
@@ -119,36 +121,39 @@ var cookie = '', UserName, index, allMessage = '', res = '', message = '';
119
121
carriageId : carriageId
120
122
} ;
121
123
}
122
- _e . label = 7 ;
124
+ _h . label = 7 ;
123
125
case 7 :
124
- _i ++ ;
126
+ _c ++ ;
125
127
return [ 3 /*break*/ , 5 ] ;
126
128
case 8 :
127
- if ( message ) {
128
- message = "<\u4EAC\u4E1C\u8D26\u53F7" . concat ( i + 1 , "> " ) . concat ( UserName , "\n\n" ) . concat ( message ) ;
129
- allMessage += message ;
130
- }
131
- return [ 4 /*yield*/ , ( 0 , TS_USER_AGENTS_1 . wait ) ( 1000 ) ] ;
129
+ console . log ( markdown ) ;
130
+ if ( ! ( message || markdown ) ) return [ 3 /*break*/ , 10 ] ;
131
+ message = "<\u4EAC\u4E1C\u8D26\u53F7" . concat ( i + 1 , "> " ) . concat ( UserName , "\n\n" ) . concat ( message ) ;
132
+ markdown = "#### <" . concat ( UserName , ">\n" ) . concat ( markdown ) ;
133
+ // await pushplus(message)
134
+ return [ 4 /*yield*/ , ( 0 , pushplus_1 . pushplus ) ( '京东快递更新' , markdown , 'markdown' )
135
+ // allMessage += message
136
+ ] ;
132
137
case 9 :
133
- _e . sent ( ) ;
134
- _e . label = 10 ;
135
- case 10 :
136
- i ++ ;
137
- return [ 3 /*break*/ , 2 ] ;
138
+ // await pushplus(message)
139
+ _h . sent ( ) ;
140
+ _h . label = 10 ;
141
+ case 10 : return [ 4 /*yield*/ , ( 0 , TS_USER_AGENTS_1 . wait ) ( 1000 ) ] ;
138
142
case 11 :
143
+ _h . sent ( ) ;
144
+ _h . label = 12 ;
145
+ case 12 :
146
+ _i ++ ;
147
+ return [ 3 /*break*/ , 2 ] ;
148
+ case 13 :
139
149
orders = JSON . stringify ( orders , null , 2 ) ;
140
150
account = JSON . parse ( ( 0 , fs_1 . readFileSync ) ( './utils/account.json' ) . toString ( ) || '[]' ) || [ ] ;
141
- for ( _b = 0 , account_1 = account ; _b < account_1 . length ; _b ++ ) {
142
- acc = account_1 [ _b ] ;
151
+ for ( _e = 0 , account_1 = account ; _e < account_1 . length ; _e ++ ) {
152
+ acc = account_1 [ _e ] ;
143
153
orders = orders . replace ( new RegExp ( decodeURIComponent ( acc [ 'pt_pin' ] ) , 'g' ) , acc [ 'remarks' ] ) ;
144
154
}
145
155
( 0 , fs_1 . writeFileSync ) ( './json/jd_track.json' , orders ) ;
146
- if ( ! allMessage ) return [ 3 /*break*/ , 13 ] ;
147
- return [ 4 /*yield*/ , ( 0 , sendNotify_1 . sendNotify ) ( '京东快递更新' , allMessage ) ] ;
148
- case 12 :
149
- _e . sent ( ) ;
150
- _e . label = 13 ;
151
- case 13 : return [ 2 /*return*/ ] ;
156
+ return [ 2 /*return*/ ] ;
152
157
}
153
158
} ) ;
154
159
} ) ; } ) ( ) ;
0 commit comments