

var jsVersion = +new Date() // '?v=202106091751';
var contextPath = '.'
if (getPageN() === 'index' || getPageN() === 'home') {
  contextPath = '.'
} else {
  contextPath = '..'
}
// css
// CSS 统一加载
document.write(`
  <link rel="icon" href="${contextPath}/image/favicon.ico">
  <link rel="stylesheet" href="${contextPath}/css/normalize.css">
  <link rel="stylesheet" href="${contextPath}/css/vant.css">
  <link rel="stylesheet" href="${contextPath}/css/common.css?rev=${jsVersion}">
`)

/**
 * 爱山东 jssdk相关引用
 */
document.write(`
  <script type="text/javascript" src="https://isdapp.shandong.gov.cn/jmopen/jssdk/index.js"></script>
  <script type="text/javascript" src="${contextPath}/sdk/jssdk2/aes.js"></script>
  <script type="text/javascript" src="${contextPath}/sdk/jssdk2/sm2/build/SM.js"></script>
`)
// 移动端 debugger 调试
if (localStorage.getItem('debug')=='Y') {
	document.write(
	  `<script type="text/javascript" src="${contextPath}/sdk/eruda-2.4.1.js"></script>\
					<script>eruda.init();</script>`
	)
}

// 自动识别环境（需在文件最顶部添加）
window.env = window.location.hostname === 'web1.isdapp.shandong.gov.cn' ? 'pro' : 'dev';


/**
 * 项目业务相关 js
 */
// <script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/vant/2.12.54/vant.min.js"></script>\
// <script type="text/javascript" src="' + contextPath + '/sdk/vant.min.js"></script>\
// <script type="text/javascript" src="' + contextPath + '/sdk/axios.min.js"></script>\
document.write(`
   <script type="text/javascript" src="${contextPath}/sdk/vue.min.js"></script>
   <script type="text/javascript" src="${contextPath}/sdk/vant.min.js"></script>
   <script type="text/javascript" src="${contextPath}/sdk/flexible.js"></script>
   <script type="text/javascript" src="${contextPath}/sdk/util.js?rev=${jsVersion}"></script>
   <script type="text/javascript" src="${contextPath}/sdk/jssdk2/apiKeyMap.js?rev=${jsVersion}"></script>
	<script type="text/javascript" src="${contextPath}/sdk/axios.min.js"></script>
`)

let writeText = ''
if (window.env == 'dev') {
	

  const tempTk = 
      // 网格员
  // 'Bearer eyJhbGciOiJIUzUx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lW5btrver7aBcCLm7QQEFYBTemA'
    // 管理员 本地
	'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImxvZ2luX3VzZXJfa2V5IjoiZjA5OWU0ZTAtNzMxMS00MDlkLTg3YTUtYjhkNDNjMWVjNjQ4In0.qrivFnf68QSQ9mG0tOg9jeSB7loDMnP4NlpNthEBywPLkIaGZoE74IrTGSzFvajyay2-gBJ8GCunVOTyvTEebw'
  // 街道
  // 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqaWVkYW8iLCJsb2dpbl91c2VyX2tleSI6ImNjNjRkMmZhLWQzNmItNGRkZi05MjcxLTliYTA0ZDJkYzM4NiJ9.G2BAs3XnlqR6QgDRWDfXkOpdLYhFdqEaTxvE8GxLAgU8vcsHPEKdhQ4VvOwsiNAtIaUpMDXirOb-FrHVNvZo4g'

  _setCookie('token', tempTk)

  const tempApiHost = 'http://192.168.2.37:8080'
  // const tempApiHost = 'https://gqyjpt.weihai.cn/prod-api'

  localStorage.setItem('apiHost', tempApiHost)


  writeText = `
  <script type="text/javascript" src="${contextPath}/sdk/axios_http.js"></script>
`
} else {
  writeText = `
   <script type="text/javascript" src="${contextPath}/sdk/http.js?rev=${jsVersion}"></script>
 `
}


document.write(writeText)
if (getPageN()) {
  // 加载同名js
  document.write('<script type="text/javascript" src="./' + getPageN() + '.js?rev=' + jsVersion + '"></script>')
  document.write('<link rel="stylesheet" type="text/css" href="./' + getPageN() + '.css?rev=' + jsVersion + '" />')
}

function getPageN() {
  var pageN = window.location.pathname
  pageN = pageN.substring(pageN.lastIndexOf('/') + 1, pageN.indexOf('.'))
  return pageN
}

// 新增浏览器地址变化监听
window.addEventListener('popstate', function () {
  vant.Toast.loading({
    message: '加载中...',
    forbidClick: true,
    loadingType: 'spinner'
  });
});



function _setCookie(name, value, days) {
  var len = arguments.length
  if (len == 2) {
    var exp = new Date()
    exp.setTime(exp.getTime() + 30 * 24 * 60 * 60 * 1000)
    document.cookie =
      name + '=' + escape(value) + ';expires=' + exp.toGMTString() + ';path=/'
  } else if (len == 3) {
    var exp = new Date()
    exp.setDate(exp.getDate() + parseInt(days))
    exp.setHours(1, 0, 0, 0)
    document.cookie =
      name + '=' + escape(value) + ';expires=' + exp.toGMTString() + ';path=/'
  }
}