国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

263 рядки
10KB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
  6. <title>支付接口设置</title>
  7. <link rel="stylesheet" href="/static/web/css/font-awesome.min.css">
  8. <link rel="stylesheet" href="/static/web/css/bootstrap.min.css">
  9. <link rel="stylesheet" href="/static/web/css/admin.css">
  10. <script src="/static/web/js/jquery.min.js"></script>
  11. <script src="/static/web/js/bootstrap.min.js"></script>
  12. <script src="/static/web/js/admin.main.js"></script>
  13. </head>
  14. <body>
  15. <div class="container-fluid">
  16. <ol class="breadcrumb">
  17. <li class="breadcrumb-item"><a href="index_body.php">后台面板</a></li>
  18. <li class="breadcrumb-item active">支付接口设置</li>
  19. </ol>
  20. <div class="card shadow-sm mb-3">
  21. <div class="card-header">支付接口设置</div>
  22. <div class="card-body">
  23. <ul class="nav nav-tabs" id="myTab" role="tablist">
  24. <li class="nav-item" role="presentation"><button type="button" id="wechat-tab" class="nav-link active" data-toggle="tab" data-target="#wechat" role="tab" aria-controls="wechat" aria-selected="true">微信支付</button></li>
  25. <li class="nav-item" role="presentation"><button type="button" id="alipay-tab" class="nav-link" data-toggle="tab" data-target="#alipay" role="tab" aria-controls="alipay" aria-selected="false">支付宝</button></li>
  26. <li class="nav-item" role="presentation"><button type="button" id="bank-tab" class="nav-link" data-toggle="tab" data-target="#bank" role="tab" aria-controls="bank" aria-selected="false">银行转帐</button></li>
  27. <li class="nav-item" role="presentation"><button type="button" id="balance-tab" class="nav-link" data-toggle="tab" data-target="#balance" role="tab" aria-controls="balance" aria-selected="false">积分支付</button></li>
  28. <li class="nav-item" role="presentation"><button type="button" id="cod-tab" class="nav-link" data-toggle="tab" data-target="#cod" role="tab" aria-controls="cod" aria-selected="false">货到付款</button></li>
  29. </ul>
  30. <div class="tab-content pt-3" id="myTabContent">
  31. <div class="tab-pane fade show active" id="wechat" role="tabpanel" aria-labelledby="wechat-tab">
  32. <form>
  33. <div class="form-group form-check">
  34. <input type="checkbox" id="iptWechatEnabled" class="form-check-input">
  35. <label class="form-check-label ml-2" for="iptWechatEnabled">是否启用</label>
  36. </div>
  37. <div class="form-group">
  38. <label for="iptWechatAppID">AppID</label>
  39. <input type="text" id="iptWechatAppID" class="form-control">
  40. </div>
  41. <div class="form-group">
  42. <label for="iptWechatAPIv2Secret">APIv2Secret</label>
  43. <input type="text" id="iptWechatAPIv2Secret" class="form-control">
  44. </div>
  45. <div class="form-group">
  46. <label for="iptWechatMchID">商户号</label>
  47. <input type="text" id="iptWechatMchID" class="form-control">
  48. </div>
  49. <div class="form-group">
  50. <label for="iptWechatSortrank">排序(越小越靠前)</label>
  51. <input type="text" id="iptWechatSortrank" class="form-control" value="0">
  52. </div>
  53. </form>
  54. </div>
  55. <div class="tab-pane fade" id="alipay" role="tabpanel" aria-labelledby="alipay-tab">
  56. <form>
  57. <div class="form-group form-check">
  58. <input type="checkbox" id="iptAlipayEnabled" class="form-check-input">
  59. <label class="form-check-label ml-2" for="iptAlipayEnabled">是否启用</label>
  60. </div>
  61. <div class="form-group">
  62. <label for="iptAlipayAPPID">APPID</label>
  63. <input type="text" id="iptAlipayAPPID" class="form-control">
  64. </div>
  65. <div class="form-group">
  66. <label for="iptAlipayPrivateKey">应用私钥</label>
  67. <input type="text" id="iptAlipayPrivateKey" class="form-control">
  68. </div>
  69. <div class="form-group">
  70. <label for="iptAlipayCertPublicKey">支付宝公钥证书</label>
  71. <input type="text" id="iptAlipayCertPublicKey" class="form-control">
  72. </div>
  73. <div class="form-group">
  74. <label for="iptAlipaySignType">签名类型</label>
  75. <input type="text" id="iptAlipaySignType" class="form-control" value="RSA2" disabled>
  76. </div>
  77. <div class="form-group">
  78. <label for="iptAlipaySortrank">排序(越小越靠前)</label>
  79. <input type="text" id="iptAlipaySortrank" class="form-control" value="0">
  80. </div>
  81. </form>
  82. </div>
  83. <div class="tab-pane fade" id="bank" role="tabpanel" aria-labelledby="bank-tab">
  84. <form>
  85. <div class="form-group form-check">
  86. <input type="checkbox" id="iptBankEnabled" class="form-check-input">
  87. <label class="form-check-label ml-2" for="iptBankEnabled">是否启用</label>
  88. <span>(会员支付到指定银行卡,手动确认订单收款)</span>
  89. </div>
  90. <div class="form-group">
  91. <label for="iptBankAccountName">账户名</label>
  92. <input type="text" id="iptBankAccountName" class="form-control">
  93. </div>
  94. <div class="form-group">
  95. <label for="iptBankAccountNO">账号</label>
  96. <input type="text" id="iptBankAccountNO" class="form-control">
  97. </div>
  98. <div class="form-group">
  99. <label for="iptBankName">开户行</label>
  100. <input type="text" id="iptBankName" class="form-control">
  101. </div>
  102. <div class="form-group">
  103. <label for="iptBankSortrank">排序(越小越靠前)</label>
  104. <input type="text" id="iptBankSortrank" class="form-control" value="0">
  105. </div>
  106. </form>
  107. </div>
  108. <div class="tab-pane fade" id="balance" role="tabpanel" aria-labelledby="balance-tab">
  109. <form>
  110. <div class="form-group form-check">
  111. <input type="checkbox" id="iptBalanceEnabled" class="form-check-input">
  112. <label class="form-check-label ml-2" for="iptBalanceEnabled">是否启用</label>
  113. <span>(采用积分进行支付)</span>
  114. </div>
  115. <div class="form-group">
  116. <label for="iptBalanceSortrank">排序(越小越靠前)</label>
  117. <input type="text" id="iptBalanceSortrank" class="form-control" value="0">
  118. </div>
  119. </form>
  120. </div>
  121. <div class="tab-pane fade" id="cod" role="tabpanel" aria-labelledby="cod-tab">
  122. <form>
  123. <div class="form-group form-check">
  124. <input type="checkbox" id="iptCodEnabled" class="form-check-input">
  125. <label class="form-check-label ml-2" for="iptCodEnabled">是否启用</label>
  126. <span>(购买直接发货,到货后支付)</span>
  127. </div>
  128. <div class="form-group">
  129. <label for="iptCodSortrank">排序(越小越靠前)</label>
  130. <input type="text" id="iptCodSortrank" class="form-control" value="0">
  131. </div>
  132. </form>
  133. </div>
  134. <div class="text-center"><button type="submit" id="btnSave" class="btn btn-success btn-sm">保存</button></div>
  135. </div>
  136. </div>
  137. </div>
  138. </div>
  139. <script>
  140. $('.custom-file-input').on('change', function() {
  141. let fileName = $(this).val().split('\\').pop();
  142. $(this).siblings('.custom-file-label').addClass("selected").html(fileName);
  143. });
  144. let config = {
  145. Wechat: {
  146. AppID: '',
  147. APIv2Secret: '',
  148. MchID: '',
  149. Sortrank: 0,
  150. Enabled: true,
  151. },
  152. Alipay: {
  153. APPID: '',
  154. PrivateKey: '',
  155. CertPublicKey: '',
  156. SignType: 'RSA2',
  157. Sortrank: 0,
  158. Enabled: false,
  159. },
  160. Bank: {
  161. AccountName: '',
  162. AccountNO: '',
  163. Name: '',
  164. Sortrank: 0,
  165. Enabled: true,
  166. },
  167. Balance: {
  168. Sortrank: 0,
  169. Enabled: false,
  170. },
  171. Cod: {
  172. Sortrank: 0,
  173. Enabled: true,
  174. }
  175. }
  176. //加载系统config
  177. function getPayments() {
  178. $.get("sys_payment.php?dopost=get_payments", function(data) {
  179. if (data.code === 0) {
  180. for (const key in data.data) {
  181. if (Object.hasOwnProperty.call(data.data, key)) {
  182. const element = data.data[key];
  183. let itemConfig = {};
  184. try {
  185. itemConfig = JSON.parse(element.config);
  186. } catch (error) {
  187. itemConfig = config[key]
  188. }
  189. itemConfig.Sortrank = element.sortrank;
  190. itemConfig.Enabled = parseInt(element.status) === 0? false : true;
  191. for (const k1 in config[key]) {
  192. if (Object.hasOwnProperty.call(config[key], k1)) {
  193. const ee = config[key][k1];
  194. if (typeof itemConfig[k1] === "undefined") {
  195. itemConfig[k1] = ee;
  196. }
  197. }
  198. }
  199. for (const k2 in itemConfig) {
  200. if (Object.hasOwnProperty.call(itemConfig, k2)) {
  201. const element = itemConfig[k2];
  202. if ($(`#ipt${key}${k2}`).attr('type') === 'text') {
  203. $(`#ipt${key}${k2}`).val(element);
  204. } else if ($(`#ipt${key}${k2}`).attr('type') === 'checkbox') {
  205. $(`#ipt${key}${k2}`).prop('checked', element);
  206. }
  207. }
  208. }
  209. config[key] = itemConfig;
  210. }
  211. }
  212. }
  213. });
  214. }
  215. //更新config
  216. function updateConfig() {
  217. for (const key in config) {
  218. if (Object.hasOwnProperty.call(config, key)) {
  219. const element = config[key];
  220. for (const kk in element) {
  221. if (Object.hasOwnProperty.call(element, kk)) {
  222. const itemConfig = element[kk];
  223. if ($(`#ipt${key}${kk}`).attr('type') === 'text') {
  224. let val = $(`#ipt${key}${kk}`).val();
  225. if (kk === "Sortrank") {
  226. val = parseInt(val);
  227. }
  228. config[key][kk] = val;
  229. } else if ($(`#ipt${key}${kk}`).attr('type') === 'checkbox') {
  230. config[key][kk] = $(`#ipt${key}${kk}`).prop('checked');
  231. }
  232. }
  233. }
  234. }
  235. }
  236. }
  237. //保存配置信息
  238. function saveConfig() {
  239. $.ajax({
  240. type: "post",
  241. url: 'sys_payment.php?dopost=save_config',
  242. data: JSON.stringify(config),
  243. contentType: "application/json; charset=utf-8",
  244. dataType: "json",
  245. success: function(data) {
  246. if (data.code === 0) {
  247. ShowMsg("保存支付配置成功");
  248. } else {
  249. ShowMsg("保存失败");
  250. }
  251. }
  252. })
  253. }
  254. $(document).ready(function() {
  255. getPayments();
  256. $("#btnSave").click(() => {
  257. updateConfig()
  258. saveConfig();
  259. });
  260. });
  261. </script>
  262. </body>
  263. </html>