wxpay.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'clipboard'], function ($, undefined, Backend, Table, Form, Clipboard) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'wxpay/index',
  8. add_url: 'wxpay/add',
  9. edit_url: 'wxpay/edit',
  10. // del_url: 'wxpay/del',
  11. multi_url: 'wxpay/multi',
  12. table: 'wxpay',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'id',
  21. columns: [
  22. [
  23. {checkbox: true},
  24. {field: 'id', title: __('Id')},
  25. {field: 'name', title: __('Name')},
  26. {field: 'platform_id', title: __('Platform_id'), operate:false,formatter:function(value,row,index){return value+"<br>"+row.platform.name;}},
  27. {field: 'pay_host', title: __('Pay_host'), operate:false},
  28. {field: 'status', title: __('Status'), visible:false, searchList: {"0":__('Status 0'),"1":__('Status 1')}},
  29. {field: 'isdefault', title: __('Isdefault'), visible:false, searchList: {"0":__('Isdefault 0'),"1":__('Isdefault 1')}},
  30. {field: 'is_closure', title: __('IsClosure'), visible:false, searchList:{"0":__('IsClosure 0'),"1":__('IsClosure 1')}},
  31. {field: 'isdefault_text', title: __('Isdefault'), operate:false},
  32. {field: 'status_text', title: __('Status'), operate:false},
  33. {field: 'is_closure_text', title: __('IsClosure'), operate:false},
  34. {
  35. field: 'payment_method',
  36. title: '支付方式',
  37. searchList: $.parseJSON(Config.paymentMethodList),
  38. formatter: function (value, row, index) {
  39. var list = $.parseJSON(Config.paymentMethodList);
  40. if (list[value] != undefined) {
  41. return list[value];
  42. }
  43. return '微信官方支付';
  44. }
  45. },
  46. {field: 'quartet_merchant_id', title: '四方支付商户ID'},
  47. {field: 'quartet_app_id', title: '四方支付APPID'},
  48. {
  49. field: 'quartet_app_key', title: '四方支付APPKEY', formatter: function (value, row, index) {
  50. if (value && value.length > 40) {
  51. return value.substr(0, 40) + '......';
  52. } else {
  53. return value;
  54. }
  55. }
  56. },
  57. {
  58. field: 'quartet_app_public_key', title: '四方支付公钥', formatter: function (value, row, index) {
  59. if (value && value.length > 40) {
  60. return value.substr(0, 40) + '......';
  61. } else {
  62. return value;
  63. }
  64. }
  65. },
  66. {field: 'appid', title: __('Appid'), searchList:$.parseJSON(Config.appidList)},
  67. {field: 'secret', title: __('Secret'), operate:false},
  68. {field: 'payfile', title: __('Payfile'), operate:false},
  69. {field: 'mcid', title: __('Mcid'), operate:false},
  70. {field: 'apikey', title: __('Apikey'), operate:false},
  71. {field: 'p_desc', title: __('描述'), operate:false},
  72. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime, operate:false},
  73. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime, operate:false},
  74. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  75. ]
  76. ]
  77. });
  78. // 为表格绑定事件
  79. Table.api.bindevent(table);
  80. },
  81. add: function () {
  82. Controller.api.isdefault();
  83. Controller.api.bindevent();
  84. switchPaymentMethod();
  85. $(document).delegate("input[name='row[payment_method]']", 'click', switchPaymentMethod);
  86. },
  87. edit: function () {
  88. if($("#c-isdefault").val()==1){
  89. $("#c-isdefault").addClass("disabled");
  90. }
  91. Controller.api.isdefault();
  92. Controller.api.bindevent();
  93. switchPaymentMethod();
  94. $(document).delegate("input[name='row[payment_method]']", 'click', switchPaymentMethod);
  95. },
  96. api: {
  97. bindevent: function () {
  98. $("form[role=form]").data("validator-options", {
  99. ignore: ':hidden'
  100. });
  101. Form.api.bindevent($("form[role=form]"));
  102. },
  103. isdefault:function (){
  104. $("#c-isdefault").change(function(){
  105. if($(this).val()==1){
  106. if(!confirm("确定修改为默认吗?")){
  107. $(this).val(0);
  108. }
  109. }
  110. });
  111. }
  112. }
  113. };
  114. function switchPaymentMethod() {
  115. var paymentMethod = $("input[name='row[payment_method]']:checked").val();
  116. $('.group-' + paymentMethod).removeClass('hide').siblings().addClass('hide');
  117. $('.group-' + paymentMethod).find('input').prop('disabled', false);
  118. $('.group-' + paymentMethod).siblings().find('input').prop('disabled', true);
  119. $("#c-quartet_app_key-" + paymentMethod).change(function () {
  120. $("#btn_copy_quartet_app_key-" + paymentMethod).attr('data-clipboard-text', $(this).val());
  121. });
  122. $("#c-quartet_app_public_key-" + paymentMethod).change(function () {
  123. $("#btn_copy_quartet_app_public_key-" + paymentMethod).attr('data-clipboard-text', $(this).val());
  124. });
  125. }
  126. return Controller;
  127. });