$(
'body'
).append(
'<div class="pdd-go-to-app" id="export">导出数据</div>'
)
$(
'#export'
).click(
function
(){
var
scrollBottom = setInterval(scrollToBottom, 500);
function
scrollToBottom() {
var
tisp = $(
'.loading-text'
).text();
console.log(tisp)
if
(tisp ==
"您已经没有更多的订单了"
){
var
order = [];
clearInterval(scrollBottom);
var
listOrder = $(
'#base-list0>.react-base-list'
).children();
$.each(listOrder,
function
(index,row){
order.push($(row)[0].innerText.split(
'\n\n'
))
if
(index == listOrder.length - 1){
let
orderlist =
'店铺名称,交易状态,商品名称,型号分类,价格,数量,实际付款\r\n'
$.each(order,
function
(index1,row1){
console.log(row1)
if
(row1.length == 9){
let
price = row1[4].split(
'\n'
);
orderlist += `${row1[0].replace(/\r|\n|\r\n|\n\r|\t|,/ig,
""
) +
','
+ row1[1] +
','
+ row1[2].replace(/\r|\n|\r\n|\n\r|\t|,/ig,
""
) +
','
+ row1[3].replace(/\r|\n|\r\n|\n\r|\t|,/ig,
""
)+
','
+price[0] +
','
+ price[1] +
','
+ row1[6] }\r\n`
}
else
{
let
price = row1[3].split(
'\n'
);
orderlist += `${row1[0].replace(/\r|\n|\r\n|\n\r|\t|,/ig,
""
) +
','
+ row1[1] +
','
+ row1[2].replace(/\r|\n|\r\n|\n\r|\t|,/ig,
""
) +
',null,'
+price[0] +
','
+ price[1] +
','
+ row1[5] }\r\n`
}
if
(index1 == order.length - 1){
const uri =
'data:text/csv;charset=utf-8,\ufeff'
+ encodeURIComponent(orderlist);
const link = document.createElement(
"a"
);
link.href = uri;
link.download = `${
'拼多多订单数据'
+
'.csv'
}`;
link.click();
}
})
}
})
}
$(
"html, body"
).animate({ scrollTop: $(document).height() }, 500);
}
})