JkConfigSys.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. var data = {};
  2. $(function() {
  3. init();
  4. // 保存
  5. $('#save').click(function() {
  6. var str ='';
  7. str+="[";
  8. $.each(data, function(i, val) {
  9. if (val.switchtype == 1) {
  10. // 评论
  11. if ($.trim($('#type1 .checked').text()) == "开") {
  12. str+='{"id":'+val.id+',"switchstate":1}';
  13. } else {
  14. str+='{"id":'+val.id+',"switchstate":2}';
  15. }
  16. }
  17. if (val.switchtype == 2) {
  18. // 认证
  19. if ($.trim($('#type2 .checked').text()) == "开") {
  20. str+='{"id":'+val.id+',"switchstate":1}';
  21. } else {
  22. str+='{"id":'+val.id+',"switchstate":2}';
  23. }
  24. }
  25. if(i+1 !=2){
  26. str+=',';
  27. }
  28. });
  29. str+="]";
  30. update(str);
  31. });
  32. });
  33. function init() {
  34. var param = {};
  35. $.post("/JkEdu/ConfigSystem/getConfigSys", param, function(result) {
  36. console.log(result.Code);
  37. if (result.Code == 10000) {
  38. data = result.result;
  39. $.each(data, function(i, val) {
  40. console.log(val.switchtype);
  41. if (val.switchtype == 1) {
  42. $('#type1').radioGroup({
  43. operate : 'setKey',
  44. opreateDataKey : val.switchstate
  45. });
  46. } else if (val.switchtype == 2) {
  47. $('#type2').radioGroup({
  48. operate : 'setKey',
  49. opreateDataKey : val.switchstate
  50. });
  51. }
  52. });
  53. }
  54. });
  55. }
  56. function update(params) {
  57. console.log(params);
  58. param = {};
  59. param.params=params;
  60. $.post("/JkEdu/ConfigSystem/updateConfigSys", param, function(result) {
  61. console.log(result.Code);
  62. if (result.Code == 10000) {
  63. return true;
  64. } else {
  65. return false;
  66. }
  67. });
  68. }