You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 regels
2.1 KiB

3 jaren geleden
  1. $(function(){
  2. var item_id = $("#item_id").val();
  3. $('#edit-cat').modal({
  4. "backdrop":'static'
  5. });
  6. getList();
  7. function getList(){
  8. $.get(
  9. "?s=/home/member/getList",
  10. { "item_id": item_id },
  11. function(data){
  12. $("#show-cat").html('');
  13. if (data.error_code == 0) {
  14. json = data.data;
  15. console.log(json);
  16. for (var i = 0; i < json.length; i++) {
  17. cat_html ='<a class="badge badge-important single-cat" data-username="'+json[i].username+'" >'+json[i].username+'&nbsp;x</a>';
  18. $("#show-cat").append(cat_html);
  19. };
  20. };
  21. },
  22. "json"
  23. );
  24. }
  25. //保存
  26. $("#save-cat").click(function(){
  27. var username = $("#username").val();
  28. var member_group_id = $("#member_group_id").is(':checked') ? 0 : 1 ;
  29. $.post(
  30. "?s=/home/member/save",
  31. {"username": username ,"item_id": item_id,"member_group_id": member_group_id },
  32. function(data){
  33. if (data.error_code == 0) {
  34. $("#username").val('');
  35. alert(lang["save_success"]);
  36. }else{
  37. alert(data.error_message);
  38. }
  39. getList();
  40. },
  41. "json"
  42. );
  43. return false;
  44. });
  45. //删除
  46. $('#show-cat').delegate('.single-cat','click', function(){
  47. var username = $(this).attr("data-username");
  48. if (!confirm(lang['confirm_to_delete_member'])) {
  49. return false;
  50. }
  51. if (username) {
  52. $.post(
  53. "?s=/home/member/delete",
  54. { "username": username, "item_id" :item_id },
  55. function(data){
  56. if (data.error_code == 0) {
  57. alert(lang["delete_success"]);
  58. getList();
  59. }else{
  60. alert(lang["delete_fail"]);
  61. }
  62. },
  63. "json"
  64. );
  65. }
  66. return false;
  67. });
  68. $(".exist-cat").click(function(){
  69. window.location.href="?s=/home/item/show&item_id="+item_id;
  70. });
  71. });