当我在AngularJS中构建的Ionic应用程序完成订单时,它会使用以下命令将订单号发布到API URL:
var returnUrl = window.open("http://example.com/api/" + ordernumber, "_self");
如何在2秒后关闭此窗口然后返回我的应用主页(这是我以前用于超时选项的一些代码)
.controller('ProductListCtrl', function (Products, $rootScope, $scope, $stateParams, $state, $timeout) {
$scope.products = Products;
var timeout;
$scope.$on('$ionicView.enter', function () {
timeout = setTimeout(function () {
$state.go('app.home');
}, 2000);
})
不确定“自我”浏览器应用程序窗口如何连接控制器?
此窗口打开是以下现有功能的一部分:
function onPay(order) {
var itemsArr = [];
var invoice = {};
var myItems = {};
var myItem = {};
myItem['name'] = order.data.name;
myItem['description'] = order.data.ordernumber;
myItem['quantity'] = "1.0";
myItem['unitPrice'] = order.data.amount;
myItem['taxRate'] = '0.0';
myItem['taxName'] = 'Tax';
itemsArr.push(myItem);
myItems['item'] = itemsArr;
invoice['itemList'] = myItems;
invoice['paymentTerms'] = 'DueOnReceipt';
invoice['currencyCode'] = 'GBP';
invoice['discountPercent'] = '0';
var ordernumber = order.data.order;
var returnUrl = window.open("http://example.com/api/" + ordernumber, "_blank");
var retUrl = encodeURIComponent(returnUrl + "/{result}/Type={Type}/InvoiceId={InvoiceId}/Tip={Tip}/Email={Email}/TxId={TxId}");
var pphereUrl = "paypalhere://takePayment/v2?returnUrl=" + retUrl;
pphereUrl = pphereUrl + '&invoice=' + escape(JSON.stringify(invoice));
console.log(pphereUrl);
return pphereUrl;
}