Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
bff8714b41 | ||
![]() |
7f12abf13f |
32
view/peko/modules/pay/css/default.css
Normal file
32
view/peko/modules/pay/css/default.css
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
html, body {
|
||||||
|
min-height: 100%;
|
||||||
|
background: #084f70;
|
||||||
|
font-family: "Helvetica Neue","Helvetica",Arial,sans-serif;
|
||||||
|
font-weight: 100;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #fff;
|
||||||
|
text-align: center;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitle {
|
||||||
|
font-size: 16px;
|
||||||
|
margin: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.note {
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
b {
|
||||||
|
font-weight: 300;
|
||||||
|
}
|
@@ -171,4 +171,4 @@
|
|||||||
<script src="../../common/js/common2.js"></script>
|
<script src="../../common/js/common2.js"></script>
|
||||||
<script src="../../common/js/layer.js"></script>
|
<script src="../../common/js/layer.js"></script>
|
||||||
<script src="../../common/js/vconsole.min.js"></script>
|
<script src="../../common/js/vconsole.min.js"></script>
|
||||||
<script src="./js/index.js?v=1.1"></script>
|
<script src="./js/index.js?v1.0"></script>
|
@@ -219,6 +219,11 @@ $('.page1 .position').on('click', 'div', function () {
|
|||||||
})
|
})
|
||||||
// 充值接口
|
// 充值接口
|
||||||
function apply2New () {
|
function apply2New () {
|
||||||
|
if (border.app) {
|
||||||
|
failureUrl = urlPrefix + '/peko/modules/pay/result.html?channelType=4&app=1';
|
||||||
|
} else {
|
||||||
|
failureUrl = urlPrefix + '/peko/modules/pay/result.html?channelType=4&app=0';
|
||||||
|
}
|
||||||
apply2NewLock = false;
|
apply2NewLock = false;
|
||||||
showLoading();
|
showLoading();
|
||||||
networkRequest({
|
networkRequest({
|
||||||
|
141
view/peko/modules/pay/js/redirect.js
Normal file
141
view/peko/modules/pay/js/redirect.js
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
|
||||||
|
// Written by Daniel Cohen Gindi
|
||||||
|
// danielgindi@gmail.com
|
||||||
|
// http://github.com/danielgindi/app-redirect
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
|
||||||
|
var queryString = {},
|
||||||
|
browserMovedToBackground = false;
|
||||||
|
|
||||||
|
// Parse the query string so we can take individual query string params
|
||||||
|
(function (search) {
|
||||||
|
|
||||||
|
search = (search || '').split(/[\&\?]/g);
|
||||||
|
for (var i = 0, count = search.length; i < count; i++) {
|
||||||
|
if (!search[i]) continue;
|
||||||
|
var pair = search[i].split('=');
|
||||||
|
queryString[pair[0]] = queryString[pair[0]] !== undefined ?
|
||||||
|
([pair[1] || ''].concat(queryString[pair[0]])) :
|
||||||
|
(pair[1] || '');
|
||||||
|
}
|
||||||
|
|
||||||
|
})(window.location.search);
|
||||||
|
|
||||||
|
// Listen to visibility change to prevent next url
|
||||||
|
window.document.addEventListener("visibilitychange", function(e) {
|
||||||
|
browserMovedToBackground = window.document.visibilityState === 'hidden' || window.document.visibilityState === 'unloaded';
|
||||||
|
});
|
||||||
|
window.addEventListener("blur", function(e) {
|
||||||
|
browserMovedToBackground = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
var AppRedirect = {
|
||||||
|
/**
|
||||||
|
* @expose
|
||||||
|
* @public
|
||||||
|
* */
|
||||||
|
queryString: queryString,
|
||||||
|
|
||||||
|
redirect: function (options) {
|
||||||
|
|
||||||
|
var hasIos = !!(options.iosApp || options.iosAppStore);
|
||||||
|
var hasAndroid = !!(options.android);
|
||||||
|
var hasOverallFallback = !!(options.overallFallback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What happens now is:
|
||||||
|
* 1. We select the correct platform based on userAgent
|
||||||
|
* 2. We try to open the app using the special schema
|
||||||
|
*
|
||||||
|
* └───> If it succeded, the we have left the browser, and went to the app.
|
||||||
|
* *. If the user goes back to the browser at this stage, he will be sadly redirected to the second url (AppStore etc.)
|
||||||
|
* └───> If opening the app failed (schema not recognized), then:
|
||||||
|
* 1. An error will be shown
|
||||||
|
* 2. The user will be redirected to the second url.
|
||||||
|
* *. Returning to the browser later will show the error.
|
||||||
|
*
|
||||||
|
* For Android it's different. There's the intent:// url, which takes the "package" argument in order to fallback to the Store.
|
||||||
|
* But if you want to aggregate arguments to the store, you can use the "fallback" argument for that, and supply a Store url.
|
||||||
|
* QueryString arguments will be automatically aggregated.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var tryToOpenInMultiplePhases = function(urls) {
|
||||||
|
|
||||||
|
browserMovedToBackground = false;
|
||||||
|
|
||||||
|
var currentIndex = 0;
|
||||||
|
var redirectTime = new Date();
|
||||||
|
window.location = urls[currentIndex++];
|
||||||
|
|
||||||
|
var next = function () {
|
||||||
|
if (urls.length > currentIndex) {
|
||||||
|
setTimeout(function () {
|
||||||
|
|
||||||
|
if (browserMovedToBackground) {
|
||||||
|
console.log('Browser moved to the background, we assume that we are done here')
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (new Date() - redirectTime > 3000) {
|
||||||
|
console.log('Enough time has passed, the app is probably open');
|
||||||
|
} else {
|
||||||
|
redirectTime = new Date();
|
||||||
|
window.location = urls[currentIndex++];
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
|
||||||
|
}, 10);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
next();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// var chromeVersion = /Chrome\/([0-9\.]+)/.test(navigator.userAgent) ? navigator.userAgent.match(/Chrome\/([0-9\.]+)/)[1] : '';
|
||||||
|
|
||||||
|
if (hasIos && /iP(hone|ad|od)/.test(navigator.userAgent)) {
|
||||||
|
|
||||||
|
var urls = [];
|
||||||
|
if (options.iosApp) {
|
||||||
|
urls.push(options.iosApp);
|
||||||
|
}
|
||||||
|
if (options.iosAppStore) {
|
||||||
|
urls.push(options.iosAppStore);
|
||||||
|
}
|
||||||
|
tryToOpenInMultiplePhases(urls);
|
||||||
|
|
||||||
|
} else if (hasAndroid && /Android/.test(navigator.userAgent)) {
|
||||||
|
|
||||||
|
var intent = options.android;
|
||||||
|
var intentUrl = 'intent://' + intent.host + '#Intent;' +
|
||||||
|
'scheme=' + encodeURIComponent(intent.scheme) + ';' +
|
||||||
|
'package=' + encodeURIComponent(intent.package) + ';' +
|
||||||
|
(intent.action ? 'action=' + encodeURIComponent(intent.action) + ';': '') +
|
||||||
|
(intent.category ? 'category=' + encodeURIComponent(intent.category) + ';': '') +
|
||||||
|
(intent.component ? 'component=' + encodeURIComponent(intent.component) + ';': '') +
|
||||||
|
(intent.fallback ? 'S.browser_fallback_url=' + encodeURIComponent(intent.fallback) + ';': '') +
|
||||||
|
'end';
|
||||||
|
var anchor = document.createElement('a');
|
||||||
|
document.body.appendChild(anchor);
|
||||||
|
anchor.href = intentUrl;
|
||||||
|
if (anchor.click) {
|
||||||
|
anchor.click();
|
||||||
|
} else {
|
||||||
|
window.location = intentUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if(hasOverallFallback) {
|
||||||
|
window.location = options.overallFallback;
|
||||||
|
} else {
|
||||||
|
console.log('Unknown platform and no overallFallback URL, nothing to do');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** @expose */
|
||||||
|
window.AppRedirect = AppRedirect;
|
||||||
|
|
||||||
|
})();
|
@@ -24,6 +24,8 @@ const toastMsg = (content = '操作完成', time = 2) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
var chargeRecordId = null;//订单号
|
var chargeRecordId = null;//订单号
|
||||||
|
var chargeStatus = 0;
|
||||||
|
var isApp = 0;
|
||||||
$(function () {
|
$(function () {
|
||||||
if (EnvCheck() == 'test') {//degBug
|
if (EnvCheck() == 'test') {//degBug
|
||||||
new VConsole();
|
new VConsole();
|
||||||
@@ -44,11 +46,12 @@ function getChargeResult () {
|
|||||||
success: function (res) {
|
success: function (res) {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
$('.success').show();
|
$('.success').show();
|
||||||
|
chargeStatus = 1;
|
||||||
} else {
|
} else {
|
||||||
|
chargeStatus = 0;
|
||||||
$('.result span').text(`原因:${res.message}`);
|
$('.result span').text(`原因:${res.message}`);
|
||||||
$('.err').show();
|
$('.err').show();
|
||||||
hideLoading(layerIndex);
|
hideLoading(layerIndex);
|
||||||
// toastMsg(res.message);
|
|
||||||
}
|
}
|
||||||
hideLoading(layerIndex);
|
hideLoading(layerIndex);
|
||||||
},
|
},
|
||||||
@@ -58,6 +61,35 @@ function getChargeResult () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$('.result .but').click(function(){
|
$('.result .but').click(function () {
|
||||||
window.location.href = urlPrefix + '/peko/modules/pay/index.html?channelType=4';
|
isApp = getUrl.app;
|
||||||
})
|
if (isApp == 1) {
|
||||||
|
if (browser.app) {
|
||||||
|
window.location.href = urlPrefix + '/peko/modules/pay/index.html?channelType=4';
|
||||||
|
} else {
|
||||||
|
window.location.href = `pekoapp://payment/result?status=${chargeStatus}`;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
window.location.href = urlPrefix + '/peko/modules/pay/index.html?channelType=4';
|
||||||
|
}
|
||||||
|
return
|
||||||
|
var qs = AppRedirect.queryString;
|
||||||
|
// Here we initiate the redirect process
|
||||||
|
AppRedirect.redirect({
|
||||||
|
iosApp: 'twitter://post?message=' + qs['message'],
|
||||||
|
iosAppStore: 'https://itunes.apple.com/il/app/twitter/id333903271?mt=8&message=' + qs['message'],
|
||||||
|
// 为此,你的应用需要有一个类别过滤器:android.intent.category.BROWSABLE
|
||||||
|
android: {
|
||||||
|
// 'host': 'post/?message=' + encodeURIComponent(qs['message']), // 自定义方案URL中的Host/path/querystring部分
|
||||||
|
// 'action': ", //相当于intent中的action
|
||||||
|
// 'category': ', //相当于intent中的category
|
||||||
|
// 'component': ', //相当于intent中的component
|
||||||
|
// 'scheme': 'twitter', // 自定义方案URL中的方案部分
|
||||||
|
// 'package': 'com.twitter.android', // Play store中的包名
|
||||||
|
// 'fallback': 'https://play.google.com/store/apps/details?id=com.twitter.android&hl=en&message=' + qs['message']
|
||||||
|
'scheme': 'pekoapp',
|
||||||
|
'host': 'payment/result'
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
})
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>储值结果</title>
|
<title>储值结果</title>
|
||||||
<link rel="stylesheet" href="../../common/css/reset.css">
|
<link rel="stylesheet" href="../../common/css/reset.css">
|
||||||
|
<link rel="stylesheet" href="./css/default.css">
|
||||||
<link rel="stylesheet" href="./css/result.css">
|
<link rel="stylesheet" href="./css/result.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@@ -15,12 +16,12 @@
|
|||||||
<img src="./images/err.png" alt="">
|
<img src="./images/err.png" alt="">
|
||||||
<p>储值失败</p>
|
<p>储值失败</p>
|
||||||
<span>原因:xxxxx</span>
|
<span>原因:xxxxx</span>
|
||||||
<div class="but">返回储值页面</div>
|
<div class="but">返回</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="result success">
|
<div class="result success">
|
||||||
<img src="./images/success.png" alt="">
|
<img src="./images/success.png" alt="">
|
||||||
<p>储值成功</p>
|
<p>储值成功</p>
|
||||||
<div class="but">确认</div>
|
<div class="but">确认</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
@@ -30,4 +31,5 @@
|
|||||||
<script src="../../common/js/common2.js"></script>
|
<script src="../../common/js/common2.js"></script>
|
||||||
<script src="../../common/js/layer.js"></script>
|
<script src="../../common/js/layer.js"></script>
|
||||||
<script src="../../common/js/vconsole.min.js"></script>
|
<script src="../../common/js/vconsole.min.js"></script>
|
||||||
<script src="./js/result.js"></script>
|
<script src="./js/redirect.js"></script>
|
||||||
|
<script src="./js/result.js?v1.0"></script>
|
Reference in New Issue
Block a user