国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

315 lines
13KB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  6. <title>支付接口设置</title>
  7. <link rel="stylesheet" href="../static/web/font/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. </head>
  13. <body>
  14. <table cellpadding="3" cellspacing="1" align="center" class="table maintable my-3">
  15. <tr>
  16. <td bgcolor="#f5f5f5" colspan="4">
  17. <table cellspacing="0" cellpadding="0" class="table table-borderless w-100">
  18. <tr>
  19. <td>支付接口设置</td>
  20. <td align="right"><span><a href="https://www.dedebiz.com/help" target="_blank" class="btn btn-success btn-sm">更多接口</a></span></td>
  21. </tr>
  22. </table>
  23. </td>
  24. </tr>
  25. <tr>
  26. <td colspan="4">
  27. <ul class="nav nav-tabs" id="myTab" role="tablist">
  28. <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>
  29. <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>
  30. <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>
  31. <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>
  32. <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>
  33. </ul>
  34. <div class="tab-content py-3" id="myTabContent">
  35. <div class="tab-pane fade show active" id="wechat" role="tabpanel" aria-labelledby="wechat-tab">
  36. <form>
  37. <div class="form-group">
  38. <span>微信支付是腾讯公司的支付业务品牌,微信支付商户平台支持线下场所、公众号、小程序、PC网站、APP、企业微信等经营场景快速接入微信支付。微信支付全面打通O2O生活消费领域,提供专业的互联网+行业解决方案,微信支付支持微信红包和微信理财通,是移动支付的首选。</span>
  39. </div>
  40. <div class="form-group">
  41. <label for="iptWechatAppID">AppID</label>
  42. <input type="text" id="iptWechatAppID" class="form-control">
  43. </div>
  44. <div class="form-group">
  45. <label for="iptWechatAppSecret">AppSecret</label>
  46. <input type="text" id="iptWechatAppSecret" class="form-control">
  47. </div>
  48. <div class="form-group">
  49. <label for="iptWechatMchID">商户号</label>
  50. <input type="text" id="iptWechatMchID" class="form-control">
  51. </div>
  52. <div class="form-group">
  53. <label for="iptWechatAPIV3Key">APIv3秘钥</label>
  54. <input type="text" id="iptWechatAPIV3Key" class="form-control">
  55. </div>
  56. <div class="form-group">
  57. <label for="iptWechatSerialNo">商户证书序列号</label>
  58. <input type="text" id="iptWechatSerialNo" class="form-control">
  59. </div>
  60. <div class="form-group">
  61. <label>商户证书文件</label>
  62. <div class="custom-file">
  63. <input type="file" id="iptWechatPrivateKey" class="custom-file-input">
  64. <label class="custom-file-label" for="iptWechatPrivateKey" data-browse="选择">选择商户证书文件</label>
  65. </div>
  66. </div>
  67. <div class="form-group">
  68. <label for="iptWechatSortrank">排序(越小越靠前)</label>
  69. <input type="text" id="iptWechatSortrank" class="form-control" value="0">
  70. </div>
  71. <div class="form-group form-check">
  72. <input type="checkbox" id="iptWechatEnabled" class="form-check-input">
  73. <label class="form-check-label" for="iptWechatEnabled"> 是否启用</label>
  74. </div>
  75. </form>
  76. </div>
  77. <div class="tab-pane fade" id="alipay" role="tabpanel" aria-labelledby="alipay-tab">
  78. <form>
  79. <div class="form-group">
  80. <span>支付宝,全球领先的独立第三方支付平台,致力于为广大用户提供安全快速的电子支付/网上支付/安全支付/手机支付体验,及转账收款/水电煤缴费/信用卡还款/AA收款等生活服务应用。</span>
  81. </div>
  82. <div class="form-group">
  83. <label for="iptAlipayAPPID">APPID</label>
  84. <input type="text" id="iptAlipayAPPID" class="form-control">
  85. </div>
  86. <div class="form-group">
  87. <label for="iptAlipayPrivateKey">应用私钥</label>
  88. <input type="text" id="iptAlipayPrivateKey" class="form-control">
  89. </div>
  90. <div class="form-group">
  91. <label>应用公钥证书</label>
  92. <div class="custom-file">
  93. <input type="file" id="iptAlipayAppCertPublicKey" class="custom-file-input">
  94. <label class="custom-file-label" for="iptAlipayAppCertPublicKey" data-browse="选择">选择应用公钥证书文件</label>
  95. </div>
  96. </div>
  97. <div class="form-group">
  98. <label>支付宝公钥证书</label>
  99. <div class="custom-file">
  100. <input type="file" id="iptAlipayCertPublicKey" class="custom-file-input">
  101. <label class="custom-file-label" for="iptAlipayCertPublicKey" data-browse="选择">选择支付宝公钥证书文件</label>
  102. </div>
  103. </div>
  104. <div class="form-group">
  105. <label>支付宝根证书</label>
  106. <div class="custom-file">
  107. <input type="file" class="custom-file-input" id="iptAlipayRootCert">
  108. <label class="custom-file-label" for="iptAlipayRootCert" data-browse="选择">选择支付宝根证书文件</label>
  109. </div>
  110. </div>
  111. <div class="form-group">
  112. <label for="iptAlipaySignType">签名类型</label>
  113. <input type="text" id="iptAlipaySignType" class="form-control" value="RSA2" disabled>
  114. </div>
  115. <div class="form-group">
  116. <label for="iptAlipaySortrank">排序(越小越靠前)</label>
  117. <input type="text" id="iptAlipaySortrank" class="form-control" value="0">
  118. </div>
  119. <div class="form-group form-check">
  120. <input type="checkbox" id="iptAlipayEnabled" class="form-check-input">
  121. <label class="form-check-label" for="iptAlipayEnabled"> 是否启用</label>
  122. </div>
  123. </form>
  124. </div>
  125. <div class="tab-pane fade" id="bank" role="tabpanel" aria-labelledby="bank-tab">
  126. <form>
  127. <div class="form-group">
  128. <span>用户支付到商户指定银行卡账号,手动确认订单收款。</span>
  129. </div>
  130. <div class="form-group">
  131. <label for="iptBankAccountName">账户名</label>
  132. <input type="text" id="iptBankAccountName" class="form-control">
  133. </div>
  134. <div class="form-group">
  135. <label for="iptBankAccountNO">账号</label>
  136. <input type="text" id="iptBankAccountNO" class="form-control">
  137. </div>
  138. <div class="form-group">
  139. <label for="iptBankName">开户行</label>
  140. <input type="text" id="iptBankName" class="form-control">
  141. </div>
  142. <div class="form-group">
  143. <label for="iptBankSortrank">排序(越小越靠前)</label>
  144. <input type="text" id="iptBankSortrank" class="form-control" value="0">
  145. </div>
  146. <div class="form-group form-check">
  147. <input type="checkbox" id="iptBankEnabled" class="form-check-input">
  148. <label class="form-check-label" for="iptBankEnabled"> 是否启用</label>
  149. </div>
  150. </form>
  151. </div>
  152. <div class="tab-pane fade" id="balance" role="tabpanel" aria-labelledby="balance-tab">
  153. <form>
  154. <div class="form-group">
  155. <span>支持采用积分进行支付。</span>
  156. </div>
  157. <div class="form-group">
  158. <label for="iptBalanceSortrank">排序(越小越靠前)</label>
  159. <input type="text" id="iptBalanceSortrank" class="form-control" value="0">
  160. </div>
  161. <div class="form-group form-check">
  162. <input type="checkbox" id="iptBalanceEnabled" class="form-check-input">
  163. <label class="form-check-label" for="iptBalanceEnabled">是否启用</label>
  164. </div>
  165. </form>
  166. </div>
  167. <div class="tab-pane fade" id="cod" role="tabpanel" aria-labelledby="cod-tab">
  168. <form>
  169. <div class="form-group">
  170. <span>购买后直接发货,到货后再进行支付。</span>
  171. </div>
  172. <div class="form-group">
  173. <label for="iptCodSortrank">排序(越小越靠前)</label>
  174. <input type="text" id="iptCodSortrank" class="form-control" value="0">
  175. </div>
  176. <div class="form-group form-check">
  177. <input type="checkbox" id="iptCodEnabled" class="form-check-input">
  178. <label class="form-check-label" for="iptCodEnabled"> 是否启用</label>
  179. </div>
  180. </form>
  181. </div>
  182. <div class="text-center"><button type="submit" id="btnSave" class="btn btn-success">保存</button></div>
  183. </div>
  184. </td>
  185. </tr>
  186. </table>
  187. <script>
  188. $('.custom-file-input').on('change', function () {
  189. let fileName = $(this).val().split('\\').pop();
  190. $(this).siblings('.custom-file-label').addClass("selected").html(fileName);
  191. });
  192. let config = {
  193. Wechat: {
  194. AppID: '',
  195. AppSecret: '',
  196. MchID: '',
  197. APIV3Key: '',
  198. SerialNo: '',
  199. PrivateKey: '',
  200. Sortrank: 0,
  201. Enabled: true,
  202. },
  203. Alipay: {
  204. APPID: '',
  205. PrivateKey: '',
  206. AppCertPublicKey: '',
  207. CertPublicKey: '',
  208. RootCert: '',
  209. SignType: 'RSA2',
  210. Sortrank: 0,
  211. Enabled: false,
  212. },
  213. Bank: {
  214. AccountName: '',
  215. AccountNO: '',
  216. Name: '',
  217. Sortrank: 0,
  218. Enabled: true,
  219. },
  220. Balance: {
  221. Sortrank: 0,
  222. Enabled: false,
  223. },
  224. Cod: {
  225. Sortrank: 0,
  226. Enabled: true,
  227. }
  228. }
  229. //加载系统config
  230. function getPayments() {
  231. $.get("sys_payment.php?dopost=get_payments", function (data) {
  232. if (data.code === 0) {
  233. for (const key in data.data) {
  234. if (Object.hasOwnProperty.call(data.data, key)) {
  235. const element = data.data[key];
  236. let itemConfig = {};
  237. try {
  238. itemConfig = JSON.parse(element.config);
  239. } catch (error) {
  240. itemConfig = config[key]
  241. }
  242. itemConfig.Sortrank = element.sortrank;
  243. itemConfig.Enabled = element.status === 0? false : true;
  244. console.log("itemConfig=", itemConfig);
  245. for (const k1 in config[key]) {
  246. if (Object.hasOwnProperty.call(config[key], k1)) {
  247. const ee = config[key][k1];
  248. if (typeof itemConfig[k1] === "undefined") {
  249. itemConfig[k1] = ee;
  250. }
  251. }
  252. }
  253. for (const k2 in itemConfig) {
  254. if (Object.hasOwnProperty.call(itemConfig, k2)) {
  255. const element = itemConfig[k2];
  256. if ($(`#ipt${key}${k2}`).attr('type') === 'text') {
  257. $(`#ipt${key}${k2}`).val(element);
  258. } else if ($(`#ipt${key}${k2}`).attr('type') === 'checkbox') {
  259. $(`#ipt${key}${k2}`).prop('checked', element);
  260. }
  261. }
  262. }
  263. config[key] = itemConfig;
  264. }
  265. }
  266. }
  267. })
  268. }
  269. //更新config
  270. function updateConfig() {
  271. for (const key in config) {
  272. if (Object.hasOwnProperty.call(config, key)) {
  273. const element = config[key];
  274. for (const kk in element) {
  275. if (Object.hasOwnProperty.call(element, kk)) {
  276. const itemConfig = element[kk];
  277. console.log(`#ipt${key}${kk}`, itemConfig);
  278. if ($(`#ipt${key}${kk}`).attr('type') === 'text') {
  279. let val = $(`#ipt${key}${kk}`).val();
  280. if (kk === "Sortrank") {
  281. val = parseInt(val);
  282. }
  283. config[key][kk] = val;
  284. } else if ($(`#ipt${key}${kk}`).attr('type') === 'checkbox') {
  285. config[key][kk] = $(`#ipt${key}${kk}`).prop('checked');
  286. }
  287. }
  288. }
  289. }
  290. }
  291. }
  292. //保存配置信息
  293. function saveConfig() {
  294. $.ajax({
  295. type: "post",
  296. url: 'sys_payment.php?dopost=save_config',
  297. data: JSON.stringify(config),
  298. contentType: "application/json; charset=utf-8",
  299. dataType: "json",
  300. success: function (data) {
  301. console.log(data);
  302. }
  303. })
  304. }
  305. $(document).ready(function () {
  306. getPayments();
  307. $("#btnSave").click(() => {
  308. updateConfig()
  309. saveConfig();
  310. console.log(config)
  311. })
  312. })
  313. </script>
  314. </body>
  315. </html>