Browse Source

解决活动搜索时,搜出还未开始的活动的bug

scr 8 years ago
parent
commit
6a192fafee

+ 2 - 2
donate-service/src/main/java/com/uas/service/donate/dao/ActivityDao.java

@@ -41,10 +41,10 @@ public interface ActivityDao extends JpaRepository<Activity,Long>,JpaSpecificati
     Page<Activity> findEndActivities(Pageable pageable);
 
     //根据活动名关键字,奖品名关键字查询活动
-    @Query("from Activity a where a.name like %:search% or a.id in (select aw.activityId from Award aw where aw.awardName like %:search%) order by a.startTime desc")
+    @Query("from Activity a where  a.publish=2 and NOW()>a.startTime and (a.name like %:search% or a.id in (select aw.activityId from Award aw where aw.awardName like %:search%)) order by a.startTime desc")
     List<Activity> search(@Param("search")String search);
 
-    @Query("from Activity a where a.name like %:search% or a.id in (select aw.activityId from Award aw where aw.awardName like %:search%) order by a.startTime desc")
+    @Query("from Activity a where  a.publish=2 and NOW()>a.startTime and (a.name like %:search% or a.id in (select aw.activityId from Award aw where aw.awardName like %:search%)) order by a.startTime desc")
     Page<Activity> search(@Param("search")String search,Pageable pageable);
 
     /**

+ 2 - 1
donate-service/src/main/resources/templates/activeCenter.ftl

@@ -321,6 +321,7 @@
             width: 160px;
             height: 160px;
             border: 1px solid #e1e1e1;
+            background: url("static/images/loading2.png") no-repeat;
         }
         .section2 .list-item .project-detail{
             margin: 10px 30px 0 0;
@@ -419,7 +420,7 @@
 <div ng-include src="'static/view/common/nav.html'"></div>
 <div id="nav">
     <div class="container clearfix">
-        <div class="fl"><a href=""><img src="static/images/uas.png" alt=""/></a><span style="font-size: 18px;font-weight: bold;">一元捐</span></div>
+        <div class="fl"><a href=""><img src="static/images/uas.png" href="http://www.ubtob.com/index"/></a><span style="font-size: 18px;font-weight: bold;">一元捐</span></div>
         <div class="fr">
             <a href="https://account.ubtob.com/sso/login">登录</a>
             <a href="javascript:void(0)">注册</a>

+ 109 - 15
donate-service/src/main/resources/templates/index.ftl

@@ -14,7 +14,7 @@
     <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" type="text/css" href="static/lib/font-awesome/css/font-awesome.min.css"/>
     <link href="https://cdn.bootcss.com/toastr.js/latest/css/toastr.min.css" rel="stylesheet">
     <link href="static/css/swiper-3.4.2.min.css" rel="stylesheet">
 
@@ -82,6 +82,15 @@
         #nav .fr a:last-child {
             margin-right: 0;
         }
+        #logout{
+             display: none;
+         }
+        #uuName{
+            display: none;
+        }
+        #icon{
+            margin-left: 10px;
+        }
         .main{
             width: 100%;
             margin: 24px 0 150px 0;
@@ -307,6 +316,9 @@
             right: 10px;
             cursor: pointer;
         }
+        #projectList{
+            border:none
+        }
         .section2 .list-item {
             margin-top: 25px;
             padding-bottom: 25px;
@@ -323,7 +335,7 @@
             width: 360px;
             height: 200px;
             border: 1px solid #e1e1e1;
-            background: url("static/images/link.png") no-repeat;
+            background: url("static/images/loading1.png") no-repeat;
         }
         .section2 .list-item .project-detail{
             margin: 10px 30px 0 0;
@@ -694,10 +706,12 @@
 <body ng-app="index">
 <div id="nav">
     <div class="container clearfix">
-        <div class="fl"><a href=""><img src="static/images/uas.png" alt=""/></a><span style="font-size: 18px;font-weight: bold;">一元捐</span></div>
+        <div class="fl"><a href=""><img src="static/images/uas.png" href="http://www.ubtob.com/index"/></a><span style="font-size: 18px;font-weight: bold;">一元捐</span></div>
         <div class="fr">
-            <a href="https://account.ubtob.com/sso/login">登录</a>
-            <a href="javascript:void(0)">注册</a>
+            <a href="javascript:void(0);" id="login">登录</a>
+            <a href="javascript:void(0);" id="uuName"><i class="fa fa-user fa-lg" id="icon"></i></a>
+            <a href="javascript:void(0)" id="register">注册</a>
+            <a href="javascript:void(0)" id="logout">退出</a>
             <a href="http://www.ubtob.com/" target="_blank">进入优软云</a>
         </div>
     </div>
@@ -786,7 +800,7 @@
                     <img src="static/images/index/search.png" alt="" id="searchButton"/>
                 </div>
             </div>
-            <div>
+            <div id="projectList">
                 <#if page?exists>
                     <#list page.content as project>
                     <div class="list-item clearfix">
@@ -853,6 +867,7 @@
                     </#list>
                 </#if>
                 <#--搜索无结果页面-->
+                <#if page?exists>
                     <#if page.totalElements==0>
                         <div class="section noSearch">
                             <div class="img">
@@ -864,6 +879,7 @@
                             </div>
                         </div>
                     </#if>
+                </#if>
                 <#-- 分页按钮-->
                 <#if (page.totalElements>0)>
                     <div id="kkpager"></div>
@@ -884,6 +900,77 @@
 </div>
 </body>
 <script>
+    var returnUrl=window.location.href;
+    $.ajax({
+        url:"http://shicr.ubtob.com:8084/sso/account",
+        type:"GET",
+        success:function(data){
+            console.log(data);
+            if(data.content!=null){
+                $("#uuName").css("display","inline-block");
+                $("#icon").before(data.content.name);
+                $("#logout").css("display","inline-block");
+                $("#login").css("display","none");
+                $("#register").css("display","none");
+            }
+        },
+        error:function(){
+            alert('error');
+        }
+    })
+    //登录
+    $("#login").click(function(){
+        $.ajax({
+            url:"http://shicr.ubtob.com:8084/sso/login",
+            data:{returnUrl:returnUrl},
+            type:"GET",
+            success:function(data){
+                window.location.href=data.content;
+                $("#uuName").css("display","inline-block");
+                $("#icon").before(data.content.name);
+                $("#login").css("display","none");
+                $("#register").css("display","none");
+                $("#logout").css("display","inline-block");
+                $("#uuName").css("display","inline-block");
+            },
+            error:function(data){
+                alert('登录失败');
+            }
+        })
+    })
+    //注册按钮点击
+    $("#register").click(function(){
+        $.ajax({
+            url:"http://shicr.ubtob.com:8084/sso/register",
+            type:"GET",
+            data:{returnUrl:returnUrl},
+            success:function(data){
+                window.location.href=data.content;
+            },
+            error:function(data){
+                alert('登录失败');
+            }
+        })
+    })
+    //退出
+    $("#logout").click(function(){
+       $.ajax({
+           url:"http://shicr.ubtob.com:8084/sso/logout",
+           type:"GET",
+           data:{returnUrl:returnUrl},
+           success:function(data){
+               window.location.href=data.content;
+               $("#login").css("display","inline-block");
+               $("#register").css("display","inline-block");
+               $("#logout").css("display","none");
+               $("#uuName").css("display","none");
+           },
+           error:function(){
+               alert('退出失败');
+           }
+       })
+    })
+
     /*设置只能输入数字和一位小数点和一位小数点后面的两位数字*/
     function clearNoNum(obj){
         obj.value = obj.value.replace(/[^\d.]/g,"");  //清除“数字”和“.”以外的字符
@@ -983,9 +1070,13 @@
         //返回参数值
         return result ? decodeURIComponent(result[2]) : null;
     }
