sns_store.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. $(function(){
  2. //展示和隐藏评论列表
  3. $(document).on('click',"[ds_type='sd_commentbtn']", function() {
  4. var $this = $(this);
  5. $.get(HOMESITEURL + '/Index/login.html', function(result) {
  6. if (result == '0') {
  7. login_dialog();
  8. } else {
  9. var data = $this.attr('data-param');
  10. eval("data = " + data);
  11. //隐藏转发模块
  12. $('#forward_' + data.txtid).hide();
  13. if ($('#tracereply_' + data.txtid).css("display") == 'none') {
  14. //加载评论列表
  15. $("#tracereply_" + data.txtid).load(HOMESITEURL + '/Storesnshome/commenttop.html?id=' + data.txtid);
  16. $('#tracereply_' + data.txtid).show();
  17. } else {
  18. $('#tracereply_' + data.txtid).hide();
  19. }
  20. return false;
  21. }
  22. });
  23. });
  24. //评论提交
  25. $(document).on('click',"[ds_type='scommentbtn']", function() {
  26. var data = $(this).attr('data-param');
  27. eval("data = " + data);
  28. if ($("#commentform_" + data.txtid).valid()) {
  29. var cookienum = $.cookie('commentnum');
  30. cookienum = parseInt(cookienum);
  31. if (cookienum >= MAX_RECORDNUM && $("#commentseccode" + data.txtid).css('display') == "none") {
  32. //显示验证码
  33. $("#commentseccode" + data.txtid).show();
  34. $("#commentseccode" + data.txtid).find("[name='codeimage']").attr('src', HOMESITEURL + '/Seccode/makecode.html?t=' + Math.random());
  35. } else if (cookienum >= MAX_RECORDNUM && $("#commentseccode" + data.txtid).find("[name='captcha']").val() == '') {
  36. layer.msg('请填写验证码');
  37. } else {
  38. var _form = $("#commentform_" + data.txtid);
  39. $.ajax({
  40. type: "POST",
  41. url: _form.attr('action'),
  42. data: _form.serialize(),
  43. dataType: "json",
  44. success: function (res) {
  45. layer.msg(res.message, {time: 1000}, function () {
  46. if (res.code == 10000) {
  47. $('#content_comment' + res.result).html('');
  48. $('#tracereply_' + res.result).load(HOMESITEURL + '/Storesnshome/commentlist?id=' + res.result);
  49. }
  50. });
  51. }
  52. });
  53. //隐藏验证码
  54. $("#commentseccode" + data.txtid).hide();
  55. $("#commentseccode" + data.txtid).find("[name='codeimage']").attr('src', '');
  56. $("#commentseccode" + data.txtid).find("[name='captcha']").val('');
  57. }
  58. }
  59. return false;
  60. });
  61. //删除评论
  62. $(document).on('click',"[ds_type='scomment_del']", function() {
  63. var obj = $(this);
  64. var data_str = $(obj).attr('data-param');
  65. eval("data_str = " + data_str);
  66. ds_ajaxget_confirm(HOMESITEURL + '/Storesnshome/delcomment.html?scid=' + data_str.scid + '&stid=' + data_str.stid,'您确定要删除该信息吗?');
  67. });
  68. //展示和隐藏转发表单
  69. $(document).on('click',"[ds_type='sd_forwardbtn']", function() {
  70. var $this = $(this);
  71. $.get(HOMESITEURL + '/Index/login.html', function(result) {
  72. if (result == '0') {
  73. login_dialog();
  74. } else {
  75. var data = $this.attr('data-param');
  76. eval("data = " + data);
  77. //隐藏评论模块
  78. $('#tracereply_' + data.txtid).hide();
  79. if ($('#forward_' + data.txtid).css("display") == 'none') {
  80. $('#forward_' + data.txtid).show();
  81. //添加字数提示
  82. if ($("#forwardcharcount" + data.txtid).html() == '') {
  83. $("#content_forward" + data.txtid).charCount({
  84. allowed: 140,
  85. warning: 10,
  86. counterContainerID: 'forwardcharcount' + data.txtid,
  87. firstCounterText: '还可以输入',
  88. endCounterText: '字',
  89. errorCounterText: '已经超出'
  90. });
  91. }
  92. //绑定表单验证
  93. $('#forwardform_' + data.txtid).validate({
  94. errorPlacement: function(error, element) {
  95. element.next('.error').append(error);
  96. },
  97. rules: {
  98. forwardcontent: {
  99. maxlength: 140
  100. }
  101. },
  102. messages: {
  103. forwardcontent: {
  104. maxlength: '不能超过140字'
  105. }
  106. }
  107. });
  108. } else {
  109. $('#forward_' + data.txtid).hide();
  110. }
  111. return false;
  112. }
  113. });
  114. });
  115. //转发提交
  116. $(document).on('click',"[ds_type='s_forwardbtn']", function() {
  117. var data = $(this).attr('data-param');
  118. var form = $(this).parents('form:first');
  119. var seccode = $("#forwardseccode" + data.txtid);
  120. eval("data = " + data);
  121. if (form.valid()) {
  122. var cookienum = $.cookie('forwardnum');
  123. cookienum = parseInt(cookienum);
  124. if (!isNaN(cookienum) && cookienum >= MAX_RECORDNUM) {
  125. if (seccode.css('display') == 'none') {
  126. //显示验证码
  127. seccode.show();
  128. seccode.find("[name='codeimage']").attr('src', HOMESITEURL + '/Seccode/makecode.html?t=' + Math.random());
  129. } else if (seccode.find("[name='captcha']").val() == '') {
  130. layer.msg('请填写验证码');
  131. }
  132. } else {
  133. ds_ajaxpost('forwardform_' + data.txtid);
  134. //隐藏验证码
  135. seccode.hide().find("[name='codeimage']").attr('src', '').end().find("[name='captcha']").val('');
  136. //隐藏表单
  137. $('#forward_' + data.txtid).hide();
  138. $('#content_forward' + data.txtid).val('');
  139. }
  140. }
  141. return false;
  142. });
  143. //删除动态
  144. $(document).on('click',"[ds_type='sd_del']", function() {
  145. var data_str = $(this).attr('data-param');
  146. eval("data_str = " + data_str);
  147. var url = HOMESITEURL + "/Storesnshome/deltrace.html?id=" + data_str.txtid;
  148. ds_ajaxget_confirm(url,'您确定要删除该信息吗?','remove',data_str)
  149. });
  150. // 查看大图
  151. $('[ds_type="thumb-image"]').on('click', function() {
  152. src = $(this).find('img').attr('src');
  153. max_src = src.replace('_240.', '_1280.');
  154. $(this).parent().hide().next().children('[ds_type="origin-image"]').append('<img src="' + max_src + '" />').end().show();
  155. });
  156. $('[ds_type="origin-image"]').on('click', function() {
  157. $(this).html('').parent().hide().prev().show();
  158. });
  159. });