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