pay.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('com-attachment');
  4. ComponentHelper::loadComponentView('com-upload');
  5. ComponentHelper::loadComponentView('com-rich-text');
  6. ?>
  7. <style>
  8. .form-body {
  9. padding: 20px 0;
  10. background-color: #fff;
  11. margin-bottom: 20px;
  12. }
  13. .form-button {
  14. margin: 0;
  15. }
  16. .form-button .el-form-item__content {
  17. margin-left: 0!important;
  18. }
  19. .button-item {
  20. padding: 9px 25px;
  21. }
  22. .app-share {
  23. padding-top: 12px;
  24. border-top: 1px solid #e2e2e2;
  25. margin-top: -20px;
  26. }
  27. .app-share .app-share-bg {
  28. position: relative;
  29. width: 310px;
  30. height: 360px;
  31. background-repeat: no-repeat;
  32. background-size: contain;
  33. background-position: center
  34. }
  35. .app-share .app-share-bg .title {
  36. width: 160px;
  37. height: 29px;
  38. line-height: 1;
  39. word-break: break-all;
  40. text-overflow: ellipsis;
  41. display: -webkit-box;
  42. -webkit-box-orient: vertical;
  43. -webkit-line-clamp: 2;
  44. overflow: hidden;
  45. }
  46. .app-share .app-share-bg .pic-image {
  47. background-repeat: no-repeat;
  48. background-position: 0 0;
  49. background-size: cover;
  50. width: 160px;
  51. height: 130px;
  52. }
  53. .goods-list {
  54. flex-wrap: wrap;
  55. margin-top: 10px;
  56. /* cursor: move; */
  57. }
  58. .goods-item,
  59. .goods-add {
  60. width: 50px;
  61. height: 50px;
  62. position: relative;
  63. border: 1px solid #e2e2e2;
  64. margin-right: 15px;
  65. margin-bottom: 15px;
  66. }
  67. .goods-add .el-button {
  68. width: 100%;
  69. height: 100%;
  70. border: none;
  71. border-radius: 0;
  72. padding: 0;
  73. }
  74. .goods-delete {
  75. position: absolute;
  76. left: calc(100% - 13px);
  77. top: -13px;
  78. width: 25px;
  79. height: 25px;
  80. line-height: 25px;
  81. padding: 0 0;
  82. visibility: hidden;
  83. z-index: 1;
  84. }
  85. .goods-delete .el-icon-close {
  86. position: absolute;
  87. top: 6px;
  88. left: 6px;
  89. }
  90. .goods-item:hover .goods-delete {
  91. visibility: visible;
  92. }
  93. .goods-pic {
  94. background-size: cover;
  95. background-position: center;
  96. width: 100%;
  97. height: 100%;
  98. background-color: #f6f6f6;
  99. background-repeat: no-repeat;
  100. }
  101. .input-item {
  102. display: inline-block;
  103. width: 250px;
  104. margin: 0;
  105. }
  106. .input-item .el-input__inner {
  107. border-right: 0;
  108. }
  109. .input-item .el-input__inner:hover {
  110. border: 1px solid #dcdfe6;
  111. border-right: 0;
  112. outline: 0;
  113. }
  114. .input-item .el-input__inner:focus {
  115. border: 1px solid #dcdfe6;
  116. border-right: 0;
  117. outline: 0;
  118. }
  119. .input-item .el-input-group__append {
  120. background-color: #fff;
  121. border-left: 0;
  122. width: 10%;
  123. padding: 0;
  124. }
  125. .input-item .el-input-group__append .el-button {
  126. padding: 0;
  127. }
  128. .input-item .el-input-group__append .el-button {
  129. margin: 0;
  130. }
  131. .customize-share-title {
  132. position: relative;
  133. margin-top: 10px;
  134. }
  135. .customize-share-title .del-btn {
  136. position: absolute;
  137. top: -10px;
  138. left: 70px;
  139. }
  140. </style>
  141. <div id="app" v-cloak>
  142. <el-card class="box-card" v-loading="loading" shadow="never" style="border:0;min-width: 1200px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  143. <div class="form_box">
  144. <template>
  145. <el-card>
  146. <el-form :model="ruleForm" size="small" ref="ruleForm" label-width="150px">
  147. <el-tabs v-model="activeName" type="card">
  148. <el-tab-pane label="微信设置" name="wxpay">
  149. <?=ComponentHelper::loadComponentView('pay/wxpay', __DIR__); ?>
  150. </el-tab-pane>
  151. <el-tab-pane label="支付宝设置" name="alipay">
  152. <?=ComponentHelper::loadComponentView('pay/alipay', __DIR__); ?>
  153. </el-tab-pane>
  154. <el-tab-pane label="应用付费" name="addonspay">
  155. <?=ComponentHelper::loadComponentView('pay/addonspay', __DIR__); ?>
  156. </el-tab-pane>
  157. </el-tabs>
  158. <el-button :loading="btnLoading" class="button-item" type="primary" style="margin-top: 24px;" @click="submit" size="small">保存
  159. </el-button>
  160. </el-form>
  161. </el-card>
  162. </template>
  163. <template>
  164. </template>
  165. </div>
  166. </el-card>
  167. </div>
  168. <script>
  169. const app = new Vue({
  170. el: '#app',
  171. data() {
  172. return {
  173. multiple: Boolean,
  174. loading: false,
  175. btnLoading: false,
  176. params: {},
  177. activeName: 'wxpay',
  178. ruleForm: {
  179. wechat:{
  180. status: {title:'启用微信支付',value:'0',remark: ''},
  181. app_id: {title:'微信公众号APPID',value:'',remark: ''},
  182. wechat_open_app_id: {title:'微信开放平台应用APPID',value:'',remark: ''},
  183. wechat_mch_id: {title:'微信支付商户号',value:'',remark: ''},
  184. wechat_pay_secret: {title:'微信支付Api密钥',value:'',remark: ''},
  185. wechat_cert_pem: {title:'微信支付apiclient_cert.pem',value:'',remark: ''},
  186. wechat_cert_pem_file: {title:'apiclient_cert.pem存储目录',value:'',remark: ''},
  187. wechat_key_pem: {title:'微信支付apiclient_key.pem',value:'',remark: ''},
  188. wechat_key_pem_file: {title:'apiclient_key.pem存储目录',value:'',remark: ''},
  189. },
  190. alipay:{
  191. status: {title:'启用支付宝支付',value:'0',remark: ''},
  192. alipay_app_id: {title:'支付宝app_id',value:'',remark: ''},
  193. alipay_private_key: {title:'支付宝应用私钥',value:'',remark: ''},
  194. alipay_public_key: {title:'支付宝应用公钥',value:'',remark: ''},
  195. },
  196. addons:{
  197. payagreement:{title:'应用付费服务协议',value:'',remark: ''},
  198. }
  199. },
  200. pem_value: '',
  201. }
  202. },
  203. mounted: function() {
  204. this.loadData();
  205. },
  206. methods: {
  207. loadData() {
  208. if(this.loading === true) return;
  209. this.loading = true;
  210. request({
  211. params: {
  212. r: 'admin/setting/pay',
  213. type: 'pay'
  214. },
  215. method: 'get'
  216. }).then(e => {
  217. this.loading = false;
  218. if (e.data.code == 0) {
  219. if(e.data.data) {//有选中的
  220. let data = e.data.data
  221. Object.keys(this.ruleForm).forEach((key) => {
  222. Object.keys(this.ruleForm[key]).forEach((k) => {
  223. if (data[key][k]) {
  224. var dataValue = data[key][k].value;
  225. if(data[key][k].value!=null&&data[key][k].value!=""){
  226. if (typeof dataValue == 'string' && (dataValue.indexOf("{") !== -1 || dataValue.indexOf("[") !== -1)) {
  227. // 将json字符串转为对象
  228. this.ruleForm[key][k].value = JSON.parse(data[key][k].value);
  229. }else{
  230. this.ruleForm[key][k].value = data[key][k].value;
  231. }
  232. }
  233. }
  234. });
  235. });
  236. this.ruleForm.basic.web_url.value = data.web_url;
  237. }
  238. }
  239. }).catch(e => {
  240. this.loading = false;
  241. })
  242. },
  243. submit() {
  244. this.btnLoading = true;
  245. this.$request({
  246. params: {
  247. r: 'admin/setting/pay',
  248. },
  249. method: 'post',
  250. data: {
  251. setting: this.ruleForm,
  252. },
  253. }).then(e => {
  254. this.btnLoading = false;
  255. if (e.data.code === 0) {
  256. this.$message.success(e.data.msg);
  257. } else {
  258. this.$message.error(e.data.msg);
  259. }
  260. }).catch(e => {
  261. this.btnLoading = false;
  262. });
  263. },
  264. uploadPem(key) {
  265. this.pem_value = key;
  266. this.$refs[key].value = null;
  267. this.$refs[key].click();
  268. },
  269. handleChange(e){
  270. var rawFiles = e.target.files;
  271. if (rawFiles.length > 1) {
  272. this.$message.error('最多一次只能上传一个文件。')
  273. return;
  274. }
  275. let file = {
  276. _complete: false,
  277. response: null,
  278. rawFile: rawFiles[0],
  279. };
  280. let formData = new FormData();
  281. const params = {};
  282. params['r'] = 'admin/file/upload';
  283. for (let i in this.params) {
  284. params[i] = this.params[i];
  285. }
  286. for (let i in this.fields) {
  287. formData.append(i, this.fields[i]);
  288. }
  289. formData.append('file', file.rawFile, file.rawFile.name);
  290. this.$request({
  291. headers: {'Content-Type': 'multipart/form-data'},
  292. params: params,
  293. method: 'post',
  294. data: formData,
  295. }).then(e => {
  296. if (e.data.code === 0) {
  297. this.ruleForm.wechat[this.pem_value].value = e.data.data.path;
  298. this.$message.success('上传成功');
  299. } else {
  300. this.$message.error(e.data.msg);
  301. }
  302. }).catch(e => {
  303. this.$message.error('上传失败');
  304. });
  305. },
  306. }
  307. });
  308. </script>