|
@@ -149,31 +149,50 @@ export default {
|
|
// var fd = new FormData();
|
|
// var fd = new FormData();
|
|
// fd.append('file', this.base64Url2Blob(imgData));
|
|
// fd.append('file', this.base64Url2Blob(imgData));
|
|
// fd.append('innerPublic',true);
|
|
// fd.append('innerPublic',true);
|
|
- const config = {
|
|
|
|
- headers: {
|
|
|
|
- // 'Content-Type': 'multipart/form-data'
|
|
|
|
- 'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
|
- 'referer': 'https://xingyun.xiaojukeji.com'
|
|
|
|
- },
|
|
|
|
- // withCredentials: false
|
|
|
|
- } // 添加请求头
|
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
|
- axios.post(
|
|
|
|
- '//star.xiaojukeji.com/upload/img.node',
|
|
|
|
- // fd,
|
|
|
|
- {
|
|
|
|
- 'imgData': imgData,
|
|
|
|
- 'innerPublic': true
|
|
|
|
- },
|
|
|
|
- config
|
|
|
|
- ).then(res => {
|
|
|
|
- console.log(res)
|
|
|
|
- // newStr = newStr.replace(imgData, res.url)
|
|
|
|
- resolve(res.url)
|
|
|
|
- }).catch(err => {
|
|
|
|
- reject(err)
|
|
|
|
- })
|
|
|
|
|
|
+ // const config = {
|
|
|
|
+ // headers: {
|
|
|
|
+ // // 'Content-Type': 'multipart/form-data'
|
|
|
|
+ // 'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
|
+ // 'referer': 'https://xingyun.xiaojukeji.com'
|
|
|
|
+ // },
|
|
|
|
+ // // withCredentials: false
|
|
|
|
+ // } // 添加请求头
|
|
|
|
+ var HTTP = axios.create({
|
|
|
|
+ baseURL: '/apis', //这是基础url
|
|
|
|
+ headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
|
|
|
+ transformRequest: [function (data) {
|
|
|
|
+ // Do whatever you want to transform the data
|
|
|
|
+ let ret = ''
|
|
|
|
+ for (let it in data) {
|
|
|
|
+ ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
|
|
|
|
+ }
|
|
|
|
+ return ret
|
|
|
|
+ }]
|
|
})
|
|
})
|
|
|
|
+ HTTP.post('//star.xiaojukeji.com/upload/img.node',{
|
|
|
|
+ 'imgData': imgData,
|
|
|
|
+ 'innerPublic': true
|
|
|
|
+ })
|
|
|
|
+ .then(function(response){
|
|
|
|
+ console.log(response.data);
|
|
|
|
+ });
|
|
|
|
+ // return new Promise((resolve, reject) => {
|
|
|
|
+ // axios.post(
|
|
|
|
+ // '//star.xiaojukeji.com/upload/img.node',
|
|
|
|
+ // // fd,
|
|
|
|
+ // {
|
|
|
|
+ // 'imgData': imgData,
|
|
|
|
+ // 'innerPublic': true
|
|
|
|
+ // },
|
|
|
|
+ // config
|
|
|
|
+ // ).then(res => {
|
|
|
|
+ // console.log(res)
|
|
|
|
+ // // newStr = newStr.replace(imgData, res.url)
|
|
|
|
+ // resolve(res.url)
|
|
|
|
+ // }).catch(err => {
|
|
|
|
+ // reject(err)
|
|
|
|
+ // })
|
|
|
|
+ // })
|
|
},
|
|
},
|
|
base64Url2Blob (url) {
|
|
base64Url2Blob (url) {
|
|
// 将base64url通过 , 分割为含有两个元素的数组
|
|
// 将base64url通过 , 分割为含有两个元素的数组
|