get ercode
Showing
7 changed files
with
121 additions
and
53 deletions
This diff is collapsed.
Click to expand it.
| ... | @@ -98,6 +98,7 @@ | ... | @@ -98,6 +98,7 @@ |
| 98 | <link href="css/app.css" rel="stylesheet"/> | 98 | <link href="css/app.css" rel="stylesheet"/> |
| 99 | <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet"> | 99 | <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet"> |
| 100 | <script type="text/javascript" src="js/jquery-1.9.1.js"></script> | 100 | <script type="text/javascript" src="js/jquery-1.9.1.js"></script> |
| 101 | <script type="text/javascript" src="js/JSBridge.js"></script> | ||
| 101 | <script type="text/javascript" src="js/angularjs/angular.min.js"></script> | 102 | <script type="text/javascript" src="js/angularjs/angular.min.js"></script> |
| 102 | <script type="text/javascript" src="js/angularjs/angular-local-storage.js"></script> | 103 | <script type="text/javascript" src="js/angularjs/angular-local-storage.js"></script> |
| 103 | <script type="text/javascript" src="js/angularjs/angular-ui-router.js"></script> | 104 | <script type="text/javascript" src="js/angularjs/angular-ui-router.js"></script> | ... | ... |
js/JSBridge.js
0 → 100644
| 1 | function AppClient(appObj, isAndroid) { | ||
| 2 | this.appObj = appObj; | ||
| 3 | this.isAndroid = isAndroid; | ||
| 4 | }; | ||
| 5 | |||
| 6 | AppClient.prototype.closePage = function() { | ||
| 7 | if (this.isAndroid) { | ||
| 8 | this.appObj.closePageAction(); | ||
| 9 | } else { | ||
| 10 | this.appObj.callHandler("closePageAction"); | ||
| 11 | } | ||
| 12 | } | ||
| 13 | function isJson(str) { | ||
| 14 | try { | ||
| 15 | JSON.parse(str); | ||
| 16 | } catch (e) { | ||
| 17 | return false; | ||
| 18 | } | ||
| 19 | return true; | ||
| 20 | } | ||
| 21 | // window.invokeJsPassCompanyCodeAndName = function(_params) { | ||
| 22 | // companyCode = _params.companyCode; | ||
| 23 | // companyName = _params.companyName; | ||
| 24 | // var jsonStr = ""; | ||
| 25 | // getSign(jsonStr); | ||
| 26 | // } | ||
| 27 | AppClient.prototype.getERCode = function (callbackName, callback, jsonStr) { | ||
| 28 | var dataParams = ""; | ||
| 29 | if(isJson(jsonStr)){ | ||
| 30 | dataParams = JSON.parse(jsonStr); | ||
| 31 | } | ||
| 32 | var iOSData = { | ||
| 33 | from: 'H5', | ||
| 34 | params: dataParams | ||
| 35 | }; | ||
| 36 | if (this.isAndroid) { | ||
| 37 | this.appObj.getERCode('H5', jsonStr); | ||
| 38 | } else { | ||
| 39 | this.appObj.callHandler("getERCode", iOSData, callback); | ||
| 40 | } | ||
| 41 | }; | ||
| 42 | if(window.android) { | ||
| 43 | appClient = new AppClient(window.android, true); | ||
| 44 | // 此处可以调用一些init的方法 | ||
| 45 | } else { | ||
| 46 | |||
| 47 | function setupWebViewJavascriptBridge(callback) { | ||
| 48 | if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); } | ||
| 49 | if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); } | ||
| 50 | window.WVJBCallbacks = [callback]; | ||
| 51 | var WVJBIframe = document.createElement('iframe'); | ||
| 52 | WVJBIframe.style.display = 'none'; | ||
| 53 | WVJBIframe.src = 'https://__bridge_loaded__'; | ||
| 54 | document.documentElement.appendChild(WVJBIframe); | ||
| 55 | setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0) | ||
| 56 | } | ||
| 57 | setupWebViewJavascriptBridge(function(bridge) { | ||
| 58 | appClient = new AppClient(bridge, false); | ||
| 59 | // 此处可以调用一些init的方法 | ||
| 60 | }); | ||
| 61 | |||
| 62 | } | ||
| 63 | window.getIOSERCode = function (_params) { | ||
| 64 | alert(JSON.parse(_params)) | ||
| 65 | |||
| 66 | } |
| ... | @@ -4,7 +4,6 @@ angular.module('myApp') | ... | @@ -4,7 +4,6 @@ angular.module('myApp') |
| 4 | $rootScope.isRendBike = false; | 4 | $rootScope.isRendBike = false; |
| 5 | $rootScope.isLoadFinish = false; | 5 | $rootScope.isLoadFinish = false; |
| 6 | $scope.unfinishOrder = {}; | 6 | $scope.unfinishOrder = {}; |
| 7 | |||
| 8 | var init = function() { | 7 | var init = function() { |
| 9 | // globalService.init(); | 8 | // globalService.init(); |
| 10 | $scope.userinfo = globalService.getData("user"); | 9 | $scope.userinfo = globalService.getData("user"); |
| ... | @@ -105,56 +104,60 @@ angular.module('myApp') | ... | @@ -105,56 +104,60 @@ angular.module('myApp') |
| 105 | $rootScope.openRing = false; | 104 | $rootScope.openRing = false; |
| 106 | $rootScope.$watch("openScan",function(newVal, oldVal){ | 105 | $rootScope.$watch("openScan",function(newVal, oldVal){ |
| 107 | if(newVal !== oldVal && newVal) { | 106 | if(newVal !== oldVal && newVal) { |
| 108 | if(!$scope.checkLogin()) { | 107 | // if(!$scope.checkLogin()) { |
| 109 | return; | 108 | // return; |
| 110 | } | 109 | // } |
| 111 | 110 | ||
| 112 | if($scope.unfinishOrder.status == 200) { | 111 | // if($scope.unfinishOrder.status == 200) { |
| 113 | $state.go('tripDetail' , { orderId : $scope.unfinishOrder.id}); | 112 | // $state.go('tripDetail' , { orderId : $scope.unfinishOrder.id}); |
| 114 | return; | 113 | // return; |
| 115 | } | 114 | // } |
| 116 | $rootScope.openScan = false; | 115 | $rootScope.openScan = false; |
| 117 | wx.scanQRCode({ | 116 | console.log(appClient) |
| 118 | needResult: 1, // 默认为1,扫描结果由微信处理,1则直接返回扫描结果, | 117 | appClient.getERCode('getIOSERCode', function (res) { |
| 119 | scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码,默认二者都有 | 118 | alert(JSON.parse(res)) |
| 120 | success: function (res) { | 119 | }, '') |
| 121 | var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果 | 120 | // wx.scanQRCode({ |
| 122 | // alert(result); | 121 | // needResult: 1, // 默认为1,扫描结果由微信处理,1则直接返回扫描结果, |
| 123 | dingdaService.verifyScanCode(result).success(function(data , status){ | 122 | // scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码,默认二者都有 |
| 124 | // alert(JSON.stringify(data)) | 123 | // success: function (res) { |
| 125 | if(data.meta.code == 200) { | 124 | // var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果 |
| 126 | if(data.data.orderDetail.id) { | 125 | // // alert(result); |
| 127 | 126 | // dingdaService.verifyScanCode(result).success(function(data , status){ | |
| 128 | layer.open({ | 127 | // // alert(JSON.stringify(data)) |
| 129 | content: "租车成功,订单号为:" + data.data.orderDetail.id, | 128 | // if(data.meta.code == 200) { |
| 130 | time:2 | 129 | // if(data.data.orderDetail.id) { |
| 131 | }); | 130 | // |
| 132 | // alert("租车成功,订单号为:" + data.data.orderDetail.id); | 131 | // layer.open({ |
| 133 | $rootScope.isRendBike = true; | 132 | // content: "租车成功,订单号为:" + data.data.orderDetail.id, |
| 134 | 133 | // time:2 | |
| 135 | $state.go('rentDetail', {}, {reload: true}); | 134 | // }); |
| 136 | 135 | // // alert("租车成功,订单号为:" + data.data.orderDetail.id); | |
| 137 | } | 136 | // $rootScope.isRendBike = true; |
| 138 | } else if(data.meta.code == 202) { | 137 | // |
| 139 | layer.open({ | 138 | // $state.go('rentDetail', {}, {reload: true}); |
| 140 | content: data.meta.message, | 139 | // |
| 141 | time:2 | 140 | // } |
| 142 | }); | 141 | // } else if(data.meta.code == 202) { |
| 143 | $state.go('bond', {longitude: $rootScope.currentPoint.longitude , latitude: $rootScope.currentPoint.latitude }); | 142 | // layer.open({ |
| 144 | } else { | 143 | // content: data.meta.message, |
| 145 | layer.open({ | 144 | // time:2 |
| 146 | content: data.meta.message, | 145 | // }); |
| 147 | time:2 | 146 | // $state.go('bond', {longitude: $rootScope.currentPoint.longitude , latitude: $rootScope.currentPoint.latitude }); |
| 148 | }); | 147 | // } else { |
| 149 | } | 148 | // layer.open({ |
| 150 | }).error(function(data , status){ | 149 | // content: data.meta.message, |
| 151 | layer.open({ | 150 | // time:2 |
| 152 | content: "租车失败" + JSON.stringify(data), | 151 | // }); |
| 153 | time:2 | 152 | // } |
| 154 | }); | 153 | // }).error(function(data , status){ |
| 155 | }); | 154 | // layer.open({ |
| 156 | } | 155 | // content: "租车失败" + JSON.stringify(data), |
| 157 | }); | 156 | // time:2 |
| 157 | // }); | ||
| 158 | // }); | ||
| 159 | // } | ||
| 160 | // }); | ||
| 158 | } | 161 | } |
| 159 | }) | 162 | }) |
| 160 | $rootScope.$watch("openDetail",function(newVal, oldVal){ | 163 | $rootScope.$watch("openDetail",function(newVal, oldVal){ | ... | ... |
| ... | @@ -9,7 +9,6 @@ angular.module('myApp') | ... | @@ -9,7 +9,6 @@ angular.module('myApp') |
| 9 | var map; | 9 | var map; |
| 10 | var endPosition; | 10 | var endPosition; |
| 11 | var polyline; | 11 | var polyline; |
| 12 | |||
| 13 | $rootScope.currentPoint = {}; | 12 | $rootScope.currentPoint = {}; |
| 14 | 13 | ||
| 15 | var rendBike = function() { | 14 | var rendBike = function() { |
| ... | @@ -154,7 +153,6 @@ angular.module('myApp') | ... | @@ -154,7 +153,6 @@ angular.module('myApp') |
| 154 | img.src = "images/scancode.png"; | 153 | img.src = "images/scancode.png"; |
| 155 | 154 | ||
| 156 | scanControlContent.innerHTML = img.outerHTML + " 扫码租车"; | 155 | scanControlContent.innerHTML = img.outerHTML + " 扫码租车"; |
| 157 | |||
| 158 | scanControlContainer.onclick = function() { | 156 | scanControlContainer.onclick = function() { |
| 159 | $scope.$apply(function() { | 157 | $scope.$apply(function() { |
| 160 | $rootScope.openScan = true; | 158 | $rootScope.openScan = true; | ... | ... |
| ... | @@ -116,7 +116,7 @@ angular.module('myApp.services') | ... | @@ -116,7 +116,7 @@ angular.module('myApp.services') |
| 116 | case 101: | 116 | case 101: |
| 117 | var param = Object.assign($location.search(),{ | 117 | var param = Object.assign($location.search(),{ |
| 118 | amount : amount, | 118 | amount : amount, |
| 119 | body : "租车租金", | 119 | body : "租车租git金", |
| 120 | type : 101 | 120 | type : 101 |
| 121 | }); | 121 | }); |
| 122 | return callUnifiedOrderApi(host + "/bill/wx/h5/" + orderId, param); | 122 | return callUnifiedOrderApi(host + "/bill/wx/h5/" + orderId, param); | ... | ... |
-
Please register or sign in to post a comment