You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

59 lines
1.6 KiB

import {_form, _post} from '../http/index'
import { baseUrl } from "../config/env";
import axios from 'axios';
const http = axios.create({
traditional: true,
contentType : "application/json",
timeout: 1000 * 500000, // 1 秒
});
const uploadFile = (files,callback) => {
files.status = "uploading";
files.message = "上传中...";
// 需要使用 FormData 进行文件上传
let form = new FormData();
form.append("file", files.file);
axios({
method: "post",
url: baseUrl+ "/app-enf/common/file/upload",
data: form,
headers: {
'Content-Type': 'multipart/form-data'
}
})
.then((res) => {
files.status = "done";
files.message = "上传成功";
callback && callback(res);
})
.catch((err) => {
files.status = "failed";
files.message = "上传失败";
console.log(err);
});
}
const nameCorrect=(name)=>{
//筛选出两个字人名
let name1=[{}];
name1=String(name).split(" ");
// console.log(name1);
if(name1[0].length==2){
if(name1.length>1){
return (String(name1[0]).substr(0,1)+"\u3000"+String(name1[0]).substr(1)+" "+name1[1]);
}else{
return (String(name1[0]).substr(0,1)+"\u3000"+String(name1[0]).substr(1));
}
}else{
return name;
}
}
// 手机号加密
const encryptPhone=(num)=>{
if(!/^\d{11}$/.test(num))return num;
const al= num.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
return al;
}
export{uploadFile,nameCorrect,encryptPhone};