Authored by 王洪广

Merge branch 'feature/wechatloading' into release/4.5

@@ -8,18 +8,19 @@ var $ = require('jquery'); @@ -8,18 +8,19 @@ var $ = require('jquery');
8 var loading = require('../plugin/loading'), 8 var loading = require('../plugin/loading'),
9 tip = require('../plugin/tip'), 9 tip = require('../plugin/tip'),
10 Hammer = require('yoho.hammer'); 10 Hammer = require('yoho.hammer');
11 - 11 +// 点击微信显示加载
  12 +var $loadingToast = $(".loadingToast");
12 var theOrderCode = document.getElementById('ordercode').value; 13 var theOrderCode = document.getElementById('ordercode').value;
13 14
14 var wxPayEl = document.getElementById('weixin'), 15 var wxPayEl = document.getElementById('weixin'),
15 wxHammer = wxPayEl && new Hammer(wxPayEl); 16 wxHammer = wxPayEl && new Hammer(wxPayEl);
16 17
17 var appIconPosition = { 18 var appIconPosition = {
18 - baidu: '-2.7rem',  
19 - weixin: '-1.2rem',  
20 - QQ: '-5.4rem',  
21 - bank: '-4rem'  
22 - }; 19 + baidu: '-2.7rem',
  20 + weixin: '-1.2rem',
  21 + QQ: '-5.4rem',
  22 + bank: '-4rem'
  23 +};
