index.jsp
5.73 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@page import="weaver.hrm.HrmUserVarify"%>
<%@page import="weaver.hrm.User"%>
<%@ include file="/mobilemode/mobile/base.jsp"%>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="/mobilemode/browser/js/fastclick.min_wev8.js"></script>
<link type="text/css" rel="stylesheet" href="css/bootstrap.css">
<%
if(user==null){
response.sendRedirect("/notice/noright.jsp") ;
return ;
}
int userid = user.getUID();
///open/js/jem.js
String js_url = new BaseBean().getPropValue("wechatElecInvoice_e9", "js_url").trim();
%>
<script type="text/javascript">
$(function(){
var js_url = "<%=js_url%>";
FastClick.attach(document.body);
getInvoiceList();//加载所有发票列表
loadLib(js_url);
});
function loadLib(url) {
var script = document.createElement("script");
script.async = false;
script.src = url;
document.body.appendChild(script);
}
function test(_json){
try{
var err_code = _json.errCode;
var err_msg = _json.errMsg;
if(err_code == "1"){
alert(err_msg);
}else{
var choose_invoice_info = _json.choose_invoice_info;
var _data = "type=synchronize";
var poststr = "";
$.each($.parseJSON(choose_invoice_info), function (i, v) {
var card_id = v.card_id;
var encrypt_code = v.encrypt_code;
var app_id = v.app_id;
if(poststr!=""){
poststr += ",s,";
}
poststr += card_id+","+encrypt_code+","+app_id+",postStrEnd";
});
if(poststr != ""){
// $(".loading-div").show();
var _data = "type=synchronize&poststr="+poststr;
jQuery.ajax({
url:"/mobile/plugin/1/fna/FnaElecInvoiceUtil.jsp",
type : "get",
cache : false,
processData : false,
data : _data,
dataType : "json",
// async:false,
success: function do4Success(_json){
var err_code = _json.err_code;
if(err_code == "1"){
alert(_json.err_msg);
}else{
alert("同步电子发票成功!");
}
},
complete:function(){
// $(".loading-div").hide();
getInvoiceList();
}
});
}else{
alert("无电子发票数据!");
}
}
}catch(ex){}
}
function getInvoiceList(){
try{
var _data = "type=list";
// $(".loading-div").show();
jQuery.ajax({
url:"/mobile/plugin/1/fna/FnaElecInvoiceUtil.jsp",
type : "get",
cache : false,
processData : false,
data : _data,
dataType : "json",
async:false,
success: function do4Success(_json){
var err_code = _json.err_code;
if(err_code == "1"){
alert(_json.err_msg);
}else{
var data = _json.data;
var dataLength = data.length;
var statusCount = _json.statusCount;
$(".already-number-span").text(statusCount);
$(".number-span").text(dataLength);
$(".invoice-div").empty();
for(var i = 0;i<dataLength;i++){
var dataInfo = data[i];
var seller = dataInfo.seller;
var purchaser = dataInfo.purchaser;
var priceWithoutTax = dataInfo.priceWithoutTax;
var billingDate = dataInfo.billingDate;
var divs = " <div class='panel panel-info'>"+
" <div class='panel-heading'>"+
" <h3 class='panel-title'>"+
seller+
" </h3>"+
" </div>"+
" <div class='panel-body'>"+
" <div class='invoice-detail-div'>"+
" <span class='info-title'>购方名称:</span>"+
" <div class='number-div'>"+
purchaser+
" </div>"+
" </div>"+
" <div class='invoice-detail-div'>"+
" <span class='info-title'>发票金额:</span>"+
" <div class='number-div'>"+
priceWithoutTax+
" </div>"+
" </div>"+
" <div class='invoice-detail-div'>"+
" <span class='info-title'>开票日期:</span>"+
" <div class='number-div'>"+
billingDate+
" </div>"+
" </div>"+
" </div>"+
" </div>";
$(".invoice-div").append(divs);
}
}
},
complete:function(){
// $(".loading-div").hide();
}
});
}catch(ex){}
}
function chooseInvoice(){
if(em && em.checkJsApi('chooseInvoice')){
em.chooseInvoice({
success: function(res){
console.log(res);
// alert(JSON.stringify(res));
test(res);
},
fail: function(e){
console.log(e);
}
});
}else{
alert('不支持');
}
}
</script>
<style type="text/css">
body{
background-color: #f5f4f9;
}
.container{
width: 98%;
height: 100%;
margin-left: 1%;
}
.btn{
margin-top: 20px;
width: 100%;
}
.my-info-div{
height: 30px;
margin-top: 10px;
font-weight: bold;
line-height: 30px;
}
.number-div{
margin-left: 0px;
float: right;
font-weight: bold;
}
.number-span{
color: #bf7037;
}
.already-number-span{
color: #bf7037;
}
.invoice-div{
margin-top: 10px;
}
.invoice-detail-div{
height: 30px;
width: 100%;
line-height: 30px;
}
.info-title{
color: #979797;
}
.loading-div{
margin-top: 30px;
height: 30px;
line-height: 30px;
text-align: center;
display: none;
}
</style>
</head>
<body>
<div class="container">
<input type="button" class="btn btn-primary" onclick="chooseInvoice();" value="同步电子发票">
<div class="my-info-div">
<span>我的发票</span>
<div class="number-div">
<span>已用</span><span class="already-number-span">0</span><span>张,</span>
<span>共</span><span class="number-span">0</span><span>张</span>
</div>
</div>
<div class="loading-div">
<img src="img/loading.gif">
</div>
<div class="invoice-div"></div>
</div>
</body>
</html>