couple.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 informationtInfo = $(".informationtInfo")[0];//获取反馈信息
  75. var informationtTime = $(".informationtTime")[0];//获取反馈时间
  76. userName.innerText = document.URL.split('?')[1].split("=")[1];
  77. U.A.Request("http://cd.1473.cn/net",["db.1473.cn", "UseStudio_Couple", "GetProductByUserId",U.UF.Cookie.get("usestudiosso","userid")[0]],function (r){//获取项目列表
  78. for(var i=0;i<r.value.length;i++){
  79. var li=$$("li", {
  80. "className": "asideItem","productId":r.value[i].ProductId
  81. }, ul);
  82. var a=$$("a", {}, li);
  83. var icon=$$("span", {
  84. "className": "icon icon-times icon-2x",
  85. }, a);
  86. var span=$$("span", {
  87. "className": "asideItemText","innerText":r.value[i].ProductName
  88. }, a);
  89. ul.onclick = function(ev) {//点击项目列表
  90. ev = ev || event;
  91. var target = ev.target || ev.srcElement;
  92. var productId = target.parentNode.parentElement.productId;
  93. if(informationtTime.firstChild==null){
  94. Couple.Bind(productId)
  95. }else{
  96. informationtInfo.removeChild(informationtInfo.firstChild);
  97. informationtTime.removeChild(informationtTime.firstChild);
  98. Couple.Bind(productId)
  99. }
  100. Couple.OnclickTime=function(id,time){//点击时间对应获取信息
  101. U.A.Request("http://cd.1473.cn/net",["db.1473.cn", "UseStudio_Couple", "GetCouple",id,time],function (r){//获取产品的反馈信息
  102. if(informationtInfo.firstChild==null){}else{
  103. informationtInfo.removeChild(informationtInfo.firstChild);
  104. informationtTime.removeChild(informationtTime.firstChild);
  105. Couple.Bind(productId)
  106. }
  107. var tbody = $$("tbody", {//创建表格
  108. "className": "tbMain",
  109. }, informationtInfo);
  110. var tr = $$("tr", {}, tbody);
  111. var td = $$("td", {
  112. "className":"infoTitle","innerText":"排序"
  113. }, tr);
  114. var td = $$("td", {
  115. "className":"infoTitle trTitle","innerText":"标题"
  116. }, tr);
  117. var td = $$("td", {
  118. "className":"infoTitle trContent","innerText":"内容",
  119. }, tr);
  120. var td = $$("td", {
  121. "className":"infoTitle trCoupleTime","innerText":"反馈时间"
  122. }, tr);
  123. var td = $$("td", {}, tr);
  124. for(var i=0;i<r.value.length;i++){
  125. var trow = Couple.getDataRow(r.value[i],i+1);
  126. tbody.appendChild(trow);
  127. }
  128. })
  129. }
  130. };
  131. }
  132. })
  133. Couple.logout=function(){//退出
  134. U.UF.CD.loadAjaxCrossDomain(function(){
  135. U.A.Request(US.AUTH, ["UserOffline", U.UF.Cookie.get("usestudiosso","userid")[0]],function(r){
  136. window.location.href="http://couple.1473.cn/login.html";
  137. });
  138. });
  139. }
  140. }();