+    //获取地址栏领域值
     var area=getUrlParam('area');
+    //获取地址栏状态值
     var status=getUrlParam('status');
+    //获取地址栏页码值
     var pno=getUrlParam('page');
+    //获取地址栏搜索框值
     var search=getUrlParam('search');
 
 
@@ -1031,23 +1122,26 @@
         }
 
     });
+    var address='http://lj.ubtob.com/index';
     /*页面跳转*/
     function searchpage(pno) {
         if(search!=null){
-            window.location.href="http://lj.ubtob.com/index?search="+search+"&&page="+(pno-1);
+            window.location.href=address+"?search="+search+"&&page="+(pno-1);
         }else{
             //得到被选中的领域下拉框的文本值
             var area=$("#chooseArea").find("option:selected").text();
             //得到被选中的状态下拉框文本值
             var status=$("#chooseStatus").find("option:selected").text();
-            window.location.href="http://lj.ubtob.com/index?area="+area+"&&status="+status+"&&page="+(pno-1);
+            window.location.href=address+"?area="+area+"&&status="+status+"&&page="+(pno-1);
         }
     }
-
+    //给领域下拉框赋值
     $('#chooseArea').val(area);
 
+    //给状态下拉框
     $('#chooseStatus').val(status);
 
+    //给搜索框赋值
     $('#search').val(search);
 
     //项目领域下拉框查询项目
@@ -1056,7 +1150,7 @@
         var area=$("#chooseArea").find("option:selected").text();
         //得到被选中的状态下拉框文本值
         var status=$("#chooseStatus").find("option:selected").text();
-        window.location.href="http://lj.ubtob.com/index?area="+area+"&&status="+status;
+        window.location.href=address+"?area="+area+"&&status="+status;
     })
 
     //项目状态下拉框查询项目
@@ -1065,7 +1159,7 @@
         var area=$("#chooseArea").find("option:selected").text();
         //得到被选中的状态下拉框文本值
         var status=$("#chooseStatus").find("option:selected").text();
-        window.location.href="http://lj.ubtob.com/index?area="+area+"&&status="+status;
+        window.location.href=address+"?area="+area+"&&status="+status;
     })
 
     //搜索框enter键搜索框查询项目
@@ -1073,9 +1167,9 @@
         if(event.keyCode==13){
             var search=$("#search").val();
             if(search!=""){
-                window.location.href="http://lj.ubtob.com/index?search="+search;
+                window.location.href=address+"?search="+search;
             }else{
-                window.location.href="http://lj.ubtob.com/index";
+                window.location.href=address;
             }
         }
     })
@@ -1084,9 +1178,9 @@
     $("#searchButton").click(function(){
         var search=$("#search").val();
         if(search!=""){
-            window.location.href="http://lj.ubtob.com/index?search="+search;
+            window.location.href=address+"?search="+search;
         }else{
-            window.location.href="http://lj.ubtob.com/index";
+            window.location.href=uaddressrl;
         }
 
     })

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


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