Browse Source

20210820 18-20

邪性 3 years ago
parent
commit
3bcf1f9468
5 changed files with 158 additions and 124 deletions
  1. 15 6
      .idea/workspace.xml
  2. 3 2
      h_news/news_detail.html
  3. 103 112
      js/components.js
  4. 1 1
      js/exam_list.js
  5. 36 3
      js/new_detail.js

+ 15 - 6
.idea/workspace.xml

@@ -1,11 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="ChangeListManager">
-    <list default="true" id="82570a17-8430-4238-ae79-81bbbd2de81f" name="Default Changelist" comment="">
+    <list default="true" id="82570a17-8430-4238-ae79-81bbbd2de81f" name="Default Changelist" comment="20210820 17-44">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/h_exam/exam_list.html" beforeDir="false" afterPath="$PROJECT_DIR$/h_exam/exam_list.html" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/h_news/news_detail.html" beforeDir="false" afterPath="$PROJECT_DIR$/h_news/news_detail.html" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/js/components.js" beforeDir="false" afterPath="$PROJECT_DIR$/js/components.js" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/js/exam_list.js" beforeDir="false" afterPath="$PROJECT_DIR$/js/exam_list.js" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/js/new_detail.js" beforeDir="false" afterPath="$PROJECT_DIR$/js/new_detail.js" afterDir="false" />
     </list>
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
     <option name="SHOW_DIALOG" value="false" />
@@ -99,12 +100,12 @@
     <session id="-1918643531">
       <usages-collector id="statistics.file.extensions.edit">
         <counts>
-          <entry key="txt" value="15" />
+          <entry key="txt" value="22" />
         </counts>
       </usages-collector>
       <usages-collector id="statistics.file.types.edit">
         <counts>
-          <entry key="PLAIN_TEXT" value="15" />
+          <entry key="PLAIN_TEXT" value="22" />
         </counts>
       </usages-collector>
     </session>
@@ -1322,7 +1323,14 @@
       <option name="project" value="LOCAL" />
       <updated>1629442332288</updated>
     </task>
-    <option name="localTasksCounter" value="27" />
+    <task id="LOCAL-00027" summary="20210820 17-44">
+      <created>1629452683994</created>
+      <option name="number" value="00027" />
+      <option name="presentableId" value="LOCAL-00027" />
+      <option name="project" value="LOCAL" />
+      <updated>1629452683994</updated>
+    </task>
+    <option name="localTasksCounter" value="28" />
     <servers />
   </component>
   <component name="ToolWindowManager">
@@ -1432,7 +1440,8 @@
     <MESSAGE value="试卷图片页,删除多余功能" />
     <MESSAGE value="试卷图片页" />
     <MESSAGE value="20210820 14-52" />
-    <option name="LAST_COMMIT_MESSAGE" value="20210820 14-52" />
+    <MESSAGE value="20210820 17-44" />
+    <option name="LAST_COMMIT_MESSAGE" value="20210820 17-44" />
   </component>
   <component name="editorHistoryManager">
     <entry file="file://$PROJECT_DIR$/h_news/new_detail.html" />

+ 3 - 2
h_news/news_detail.html

@@ -16,6 +16,7 @@
   <link rel="stylesheet" href="../css/new_detail.css">
   <script src="../js/qrcode.min.js"></script>
   <script src="../js/components.js"></script>
