1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>
<%= htmlWebpackPlugin.options.title %>
</title>
<!-- Open Graph data -->
<!-- <meta property="og:title" content="Title Here" /> -->
<!-- <meta property="og:url" content="http://www.example.com/" /> -->
<!-- <meta property="og:image" content="http://example.com/image.jpg" /> -->
<!-- <meta property="og:description" content="Description Here" /> -->
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<link rel="stylesheet" href="<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css" />
</head>
<body>
<noscript>
<strong>Please enable JavaScript to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
<script type="text/javascript">
var NODE_ENV = window.localStorage.getItem('NODE_ENV') || '';
var apiBaseUrl = '';
var testDomain = 'pdatest.groupage.cn'
// 在HBuilderX 中,点击“运行”编译出来的代码是开发环境,点击“发行”编译出来的代码是生产环境
if (NODE_ENV === 'development') {
// 开发环境
apiBaseUrl = 'http://pdatest.groupage.cn/api.php' //测试
} else {
// 生产环境
if (location.href.indexOf(testDomain) != -1) {
apiBaseUrl = 'http://pdatest.groupage.cn/api.php'
} else {
apiBaseUrl = 'http://pda.groupage.cn/api.php'
}
}
// 请求封装
var Ajax = {
get: function(url,callback){
// XMLHttpRequest对象用于在后台与服务器交换数据
var xhr=new XMLHttpRequest();
xhr.open('GET',url,false);
xhr.onreadystatechange=function(){
// readyState == 4说明请求已完成
if(xhr.readyState==4){
if(xhr.status==200 || xhr.status==304){
console.log(xhr.responseText);
callback(xhr.responseText);
}
}
}
xhr.send();
},
// data应为'a=a1&b=b1'这种字符串格式,在jq里如果data为对象会自动将对象转成这种字符串格式
post: function(url,data,callback){
var xhr=new XMLHttpRequest();
xhr.open('POST',url,false);
// 添加http头,发送信息至服务器时内容编码类型
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xhr.onreadystatechange=function(){
if (xhr.readyState==4){
if (xhr.status==200 || xhr.status==304){
// console.log(JSON.parse(xhr.responseText));
callback(JSON.parse(xhr.responseText));
}
}
}
xhr.send(data);
}
};
// 创建Script标签
var creatScript = function (src){
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type= 'text/javascript';
script.onload = script.onreadystatechange = function(){
if(!this.readyState||this.readyState=='loaded'||this.readyState=='complete'){
console.log('script.loaded');
}
};
script.src = src;
head.appendChild(script);
}
// 打印机配置接口
// Ajax.post(apiBaseUrl+'/Printer/getPrinterConf','sign=6df487c0a47106c49d64f1116ab743f5',function(res){
// if(res.code == 0){
// // creatScript('http://127.0.0.1:8000/CLodopfuncs.js');
// creatScript('http://'+res.data.ip+":"+res.data.port+'/CLodopfuncs.js');
// window.localStorage.setItem('PRINTER_INDEX',res.data.code)
// }
// })
</script>
</html>