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 调试
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') {
  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
}

