Commit a07dc269 authored by 李俊赕's avatar 李俊赕

add-file

parent df65da14
...@@ -5,14 +5,6 @@ export default { ...@@ -5,14 +5,6 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
// domain: 'http://upload.qiniup.com', // 七牛上传域名地址
// uptokenURL: globalUrl.ucenterUrl.apiUrl + '/v1/tokens', // 上传token地址
// files:[], // 上传文件
// fileMaps:[], // 上传文件返回对象
// keys:[], // 七牛返回key
// uploadToken: '', // 上传token
// maximum:999, // 最大上传数量
// qiniuOptions: {}, // 七牛上传配置
imgList:[] imgList:[]
}; };
}, },
...@@ -21,6 +13,19 @@ export default { ...@@ -21,6 +13,19 @@ export default {
// this.initQiniu() // this.initQiniu()
}, },
methods: { methods: {
async uploadPath(type){
// 可以直接上传path
const self = this
let imgList = []
let options = {
files:[] // 文件路径
}
if(type==='qiniu'){
let res = await uploader.qnFileUpload(options)
return
}
let res = await uploader.urlFileUpload(options)
},
async chooseImage(type){ async chooseImage(type){
const self = this const self = this
let imgList = [] let imgList = []
......
import qiniuUploader from '@/include/libs/qiniuUploader.js'; import qiniuUploader from '../upload/qiniuUploader.js';
//七牛云上传文件命名 //七牛云上传文件命名
export const randomChar = function(l, url = "") { export const randomChar = function(l, url = "") {
const x = "0123456789qwertyuioplkjhgfdsazxcvbnm"; const x = "0123456789qwertyuioplkjhgfdsazxcvbnm";
......
...@@ -2,8 +2,7 @@ import request from "./request"; ...@@ -2,8 +2,7 @@ import request from "./request";
const globalUrl = process.uniEnv || {} const globalUrl = process.uniEnv || {}
let baseOptions = { let baseOptions = {
baseUrl: '', // 接口请求地址,用于图片上传域名配置 baseUrl: '', // 接口请求地址,用于图片上传域名配置
//服务器本地上传文件地址 fileUrl: '', //服务器本地上传文件地址
fileUrl: '',
defaultUploadUrl: "api/common/v1/upload_image", // 服务器上传图片默认url defaultUploadUrl: "api/common/v1/upload_image", // 服务器上传图片默认url
qiniuUploadUrl: globalUrl.ucenterUrl.apiUrl + '/v1/tokens', qiniuUploadUrl: globalUrl.ucenterUrl.apiUrl + '/v1/tokens',
//设置请求头(如果使用报错跨域问题,可能是content-type请求类型和后台那边设置的不一致) //设置请求头(如果使用报错跨域问题,可能是content-type请求类型和后台那边设置的不一致)
......
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
fileName = options.key; fileName = options.key;
} }
var formData = { var formData = {
'token': config.qiniuUploadToken 'token': config.qiniuUploadToken,
}; };
if (!config.qiniuShouldUseQiniuFileName) { if (!config.qiniuShouldUseQiniuFileName) {
formData['key'] = fileName formData['key'] = fileName
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment