|  | @@ -3,7 +3,7 @@ import appConst from './appConst'
 | 
												
													
														
															|  |  import * as qiniu from 'qiniu-js'
 |  |  import * as qiniu from 'qiniu-js'
 | 
												
													
														
															|  |  // var qiniu = require('qiniu-js')
 |  |  // var qiniu = require('qiniu-js')
 | 
												
													
														
															|  |  //请求mongodb的get
 |  |  //请求mongodb的get
 | 
												
													
														
															|  | -window.axios=axios
 |  | 
 | 
												
													
														
															|  | 
 |  | +window.axios = axios
 | 
												
													
														
															|  |  export const get = (url, query) => {
 |  |  export const get = (url, query) => {
 | 
												
													
														
															|  |    const token = 'Bearer ' + window.localStorage.token
 |  |    const token = 'Bearer ' + window.localStorage.token
 | 
												
													
														
															|  |    const loginId = window.localStorage.loginId
 |  |    const loginId = window.localStorage.loginId
 | 
												
											
												
													
														
															|  | @@ -15,8 +15,7 @@ export const get = (url, query) => {
 | 
												
													
														
															|  |      _url = `${appConst.BACKEND_DOMAIN}${url}`
 |  |      _url = `${appConst.BACKEND_DOMAIN}${url}`
 | 
												
													
														
															|  |    }
 |  |    }
 | 
												
													
														
															|  |    return axios.get(_url, {
 |  |    return axios.get(_url, {
 | 
												
													
														
															|  | -    headers: { authorization: token, loginId: loginId }
 |  | 
 | 
												
													
														
															|  | -  })
 |  | 
 | 
												
													
														
															|  | 
 |  | +    })
 | 
												
													
														
															|  |      .then((res) => {
 |  |      .then((res) => {
 | 
												
													
														
															|  |        if (res.status >= 200 && res.status < 300) {
 |  |        if (res.status >= 200 && res.status < 300) {
 | 
												
													
														
															|  |          return res.data
 |  |          return res.data
 | 
												
											
												
													
														
															|  | @@ -29,12 +28,8 @@ export const get = (url, query) => {
 | 
												
													
														
															|  |  }
 |  |  }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |  export const post = (url, query) => {
 |  |  export const post = (url, query) => {
 | 
												
													
														
															|  | -  const token = 'Bearer ' + window.localStorage.token
 |  | 
 | 
												
													
														
															|  | -  const loginId = window.localStorage.getItem('loginId')
 |  | 
 | 
												
													
														
															|  |    let _url = `${appConst.BACKEND_DOMAIN}${url}`
 |  |    let _url = `${appConst.BACKEND_DOMAIN}${url}`
 | 
												
													
														
															|  | -  return axios.post(_url, query, {
 |  | 
 | 
												
													
														
															|  | -    headers: { authorization: token, loginId: loginId  }
 |  | 
 | 
												
													
														
															|  | -  })
 |  | 
 | 
												
													
														
															|  | 
 |  | +  return axios.post(_url, query, {})
 | 
												
													
														
															|  |      .then((res) => {
 |  |      .then((res) => {
 | 
												
													
														
															|  |        if (res.status >= 200 && res.status < 300) {
 |  |        if (res.status >= 200 && res.status < 300) {
 | 
												
													
														
															|  |          return res.data
 |  |          return res.data
 | 
												
											
												
													
														
															|  | @@ -52,8 +47,11 @@ export const uploadPsd = (url, query) => {
 | 
												
													
														
															|  |    const loginId = window.localStorage.getItem('loginId')
 |  |    const loginId = window.localStorage.getItem('loginId')
 | 
												
													
														
															|  |    let _url = `${appConst.BACKEND_DOMAIN}${url}`
 |  |    let _url = `${appConst.BACKEND_DOMAIN}${url}`
 | 
												
													
														
															|  |    return axios.post(_url, query, {
 |  |    return axios.post(_url, query, {
 | 
												
													
														
															|  | -    headers: { authorization: token, loginId: loginId  }
 |  | 
 | 
												
													
														
															|  | -  })
 |  | 
 | 
												
													
														
															|  | 
 |  | +      headers: {
 | 
												
													
														
															|  | 
 |  | +        authorization: token,
 | 
												
													
														
															|  | 
 |  | +        loginId: loginId
 | 
												
													
														
															|  | 
 |  | +      }
 | 
												
													
														
															|  | 
 |  | +    })
 | 
												
													
														
															|  |      .then((res) => {
 |  |      .then((res) => {
 | 
												
													
														
															|  |        if (res.status >= 200 && res.status < 300) {
 |  |        if (res.status >= 200 && res.status < 300) {
 | 
												
													
														
															|  |          return res.data
 |  |          return res.data
 | 
												
											
												
													
														
															|  | @@ -70,8 +68,11 @@ export const put = (url, query) => {
 | 
												
													
														
															|  |    const loginId = window.localStorage.loginId
 |  |    const loginId = window.localStorage.loginId
 | 
												
													
														
															|  |    let _url = `${appConst.BACKEND_DOMAIN}${url}`
 |  |    let _url = `${appConst.BACKEND_DOMAIN}${url}`
 | 
												
													
														
															|  |    return axios.put(_url, query, {
 |  |    return axios.put(_url, query, {
 | 
												
													
														
															|  | -    headers: { authorization: token, loginId: loginId  }
 |  | 
 | 
												
													
														
															|  | -  })
 |  | 
 | 
												
													
														
															|  | 
 |  | +      headers: {
 | 
												
													
														
															|  | 
 |  | +        authorization: token,
 | 
												
													
														
															|  | 
 |  | +        loginId: loginId
 | 
												
													
														
															|  | 
 |  | +      }
 | 
												
													
														
															|  | 
 |  | +    })
 | 
												
													
														
															|  |      .then((res) => {
 |  |      .then((res) => {
 | 
												
													
														
															|  |        if (res.status >= 200 && res.status < 300) {
 |  |        if (res.status >= 200 && res.status < 300) {
 | 
												
													
														
															|  |          return res.data
 |  |          return res.data
 | 
												
											
												
													
														
															|  | @@ -88,8 +89,11 @@ export const patch = (url, query) => {
 | 
												
													
														
															|  |    const loginId = window.localStorage.getItem('loginId')
 |  |    const loginId = window.localStorage.getItem('loginId')
 | 
												
													
														
															|  |    let _url = `${appConst.BACKEND_DOMAIN}${url}`
 |  |    let _url = `${appConst.BACKEND_DOMAIN}${url}`
 | 
												
													
														
															|  |    return axios.patch(_url, query, {
 |  |    return axios.patch(_url, query, {
 | 
												
													
														
															|  | -    headers: { authorization: token, loginId: loginId  }
 |  | 
 | 
												
													
														
															|  | -  })
 |  | 
 | 
												
													
														
															|  | 
 |  | +      headers: {
 | 
												
													
														
															|  | 
 |  | +        authorization: token,
 | 
												
													
														
															|  | 
 |  | +        loginId: loginId
 | 
												
													
														
															|  | 
 |  | +      }
 | 
												
													
														
															|  | 
 |  | +    })
 | 
												
													
														
															|  |      .then((res) => {
 |  |      .then((res) => {
 | 
												
													
														
															|  |        if (res.status >= 200 && res.status < 300) {
 |  |        if (res.status >= 200 && res.status < 300) {
 | 
												
													
														
															|  |          return res.data
 |  |          return res.data
 | 
												
											
												
													
														
															|  | @@ -106,8 +110,11 @@ export const del = (url, article) => {
 | 
												
													
														
															|  |    const loginId = window.localStorage.getItem('loginId')
 |  |    const loginId = window.localStorage.getItem('loginId')
 | 
												
													
														
															|  |    let _url = `${appConst.BACKEND_DOMAIN}${url}/${article._id}`
 |  |    let _url = `${appConst.BACKEND_DOMAIN}${url}/${article._id}`
 | 
												
													
														
															|  |    return axios.delete(_url, {
 |  |    return axios.delete(_url, {
 | 
												
													
														
															|  | -    headers: { authorization: token, loginId: loginId  }
 |  | 
 | 
												
													
														
															|  | -  })
 |  | 
 | 
												
													
														
															|  | 
 |  | +      headers: {
 | 
												
													
														
															|  | 
 |  | +        authorization: token,
 | 
												
													
														
															|  | 
 |  | +        loginId: loginId
 | 
												
													
														
															|  | 
 |  | +      }
 | 
												
													
														
															|  | 
 |  | +    })
 | 
												
													
														
															|  |      .then((res) => {
 |  |      .then((res) => {
 | 
												
													
														
															|  |        if (res.status >= 200 && res.status < 300) {
 |  |        if (res.status >= 200 && res.status < 300) {
 | 
												
													
														
															|  |          return res.data
 |  |          return res.data
 | 
												
											
												
													
														
															|  | @@ -151,8 +158,9 @@ export const getQiniuToken = (url, query) => {
 | 
												
													
														
															|  |   * @returns {string} 类似java中的String.getUUID方法所返回的值
 |  |   * @returns {string} 类似java中的String.getUUID方法所返回的值
 | 
												
													
														
															|  |   */
 |  |   */
 | 
												
													
														
															|  |  function getUUID() {
 |  |  function getUUID() {
 | 
												
													
														
															|  | -  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
 |  | 
 | 
												
													
														
															|  | -    var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
 |  | 
 | 
												
													
														
															|  | 
 |  | +  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
 | 
												
													
														
															|  | 
 |  | +    var r = Math.random() * 16 | 0,
 | 
												
													
														
															|  | 
 |  | +      v = c == 'x' ? r : (r & 0x3 | 0x8);
 | 
												
													
														
															|  |      return v.toString(16);
 |  |      return v.toString(16);
 | 
												
													
														
															|  |    });
 |  |    });
 | 
												
													
														
															|  |  }
 |  |  }
 | 
												
											
												
													
														
															|  | @@ -163,12 +171,12 @@ function getUUID() {
 | 
												
													
														
															|  |   * @param complete 上传完执行的回调方法
 |  |   * @param complete 上传完执行的回调方法
 | 
												
													
														
															|  |   * @param progress 上传过程中的回调方法
 |  |   * @param progress 上传过程中的回调方法
 | 
												
													
														
															|  |   */
 |  |   */
 | 
												
													
														
															|  | -export const uploadMaterielFile = (file,complete, progress) => {
 |  | 
 | 
												
													
														
															|  | -    getQiniuToken('/elab-marketing-file/upload/getUploadToken').then(res => {
 |  | 
 | 
												
													
														
															|  | 
 |  | +export const uploadMaterielFile = (file, complete, progress) => {
 | 
												
													
														
															|  | 
 |  | +  getQiniuToken('/elab-marketing-file/upload/getUploadToken').then(res => {
 | 
												
													
														
															|  |      var token = res.single.token;
 |  |      var token = res.single.token;
 | 
												
													
														
															|  | -    var resultUrl =  res.single.resultUrl;
 |  | 
 | 
												
													
														
															|  | -    var prefix = 'launchTemplate/'+getUUID() + '-';
 |  | 
 | 
												
													
														
															|  | -    var fileName = prefix + file.name.replace(/\s+/g,"");
 |  | 
 | 
												
													
														
															|  | 
 |  | +    var resultUrl = res.single.resultUrl;
 | 
												
													
														
															|  | 
 |  | +    var prefix = 'launchTemplate/' + getUUID() + '-';
 | 
												
													
														
															|  | 
 |  | +    var fileName = prefix + file.name.replace(/\s+/g, "");
 | 
												
													
														
															|  |      var putExtra = {
 |  |      var putExtra = {
 | 
												
													
														
															|  |        fname: "",
 |  |        fname: "",
 | 
												
													
														
															|  |        params: {},
 |  |        params: {},
 | 
												
											
												
													
														
															|  | @@ -180,25 +188,24 @@ export const uploadMaterielFile = (file,complete, progress) => {
 | 
												
													
														
															|  |        retryCount: 6,
 |  |        retryCount: 6,
 | 
												
													
														
															|  |        region: qiniu.region.z0
 |  |        region: qiniu.region.z0
 | 
												
													
														
															|  |      };
 |  |      };
 | 
												
													
														
															|  | -    var tp=file.name.substring(file.name.indexOf('.'));
 |  | 
 | 
												
													
														
															|  | -    if(tp==".jpeg"||tp==".jpg"||tp==".gif"||tp==".png"||tp==".icon"){
 |  | 
 | 
												
													
														
															|  | 
 |  | +    var tp = file.name.substring(file.name.indexOf('.'));
 | 
												
													
														
															|  | 
 |  | +    if (tp == ".jpeg" || tp == ".jpg" || tp == ".gif" || tp == ".png" || tp == ".icon") {
 | 
												
													
														
															|  |        console.log('图片')
 |  |        console.log('图片')
 | 
												
													
														
															|  | -    }
 |  | 
 | 
												
													
														
															|  | -    else if(tp==".mp4"||tp==".ogg"||tp==".fly"||tp==".mp3"){
 |  | 
 | 
												
													
														
															|  | 
 |  | +    } else if (tp == ".mp4" || tp == ".ogg" || tp == ".fly" || tp == ".mp3") {
 | 
												
													
														
															|  |        console.log('音视频')
 |  |        console.log('音视频')
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |      var observable = qiniu.upload(file, fileName, token, putExtra, config);
 |  |      var observable = qiniu.upload(file, fileName, token, putExtra, config);
 | 
												
													
														
															|  | -    observable.subscribe(function(res){
 |  | 
 | 
												
													
														
															|  | 
 |  | +    observable.subscribe(function (res) {
 | 
												
													
														
															|  |        console.log('next------' + JSON.stringify(res))
 |  |        console.log('next------' + JSON.stringify(res))
 | 
												
													
														
															|  |        progress(res);
 |  |        progress(res);
 | 
												
													
														
															|  | -    }, function(res){
 |  | 
 | 
												
													
														
															|  | 
 |  | +    }, function (res) {
 | 
												
													
														
															|  |        console.log('error-----' + JSON.stringify(res))
 |  |        console.log('error-----' + JSON.stringify(res))
 | 
												
													
														
															|  | -    }, function(res){
 |  | 
 | 
												
													
														
															|  | 
 |  | +    }, function (res) {
 | 
												
													
														
															|  |        console.log('complete--------' + JSON.stringify(res))
 |  |        console.log('complete--------' + JSON.stringify(res))
 | 
												
													
														
															|  |        let addressUrl = resultUrl + res.key;
 |  |        let addressUrl = resultUrl + res.key;
 | 
												
													
														
															|  |        complete(addressUrl)
 |  |        complete(addressUrl)
 | 
												
													
														
															|  | -      return addressUrl ;
 |  | 
 | 
												
													
														
															|  | 
 |  | +      return addressUrl;
 | 
												
													
														
															|  |      });
 |  |      });
 | 
												
													
														
															|  |    }).catch((err) => {
 |  |    }).catch((err) => {
 | 
												
													
														
															|  |      errorProcess(err)
 |  |      errorProcess(err)
 | 
												
											
												
													
														
															|  | @@ -207,57 +214,61 @@ export const uploadMaterielFile = (file,complete, progress) => {
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |  }
 |  |  }
 | 
												
													
														
															|  |  // base 64
 |  |  // base 64
 | 
												
													
														
															|  | -export const uploadBase64=(data)=>{
 |  | 
 | 
												
													
														
															|  | 
 |  | +export const uploadBase64 = (data) => {
 | 
												
													
														
															|  |    // return axios.post(appConst.QINIU_DOMAIN+'/elab-marketing-file/upload/uploadBase64',data)
 |  |    // return axios.post(appConst.QINIU_DOMAIN+'/elab-marketing-file/upload/uploadBase64',data)
 | 
												
													
														
															|  | -    return  new Promise(function (resolve,reject) {
 |  | 
 | 
												
													
														
															|  | -      var base64Str = data.base64Str
 |  | 
 | 
												
													
														
															|  | -      getQiniuToken('/elab-marketing-file/upload/getUploadToken').then(res => {
 |  | 
 | 
												
													
														
															|  | -        var token = res.single.token;
 |  | 
 | 
												
													
														
															|  | -        var resultUrl =  res.single.resultUrl;
 |  | 
 | 
												
													
														
															|  | -        var pic = base64Str.replace(/^.*?,/, '');
 |  | 
 | 
												
													
														
															|  | -        var url = "https://upload.qiniup.com/putb64/-1"; //非华东空间需要根据注意事项 1 修改上传域名
 |  | 
 | 
												
													
														
															|  | -        var xhr = new XMLHttpRequest();
 |  | 
 | 
												
													
														
															|  | -        xhr.onreadystatechange=function(){
 |  | 
 | 
												
													
														
															|  | -          if (xhr.readyState==4){
 |  | 
 | 
												
													
														
															|  | -            let response = JSON.parse(xhr.response)
 |  | 
 | 
												
													
														
															|  | -            let data={}
 |  | 
 | 
												
													
														
															|  | -            if(xhr.status == 200){
 |  | 
 | 
												
													
														
															|  | -              data={
 |  | 
 | 
												
													
														
															|  | -                "success": true,
 |  | 
 | 
												
													
														
															|  | -                "errorCode": null,
 |  | 
 | 
												
													
														
															|  | -                "message": null,
 |  | 
 | 
												
													
														
															|  | -                "single": {
 |  | 
 | 
												
													
														
															|  | -                  "filePath": resultUrl+response.key ,
 |  | 
 | 
												
													
														
															|  | -                }
 |  | 
 | 
												
													
														
															|  | 
 |  | +  return new Promise(function (resolve, reject) {
 | 
												
													
														
															|  | 
 |  | +    var base64Str = data.base64Str
 | 
												
													
														
															|  | 
 |  | +    getQiniuToken('/elab-marketing-file/upload/getUploadToken').then(res => {
 | 
												
													
														
															|  | 
 |  | +      var token = res.single.token;
 | 
												
													
														
															|  | 
 |  | +      var resultUrl = res.single.resultUrl;
 | 
												
													
														
															|  | 
 |  | +      var pic = base64Str.replace(/^.*?,/, '');
 | 
												
													
														
															|  | 
 |  | +      var url = "https://upload.qiniup.com/putb64/-1"; //非华东空间需要根据注意事项 1 修改上传域名
 | 
												
													
														
															|  | 
 |  | +      var xhr = new XMLHttpRequest();
 | 
												
													
														
															|  | 
 |  | +      xhr.onreadystatechange = function () {
 | 
												
													
														
															|  | 
 |  | +        if (xhr.readyState == 4) {
 | 
												
													
														
															|  | 
 |  | +          let response = JSON.parse(xhr.response)
 | 
												
													
														
															|  | 
 |  | +          let data = {}
 | 
												
													
														
															|  | 
 |  | +          if (xhr.status == 200) {
 | 
												
													
														
															|  | 
 |  | +            data = {
 | 
												
													
														
															|  | 
 |  | +              "success": true,
 | 
												
													
														
															|  | 
 |  | +              "errorCode": null,
 | 
												
													
														
															|  | 
 |  | +              "message": null,
 | 
												
													
														
															|  | 
 |  | +              "single": {
 | 
												
													
														
															|  | 
 |  | +                "filePath": resultUrl + response.key,
 | 
												
													
														
															|  |                }
 |  |                }
 | 
												
													
														
															|  | -            }else{
 |  | 
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +          } else {
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | -              data={
 |  | 
 | 
												
													
														
															|  | -                "success": false,
 |  | 
 | 
												
													
														
															|  | -                "errorCode": xhr.status,
 |  | 
 | 
												
													
														
															|  | -                "message": response.error,
 |  | 
 | 
												
													
														
															|  | -                "single": {
 |  | 
 | 
												
													
														
															|  | -                  "filePath": null ,
 |  | 
 | 
												
													
														
															|  | -                }
 |  | 
 | 
												
													
														
															|  | 
 |  | +            data = {
 | 
												
													
														
															|  | 
 |  | +              "success": false,
 | 
												
													
														
															|  | 
 |  | +              "errorCode": xhr.status,
 | 
												
													
														
															|  | 
 |  | +              "message": response.error,
 | 
												
													
														
															|  | 
 |  | +              "single": {
 | 
												
													
														
															|  | 
 |  | +                "filePath": null,
 | 
												
													
														
															|  |                }
 |  |                }
 | 
												
													
														
															|  |              }
 |  |              }
 | 
												
													
														
															|  | -            resolve({data})
 |  | 
 | 
												
													
														
															|  |            }
 |  |            }
 | 
												
													
														
															|  | 
 |  | +          resolve({
 | 
												
													
														
															|  | 
 |  | +            data
 | 
												
													
														
															|  | 
 |  | +          })
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  | -        xhr.open("POST", url, true);
 |  | 
 | 
												
													
														
															|  | -        xhr.setRequestHeader("Content-Type", "application/octet-stream");
 |  | 
 | 
												
													
														
															|  | -        xhr.setRequestHeader("Authorization",  "UpToken " + token);
 |  | 
 | 
												
													
														
															|  | -        xhr.send(pic);
 |  | 
 | 
												
													
														
															|  | -      }).catch((err) => {
 |  | 
 | 
												
													
														
															|  | -        var data={
 |  | 
 | 
												
													
														
															|  | -          "success": false,
 |  | 
 | 
												
													
														
															|  | -          "errorCode": 'faild',
 |  | 
 | 
												
													
														
															|  | -          "message": err,
 |  | 
 | 
												
													
														
															|  | -          "single": {
 |  | 
 | 
												
													
														
															|  | -            "filePath": null ,
 |  | 
 | 
												
													
														
															|  | -          }
 |  | 
 | 
												
													
														
															|  | 
 |  | +      }
 | 
												
													
														
															|  | 
 |  | +      xhr.open("POST", url, true);
 | 
												
													
														
															|  | 
 |  | +      xhr.setRequestHeader("Content-Type", "application/octet-stream");
 | 
												
													
														
															|  | 
 |  | +      xhr.setRequestHeader("Authorization", "UpToken " + token);
 | 
												
													
														
															|  | 
 |  | +      xhr.send(pic);
 | 
												
													
														
															|  | 
 |  | +    }).catch((err) => {
 | 
												
													
														
															|  | 
 |  | +      var data = {
 | 
												
													
														
															|  | 
 |  | +        "success": false,
 | 
												
													
														
															|  | 
 |  | +        "errorCode": 'faild',
 | 
												
													
														
															|  | 
 |  | +        "message": err,
 | 
												
													
														
															|  | 
 |  | +        "single": {
 | 
												
													
														
															|  | 
 |  | +          "filePath": null,
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  | -        reject({data})
 |  | 
 | 
												
													
														
															|  | 
 |  | +      }
 | 
												
													
														
															|  | 
 |  | +      reject({
 | 
												
													
														
															|  | 
 |  | +        data
 | 
												
													
														
															|  |        })
 |  |        })
 | 
												
													
														
															|  | 
 |  | +    })
 | 
												
													
														
															|  |    })
 |  |    })
 | 
												
													
														
															|  |  }
 |  |  }
 |