Commit 29d61beb1113605a6890844ae40fc14e77ca233a
1 parent
da529851
mall + pay:
1. 简化支付宝支付的配置界面
Showing
3 changed files
with
276 additions
and
306 deletions
yudao-ui-admin/src/views/pay/app/components/aliPayChannelForm.vue deleted
| 1 | -<template> | ||
| 2 | - <div> | ||
| 3 | - <el-dialog :visible.sync="transferParam.aliPayOpen" :title="title" @closed="close" append-to-body width="800px"> | ||
| 4 | - <el-form ref="aliPayForm" :model="form" :rules="rules" size="medium" label-width="100px" | ||
| 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="aliPayConfig.appId"> | ||
| 12 | - <el-input v-model="form.aliPayConfig.appId" placeholder="请输入开放平台APPID" clearable :style="{width: '100%'}"> | ||
| 13 | - </el-input> | ||
| 14 | - </el-form-item> | ||
| 15 | - <el-form-item label-width="180px" label="渠道状态" prop="status"> | ||
| 16 | - <el-radio-group v-model="form.status" size="medium"> | ||
| 17 | - <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" :key="parseInt(dict.value)" :label="parseInt(dict.value)"> | ||
| 18 | - {{ dict.label }} | ||
| 19 | - </el-radio> | ||
| 20 | - </el-radio-group> | ||
| 21 | - </el-form-item> | ||
| 22 | - <el-form-item label-width="180px" label="网关地址" prop="aliPayConfig.serverUrl"> | ||
| 23 | - <el-radio-group v-model="form.aliPayConfig.serverUrl" size="medium"> | ||
| 24 | - <el-radio label="https://openapi.alipay.com/gateway.do">线上环境</el-radio> | ||
| 25 | - <el-radio label="https://openapi-sandbox.dl.alipaydev.com/gateway.do">沙箱环境</el-radio> | ||
| 26 | - </el-radio-group> | ||
| 27 | - </el-form-item> | ||
| 28 | - <el-form-item label-width="180px" label="算法类型" prop="aliPayConfig.signType"> | ||
| 29 | - <el-radio-group v-model="form.aliPayConfig.signType" size="medium"> | ||
| 30 | - <el-radio key="RSA2" label="RSA2">RSA2</el-radio> | ||
| 31 | - </el-radio-group> | ||
| 32 | - </el-form-item> | ||
| 33 | - <el-form-item label-width="180px" label="公钥类型" prop="aliPayConfig.mode"> | ||
| 34 | - <el-radio-group v-model="form.aliPayConfig.mode" size="medium"> | ||
| 35 | - <el-radio key="公钥模式" :label="1">公钥模式</el-radio> | ||
| 36 | - <el-radio key="证书模式" :label="2">证书模式</el-radio> | ||
| 37 | - </el-radio-group> | ||
| 38 | - </el-form-item> | ||
| 39 | - <div v-if="form.aliPayConfig.mode === 1"> | ||
| 40 | - <el-form-item label-width="180px" label="应用私钥" prop="aliPayConfig.privateKey"> | ||
| 41 | - <el-input type="textarea" :autosize="{minRows: 8, maxRows: 8}" v-model="form.aliPayConfig.privateKey" | ||
| 42 | - placeholder="请输入应用私钥" clearable :style="{width: '100%'}"> | ||
| 43 | - </el-input> | ||
| 44 | - </el-form-item> | ||
| 45 | - <el-form-item label-width="180px" label="支付宝公钥" prop="aliPayConfig.alipayPublicKey"> | ||
| 46 | - <el-input | ||
| 47 | - type="textarea" | ||
| 48 | - :autosize="{minRows: 8, maxRows: 8}" | ||
| 49 | - v-model="form.aliPayConfig.alipayPublicKey" | ||
| 50 | - placeholder="请输入支付宝公钥" clearable | ||
| 51 | - :style="{width: '100%'}"> | ||
| 52 | - </el-input> | ||
| 53 | - </el-form-item> | ||
| 54 | - </div> | ||
| 55 | - <div v-if="form.aliPayConfig.mode === 2"> | ||
| 56 | - <el-form-item label-width="180px" label="商户公钥应用证书" prop="aliPayConfig.appCertContent"> | ||
| 57 | - <el-input v-model="form.aliPayConfig.appCertContent" type="textarea" | ||
| 58 | - placeholder="请上传商户公钥应用证书" | ||
| 59 | - readonly :autosize="{minRows: 8, maxRows: 8}" :style="{width: '100%'}"></el-input> | ||
| 60 | - </el-form-item> | ||
| 61 | - <el-form-item label-width="180px" label=""> | ||
| 62 | - <el-upload | ||
| 63 | - action="" | ||
| 64 | - ref="privateKeyContentFile" | ||
| 65 | - :limit="1" | ||
| 66 | - :accept="fileAccept" | ||
| 67 | - :http-request="appCertUpload" | ||
| 68 | - :before-upload="fileBeforeUpload"> | ||
| 69 | - <el-button size="small" type="primary" icon="el-icon-upload">点击上传</el-button> | ||
| 70 | - </el-upload> | ||
| 71 | - </el-form-item> | ||
| 72 | - <el-form-item label-width="180px" label="支付宝公钥证书" prop="aliPayConfig.alipayPublicCertContent"> | ||
| 73 | - <el-input v-model="form.aliPayConfig.alipayPublicCertContent" type="textarea" | ||
| 74 | - placeholder="请上传支付宝公钥证书" | ||
| 75 | - readonly :autosize="{minRows: 8, maxRows: 8}" :style="{width: '100%'}"></el-input> | ||
| 76 | - </el-form-item> | ||
| 77 | - <el-form-item label-width="180px" label=""> | ||
| 78 | - <el-upload | ||
| 79 | - ref="privateCertContentFile" | ||
| 80 | - action="" | ||
| 81 | - :limit="1" | ||
| 82 | - :accept="fileAccept" | ||
| 83 | - :before-upload="fileBeforeUpload" | ||
| 84 | - :http-request="alipayPublicCertUpload"> | ||
| 85 | - <el-button size="small" type="primary" icon="el-icon-upload">点击上传</el-button> | ||
| 86 | - </el-upload> | ||
| 87 | - </el-form-item> | ||
| 88 | - <el-form-item label-width="180px" label="根证书" prop="aliPayConfig.rootCertContent"> | ||
| 89 | - <el-input | ||
| 90 | - v-model="form.aliPayConfig.rootCertContent" | ||
| 91 | - type="textarea" | ||
| 92 | - placeholder="请上传根证书" | ||
| 93 | - readonly :autosize="{minRows: 8, maxRows: 8}" | ||
| 94 | - :style="{width: '100%'}"> | ||
| 95 | - </el-input> | ||
| 96 | - </el-form-item> | ||
| 97 | - <el-form-item label-width="180px" label=""> | ||
| 98 | - <el-upload | ||
| 99 | - ref="privateCertContentFile" | ||
| 100 | - :limit="1" | ||
| 101 | - :accept="fileAccept" | ||
| 102 | - action="" | ||
| 103 | - :before-upload="fileBeforeUpload" | ||
| 104 | - :http-request="rootCertUpload"> | ||
| 105 | - <el-button size="small" type="primary" icon="el-icon-upload">点击上传</el-button> | ||
| 106 | - </el-upload> | ||
| 107 | - </el-form-item> | ||
| 108 | - </div> | ||
| 109 | - <el-form-item label-width="180px" label="备注" prop="remark"> | ||
| 110 | - <el-input v-model="form.remark" :style="{width: '100%'}"></el-input> | ||
| 111 | - </el-form-item> | ||
| 112 | - </el-form> | ||
| 113 | - <div slot="footer" class="dialog-footer"> | ||
| 114 | - <el-button @click="close">取消</el-button> | ||
| 115 | - <el-button type="primary" @click="handleConfirm">确定</el-button> | ||
| 116 | - </div> | ||
| 117 | - </el-dialog> | ||
| 118 | - </div> | ||
| 119 | -</template> | ||
| 120 | -<script> | ||
| 121 | -import {createChannel, getChannel, updateChannel} from "@/api/pay/channel"; | ||
| 122 | - | ||
| 123 | -const defaultForm = { | ||
| 124 | - code: '', | ||
| 125 | - status: null, | ||
| 126 | - remark: '', | ||
| 127 | - feeRate: null, | ||
| 128 | - appId: '', | ||
| 129 | - aliPayConfig: { | ||
| 130 | - appId: '', | ||
| 131 | - serverUrl: null, | ||
| 132 | - signType: '', | ||
| 133 | - mode: null, | ||
| 134 | - privateKey: '', | ||
| 135 | - alipayPublicKey: '', | ||
| 136 | - appCertContent: '', | ||
| 137 | - alipayPublicCertContent: '', | ||
| 138 | - rootCertContent: '' | ||
| 139 | - } | ||
| 140 | -}; | ||
| 141 | - | ||
| 142 | -export default { | ||
| 143 | - name: "aliPayChannelForm", | ||
| 144 | - components: {}, | ||
| 145 | - props: { | ||
| 146 | - // 传输的参数 | ||
| 147 | - transferParam: { | ||
| 148 | - // 加载动画 | ||
| 149 | - "loading": false, | ||
| 150 | - // 是否修改 | ||
| 151 | - "edit": false, | ||
| 152 | - // 是否显示 | ||
| 153 | - "aliPayOpen": false, | ||
| 154 | - // 应用ID | ||
| 155 | - "appId": null, | ||
| 156 | - // 渠道编码 | ||
| 157 | - "payCode": null, | ||
| 158 | - } | ||
| 159 | - }, | ||
| 160 | - data() { | ||
| 161 | - return { | ||
| 162 | - title:'', | ||
| 163 | - form: JSON.parse(JSON.stringify(defaultForm)), | ||
| 164 | - rules: { | ||
| 165 | - feeRate: [{ required: true, message: '请输入渠道费率', trigger: 'blur' }], | ||
| 166 | - status: [{ required: true, message: '渠道状态不能为空', trigger: 'blur' }], | ||
| 167 | - 'aliPayConfig.appId': [{ required: true, message: '请输入开放平台上创建的应用的 ID', trigger: 'blur' }], | ||
| 168 | - 'aliPayConfig.serverUrl': [{ required: true, message: '请传入网关地址', trigger: 'blur' }], | ||
| 169 | - 'aliPayConfig.signType': [{ required: true, message: '请传入签名算法类型', trigger: 'blur' }], | ||
| 170 | - 'aliPayConfig.mode': [{ required: true, message: '公钥类型不能为空', trigger: 'blur'}], | ||
| 171 | - 'aliPayConfig.privateKey': [{ required: true, message: '请输入商户私钥', trigger: 'blur' }], | ||
| 172 | - 'aliPayConfig.alipayPublicKey': [{ required: true, message: '请输入支付宝公钥字符串', trigger: 'blur' }], | ||
| 173 | - 'aliPayConfig.appCertContent': [{ required: true, message: '请上传商户公钥应用证书', trigger: 'blur' }], | ||
| 174 | - 'aliPayConfig.alipayPublicCertContent': [{ required: true, message: '请上传支付宝公钥证书', trigger: 'blur'}], | ||
| 175 | - 'aliPayConfig.rootCertContent': [{ required: true, message: '请上传指定根证书', trigger: 'blur' }], | ||
| 176 | - }, | ||
| 177 | - fileAccept: ".crt", | ||
| 178 | - } | ||
| 179 | - }, | ||
| 180 | - watch: { | ||
| 181 | - transferParam: { | ||
| 182 | - deep: true, // 深度监听 | ||
| 183 | - handler(newVal) { | ||
| 184 | - if (newVal.aliPayOpen) { | ||
| 185 | - this.form.code = newVal.payCode; | ||
| 186 | - this.form.appId = newVal.appId; | ||
| 187 | - // 只有在初次进来为编辑 并且为加载中的时候才回去请求数据 | ||
| 188 | - if (newVal.edit === true && newVal.loading) { | ||
| 189 | - this.title = "编辑支付渠道"; | ||
| 190 | - this.init(); | ||
| 191 | - } else { | ||
| 192 | - this.title = "创建支付渠道"; | ||
| 193 | - } | ||
| 194 | - } | ||
| 195 | - } | ||
| 196 | - } | ||
| 197 | - }, | ||
| 198 | - methods: { | ||
| 199 | - init() { | ||
| 200 | - getChannel(this.transferParam.appId, this.transferParam.payCode) | ||
| 201 | - .then(response => { | ||
| 202 | - this.form.id = response.data.id; | ||
| 203 | - this.form.feeRate = response.data.feeRate; | ||
| 204 | - this.form.status = response.data.status; | ||
| 205 | - this.form.remark = response.data.remark; | ||
| 206 | - | ||
| 207 | - let config = JSON.parse(response.data.config); | ||
| 208 | - this.form.aliPayConfig.appId = config.appId; | ||
| 209 | - this.form.aliPayConfig.serverUrl = config.serverUrl; | ||
| 210 | - this.form.aliPayConfig.signType = config.signType; | ||
| 211 | - this.form.aliPayConfig.mode = config.mode; | ||
| 212 | - this.form.aliPayConfig.privateKey = config.privateKey; | ||
| 213 | - this.form.aliPayConfig.alipayPublicKey = config.alipayPublicKey; | ||
| 214 | - this.form.aliPayConfig.appCertContent = config.appCertContent; | ||
| 215 | - this.form.aliPayConfig.alipayPublicCertContent = config.alipayPublicCertContent; | ||
| 216 | - this.form.aliPayConfig.rootCertContent = config.rootCertContent; | ||
| 217 | - this.transferParam.loading = false; | ||
| 218 | - }) | ||
| 219 | - }, | ||
| 220 | - close() { | ||
| 221 | - this.transferParam.aliPayOpen = false; | ||
| 222 | - this.form = JSON.parse(JSON.stringify(defaultForm)); | ||
| 223 | - }, | ||
| 224 | - handleConfirm() { | ||
| 225 | - this.$refs['aliPayForm'].validate(valid => { | ||
| 226 | - if (!valid) { | ||
| 227 | - return | ||
| 228 | - } | ||
| 229 | - let data = this.form; | ||
| 230 | - data.config = JSON.stringify(this.form.aliPayConfig); | ||
| 231 | - if (this.transferParam.edit) { | ||
| 232 | - updateChannel(data).then(response => { | ||
| 233 | - if (response.code === 0) { | ||
| 234 | - this.$modal.msgSuccess("修改成功"); | ||
| 235 | - this.close(); | ||
| 236 | - } | ||
| 237 | - }) | ||
| 238 | - } else { | ||
| 239 | - createChannel(data).then(response => { | ||
| 240 | - if (response.code === 0) { | ||
| 241 | - this.$modal.msgSuccess("新增成功"); | ||
| 242 | - this.$parent.refreshTable(); | ||
| 243 | - this.close(); | ||
| 244 | - } | ||
| 245 | - }); | ||
| 246 | - } | ||
| 247 | - }); | ||
| 248 | - }, | ||
| 249 | - fileBeforeUpload(file) { | ||
| 250 | - let format = '.' + file.name.split(".")[1]; | ||
| 251 | - if (format !== this.fileAccept) { | ||
| 252 | - this.$message.error('请上传指定格式"' + this.fileAccept + '"文件'); | ||
| 253 | - return false; | ||
| 254 | - } | ||
| 255 | - let isRightSize = file.size / 1024 / 1024 < 2 | ||
| 256 | - if (!isRightSize) { | ||
| 257 | - this.$message.error('文件大小超过 2MB') | ||
| 258 | - } | ||
| 259 | - return isRightSize | ||
| 260 | - }, | ||
| 261 | - appCertUpload(event) { | ||
| 262 | - const readFile = new FileReader() | ||
| 263 | - readFile.onload = (e) => { | ||
| 264 | - this.form.aliPayConfig.appCertContent = e.target.result | ||
| 265 | - } | ||
| 266 | - readFile.readAsText(event.file); | ||
| 267 | - }, | ||
| 268 | - alipayPublicCertUpload(event) { | ||
| 269 | - const readFile = new FileReader() | ||
| 270 | - readFile.onload = (e) => { | ||
| 271 | - this.form.aliPayConfig.alipayPublicCertContent = e.target.result | ||
| 272 | - } | ||
| 273 | - readFile.readAsText(event.file); | ||
| 274 | - }, | ||
| 275 | - rootCertUpload(event) { | ||
| 276 | - const readFile = new FileReader() | ||
| 277 | - readFile.onload = (e) => { | ||
| 278 | - this.form.aliPayConfig.rootCertContent = e.target.result | ||
| 279 | - } | ||
| 280 | - readFile.readAsText(event.file); | ||
| 281 | - }, | ||
| 282 | - | ||
| 283 | - } | ||
| 284 | -} | ||
| 285 | - | ||
| 286 | -</script> | ||
| 287 | -<style scoped> | ||
| 288 | - | ||
| 289 | -</style> |
yudao-ui-admin/src/views/pay/app/components/alipayChannelForm.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div> | ||
| 3 | + <el-dialog :visible.sync="dialogVisible" :title="title" @closed="close" append-to-body width="800px"> | ||
| 4 | + <el-form ref="form" :model="formData" :rules="rules" size="medium" label-width="100px" v-loading="formLoading"> | ||
| 5 | + <el-form-item label-width="180px" label="渠道费率" prop="feeRate"> | ||
| 6 | + <el-input v-model="formData.feeRate" placeholder="请输入渠道费率" clearable :style="{width: '100%'}"> | ||
| 7 | + <template slot="append">%</template> | ||
| 8 | + </el-input> | ||
| 9 | + </el-form-item> | ||
| 10 | + <el-form-item label-width="180px" label="开放平台 APPID" prop="config.appId"> | ||
| 11 | + <el-input v-model="formData.config.appId" placeholder="请输入开放平台 APPID" clearable :style="{width: '100%'}"> | ||
| 12 | + </el-input> | ||
| 13 | + </el-form-item> | ||
| 14 | + <el-form-item label-width="180px" label="渠道状态" prop="status"> | ||
| 15 | + <el-radio-group v-model="formData.status" size="medium"> | ||
| 16 | + <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" :key="parseInt(dict.value)" | ||
| 17 | + :label="parseInt(dict.value)"> | ||
| 18 | + {{ dict.label }} | ||
| 19 | + </el-radio> | ||
| 20 | + </el-radio-group> | ||
| 21 | + </el-form-item> | ||
| 22 | + <el-form-item label-width="180px" label="网关地址" prop="config.serverUrl"> | ||
| 23 | + <el-radio-group v-model="formData.config.serverUrl" size="medium"> | ||
| 24 | + <el-radio label="https://openapi.alipay.com/gateway.do">线上环境</el-radio> | ||
| 25 | + <el-radio label="https://openapi-sandbox.dl.alipaydev.com/gateway.do">沙箱环境</el-radio> | ||
| 26 | + </el-radio-group> | ||
| 27 | + </el-form-item> | ||
| 28 | + <el-form-item label-width="180px" label="算法类型" prop="config.signType"> | ||
| 29 | + <el-radio-group v-model="formData.config.signType" size="medium"> | ||
| 30 | + <el-radio key="RSA2" label="RSA2">RSA2</el-radio> | ||
| 31 | + </el-radio-group> | ||
| 32 | + </el-form-item> | ||
| 33 | + <el-form-item label-width="180px" label="公钥类型" prop="config.mode"> | ||
| 34 | + <el-radio-group v-model="formData.config.mode" size="medium"> | ||
| 35 | + <el-radio key="公钥模式" :label="1">公钥模式</el-radio> | ||
| 36 | + <el-radio key="证书模式" :label="2">证书模式</el-radio> | ||
| 37 | + </el-radio-group> | ||
| 38 | + </el-form-item> | ||
| 39 | + <div v-if="formData.config.mode === 1"> | ||
| 40 | + <el-form-item label-width="180px" label="应用私钥" prop="config.privateKey"> | ||
| 41 | + <el-input type="textarea" :autosize="{minRows: 8, maxRows: 8}" v-model="formData.config.privateKey" | ||
| 42 | + placeholder="请输入应用私钥" clearable :style="{width: '100%'}"> | ||
| 43 | + </el-input> | ||
| 44 | + </el-form-item> | ||
| 45 | + <el-form-item label-width="180px" label="支付宝公钥" prop="config.alipayPublicKey"> | ||
| 46 | + <el-input | ||
| 47 | + type="textarea" | ||
| 48 | + :autosize="{minRows: 8, maxRows: 8}" | ||
| 49 | + v-model="formData.config.alipayPublicKey" | ||
| 50 | + placeholder="请输入支付宝公钥" clearable | ||
| 51 | + :style="{width: '100%'}"> | ||
| 52 | + </el-input> | ||
| 53 | + </el-form-item> | ||
| 54 | + </div> | ||
| 55 | + <div v-if="formData.config.mode === 2"> | ||
| 56 | + <el-form-item label-width="180px" label="商户公钥应用证书" prop="config.appCertContent"> | ||
| 57 | + <el-input v-model="formData.config.appCertContent" type="textarea" | ||
| 58 | + placeholder="请上传商户公钥应用证书" | ||
| 59 | + readonly :autosize="{minRows: 8, maxRows: 8}" :style="{width: '100%'}"></el-input> | ||
| 60 | + </el-form-item> | ||
| 61 | + <el-form-item label-width="180px" label=""> | ||
| 62 | + <el-upload | ||
| 63 | + action="" | ||
| 64 | + ref="privateKeyContentFile" | ||
| 65 | + :limit="1" | ||
| 66 | + :accept="fileAccept" | ||
| 67 | + :http-request="appCertUpload" | ||
| 68 | + :before-upload="fileBeforeUpload"> | ||
| 69 | + <el-button size="small" type="primary" icon="el-icon-upload">点击上传</el-button> | ||
| 70 | + </el-upload> | ||
| 71 | + </el-form-item> | ||
| 72 | + <el-form-item label-width="180px" label="支付宝公钥证书" prop="config.alipayPublicCertContent"> | ||
| 73 | + <el-input v-model="formData.config.alipayPublicCertContent" type="textarea" | ||
| 74 | + placeholder="请上传支付宝公钥证书" | ||
| 75 | + readonly :autosize="{minRows: 8, maxRows: 8}" :style="{width: '100%'}"></el-input> | ||
| 76 | + </el-form-item> | ||
| 77 | + <el-form-item label-width="180px" label=""> | ||
| 78 | + <el-upload | ||
| 79 | + ref="privateCertContentFile" | ||
| 80 | + action="" | ||
| 81 | + :limit="1" | ||
| 82 | + :accept="fileAccept" | ||
| 83 | + :before-upload="fileBeforeUpload" | ||
| 84 | + :http-request="alipayPublicCertUpload"> | ||
| 85 | + <el-button size="small" type="primary" icon="el-icon-upload">点击上传</el-button> | ||
| 86 | + </el-upload> | ||
| 87 | + </el-form-item> | ||
| 88 | + <el-form-item label-width="180px" label="根证书" prop="config.rootCertContent"> | ||
| 89 | + <el-input | ||
| 90 | + v-model="formData.config.rootCertContent" | ||
| 91 | + type="textarea" | ||
| 92 | + placeholder="请上传根证书" | ||
| 93 | + readonly :autosize="{minRows: 8, maxRows: 8}" | ||
| 94 | + :style="{width: '100%'}"> | ||
| 95 | + </el-input> | ||
| 96 | + </el-form-item> | ||
| 97 | + <el-form-item label-width="180px" label=""> | ||
| 98 | + <el-upload | ||
| 99 | + ref="privateCertContentFile" | ||
| 100 | + :limit="1" | ||
| 101 | + :accept="fileAccept" | ||
| 102 | + action="" | ||
| 103 | + :before-upload="fileBeforeUpload" | ||
| 104 | + :http-request="rootCertUpload"> | ||
| 105 | + <el-button size="small" type="primary" icon="el-icon-upload">点击上传</el-button> | ||
| 106 | + </el-upload> | ||
| 107 | + </el-form-item> | ||
| 108 | + </div> | ||
| 109 | + <el-form-item label-width="180px" label="备注" prop="remark"> | ||
| 110 | + <el-input v-model="formData.remark" :style="{width: '100%'}"></el-input> | ||
| 111 | + </el-form-item> | ||
| 112 | + </el-form> | ||
| 113 | + <div slot="footer" class="dialog-footer"> | ||
| 114 | + <el-button @click="close">取消</el-button> | ||
| 115 | + <el-button type="primary" @click="submitForm">确定</el-button> | ||
| 116 | + </div> | ||
| 117 | + </el-dialog> | ||
| 118 | + </div> | ||
| 119 | +</template> | ||
| 120 | +<script> | ||
| 121 | +import { createChannel, getChannel, updateChannel } from "@/api/pay/channel"; | ||
| 122 | +import { CommonStatusEnum } from "@/utils/constants"; | ||
| 123 | + | ||
| 124 | +export default { | ||
| 125 | + name: "alipayChannelForm", | ||
| 126 | + data() { | ||
| 127 | + return { | ||
| 128 | + dialogVisible: false, | ||
| 129 | + formLoading: false, | ||
| 130 | + title:'', | ||
| 131 | + formData: { | ||
| 132 | + appId: '', | ||
| 133 | + code: '', | ||
| 134 | + status: undefined, | ||
| 135 | + feeRate: undefined, | ||
| 136 | + remark: '', | ||
| 137 | + config: { | ||
| 138 | + appId: '', | ||
| 139 | + serverUrl: null, | ||
| 140 | + signType: '', | ||
| 141 | + mode: null, | ||
| 142 | + privateKey: '', | ||
| 143 | + alipayPublicKey: '', | ||
| 144 | + appCertContent: '', | ||
| 145 | + alipayPublicCertContent: '', | ||
| 146 | + rootCertContent: '' | ||
| 147 | + } | ||
| 148 | + }, | ||
| 149 | + rules: { | ||
| 150 | + feeRate: [{ required: true, message: '请输入渠道费率', trigger: 'blur' }], | ||
| 151 | + status: [{ required: true, message: '渠道状态不能为空', trigger: 'blur' }], | ||
| 152 | + 'config.appId': [{ required: true, message: '请输入开放平台上创建的应用的 ID', trigger: 'blur' }], | ||
| 153 | + 'config.serverUrl': [{ required: true, message: '请传入网关地址', trigger: 'blur' }], | ||
| 154 | + 'config.signType': [{ required: true, message: '请传入签名算法类型', trigger: 'blur' }], | ||
| 155 | + 'config.mode': [{ required: true, message: '公钥类型不能为空', trigger: 'blur'}], | ||
| 156 | + 'config.privateKey': [{ required: true, message: '请输入商户私钥', trigger: 'blur' }], | ||
| 157 | + 'config.alipayPublicKey': [{ required: true, message: '请输入支付宝公钥字符串', trigger: 'blur' }], | ||
| 158 | + 'config.appCertContent': [{ required: true, message: '请上传商户公钥应用证书', trigger: 'blur' }], | ||
| 159 | + 'config.alipayPublicCertContent': [{ required: true, message: '请上传支付宝公钥证书', trigger: 'blur'}], | ||
| 160 | + 'config.rootCertContent': [{ required: true, message: '请上传指定根证书', trigger: 'blur' }], | ||
| 161 | + }, | ||
| 162 | + fileAccept: ".crt", | ||
| 163 | + } | ||
| 164 | + }, | ||
| 165 | + methods: { | ||
| 166 | + open(appId, code) { | ||
| 167 | + this.dialogVisible = true; | ||
| 168 | + this.formLoading = true; | ||
| 169 | + this.reset(appId, code); | ||
| 170 | + getChannel(appId, code).then(response => { | ||
| 171 | + if (response.data && response.data.id) { | ||
| 172 | + this.formData = response.data; | ||
| 173 | + this.formData.config = JSON.parse(response.data.config); | ||
| 174 | + } | ||
| 175 | + this.title = this.formData.id ? '创建支付渠道' : '编辑支付渠道' | ||
| 176 | + }).finally(() => { | ||
| 177 | + this.formLoading = false; | ||
| 178 | + }); | ||
| 179 | + }, | ||
| 180 | + close() { | ||
| 181 | + this.dialogVisible = false; | ||
| 182 | + this.reset(undefined, undefined); | ||
| 183 | + }, | ||
| 184 | + submitForm() { | ||
| 185 | + this.$refs['form'].validate(valid => { | ||
| 186 | + if (!valid) { | ||
| 187 | + return | ||
| 188 | + } | ||
| 189 | + const data = { ...this.formData }; | ||
| 190 | + data.config = JSON.stringify(this.formData.config); | ||
| 191 | + if (!data.id) { | ||
| 192 | + createChannel(data).then(response => { | ||
| 193 | + this.$modal.msgSuccess("新增成功"); | ||
| 194 | + this.$emit('success') | ||
| 195 | + this.close(); | ||
| 196 | + }); | ||
| 197 | + } else { | ||
| 198 | + updateChannel(data).then(response => { | ||
| 199 | + this.$modal.msgSuccess("修改成功"); | ||
| 200 | + this.$emit('success') | ||
| 201 | + this.close(); | ||
| 202 | + }) | ||
| 203 | + } | ||
| 204 | + }); | ||
| 205 | + }, | ||
| 206 | + /** 重置表单 */ | ||
| 207 | + reset(appId, code) { | ||
| 208 | + this.formData = { | ||
| 209 | + appId: appId, | ||
| 210 | + code: code, | ||
| 211 | + status: CommonStatusEnum.ENABLE, | ||
| 212 | + remark: '', | ||
| 213 | + feeRate: null, | ||
| 214 | + config: { | ||
| 215 | + appId: '', | ||
| 216 | + serverUrl: null, | ||
| 217 | + signType: 'RSA2', | ||
| 218 | + mode: null, | ||
| 219 | + privateKey: '', | ||
| 220 | + alipayPublicKey: '', | ||
| 221 | + appCertContent: '', | ||
| 222 | + alipayPublicCertContent: '', | ||
| 223 | + rootCertContent: '' | ||
| 224 | + } | ||
| 225 | + } | ||
| 226 | + this.resetForm('form') | ||
| 227 | + }, | ||
| 228 | + fileBeforeUpload(file) { | ||
| 229 | + let format = '.' + file.name.split(".")[1]; | ||
| 230 | + if (format !== this.fileAccept) { | ||
| 231 | + this.$message.error('请上传指定格式"' + this.fileAccept + '"文件'); | ||
| 232 | + return false; | ||
| 233 | + } | ||
| 234 | + let isRightSize = file.size / 1024 / 1024 < 2 | ||
| 235 | + if (!isRightSize) { | ||
| 236 | + this.$message.error('文件大小超过 2MB') | ||
| 237 | + } | ||
| 238 | + return isRightSize | ||
| 239 | + }, | ||
| 240 | + appCertUpload(event) { | ||
| 241 | + const readFile = new FileReader() | ||
| 242 | + readFile.onload = (e) => { | ||
| 243 | + this.formData.config.appCertContent = e.target.result | ||
| 244 | + } | ||
| 245 | + readFile.readAsText(event.file); | ||
| 246 | + }, | ||
| 247 | + alipayPublicCertUpload(event) { | ||
| 248 | + const readFile = new FileReader() | ||
| 249 | + readFile.onload = (e) => { | ||
| 250 | + this.formData.config.alipayPublicCertContent = e.target.result | ||
| 251 | + } | ||
| 252 | + readFile.readAsText(event.file); | ||
| 253 | + }, | ||
| 254 | + rootCertUpload(event) { | ||
| 255 | + const readFile = new FileReader() | ||
| 256 | + readFile.onload = (e) => { | ||
| 257 | + this.formData.config.rootCertContent = e.target.result | ||
| 258 | + } | ||
| 259 | + readFile.readAsText(event.file); | ||
| 260 | + }, | ||
| 261 | + | ||
| 262 | + } | ||
| 263 | +} | ||
| 264 | + | ||
| 265 | +</script> | ||
| 266 | +<style scoped> | ||
| 267 | + | ||
| 268 | +</style> |
yudao-ui-admin/src/views/pay/app/index.vue
| @@ -216,7 +216,7 @@ | @@ -216,7 +216,7 @@ | ||
| 216 | 216 | ||
| 217 | <!-- 弹窗 --> | 217 | <!-- 弹窗 --> |
| 218 | <wechat-channel-form :transferParam="channelParam" /> | 218 | <wechat-channel-form :transferParam="channelParam" /> |
| 219 | - <ali-pay-channel-form :transferParam="channelParam"></ali-pay-channel-form> | 219 | + <alipay-channel-form ref="alipayChannelFormRef" @success="getList" /> |
| 220 | </div> | 220 | </div> |
| 221 | </template> | 221 | </template> |
| 222 | 222 | ||
| @@ -225,13 +225,13 @@ import { createApp, updateApp, changeAppStatus, deleteApp, getApp, getAppPage } | @@ -225,13 +225,13 @@ import { createApp, updateApp, changeAppStatus, deleteApp, getApp, getAppPage } | ||
| 225 | import { DICT_TYPE, getDictDatas } from "@/utils/dict"; | 225 | import { DICT_TYPE, getDictDatas } from "@/utils/dict"; |
| 226 | import { PayType, PayChannelEnum, CommonStatusEnum } from "@/utils/constants"; | 226 | import { PayType, PayChannelEnum, CommonStatusEnum } from "@/utils/constants"; |
| 227 | import wechatChannelForm from "@/views/pay/app/components/wechatChannelForm"; | 227 | import wechatChannelForm from "@/views/pay/app/components/wechatChannelForm"; |
| 228 | -import aliPayChannelForm from "@/views/pay/app/components/aliPayChannelForm"; | 228 | +import alipayChannelForm from "@/views/pay/app/components/alipayChannelForm"; |
| 229 | 229 | ||
| 230 | export default { | 230 | export default { |
| 231 | name: "PayApp", | 231 | name: "PayApp", |
| 232 | components: { | 232 | components: { |
| 233 | "wechatChannelForm": wechatChannelForm, | 233 | "wechatChannelForm": wechatChannelForm, |
| 234 | - "aliPayChannelForm": aliPayChannelForm | 234 | + "alipayChannelForm": alipayChannelForm |
| 235 | }, | 235 | }, |
| 236 | data() { | 236 | data() { |
| 237 | return { | 237 | return { |
| @@ -285,13 +285,6 @@ export default { | @@ -285,13 +285,6 @@ export default { | ||
| 285 | "appId": null, | 285 | "appId": null, |
| 286 | // 渠道编码 | 286 | // 渠道编码 |
| 287 | "payCode": null, | 287 | "payCode": null, |
| 288 | - // 商户对象 | ||
| 289 | - "payMerchant": { | ||
| 290 | - // 编号 | ||
| 291 | - "id": null, | ||
| 292 | - // 名称 | ||
| 293 | - "name": null | ||
| 294 | - }, | ||
| 295 | } | 288 | } |
| 296 | }; | 289 | }; |
| 297 | }, | 290 | }, |
| @@ -426,14 +419,12 @@ export default { | @@ -426,14 +419,12 @@ export default { | ||
| 426 | this.channelParam.aliPayOpen = false; | 419 | this.channelParam.aliPayOpen = false; |
| 427 | } | 420 | } |
| 428 | if (type === PayType.ALIPAY) { | 421 | if (type === PayType.ALIPAY) { |
| 429 | - this.channelParam.aliPayOpen = true; | ||
| 430 | - this.channelParam.wechatOpen = false; | 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; | ||
| 431 | } | 427 | } |
| 432 | - this.channelParam.edit = false; | ||
| 433 | - this.channelParam.loading = false; | ||
| 434 | - this.channelParam.appId = row.id; | ||
| 435 | - this.channelParam.payCode = payCode; | ||
| 436 | - this.channelParam.payMerchant = row.payMerchant; | ||
| 437 | }, | 428 | }, |
| 438 | /** | 429 | /** |
| 439 | * 根据渠道编码判断渠道列表中是否存在 | 430 | * 根据渠道编码判断渠道列表中是否存在 |