diff --git a/src/main/ui/static/templates/alipay/v1/bill_retail_jsapi.js b/src/main/ui/static/templates/alipay/v1/bill_retail_jsapi.js
index 4afadc43b..1b4a99494 100644
--- a/src/main/ui/static/templates/alipay/v1/bill_retail_jsapi.js
+++ b/src/main/ui/static/templates/alipay/v1/bill_retail_jsapi.js
@@ -37,6 +37,14 @@ $(document).ready(function () {
location.href = window.redirect;
return;
}
+ if (pay.web_url) {
+ location.href = pay.web_url;
+ return;
+ }
+ if (pay.mweb_url) {
+ location.href = pay.mweb_url;
+ return;
+ }
if (window.AlipayJSBridge) {
callPayment();
} else {
diff --git a/src/main/ui/static/templates/alipay/v1/gateway_jsapi.js b/src/main/ui/static/templates/alipay/v1/gateway_jsapi.js
index dddac6e4e..d2e791774 100644
--- a/src/main/ui/static/templates/alipay/v1/gateway_jsapi.js
+++ b/src/main/ui/static/templates/alipay/v1/gateway_jsapi.js
@@ -57,9 +57,9 @@ $(document).ready(function () {
} else {
// 如果没有注入则监听注入的事件
document.addEventListener('AlipayJSBridgeReady', function () {
-
+ callPayment(pay.trade_no);
});
- callPayment(pay.trade_no);
+
}
},
diff --git a/src/main/ui/static/templates/alipay/v1/retail_jsapi.js b/src/main/ui/static/templates/alipay/v1/retail_jsapi.js
index 6e1145907..274404c2f 100644
--- a/src/main/ui/static/templates/alipay/v1/retail_jsapi.js
+++ b/src/main/ui/static/templates/alipay/v1/retail_jsapi.js
@@ -4,18 +4,21 @@
$(document).ready(function () {
'use strict';
decode();
+
function decode() {
var redirect = window.redirect;
- while(redirect.indexOf('://')<0){
+ while (redirect.indexOf('://') < 0) {
redirect = decodeURIComponent(redirect);
- if(redirect==window.redirect){
+ if (redirect == window.redirect) {
break;
}
window.redirect = redirect;
}
}
+
var dataCache = {paying: false};
$('#key_P').bind('touchstart', startPay);
+
function startPay() {
$('#wdiv').show();
if (dataCache.paying) {
@@ -32,6 +35,9 @@ $(document).ready(function () {
location.href = window.redirect;
return;
}
+ if (window.client_moniker == 'PINE') {
+ alert(JSON.stringify(pay))
+ }
if (pay.web_from) {
$('#alipay_plus').html(pay.web_from)
startCheckOrder(window.order_id, window.redirect);
@@ -94,7 +100,7 @@ $(document).ready(function () {
setTimeout(checkOrderStd, 500);
}
},
- error:function (){
+ error: function () {
setTimeout(checkOrderStd, 500);
}
})
diff --git a/src/main/ui/static/templates/alipayaps/v1/gateway_jsapi.js b/src/main/ui/static/templates/alipayaps/v1/gateway_jsapi.js
new file mode 100644
index 000000000..c88db1939
--- /dev/null
+++ b/src/main/ui/static/templates/alipayaps/v1/gateway_jsapi.js
@@ -0,0 +1,73 @@
+$(document).ready(function (){
+
+ decode();
+
+ function decode() {
+ if (window.client_moniker == 'PINE') {
+ alert('debug:origin redirect:' + window.redirect);
+ }
+ let redirect = window.redirect;
+ if (window.redirect !=null) {
+ while (redirect.indexOf('://') < 0) {
+ redirect = decodeURIComponent(redirect);
+ if (redirect == window.redirect) {
+ break;
+ }
+ window.redirect = redirect;
+ }
+ }
+
+ }
+
+ let dataCache = {paying: false};
+ $('#key_P').bind('touchstart', startPay);
+ function startPay() {
+ $('#wdiv').show();
+ if (dataCache.paying) {
+ return;
+ }
+ dataCache.paying = true;
+
+ $.ajax({
+ url: './preorder',
+ method: 'GET',
+ dataType: 'json',
+ success: function (pay) {
+ if (pay.direct_paid) {
+ startCheckOrder(window.client_moniker, window.merchant_orderid);
+ return;
+ }
+ if (pay.mweb_url){
+ location.href = pay.mweb_url
+ }
+
+ },
+ error: function (jqXhr) {
+ alert(jqXhr.responseJSON.message);
+ $('#wdiv').hide();
+ dataCache.paying = false;
+ }
+ })
+
+
+ }
+
+ function startCheckOrder(clientMoniker, merchantOrderId) {
+ function checkOrderStd() {
+ $.ajax({
+ url: '/api/v1.0/payment/clients/' + clientMoniker + '/orders/' + merchantOrderId + '/status',
+ method: 'GET',
+ dataType: 'json',
+ success: function (res) {
+ if (res.paid) {
+ location.href = window.redirect + (window.redirect.indexOf('?') < 0 ? '?' : '&') + 'success=true&time=' + res.time + '&nonce_str=' + res.nonce_str + '&sign=' + res.sign;
+ } else {
+ setTimeout(checkOrderStd, 500);
+ }
+ }
+ })
+ }
+
+ checkOrderStd();
+ }
+})
\ No newline at end of file
diff --git a/src/main/ui/static/templates/alipayaps/v1/payment.js b/src/main/ui/static/templates/alipayaps/v1/payment.js
new file mode 100644
index 000000000..0a49f9143
--- /dev/null
+++ b/src/main/ui/static/templates/alipayaps/v1/payment.js
@@ -0,0 +1,444 @@
+/**
+ * Created by yixian on 2017-05-08
+ */
+$(function () {
+ 'use strict';
+ // document.querySelector('body').addEventListener('touchmove', function (e) {
+ // if (!document.querySelector('.coupons').contains(e.target)) {
+ // e.preventDefault();
+ // }
+ // })
+ var dataCache = {price: '0', coupons: [], coupon_groups: {}};
+ var exchangeRate = parseFloat(window.exchange_rate);
+
+ if (window.AlipayJSBridge) {
+ AlipayJSBridge.call('hideOptionMenu');
+ } else {
+ document.addEventListener('AlipayJSBridgeReady', function () {
+ AlipayJSBridge.call('hideOptionMenu');
+ }, false);
+ }
+ dataCache.paying = false;
+ var ctrl = {};
+
+ $('.ff.key').bind('touchstart', function () {
+ if (dataCache.paying) {
+ return;
+ }
+ var char = $(this).attr('data-char');
+ appendChar(char);
+ });
+
+ $('.coupons .use-check').click(function () {
+ if ($(this).hasClass('disabled')) {
+ return;
+ }
+ var couponId = $(this).attr('data-coupon-id');
+ var couponGroup = $(this).attr('data-coupon-group');
+ if (couponGroup) {
+ var prevCouponId = dataCache.coupon_groups[couponGroup];
+ if (prevCouponId) {
+ var prevIdx = dataCache.coupons.indexOf(prevCouponId);
+ if (prevIdx >= 0) {
+ dataCache.coupons.splice(prevIdx, 1);
+ }
+ if (prevCouponId != couponId) {
+ $('.coupons .use-check[data-coupon-id="' + prevCouponId + '"]').removeClass('checked').addClass('unchecked');
+ dataCache.coupon_groups[couponGroup] = couponId;
+ } else {
+ dataCache.coupon_groups[couponGroup] = null;
+ }
+ } else {
+ dataCache.coupon_groups[couponGroup] = couponId;
+ }
+
+ }
+
+ if ($(this).is('.checked')) {
+ $(this).removeClass('checked').addClass('unchecked');
+ } else {
+ $(this).removeClass('unchecked').addClass('checked');
+ }
+ var checked = $(this).is('.checked');
+ if (checked) {
+ dataCache.coupons.push(couponId);
+ updatePrice();
+ } else {
+ var idx = dataCache.coupons.indexOf(couponId);
+ dataCache.coupons.splice(idx, 1);
+ updatePrice();
+ }
+ });
+
+ $('#key_B').bind('touchstart', function () {
+ backspace();
+ });
+
+ function updatePoundage(price) {
+ if (window.extensions.indexOf('customerrate') >= 0 && window.rateValue != null) {
+ if (window.use_customised_rate) {
+ var rate = new Decimal(100).plus(window.rateValue).div(100);
+ var poundageValue = new Decimal(dataCache.price).mul(rate).sub(dataCache.price);
+ } else {
+ var rateRemain = new Decimal(100).sub(window.rateValue).div(100);
+ poundageValue = new Decimal(dataCache.price).div(rateRemain).sub(dataCache.price);
+ }
+ dataCache.poundageValue = poundageValue.toFixed(2, Decimal.ROUND_HALF_UP);
+ return poundageValue.plus(price).toFixed(2, Decimal.ROUND_HALF_UP);
+ }
+ return price;
+ }
+
+ function updatePrice() {
+ $('#audVal').html(dataCache.price);
+ var realPrice = dataCache.price;
+ $('#audValReal').html(realPrice);
+ var surchargeData = calculateSurcharge(realPrice);
+
+ var price = surchargeData.newPrice || realPrice;
+ var priceBeforeDiscount = price;
+ dataCache.discounts = [];
+ dataCache.tax = surchargeData.tax;
+ dataCache.surcharge = surchargeData.surcharge;
+
+ $(window.coupons).each(function () {
+ price = this.handleDiscount(price, dataCache.price, dataCache.discounts, dataCache.coupons);
+ });
+ dataCache.customSurcharge = new Decimal(price).sub(realPrice).toFixed(2, Decimal.ROUND_HALF_UP);
+ dataCache.finalPrice = new Decimal(price).toFixed(2, Decimal.ROUND_FLOOR);
+ var rate = 'CNY' == window.currency ? 1 : exchangeRate;
+ var cnyVal = Decimal.mul(price, rate).toFixed(2, Decimal.ROUND_HALF_UP);
+ $('#cnyVal').html(cnyVal);
+ dataCache.currencyPrice = 'CNY' == window.currency ? Decimal.div(priceBeforeDiscount, exchangeRate).toFixed(2, Decimal.ROUND_FLOOR) : priceBeforeDiscount;
+ }
+
+ function updatePoundageStatus() {
+ $(window.coupons).each(function () {
+ var coupon = this;
+ var couponId = coupon.couponId();
+ if (coupon.isEnable(dataCache.currencyPrice || 0)) {
+ $('.coupons .use-check[data-coupon-id=' + couponId + ']').removeClass('disabled');
+ } else {
+ var dom = $('.coupons .use-check[data-coupon-id=' + couponId + ']').addClass('disabled');
+ var couponGroup = dom.attr('data-coupon-group');
+ if (couponGroup) {
+ if (dataCache.coupon_groups[couponGroup] == couponId) {
+ dataCache.coupon_groups[couponGroup] = null;
+ }
+ }
+ var idx = dataCache.coupons.indexOf(couponId);
+ if (idx >= 0) {
+ dataCache.coupons.splice(idx, 1);
+ }
+ dom.removeClass('checked').addClass('unchecked');
+ }
+ })
+ }
+
+ updatePoundageStatus();
+
+ function backspace() {
+ dataCache.price = dataCache.price.substring(0, dataCache.price.length - 1);
+ if (dataCache.price.length == 0) {
+ dataCache.price = '0';
+ }
+ updatePrice();
+ updatePoundageStatus();
+ }
+
+ function appendChar(char) {
+ var pointLocation = dataCache.price.indexOf('.');
+ if (pointLocation >= 0 || char == '.' || dataCache.price.length < 5) {
+ if (pointLocation >= 0 && char == '.') {
+ return;
+ }
+ if (pointLocation >= 0 && pointLocation <= dataCache.price.length - 3) {
+ return;
+ }
+ if (dataCache.price == '0' && char != '.') {
+ dataCache.price = '';
+ }
+ dataCache.price += char;
+ updatePrice();
+ updatePoundageStatus();
+ }
+ }
+
+ $('#coupon-box-toggle').click(function () {
+ $('.coupons-container').addClass('show');
+ });
+ $('.coupons-container>.coupons-mask,.coupons-container #close-coupon-box').click(function () {
+ $(this).parents('.coupons-container').removeClass('show');
+ });
+
+
+ $('.remark-btn').click(function () {
+ var cfg = {
+ title: '备注 Remark',
+ template: '',
+ initialize: function (dialog) {
+ $('
').addClass('remark-input').attr('name', 'remark').val(dataCache.remark || '').appendTo($('.weui_dialog_bd', dialog));
+ },
+ confirm: function (dialog, chosen) {
+ if (chosen) {
+ var remark = $('textarea[name="remark"]', dialog).val();
+ if (remark) {
+ $('#remark-box').text('备注:' + remark).show()
+ } else {
+ $('#remark-box').text('').hide();
+ }
+ dataCache.remark = remark;
+ }
+
+ }
+ };
+ showWeuiDialog(cfg);
+ });
+
+ $('.paydetail').click(function () {
+ var config = {
+ title: 'Payment Detail',
+ template: '',
+ initialize: function (dialog) {
+ var bd = $('.weui_dialog_bd', dialog);
+ var currencySymbol = window.currency == 'AUD' ? '$' : '¥';
+ $('
').html('Input Price 输入金额:' + currencySymbol + dataCache.price).appendTo(bd);
+ if (parseFloat(dataCache.customSurcharge) > 0) {
+ $('
').html('Surcharge 手续费(' + window.rateValue + '%):+' + currencySymbol + dataCache.customSurcharge).appendTo(bd);
+ $('
').addClass('warning-sm').html('温馨提示:商户将向您收取本次消费手续费' + window.rateValue + '%').appendTo(bd);
+ }
+ $(dataCache.discounts).each(function () {
+ $('
').html(this.title + ':-' + currencySymbol + this.amount).appendTo(bd);
+ });
+ $('
').addClass('final').html('Final 支付金额:' + currencySymbol + (dataCache.finalPrice || 0)).appendTo(bd);
+ }
+ };
+ showWeuiDialog(config);
+ });
+
+ $('#key_P').click(function () {
+ if (window.requireRemark) {
+ if (!dataCache.remark) {
+ var config = {
+ title: '请先输入备注',
+ template: ''
+ };
+ showWeuiDialog(config);
+ }
+
+ }
+ });
+
+ $('#key_P').bind('touchstart', function () {
+ if (window.requireRemark) {
+ if (!dataCache.remark) {
+ return;
+ }
+ }
+ $('#key_P').addClass('hidden');
+ $('#key_Loading').removeClass('hidden');
+ if (dataCache.paying) {
+ return;
+ }
+ dataCache.paying = true;
+ var data = {price: dataCache.price + '', original_number: true, currency: window.currency};
+ if (dataCache.remark) {
+ data.description = dataCache.remark;
+ }
+ if (window.extensions.indexOf('preauthorize') >= 0) {
+ data.preauthorize = true;
+ }
+ if (window.extensions.indexOf('qrcodemode') >= 0) {
+ data.qrmode = true;
+ }
+ if (window.extensions.indexOf('customerrate') >= 0) {
+ data.customerrate = true;
+ }
+ data.coupons = dataCache.coupons;
+ data.qrcodeVersion = window.qrcodeVersion;
+
+ $.ajax({
+ url: '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders',
+ method: 'POST',
+ data: JSON.stringify(data),
+ contentType: 'application/json',
+ dataType: 'json',
+ success: function (pay) {
+ if (pay.direct_paid) {
+ location.href = '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result';
+ return;
+ }
+ if (pay.mweb_url){
+ location.href = pay.mweb_url;
+ return;
+ }
+ if (window.AlipayJSBridge) {
+ callPayment();
+ } else {
+ // 如果没有注入则监听注入的事件
+ document.addEventListener('AlipayJSBridgeReady', callPayment, false);
+ }
+
+ function callPayment() {
+ try {
+ AlipayJSBridge.call('tradePay', {
+ tradeNO: pay.trade_no
+ }, function (res) {
+ dataCache.paying = false;
+ if (res.resultCode == '9000') {
+ AlipayJSBridge.call('startApp', {
+ appId: '20000056',
+ param: {
+ actionType: 'showSuccPage',
+ payResult: res.result
+ },
+ closeCurrentApp: false
+ });
+ startCheckOrder(pay.order_id, '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result');
+ } else if (res.resultCode == '6001') {
+ //do nothing
+ } else {
+ if (res.memo) {
+ weuiAlert(res.memo);
+ }
+ }
+ $('#key_P').removeClass('hidden');
+ $('#key_Loading').addClass('hidden');
+ })
+ } catch (err) {
+ weuiAlert(err)
+ }
+ }
+ },
+ error: function (jqXhr) {
+ weuiAlert(jqXhr.responseJSON.message);
+ $('#key_P').removeClass('hidden');
+ $('#key_Loading').addClass('hidden');
+ dataCache.paying = false;
+ }
+ })
+ });
+
+ function startCheckOrder(orderId, url) {
+ function checkOrderStd() {
+ $.ajax({
+ url: '/api/v1.0/payment/orders/' + orderId + '/status',
+ method: 'GET',
+ dataType: 'json',
+ success: function (res) {
+ if (res.paid) {
+ location.href = url;
+ } else {
+ setTimeout(checkOrderStd, 500);
+ }
+ }
+ })
+ }
+
+ checkOrderStd();
+ }
+
+ function weuiAlert(msg) {
+ var config = {
+ template: msg
+ };
+ showWeuiDialog(config);
+ }
+
+ function showWeuiDialog(config) {
+ if (config.templateUrl) {
+ $.ajax({
+ url: config.templateUrl,
+ dataType: 'html',
+ success: function (template) {
+ buildDialog(template);
+ }
+ });
+ } else {
+ buildDialog(config.template);
+ }
+
+
+ function buildDialog(template) {
+ var defaultConfig = {backdrop: true};
+ config = $.extend({}, defaultConfig, config);
+ var dialog = $("
", {class: 'weui_dialog_confirm'});
+ var mask = $('
', {class: 'weui_mask'}).appendTo(dialog);
+ if (config.backdrop) {
+ mask.click(function () {
+ dialog.remove();
+ if ($.isFunction(config.dismiss)) {
+ config.dismiss();
+ }
+ })
+ }
+ var dialogBox = $("
", {class: 'weui_dialog'}).appendTo(dialog);
+ if (config.title) {
+ $('
', {class: 'weui_dialog_hd'}).append($('
', {class: 'weui_dialog_title'}).html(config.title)).appendTo(dialogBox);
+ }
+ var dialogBody = $("
", {class: 'weui_dialog_bd'}).appendTo(dialogBox);
+ if (template) {
+ dialogBody.append(template);
+ }
+ if ($.isFunction(config.initialize)) {
+ config.initialize(dialog);
+ }
+ var ft = $('
').appendTo(dialogBox);
+ if(window.paypad_version !== 'v3'){
+ if ($.isFunction(config.confirm)) {
+ var yes = $('
', {
+ class: 'weui_btn_dialog primary',
+ text: 'OK',
+ style: 'background: #108ee9;color: #fff;'
+ }).appendTo(ft);
+ yes.click(function () {
+ config.confirm(dialog, true);
+ dialog.remove();
+ });
+ var no = $('
', {class: 'weui_btn_dialog default', text: 'Cancel'}).appendTo(ft);
+ no.click(function () {
+ config.confirm(dialog, false);
+ dialog.remove();
+ })
+ } else {
+ var ok = $('
', {
+ class: 'weui_btn_dialog primary',
+ text: 'OK',
+ style: 'background: #108ee9;color: #fff;'
+ }).appendTo(ft);
+ ok.click(function () {
+ dialog.remove();
+ })
+ }
+ }else{
+ if ($.isFunction(config.confirm)) {
+ var yes = $('
', {
+ class: 'weui_btn_dialog primary',
+ text: 'OK',
+ style: 'background: #FF9705;color: #fff;'
+ }).appendTo(ft);
+ yes.click(function () {
+ config.confirm(dialog, true);
+ dialog.remove();
+ });
+ var no = $('
', {class: 'weui_btn_dialog default', text: 'Cancel'}).appendTo(ft);
+ no.click(function () {
+ config.confirm(dialog, false);
+ dialog.remove();
+ })
+ } else {
+ var ok = $('
', {
+ class: 'weui_btn_dialog primary',
+ text: 'OK',
+ style: 'background: #FF9705;color: #fff;'
+ }).appendTo(ft);
+ ok.click(function () {
+ dialog.remove();
+ })
+ }
+ }
+ dialog.appendTo($('body'));
+ }
+
+ }
+});
diff --git a/src/main/ui/static/templates/alipayaps/v4/payment.js b/src/main/ui/static/templates/alipayaps/v4/payment.js
new file mode 100644
index 000000000..be2d64c9a
--- /dev/null
+++ b/src/main/ui/static/templates/alipayaps/v4/payment.js
@@ -0,0 +1,488 @@
+/**
+ * Created by yixian on 2017-05-08
+ */
+var num = function(obj){
+ obj.value = obj.value.replace(/[^\d.]/g,""); //清除"数字"和"."以外的字符
+ obj.value = obj.value.replace(/^\./g,""); //验证第一个字符是数字
+ obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个, 清除多余的
+ obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
+ obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'); //只能输入两个小数
+};
+
+$(function () {
+ 'use strict';
+ // document.querySelector('body').addEventListener('touchmove', function(e) {
+ // if (!document.querySelector('.coupons').contains(e.target)) {
+ // e.preventDefault();
+ // }
+ // });
+ var dataCache = {price: '0', coupons: [], coupon_groups: {}};
+ var exchangeRate = parseFloat(window.exchange_rate);
+
+ if (window.AlipayJSBridge) {
+ AlipayJSBridge.call('hideOptionMenu');
+ } else {
+ document.addEventListener('AlipayJSBridgeReady', function () {
+ AlipayJSBridge.call('hideOptionMenu');
+ }, false);
+ }
+ dataCache.paying = false;
+ var ctrl = {};
+
+ $('.ff.key').bind('touchstart', function () {
+ if (dataCache.paying) {
+ return;
+ }
+ var char = $(this).attr('data-char');
+ appendChar(char);
+ });
+
+ $('#audVal').bind('input porpertychange', function () {
+ if (dataCache.paying) {
+ return;
+ }
+ var char = $(this).val();
+ if (parseFloat(char) >= 100000) {
+ char = char.slice(0, char.length - 1);
+ $(this).val(char);
+ return;
+ }
+ appendChar(char);
+ });
+
+ $('.coupons .use-check').click(function () {
+ if ($(this).hasClass('disabled')) {
+ return;
+ }
+ var couponId = $(this).attr('data-coupon-id');
+ var couponGroup = $(this).attr('data-coupon-group');
+ if (couponGroup) {
+ var prevCouponId = dataCache.coupon_groups[couponGroup];
+ if (prevCouponId) {
+ var prevIdx = dataCache.coupons.indexOf(prevCouponId);
+ if (prevIdx >= 0) {
+ dataCache.coupons.splice(prevIdx, 1);
+ }
+ if (prevCouponId != couponId) {
+ $('.coupons .use-check[data-coupon-id="' + prevCouponId + '"]').removeClass('checked').addClass('unchecked');
+ dataCache.coupon_groups[couponGroup] = couponId;
+ } else {
+ dataCache.coupon_groups[couponGroup] = null;
+ }
+ } else {
+ dataCache.coupon_groups[couponGroup] = couponId;
+ }
+
+ }
+
+ if ($(this).is('.checked')) {
+ $(this).removeClass('checked').addClass('unchecked');
+ } else {
+ $(this).removeClass('unchecked').addClass('checked');
+ }
+ var checked = $(this).is('.checked');
+ if (checked) {
+ dataCache.coupons.push(couponId);
+ updatePrice();
+ } else {
+ var idx = dataCache.coupons.indexOf(couponId);
+ dataCache.coupons.splice(idx, 1);
+ updatePrice();
+ }
+ });
+ $('.cb_bankpay').click(function () {
+ $.ajax({
+ url: '/sys/partners/' + window.client_moniker + '/jump/link',
+ method: 'GET',
+ success: function (res) {
+ location.href = res;
+ },
+ error: function (resp) {
+ var config = {
+ template: resp
+ };
+ showWeuiDialog(config);
+ }
+ })
+ });
+ $('#key_B').bind('touchstart', function () {
+ backspace();
+ });
+
+ function updatePoundage(price) {
+ if (window.extensions.indexOf('customerrate') >= 0 && window.rateValue != null) {
+ if (window.use_customised_rate) {
+ var rate = new Decimal(100).plus(window.rateValue).div(100);
+ var poundageValue = new Decimal(dataCache.price).mul(rate).sub(dataCache.price);
+ } else {
+ var rateRemain = new Decimal(100).sub(window.rateValue).div(100);
+ poundageValue = new Decimal(dataCache.price).div(rateRemain).sub(dataCache.price);
+ }
+ dataCache.poundageValue = poundageValue.toFixed(2, Decimal.ROUND_HALF_UP);
+ return poundageValue.plus(price).toFixed(2, Decimal.ROUND_HALF_UP);
+ }
+ return price;
+ }
+
+ function updatePrice() {
+ $('#audVal').html(dataCache.price);
+ var realPrice = dataCache.price;
+ $('#audValReal').html(realPrice);
+ var surchargeData = calculateSurcharge(realPrice);
+
+ var price = surchargeData.newPrice || realPrice;
+ var priceBeforeDiscount = price;
+ dataCache.discounts = [];
+ dataCache.tax = surchargeData.tax;
+ dataCache.surcharge = surchargeData.surcharge;
+ $(window.coupons).each(function () {
+ price = this.handleDiscount(price, dataCache.price, dataCache.discounts, dataCache.coupons);
+ });
+ dataCache.finalPrice = new Decimal(price).toFixed(2, Decimal.ROUND_FLOOR);
+ var rate = 'CNY' == window.currency ? 1 : exchangeRate;
+ var cnyVal = Decimal.mul(price, rate).toFixed(2, Decimal.ROUND_FLOOR);
+ dataCache.currencyPrice = 'CNY' == window.currency ? Decimal.div(priceBeforeDiscount, exchangeRate).toFixed(2, Decimal.ROUND_FLOOR) : priceBeforeDiscount;
+ $('#cnyVal').html(cnyVal)
+ }
+
+ function backspace() {
+ dataCache.price = dataCache.price.substring(0, dataCache.price.length - 1);
+ if (dataCache.price.length == 0) {
+ dataCache.price = '0';
+ }
+ updatePrice();
+ updatePoundageStatus();
+ }
+
+ function appendChar(char) {
+ if (char == "") {
+ char = '0';
+ }
+ var check = /[^\d.]/g;
+ if (check.test(char)) {
+ return;
+ }
+ var tmpChar = (char.split('.')).length-1;
+ if (tmpChar > 1) {
+ return;
+ }
+ var pointLocation = dataCache.price.indexOf('.');
+ if (char == '.' || char.length > 8) {
+ return;
+ }
+ if (pointLocation >= 0 && pointLocation <= char.length - 4) {
+ return;
+ }
+ if (dataCache.price == '0' && char != '.') {
+ dataCache.price = '';
+ }
+ dataCache.price = char;
+ updatePrice();
+ updatePoundageStatus();
+ }
+
+ function updatePoundageStatus() {
+ $(window.coupons).each(function () {
+ var coupon = this;
+ var couponId = coupon.couponId();
+ if (coupon.isEnable(dataCache.currencyPrice || 0)) {
+ $('.coupons .use-check[data-coupon-id=' + couponId + ']').removeClass('disabled');
+ } else {
+ var dom = $('.coupons .use-check[data-coupon-id=' + couponId + ']').addClass('disabled');
+ var couponGroup = dom.attr('data-coupon-group');
+ if (couponGroup) {
+ if (dataCache.coupon_groups[couponGroup] == couponId) {
+ dataCache.coupon_groups[couponGroup] = null;
+ }
+ }
+ var idx = dataCache.coupons.indexOf(couponId);
+ if (idx >= 0) {
+ dataCache.coupons.splice(idx, 1);
+ }
+ dom.removeClass('checked').addClass('unchecked');
+ }
+ })
+ }
+
+ updatePoundageStatus();
+
+ $('#coupon-box-toggle').click(function () {
+ $('.coupons-container').addClass('show');
+ });
+ $('.coupons-container>.coupons-mask,.coupons-container #close-coupon-box').click(function () {
+ $(this).parents('.coupons-container').removeClass('show');
+ });
+
+
+ $('.remark-btn').click(function () {
+ var cfg = {
+ title: '备注 Remark',
+ template: '',
+ initialize: function (dialog) {
+ $('
').addClass('remark-input').attr('name', 'remark').val(dataCache.remark || '').appendTo($('.weui_dialog_bd', dialog));
+ },
+ confirm: function (dialog, chosen) {
+ if (chosen) {
+ var remark = $('textarea[name="remark"]', dialog).val();
+ if (remark) {
+ $('#remark-box').text('备注:' + remark).show()
+ } else {
+ $('#remark-box').text('').hide();
+ }
+ dataCache.remark = remark;
+ }
+
+ }
+ };
+ showWeuiDialog(cfg);
+ });
+
+ $('.paydetail').click(function () {
+ var config = {
+ title: 'Payment Detail',
+ template: '',
+ initialize: function (dialog) {
+ var bd = $('.weui_dialog_bd', dialog);
+ var currencySymbol = window.currency == 'CNY' ? '¥' : '$';
+ $('
').html('Input Price 输入金额:' + currencySymbol + dataCache.price).appendTo(bd);
+ if (parseFloat(dataCache.surcharge) > 0) {
+ $('
').html('Surcharge 手续费(' + window.rateValue + '%):+' + currencySymbol + dataCache.surcharge).appendTo(bd);
+ }
+ if (parseFloat(dataCache.tax) > 0) {
+ $('
').html('GST(10%):' + currencySymbol + dataCache.tax).appendTo(bd);
+ }
+ $(dataCache.discounts).each(function () {
+ $('
').html(this.title + ':-' + currencySymbol + this.amount).appendTo(bd);
+ });
+ $('
').addClass('final').html('Final 支付金额:' + currencySymbol + (dataCache.finalPrice || 0)).appendTo(bd);
+ }
+ };
+ showWeuiDialog(config);
+ });
+
+ $('#key_P').click(function () {
+ dataCache.remark = $('.remark-textarea-new').val();
+ if (window.requireRemark) {
+ if (!dataCache.remark) {
+ var config = {
+ title: '请先输入备注',
+ template: ''
+ };
+ showWeuiDialog(config);
+ }
+
+ }
+ });
+
+ $('#key_P').bind('touchstart', function () {
+ dataCache.remark = $('.remark-textarea-new').val();
+ if (window.requireRemark) {
+ if (!dataCache.remark) {
+ return;
+ }
+ }
+ $('#key_P_div').addClass('hidden');
+ $('#key_Loading_div').removeClass('hidden');
+ if (dataCache.paying) {
+ return;
+ }
+ dataCache.paying = true;
+ var data = {price: dataCache.price + '', currency: window.currency};
+ if (dataCache.remark) {
+ data.description = dataCache.remark;
+ }
+ if (window.extensions.indexOf('preauthorize') >= 0) {
+ data.preauthorize = true;
+ }
+ if (window.extensions.indexOf('qrcodemode') >= 0) {
+ data.qrmode = true;
+ }
+ if (window.extensions.indexOf('customerrate') >= 0) {
+ data.customerrate = true;
+ }
+ data.coupons = dataCache.coupons;
+ data.qrcodeVersion = window.qrcodeVersion;
+ $.ajax({
+ url: '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders',
+ method: 'POST',
+ data: JSON.stringify(data),
+ contentType: 'application/json',
+ dataType: 'json',
+ success: function (pay) {
+ if (pay.direct_paid) {
+ location.href = '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result';
+ return;
+ }
+ if (pay.mweb_url){
+ location.href = pay.mweb_url;
+ return;
+ }
+ if (window.AlipayJSBridge) {
+ callPayment();
+ } else {
+ // 如果没有注入则监听注入的事件
+ document.addEventListener('AlipayJSBridgeReady', callPayment, false);
+ }
+
+ function callPayment() {
+ try {
+ AlipayJSBridge.call('tradePay', {
+ tradeNO: pay.trade_no
+ }, function (res) {
+ dataCache.paying = false;
+ if (res.resultCode == '9000') {
+ AlipayJSBridge.call('startApp', {
+ appId: '20000056',
+ param: {
+ actionType: 'showSuccPage',
+ payResult: res.result
+ },
+ closeCurrentApp: false
+ });
+ startCheckOrder(pay.order_id, '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result');
+ } else if (res.resultCode == '6001') {
+ //do nothing
+ } else {
+ if (res.memo) {
+ weuiAlert(res.memo);
+ }
+ }
+ $('#key_P_div').removeClass('hidden');
+ $('#key_Loading_div').addClass('hidden');
+ })
+ } catch (err) {
+ weuiAlert(err)
+ }
+ }
+ },
+ error: function (jqXhr) {
+ weuiAlert(jqXhr.responseJSON.message);
+ $('#key_P_div').removeClass('hidden');
+ $('#key_Loading_div').addClass('hidden');
+ dataCache.paying = false;
+ }
+ })
+ });
+
+ function startCheckOrder(orderId, url) {
+ function checkOrderStd() {
+ $.ajax({
+ url: '/api/v1.0/payment/orders/' + orderId + '/status',
+ method: 'GET',
+ dataType: 'json',
+ success: function (res) {
+ if (res.paid) {
+ location.href = url;
+ } else {
+ setTimeout(checkOrderStd, 500);
+ }
+ }
+ })
+ }
+
+ checkOrderStd();
+ }
+
+ function weuiAlert(msg) {
+ var config = {
+ template: msg
+ };
+ showWeuiDialog(config);
+ }
+
+ function showWeuiDialog(config) {
+ if (config.templateUrl) {
+ $.ajax({
+ url: config.templateUrl,
+ dataType: 'html',
+ success: function (template) {
+ buildDialog(template);
+ }
+ });
+ } else {
+ buildDialog(config.template);
+ }
+
+ function buildDialog(template) {
+ var defaultConfig = {backdrop: true};
+ config = $.extend({}, defaultConfig, config);
+ var dialog = $("
", {class: 'weui_dialog_confirm'});
+ var mask = $('
', {class: 'weui_mask'}).appendTo(dialog);
+ if (config.backdrop) {
+ mask.click(function () {
+ dialog.remove();
+ if ($.isFunction(config.dismiss)) {
+ config.dismiss();
+ }
+ })
+ }
+ var dialogBox = $("
", {class: 'weui_dialog'}).appendTo(dialog);
+ if (config.title) {
+ $('
', {class: 'weui_dialog_hd'}).append($('
', {class: 'weui_dialog_title'}).html(config.title)).appendTo(dialogBox);
+ }
+ var dialogBody = $("
", {class: 'weui_dialog_bd'}).appendTo(dialogBox);
+ if (template) {
+ dialogBody.append(template);
+ }
+ if ($.isFunction(config.initialize)) {
+ config.initialize(dialog);
+ }
+ var ft = $('
').appendTo(dialogBox);
+ if(window.paypad_version !== 'v3'){
+ if ($.isFunction(config.confirm)) {
+ var yes = $('
', {
+ class: 'weui_btn_dialog primary',
+ text: 'OK',
+ style: 'background: #0bb20c;color: #fff;'
+ }).appendTo(ft);
+ yes.click(function () {
+ config.confirm(dialog, true);
+ dialog.remove();
+ });
+ var no = $('
', {class: 'weui_btn_dialog default', text: 'Cancel'}).appendTo(ft);
+ no.click(function () {
+ config.confirm(dialog, false);
+ dialog.remove();
+ })
+ } else {
+ var ok = $('
', {
+ class: 'weui_btn_dialog primary',
+ text: 'OK',
+ style: 'background: #0bb20c;color: #fff;'
+ }).appendTo(ft);
+ ok.click(function () {
+ dialog.remove();
+ })
+ }
+ } else {
+ if ($.isFunction(config.confirm)) {
+ var yes = $('
', {
+ class: 'weui_btn_dialog primary',
+ text: 'OK',
+ style: 'background: #FF9705;color: #fff;'
+ }).appendTo(ft);
+ yes.click(function () {
+ config.confirm(dialog, true);
+ dialog.remove();
+ });
+ var no = $('
', {class: 'weui_btn_dialog default', text: 'Cancel'}).appendTo(ft);
+ no.click(function () {
+ config.confirm(dialog, false);
+ dialog.remove();
+ })
+ } else {
+ var ok = $('
', {
+ class: 'weui_btn_dialog primary',
+ text: 'OK',
+ style: 'background: #FF9705;color: #fff;'
+ }).appendTo(ft);
+ ok.click(function () {
+ dialog.remove();
+ })
+ }
+ }
+ dialog.appendTo($('body'));
+ }
+
+ }
+});
diff --git a/src/main/ui/static/templates/alipayaps/v5/payment.js b/src/main/ui/static/templates/alipayaps/v5/payment.js
new file mode 100644
index 000000000..759356aff
--- /dev/null
+++ b/src/main/ui/static/templates/alipayaps/v5/payment.js
@@ -0,0 +1,452 @@
+/**
+ * Created by yixian on 2017-05-08
+ */
+
+$(function () {
+ 'use strict';
+ // document.querySelector('body').addEventListener('touchmove', function(e) {
+ // if (!document.querySelector('.coupons').contains(e.target)) {
+ // e.preventDefault();
+ // }
+ // });
+ var dataCache = {price: '0', coupons: [], coupon_groups: {}};
+ var exchangeRate = 'CNY' == window.currency ? 1 : parseFloat(window.exchange_rate);
+ dataCache.paying = false;
+ var ctrl = {};
+
+ if (window.AlipayJSBridge) {
+ AlipayJSBridge.call('hideOptionMenu');
+ } else {
+ document.addEventListener('AlipayJSBridgeReady', function () {
+ AlipayJSBridge.call('hideOptionMenu');
+ }, false);
+ }
+ dataCache.paying = false;
+ var ctrl = {};
+
+ $('.ff.key').bind('touchstart', function () {
+ if (dataCache.paying) {
+ return;
+ }
+ var char = $(this).attr('data-char');
+ appendChar(char);
+ });
+
+ $('.coupons .use-check').click(function () {
+ if ($(this).hasClass('disabled')) {
+ return;
+ }
+ var couponId = $(this).attr('data-coupon-id');
+ var couponGroup = $(this).attr('data-coupon-group');
+ if (couponGroup) {
+ var prevCouponId = dataCache.coupon_groups[couponGroup];
+ if (prevCouponId) {
+ var prevIdx = dataCache.coupons.indexOf(prevCouponId);
+ if (prevIdx >= 0) {
+ dataCache.coupons.splice(prevIdx, 1);
+ }
+ if (prevCouponId != couponId) {
+ $('.coupons .use-check[data-coupon-id="' + prevCouponId + '"]').removeClass('checked').addClass('unchecked');
+ dataCache.coupon_groups[couponGroup] = couponId;
+ } else {
+ dataCache.coupon_groups[couponGroup] = null;
+ }
+ } else {
+ dataCache.coupon_groups[couponGroup] = couponId;
+ }
+
+ }
+
+ if ($(this).is('.checked')) {
+ $(this).removeClass('checked').addClass('unchecked');
+ } else {
+ $(this).removeClass('unchecked').addClass('checked');
+ }
+ var checked = $(this).is('.checked');
+ if (checked) {
+ dataCache.coupons.push(couponId);
+ updatePrice();
+ } else {
+ var idx = dataCache.coupons.indexOf(couponId);
+ dataCache.coupons.splice(idx, 1);
+ updatePrice();
+ }
+ });
+ $('.cb_bankpay').click(function () {
+ $.ajax({
+ url: '/sys/partners/' + window.client_moniker + '/jump/link',
+ method: 'GET',
+ success: function (res) {
+ location.href = res;
+ },
+ error: function (resp) {
+ var config = {
+ template: resp
+ };
+ showWeuiDialog(config);
+ }
+ })
+ });
+ $('#key_B').bind('touchstart', function () {
+ backspace();
+ });
+
+ function updatePoundage(price) {
+ if (window.extensions.indexOf('customerrate') >= 0 && window.rateValue != null) {
+ if (window.use_customised_rate) {
+ var rate = new Decimal(100).plus(window.rateValue).div(100);
+ var poundageValue = new Decimal(dataCache.price).mul(rate).sub(dataCache.price);
+ } else {
+ var rateRemain = new Decimal(100).sub(window.rateValue).div(100);
+ poundageValue = new Decimal(dataCache.price).div(rateRemain).sub(dataCache.price);
+ }
+ dataCache.poundageValue = poundageValue.toFixed(2, Decimal.ROUND_HALF_UP);
+ return poundageValue.plus(price).toFixed(2, Decimal.ROUND_HALF_UP);
+ }
+ return price;
+ }
+
+ function updatePrice() {
+ $('#audVal').html(dataCache.price);
+ var realPrice = dataCache.price;
+ $('#audValReal').html(realPrice);
+ var surchargeData = calculateSurcharge(realPrice);
+
+ var price = surchargeData.newPrice || realPrice;
+ var priceBeforeDiscount = price;
+ dataCache.discounts = [];
+ dataCache.tax = surchargeData.tax;
+ dataCache.surcharge = surchargeData.surcharge;
+ $(window.coupons).each(function () {
+ price = this.handleDiscount(price, dataCache.price, dataCache.discounts, dataCache.coupons);
+ });
+ dataCache.finalPrice = new Decimal(price).toFixed(2, Decimal.ROUND_FLOOR);
+ var rate = 'CNY' == window.currency ? 1 : exchangeRate;
+ var cnyVal = Decimal.mul(price, rate).toFixed(2, Decimal.ROUND_FLOOR);
+ dataCache.currencyPrice = 'CNY' == window.currency ? Decimal.div(priceBeforeDiscount, exchangeRate).toFixed(2, Decimal.ROUND_FLOOR) : priceBeforeDiscount;
+ $('#cnyVal').html(cnyVal)
+ }
+
+ function backspace() {
+ dataCache.price = dataCache.price.substring(0, dataCache.price.length - 1);
+ if (dataCache.price.length == 0) {
+ dataCache.price = '0';
+ }
+ updatePrice();
+ updatePoundageStatus();
+ }
+
+ function appendChar(char) {
+ var pointLocation = dataCache.price.indexOf('.');
+ if (pointLocation >= 0 || char == '.' || dataCache.price.length < 5) {
+ if (pointLocation >= 0 && char == '.') {
+ return;
+ }
+ if (pointLocation >= 0 && pointLocation <= dataCache.price.length - 3) {
+ return;
+ }
+ if (dataCache.price == '0' && char != '.') {
+ dataCache.price = '';
+ }
+ dataCache.price += char;
+ updatePrice();
+ updatePoundageStatus();
+ }
+ }
+
+ function updatePoundageStatus() {
+ $(window.coupons).each(function () {
+ var coupon = this;
+ var couponId = coupon.couponId();
+ if (coupon.isEnable(dataCache.currencyPrice || 0)) {
+ $('.coupons .use-check[data-coupon-id=' + couponId + ']').removeClass('disabled');
+ } else {
+ var dom = $('.coupons .use-check[data-coupon-id=' + couponId + ']').addClass('disabled');
+ var couponGroup = dom.attr('data-coupon-group');
+ if (couponGroup) {
+ if (dataCache.coupon_groups[couponGroup] == couponId) {
+ dataCache.coupon_groups[couponGroup] = null;
+ }
+ }
+ var idx = dataCache.coupons.indexOf(couponId);
+ if (idx >= 0) {
+ dataCache.coupons.splice(idx, 1);
+ }
+ dom.removeClass('checked').addClass('unchecked');
+ }
+ })
+ }
+
+ updatePoundageStatus();
+
+ $('#coupon-box-toggle').click(function () {
+ $('.coupons-container').addClass('show');
+ });
+ $('.coupons-container>.coupons-mask,.coupons-container #close-coupon-box').click(function () {
+ $(this).parents('.coupons-container').removeClass('show');
+ });
+
+ $('.paydetail').click(function () {
+ var config = {
+ title: 'Payment Detail',
+ template: '',
+ initialize: function (dialog) {
+ var bd = $('.weui_dialog_bd', dialog);
+ var currencySymbol = window.currency == 'CNY' ? '¥' : '$';
+ $('
').html('Input Price 输入金额:' + currencySymbol + dataCache.price).appendTo(bd);
+ if (parseFloat(dataCache.surcharge) > 0) {
+ $('
').html('Surcharge 手续费(' + window.rateValue + '%):+' + currencySymbol + dataCache.surcharge).appendTo(bd);
+ }
+ if (parseFloat(dataCache.tax) > 0) {
+ $('
').html('GST(10%):' + currencySymbol + dataCache.tax).appendTo(bd);
+ }
+ $(dataCache.discounts).each(function () {
+ $('
').html(this.title + ':-' + currencySymbol + this.amount).appendTo(bd);
+ });
+ $('
').addClass('final').html('Final 支付金额:' + currencySymbol + (dataCache.finalPrice || 0)).appendTo(bd);
+ }
+ };
+ showWeuiDialog(config);
+ });
+
+ $('#key_P').click(function () {
+ if (window.requireRemark) {
+ if (!dataCache.remark) {
+ var config = {
+ title: '请先输入备注',
+ template: ''
+ };
+ showWeuiDialog(config);
+ }
+
+ }
+ });
+
+ function addBlurListen() {
+ $('.remark-input').on('blur', function (event) {
+ dataCache.remark = $('textarea[name="remark"]').val();
+ });
+ }
+ addBlurListen();
+
+ $('#audVal').bind('DOMNodeInserted', function(e) {
+ if(dataCache.price==0){
+ $('.pay_button').css({"background-color":"#eee",}).attr('disabled',true);
+ $('.bank_button').css({"background-color":"#eee",}).attr('disabled',true);
+ }else{
+ $('.pay_button').css({"background-color":"#108ee9",}).attr('disabled',false);
+ $('.bank_button').css({"background-color":"#FF6600",}).attr('disabled',false);
+ }
+ });
+ $('#key_P').bind('touchstart', function () {
+ if (window.requireRemark) {
+ if ($('textarea[name="remark"]').val()=="") {
+ return;
+ }
+ }
+ $('#key_P').addClass('hidden');
+ $('#key_Loading').removeClass('hidden');
+ if (dataCache.paying) {
+ return;
+ }
+ dataCache.paying = true;
+ var data = {price: dataCache.price + '', currency: window.currency};
+ if (dataCache.remark) {
+ data.description = dataCache.remark;
+ }
+ if (window.extensions.indexOf('preauthorize') >= 0) {
+ data.preauthorize = true;
+ }
+ if (window.extensions.indexOf('qrcodemode') >= 0) {
+ data.qrmode = true;
+ }
+ if (window.extensions.indexOf('customerrate') >= 0) {
+ data.customerrate = true;
+ }
+ data.coupons = dataCache.coupons;
+ data.qrcodeVersion = window.qrcodeVersion;
+ $.ajax({
+ url: '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders',
+ method: 'POST',
+ data: JSON.stringify(data),
+ contentType: 'application/json',
+ dataType: 'json',
+ success: function (pay) {
+ if (pay.direct_paid) {
+ location.href = '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result';
+ return;
+ }
+ if (pay.mweb_url){
+ location.href = pay.mweb_url;
+ return;
+ }
+ if (window.AlipayJSBridge) {
+ callPayment();
+ } else {
+ // 如果没有注入则监听注入的事件
+ document.addEventListener('AlipayJSBridgeReady', callPayment, false);
+ }
+
+ function callPayment() {
+ try {
+ AlipayJSBridge.call('tradePay', {
+ tradeNO: pay.trade_no
+ }, function (res) {
+ dataCache.paying = false;
+ if (res.resultCode == '9000') {
+ AlipayJSBridge.call('startApp', {
+ appId: '20000056',
+ param: {
+ actionType: 'showSuccPage',
+ payResult: res.result
+ },
+ closeCurrentApp: false
+ });
+ startCheckOrder(pay.order_id, '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result');
+ } else if (res.resultCode == '6001') {
+ //do nothing
+ } else {
+ if (res.memo) {
+ weuiAlert(res.memo);
+ }
+ }
+ $('#key_P_div').removeClass('hidden');
+ $('#key_Loading_div').addClass('hidden');
+ })
+ } catch (err) {
+ weuiAlert(err)
+ }
+ }
+ },
+ error: function (jqXhr) {
+ weuiAlert(jqXhr.responseJSON.message);
+ $('#key_P_div').removeClass('hidden');
+ $('#key_Loading_div').addClass('hidden');
+ dataCache.paying = false;
+ }
+ })
+ });
+
+ function startCheckOrder(orderId, url) {
+ function checkOrderStd() {
+ $.ajax({
+ url: '/api/v1.0/payment/orders/' + orderId + '/status',
+ method: 'GET',
+ dataType: 'json',
+ success: function (res) {
+ if (res.paid) {
+ location.href = url;
+ } else {
+ setTimeout(checkOrderStd, 500);
+ }
+ }
+ })
+ }
+
+ checkOrderStd();
+ }
+
+ function weuiAlert(msg) {
+ var config = {
+ template: msg
+ };
+ showWeuiDialog(config);
+ }
+
+ function showWeuiDialog(config) {
+ if (config.templateUrl) {
+ $.ajax({
+ url: config.templateUrl,
+ dataType: 'html',
+ success: function (template) {
+ buildDialog(template);
+ }
+ });
+ } else {
+ buildDialog(config.template);
+ }
+
+ function buildDialog(template) {
+ var defaultConfig = {backdrop: true};
+ config = $.extend({}, defaultConfig, config);
+ var dialog = $("
", {class: 'weui_dialog_confirm'});
+ var mask = $('
', {class: 'weui_mask'}).appendTo(dialog);
+ if (config.backdrop) {
+ mask.click(function () {
+ dialog.remove();
+ if ($.isFunction(config.dismiss)) {
+ config.dismiss();
+ }
+ })
+ }
+ var dialogBox = $("
", {class: 'weui_dialog'}).appendTo(dialog);
+ if (config.title) {
+ $('
', {class: 'weui_dialog_hd'}).append($('
', {class: 'weui_dialog_title'}).html(config.title)).appendTo(dialogBox);
+ }
+ var dialogBody = $("
", {class: 'weui_dialog_bd'}).appendTo(dialogBox);
+ if (template) {
+ dialogBody.append(template);
+ }
+ if ($.isFunction(config.initialize)) {
+ config.initialize(dialog);
+ }
+ var ft = $('
').appendTo(dialogBox);
+ if(window.paypad_version !== 'v3'){
+ if ($.isFunction(config.confirm)) {
+ var yes = $('
', {
+ class: 'weui_btn_dialog primary',
+ text: 'OK',
+ style: 'background: #0bb20c;color: #fff;'
+ }).appendTo(ft);
+ yes.click(function () {
+ config.confirm(dialog, true);
+ dialog.remove();
+ });
+ var no = $('
', {class: 'weui_btn_dialog default', text: 'Cancel'}).appendTo(ft);
+ no.click(function () {
+ config.confirm(dialog, false);
+ dialog.remove();
+ })
+ } else {
+ var ok = $('
', {
+ class: 'weui_btn_dialog primary',
+ text: 'OK',
+ style: 'background: #0bb20c;color: #fff;'
+ }).appendTo(ft);
+ ok.click(function () {
+ dialog.remove();
+ })
+ }
+ } else {
+ if ($.isFunction(config.confirm)) {
+ var yes = $('
', {
+ class: 'weui_btn_dialog primary',
+ text: 'OK',
+ style: 'background: #FF9705;color: #fff;'
+ }).appendTo(ft);
+ yes.click(function () {
+ config.confirm(dialog, true);
+ dialog.remove();
+ });
+ var no = $('
', {class: 'weui_btn_dialog default', text: 'Cancel'}).appendTo(ft);
+ no.click(function () {
+ config.confirm(dialog, false);
+ dialog.remove();
+ })
+ } else {
+ var ok = $('
', {
+ class: 'weui_btn_dialog primary',
+ text: 'OK',
+ style: 'background: #FF9705;color: #fff;'
+ }).appendTo(ft);
+ ok.click(function () {
+ dialog.remove();
+ })
+ }
+ }
+ dialog.appendTo($('body'));
+ addBlurListen();
+ }
+
+ }
+});
diff --git a/src/main/ui/static/templates/billCode/js/mobile_payment.js b/src/main/ui/static/templates/billCode/js/mobile_payment.js
index 7a61910a8..8c63fdec4 100644
--- a/src/main/ui/static/templates/billCode/js/mobile_payment.js
+++ b/src/main/ui/static/templates/billCode/js/mobile_payment.js
@@ -9,9 +9,18 @@ $(document).ready(function () {
if(window.openmobilefun == 'wechat'|| window.openmobilefun == 'other'){
paymentFun = 'Wechat'
- }else{
+ }
+ else if(window.openmobilefun == 'alipayaps'|| window.openmobilefun == 'alipayaps_cn'){
+ paymentFun = 'AlipayAps'
+ $(".select_wechat").empty();
+ $(".select_alipay_aps").append(selectPaymentHTML);
+ $(".select_alipay").empty();
+ $(".select_bank").empty();
+ }
+ else{
paymentFun = 'Alipay'
$(".select_wechat").empty();
+ $(".select_alipay_aps").empty();
$(".select_alipay").append(selectPaymentHTML);
$(".select_bank").empty();
}
@@ -35,6 +44,8 @@ $(document).ready(function () {
paymentFun = 'Wechat'
$(".select_wechat").append(selectPaymentHTML);
$(".select_alipay").empty();
+ $(".select_alipay_aps").empty();
+
$(".select_bank").empty();
}
})
@@ -42,15 +53,28 @@ $(document).ready(function () {
if(paymentFun != 'Alipay'){
paymentFun = 'Alipay'
$(".select_wechat").empty();
+ $(".select_alipay_aps").empty();
+
$(".select_alipay").append(selectPaymentHTML);
$(".select_bank").empty();
}
})
+ $("#select_alipay_aps").click(function(){
+ if(paymentFun != 'AlipayAps'){
+ paymentFun = 'AlipayAps'
+ $(".select_wechat").empty();
+ $(".select_alipay").empty();
+ $(".select_alipay_aps").append(selectPaymentHTML);
+ $(".select_bank").empty();
+ }
+ })
$("#select_bank").click(function(){
if(paymentFun != 'Bank'){
paymentFun = 'Bank'
$(".select_wechat").empty();
$(".select_alipay").empty();
+ $(".select_alipay_aps").empty();
+
$(".select_bank").append(selectPaymentHTML);
}
})
@@ -81,6 +105,13 @@ $(document).ready(function () {
redirectH5Payment(res.partner_order_id,res.client_moniker)
}
}
+ if(paymentFun == 'AlipayAps'){
+ if(window.openmobilefun == 'alipayaps'){
+ callPayment(res);
+ }else{
+ redirectH5PaymentForAps(res.partner_order_id,res.client_moniker)
+ }
+ }
if(paymentFun == 'Alipay'){
if(window.openmobilefun == 'alipay'){
callPayment(res);
@@ -108,6 +139,9 @@ $(document).ready(function () {
function redirectH5Payment(orderId,clientMoniker){
window.location.href='/api/v1.0/share_code/business/bills/'+clientMoniker+'/orders/'+orderId+'/pay';
}
+ function redirectH5PaymentForAps(orderId,clientMoniker){
+ window.location.href='/api/v1.0/share_code/business/bills/'+clientMoniker+'/orders/'+orderId+'/alipayaps_pay';
+ }
function getShareLink(){
var paymentLink = ''
@@ -127,6 +161,13 @@ $(document).ready(function () {
paymentLink = '/api/v1.0/share_code/business/bills/'+window.billInfo.bill_code_id+'/alipay/mobile/redirectApp?priorityChannel=Alipay';
}
}
+ if(paymentFun == 'AlipayAps'){
+ if(window.openmobilefun == 'alipayaps'|| window.openmobilefun == 'alipayaps_cn'){
+ paymentLink = '/api/v1.0/share_code/business/bills/'+window.billInfo.bill_code_id+'/alipay_aps/mobile';
+ }else{
+ paymentLink = '/api/v1.0/share_code/business/bills/'+window.billInfo.bill_code_id+'/alipay_aps/mobile/redirectApp?priorityChannel=AlipayAps';
+ }
+ }
if(paymentFun == 'Bank'){
paymentLink = '/api/v1.0/share_code/business/bills/'+window.billInfo.bill_code_id+'/cbbank/mobile?partner_moniker='+window.clientmoniker;
}
@@ -147,6 +188,14 @@ $(document).ready(function () {
}
}
+ if(paymentFun == 'AlipayAps'){
+ if(window.openmobilefun == 'alipayaps'|| window.openmobilefun == 'alipayaps_cn'){
+ paymentLink = '/api/v1.0/share_code/bills/payment/orders/'+window.billInfo.bill_code_id+'/alipay_aps/share_link'
+ }else{
+ paymentLink = '/api/v1.0/share_code/bills/payment/'+window.billInfo.bill_code_id+'/alipay_aps/mobile/redirectApp?priorityChannel=AlipayAps';
+
+ }
+ }
if(paymentFun == 'Bank'){
paymentLink = '/api/v1.0/share_code/bills/payment/orders/'+window.billInfo.bill_code_id+'/cbbank/share_link?partner_moniker='+window.clientmoniker;
}
@@ -187,7 +236,11 @@ $(document).ready(function () {
function callPayment(paydata) {
try {
if(typeof paydata.trade_no == 'undefined'){
- window.location.href = paydata.mweb_url
+ if(paydata.mweb_url!=null){
+ window.location.href = paydata.mweb_url
+ }else{
+ window.location.href = paydata.web_url
+ }
}else {
AlipayJSBridge.call('tradePay', {
tradeNO: paydata.trade_no
diff --git a/src/main/ui/static/templates/billCode/js/pc_payment.js b/src/main/ui/static/templates/billCode/js/pc_payment.js
index e69cdfa9f..feda74b2f 100644
--- a/src/main/ui/static/templates/billCode/js/pc_payment.js
+++ b/src/main/ui/static/templates/billCode/js/pc_payment.js
@@ -19,6 +19,9 @@ $(document).ready(function () {
}else if(window.clientInfo.enable_cb_bankpay){
var paymentFun = 'Bank';
showQRcode();
+ }else if(window.clientInfo.enable_alipayaps){
+ var paymentFun = 'AlipayAps';
+ showQRcode();
}
startCheckOrder();
@@ -43,6 +46,8 @@ $(document).ready(function () {
$("#select_wechat").removeClass("no-select-pay-fun").addClass("select-pay-fun");
$("#select_alipay").removeClass("select-pay-fun").addClass("no-select-pay-fun");
$("#select_bank").removeClass("select-pay-fun").addClass("no-select-pay-fun");
+ $("#select_alipay_aps").removeClass("select-pay-fun").addClass("no-select-pay-fun");
+
showQRcode();
}
})
@@ -52,6 +57,18 @@ $(document).ready(function () {
$("#select_wechat").removeClass("select-pay-fun").addClass("no-select-pay-fun");
$("#select_alipay").removeClass("no-select-pay-fun").addClass("select-pay-fun");
$("#select_bank").removeClass("select-pay-fun").addClass("no-select-pay-fun");
+ $("#select_alipay_aps").removeClass("select-pay-fun").addClass("no-select-pay-fun");
+ showQRcode();
+ }
+ })
+ $("#select_alipay_aps").click(function(){
+ if(paymentFun != 'AlipayAps'){
+ paymentFun = 'AlipayAps'
+ $("#select_wechat").removeClass("select-pay-fun").addClass("no-select-pay-fun");
+ $("#select_alipay").removeClass("select-pay-fun").addClass("no-select-pay-fun");
+ $("#select_bank").removeClass("select-pay-fun").addClass("no-select-pay-fun");
+ $("#select_alipay_aps").removeClass("no-select-pay-fun").addClass("select-pay-fun");
+
showQRcode();
}
})
@@ -61,6 +78,7 @@ $(document).ready(function () {
$("#select_wechat").removeClass("select-pay-fun").addClass("no-select-pay-fun");
$("#select_alipay").removeClass("select-pay-fun").addClass("no-select-pay-fun");
$("#select_bank").removeClass("no-select-pay-fun").addClass("select-pay-fun");
+ $("#select_alipay_aps").removeClass("select-pay-fun").addClass("no-select-pay-fun");
showQRcode();
}
})
@@ -85,7 +103,15 @@ $(document).ready(function () {
"
请使用" + channelName + "客户端扫码支付
" +
"
";
$('#qrImg').append(selectPaymentHTML)
- } else if (paymentFun == 'Bank') {
+ }
+ else if (paymentFun == 'AlipayAps') {
+ $('#qrImg').empty();
+ document.getElementById("qrImg").style.display = 'block';
+ var selectPaymentHTML =
+ "
请使用" + channelName + "客户端扫码支付
" +
+ "
";
+ $('#qrImg').append(selectPaymentHTML)
+ }else if (paymentFun == 'Bank') {
$('#qrImg').empty();
document.getElementById("qrImg").style.display = 'block';
if( hasPayment){
diff --git a/src/main/ui/static/templates/payment/gateway_jsapi.css b/src/main/ui/static/templates/payment/gateway_jsapi.css
index a573b9fd0..4cf61b514 100644
--- a/src/main/ui/static/templates/payment/gateway_jsapi.css
+++ b/src/main/ui/static/templates/payment/gateway_jsapi.css
@@ -68,4 +68,19 @@ body{
.alipay .royal-pay-btn{
background: #108ee9;
+}
+
+.alipayaps-pay-brands {
+ text-align: center;
+ line-height: 20px;
+ font-size: 24px;
+ margin-top: 64px;
+ color: #dddddd;
+}
+.alipayaps-pay-brands img {
+ height: 18px;
+}
+
+.alipayaps-pay-brands img.alipayaps-logo {
+ height: 14px;
}
\ No newline at end of file
diff --git a/src/main/ui/static/templates/skip_wxbrowser.css b/src/main/ui/static/templates/skip_wxbrowser.css
index e91cd1866..e9a832f30 100644
--- a/src/main/ui/static/templates/skip_wxbrowser.css
+++ b/src/main/ui/static/templates/skip_wxbrowser.css
@@ -59,6 +59,15 @@ body {
background-size: contain;
}
+.result-alipayaps-logo {
+ width: 80px;
+ height: 80px;
+ margin: auto;
+ background-image: url(/static/images/alipay_aps_big.svg);
+ background-repeat: no-repeat;
+ background-size: contain;
+}
+
.result-royalpay-logo {
width: 70px;
height: 98px;