| /* |
| * Licensed to the Apache Software Foundation (ASF) under one or more |
| * contributor license agreements. See the NOTICE file distributed with |
| * this work for additional information regarding copyright ownership. |
| * The ASF licenses this file to You under the Apache License, Version 2.0 |
| * (the "License"); you may not use this file except in compliance with |
| * the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| /** |
| * 一些工具类的集合 |
| */ |
| |
| //dataURL to blob, |
| export function dataUrlToBlob(dataURI){ |
| let mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; // mime类型 |
| let byteString = atob(dataURI.split(',')[1]); //base64 解码 |
| |
| let arrayBuffer = new ArrayBuffer(byteString.length); //创建缓冲数组 |
| let intArray = new Uint8Array(arrayBuffer); //创建视图 |
| |
| for (let i = 0; i < byteString.length; i++) { |
| intArray[i] = byteString.charCodeAt(i); |
| } |
| return new Blob([intArray], {type: mimeString}); |
| } |
| |
| export function format(time, format){ |
| var t = new Date(time); |
| var tf = function(i){return (i < 10 ? '0' : '') + i}; |
| return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function(a){ |
| switch(a){ |
| case 'yyyy': |
| return tf(t.getFullYear()); |
| break; |
| case 'MM': |
| return tf(t.getMonth() + 1); |
| break; |
| case 'mm': |
| return tf(t.getMinutes()); |
| break; |
| case 'dd': |
| return tf(t.getDate()); |
| break; |
| case 'HH': |
| return tf(t.getHours()); |
| break; |
| case 'ss': |
| return tf(t.getSeconds()); |
| break; |
| } |
| }) |
| } |
| |
| export function getArchivesName(code){ |
| let arr = { |
| '1': '身份证正面', |
| '11': '身份证反面', |
| '3': '行驶证主页', |
| '10': '行驶证附页', |
| '6': '车头45度照', |
| } |
| return arr[code] ? arr[code] : '--' |
| } |