sorypage.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. var nei="";
  2. var ask="";
  3. //发布框等字数统计
  4. function checkWord(len, evt, wordCheckNumID) {
  5. if (evt == null)
  6. evt = window.event;
  7. var src = evt.srcElement ? evt.srcElement : evt.target;
  8. var str = src.value.trim();
  9. myLen = 0;
  10. i = 0;
  11. for (; (i < str.length) && (myLen <= len * 2); i++) {
  12. if (str.charCodeAt(i) > 0 && str.charCodeAt(i) < 128)
  13. myLen++;
  14. else
  15. myLen += 2;
  16. }
  17. if (myLen > len * 2) {
  18. src.value = str.substring(0, i - 1);
  19. } else {
  20. document.getElementById(wordCheckNumID).innerHTML = Math
  21. .floor((len * 2 - myLen) / 2);
  22. }
  23. }
  24. $(function() {
  25. $("#additionalclose").click(function() {
  26. $('#additional_content').toggle(1000);
  27. });
  28. $("#toaskclose").click(function() {
  29. $('#to_ask_info').toggle(1000);
  30. });
  31. //追问
  32. $("#to_ask").click(function() {
  33. if(typeof( ask) =="string"){
  34. ask = new UE.ui.Editor();
  35. ask.render('to_ask_text');
  36. }
  37. $('#to_ask_info').toggle(1000);
  38. });
  39. //不满意
  40. $("#answer_no_satisfy").click(function() {
  41. var qid=$("#qid").val();
  42. var url="/ajax/vip_question/refunds";
  43. $.ajax({
  44. url:url,
  45. type: "post",
  46. cache: false,
  47. dataType: "json",
  48. data: {
  49. qid:qid
  50. },
  51. global: true,
  52. success: function(data){
  53. if(data.refunds==1){
  54. easyDialog.open({
  55. container : {
  56. header : '确认该答案为不满意',
  57. content : data.message+"<br/>原因:<input type='text' name='refunds_content' id='refunds_content' value=''/>",
  58. yesFn : setnosatisfy,
  59. noFn : true
  60. },
  61. overlay : false
  62. });
  63. }else{
  64. easyDialog.open({
  65. container : {
  66. header : '确认该答案为不满意',
  67. content : data.message,
  68. noFn : true
  69. },
  70. overlay : false
  71. });
  72. }
  73. },
  74. error:function(err){
  75. easyDialog.open({
  76. container : { content : '无法读取,请重新操作'},
  77. autoClose : 1500,
  78. overlay : false
  79. });
  80. }
  81. });
  82. });
  83. //满意
  84. $("#answer_satisfy").click(function() {
  85. easyDialog.open({
  86. container : {
  87. header : '确认该答案为满意',
  88. content : '点击‘确定’完成这次提问;答疑满意后还能进行追问!',
  89. yesFn : setsatisfy,
  90. noFn : true
  91. },
  92. overlay : false
  93. });
  94. });
  95. var setnosatisfy=function(){
  96. var form1 = $("#setnosatisfy");
  97. $("#refunds_description").attr("value",$("#refunds_content").val());
  98. form1.submit();
  99. }
  100. var setsatisfy=function(){
  101. var form1 = $("#setsatisfy");
  102. form1.submit();
  103. }
  104. /**
  105. * 补充问题
  106. */
  107. $("#additional_button").click(function() {
  108. if(typeof( nei) =="string"){
  109. nei = new UE.ui.Editor();
  110. nei.render('description_text');
  111. }
  112. $('#additional_content').toggle(1000);
  113. });
  114. $("#additional").click(function() {
  115. var qid=$("#qid").val();
  116. if(!nei.hasContents()){ //此处以非空为例
  117. alert("请输入内容");
  118. return false;
  119. }
  120. var content=nei.getContent();
  121. var html='<div class="pgBoxExtra"><p>'+content+'</p></div>';
  122. $("#description_pg").html(html);
  123. $('#description_pg').hide();
  124. var url="/ajax/vip_question/edit";
  125. $.ajax({
  126. url:url,
  127. type: "post",
  128. cache: false,
  129. dataType: "json",
  130. data: {
  131. qid:qid,
  132. description:content
  133. },
  134. global: true,
  135. success: function(data){
  136. $('#description_pg').toggle(1000);
  137. $("#additional_button").remove();
  138. $("#additional_content").remove();
  139. },
  140. error:function(err){
  141. // document.getElementById('i_commont').innerHTML = err.responseText;
  142. }
  143. });
  144. });
  145. $("#addtoaskvip").click(function() {
  146. if(!ask.hasContents()){ //此处以非空为例
  147. alert("请输入内容");
  148. return false;
  149. }else{
  150. answer=window.confirm("追问后,该提问自动设为‘满意’");
  151. if(answer==true)
  152. return true;
  153. else
  154. return false;
  155. }
  156. });
  157. $("#submit_comment").click(function() {
  158. var c_content=$('#comment_content').val();
  159. var username=$('#username').val();
  160. var qid=$("#qid").val();
  161. if(c_content==""){
  162. alert("请输入内容");
  163. return false;
  164. }
  165. var html='<blockquote><b>'+username+'</b>评价:'+c_content+'</blockquote>';
  166. $("#aj_comment").html(html);
  167. $('#aj_comment').hide();
  168. var url="/ajax/vip_question/comment";
  169. $.ajax({
  170. url:url,
  171. type: "post",
  172. cache: false,
  173. dataType: "json",
  174. data: {
  175. qid:qid,
  176. comment:c_content
  177. },
  178. global: true,
  179. success: function(data){
  180. $('#aj_comment').toggle(1000);
  181. $("#enter_comment").remove();
  182. },
  183. error:function(err){
  184. document.getElementById('aj_comment').innerHTML = err.responseText;
  185. }
  186. });
  187. });
  188. $("#add_discuss").click(function() {
  189. var discuss_content=$("#discuss_content").val();
  190. if(discuss_content==""){
  191. alert("请输入内容");
  192. return false;
  193. }
  194. });
  195. $("input[id^='add_discuss_chire']").click(function() {
  196. var id=parseInt($(this).attr('data'));
  197. var discuss_content=$("#discuss_content_"+id).val();
  198. if(discuss_content==""){
  199. alert("请输入内容");
  200. return false;
  201. }
  202. });
  203. //显示子评论
  204. $("a[id^='show_chir_discuss_']").click(function() {
  205. var id=parseInt($(this).attr('data'));
  206. $('#chircomm_'+id).toggle(1000);
  207. var cla=$('#open_'+id).attr("class");
  208. if(cla=="openUp"){
  209. $('#open_'+id).removeClass('openUp');
  210. $('#open_'+id).addClass('openDown');
  211. }else{
  212. $('#open_'+id).removeClass('openDown');
  213. $('#open_'+id).addClass('openUp');
  214. }
  215. });
  216. })