Authored by biao

switch to jquery as Liangzhifeng comments. code review by bikai

@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 var $ = require('jquery'); 6 var $ = require('jquery');
7 7
8 var loading = require('../plugin/loading'), 8 var loading = require('../plugin/loading'),
  9 + tip = require('../plugin/tip');
9 Hammer = require('yoho.hammer'); 10 Hammer = require('yoho.hammer');
10 11
11 var theOrderCode = document.getElementById('ordercode').value; 12 var theOrderCode = document.getElementById('ordercode').value;
@@ -17,7 +18,7 @@ var appIconPosition = { @@ -17,7 +18,7 @@ var appIconPosition = {
17 baidu: '-2.7rem', 18 baidu: '-2.7rem',
18 weixin: '-1.2rem', 19 weixin: '-1.2rem',
19 QQ: '-5.4rem', 20 QQ: '-5.4rem',
20 - bank: '-4' 21 + bank: '-4rem'
21 }; 22 };
22 23
23 //隐藏微信分享选项 24 //隐藏微信分享选项
@@ -77,11 +78,11 @@ function callpay(orderCode) { @@ -77,11 +78,11 @@ function callpay(orderCode) {
77 jsApiParameters = res.data.jsApiParameters; 78 jsApiParameters = res.data.jsApiParameters;
78 jsApiCall(orderCode, jsApiParameters); 79 jsApiCall(orderCode, jsApiParameters);
79 } else { 80 } else {
80 - alert('微信支付调取失败'); 81 + tip.show('微信支付调取失败');
81 } 82 }
82 }, 83 },
83 error: function() { 84 error: function() {
84 - alert('请刷新本页面,完成微信支付'); 85 + tip.show('请刷新本页面,完成微信支付');
85 } 86 }
86 }); 87 });
87 } 88 }
@@ -99,11 +100,11 @@ function isWXOpen() { @@ -99,11 +100,11 @@ function isWXOpen() {
99 } 100 }
100 101
101 function hideWeChatPay() { 102 function hideWeChatPay() {
102 - var payApps = document.getElementsByClassName('app'); 103 + var payApps = $('.app');
103 104
104 - [].forEach.call(payApps, function(app, index) {  
105 - if (app.innerHTML.indexOf('微信') !== -1) {  
106 - app.parentNode.style.display = 'none'; 105 + payApps.each(function(idx, app) {
  106 + if ($(app).attr('id') === 'weixin') {
  107 + $(app).parent().css('display', 'none');
107 return false; 108 return false;
108 } 109 }
109 }); 110 });
@@ -117,18 +118,18 @@ function handleForWX() { @@ -117,18 +118,18 @@ function handleForWX() {
117 118
118 119
119 function setAppIcon(el, position) { 120 function setAppIcon(el, position) {
120 - el.style.backgroundPositionY = position; 121 + $(el).css('background-position-y', position);
121 } 122 }
122 123
123 function loadIcon() { 124 function loadIcon() {
124 - var boxs = document.getElementsByClassName('box'); 125 + var boxs = $('.box');
125 var div = null; 126 var div = null;
126 var appid = null; 127 var appid = null;
127 128
128 - [].forEach.call(boxs, function(box, index) {  
129 - div = box.getElementsByClassName('icon')[0].getElementsByTagName('div')[0];  
130 - if (div) {  
131 - appid = box.getAttribute('id'); 129 + boxs.each(function(idx, box) {
  130 + div = $(box).find('.icon').find('div');
  131 + if (div.length > 0) {
  132 + appid = $(box).attr('id');
132 if (appid !== 'alipay') { 133 if (appid !== 'alipay') {
133 setAppIcon(div, appIconPosition[appid]); 134 setAppIcon(div, appIconPosition[appid]);
134 } 135 }
@@ -137,9 +138,9 @@ function loadIcon() { @@ -137,9 +138,9 @@ function loadIcon() {
137 } 138 }
138 139
139 function showPage() { 140 function showPage() {
140 - var pageList = document.getElementsByClassName('payapp-list')[0]; 141 + var pageList = $('.payapp-list');
141 142
142 - pageList.style.visibility = 'visible'; 143 + pageList.css('visibility', 'visible');
143 } 144 }
144 145
145 if (wxHammer) { 146 if (wxHammer) {
@@ -807,7 +807,7 @@ class HomeController extends AbstractAction @@ -807,7 +807,7 @@ class HomeController extends AbstractAction
807 ), 807 ),
808 ), 808 ),
809 'orderCode' => $orderCode, 809 'orderCode' => $orderCode,
810 - 'hasWxShare' => strpos($this->_request->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false 810 + 'hasWxShare' => strpos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false
811 )); 811 ));
812 } 812 }
813 813