Commit 8a9e2d81 authored by kaitly205422@163.com's avatar kaitly205422@163.com
Browse files

修复参数传递问题

parent 1789f962
Loading
Loading
Loading
Loading
−15.3 MiB (16.2 MiB)

File changed.

No diff preview for this file type.

+6 −6
Original line number Diff line number Diff line
@@ -30,12 +30,12 @@ service.interceptors.request.use(config => {
    config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
  }
  // // get请求映射params参数
  // if (config.method === 'get' && config.params) {
  //   let url = config.url + '?' + tansParams(config.params);
  //   url = url.slice(0, -1);
  //   config.params = {};
  //   config.url = url;
  // }
  if (config.method === 'get' && config.params) {
    let url = config.url + '?' + tansParams(config.params);
    url = url.slice(0, -1);
    config.params = {};
    config.url = url;
  }
  if (!isRepeatSubmit && (config.method === 'post' || config.method === 'put')) {
    const requestObj = {
      url: config.url,
+4 −2
Original line number Diff line number Diff line
@@ -206,11 +206,13 @@ export function handleTree(data, id, parentId, children) {
* @param {*} params  参数
*/
export function tansParams(params) {
  console.log(params)
  let result = ''
  for (const propName of Object.keys(params)) {
    const value = params[propName];
    var part = encodeURIComponent(propName) + "=";
    if (value !== null && value !== "" && typeof (value) !== "undefined") {
    // && value !== "" 有的接口需要默认传空值
    if (value !== null && typeof (value) !== "undefined") {
      if (typeof value === 'object') {
        for (const key of Object.keys(value)) {
          if (value[key] !== null && value[key] !== "" && typeof (value[key]) !== 'undefined') {