couple.js 7.1 KB

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