Browse Source

三个支付界面的输入限制与信息提示调整

huangct 8 năm trước cách đây
mục cha
commit
a2942fdd99

+ 2 - 3
donate-service/src/main/java/com/uas/service/donate/controller/IndexController.java

@@ -87,7 +87,8 @@ public class IndexController {
         }
 
 
-        /*if (ua.indexOf("micromessenger") >= 0) {// 是微信浏览器
+        /*User user = SystemSession.getUser();
+        if (ua.indexOf("micromessenger") >= 0) {// 是微信浏览器
 
             if (user != null && user.getWxOpenId() != null) {
                 //有用户 有openid 已授权
@@ -127,8 +128,6 @@ public class IndexController {
                 }
 
                 //openId = wxPayApi.authcode2Openid(code);
-            } catch (WxPayException e) {
-                e.printStackTrace();
             } catch (Exception e) {
                 e.printStackTrace();
             }

+ 3 - 2
donate-service/src/main/java/com/uas/service/donate/controller/WxpayController.java

@@ -127,10 +127,11 @@ public class WxpayController {
         }
 
         WxPayUnifiedOrderRequest wxPayUnifiedOrderRequest = createWxPayUnifiedOrderRequest(request, projectRecode, WxPayConstants.TradeType.JSAPI);
-        //User user =SystemSession.getUser();
         String openId = null;
         Object openIdObj = request.getSession().getAttribute("openId");
-        /*if (user != null && user.getWxOpenId() != null) {
+
+        /*User user =SystemSession.getUser();
+        if (user != null && user.getWxOpenId() != null) {
             logger.info("当前用户信息:" + user.toString());
             openId = user.getWxOpenId();
         } else {

+ 38 - 5
donate-service/src/main/resources/templates/index.ftl

@@ -13,9 +13,11 @@
     <link rel="stylesheet" href="static/css/bootstrap.min.css">
     <link rel="stylesheet" href="static/css/base.css">
     <link rel="stylesheet" type="text/css" href="static/css/kkpager_orange.css" />
+    <!--<link rel="stylesheet" href="static/css/toastr.css">
+    <script type="text/javascript" src ="static/js/toastr.js"></script>-->
+    <link href="https://cdn.bootcss.com/toastr.js/latest/css/toastr.css" rel="stylesheet">
+    <link href="https://cdn.bootcss.com/toastr.js/latest/css/toastr.min.css" rel="stylesheet">
 
-    <script type="text/javascript" src ="static/js/pay.js"></script>
-    <script type="text/javascript" src ="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
     <style>
         body{
             font-family: "Microsoft Yahei", "微软雅黑";
@@ -657,6 +659,10 @@
         .carousel-control:focus, .carousel-control:hover {
             cursor: pointer;
         }
+
+        #toast-container {
+            left: 0;
+        }
     </style>
 </head>
 <script type="text/javascript" src="static/js/jquery-1.9.1.min.js"></script>
@@ -819,7 +825,7 @@
                                         <li>100元</li>
                                         <li>200元</li>
                                     </ul>
-                                    <div class="write"><input type="text" placeholder="其他金额" class="form-control" id="custom-amount${project.id!''}"/><em>元</em></div>
+                                    <div class="write"><input type="text" placeholder="其他金额" class="form-control" id="custom-amount${project.id!''}" maxlength="10"/><em>元</em></div>
                                 </div>
                             </div>
                             <div class="choose clearfix">
@@ -831,8 +837,8 @@
                                 </div>
                             </div>
                             <div class="choose clearfix">
-                                <span class="fl best">我的祝福:</span>
-                                <textarea name="" id="" cols="30" rows="10" class="fl form-control"></textarea>
+                                <#--<span class="fl best">我的祝福:</span>
+                                <textarea name="" id="" cols="30" rows="10" class="fl form-control" maxlength="300"></textarea>-->
                                 <div class="fl agree clearfix">
                                     <input type="checkbox" class="fl"><span class="fl">同意并接受《<a href="/userAgreement" target="_blank" style="color: #5078cb;">优软一元捐用户协议</a>》</span></span>
                                 </div>
@@ -1055,6 +1061,33 @@
         return isPayButtonAble;
     }
 
+    initToast();
+    function initToast(){
+        toastr.options = {
+            "closeButton": true,
+            "debug": false,
+            "newestOnTop": false,
+            "progressBar": true,
+            "positionClass": "toast-top-center",
+            "preventDuplicates": false,
+            "onclick": null,
+            "showDuration": "300",
+            "hideDuration": "1000",
+            "timeOut": "2000",
+            "extendedTimeOut": "1000",
+            "showEasing": "swing",
+            "hideEasing": "linear",
+            "showMethod": "fadeIn",
+            "hideMethod": "fadeOut"
+        }
+
+    }
+
+
 </script>
+<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js"></script>
+<script src="https://cdn.bootcss.com/toastr.js/latest/js/toastr.min.js"></script>
+<script type="text/javascript" src ="static/js/pay.js"></script>
+<script type="text/javascript" src ="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
 </body>
 </html>

+ 30 - 1
donate-service/src/main/webapp/WEB-INF/views/project.html

@@ -13,6 +13,9 @@
     <link rel="stylesheet" href="static/lib/bootstrap/css/bootstrap.min.css">
     <link rel="stylesheet" href="static/lib/angular/toaster.css">
     <link rel="stylesheet" href="static/css/base.css">
+
+    <link href="https://cdn.bootcss.com/toastr.js/latest/css/toastr.css" rel="stylesheet">
+    <link href="https://cdn.bootcss.com/toastr.js/latest/css/toastr.min.css" rel="stylesheet">
     <style>
         a {
             cursor: pointer;
@@ -21,6 +24,9 @@
         button {
             cursor: pointer;
         }
+        #toast-container {
+            left: 0;
+        }
     </style>
 </head>
 <body>
@@ -32,9 +38,10 @@
 <toaster-container
         toaster-options="{'position-class': 'toast-top-center'}"></toaster-container>
 <script src="static/lib/jquery/jquery.min.js"></script>
+<script src="https://cdn.bootcss.com/toastr.js/latest/js/toastr.min.js"></script>
 <script src="static/lib/bootstrap/js/bootstrap.min.js"></script>
 <script type="text/javascript" src="static/lib/require.js"
-        data-main="static/js/project/main.js"></script>
+data-main="static/js/project/main.js"></script>
 <script>
     //    banner
     $('#myCarousel').carousel({
@@ -46,6 +53,28 @@
         $(this).addClass('active').siblings().removeClass('active');
         $('.buttons').eq(index).addClass('show').siblings().removeClass('show');
     });
+
+    initToast();
+    function initToast(){
+        toastr.options = {
+            "closeButton": true,
+            "debug": false,
+            "newestOnTop": false,
+            "progressBar": true,
+            "positionClass": "toast-top-center",
+            "preventDuplicates": false,
+            "onclick": null,
+            "showDuration": "300",
+            "hideDuration": "1000",
+            "timeOut": "2000",
+            "extendedTimeOut": "1000",
+            "showEasing": "swing",
+            "hideEasing": "linear",
+            "showMethod": "fadeIn",
+            "hideMethod": "fadeOut"
+        }
+    }
+
 </script>
 </body>
 </html>

+ 15 - 56
donate-service/src/main/webapp/resources/js/pay.js

@@ -9,11 +9,9 @@
 
 const userAgent = navigator.userAgent;
 const isMobile = /(iPhone|iPad|Opera Mini|Android.*Mobile|NetFront|PSP|BlackBerry|Windows Phone)/ig.test(userAgent);
-var orderInterval;
 
 var pay =function (proId, amount, payWay, uuid) {
      var customAmount = $("#custom-amount" + proId).val();
-     console.log(customAmount);
     if ($.trim(customAmount) != "") {
         var reg = "^(([0-9]+\.[0-9]{1,2})|([0-9]*[1-9][0-9]*\.[0-9]{1,2})|([0-9]*[1-9][0-9]*))$";
         var patt = new RegExp(reg);
@@ -22,11 +20,11 @@ var pay =function (proId, amount, payWay, uuid) {
             if (parseFloat(customAmount) < 10000000) {
                 amount = customAmount;
             } else {
-                alert("您输入的金额过大,请不要超过一千万");
+                toastr.warning("您输入的金额过大,请不要超过一千万");
                 return;
             }
         } else {
-            alert('输入金额有误,请正确输入金额且最多保留两位小数!');
+            toastr.warning('输入金额有误,请正确输入金额且最多保留两位小数!');
             return;
         }
     }
@@ -36,6 +34,11 @@ var pay =function (proId, amount, payWay, uuid) {
         amount = amount.toString().substring(0, yuanIndex);
     }
 
+    if (parseFloat(amount) >= 10000000) {
+        toastr.warning("您输入的金额过大,请不要超过一千万");
+        return;
+    }
+
     //获取支付方式
     if(payWay == "支付宝") {
         aliPay(proId, amount, payWay, uuid);
@@ -90,7 +93,7 @@ var wxPay = function (proId, amount, payWay, uuid) {
             success : function(res){
                 var resJsonObj=JSON.parse(res);
                 if (resJsonObj.error != null) {
-                    alert(resJsonObj.error);
+                    toastr.warning(resJsonObj.error);
                     return;
                 }
 
@@ -102,7 +105,7 @@ var wxPay = function (proId, amount, payWay, uuid) {
                 }
             },
             error : function() {
-                alert('系统异常,请联系客服!');
+                toastr.error('系统异常,请联系客服!');
             }
         });
     }
@@ -129,7 +132,7 @@ var aliPay = function (proId, amount, payWay, uuid) {
             document.write(data);
         },
         error : function() {
-            alert('系统异常,请联系客服!');
+            toastr.error('系统异常,请联系客服!');
         }
     });
 }
@@ -140,48 +143,6 @@ var unionPay  = function () {
 
 /*公众号支付*/
 var webPay = function (jsonStr) {
-    // var xmlHttpRequest;
-    //
-    // $(function(){
-    //     if(window.XMLHttpRequest){
-    //         xmlHttpRequest=new XMLHttpRequest();
-    //     }else{
-    //         xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");
-    //     }
-    //     //xmlHttpRequest.responseType = 'json';
-    //     //xmlHttpRequest.setRequestHeader('Content-type','application/x-www-form-urlencoded');
-    //     xmlHttpRequest.onreadystatechange = back;
-    //     xmlHttpRequest.open('POST','/wxpay/webPay',true);
-    //     xmlHttpRequest.send('jsonStr=' + jsonStr);
-    //     function back() {
-    //         if(xmlHttpRequest.status == 200 || xmlHttpRequest.readyState == 4){
-    //             alert(xmlHttpRequest.responseText);
-    //             var resJsonObj=JSON.parse(xmlHttpRequest.responseText);
-    //             if (resJsonObj.error != null) {
-    //                 alert(resJsonObj.error);
-    //                 return;
-    //             }
-    //
-    //             alert("0");
-    //
-    //             if (typeof WeixinJSBridge == "undefined") {
-    //                 alert("1");
-    //                 if (document.addEventListener) {
-    //                     document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
-    //                 } else if (document.attachEvent) {
-    //                     document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
-    //                     document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
-    //                 }
-    //             } else {
-    //                 alert("2");
-    //                 onBridgeReady(resJsonObj);
-    //             }
-    //         }
-    //     }
-    //
-    // });
-
-
     $.ajax({
         url : '/wxpay/webPay',
         method : 'post',
@@ -193,12 +154,11 @@ var webPay = function (jsonStr) {
         },
         success : function(res) {
             if (res.error != null) {
-                alert(res.error);
+                toastr.info(res.error);
                 return;
             }
 
             if (typeof WeixinJSBridge == "undefined") {
-                alert("2");
                 if (document.addEventListener) {
                     document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
                 } else if (document.attachEvent) {
@@ -210,7 +170,7 @@ var webPay = function (jsonStr) {
             }
         },
         error : function() {
-            alert('系统异常,请联系客服!');
+            toastr.error('系统异常,请联系客服!');
         }
     });
 
@@ -262,16 +222,15 @@ function onBridgeReady(resJsonObj){
     function (res) {
         // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回    ok,但并不保证它绝对可靠。
         if (res.err_msg == 'get_brand_wcpay_request:ok') {
-            alert("支付成功");
+            toastr.success("支付成功!");
             //window.location.href = "${returnUrl}";
         }else if(res.err_msg == 'get_brand_wcpay_request:cancel'){
-            alert("取消支付");
+            toastr.info("取消支付!");
         }else{
-            alert("支付失败");
+            toastr.error("支付失败!");
         } // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回    ok,但并不保证它绝对可靠。
     });
 }
 
 
 
-

+ 4 - 4
donate-service/src/main/webapp/resources/view/project/organization_detail.html

@@ -795,20 +795,20 @@
                                 <li class="select-money" ng-click="setMoney(100)">100元</li>
                                 <li class="select-money" ng-click="setMoney(200)">200元</li>
                             </ul>
-                            <div class="write"><input type="text" ng-pattern="/^\d{1,9}(.\d{1,2})?$/" ng-model="donation" ng-click="setMoney(0)" ng-change="inputMoney()" placeholder="其他金额" class="write-money  form-control"/><em>元</em></div>
+                            <div class="write"><input type="text" ng-pattern="/^\d{1,9}(.\d{1,2})?$/" ng-model="donation" ng-click="setMoney(0)" ng-change="inputMoney()" placeholder="其他金额" class="write-money  form-control" maxlength="10"/><em>元</em></div>
                         </div>
                     </div>
                     <div class="choose clearfix">
                         <span class="fl">支付方式:</span>
                         <div class="fl pay">
                             <div class="item active select-way"><a ng-click="setWay('支付宝')"><img src="static/images/zfb.png" alt=""/>支付宝</a></div>
-                            <div class="item select-way"><a ng-click="setWay('微信')"><img src="static/images/wx.png" alt=""/>微信支付</a></div>
+                            <div class="item select-way"><a ng-click="setWay('微信支付')"><img src="static/images/wx.png" alt=""/>微信支付</a></div>
                             <!--<div class="item select-way"><a ng-click="setWay('网银')"><img src="static/images/bank.png" alt=""/>网银支付</a></div>-->
                         </div>
                     </div>
                     <div class="choose clearfix">
-                        <span class="fl best">我的祝福:</span>
-                        <textarea ng-model="projectRecord.bless" cols="30" rows="10" class="fl form-control"></textarea>
+                        <!--<span class="fl best">我的祝福:</span>
+                        <textarea ng-model="projectRecord.bless" cols="30" rows="10" class="fl form-control" maxlength="300"></textarea>-->
                         <div class="fl agree clearfix">
                             <input type="checkbox" class="fl" required ng-checked="checked" ng-click="changeChecked()"><span class="fl">同意并接受《<a href="/userAgreement" target="_blank" style="color: #5078cb;">优软一元捐用户协议</a>》</span>
                         </div>

+ 4 - 4
donate-service/src/main/webapp/resources/view/project/project_detail.html

@@ -896,20 +896,20 @@
                                 <li class="select-money" ng-click="setMoney(100)">100元</li>
                                 <li class="select-money" ng-click="setMoney(200)">200元</li>
                             </ul>
-                            <div class="write"><input type="text" ng-pattern="/^\d{1,9}(.\d{1,2})?$/" ng-model="donation" ng-click="setMoney(0)" ng-change="inputMoney()" placeholder="其他金额" class="write-money  form-control"/><em>元</em></div>
+                            <div class="write"><input type="text" ng-pattern="/^\d{1,9}(.\d{1,2})?$/" ng-model="donation" ng-click="setMoney(0)" ng-change="inputMoney()" placeholder="其他金额" class="write-money  form-control" maxlength="10"/><em>元</em></div>
                         </div>
                     </div>
                     <div class="choose clearfix">
                         <span class="fl">支付方式:</span>
                         <div class="fl pay">
                             <div class="item active select-way"><a ng-click="setWay('支付宝')"><img src="static/images/zfb.png" alt=""/>支付宝</a></div>
-                            <div class="item select-way"><a ng-click="setWay('微信')"><img src="static/images/wx.png" alt=""/>微信支付</a></div>
+                            <div class="item select-way"><a ng-click="setWay('微信支付')"><img src="static/images/wx.png" alt=""/>微信支付</a></div>
                             <!--<div class="item select-way"><a ng-click="setWay('网银')"><img src="static/images/bank.png" alt=""/>网银支付</a></div>-->
                         </div>
                     </div>
                     <div class="choose clearfix">
-                        <span class="fl best">我的祝福:</span>
-                        <textarea ng-model="projectRecord.bless" cols="30" rows="10" class="fl form-control"></textarea>
+                        <!--<span class="fl best">我的祝福:</span>
+                        <textarea ng-model="projectRecord.bless" cols="30" rows="10" class="fl form-control" maxlength="300"></textarea>-->
                         <div class="fl agree clearfix">
                             <input type="checkbox" class="fl" required ng-checked="checked" ng-click="changeChecked()"><span class="fl">同意并接受《<a href="/userAgreement" target="_blank" style="color: #5078cb;">优软一元捐用户协议</a>》</span>
                         </div>