1
+ import axios from 'axios'
2
+
1
3
export default function ( ) {
2
4
const { $, ecomUtils, callApi, formatPhone, tabId, routeParams } = window
3
5
const store = window . Store || { }
@@ -162,13 +164,14 @@ export default function () {
162
164
$appTab . find ( '.tags:last-child' ) . after ( $shippingTags )
163
165
$appTab . find ( '.spinner-linear' ) . remove ( )
164
166
$appTab . find ( '.doc-correios' ) . click ( ( ) => {
165
- let url = 'https://declaracao-correios.netlify.app/?'
167
+ const url = 'https://app.ecomplus.io/extra/declaracao-correios'
168
+ const body = { pedidos : [ ] }
166
169
data . result . forEach ( ( order , i ) => {
167
170
if ( order . shipping_lines && order . shipping_lines [ 0 ] ) {
168
171
const { to, from } = order . shipping_lines [ 0 ]
169
172
if ( from && to ) {
170
173
const pkg = order . shipping_lines [ 0 ] . package
171
- url += `&pedido= ${ encodeURIComponent ( JSON . stringify ( {
174
+ body . pedidos . push ( {
172
175
remNome : from . name || store . corporate_name ,
173
176
remEndereco : `${ from . street } , ${ from . number } , ${ ( from . borough || '' ) } ` ,
174
177
remLinha2 : `${ ( from . complement || '' ) } - ${ ( from . near_to || '' ) } ` ,
@@ -190,17 +193,19 @@ export default function () {
190
193
} ) ) ,
191
194
peso : pkg && pkg . weight
192
195
? ( ! pkg . weight . unit || pkg . weight . unit === 'kg' )
193
- ? pkg . weight . value
194
- : pkg . weight . unit === 'g'
195
- ? pkg . weight . value / 1000
196
- : undefined
196
+ ? pkg . weight . value
197
+ : pkg . weight . unit === 'g'
198
+ ? pkg . weight . value / 1000
199
+ : undefined
197
200
: undefined
198
- } ) ) } `
201
+ } )
199
202
}
200
203
}
201
204
} )
202
- const win = window . open ( url , '_blank' )
203
- win . focus ( )
205
+ axios . post ( url , body ) . then ( ( ) => {
206
+ const win = window . open ( url , '_blank' )
207
+ win . focus ( )
208
+ } )
204
209
} )
205
210
}
206
211
}
0 commit comments