config.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. $(document).on('click','.btn-re',function () {
  3. layer.alert('如需要进行重置服务号,请联系商务人员/开户人进行重置服务号,谢谢');
  4. });
  5. $(document).on('click','.updateAuthBtn',function(){
  6. layer.open({
  7. type: 2,
  8. title: $(this).html(),
  9. maxmin: false,
  10. area: ['60%', '60%'],
  11. shadeClose: true, //点击遮罩关闭层
  12. content: $(this).attr('href')
  13. });
  14. return false;
  15. });
  16. $(document).on('click','.getSourceIdBtn',function(){
  17. var url = $(this).attr('href');
  18. $.ajax({
  19. type: 'get',
  20. url: url,
  21. cache: false,
  22. async: false,
  23. success:function(data){
  24. if(!data.code){
  25. Toastr.error(data.msg);
  26. }else{
  27. $('.getSourceIdBtnShow').addClass('hide');
  28. $('.getSourceIdInput').val(data.data);
  29. Toastr.success('操作成功');
  30. }
  31. },
  32. error:function(err){
  33. Toastr.error('操作失败');
  34. }
  35. });
  36. return false;
  37. })
  38. var Controller = {
  39. index: function () {
  40. $(document).on('click','.layer-open',function () {
  41. Fast.api.open($(this).attr('href'), $(this).data('title')?$(this).data('title'):'配置回传信息', {});
  42. return false;
  43. });
  44. // 给上传按钮添加上传成功事件
  45. $("#plupload-qrcode_image").data("upload-success", function (data) {
  46. var url = Backend.api.cdnurl(data.url);
  47. $(".profile-user-img").prop("src", url);
  48. Toastr.success("上传成功!");
  49. });
  50. // 给表单绑定事件
  51. Controller.api.bindevent();
  52. },
  53. updateauth:function(){
  54. $('.close-auth-btn').click(function(){
  55. console.log('ddddd');
  56. var index = parent.layer.getFrameIndex(window.name);
  57. parent.layer.close(index);
  58. parent.location.reload();
  59. });
  60. },
  61. add: function () {
  62. Controller.api.bindevent();
  63. },
  64. edit: function () {
  65. Controller.api.bindevent();
  66. },
  67. push: function () {
  68. $(document).on("click", ".btn-change", function (e) {
  69. e.preventDefault();
  70. $this = $(this);
  71. var field = $this.data('field');
  72. var value = $this.data('value');
  73. Fast.api.ajax({
  74. url: 'admin.config/multi',
  75. data: {
  76. action: '',
  77. ids: $this.data('id'),
  78. params: field + '=' + value
  79. }
  80. }, function (data) {
  81. $this.toggleClass('fa-toggle-on fa-toggle-off');
  82. $this.data('value', value == 0 ? 1 : 0);
  83. }, function (data) {
  84. });
  85. });
  86. $(document).on("click", ".btn-change-extend", function (e) {
  87. e.preventDefault();
  88. $this = $(this);
  89. var field = $this.data('field');
  90. var value = $this.data('value');
  91. Fast.api.ajax({
  92. url: 'admin.config/editextend',
  93. data: {
  94. action: '',
  95. ids: $this.data('id'),
  96. params: field + '=' + value
  97. }
  98. }, function (data) {
  99. $this.toggleClass('fa-toggle-on fa-toggle-off');
  100. $this.data('value', value == 0 ? 1 : 0);
  101. }, function (data) {
  102. });
  103. });
  104. },
  105. api: {
  106. bindevent: function () {
  107. Form.api.bindevent($("form[role=form]"));
  108. $(document).on('click','.resource_type',function () {
  109. var sex = $(this).val();
  110. if(sex ==1){
  111. $('.girl').css('display','none');
  112. $('.boy').removeAttr('style');
  113. }
  114. if(sex == 2){
  115. $('.boy').css('display','none');
  116. $('.girl').removeAttr('style');
  117. }
  118. if(sex == 0){
  119. $('.boy').removeAttr('style');
  120. $('.girl').removeAttr('style');
  121. }
  122. })
  123. }
  124. }
  125. };
  126. return Controller;
  127. });