Bläddra i källkod

增加项目搜索时给出相应提示功能

scr 8 år sedan
förälder
incheckning
5f2fcce567

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

@@ -20,6 +20,7 @@ import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -164,6 +165,7 @@ public class IndexController {
         List<JSONObject> carouselList=carouselService.getCarousels(useFor);
 	    //动态获取所有领域分类
 	    List<String> areaList = projectService.allArea();
+
 	    //展示不同的状态列表
 	    if (!Status.ALL.getPhrase().equals(status) && Status.ALL.getPhrase().equals(area)) {
 		    if (Status.LOADING.getPhrase().equals(status)) {
@@ -192,6 +194,7 @@ public class IndexController {
 
         if(!"".equals(search)){
             Page<Project> projects=projectService.searchPage(pageable,search);
+            System.out.println("总条数"+projects.getTotalElements());
             model.addAttribute("page",projects);
         }
 

+ 44 - 9
donate-service/src/main/resources/templates/index.ftl

@@ -656,7 +656,32 @@
         #toast-container {
             left: 0;
         }
-
+        /*搜索无结果*/
+        .noSearch .img{
+            margin: 50px auto 26px;
+        }
+        .noSearch .img img{
+            width: 80px;
+            height: 80px;
+        }
+        .noSearch .txt{
+            margin: 0 auto;
+            text-align: center;
+        }
+        .noSearch .txt p{
+            margin-bottom: 54px;
+            font-size: 18px;
+            color: #8c8c8c;
+        }
+        .noSearch .txt a{
+            display: inline-block;
+            width: 140px;
+            height: 36px;
+            line-height: 36px;
+            font-size: 16px;
+            color: #ef613b;
+            border: 1px solid #dcdcdc;
+        }
     </style>
 </head>
 <script type="text/javascript" src="static/js/jquery-1.9.1.min.js"></script>
@@ -751,12 +776,6 @@
                         <#list allArea as area>
                             <option>${area}</option>
                         </#list>
-                        <#--<option>全部</option>
-                        <option>环境/动物保护</option>
-                        <option>疾病援助</option>
-                        <option>扶贫/救灾</option>
-                        <option>教育/助学</option>
-                        <option>其他</option>-->
                     </select>
                 </div>
                 <div class="form-group form-groups">
@@ -764,6 +783,7 @@
                     <img src="static/images/index/search.png" alt="" id="searchButton"/>
                 </div>
             </div>
+            <div>
                 <#if page?exists>
                     <#list page.content as project>
                     <div class="list-item clearfix">
@@ -830,8 +850,23 @@
                         </div>
                     </#list>
                 </#if>
-        <#-- 分页按钮-->
-            <div id="kkpager"></div>
+                <#--搜索无结果页面-->
+                    <#if page.totalElements==0>
+                        <div class="section noSearch">
+                            <div class="img">
+                                <img src="static/images/noSearch.png" alt=""/>
+                            </div>
+                            <div class="txt">
+                                <p>未找到相关内容..</p>
+                                <a href="http://lj.ubtob.com/index">返回</a>
+                            </div>
+                        </div>
+                    </#if>
+                <#-- 分页按钮-->
+                <#if (page.totalElements>0)>
+                    <div id="kkpager"></div>
+                </#if>
+            </div>
         </div>
         </div>
     </div>

BIN
donate-service/src/main/webapp/resources/images/noSearch.png