如何从srcipts传递参数并在IONIC中获取cordovaInAppBrowser中的那些参数

时间:2016-10-29 05:00:42

标签: angularjs ionic-framework cordova-plugins inappbrowser

我正在尝试集成支付网关,我的想法是从cordovaInAppBrowser完成它。所以这是我的脚本文件

scripts.js中

SELECT 
    (select SUM(Num_Avail) FROM Goods WHERE Color = 'White' ) AS [AVAILABLE WHITE] , 
    (SELECT SUM(Num_Avail) FROM Goods WHERE Color = 'Blue' )   AS  [AVAILABL EBLUE] ,
    (SELECT SUM(Num_Avail) FROM Goods WHERE Color = 'Green' )  AS [Available GREEN] , 
    (SELECT SUM(Num_Avail) FROM Goods ) as  [TOTAL AVAILABLE]

我已经安装了Cordova InAppBrowser的插件,我正在使用它如下:

 $rootScope.paymentdata.salt="sdfg"
     $rootScope.paymentdata.key="sdfg";
     $rootScope.paymentdata.amount=checkout.grandtotal;
     $rootScope.paymentdata.productinfo=$rootScope.cartlist
     $rootScope.paymentdata.firstname=$rootScope.userinfo.name;
     $rootScope.paymentdata.email=$rootScope.userinfo.email
     $rootScope.paymentdata.phone=$rootScope.userinfo.contactno;
     $rootScope.paymentdata.surl="http://localhost:8100/#/success.php"
     $rootScope.paymentdata.furl="http://localhost:8100/#/failure.php"
     $rootScope.paymentdata.service_provider="payu_paisa"
     var string = $rootScope.paymentdata.key + '|' + $rootScope.paymentdata.txnid + '|' + $rootScope.paymentdata.amount + '|' + $rootScope.paymentdata.productinfo + '|' + $rootScope.paymentdata.firstname + '|' + $rootScope.paymentdata.email + '|||||||||||' + $rootScope.paymentdata.salt;
$rootScope.paymentdata.hash=$scope.SHA512(string)

使用Javascript窗口如下,

var browserWindow = $cordovaInAppBrowser.open('payumoney.html', '_blank', 'location=yes,hidden=yes,hardwareback=no');

这里payumoney.html是我的html文件,我想从中完成这个过程。在这个payumoney.html中,我有以下输入/参数,我可以从中完成此付款。

payymoney.html

var browserWindow = window.open('payumoney.html', '_self', 'location=yes,hidden=yes,hardwareback=no');

所以这样我就拥有了我要发送的所有字段。但我无法在该文件中获取这些参数。

所以我的问题是,如何传递这些参数或在该文件中获取这些参数。

1 个答案:

答案 0 :(得分:0)

您可以使用localStorage在app和InAppBrowser页面payumoney.html之间共享数据。

所以在Scripts.js添加以下行:

localStorage.setItem('paymentdata', JSON.stringify($rootScope.payementdata));

payumoney.html

<script type="text/javascript">
var paymentData = JSON.parse(localStorage.getItem('paymentdata'));
alert(paymentData.salt):
</script>