import request from './request'
import { searchObj } from '~/config/app'
export const searchMap = new URLSearchParams(decodeURIComponent(location.search))


const cookieObj = {}
document.cookie.split(';').forEach(item => {
  const [key, value] = item.split('=')
  cookieObj[key?.trim()] = value?.trim()
})


export const user = JSON.parse(localStorage.getItem('userInfo'))
export const js_code = searchObj?.js_code ?? sessionStorage.getItem('js_code') ?? cookieObj.js_code ?? undefined

export const webInfo = await request({
  url: 'https://openapi.bozedu.net' + '/jlt/set/detail',
  method: 'post',
  headers: {
    "Content-Type": 'application/x-www-form-urlencoded;charset=UTF-8'
  },
  data: {
    // token: user?.token
    token: undefined,
    js_code: js_code
  }
}).then(res => res.data.one_info)