blob: 057b1062236d455949b6e35d4a187b0b4da52471 [file] [log] [blame]
qiaoweif044a742019-07-10 16:04:20 +08001var app = {
2
3 // Application Constructor
4 initialize: function() {
5 document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
6 },
7
8 onDeviceReady: function() {
9 this.loadBill()
10 },
11 loadBill: function() {
12 var refno = window.localStorage.getItem("currentrefno");
13 if (isEmpty(refno)) {
14 $.alert("加载失败了", "提示");
15 return;
16 }
17 $.showLoading("加载中");
18 var param = {
19 "billid": refno
20 }
21 V1Billdetail(param, function(ok, ret) {
22 if (ok) {
23 if (ret.code == 200) {
24 if (ret.dtl == null) {
25 $.hideLoading();
26 $.alert("数据加载异常,请稍后再试", "错误");
27 } else {
28 app.initBillView(ret.dtl)
29 }
30 } else {
31 $.hideLoading();
32 $.alert("数据加载异常,请稍后再试", "错误");
33 }
34 } else {
35 $.hideLoading();
36 $.alert("请求失败了:" + ret.status + "请稍后再试", "错误");
37 }
38 })
39 },
40 initBillView: function(data) {
41 console.log(data);
42 if (data.tradeflag == 'in') {
43 $("#amount").text('+' + data.amount)
44 } else {
45 $("#amount").text(data.amount)
46 }
47 if (data.status == 'success') {
48 $("#status").text("交易成功");
49 } else {
50 $("#status").text("交易失败");
51 }
52 $("#tranddes").text(data.transdesc);
53 $("#transtime").text(formatDate(data.transdate + '' + data.transtime, true));
54 $("#refno").text(data.refno);
55 $.hideLoading();
56 }
57};
58app.initialize();