send.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. {extend name="default/base/base_member" /}
  2. {block name="member_main"}
  3. <div class="dsm-message-send">
  4. <div class="dsm-message-send-form">
  5. <div class="dsm-default-form">
  6. <form method="post" id="send_form" action="{:url('Membermessage/savemsg')}">
  7. <dl>
  8. <dt><i class="required">*</i>{$Think.lang.home_message_reveiver}{$Think.lang.ds_colon}</dt>
  9. <dd>
  10. <input type="text" class="text w500" name="to_member_name" value="{present name='member_name'}{$member_name}{/present}" {notempty name="member_name"}readonly{/notempty}/>
  11. <p class="hint">{$Think.lang.home_message_separate}</p>
  12. </dd>
  13. </dl>
  14. <dl>
  15. <dt>{$Think.lang.home_message_type}:</dt>
  16. <dd><span class="mr10">
  17. <input type="radio" class="radio vm" value="2" name="msg_type" checked="checked" />
  18. {$Think.lang.home_message_open}</span><span>
  19. <input type="radio" class="radio vm" name="msg_type" value="0" />
  20. {$Think.lang.home_message_close}</span></dd>
  21. </dl>
  22. <dl>
  23. <dt><i class="required">*</i>{$Think.lang.home_message_content}{$Think.lang.ds_colon}</dt>
  24. <dd>
  25. <textarea name="msg_content" rows="3" class="textarea w500 h100"></textarea>
  26. <p class ="error"></p>
  27. </dd>
  28. </dl>
  29. <div class="bottom">
  30. <input type="submit" class="submit" value="{$Think.lang.home_message_ensure_send}" />
  31. </div>
  32. </form>
  33. </div>
  34. </div>
  35. <div class="dsm-message-send-friend">
  36. <h3>{$Think.lang.home_message_friend}</h3>
  37. {notempty name="friend_list"}
  38. <ul>
  39. {foreach name="friend_list" item="val"}
  40. <li><a href="javascript:void(0);" id="{$val.friend_tomname}" ds_type="to_member_name">
  41. <div class="avatar"><img src="{:get_member_avatar($val.friend_tomavatar)}"></div>
  42. <p>{$val.friend_tomname}</p>
  43. </a></li>
  44. {/foreach}
  45. </ul>
  46. {else /}
  47. <div class="nomessage"><p>{$Think.lang.home_message_no_friends}</p>
  48. <a href="{:url('Membersnsfriend/index')}" class="dsm-btn-mini" target="_blank">{$Think.lang.home_add_buddy}</a>
  49. </div>
  50. {/notempty}
  51. </div>
  52. </div>
  53. <script type="text/javascript">
  54. $(function(){
  55. $('a[ds_type="to_member_name"]').click(function (){
  56. var str = $('input[name="to_member_name"]').val();
  57. var id = $(this).attr('id');
  58. if(str.indexOf(id+',') < 0){
  59. doFriend(id+',', 'add');
  60. }else{
  61. doFriend(id, 'delete');
  62. }
  63. });
  64. });
  65. $(function(){
  66. $('#send_form').validate({
  67. errorPlacement: function(error, element){
  68. $(element).next('p').html(error);
  69. },
  70. submitHandler:function(form){
  71. ds_ajaxpost('send_form', 'url', "{:url('Membermessage/privatemsg')}")
  72. },
  73. rules : {
  74. to_member_name : {
  75. required : true
  76. },
  77. msg_content : {
  78. required : false
  79. }
  80. },
  81. messages : {
  82. to_member_name : {
  83. required : '{$Think.lang.home_message_receiver_null}.'
  84. },
  85. msg_content : {
  86. required : '{$Think.lang.home_message_content_null}.'
  87. }
  88. }
  89. });
  90. });
  91. function doFriend(user_name, action){
  92. var input_name = $("input[name='to_member_name']").val();
  93. var key, i = 0;
  94. var exist = false;
  95. var arrOld = new Array();
  96. var arrNew = new Array();
  97. input_name = input_name.replace(/\uff0c/g,',');
  98. arrOld = input_name.split(',');
  99. for(key in arrOld){
  100. arrOld[key] = $.trim(arrOld[key]);
  101. if(arrOld[key].length > 0){
  102. arrOld[key] == user_name && action == 'delete' ? null : arrNew[i++] = arrOld[key]; //剔除好友
  103. arrOld[key] == user_name ? exist = true : null; //判断好友是否已选
  104. }
  105. }
  106. if(action == 'delete' && arrNew !=''){
  107. arrNew = arrNew+',';
  108. }
  109. if(!exist && action == 'add'){
  110. arrNew[i] = user_name;
  111. }
  112. $("input[name='to_member_name']").val(arrNew);
  113. }
  114. </script>
  115. {/block}