Commit f92a5899f3bb9e7ee53cc002a10909467b31f5e8
1 parent
29d61beb
mall + pay:
1. 简化微信支付的配置界面
Showing
5 changed files
with
318 additions
and
451 deletions
yudao-ui-admin/src/utils/constants.js
| @@ -181,14 +181,6 @@ export const PayDisplayModeEnum = { | @@ -181,14 +181,6 @@ export const PayDisplayModeEnum = { | ||
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | /** | 183 | /** |
| 184 | - * 支付类型枚举 | ||
| 185 | - */ | ||
| 186 | -export const PayType = { | ||
| 187 | - WECHAT: "WECHAT", | ||
| 188 | - ALIPAY: "ALIPAY" | ||
| 189 | -} | ||
| 190 | - | ||
| 191 | -/** | ||
| 192 | * 支付订单状态枚举 | 184 | * 支付订单状态枚举 |
| 193 | */ | 185 | */ |
| 194 | export const PayOrderStatusEnum = { | 186 | export const PayOrderStatusEnum = { |
yudao-ui-admin/src/views/pay/app/components/alipayChannelForm.vue
| @@ -172,7 +172,7 @@ export default { | @@ -172,7 +172,7 @@ export default { | ||
| 172 | this.formData = response.data; | 172 | this.formData = response.data; |
| 173 | this.formData.config = JSON.parse(response.data.config); | 173 | this.formData.config = JSON.parse(response.data.config); |
| 174 | } | 174 | } |
| 175 | - this.title = this.formData.id ? '创建支付渠道' : '编辑支付渠道' | 175 | + this.title = !this.formData.id ? '创建支付渠道' : '编辑支付渠道' |
| 176 | }).finally(() => { | 176 | }).finally(() => { |
| 177 | this.formLoading = false; | 177 | this.formLoading = false; |
| 178 | }); | 178 | }); |
| @@ -257,12 +257,7 @@ export default { | @@ -257,12 +257,7 @@ export default { | ||
| 257 | this.formData.config.rootCertContent = e.target.result | 257 | this.formData.config.rootCertContent = e.target.result |
| 258 | } | 258 | } |
| 259 | readFile.readAsText(event.file); | 259 | readFile.readAsText(event.file); |
| 260 | - }, | ||
| 261 | - | 260 | + } |
| 262 | } | 261 | } |
| 263 | } | 262 | } |
| 264 | - | ||
| 265 | </script> | 263 | </script> |
| 266 | -<style scoped> | ||
| 267 | - | ||
| 268 | -</style> |
yudao-ui-admin/src/views/pay/app/components/wechatChannelForm.vue deleted
| 1 | -<template> | ||
| 2 | - <div> | ||
| 3 | - <el-dialog :visible.sync="transferParam.wechatOpen" :title="title" @close="close" append-to-body width="800px"> | ||
| 4 | - <el-form ref="wechatJsApiForm" :model="form" :rules="rules" size="medium" label-width="120px" | ||
| 5 | - v-loading="transferParam.loading"> | ||
| 6 | - <el-form-item label-width="180px" label="渠道费率" prop="feeRate"> | ||
| 7 | - <el-input v-model="form.feeRate" placeholder="请输入渠道费率" clearable :style="{width: '100%'}"> | ||
| 8 | - <template slot="append">%</template> | ||
| 9 | - </el-input> | ||
| 10 | - </el-form-item> | ||
| 11 | - <el-form-item label-width="180px" label="公众号 APPID" prop="weChatConfig.appId"> | ||
| 12 | - <el-input v-model="form.weChatConfig.appId" placeholder="请输入公众号 APPID" clearable :style="{width: '100%'}"> | ||
| 13 | - </el-input> | ||
| 14 | - </el-form-item> | ||
| 15 | - <el-form-item label-width="180px" label="商户号" prop="weChatConfig.mchId"> | ||
| 16 | - <el-input v-model="form.weChatConfig.mchId" :style="{width: '100%'}"></el-input> | ||
| 17 | - </el-form-item> | ||
| 18 | - <el-form-item label-width="180px" label="渠道状态" prop="status"> | ||
| 19 | - <el-radio-group v-model="form.status" size="medium"> | ||
| 20 | - <el-radio v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="parseInt(dict.value)"> | ||
| 21 | - {{ dict.label }} | ||
| 22 | - </el-radio> | ||
| 23 | - </el-radio-group> | ||
| 24 | - </el-form-item> | ||
| 25 | - <el-form-item label-width="180px" label="API 版本" prop="weChatConfig.apiVersion"> | ||
| 26 | - <el-radio-group v-model="form.weChatConfig.apiVersion" size="medium"> | ||
| 27 | - <el-radio v-for="dict in versionDictDatas" :key="dict.value" :label="dict.value"> | ||
| 28 | - {{ dict.label }} | ||
| 29 | - </el-radio> | ||
| 30 | - </el-radio-group> | ||
| 31 | - </el-form-item> | ||
| 32 | - <div v-if="form.weChatConfig.apiVersion === 'v2'"> | ||
| 33 | - <el-form-item label-width="180px" label="商户密钥" prop="weChatConfig.mchKey"> | ||
| 34 | - <el-input v-model="form.weChatConfig.mchKey" placeholder="请输入商户密钥" clearable | ||
| 35 | - :style="{width: '100%'}" type="textarea" :autosize="{minRows: 8, maxRows: 8}"></el-input> | ||
| 36 | - </el-form-item> | ||
| 37 | - <el-form-item label-width="180px" label="apiclient_cert.p12 证书" prop="weChatConfig.keyContent"> | ||
| 38 | - <el-input v-model="form.weChatConfig.keyContent" type="textarea" | ||
| 39 | - placeholder="请上传 apiclient_cert.p12 证书" | ||
| 40 | - readonly :autosize="{minRows: 8, maxRows: 8}" :style="{width: '100%'}"></el-input> | ||
| 41 | - </el-form-item> | ||
| 42 | - <el-form-item label-width="180px" label=""> | ||
| 43 | - <el-upload :limit="1" accept=".p12" action="" | ||
| 44 | - :before-upload="p12FileBeforeUpload" | ||
| 45 | - :http-request="keyContentUpload"> | ||
| 46 | - <el-button size="small" type="primary" icon="el-icon-upload">点击上传</el-button> | ||
| 47 | - </el-upload> | ||
| 48 | - </el-form-item> | ||
| 49 | - </div> | ||
| 50 | - <div v-if="form.weChatConfig.apiVersion === 'v3'"> | ||
| 51 | - <el-form-item label-width="180px" label="API V3 密钥" prop="weChatConfig.apiV3Key"> | ||
| 52 | - <el-input v-model="form.weChatConfig.apiV3Key" placeholder="请输入 API V3 密钥" clearable | ||
| 53 | - :style="{width: '100%'}" type="textarea" :autosize="{minRows: 8, maxRows: 8}"></el-input> | ||
| 54 | - </el-form-item> | ||
| 55 | - <el-form-item label-width="180px" label="apiclient_key.perm 证书" prop="weChatConfig.privateKeyContent"> | ||
| 56 | - <el-input v-model="form.weChatConfig.privateKeyContent" type="textarea" | ||
| 57 | - placeholder="请上传 apiclient_key.perm 证书" | ||
| 58 | - readonly :autosize="{minRows: 8, maxRows: 8}" :style="{width: '100%'}"></el-input> | ||
| 59 | - </el-form-item> | ||
| 60 | - <el-form-item label-width="180px" label="" prop="privateKeyContentFile"> | ||
| 61 | - <el-upload ref="privateKeyContentFile" | ||
| 62 | - :limit="1" | ||
| 63 | - accept=".pem" | ||
| 64 | - action="" | ||
| 65 | - :before-upload="pemFileBeforeUpload" | ||
| 66 | - :http-request="privateKeyContentUpload" | ||
| 67 | - > | ||
| 68 | - <el-button size="small" type="primary" icon="el-icon-upload">点击上传</el-button> | ||
| 69 | - </el-upload> | ||
| 70 | - </el-form-item> | ||
| 71 | - <el-form-item label-width="180px" label="apiclient_cert.perm证书" prop="weChatConfig.privateCertContent"> | ||
| 72 | - <el-input v-model="form.weChatConfig.privateCertContent" type="textarea" | ||
| 73 | - placeholder="请上传apiclient_cert.perm证书" | ||
| 74 | - readonly :autosize="{minRows: 8, maxRows: 8}" :style="{width: '100%'}"></el-input> | ||
| 75 | - </el-form-item> | ||
| 76 | - <el-form-item label-width="180px" label="" prop="privateCertContentFile"> | ||
| 77 | - <el-upload ref="privateCertContentFile" | ||
| 78 | - :limit="1" | ||
| 79 | - accept=".pem" | ||
| 80 | - action="" | ||
| 81 | - :before-upload="pemFileBeforeUpload" | ||
| 82 | - :http-request="privateCertContentUpload" | ||
| 83 | - > | ||
| 84 | - <el-button size="small" type="primary" icon="el-icon-upload">点击上传</el-button> | ||
| 85 | - </el-upload> | ||
| 86 | - </el-form-item> | ||
| 87 | - </div> | ||
| 88 | - <el-form-item label-width="180px" label="备注" prop="remark"> | ||
| 89 | - <el-input v-model="form.remark" :style="{width: '100%'}" /> | ||
| 90 | - </el-form-item> | ||
| 91 | - </el-form> | ||
| 92 | - <div slot="footer" class="dialog-footer"> | ||
| 93 | - <el-button @click="close">取消</el-button> | ||
| 94 | - <el-button type="primary" @click="handleConfirm">确定</el-button> | ||
| 95 | - </div> | ||
| 96 | - </el-dialog> | ||
| 97 | - </div> | ||
| 98 | -</template> | ||
| 99 | -<script> | ||
| 100 | -import {DICT_TYPE, getDictDatas} from "@/utils/dict"; | ||
| 101 | -import {createChannel, getChannel, updateChannel} from "@/api/pay/channel"; | ||
| 102 | - | ||
| 103 | -const defaultForm = { | ||
| 104 | - code: '', | ||
| 105 | - status: null, | ||
| 106 | - remark: '', | ||
| 107 | - feeRate: null, | ||
| 108 | - appId: '', | ||
| 109 | - weChatConfig: { | ||
| 110 | - appId: '', | ||
| 111 | - mchId: '', | ||
| 112 | - apiVersion: '', | ||
| 113 | - mchKey: '', | ||
| 114 | - keyContent: '', | ||
| 115 | - privateKeyContent: '', | ||
| 116 | - privateCertContent: '', | ||
| 117 | - apiV3Key:'', | ||
| 118 | - } | ||
| 119 | -} | ||
| 120 | - | ||
| 121 | -export default { | ||
| 122 | - name: "wechatChannelForm", | ||
| 123 | - components: {}, | ||
| 124 | - props: { | ||
| 125 | - // 传输的参数 | ||
| 126 | - transferParam: { | ||
| 127 | - // 加载动画 | ||
| 128 | - "loading": false, | ||
| 129 | - // 是否修改 | ||
| 130 | - "edit": false, | ||
| 131 | - // 是否显示 | ||
| 132 | - "wechatOpen": false, | ||
| 133 | - // 应用ID | ||
| 134 | - "appId": null, | ||
| 135 | - // 渠道编码 | ||
| 136 | - "payCode": null, | ||
| 137 | - } | ||
| 138 | - }, | ||
| 139 | - data() { | ||
| 140 | - return { | ||
| 141 | - title:'', | ||
| 142 | - form: JSON.parse(JSON.stringify(defaultForm)), | ||
| 143 | - rules: { | ||
| 144 | - feeRate: [{ | ||
| 145 | - required: true, | ||
| 146 | - message: '请输入渠道费率', | ||
| 147 | - trigger: 'blur' | ||
| 148 | - }], | ||
| 149 | - 'weChatConfig.mchId': [{ | ||
| 150 | - required: true, | ||
| 151 | - message: '请传入商户号', | ||
| 152 | - trigger: 'blur' | ||
| 153 | - }], | ||
| 154 | - 'weChatConfig.appId': [{ | ||
| 155 | - required: true, | ||
| 156 | - message: '请输入公众号APPID', | ||
| 157 | - trigger: 'blur' | ||
| 158 | - }], | ||
| 159 | - status: [{ | ||
| 160 | - required: true, | ||
| 161 | - message: '渠道状态不能为空', | ||
| 162 | - trigger: 'blur' | ||
| 163 | - }], | ||
| 164 | - 'weChatConfig.apiVersion': [{ | ||
| 165 | - required: true, | ||
| 166 | - message: 'API版本不能为空', | ||
| 167 | - trigger: 'blur' | ||
| 168 | - }], | ||
| 169 | - 'weChatConfig.mchKey': [{ | ||
| 170 | - required: true, | ||
| 171 | - message: '请输入商户密钥', | ||
| 172 | - trigger: 'blur' | ||
| 173 | - }], | ||
| 174 | - 'weChatConfig.keyContent': [{ | ||
| 175 | - required: true, | ||
| 176 | - message: '请上传 apiclient_cert.p12 证书', | ||
| 177 | - trigger: 'blur' | ||
| 178 | - }], | ||
| 179 | - 'weChatConfig.privateKeyContent': [{ | ||
| 180 | - required: true, | ||
| 181 | - message: '请上传 apiclient_key.perm 证书', | ||
| 182 | - trigger: 'blur' | ||
| 183 | - }], | ||
| 184 | - 'weChatConfig.privateCertContent': [{ | ||
| 185 | - required: true, | ||
| 186 | - message: '请上传 apiclient_cert.perm证 书', | ||
| 187 | - trigger: 'blur' | ||
| 188 | - }], | ||
| 189 | - 'weChatConfig.apiV3Key': [{ | ||
| 190 | - required: true, | ||
| 191 | - message: '请上传 api V3 密钥值', | ||
| 192 | - trigger: 'blur' | ||
| 193 | - }], | ||
| 194 | - }, | ||
| 195 | - // 渠道状态 数据字典 | ||
| 196 | - statusDictDatas: getDictDatas(DICT_TYPE.COMMON_STATUS), | ||
| 197 | - versionDictDatas: getDictDatas(DICT_TYPE.PAY_CHANNEL_WECHAT_VERSION), | ||
| 198 | - } | ||
| 199 | - }, | ||
| 200 | - watch: { | ||
| 201 | - transferParam: { | ||
| 202 | - deep: true, // 深度监听 | ||
| 203 | - handler(newVal) { | ||
| 204 | - if (newVal.wechatOpen) { | ||
| 205 | - this.form.code = newVal.payCode; | ||
| 206 | - this.form.appId = newVal.appId; | ||
| 207 | - // 只有在初次进来为编辑 并且为加载中的时候才回去请求数据 | ||
| 208 | - if (newVal.edit && newVal.loading) { | ||
| 209 | - this.title = "编辑支付渠道"; | ||
| 210 | - this.init(); | ||
| 211 | - } else { | ||
| 212 | - this.title = "创建支付渠道"; | ||
| 213 | - } | ||
| 214 | - } | ||
| 215 | - } | ||
| 216 | - } | ||
| 217 | - }, | ||
| 218 | - methods: { | ||
| 219 | - init() { | ||
| 220 | - getChannel(this.transferParam.appId, this.transferParam.payCode) | ||
| 221 | - .then(response => { | ||
| 222 | - this.form.id = response.data.id; | ||
| 223 | - this.form.feeRate = response.data.feeRate; | ||
| 224 | - this.form.appId = response.data.appId; | ||
| 225 | - this.form.status = response.data.status; | ||
| 226 | - this.form.remark = response.data.remark; | ||
| 227 | - | ||
| 228 | - let config = JSON.parse(response.data.config); | ||
| 229 | - this.form.weChatConfig.appId = config.appId; | ||
| 230 | - this.form.weChatConfig.apiVersion = config.apiVersion; | ||
| 231 | - this.form.weChatConfig.mchId = config.mchId; | ||
| 232 | - this.form.weChatConfig.mchKey = config.mchKey; | ||
| 233 | - this.form.weChatConfig.keyContent = config.keyContent; | ||
| 234 | - this.form.weChatConfig.privateKeyContent = config.privateKeyContent; | ||
| 235 | - this.form.weChatConfig.privateCertContent = config.privateCertContent; | ||
| 236 | - this.form.weChatConfig.apiV3Key = config.apiV3Key; | ||
| 237 | - this.transferParam.loading = false; | ||
| 238 | - }) | ||
| 239 | - }, | ||
| 240 | - close() { | ||
| 241 | - this.transferParam.wechatOpen = false; | ||
| 242 | - this.form = JSON.parse(JSON.stringify(defaultForm)); | ||
| 243 | - }, | ||
| 244 | - handleConfirm() { | ||
| 245 | - this.$refs['wechatJsApiForm'].validate(valid => { | ||
| 246 | - if (!valid) { | ||
| 247 | - return | ||
| 248 | - } | ||
| 249 | - let data = this.form; | ||
| 250 | - data.config = JSON.stringify(this.form.weChatConfig); | ||
| 251 | - if (this.transferParam.edit) { | ||
| 252 | - updateChannel(data).then(response => { | ||
| 253 | - if (response.code === 0) { | ||
| 254 | - this.$modal.msgSuccess("修改成功"); | ||
| 255 | - this.close(); | ||
| 256 | - } | ||
| 257 | - }) | ||
| 258 | - } else { | ||
| 259 | - | ||
| 260 | - createChannel(data).then(response => { | ||
| 261 | - if (response.code === 0) { | ||
| 262 | - this.$modal.msgSuccess("新增成功"); | ||
| 263 | - this.$parent.refreshTable(); | ||
| 264 | - this.close(); | ||
| 265 | - } | ||
| 266 | - }); | ||
| 267 | - } | ||
| 268 | - }); | ||
| 269 | - }, | ||
| 270 | - /** | ||
| 271 | - * apiclient_cert.p12、apiclient_cert.pem、apiclient_key.pem 上传前的校验 | ||
| 272 | - */ | ||
| 273 | - fileBeforeUpload(file, fileAccept) { | ||
| 274 | - let format = '.' + file.name.split(".")[1]; | ||
| 275 | - if (format !== fileAccept) { | ||
| 276 | - debugger | ||
| 277 | - this.$message.error('请上传指定格式"' + fileAccept + '"文件'); | ||
| 278 | - return false; | ||
| 279 | - } | ||
| 280 | - let isRightSize = file.size / 1024 / 1024 < 2 | ||
| 281 | - if (!isRightSize) { | ||
| 282 | - this.$message.error('文件大小超过 2MB') | ||
| 283 | - } | ||
| 284 | - return isRightSize | ||
| 285 | - }, | ||
| 286 | - p12FileBeforeUpload(file) { | ||
| 287 | - this.fileBeforeUpload(file, '.p12') | ||
| 288 | - }, | ||
| 289 | - pemFileBeforeUpload(file) { | ||
| 290 | - this.fileBeforeUpload(file, '.pem') | ||
| 291 | - }, | ||
| 292 | - /** | ||
| 293 | - * 读取 apiclient_key.pem 到 privateKeyContent 字段 | ||
| 294 | - */ | ||
| 295 | - privateKeyContentUpload(event) { | ||
| 296 | - const readFile = new FileReader() | ||
| 297 | - readFile.onload = (e) => { | ||
| 298 | - this.form.weChatConfig.privateKeyContent = e.target.result | ||
| 299 | - } | ||
| 300 | - readFile.readAsText(event.file); | ||
| 301 | - }, | ||
| 302 | - /** | ||
| 303 | - * 读取 apiclient_cert.pem 到 privateCertContent 字段 | ||
| 304 | - */ | ||
| 305 | - privateCertContentUpload(event) { | ||
| 306 | - const readFile = new FileReader() | ||
| 307 | - readFile.onload = (e) => { | ||
| 308 | - this.form.weChatConfig.privateCertContent = e.target.result | ||
| 309 | - } | ||
| 310 | - readFile.readAsText(event.file); | ||
| 311 | - }, | ||
| 312 | - /** | ||
| 313 | - * 读取 apiclient_cert.p12 到 keyContent 字段 | ||
| 314 | - */ | ||
| 315 | - keyContentUpload(event) { | ||
| 316 | - const readFile = new FileReader() | ||
| 317 | - readFile.onload = (e) => { | ||
| 318 | - this.form.weChatConfig.keyContent = e.target.result.split(',')[1] | ||
| 319 | - } | ||
| 320 | - readFile.readAsDataURL(event.file); // 读成 base64 | ||
| 321 | - } | ||
| 322 | - } | ||
| 323 | -} | ||
| 324 | - | ||
| 325 | -</script> | ||
| 326 | -<style scoped> | ||
| 327 | - | ||
| 328 | -</style> |
yudao-ui-admin/src/views/pay/app/components/weixinChannelForm.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div> | ||
| 3 | + <el-dialog :visible.sync="dialogVisible" :title="title" @close="close" append-to-body width="800px"> | ||
| 4 | + <el-form ref="form" :model="formData" :rules="rules" size="medium" label-width="120px" | ||
| 5 | + v-loading="formLoading"> | ||
| 6 | + <el-form-item label-width="180px" label="渠道费率" prop="feeRate"> | ||
| 7 | + <el-input v-model="formData.feeRate" placeholder="请输入渠道费率" clearable :style="{width: '100%'}"> | ||
| 8 | + <template slot="append">%</template> | ||
| 9 | + </el-input> | ||
| 10 | + </el-form-item> | ||
| 11 | + <el-form-item label-width="180px" label="公众号 APPID" prop="config.appId"> | ||
| 12 | + <el-input v-model="formData.config.appId" placeholder="请输入公众号 APPID" clearable :style="{width: '100%'}"> | ||
| 13 | + </el-input> | ||
| 14 | + </el-form-item> | ||
| 15 | + <el-form-item label-width="180px" label="商户号" prop="config.mchId"> | ||
| 16 | + <el-input v-model="formData.config.mchId" :style="{width: '100%'}"></el-input> | ||
| 17 | + </el-form-item> | ||
| 18 | + <el-form-item label-width="180px" label="渠道状态" prop="status"> | ||
| 19 | + <el-radio-group v-model="formData.status" size="medium"> | ||
| 20 | + <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" :key="parseInt(dict.value)" | ||
| 21 | + :label="parseInt(dict.value)"> | ||
| 22 | + {{ dict.label }} | ||
| 23 | + </el-radio> | ||
| 24 | + </el-radio-group> | ||
| 25 | + </el-form-item> | ||
| 26 | + <el-form-item label-width="180px" label="API 版本" prop="config.apiVersion"> | ||
| 27 | + <el-radio-group v-model="formData.config.apiVersion" size="medium"> | ||
| 28 | + <el-radio label="v2">v2</el-radio> | ||
| 29 | + <el-radio label="v3">v3</el-radio> | ||
| 30 | + </el-radio-group> | ||
| 31 | + </el-form-item> | ||
| 32 | + <div v-if="formData.config.apiVersion === 'v2'"> | ||
| 33 | + <el-form-item label-width="180px" label="商户密钥" prop="config.mchKey"> | ||
| 34 | + <el-input v-model="formData.config.mchKey" placeholder="请输入商户密钥" clearable | ||
| 35 | + :style="{width: '100%'}" type="textarea" :autosize="{minRows: 8, maxRows: 8}"></el-input> | ||
| 36 | + </el-form-item> | ||
| 37 | + <el-form-item label-width="180px" label="apiclient_cert.p12 证书" prop="config.keyContent"> | ||
| 38 | + <el-input v-model="formData.config.keyContent" type="textarea" | ||
| 39 | + placeholder="请上传 apiclient_cert.p12 证书" | ||
| 40 | + readonly :autosize="{minRows: 8, maxRows: 8}" :style="{width: '100%'}"></el-input> | ||
| 41 | + </el-form-item> | ||
| 42 | + <el-form-item label-width="180px" label=""> | ||
| 43 | + <el-upload :limit="1" accept=".p12" action="" | ||
| 44 | + :before-upload="p12FileBeforeUpload" | ||
| 45 | + :http-request="keyContentUpload"> | ||
| 46 | + <el-button size="small" type="primary" icon="el-icon-upload">点击上传</el-button> | ||
| 47 | + </el-upload> | ||
| 48 | + </el-form-item> | ||
| 49 | + </div> | ||
| 50 | + <div v-if="formData.config.apiVersion === 'v3'"> | ||
| 51 | + <el-form-item label-width="180px" label="API V3 密钥" prop="config.apiV3Key"> | ||
| 52 | + <el-input v-model="formData.config.apiV3Key" placeholder="请输入 API V3 密钥" clearable | ||
| 53 | + :style="{width: '100%'}" type="textarea" :autosize="{minRows: 8, maxRows: 8}"></el-input> | ||
| 54 | + </el-form-item> | ||
| 55 | + <el-form-item label-width="180px" label="apiclient_key.perm 证书" prop="config.privateKeyContent"> | ||
| 56 | + <el-input v-model="formData.config.privateKeyContent" type="textarea" | ||
| 57 | + placeholder="请上传 apiclient_key.perm 证书" | ||
| 58 | + readonly :autosize="{minRows: 8, maxRows: 8}" :style="{width: '100%'}"></el-input> | ||
| 59 | + </el-form-item> | ||
| 60 | + <el-form-item label-width="180px" label="" prop="privateKeyContentFile"> | ||
| 61 | + <el-upload ref="privateKeyContentFile" | ||
| 62 | + :limit="1" | ||
| 63 | + accept=".pem" | ||
| 64 | + action="" | ||
| 65 | + :before-upload="pemFileBeforeUpload" | ||
| 66 | + :http-request="privateKeyContentUpload" | ||
| 67 | + > | ||
| 68 | + <el-button size="small" type="primary" icon="el-icon-upload">点击上传</el-button> | ||
| 69 | + </el-upload> | ||
| 70 | + </el-form-item> | ||
| 71 | + <el-form-item label-width="180px" label="apiclient_cert.perm证书" prop="config.privateCertContent"> | ||
| 72 | + <el-input v-model="formData.config.privateCertContent" type="textarea" | ||
| 73 | + placeholder="请上传apiclient_cert.perm证书" | ||
| 74 | + readonly :autosize="{minRows: 8, maxRows: 8}" :style="{width: '100%'}"></el-input> | ||
| 75 | + </el-form-item> | ||
| 76 | + <el-form-item label-width="180px" label="" prop="privateCertContentFile"> | ||
| 77 | + <el-upload ref="privateCertContentFile" | ||
| 78 | + :limit="1" | ||
| 79 | + accept=".pem" | ||
| 80 | + action="" | ||
| 81 | + :before-upload="pemFileBeforeUpload" | ||
| 82 | + :http-request="privateCertContentUpload" | ||
| 83 | + > | ||
| 84 | + <el-button size="small" type="primary" icon="el-icon-upload">点击上传</el-button> | ||
| 85 | + </el-upload> | ||
| 86 | + </el-form-item> | ||
| 87 | + </div> | ||
| 88 | + <el-form-item label-width="180px" label="备注" prop="remark"> | ||
| 89 | + <el-input v-model="formData.remark" :style="{width: '100%'}" /> | ||
| 90 | + </el-form-item> | ||
| 91 | + </el-form> | ||
| 92 | + <div slot="footer" class="dialog-footer"> | ||
| 93 | + <el-button @click="close">取消</el-button> | ||
| 94 | + <el-button type="primary" @click="submitForm">确定</el-button> | ||
| 95 | + </div> | ||
| 96 | + </el-dialog> | ||
| 97 | + </div> | ||
| 98 | +</template> | ||
| 99 | +<script> | ||
| 100 | +import { createChannel, getChannel, updateChannel } from "@/api/pay/channel"; | ||
| 101 | +import { CommonStatusEnum } from "@/utils/constants"; | ||
| 102 | + | ||
| 103 | +export default { | ||
| 104 | + name: "weixinChannelForm", | ||
| 105 | + data() { | ||
| 106 | + return { | ||
| 107 | + dialogVisible: false, | ||
| 108 | + formLoading: false, | ||
| 109 | + title:'', | ||
| 110 | + formData: { | ||
| 111 | + appId: '', | ||
| 112 | + code: '', | ||
| 113 | + status: undefined, | ||
| 114 | + feeRate: undefined, | ||
| 115 | + remark: '', | ||
| 116 | + config: { | ||
| 117 | + appId: '', | ||
| 118 | + mchId: '', | ||
| 119 | + apiVersion: '', | ||
| 120 | + mchKey: '', | ||
| 121 | + keyContent: '', | ||
| 122 | + privateKeyContent: '', | ||
| 123 | + privateCertContent: '', | ||
| 124 | + apiV3Key:'', | ||
| 125 | + } | ||
| 126 | + }, | ||
| 127 | + rules: { | ||
| 128 | + feeRate: [{ required: true, message: '请输入渠道费率', trigger: 'blur' }], | ||
| 129 | + status: [{ required: true, message: '渠道状态不能为空', trigger: 'blur'}], | ||
| 130 | + 'config.mchId': [{ required: true, message: '请传入商户号', trigger: 'blur'}], | ||
| 131 | + 'config.appId': [{ required: true, message: '请输入公众号APPID', trigger: 'blur'}], | ||
| 132 | + 'config.apiVersion': [{ required: true, message: 'API版本不能为空', trigger: 'blur'}], | ||
| 133 | + 'config.mchKey': [{ required: true, message: '请输入商户密钥', trigger: 'blur' }], | ||
| 134 | + 'config.keyContent': [{ required: true, message: '请上传 apiclient_cert.p12 证书', trigger: 'blur' }], | ||
| 135 | + 'config.privateKeyContent': [{ required: true, message: '请上传 apiclient_key.perm 证书', trigger: 'blur' }], | ||
| 136 | + 'config.privateCertContent': [{ required: true, message: '请上传 apiclient_cert.perm证 书', trigger: 'blur' }], | ||
| 137 | + 'config.apiV3Key': [{ required: true, message: '请上传 api V3 密钥值', trigger: 'blur' }], | ||
| 138 | + }, | ||
| 139 | + } | ||
| 140 | + }, | ||
| 141 | + methods: { | ||
| 142 | + open(appId, code) { | ||
| 143 | + this.dialogVisible = true; | ||
| 144 | + this.formLoading = true; | ||
| 145 | + this.reset(appId, code); | ||
| 146 | + getChannel(appId, code).then(response => { | ||
| 147 | + if (response.data && response.data.id) { | ||
| 148 | + this.formData = response.data; | ||
| 149 | + this.formData.config = JSON.parse(response.data.config); | ||
| 150 | + } | ||
| 151 | + this.title = !this.formData.id ? '创建支付渠道' : '编辑支付渠道' | ||
| 152 | + }).finally(() => { | ||
| 153 | + this.formLoading = false; | ||
| 154 | + }); | ||
| 155 | + }, | ||
| 156 | + close() { | ||
| 157 | + this.dialogVisible = false; | ||
| 158 | + this.reset(undefined, undefined); | ||
| 159 | + }, | ||
| 160 | + submitForm() { | ||
| 161 | + this.$refs['form'].validate(valid => { | ||
| 162 | + if (!valid) { | ||
| 163 | + return | ||
| 164 | + } | ||
| 165 | + const data = { ...this.formData }; | ||
| 166 | + data.config = JSON.stringify(this.formData.config); | ||
| 167 | + if (!data.id) { | ||
| 168 | + createChannel(data).then(response => { | ||
| 169 | + this.$modal.msgSuccess("新增成功"); | ||
| 170 | + this.$emit('success') | ||
| 171 | + this.close(); | ||
| 172 | + }); | ||
| 173 | + } else { | ||
| 174 | + updateChannel(data).then(response => { | ||
| 175 | + this.$modal.msgSuccess("修改成功"); | ||
| 176 | + this.$emit('success') | ||
| 177 | + this.close(); | ||
| 178 | + }) | ||
| 179 | + } | ||
| 180 | + }); | ||
| 181 | + }, | ||
| 182 | + /** 重置表单 */ | ||
| 183 | + reset(appId, code) { | ||
| 184 | + this.formData = { | ||
| 185 | + appId: appId, | ||
| 186 | + code: code, | ||
| 187 | + status: CommonStatusEnum.ENABLE, | ||
| 188 | + feeRate: undefined, | ||
| 189 | + remark: '', | ||
| 190 | + config: { | ||
| 191 | + appId: '', | ||
| 192 | + mchId: '', | ||
| 193 | + apiVersion: '', | ||
| 194 | + mchKey: '', | ||
| 195 | + keyContent: '', | ||
| 196 | + privateKeyContent: '', | ||
| 197 | + privateCertContent: '', | ||
| 198 | + apiV3Key:'', | ||
| 199 | + } | ||
| 200 | + } | ||
| 201 | + this.resetForm('form') | ||
| 202 | + }, | ||
| 203 | + /** | ||
| 204 | + * apiclient_cert.p12、apiclient_cert.pem、apiclient_key.pem 上传前的校验 | ||
| 205 | + */ | ||
| 206 | + fileBeforeUpload(file, fileAccept) { | ||
| 207 | + let format = '.' + file.name.split(".")[1]; | ||
| 208 | + if (format !== fileAccept) { | ||
| 209 | + debugger | ||
| 210 | + this.$message.error('请上传指定格式"' + fileAccept + '"文件'); | ||
| 211 | + return false; | ||
| 212 | + } | ||
| 213 | + let isRightSize = file.size / 1024 / 1024 < 2 | ||
| 214 | + if (!isRightSize) { | ||
| 215 | + this.$message.error('文件大小超过 2MB') | ||
| 216 | + } | ||
| 217 | + return isRightSize | ||
| 218 | + }, | ||
| 219 | + p12FileBeforeUpload(file) { | ||
| 220 | + this.fileBeforeUpload(file, '.p12') | ||
| 221 | + }, | ||
| 222 | + pemFileBeforeUpload(file) { | ||
| 223 | + this.fileBeforeUpload(file, '.pem') | ||
| 224 | + }, | ||
| 225 | + /** | ||
| 226 | + * 读取 apiclient_key.pem 到 privateKeyContent 字段 | ||
| 227 | + */ | ||
| 228 | + privateKeyContentUpload(event) { | ||
| 229 | + const readFile = new FileReader() | ||
| 230 | + readFile.onload = (e) => { | ||
| 231 | + this.formData.config.privateKeyContent = e.target.result | ||
| 232 | + } | ||
| 233 | + readFile.readAsText(event.file); | ||
| 234 | + }, | ||
| 235 | + /** | ||
| 236 | + * 读取 apiclient_cert.pem 到 privateCertContent 字段 | ||
| 237 | + */ | ||
| 238 | + privateCertContentUpload(event) { | ||
| 239 | + const readFile = new FileReader() | ||
| 240 | + readFile.onload = (e) => { | ||
| 241 | + this.formData.config.privateCertContent = e.target.result | ||
| 242 | + } | ||
| 243 | + readFile.readAsText(event.file); | ||
| 244 | + }, | ||
| 245 | + /** | ||
| 246 | + * 读取 apiclient_cert.p12 到 keyContent 字段 | ||
| 247 | + */ | ||
| 248 | + keyContentUpload(event) { | ||
| 249 | + const readFile = new FileReader() | ||
| 250 | + readFile.onload = (e) => { | ||
| 251 | + this.formData.config.keyContent = e.target.result.split(',')[1] | ||
| 252 | + } | ||
| 253 | + readFile.readAsDataURL(event.file); // 读成 base64 | ||
| 254 | + } | ||
| 255 | + } | ||
| 256 | +} | ||
| 257 | +</script> |
yudao-ui-admin/src/views/pay/app/index.vue
| @@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
| 9 | </el-form-item> | 9 | </el-form-item> |
| 10 | <el-form-item label="开启状态" prop="status"> | 10 | <el-form-item label="开启状态" prop="status"> |
| 11 | <el-select v-model="queryParams.status" placeholder="请选择开启状态" clearable> | 11 | <el-select v-model="queryParams.status" placeholder="请选择开启状态" clearable> |
| 12 | - <el-option v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="dict.label" | 12 | + <el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" :key="parseInt(dict.value)" :label="dict.label" |
| 13 | :value="parseInt(dict.value)"/> | 13 | :value="parseInt(dict.value)"/> |
| 14 | </el-select> | 14 | </el-select> |
| 15 | </el-form-item> | 15 | </el-form-item> |
| @@ -48,60 +48,55 @@ | @@ -48,60 +48,55 @@ | ||
| 48 | <el-table-column :label="payChannelEnum.ALIPAY_APP.name" align="center"> | 48 | <el-table-column :label="payChannelEnum.ALIPAY_APP.name" align="center"> |
| 49 | <template v-slot="scope"> | 49 | <template v-slot="scope"> |
| 50 | <el-button type="success" icon="el-icon-check" circle | 50 | <el-button type="success" icon="el-icon-check" circle |
| 51 | - v-if="judgeChannelExist(scope.row.channelCodes,payChannelEnum.ALIPAY_APP.code)" | ||
| 52 | - @click="handleUpdateChannel(scope.row,payChannelEnum.ALIPAY_APP.code,payType.ALIPAY)"> | 51 | + v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.ALIPAY_APP.code)" |
| 52 | + @click="handleChannel(scope.row, payChannelEnum.ALIPAY_APP.code)"> | ||
| 53 | </el-button> | 53 | </el-button> |
| 54 | - <el-button v-else | ||
| 55 | - type="danger" icon="el-icon-close" circle | ||
| 56 | - @click="handleCreateChannel(scope.row,payChannelEnum.ALIPAY_APP.code,payType.ALIPAY)"> | 54 | + <el-button v-else type="danger" icon="el-icon-close" circle |
| 55 | + @click="handleChannel(scope.row, payChannelEnum.ALIPAY_APP.code)"> | ||
| 57 | </el-button> | 56 | </el-button> |
| 58 | </template> | 57 | </template> |
| 59 | </el-table-column> | 58 | </el-table-column> |
| 60 | <el-table-column :label="payChannelEnum.ALIPAY_PC.name" align="center"> | 59 | <el-table-column :label="payChannelEnum.ALIPAY_PC.name" align="center"> |
| 61 | <template v-slot="scope"> | 60 | <template v-slot="scope"> |
| 62 | <el-button type="success" icon="el-icon-check" circle | 61 | <el-button type="success" icon="el-icon-check" circle |
| 63 | - v-if="judgeChannelExist(scope.row.channelCodes,payChannelEnum.ALIPAY_PC.code)" | ||
| 64 | - @click="handleUpdateChannel(scope.row,payChannelEnum.ALIPAY_PC.code,payType.ALIPAY)"> | 62 | + v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.ALIPAY_PC.code)" |
| 63 | + @click="handleChannel(scope.row, payChannelEnum.ALIPAY_PC.code)"> | ||
| 65 | </el-button> | 64 | </el-button> |
| 66 | - <el-button v-else | ||
| 67 | - type="danger" icon="el-icon-close" circle | ||
| 68 | - @click="handleCreateChannel(scope.row,payChannelEnum.ALIPAY_PC.code,payType.ALIPAY)"> | 65 | + <el-button v-else type="danger" icon="el-icon-close" circle |
| 66 | + @click="handleChannel(scope.row, payChannelEnum.ALIPAY_PC.code)"> | ||
| 69 | </el-button> | 67 | </el-button> |
| 70 | </template> | 68 | </template> |
| 71 | </el-table-column> | 69 | </el-table-column> |
| 72 | <el-table-column :label="payChannelEnum.ALIPAY_WAP.name" align="center"> | 70 | <el-table-column :label="payChannelEnum.ALIPAY_WAP.name" align="center"> |
| 73 | <template v-slot="scope"> | 71 | <template v-slot="scope"> |
| 74 | <el-button type="success" icon="el-icon-check" circle | 72 | <el-button type="success" icon="el-icon-check" circle |
| 75 | - v-if="judgeChannelExist(scope.row.channelCodes,payChannelEnum.ALIPAY_WAP.code)" | ||
| 76 | - @click="handleUpdateChannel(scope.row,payChannelEnum.ALIPAY_WAP.code,payType.ALIPAY)"> | 73 | + v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.ALIPAY_WAP.code)" |
| 74 | + @click="handleChannel(scope.row, payChannelEnum.ALIPAY_WAP.code)"> | ||
| 77 | </el-button> | 75 | </el-button> |
| 78 | - <el-button v-else | ||
| 79 | - type="danger" icon="el-icon-close" circle | ||
| 80 | - @click="handleCreateChannel(scope.row,payChannelEnum.ALIPAY_WAP.code,payType.ALIPAY)"> | 76 | + <el-button v-else type="danger" icon="el-icon-close" circle |
| 77 | + @click="handleChannel(scope.row, payChannelEnum.ALIPAY_WAP.code)"> | ||
| 81 | </el-button> | 78 | </el-button> |
| 82 | </template> | 79 | </template> |
| 83 | </el-table-column> | 80 | </el-table-column> |
| 84 | <el-table-column :label="payChannelEnum.ALIPAY_QR.name" align="center"> | 81 | <el-table-column :label="payChannelEnum.ALIPAY_QR.name" align="center"> |
| 85 | <template v-slot="scope"> | 82 | <template v-slot="scope"> |
| 86 | <el-button type="success" icon="el-icon-check" circle | 83 | <el-button type="success" icon="el-icon-check" circle |
| 87 | - v-if="judgeChannelExist(scope.row.channelCodes,payChannelEnum.ALIPAY_QR.code)" | ||
| 88 | - @click="handleUpdateChannel(scope.row,payChannelEnum.ALIPAY_QR.code,payType.ALIPAY)"> | 84 | + v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.ALIPAY_QR.code)" |
| 85 | + @click="handleChannel(scope.row, payChannelEnum.ALIPAY_QR.code)"> | ||
| 89 | </el-button> | 86 | </el-button> |
| 90 | - <el-button v-else | ||
| 91 | - type="danger" icon="el-icon-close" circle | ||
| 92 | - @click="handleCreateChannel(scope.row,payChannelEnum.ALIPAY_QR.code,payType.ALIPAY)"> | 87 | + <el-button v-else type="danger" icon="el-icon-close" circle |
| 88 | + @click="handleChannel(scope.row, payChannelEnum.ALIPAY_QR.code)"> | ||
| 93 | </el-button> | 89 | </el-button> |
| 94 | </template> | 90 | </template> |
| 95 | </el-table-column> | 91 | </el-table-column> |
| 96 | <el-table-column :label="payChannelEnum.ALIPAY_BAR.name" align="center"> | 92 | <el-table-column :label="payChannelEnum.ALIPAY_BAR.name" align="center"> |
| 97 | <template v-slot="scope"> | 93 | <template v-slot="scope"> |
| 98 | <el-button type="success" icon="el-icon-check" circle | 94 | <el-button type="success" icon="el-icon-check" circle |
| 99 | - v-if="judgeChannelExist(scope.row.channelCodes,payChannelEnum.ALIPAY_BAR.code)" | ||
| 100 | - @click="handleUpdateChannel(scope.row,payChannelEnum.ALIPAY_BAR.code,payType.ALIPAY)"> | 95 | + v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.ALIPAY_BAR.code)" |
| 96 | + @click="handleChannel(scope.row,payChannelEnum.ALIPAY_BAR.code)"> | ||
| 101 | </el-button> | 97 | </el-button> |
| 102 | - <el-button v-else | ||
| 103 | - type="danger" icon="el-icon-close" circle | ||
| 104 | - @click="handleCreateChannel(scope.row,payChannelEnum.ALIPAY_BAR.code,payType.ALIPAY)"> | 98 | + <el-button v-else type="danger" icon="el-icon-close" circle |
| 99 | + @click="handleChannel(scope.row, payChannelEnum.ALIPAY_BAR.code)"> | ||
| 105 | </el-button> | 100 | </el-button> |
| 106 | </template> | 101 | </template> |
| 107 | </el-table-column> | 102 | </el-table-column> |
| @@ -110,60 +105,55 @@ | @@ -110,60 +105,55 @@ | ||
| 110 | <el-table-column :label="payChannelEnum.WX_LITE.name" align="center"> | 105 | <el-table-column :label="payChannelEnum.WX_LITE.name" align="center"> |
| 111 | <template v-slot="scope"> | 106 | <template v-slot="scope"> |
| 112 | <el-button type="success" icon="el-icon-check" circle | 107 | <el-button type="success" icon="el-icon-check" circle |
| 113 | - v-if="judgeChannelExist(scope.row.channelCodes,payChannelEnum.WX_LITE.code)" | ||
| 114 | - @click="handleUpdateChannel(scope.row,payChannelEnum.WX_LITE.code,payType.WECHAT)"> | 108 | + v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.WX_LITE.code)" |
| 109 | + @click="handleChannel(scope.row, payChannelEnum.WX_LITE.code)"> | ||
| 115 | </el-button> | 110 | </el-button> |
| 116 | - <el-button v-else | ||
| 117 | - type="danger" icon="el-icon-close" circle | ||
| 118 | - @click="handleCreateChannel(scope.row,payChannelEnum.WX_LITE.code,payType.WECHAT)"> | 111 | + <el-button v-else type="danger" icon="el-icon-close" circle |
| 112 | + @click="handleChannel(scope.row, payChannelEnum.WX_LITE.code)"> | ||
| 119 | </el-button> | 113 | </el-button> |
| 120 | </template> | 114 | </template> |
| 121 | </el-table-column> | 115 | </el-table-column> |
| 122 | <el-table-column :label="payChannelEnum.WX_PUB.name" align="center"> | 116 | <el-table-column :label="payChannelEnum.WX_PUB.name" align="center"> |
| 123 | <template v-slot="scope"> | 117 | <template v-slot="scope"> |
| 124 | <el-button type="success" icon="el-icon-check" circle | 118 | <el-button type="success" icon="el-icon-check" circle |
| 125 | - v-if="judgeChannelExist(scope.row.channelCodes,payChannelEnum.WX_PUB.code)" | ||
| 126 | - @click="handleUpdateChannel(scope.row,payChannelEnum.WX_PUB.code,payType.WECHAT)"> | 119 | + v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.WX_PUB.code)" |
| 120 | + @click="handleChannel(scope.row, payChannelEnum.WX_PUB.code)"> | ||
| 127 | </el-button> | 121 | </el-button> |
| 128 | - <el-button v-else | ||
| 129 | - type="danger" icon="el-icon-close" circle | ||
| 130 | - @click="handleCreateChannel(scope.row,payChannelEnum.WX_PUB.code,payType.WECHAT)"> | 122 | + <el-button v-else type="danger" icon="el-icon-close" circle |
| 123 | + @click="handleChannel(scope.row, payChannelEnum.WX_PUB.code)"> | ||
| 131 | </el-button> | 124 | </el-button> |
| 132 | </template> | 125 | </template> |
| 133 | </el-table-column> | 126 | </el-table-column> |
| 134 | <el-table-column :label="payChannelEnum.WX_APP.name" align="center"> | 127 | <el-table-column :label="payChannelEnum.WX_APP.name" align="center"> |
| 135 | <template v-slot="scope"> | 128 | <template v-slot="scope"> |
| 136 | <el-button type="success" icon="el-icon-check" circle | 129 | <el-button type="success" icon="el-icon-check" circle |
| 137 | - v-if="judgeChannelExist(scope.row.channelCodes,payChannelEnum.WX_APP.code)" | ||
| 138 | - @click="handleUpdateChannel(scope.row,payChannelEnum.WX_APP.code,payType.WECHAT)"> | 130 | + v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.WX_APP.code)" |
| 131 | + @click="handleChannel(scope.row, payChannelEnum.WX_APP.code)"> | ||
| 139 | </el-button> | 132 | </el-button> |
| 140 | - <el-button v-else | ||
| 141 | - type="danger" icon="el-icon-close" circle | ||
| 142 | - @click="handleCreateChannel(scope.row,payChannelEnum.WX_APP.code,payType.WECHAT)"> | 133 | + <el-button v-else type="danger" icon="el-icon-close" circle |
| 134 | + @click="handleChannel(scope.row, payChannelEnum.WX_APP.code)"> | ||
| 143 | </el-button> | 135 | </el-button> |
| 144 | </template> | 136 | </template> |
| 145 | </el-table-column> | 137 | </el-table-column> |
| 146 | <el-table-column :label="payChannelEnum.WX_NATIVE.name" align="center"> | 138 | <el-table-column :label="payChannelEnum.WX_NATIVE.name" align="center"> |
| 147 | <template v-slot="scope"> | 139 | <template v-slot="scope"> |
| 148 | <el-button type="success" icon="el-icon-check" circle | 140 | <el-button type="success" icon="el-icon-check" circle |
| 149 | - v-if="judgeChannelExist(scope.row.channelCodes,payChannelEnum.WX_NATIVE.code)" | ||
| 150 | - @click="handleUpdateChannel(scope.row,payChannelEnum.WX_NATIVE.code,payType.WECHAT)"> | 141 | + v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.WX_NATIVE.code)" |
| 142 | + @click="handleChannel(scope.row, payChannelEnum.WX_NATIVE.code)"> | ||
| 151 | </el-button> | 143 | </el-button> |
| 152 | - <el-button v-else | ||
| 153 | - type="danger" icon="el-icon-close" circle | ||
| 154 | - @click="handleCreateChannel(scope.row,payChannelEnum.WX_NATIVE.code,payType.WECHAT)"> | 144 | + <el-button v-else type="danger" icon="el-icon-close" circle |
| 145 | + @click="handleChannel(scope.row, payChannelEnum.WX_NATIVE.code)"> | ||
| 155 | </el-button> | 146 | </el-button> |
| 156 | </template> | 147 | </template> |
| 157 | </el-table-column> | 148 | </el-table-column> |
| 158 | <el-table-column :label="payChannelEnum.WX_BAR.name" align="center"> | 149 | <el-table-column :label="payChannelEnum.WX_BAR.name" align="center"> |
| 159 | <template v-slot="scope"> | 150 | <template v-slot="scope"> |
| 160 | <el-button type="success" icon="el-icon-check" circle | 151 | <el-button type="success" icon="el-icon-check" circle |
| 161 | - v-if="judgeChannelExist(scope.row.channelCodes,payChannelEnum.WX_BAR.code)" | ||
| 162 | - @click="handleUpdateChannel(scope.row,payChannelEnum.WX_BAR.code,payType.WECHAT)"> | 152 | + v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.WX_BAR.code)" |
| 153 | + @click="handleChannel(scope.row, payChannelEnum.WX_BAR.code)"> | ||
| 163 | </el-button> | 154 | </el-button> |
| 164 | - <el-button v-else | ||
| 165 | - type="danger" icon="el-icon-close" circle | ||
| 166 | - @click="handleCreateChannel(scope.row,payChannelEnum.WX_BAR.code,payType.WECHAT)"> | 155 | + <el-button v-else type="danger" icon="el-icon-close" circle |
| 156 | + @click="handleChannel(scope.row, payChannelEnum.WX_BAR.code)"> | ||
| 167 | </el-button> | 157 | </el-button> |
| 168 | </template> | 158 | </template> |
| 169 | </el-table-column> | 159 | </el-table-column> |
| @@ -191,7 +181,7 @@ | @@ -191,7 +181,7 @@ | ||
| 191 | </el-form-item> | 181 | </el-form-item> |
| 192 | <el-form-item label="开启状态" prop="status"> | 182 | <el-form-item label="开启状态" prop="status"> |
| 193 | <el-radio-group v-model="form.status"> | 183 | <el-radio-group v-model="form.status"> |
| 194 | - <el-radio v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="parseInt(dict.value)"> | 184 | + <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" :key="parseInt(dict.value)" :label="parseInt(dict.value)"> |
| 195 | {{ dict.label }} | 185 | {{ dict.label }} |
| 196 | </el-radio> | 186 | </el-radio> |
| 197 | </el-radio-group> | 187 | </el-radio-group> |
| @@ -214,24 +204,23 @@ | @@ -214,24 +204,23 @@ | ||
| 214 | </div> | 204 | </div> |
| 215 | </el-dialog> | 205 | </el-dialog> |
| 216 | 206 | ||
| 217 | - <!-- 弹窗 --> | ||
| 218 | - <wechat-channel-form :transferParam="channelParam" /> | 207 | + <!-- 对话框(支付应用的配置) --> |
| 208 | + <weixin-channel-form ref="weixinChannelFormRef" @success="getList" /> | ||
| 219 | <alipay-channel-form ref="alipayChannelFormRef" @success="getList" /> | 209 | <alipay-channel-form ref="alipayChannelFormRef" @success="getList" /> |
| 220 | </div> | 210 | </div> |
| 221 | </template> | 211 | </template> |
| 222 | 212 | ||
| 223 | <script> | 213 | <script> |
| 224 | import { createApp, updateApp, changeAppStatus, deleteApp, getApp, getAppPage } from "@/api/pay/app"; | 214 | import { createApp, updateApp, changeAppStatus, deleteApp, getApp, getAppPage } from "@/api/pay/app"; |
| 225 | -import { DICT_TYPE, getDictDatas } from "@/utils/dict"; | ||
| 226 | -import { PayType, PayChannelEnum, CommonStatusEnum } from "@/utils/constants"; | ||
| 227 | -import wechatChannelForm from "@/views/pay/app/components/wechatChannelForm"; | 215 | +import { PayChannelEnum, CommonStatusEnum } from "@/utils/constants"; |
| 216 | +import weixinChannelForm from "@/views/pay/app/components/weixinChannelForm"; | ||
| 228 | import alipayChannelForm from "@/views/pay/app/components/alipayChannelForm"; | 217 | import alipayChannelForm from "@/views/pay/app/components/alipayChannelForm"; |
| 229 | 218 | ||
| 230 | export default { | 219 | export default { |
| 231 | name: "PayApp", | 220 | name: "PayApp", |
| 232 | components: { | 221 | components: { |
| 233 | - "wechatChannelForm": wechatChannelForm, | ||
| 234 | - "alipayChannelForm": alipayChannelForm | 222 | + weixinChannelForm, |
| 223 | + alipayChannelForm | ||
| 235 | }, | 224 | }, |
| 236 | data() { | 225 | data() { |
| 237 | return { | 226 | return { |
| @@ -264,28 +253,8 @@ export default { | @@ -264,28 +253,8 @@ export default { | ||
| 264 | orderNotifyUrl: [{required: true, message: "支付结果的回调地址不能为空", trigger: "blur"}], | 253 | orderNotifyUrl: [{required: true, message: "支付结果的回调地址不能为空", trigger: "blur"}], |
| 265 | refundNotifyUrl: [{required: true, message: "退款结果的回调地址不能为空", trigger: "blur"}], | 254 | refundNotifyUrl: [{required: true, message: "退款结果的回调地址不能为空", trigger: "blur"}], |
| 266 | }, | 255 | }, |
| 267 | - // 数据字典 | ||
| 268 | - statusDictDatas: getDictDatas(DICT_TYPE.COMMON_STATUS), | ||
| 269 | - sysCommonStatusEnum: CommonStatusEnum, | ||
| 270 | // 支付渠道枚举 | 256 | // 支付渠道枚举 |
| 271 | payChannelEnum: PayChannelEnum, | 257 | payChannelEnum: PayChannelEnum, |
| 272 | - // 支付类型 | ||
| 273 | - payType: PayType, | ||
| 274 | - // 是否显示支付窗口 | ||
| 275 | - payOpen: false, | ||
| 276 | - // 微信组件传参参数 | ||
| 277 | - channelParam: { | ||
| 278 | - // 是否修改 | ||
| 279 | - "edit": false, | ||
| 280 | - // 微信是否显示 | ||
| 281 | - "wechatOpen": false, | ||
| 282 | - // 支付宝是否显示 | ||
| 283 | - "aliPayOpen": false, | ||
| 284 | - // 应用ID | ||
| 285 | - "appId": null, | ||
| 286 | - // 渠道编码 | ||
| 287 | - "payCode": null, | ||
| 288 | - } | ||
| 289 | }; | 258 | }; |
| 290 | }, | 259 | }, |
| 291 | created() { | 260 | created() { |
| @@ -312,7 +281,7 @@ export default { | @@ -312,7 +281,7 @@ export default { | ||
| 312 | this.form = { | 281 | this.form = { |
| 313 | id: undefined, | 282 | id: undefined, |
| 314 | name: undefined, | 283 | name: undefined, |
| 315 | - status: undefined, | 284 | + status: CommonStatusEnum.ENABLE, |
| 316 | remark: undefined, | 285 | remark: undefined, |
| 317 | orderNotifyUrl: undefined, | 286 | orderNotifyUrl: undefined, |
| 318 | refundNotifyUrl: undefined, | 287 | refundNotifyUrl: undefined, |
| @@ -397,43 +366,25 @@ export default { | @@ -397,43 +366,25 @@ export default { | ||
| 397 | /** | 366 | /** |
| 398 | * 修改支付渠道信息 | 367 | * 修改支付渠道信息 |
| 399 | */ | 368 | */ |
| 400 | - handleUpdateChannel(row, payCode, type) { | ||
| 401 | - this.settingChannelParam(row, payCode, type) | ||
| 402 | - this.channelParam.edit = true; | ||
| 403 | - this.channelParam.loading = true; | ||
| 404 | - }, | ||
| 405 | - /** | ||
| 406 | - * 新增支付渠道信息 | ||
| 407 | - */ | ||
| 408 | - handleCreateChannel(row, payCode, type) { | ||
| 409 | - this.settingChannelParam(row, payCode, type) | ||
| 410 | - this.channelParam.edit = false; | ||
| 411 | - this.channelParam.loading = false; | ||
| 412 | - }, | ||
| 413 | - /** | ||
| 414 | - * 设置支付渠道信息 | ||
| 415 | - */ | ||
| 416 | - settingChannelParam(row, payCode, type) { | ||
| 417 | - if (type === PayType.WECHAT) { | ||
| 418 | - this.channelParam.wechatOpen = true; | ||
| 419 | - this.channelParam.aliPayOpen = false; | 369 | + handleChannel(row, code) { |
| 370 | + if (code.indexOf('alipay_') === 0) { | ||
| 371 | + this.$refs['alipayChannelFormRef'].open(row.id, code); | ||
| 372 | + return | ||
| 420 | } | 373 | } |
| 421 | - if (type === PayType.ALIPAY) { | ||
| 422 | - console.log(this.$refs['alipayChannelFormRef']) | ||
| 423 | - this.$refs['alipayChannelFormRef'].open(row.id, payCode); | ||
| 424 | - return; | ||
| 425 | - // this.channelParam.aliPayOpen = true; | ||
| 426 | - // this.channelParam.wechatOpen = false; | 374 | + if (code.indexOf('wx_') === 0) { |
| 375 | + this.$refs['weixinChannelFormRef'].open(row.id, code); | ||
| 376 | + return | ||
| 427 | } | 377 | } |
| 428 | }, | 378 | }, |
| 429 | /** | 379 | /** |
| 430 | * 根据渠道编码判断渠道列表中是否存在 | 380 | * 根据渠道编码判断渠道列表中是否存在 |
| 381 | + * | ||
| 431 | * @param channels 渠道列表 | 382 | * @param channels 渠道列表 |
| 432 | * @param channelCode 渠道编码 | 383 | * @param channelCode 渠道编码 |
| 433 | */ | 384 | */ |
| 434 | - judgeChannelExist(channels, channelCode) { | 385 | + isChannelExists(channels, channelCode) { |
| 435 | return channels.indexOf(channelCode) !== -1; | 386 | return channels.indexOf(channelCode) !== -1; |
| 436 | } | 387 | } |
| 437 | } | 388 | } |
| 438 | -}; | 389 | +} |
| 439 | </script> | 390 | </script> |