qiaowei | f044a74 | 2019-07-10 16:04:20 +0800 | [diff] [blame] | 1 | var 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 | }, |
qiaowei | 60c27e4 | 2019-07-11 16:43:54 +0800 | [diff] [blame] | 11 | toBack: function (){ |
| 12 | window.history.back(); |
| 13 | }, |
qiaowei | f044a74 | 2019-07-10 16:04:20 +0800 | [diff] [blame] | 14 | loadBill: function() { |
| 15 | var refno = window.localStorage.getItem("currentrefno"); |
| 16 | if (isEmpty(refno)) { |
| 17 | $.alert("加载失败了", "提示"); |
| 18 | return; |
| 19 | } |
| 20 | $.showLoading("加载中"); |
| 21 | var param = { |
| 22 | "billid": refno |
| 23 | } |
| 24 | V1Billdetail(param, function(ok, ret) { |
| 25 | if (ok) { |
| 26 | if (ret.code == 200) { |
| 27 | if (ret.dtl == null) { |
| 28 | $.hideLoading(); |
| 29 | $.alert("数据加载异常,请稍后再试", "错误"); |
| 30 | } else { |
| 31 | app.initBillView(ret.dtl) |
| 32 | } |
| 33 | } else { |
| 34 | $.hideLoading(); |
| 35 | $.alert("数据加载异常,请稍后再试", "错误"); |
| 36 | } |
| 37 | } else { |
| 38 | $.hideLoading(); |
| 39 | $.alert("请求失败了:" + ret.status + "请稍后再试", "错误"); |
| 40 | } |
| 41 | }) |
| 42 | }, |
| 43 | initBillView: function(data) { |
| 44 | console.log(data); |
| 45 | if (data.tradeflag == 'in') { |
| 46 | $("#amount").text('+' + data.amount) |
| 47 | } else { |
| 48 | $("#amount").text(data.amount) |
| 49 | } |
| 50 | if (data.status == 'success') { |
| 51 | $("#status").text("交易成功"); |
| 52 | } else { |
| 53 | $("#status").text("交易失败"); |
| 54 | } |
| 55 | $("#tranddes").text(data.transdesc); |
| 56 | $("#transtime").text(formatDate(data.transdate + '' + data.transtime, true)); |
| 57 | $("#refno").text(data.refno); |
| 58 | $.hideLoading(); |
| 59 | } |
| 60 | }; |
| 61 | app.initialize(); |