

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="//cdn.bootcdn.net/ajax/libs/eruda/2.4.1/eruda.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 ey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Q4VvOwsiNAtIaUpMDXirOb-FrHVNvZo4g'

	localStorage.setItem('token', tempTk)

  const tempApiHost = 'http://192.168.2.37:8080'
  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'
  });
});
