feat: tell the customer how long the upload takes before it starts
When files are picked, the product page shows the range the upload takes between a slow (10 Mbps) and a fast (150 Mbps) connection, and asks to keep the page open. The cart shows the same range until the real speed is measured, then the measured time left. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -96,6 +96,25 @@ const destinoApi=()=>entrega.tipo!=='frete' ? null : {
|
||||
recipient:entrega.end.nome.trim(), street:entrega.end.rua.trim(), number:entrega.end.num.trim(),
|
||||
complement:(entrega.end.comp||'').trim(), district:entrega.end.bairro.trim(),
|
||||
city:entrega.end.cidade.trim(), state:entrega.end.uf.trim().toUpperCase(), postal_code:entrega.cep};
|
||||
// Tempo de envio antes de medir a internet de quem compra: uma faixa entre um
|
||||
// upload lento (10 Mbps) e um rápido (150 Mbps). O arquivo vai direto para o
|
||||
// armazenamento, então é o upload do cliente que manda.
|
||||
const ENVIO_LENTO=10e6/8, ENVIO_RAPIDO=150e6/8, ENVIO_AVISA_S=120;
|
||||
const duracao=s=>{
|
||||
const min=Math.ceil(s/60);
|
||||
return s<60 ? 'menos de 1 min' : min<60 ? min+' min' : Math.floor(min/60)+' h'+(min%60? ' '+min%60+' min' : '');
|
||||
};
|
||||
const faixaEnvio=bytes=>'de '+duracao(bytes/ENVIO_RAPIDO)+' a '+duracao(bytes/ENVIO_LENTO);
|
||||
function pintaAvisoEnvio(){
|
||||
const el=$('avisoEnvio'); if(!el) return;
|
||||
const total=(ehFolha()?folhas:artes).reduce((t,x)=>t+(x.f?.size||0),0);
|
||||
el.hidden = total/ENVIO_LENTO < ENVIO_AVISA_S;
|
||||
if(el.hidden) return;
|
||||
el.innerHTML='<b>O envio '+((ehFolha()?folhas:artes).length>1?'destes arquivos':'deste arquivo')+
|
||||
' ('+fmt(total)+') leva '+faixaEnvio(total)+'</b>, conforme a velocidade de upload da sua internet. '+
|
||||
'Ele começa quando você coloca o item no carrinho e continua enquanto você preenche os dados. '+
|
||||
'<b>Mantenha a página aberta até terminar.</b>';
|
||||
}
|
||||
const larguraFilme=()=>MODOS[modo].larg;
|
||||
// cobrança proporcional: arredonda para cima em 10 cm · 2,75 m vira 2,80 m
|
||||
const cobrar=m=>Math.max(MINIMO_M, Math.ceil(m*10)/10);
|
||||
|
||||
Reference in New Issue
Block a user