pay.js
1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
* 支付页面
* @author: 赵彪<bill.zhao@yoho.cn>
* @date: 2015/12/03
*/
var loading = require('../plugin/loading');
function isWXOpen() {
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) === 'micromessenger') {
return true;
} else {
return false;
}
}
function hideWeChatPay() {
var payApps = document.getElementsByClassName('app');
[].forEach.call(payApps, function(app, index) {
if (app.innerHTML.indexOf('微信') !== -1) {
app.parentNode.style.display = 'none';
return false;
}
});
}
function handleForWX() {
if (!isWXOpen()) {
hideWeChatPay();
}
}
function setIcon(div, appName) {
if (appName.indexOf('百度') !== -1) {
div.style.backgroundPositionY = '-2.7rem';
return false;
}
if (appName.indexOf('微信') !== -1) {
div.style.backgroundPositionY = '-1.2rem';
return false;
}
if (appName.indexOf('银联') !== -1) {
div.style.backgroundPositionY = '-4rem';
return false;
}
if (appName.indexOf('QQ') !== -1) {
div.style.backgroundPositionY = '-5.4rem';
return false;
}
}
function loadIcon() {
var boxs = document.getElementsByClassName('box');
var div = null;
var appName = null;
[].forEach.call(boxs, function(box, index) {
div = box.getElementsByClassName('icon')[0].getElementsByTagName('div')[0];
if (div) {
appName = box.getElementsByClassName('app')[0].innerHTML;
setIcon(div, appName);
}
});
}
function showPage() {
var pageList = document.getElementsByClassName('payapp-list')[0];
pageList.style.visibility = 'visible';
}
function main() {
handleForWX();
loading.hideLoadingMask();
showPage();
loadIcon();
}
loading.showLoadingMask();
window.onload = main;