import { get, upload } from "./http"; const prefix = 'devicesApi/picture/upload'; const prefixObs = 'devicesApi/picture/obs-upload'; export default { /** * 上传图片(已过时) * @param {*} uri 图片地址 * @param {*} mime 图片类型 * @param {*} type 图片分类 ↓ * USER_PROFILE 用户头像 * FEEDBACK 用户反馈 * SERVICE_LOGO 服务提供商logo * SITE 站点 * PDVL 驾驶证 * @returns 服务器路径 */ uploadImageOld(uri, mime, type) { let data = new FormData(); data.append('file', { uri: uri, type: mime, name: getFileName(uri) }); return upload(prefix, data, {photoSubDir: type}); }, uploadImage(uri, mime, type="") { let data = new FormData(); data.append('file', { uri: uri, type: mime, name: getFileName(uri) }); return upload(prefixObs, data, {photoSubDir: type}); }, testNotification() { return get('devicesApi/googleNotification/doNotification'); } } const getFileName = (path) => { var pos = path.lastIndexOf("/"); var name = path.substring(pos+1); return name; }