ソースを参照

修复图片上传逻辑问题

李天标 5 年 前
コミット
d6dd71c471

+ 6 - 6
app-backend-web/src/main/java/com/hboxs/control/admin/JoinPayMchController.java

@@ -186,13 +186,13 @@ public class JoinPayMchController extends BaseController {
         adminService.getCurrent().getId();
         Mch mch = mchService.getUniqueness(id);
         if(cardPositive==null||cardNegative==null){
-            return JsonMessage.success("图片地址不能为空");
-        }
-        String[] string1 = cardPositive.split("\\.");
-        String[] string2 = cardNegative.split("\\.");
-        if(string1.length<2||string2.length<2){
-            return JsonMessage.success("图片地址不规范,留意是否加入后缀名");
+            return JsonMessage.success("图片不能为空");
         }
+//        String[] string1 = cardPositive.split("\\.");
+//        String[] string2 = cardNegative.split("\\.");
+//        if(string1.length<2||string2.length<2){
+//            return JsonMessage.success("图片地址不规范,留意是否加入后缀名");
+//        }
         // 如果分销商商户状态 不为空,则要远程请求刷一下当前的用户order_status
         if (!StringUtils.isBlank(mch.getOrder_status())) {
             String str = mchService.sendCard(mch,cardPositive,cardNegative);

+ 1 - 0
app-backend-web/src/main/java/com/hboxs/control/admin/PromoCodeController.java

@@ -381,4 +381,5 @@ public class PromoCodeController extends BaseController {
         return JsonMessage.success("导出错误");
     }
 
+
 }

+ 43 - 2
app-backend-web/src/main/webapp/WEB-INF/template/admin/adminAgency/edit.ftl

@@ -208,8 +208,12 @@ $().ready(function() {
                 <th>
                     身份证正面存放地址:
                 </th>
+[#--                <td >--]
+[#--                    <input type="text"  name="sn" id="card_positive" style="width: 300px"/>--]
+[#--                </td>--]
                 <td >
-                    <input type="text"  name="sn" id="card_positive" style="width: 300px"/>
+                    <input type="file" accept="image/*" onchange="showImg(this)" />
+                    <img src="" alt="" id="card_positive" style="height: 150px">
                 </td>
             </tr>
             <tr>
@@ -217,7 +221,9 @@ $().ready(function() {
                     身份证背面存放地址:
                 </th>
                 <td >
-                    <input type="text"  name="sn" id="card_negative" style="width: 300px"/>
+[#--                    <input type="text"  name="sn" id="card_negative" style="width: 300px"/>--]
+                    <input type="file" accept="image/*" onchange="showImg2(this)" />
+                    <img src="" alt="" id="card_negative" value="" style="height: 150px" >
                     &nbsp &nbsp <button type="button" id="sendCard" >上传</button>
                 </td>
             </tr>
@@ -445,5 +451,40 @@ $().ready(function() {
             }
         })
     });
+    function showImg(obj) {
+        var file=$(obj)[0].files[0];    //获取文件信息
+        var imgdata='';
+        if(file)
+        {
+            var reader=new FileReader();  //调用FileReader
+            reader.readAsDataURL(file); //将文件读取为 DataURL(base64)
+            reader.onload=function(evt){
+                //读取操作完成时触发。
+                $("#card_positive").attr('src',evt.target.result);  //将img标签的src绑定为DataURL
+                $("#card_positive").attr('value',evt.target.result);
+            };
+        }
+        else{
+            alert("上传失败");
+        }
+    }
+
+    function showImg2(obj) {
+        var file=$(obj)[0].files[0];    //获取文件信息
+        var imgdata='';
+        if(file)
+        {
+            var reader=new FileReader();  //调用FileReader
+            reader.readAsDataURL(file); //将文件读取为 DataURL(base64)
+            reader.onload=function(evt){
+                //读取操作完成时触发。
+                $("#card_negative").attr('src',evt.target.result);  //将img标签的src绑定为DataURL
+                $("#card_negative").attr('value',evt.target.result);
+            };
+        }
+        else{
+            alert("上传失败");
+        }
+    }
 </script>
 </html>

+ 43 - 2
app-backend-web/src/main/webapp/WEB-INF/template/admin/adminMerchant/edit.ftl

@@ -202,8 +202,12 @@ $().ready(function() {
                 <th>
                     身份证正面存放地址:
                 </th>
+[#--                <td >--]
+[#--                    <input type="text" id="card_positive"  style="width: 300px"/>--]
+[#--                </td>--]
                 <td >
-                    <input type="text" id="card_positive"  style="width: 300px"/>
+                    <input type="file" accept="image/*" onchange="showImg(this)" />
+                    <img src="" alt="" id="card_positive" style="height: 150px">
                 </td>
             </tr>
             <tr>
@@ -211,7 +215,9 @@ $().ready(function() {
                     身份证背面存放地址:
                 </th>
                 <td >
-                    <input type="text"   id="card_negative" style="width: 300px" />
+[#--                    <input type="text"   id="card_negative" style="width: 300px" />--]
+                    <input type="file" accept="image/*" onchange="showImg2(this)" />
+                    <img src="" alt="" id="card_negative" value="" style="height: 150px" >
                     &nbsp &nbsp <button type="button" id="sendCard" >上传</button>
                 </td>
             </tr>
@@ -422,5 +428,40 @@ $().ready(function() {
             }
         })
     });
+    function showImg(obj) {
+        var file=$(obj)[0].files[0];    //获取文件信息
+        var imgdata='';
+        if(file)
+        {
+            var reader=new FileReader();  //调用FileReader
+            reader.readAsDataURL(file); //将文件读取为 DataURL(base64)
+            reader.onload=function(evt){
+                //读取操作完成时触发。
+                $("#card_positive").attr('src',evt.target.result);  //将img标签的src绑定为DataURL
+                $("#card_positive").attr('value',evt.target.result);
+            };
+        }
+        else{
+            alert("上传失败");
+        }
+    }
+
+    function showImg2(obj) {
+        var file=$(obj)[0].files[0];    //获取文件信息
+        var imgdata='';
+        if(file)
+        {
+            var reader=new FileReader();  //调用FileReader
+            reader.readAsDataURL(file); //将文件读取为 DataURL(base64)
+            reader.onload=function(evt){
+                //读取操作完成时触发。
+                $("#card_negative").attr('src',evt.target.result);  //将img标签的src绑定为DataURL
+                $("#card_negative").attr('value',evt.target.result);
+            };
+        }
+        else{
+            alert("上传失败");
+        }
+    }
 </script>
 </html>

+ 44 - 3
app-backend-web/src/main/webapp/WEB-INF/template/admin/adminPersonage/edit.ftl

@@ -199,16 +199,22 @@ $().ready(function() {
                 <th>
                     身份证正面存放地址:
                 </th>
+[#--                <td >--]
+[#--                    <input type="text"  name="sn" id="card_positive" style="width: 300px"/>--]
+[#--                </td>--]
                 <td >
-                    <input type="text"  name="sn" id="card_positive" style="width: 300px"/>
+                    <input type="file" accept="image/*" onchange="showImg(this)" />
+                    <img src="" alt="" id="card_positive" style="height: 150px">
                 </td>
             </tr>
             <tr>
                 <th>
                     身份证背面存放地址:
                 </th>
-                <td id="orderStatus">
-                    <input type="text"  name="sn" id="card_negative" style="width: 300px"/>
+                <td >
+[#--                    <input type="text"  name="sn" id="card_negative" style="width: 300px"/>--]
+                    <input type="file" accept="image/*" onchange="showImg2(this)" />
+                    <img src="" alt="" id="card_negative" value="" style="height: 150px" >
                     &nbsp &nbsp <button type="button" id="sendCard" >上传</button>
                 </td>
             </tr>
@@ -401,5 +407,40 @@ $().ready(function() {
             }
         })
     });
+    function showImg(obj) {
+        var file=$(obj)[0].files[0];    //获取文件信息
+        var imgdata='';
+        if(file)
+        {
+            var reader=new FileReader();  //调用FileReader
+            reader.readAsDataURL(file); //将文件读取为 DataURL(base64)
+            reader.onload=function(evt){
+                //读取操作完成时触发。
+                $("#card_positive").attr('src',evt.target.result);  //将img标签的src绑定为DataURL
+                $("#card_positive").attr('value',evt.target.result);
+            };
+        }
+        else{
+            alert("上传失败");
+        }
+    }
+
+    function showImg2(obj) {
+        var file=$(obj)[0].files[0];    //获取文件信息
+        var imgdata='';
+        if(file)
+        {
+            var reader=new FileReader();  //调用FileReader
+            reader.readAsDataURL(file); //将文件读取为 DataURL(base64)
+            reader.onload=function(evt){
+                //读取操作完成时触发。
+                $("#card_negative").attr('src',evt.target.result);  //将img标签的src绑定为DataURL
+                $("#card_negative").attr('value',evt.target.result);
+            };
+        }
+        else{
+            alert("上传失败");
+        }
+    }
 </script>
 </html>

+ 44 - 2
app-backend-web/src/main/webapp/WEB-INF/template/admin/joinpay/mch/edit.ftl

@@ -130,8 +130,12 @@ $().ready(function() {
                 <th>
                     身份证正面存放地址:
                 </th>
+[#--                <td >--]
+[#--                    <input type="text"  id="card_positive"  style="width: 300px"/>--]
+[#--                </td>     --]
                 <td >
-                    <input type="text"  id="card_positive"  style="width: 300px"/>
+                    <input type="file" accept="image/*" onchange="showImg(this)" />
+                    <img src="" alt="" id="card_positive" style="height: 150px">
                 </td>
             </tr>
             <tr>
@@ -139,7 +143,10 @@ $().ready(function() {
                     身份证背面存放地址:
                 </th>
                 <td >
-                    <input type="text"   id="card_negative"  style="width: 300px">
+[#--                    <input type="text"   id="card_negative"  style="width: 300px">--]
+                    <input type="file" accept="image/*" onchange="showImg2(this)" />
+                    <img src="" alt="" id="card_negative" value="" style="height: 150px" >
+
                     &nbsp &nbsp <button type="button" id="sendCard" >上传</button>
                 </td>
             </tr>
@@ -334,5 +341,40 @@ $().ready(function() {
             }
         })
     });
+    function showImg(obj) {
+        var file=$(obj)[0].files[0];    //获取文件信息
+        var imgdata='';
+        if(file)
+        {
+            var reader=new FileReader();  //调用FileReader
+            reader.readAsDataURL(file); //将文件读取为 DataURL(base64)
+            reader.onload=function(evt){
+                //读取操作完成时触发。
+                $("#card_positive").attr('src',evt.target.result);  //将img标签的src绑定为DataURL
+                $("#card_positive").attr('value',evt.target.result);
+            };
+        }
+        else{
+            alert("上传失败");
+        }
+    }
+
+    function showImg2(obj) {
+        var file=$(obj)[0].files[0];    //获取文件信息
+        var imgdata='';
+        if(file)
+        {
+            var reader=new FileReader();  //调用FileReader
+            reader.readAsDataURL(file); //将文件读取为 DataURL(base64)
+            reader.onload=function(evt){
+                //读取操作完成时触发。
+                $("#card_negative").attr('src',evt.target.result);  //将img标签的src绑定为DataURL
+                $("#card_negative").attr('value',evt.target.result);
+            };
+        }
+        else{
+            alert("上传失败");
+        }
+    }
 </script>
 </html>

+ 1 - 0
app-backend-web/src/main/webapp/WEB-INF/template/admin/promoCode/list.ftl

@@ -338,4 +338,5 @@
 [#--</script>--]
 
 
+
 </html>

+ 4 - 2
app-service/src/main/java/com/hboxs/service/impl/MchServiceImpl.java

@@ -697,8 +697,10 @@ public class MchServiceImpl extends BaseServiceImpl<Mch, Long> implements MchSer
         if(StringUtils.isEmpty(mch.getAlt_mch_no())){
             return "找不到商家编号";
         }
-        String card_positive = ImageToBase64ByLocal(cardPositive);
-        String card_negative = ImageToBase64ByLocal(cardNegative);
+//        String card_positive = ImageToBase64ByLocal(cardPositive);
+        String card_positive = cardPositive;
+//        String card_negative = ImageToBase64ByLocal(cardNegative);
+        String card_negative = cardNegative;
 
         JSONObject requestData = new JSONObject(new LinkedHashMap());
         requestData.put("alt_mch_no" , mch.getAlt_mch_no());