portal html css js resource

shareLeaveWord.js 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. (function(window) {
  2. function ajaxRequist(url, obj, type, fn) {
  3. $.ajax({
  4. url:url,
  5. data: obj,
  6. dataType: 'json',
  7. type: type,
  8. traditional: true,
  9. success: function(data) {
  10. if(data.success) {
  11. fn(data.data)
  12. }
  13. },
  14. error: function() {
  15. }
  16. });
  17. }
  18. var LeaveWord = function() {
  19. var self = this;
  20. self.sid = module.sid;
  21. self.stype = module.stype;
  22. self.init();
  23. self.bindEvent();
  24. self.LwordTotal();
  25. var str=document.createElement("div");
  26. str.className="con-kong displayNone";
  27. var tNode=document.createTextNode("暂无留言")
  28. str.appendChild(tNode);
  29. document.getElementsByClassName('commentBlock')[0].parentNode.appendChild(str);
  30. }
  31. LeaveWord.prototype.init = function() {
  32. console.log(JSON.stringify(this))
  33. var self = this;
  34. ajaxRequist("/ajax/leavemsg/subject", {
  35. sid: self.sid,
  36. stype: self.stype,
  37. time: 0,
  38. id: 0,
  39. rows: 500
  40. }, "GET", function(data) {
  41. document.getElementsByClassName('commentBlock')[0].innerHTML = ""
  42. if(data.length == 0) {
  43. return;
  44. }
  45. document.getElementById("olisten").parentNode.classList.remove("displayNone");
  46. for(var i = 0; i < data.length; i++) {
  47. var oText = "",
  48. reply = "",
  49. re ='<span class="spanitem plusbtn"><em class="hold-icon icon-zan" data-id="' + data[i].id + '" data-num="' + data[i].agreeCount + '"></em><em style="margin-left:3px;font-size: 14px;display:' + (data[i].agreeCount ? "inline-block" : "none") + '">' + data[i].agreeCount + ' </em></span>'+
  50. '<span class="spanitem replyLew" data-id="' + data[i].id + '">回复</span>';
  51. if(data[i].reciver) {
  52. reply = '<em style="font-style:normal;padding:0 6px;">回复</em>' + '<span class="h1Font reply2"></span>'
  53. }
  54. var baImg = "../images/default-photo.jpg";
  55. var li = document.createElement("li");
  56. li.className = "mui-table-view-cell leaveWord";
  57. li.innerHTML = '<div class="flexCenter mui-clearfix">' +
  58. '<div class="madiaHead useHead" style="background-image:url(' + baImg + ')" data-id="' + data[i].sender + '"></div>' +
  59. '<div class="madiaInfo">' +
  60. '<p class="h2Font"><span class="h1Font replay1"></span>' + reply + '</p>' +
  61. '</div>' +
  62. '</div>' +
  63. '<div class="madiaInfo">' +
  64. '<p class="h1Font">' + data[i].cnt + '</p>' +
  65. '<p class="operateSpan">' +
  66. '<span class="spanitem commenttime">' + commenTime(data[i].createTime) + '</span>' + re + oText +
  67. '</p>' +
  68. '</div>'
  69. document.getElementsByClassName("commentBlock")[0].appendChild(li);
  70. if(data[i].reciver) {
  71. self.userInfo(data[i].sender, li, 1);
  72. self.userInfo(data[i].reciver, li, 2)
  73. } else {
  74. self.userInfo(data[i].sender, li, 1);
  75. }
  76. }
  77. })
  78. }
  79. LeaveWord.prototype.userInfo = function(uId, li, parNum) {
  80. ajaxRequist("/ajax/professor/editBaseInfo/" + uId, {}, "GET", function($data) {
  81. if(parNum == 1) {
  82. if($data.hasHeadImage == 1) {
  83. li.getElementsByClassName("useHead")[0].style.backgroundImage = "url(/images/head/" + $data.id + "_l.jpg)";
  84. }
  85. }
  86. var userType = autho($data.authType, $data.orgAuth, $data.authStatus);
  87. var styStr='<em class="authiconNew ' + userType.sty + '" title="'+userType.title+'"></em>'
  88. if(userType.sty=="e"){
  89. styStr=""
  90. }
  91. var str = '<span class="h1Font" >' + $data.name + '</span>'+styStr
  92. if(parNum == 1) {
  93. li.getElementsByClassName("replay1")[0].innerHTML = str;
  94. } else {
  95. li.getElementsByClassName("reply2")[0].innerHTML = str;
  96. }
  97. if(li.getElementsByClassName("replyLew")[0])
  98. li.getElementsByClassName("replyLew")[0].setAttribute("name", "回复 " + $data.name + ":");
  99. })
  100. }
  101. LeaveWord.prototype.bindEvent = function() {
  102. $(".commentBlock").on("click",".useHead",function(){
  103. var OdataId=this.getAttribute("data-id");
  104. location.href="p.html?id=" + OdataId;
  105. })
  106. }
  107. LeaveWord.prototype.LwordTotal = function() {
  108. var self = this;
  109. ajaxRequist("/ajax/leavemsg/count", {
  110. sid: self.sid,
  111. stype: self.stype
  112. }, "get", function($data) {
  113. if($data > 0) {
  114. document.getElementsByClassName("con-kong")[0].classList.add("displayNone");
  115. }else{
  116. document.getElementsByClassName("con-kong")[0].classList.remove("displayNone");
  117. }
  118. })
  119. }
  120. var module = {
  121. lWord: function(sid, stype) {
  122. this.sid = sid;
  123. this.stype = stype;
  124. var lw = new LeaveWord();
  125. this.init = lw.init;
  126. }
  127. }
  128. window.module = module;
  129. })(window)