Преглед на файлове

登陆后查看招聘信息与优质岗位

Memory_LG преди 4 месеца
родител
ревизия
763702d1bf

+ 9 - 1
src/main/java/com/sooka/module/web/cms/IndexController.java

@@ -222,23 +222,31 @@ public class IndexController {
     @GetMapping("/${system.site.prefix}/{siteId}/{categoryId}")
     public String category(@PathVariable("siteId") Integer siteId,
                            @PathVariable("categoryId") Long categoryId,
-                           Model model){
+                           Model model, HttpServletRequest request){
         log.debug("栏目");
         TCmsSite site = siteService.findById(siteId);
         if(CmsUtil.isNullOrEmpty(site)) {
             throw new CmsException(CmsConst.SITE_NOT_FOUND);
         }
         TCmsCategory category = categoryService.findById(categoryId);
+        if (request.getSession().getAttribute(LOGIN_USER) == null) {
+            model.addAttribute("showState", false);
+        } else {
+            model.addAttribute("showState", true);
+        }
         if(CmsUtil.isNullOrEmpty(category)) {
             throw new CmsException(CmsConst.CATEGORY_NOT_FOUND);
         }
         PageInfo page = contentService.page(1,siteId,category.getCategoryId());
         model.addAttribute("title",category.getCategoryName());
+
         model.addAttribute("keyword",site.getKeyword());
         model.addAttribute("description",site.getDescription());
         model.addAttribute("site",site);
         model.addAttribute("category",category);
         model.addAttribute("page",page);
+
+
         if(StrUtil.isBlank(site.getTemplate())) {
             return view(category.getIndexTpl());
         }

+ 26 - 10
src/main/resources/templates/www/tuiyijunren/list-dpsg.html

@@ -4,25 +4,41 @@
 <!--中间内容开始-->
 <script>
 	function renderPost(post_str,id) {
-		console.log(post_str)
-		// let html = "<h4>";
 		let arr = post_str.replace(/ /g,"").replace(/,/g," | ");
-		// html += arr + "</h4>"
-		/*for (let i = 0; i < arr.length; i++) {
-			html += +arr[i]+" | ";
-		}*/
-
-		// console.log(html);
-		// return html;
 		$("#"+id).html(arr);
 	}
+
+	function showState(categoryName, state, id, aId, href){
+		//state == true  为已经登录
+		var html = $("#"+id);
+		if(state){
+			console.log("用户已经登陆")
+			var link = $("<a>", {
+				href: href, // 设置链接的href属性
+				text: categoryName, // 设置链接的文本
+				id: aId // 可选:添加一个ID
+			});
+			html.append(link);
+		}else{
+			console.log("用户未登录")
+			if("招聘信息" !== categoryName && "优质岗位" !== categoryName){
+				var link = $("<a>", {
+					href: href, // 设置链接的href属性
+					text: categoryName, // 设置链接的文本
+					id: aId // 可选:添加一个ID
+				});
+				html.append(link);
+			}
+		}
+	}
 </script>
 <div class="er_content clearfix">
 	<div class="er_left fl">
 		<div class="er_nav">
 			<h4>就业信息</h4>
+			<span id="${site.siteId}"></span>
 			<#cms_category_list  siteId="${site.siteId}" categoryId="1218" isNav="0" var="bean">
-				<a id="${bean.categoryId}" href="${frontPath}/${site.siteId}/${bean.categoryId}.html">${bean.categoryName}</a>
+			<script>showState("${bean.categoryName}", ${showState}, "${site.siteId}", "${bean.categoryId}", "${frontPath}/${site.siteId}/${bean.categoryId}.html")</script>
 			</#cms_category_list>
 		</div>
 	</div>

+ 32 - 1
src/main/resources/templates/www/tuiyijunren/list-jyxx.html

@@ -1,13 +1,44 @@
 <!--头部开始-->
 @includeFileTemplate("/www/tuiyijunren/include/header.html"){}
 <!--头部结束-->
+<style>
+    .yincang{
+        display: none;
+    }
+</style>
+<script>
+	function showState(categoryName, state, id, aId, href){
+		//state == true  为已经登录
+		var html = $("#"+id);
+        if(state){
+            console.log("用户已经登陆")
+            var link = $("<a>", {
+                href: href, // 设置链接的href属性
+                text: categoryName, // 设置链接的文本
+                id: aId // 可选:添加一个ID
+            });
+            html.append(link);
+        }else{
+            console.log("用户未登录")
+            if("招聘信息" !== categoryName && "优质岗位" !== categoryName){
+                var link = $("<a>", {
+                    href: href, // 设置链接的href属性
+                    text: categoryName, // 设置链接的文本
+                    id: aId // 可选:添加一个ID
+                });
+                html.append(link);
+            }
+        }
+	}
+</script>
 <!--中间内容开始-->
 <div class="er_content clearfix">
 	<div class="er_left fl">
 		<div class="er_nav">
 			<h4>就业信息</h4>
+			<span id="${site.siteId}"></span>
 			<#cms_category_list  siteId="${site.siteId}" categoryId="1218" isNav="0" var="bean">
-				<a id="${bean.categoryId}" href="${frontPath}/${site.siteId}/${bean.categoryId}.html">${bean.categoryName}</a>
+				<script>showState("${bean.categoryName}", ${showState}, "${site.siteId}", "${bean.categoryId}", "${frontPath}/${site.siteId}/${bean.categoryId}.html")</script>
 			</#cms_category_list>
 		</div>
 	</div>