export default {
  query2obj(str = '') {
    return str.replace(/\?|\//g, '').split('&').reduce((r, i) => {
      let [k, v] = i.split('=')
      if (k !== '') r[k] = v
      return r
    }, {})
  },
  obj2query(obj = {}) {
    return Object.keys(obj).reduce((r, k) => r + '&' + k + '=' + obj[k], '').replace(/^&/, '?')
  },
  getModel() {
    let u = navigator.userAgent;
    if (u.indexOf("Android") > -1 || u.indexOf("Adr") > -1) {
      return 'isAndroid'
    } else if (!!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
      return 'isIOS'
    }
  }
}