23 24
24 // 隐藏微信分享选项 25 // 隐藏微信分享选项
25 if (window.wx) { 26 if (window.wx) {
@@ -27,7 +28,7 @@ if (window.wx) { @@ -27,7 +28,7 @@ if (window.wx) {
27 } 28 }
28 29
29 function onBridgeReady() { 30 function onBridgeReady() {
30 - document.addEventListener('WeixinJSBridgeReady', function() { 31 + document.addEventListener('WeixinJSBridgeReady', function () {
31 window.WeixinJSBridge && window.WeixinJSBridge.call('hideOptionMenu'); 32 window.WeixinJSBridge && window.WeixinJSBridge.call('hideOptionMenu');
32 }); 33 });
33 } 34 }
@@ -46,14 +47,15 @@ if (typeof WeixinJSBridge === undefined) { @@ -46,14 +47,15 @@ if (typeof WeixinJSBridge === undefined) {
46 47
47 // 调用微信JS api 支付 48 // 调用微信JS api 支付
48 function jsApiCall(orderCode, jsApiParameters) { 49 function jsApiCall(orderCode, jsApiParameters) {
  50 + $loadingToast.addClass("hide");
49 51
50 // 防止重复操作弹框 52 // 防止重复操作弹框
51 window.WeixinJSBridge && window.WeixinJSBridge.invoke( 53 window.WeixinJSBridge && window.WeixinJSBridge.invoke(
52 - 'getBrandWCPayRequest',  
53 - jsApiParameters,  
54 - function(res) {  
55 - window.location.href = '/home/orders/detail?order_code=' + orderCode;  
56 - } 54 + 'getBrandWCPayRequest',
  55 + jsApiParameters,
  56 + function (res) {
  57 + window.location.href = '/home/orders/detail?order_code=' + orderCode;
  58 + }
57 ); 59 );
58 } 60 }
59 61
@@ -61,6 +63,7 @@ function jsApiCall(orderCode, jsApiParameters) { @@ -61,6 +63,7 @@ function jsApiCall(orderCode, jsApiParameters) {
61 function callpay(orderCode) { 63 function callpay(orderCode) {
62 var jsApiParameters; 64 var jsApiParameters;
63 65
  66 + $loadingToast.removeClass("hide");
64 if (typeof WeixinJSBridge === undefined) { 67 if (typeof WeixinJSBridge === undefined) {
65 if (document.addEventListener) { 68 if (document.addEventListener) {
66 document.addEventListener('WeixinJSBridgeReady', jsApiCall, false); 69 document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
@@ -70,21 +73,24 @@ function callpay(orderCode) { @@ -70,21 +73,24 @@ function callpay(orderCode) {
70 } 73 }
71 } else { 74 } else {
72 $.ajax({ 75 $.ajax({
73 - type: 'GET',  
74 - url: '/shopping/pay/wechatwapapi?order_code=' + orderCode,  
75 - dataType: 'json',  
76 - success: function(res) {  
77 - if (res.code === 200) {  
78 - jsApiParameters = res.data.jsApiParameters;  
79 - jsApiCall(orderCode, jsApiParameters);  
80 - } else {  
81 - tip.show('微信支付调取失败');  
82 - }  
83 - },  
84 - error: function() {  
85 - tip.show('请刷新本页面,完成微信支付'); 76 + type: 'GET',
  77 + url: '/shopping/pay/wechatwapapi?order_code=' + orderCode,
  78 + dataType: 'json',
  79 + success: function (res) {
  80 + if (res.code === 200) {
  81 + jsApiParameters = res.data.jsApiParameters;
  82 + jsApiCall(orderCode, jsApiParameters);
  83 + } else {
  84 + tip.show('微信支付调取失败');
86 } 85 }
87 - }); 86 + },
  87 + error: function () {
  88 + tip.show('请刷新本页面,完成微信支付');
  89 + },
  90 + complete: function () {
  91 + $loadingToast.addClass("hide");
  92 + }
  93 + });
88 } 94 }
89 } 95 }
90 96
@@ -98,7 +104,7 @@ function isWXOpen() { @@ -98,7 +104,7 @@ function isWXOpen() {
98 function hideWeChatPay() { 104 function hideWeChatPay() {
99 var $payApps = $('.app'); 105 var $payApps = $('.app');
100 106
101 - $payApps.each(function(idx, app) { 107 + $payApps.each(function (idx, app) {
102 if ($(app).parent().attr('id') === 'weixin') { 108 if ($(app).parent().attr('id') === 'weixin') {
103 $(app).parent().css('display', 'none'); 109 $(app).parent().css('display', 'none');
104 return false; 110 return false;
@@ -122,7 +128,7 @@ function loadIcon() { @@ -122,7 +128,7 @@ function loadIcon() {
122 var $div = null; 128 var $div = null;
123 var appid = null; 129 var appid = null;
124 130
125 - $boxs.each(function(idx, box) { 131 + $boxs.each(function (idx, box) {
126 $div = $(box).find('.icon').find('div'); 132 $div = $(box).find('.icon').find('div');
127 if ($div.length > 0) { 133 if ($div.length > 0) {
128 appid = $(box).attr('id'); 134 appid = $(box).attr('id');
@@ -140,15 +146,15 @@ function showPage() { @@ -140,15 +146,15 @@ function showPage() {
140 function bindTouchedEvent() { 146 function bindTouchedEvent() {
141 var $boxs = $('.box'); 147 var $boxs = $('.box');
142 148
143 - $boxs.on('touchstart', function(e) { 149 + $boxs.on('touchstart', function (e) {
144 $(this).addClass('bytouch'); 150 $(this).addClass('bytouch');
145 - }).on('touchend touchcancel', function() { 151 + }).on('touchend touchcancel', function () {
146 $boxs.removeClass('bytouch'); 152 $boxs.removeClass('bytouch');
147 }); 153 });
148 } 154 }
149 155
150 if (wxHammer) { 156 if (wxHammer) {
151 - wxHammer.on('tap', function() { 157 + wxHammer.on('tap', function () {
152 callpay(theOrderCode); 158 callpay(theOrderCode);
153 }); 159 });
154 } 160 }
@@ -165,7 +171,7 @@ loading.showLoadingMask(); @@ -165,7 +171,7 @@ loading.showLoadingMask();
165 171
166 $(document).ready(main); 172 $(document).ready(main);
167 173
168 -$('.box').on('click', function() { 174 +$('.box').on('click', function () {
169 var url = $('.payapp-list a').attr('href'), 175 var url = $('.payapp-list a').attr('href'),
170 theRequest = [], 176 theRequest = [],
171 orderCode, 177 orderCode,
@@ -173,13 +179,13 @@ $('.box').on('click', function() { @@ -173,13 +179,13 @@ $('.box').on('click', function() {
173 179
174 if (url.indexOf("?") != -1) { 180 if (url.indexOf("?") != -1) {
175 theRequest = url.split('?')[1].split("&"); 181 theRequest = url.split('?')[1].split("&");
176 - orderCode=theRequest[0].split('=')[1];  
177 - payment=theRequest[1].split('=')[1]; 182 + orderCode = theRequest[0].split('=')[1];
  183 + payment = theRequest[1].split('=')[1];
178 } 184 }
179 185
180 $.ajax({ 186 $.ajax({
181 - url:'/shopping/pay/addPaymentInterval?orderCode=' + orderCode + '&payment=' + payment,  
182 - method:'get' 187 + url: '/shopping/pay/addPaymentInterval?orderCode=' + orderCode + '&payment=' + payment,
  188 + method: 'get'
183 }); 189 });
184 }); 190 });
185 191
@@ -66,4 +66,41 @@ @@ -66,4 +66,41 @@
66 font-size: 28px; 66 font-size: 28px;
67 } 67 }
68 } 68 }
  69 + /* 加载中 */
  70 + .loadingToast {
  71 + position: fixed;
  72 + z-index: 3;
  73 + width: 3.8em;
  74 + min-height: 3.8em;
  75 + top: 38%;
  76 + left: 50%;
  77 + margin-left: -1.9em;
  78 + background: rgba(40, 40, 40, 0.75);
  79 + text-align: center;
  80 + border-radius: 5px;
  81 + color: #FFFFFF;
  82 + }
  83 + .loadingToast:after{
  84 + content:'';
  85 + position: absolute;
  86 + left:50%;
  87 + top:50%;
  88 + margin-left: -.5rem;
  89 + margin-top: -.5rem;
  90 + width: 1rem;
  91 + height:1rem;
  92 + background: url("data:image/png;charset=utf-8;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkBAMAAAATLoWrAAAAAG5wVGOkIJ/OAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAbUExURQAAAP///////////////////////////////+tNPsIAAAAJdFJOUwD+ELHdi00wbfD3fpAAAADbSURBVCjPY2CgDLBnBBtHFCCLsIWGGgNBE5Ka1tBgoIiJcwJcqKI1NF2BqcLExQOuraMDbAybiUsAVKisA6pB1cUVwmBKS4epb3GBSLKnwW1ndXEC0+rlcHuYoBaUFyGckygClilHcjWLIMgwJiUFhBCHYABYCNlnggboQkyCDiBSATkABAUwQglTCKIRBUCMRwGsggHoQhCnooBEQQzTHUXRhZgFhdCFAlGMUgZhQWR97I4gR6G4qlGQKdURRZGyIBggm2QIFgliQFPliubwRkHM1OSImcKU4SwAH1UgWePsA0wAAAAASUVORK5CYII=");
  93 + background-size:1rem;
  94 + -webkit-animation: rotate .7s infinite;
  95 + -webkit-animation-timing-function: linear;
  96 + }
69 } 97 }
  98 +@-webkit-keyframes rotate {
  99 + 0% {
  100 + -webkit-transform: rotate(0deg)
  101 + }
  102 +
  103 + 100% {
  104 + -webkit-transform: rotate(360deg)
  105 + }
  106 +}
@@ -31,6 +31,7 @@ @@ -31,6 +31,7 @@
31 {{/if}} 31 {{/if}}
32 {{/ payAppInfo}} 32 {{/ payAppInfo}}
33 </div> 33 </div>
  34 + <div class="loadingToast hide"></div>
34 </div> 35 </div>
35 <script>_ozprm="orderid={{orderCode}}&ordertotal={{orderTotal}}";</script> 36 <script>_ozprm="orderid={{orderCode}}&ordertotal={{orderTotal}}";</script>
36 <script type="text/javascript" src ="//static.yohobuy.com/m/v1/js/AG_Tracking.js"></script> 37 <script type="text/javascript" src ="//static.yohobuy.com/m/v1/js/AG_Tracking.js"></script>