+  <script src="../js/new_detail.js"></script>
   <script>
     var _hmt = _hmt || [];
     (function () {
@@ -55,7 +56,7 @@
         <div class="body">
           <!-- 标题 -->
           <h3>文章标题</h3>
-          <h6 class="click-dom">2021-07*13 11:19 gaokao <img src="../imgs/msg.png"/>评论
+          <h6 class="click-dom">2021-07*13 11:19 gaokao <img src="../imgs/msg.png" />评论
           </h6>
 
           <div id="content">
@@ -131,4 +132,4 @@
   </div>
 </body>
 
-</html>
+</html>

+ 103 - 112
js/components.js

@@ -310,124 +310,115 @@ $(function () {
 })
 // 评论区 点赞
 $(function () {
-  const globaldata = {
-    // 用户是否登录
-    user: false,
-    // 登录弹框
-    sgin () {
-      $("#toast").addClass("show").find(".msg").addClass("show").unbind("click").click(function () {
-        window.location.href = "http://down.gaokaoapp.net"
-      });
-    }
-  }
+  // const globaldata = {
+  //   // 用户是否登录
+  //   user: false,
+  //   // 登录弹框
+  //   sgin () {
+  //     $("#toast").addClass("show").find(".msg").addClass("show").unbind("click").click(function () {
+  //       window.location.href = "http://down.gaokaoapp.net"
+  //     });
+  //   }
+  // }
   // 显示区高度
-  let ch = document.documentElement.clientHeight || document.body.clientHeight;
+  // let ch = document.documentElement.clientHeight || document.body.clientHeight;
   // 实现评论区加载
-  let lock = false;
-  $(window).scroll(function () {
-    if (lock) return false;
-    // 滑动区高度
-    let sh = document.documentElement.scrollHeight || document.body.scrollHeight;
-    // 滑动位置
-    let st = document.documentElement.scrollTop || document.body.scrollTop;
-    let c = sh * 1 - ch * 1 - st * 1;
-    if (c == 0) {
-      lock = true;
-      $(".comment>.loading").addClass("show")
-      setTimeout(function (
-      ) {
-        $(".comment>.loading").removeClass("show");
-        data().then(res => {
-          if (res) {
-            $(".comment>.nodata").addClass("show");
-          }
-          lock = res;
-        });
-      }, 2000)
-    }
-  })
+  // let lock = false, dom = $("#detail") || false;
+
+  // $(window).scroll(function () {
+  //   if (lock && !!dom) return false;
+  //   // 滑动区高度
+  //   let sh = document.documentElement.scrollHeight || document.body.scrollHeight;
+  //   // 滑动位置
+  //   let st = document.documentElement.scrollTop || document.body.scrollTop;
+  //   let c = sh * 1 - ch * 1 - st * 1;
+  //   if (c == 0) {
+  //     lock = true;
+  //     data();
+  //   }
+  // })
   // 阅读量问题
 
   // 评论区
-  function data () {
-    // 请求 根据请求改变内容 唯一标识 data-userid="1" data-good="false"
-    let com = `<div class="user" data-good="false" data-userid="1" >
-    <div class="u-img"><img src="../imgs/qq.png" alt="" class="img"></div>
-    <div class="u-content">
-      <div class="u-flex">
-        <div class="u-name">QQ官方</div>
-        <div class="u-fabulous" data-gods="1"><span>0</span><i data-gods="1" style="margin-left:5px" class="glyphicon glyphicon-thumbs-up"></i></div>
-      </div>
-      <div class="u-detail">
-        对此,广东警官学院表示,其普通高等教育(全日制)招生工作严格执行教育部的“阳光高考”规定和工作程序,不以任何形式承诺录取,不因任何理由降低标准录取。学校从未委托任何个人、中介组织或招生机构开展提前招生、高职扩招等宣
-      </div>
-      <div class="u-flex">
-        <div class="u-date">2020-12-15</div>
-        <div data-gods="2"  class="u-report">举报</div>
-      </div>
-    </div>
-  </div>`;
-    return new Promise(resolve => {
-      $("#detail").append(com);
-      //评论点赞 登录状态 请求
-      let lists = $("#detail>.user");
-      // 模拟无信息加载情况
-      if (lists.length == 10) {
-        resolve(true)
-      }
-      for (let i = 0; i < lists.length; i++) {
-        $(lists[i]).unbind("click");
-        $(lists[i]).click(function (e) {
-          if (!globaldata.user) {
-            globaldata.sgin();
-            return false
-          }
-          let userid = $(this).data("userid");
-          let lock = $(this).data("good");
-          let gods = e.target.dataset.gods;
-          if (gods == 1) {
-            let $i = $(this).find("i");
-            let $span = $(this).find("span");
-            let num = $span.text();
-            if (!lock) {
-              $i.addClass("color");
-              $(this).data("good", true);
-              $span.text(num * 1 + 1);
-            } else {
-              $i.removeClass("color");
-              $(this).data("good", false);
-              $span.text(num * 1 - 1);
-            }
-            return false;
-          }
-          if (gods == 2) {
-            $("#toast").addClass("show").find("#report").addClass("show").data("userid", userid);
-          }
-        })
-      }
-      resolve(false);
-    })
-  }
+  // function data () {
+  //   // 请求 根据请求改变内容 唯一标识 data-userid="1" data-good="false"
+  //   let com = `<div class="user" data-good="false" data-userid="1" >
+  //   <div class="u-img"><img src="../imgs/qq.png" alt="" class="img"></div>
+  //   <div class="u-content">
+  //     <div class="u-flex">
+  //       <div class="u-name">QQ官方</div>
+  //       <div class="u-fabulous" data-gods="1"><span>0</span><i data-gods="1" style="margin-left:5px" class="glyphicon glyphicon-thumbs-up"></i></div>
+  //     </div>
+  //     <div class="u-detail">
+  //       对此,广东警官学院表示,其普通高等教育(全日制)招生工作严格执行教育部的“阳光高考”规定和工作程序,不以任何形式承诺录取,不因任何理由降低标准录取。学校从未委托任何个人、中介组织或招生机构开展提前招生、高职扩招等宣
+  //     </div>
+  //     <div class="u-flex">
+  //       <div class="u-date">2020-12-15</div>
+  //       <div data-gods="2"  class="u-report">举报</div>
+  //     </div>
+  //   </div>
+  // </div>`;
+  //   return new Promise(resolve => {
+  //     $("#detail").append(com);
+  //     //评论点赞 登录状态 请求
+  //     let lists = $("#detail>.user");
+  //     // 模拟无信息加载情况
+  //     if (lists.length == 10) {
+  //       resolve(true)
+  //     }
+  //     for (let i = 0; i < lists.length; i++) {
+  //       $(lists[i]).unbind("click");
+  //       $(lists[i]).click(function (e) {
+  //         if (!globaldata.user) {
+  //           globaldata.sgin();
+  //           return false
+  //         }
+  //         let userid = $(this).data("userid");
+  //         let lock = $(this).data("good");
+  //         let gods = e.target.dataset.gods;
+  //         if (gods == 1) {
+  //           let $i = $(this).find("i");
+  //           let $span = $(this).find("span");
+  //           let num = $span.text();
+  //           if (!lock) {
+  //             $i.addClass("color");
+  //             $(this).data("good", true);
+  //             $span.text(num * 1 + 1);
+  //           } else {
+  //             $i.removeClass("color");
+  //             $(this).data("good", false);
+  //             $span.text(num * 1 - 1);
+  //           }
+  //           return false;
+  //         }
+  //         if (gods == 2) {
+  //           $("#toast").addClass("show").find("#report").addClass("show").data("userid", userid);
+  //         }
+  //       })
+  //     }
+  //     resolve(false);
+  //   })
+  // }
   // 阅读点赞 登录状态 请求
-  $("#read>.good").click(function () {
-    if (!globaldata.user) {
-      globaldata.sgin();
-      return false
-    }
-    let $i = $(this).find("i");
-    let $span = $(this).find("span");
-    let num = $span.text();
-    let lock = $i.data("good");
-    if (!lock) {
-      $i.addClass("color");
-      $i.data("good", true);
-      $span.text(num * 1 + 1);
-    } else {
-      $i.removeClass("color");
-      $i.data("good", false);
-      $span.text(num * 1 - 1);
-    }
-  })
+  // $("#read>.good").click(function () {
+  //   if (!globaldata.user) {
+  //     globaldata.sgin();
+  //     return false
+  //   }
+  //   let $i = $(this).find("i");
+  //   let $span = $(this).find("span");
+  //   let num = $span.text();
+  //   let lock = $i.data("good");
+  //   if (!lock) {
+  //     $i.addClass("color");
+  //     $i.data("good", true);
+  //     $span.text(num * 1 + 1);
+  //   } else {
+  //     $i.removeClass("color");
+  //     $i.data("good", false);
+  //     $span.text(num * 1 - 1);
+  //   }
+  // })
 
 })
 // 省份

+ 1 - 1
js/exam_list.js

@@ -54,7 +54,7 @@ $(function () {
   function data (data) {
     return new Promise(resolve => {
       $.ajax({
-        url: "http://192.168.2.45:8033/exampaper/h/",
+        url: "http://api.gaokaoapp.net/exampaper/h/",
         data: {
           ...data,
           pageSize: 1

+ 36 - 3
js/new_detail.js

@@ -1,6 +1,39 @@
 $(function () {
-  $(".clickmao").click(function () {
-    let mao = $("#comment").offset().top;
-    $(window).scrollTop(mao);
+  let path = lxd.parseUrl(window.location.href).pathname;
+  let reg = /(?<=\/h_news\/).*?(?=.html)/;
+  $.ajax({
+    url: `http://192.168.2.45:8033/news/h/${path.match(reg)}/`,
+    data: {
+    },
+    type: "get",
+    error: function (error) {
+      $(".loading").html("获取更多的评论,请下载大联考app").show();
+    },
+    success: function (res) {
+      let { comments } = res.data;
+      let father = document.createDocumentFragment();
+      Array.from(comments).forEach(
+        item => {
+          let str = `<div class="user" data-good="false" data-userid="1" >
+    <div class="u-img"><img src="${item.user_face}" alt="" class="img"></div>
+    <div class="u-content">
+      <div class="u-flex">
+        <div class="u-name">${item.user_name}</div>
+        <div class="u-fabulous" data-gods="1"><span>${item.like_count}</span><i data-gods="1" style="margin-left:5px" class="glyphicon glyphicon-thumbs-up"></i></div>
+      </div>
+      <div class="u-detail">
+       ${item.content}
+      </div>
+      <div class="u-flex">
+        <div class="u-date">${item.delay_time}</div>
+      </div>
+    </div>
+  </div>`;
+          $(father).append(str);
+        }
+      )
+      $("#detail").append(father);
+      $(".loading").html("获取更多的评论,请下载大联考app").show()
+    }
   })
 })