jkSignature.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. $(function() {
  2. $('.phone-main').height($('.phone-wrap').height() - $('.phone-header').height());
  3. //预览
  4. $('#preview').click(function(){
  5. if($.trim($('#state .checked').text())=="开启"){
  6. if($.trim($('#position .checked').text()) == '顶部与尾部均添加'){
  7. $('.position-t').show();
  8. $('.position-b').show();
  9. }else{
  10. if($.trim($('#position .checked').text()) == '文章顶部'){
  11. $('.position-t').show().siblings().hide();
  12. }else{
  13. $('.position-b').show().siblings().hide();
  14. }
  15. }
  16. }else{
  17. $('.position-t').hide();
  18. $('.position-b').hide();
  19. }
  20. });
  21. //保存
  22. $('#save').click(function(){
  23. var position=1;
  24. var state=1;
  25. if($.trim($('#state .checked').text())=="开启"){
  26. state=1;
  27. if($.trim($('#position .checked').text()) == '顶部与尾部均添加'){
  28. position=3;
  29. }else{
  30. if($.trim($('#position .checked').text()) == '文章顶部'){
  31. position=1;
  32. }else{
  33. position=2;
  34. }
  35. }
  36. }else{
  37. state=2;
  38. }
  39. update(position,state);
  40. });
  41. init();
  42. //删除当前图片
  43. $('.icon-close').click(function(){
  44. $(this).parent('.upload-img').remove();
  45. });
  46. });
  47. function init(){
  48. var param = {};
  49. $.post("/JkEdu/Signature/getSignature", param, function(result) {
  50. console.log(result.Code);
  51. if(result.Code==10000){
  52. if(result.result[0].state==1){
  53. if(result.result[0].position==1){
  54. $('.position-t').show().siblings().hide();
  55. }else if(result.result[0].position==2){
  56. $('.position-b').show().siblings().hide();
  57. }else{
  58. $('.position-t').show();
  59. $('.position-b').show();
  60. }
  61. }else{
  62. $('.position-t').hide();
  63. $('.position-b').hide();
  64. }
  65. $('#state').radioGroup({operate:'setKey',opreateDataKey:result.result[0].state});
  66. $('#position').radioGroup({operate:'setKey',opreateDataKey:result.result[0].position});
  67. // if(result.result[0].state=2){
  68. // $("label[name='state']:contains('开启')").addClass('checked');
  69. // $("label[name='state']:contains('开启')").find(':radio').prop("checked", "checked");
  70. // }else{
  71. // $("label[name='state']:contains('关闭')").addClass('checked');
  72. // $("label[name='state']:contains('关闭')").find(':radio').prop("checked", "checked");
  73. // }
  74. }
  75. });
  76. }
  77. function update(position,state){
  78. var param = {};
  79. param.position=position;
  80. param.state=state;
  81. $.post("/JkEdu/Signature/updateSignature", param, function(result) {
  82. console.log(result.Code);
  83. if(result.Code==10000){
  84. return true;
  85. }else{
  86. return false;
  87. }
  88. });
  89. }