//todo:转化时间戳为 yyyy-MM-dd hh:mm:ss
export const timeToString = (time)=>{
  const date = new Date(Number(time));
  const Y = date.getFullYear() + '-';
  const M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
  const D = (date.getDate() < 10 ? ('0' + date.getDate()) : date.getDate())+ ' ';
  const h = date.getHours() < 10 ? ('0' + date.getHours()) : date.getHours();
  const m = ':' + (date.getMinutes() < 10 ? ('0' + date.getMinutes()) : date.getMinutes()) + ':';
  const s = date.getSeconds() < 10 ? ('0' + date.getSeconds()) : date.getSeconds();
  return Y+M+D+h+m+s;
}

export const getBase64 = (file)=> {
  return new Promise((resolve, reject) => {
    const reader = new FileReader();
    reader.readAsDataURL(file);
    reader.onload = () => resolve(reader.result);
    reader.onerror = error => reject(error);
  });
}
