couple.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. Namespace.register("Couple");//注册命名空间
  2. Couple.Bind=function () {
  3. var userName=$(".userName")[0]//获取用户名
  4. var ul = $(".asideMenu ul")[0];//获取项目列表ul
  5. var asideMenu = $(".asideMenu")[0];
  6. var informationtInfo = $(".informationtInfo")[0];//获取反馈信息
  7. var informationtTime = $(".informationtTime")[0];//获取反馈时间
  8. userName.innerText = document.URL.split('?')[1].split("=")[1];
  9. U.A.Request("http://cd.1473.cn/net",["db.1473.cn", "UseStudio_Couple", "GetProductByUserId",U.UF.Cookie.get("usestudiosso","userid")[0]],function (r){//获取项目列表
  10. for(var i=0;i<r.value.length;i++){
  11. var li=$$("li", {
  12. "className": "asideItem","productId":r.value[i].ProductId
  13. }, ul);
  14. var a=$$("a", {}, li);
  15. var icon=$$("span", {
  16. "className": "icon icon-times icon-2x",
  17. }, a);
  18. var span=$$("span", {
  19. "className": "asideItemText","innerText":r.value[i].ProductName
  20. }, a);
  21. ul.onclick = function(ev) {//点击项目列表
  22. ev = ev || event;
  23. var target = ev.target || ev.srcElement;
  24. var productId = target.parentNode.parentElement.productId;
  25. if(informationtTime.firstChild==null){
  26. Couple.createInfo(productId)
  27. }else{
  28. informationtInfo.removeChild(informationtInfo.firstChild);
  29. informationtTime.removeChild(informationtTime.firstChild);
  30. Couple.createInfo(productId)
  31. }
  32. Couple.OnclickTime=function(id,time){//点击时间对应获取信息
  33. U.A.Request("http://cd.1473.cn/net",["db.1473.cn", "UseStudio_Couple", "GetCouple",id,time],function (r){//获取产品的反馈信息
  34. if(informationtInfo.firstChild==null){}else{
  35. informationtInfo.removeChild(informationtInfo.firstChild);
  36. informationtTime.removeChild(informationtTime.firstChild);
  37. Couple.createInfo(productId)
  38. }
  39. var tbody = $$("tbody", {//创建表格
  40. "className": "tbMain",
  41. }, informationtInfo);
  42. var tr = $$("tr", {}, tbody);
  43. var td = $$("td", {
  44. "className":"infoTitle","innerText":"排序"
  45. }, tr);
  46. var td = $$("td", {
  47. "className":"infoTitle trTitle","innerText":"标题"
  48. }, tr);
  49. var td = $$("td", {
  50. "className":"infoTitle trContent","innerText":"内容",
  51. }, tr);
  52. var td = $$("td", {
  53. "className":"infoTitle trCoupleTime","innerText":"反馈时间"
  54. }, tr);
  55. var td = $$("td", {}, tr);
  56. for(var i=0;i<r.value.length;i++){
  57. var trow = Couple.getDataRow(r.value[i],i+1);
  58. tbody.appendChild(trow);
  59. }
  60. })
  61. }
  62. };
  63. }
  64. })
  65. }
  66. Couple.createInfo=function(productId){
  67. var informationtTime = $(".informationtTime")[0]//获取反馈时间
  68. Date.prototype.Format = function (fmt) {//时间处理对Date的扩展
  69. var o = {
  70. "M+": this.getMonth() + 1, // 月份
  71. "d+": this.getDate(), // 日
  72. "h+": this.getHours(), // 小时
  73. "m+": this.getMinutes(), // 分
  74. "s+": this.getSeconds(), // 秒
  75. "q+": Math.floor((this.getMonth() + 3) / 3), // 季度
  76. "S": this.getMilliseconds() // 毫秒
  77. };
  78. if (/(y+)/.test(fmt))
  79. fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  80. for (var k in o)
  81. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  82. return fmt;
  83. }
  84. var time = (new Date()).Format("yyyy-MM-dd hh:mm:ss");//获取时间
  85. var timeSequence=$$("div", {
  86. "className": "timeSequence"
  87. }, informationtTime);
  88. var oneDay=$$("button", {
  89. "className": "timeItem","innerText":"今天","onclick":"Couple.OnclickTime('"+productId+"','today')"
  90. }, timeSequence);
  91. var threeDay=$$("button", {
  92. "className": "timeItem","innerText":"最近三天","onclick":"Couple.OnclickTime('"+productId+"','3days')"
  93. }, timeSequence);
  94. var oneWeek=$$("button", {
  95. "className": "timeItem","innerText":"最近一周","onclick":"Couple.OnclickTime('"+productId+"','7days')"
  96. }, timeSequence)
  97. var oneMonth=$$("button", {
  98. "className": "timeItem","innerText":"最近一月","onclick":"Couple.OnclickTime('"+productId+"','30days')"
  99. }, timeSequence)
  100. }
  101. Couple.logout=function(){//退出
  102. U.UF.CD.loadAjaxCrossDomain(function(){
  103. U.A.Request(US.AUTH, ["UserOffline", U.UF.Cookie.get("usestudiosso","userid")[0]],function(r){
  104. window.location.href="http://couple.1473.cn/login.html";
  105. console.log(r)
  106. });
  107. });
  108. }
  109. Couple.getDataRow = function(h,i){//创建表格下的行放数据库循环数据
  110. var row = document.createElement('tr');
  111. var sortCell = document.createElement('td');
  112. sortCell.innerText = i;
  113. row.appendChild(sortCell);
  114. var trTitle = document.createElement('td');
  115. trTitle.setAttribute('class','trTitle');
  116. trTitle.innerText = h.CoupleName;
  117. row.appendChild(trTitle);
  118. var trContent = document.createElement('td');
  119. trContent.setAttribute('class','trContent');
  120. trContent.innerText = h.CoupleContent;
  121. row.appendChild(trContent);
  122. var trCoupleTime = document.createElement('td');
  123. trCoupleTime.setAttribute('class','trCoupleTime');
  124. trCoupleTime.innerText = U.UF.D.getYearMonthDay(h.CoupleTime)
  125. row.appendChild(trCoupleTime);
  126. //每行末尾添加删除按钮
  127. var delCell = document.createElement('td');
  128. delCell.setAttribute('class','trDel');
  129. row.appendChild(delCell);
  130. var btnDel = document.createElement('input');
  131. btnDel.setAttribute('type','button');
  132. btnDel.setAttribute('value','删除');
  133. btnDel.setAttribute('class','delectInfo');
  134. btnDel.onclick=function(){ //删除操作
  135. if(confirm("确定删除这一行嘛?")){
  136. this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
  137. }
  138. U.A.Request("http://cd.1473.cn/net",["db.1473.cn", "UseStudio_Couple", "DeleteCouple",h.CoupleId],function (r){})
  139. }
  140. delCell.appendChild(btnDel);
  141. return row;
  142. }
  143. Couple.Init=function () {
  144. var asideMenu = $(".asideMenu")[0];
  145. Couple.Bind();
  146. window.onscroll = function(){
  147. var scrollTop = document.documentElement.scrollTop;
  148. if(scrollTop>=1){
  149. asideMenu.style.top = "0";
  150. }else{
  151. asideMenu.style.top = "70px";
  152. }
  153. }
  154. }();