export function getUrlParams(url) {
  let theRequest = {};
  if(url.indexOf("#") != -1){
	  const str=url.split("#")[1];
	  const strs=str.split("&");
	  for (let i = 0; i < strs.length; i++) {
	  	theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
	  }
  }else if(url.indexOf("?") != -1){
	  const str=url.split("?")[1];
	  const strs=str.split("&");
	  for (let i = 0; i < strs.length; i++) {
	  	theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
	  }
  }
  return theRequest;
}

/**
 * 将对象参数转换为URL查询字符串格式
 * @param {Object} args - 参数对象
 * @returns {String} 返回key=value&格式的查询字符串
 */
export function objectToUrlParams(args) {
  if (!args || typeof args !== 'object') {
    return '';
  }
  
  const params = [];
  for (const key in args) {
    if (args.hasOwnProperty(key) && args[key] !== undefined && args[key] !== null) {
      params.push(`${key}=${args[key]}`);
    }
  }
  
  return params.length > 0 ? params.join('&') : '';
}
