商户微信支付设置
This commit is contained in:
parent
22dd33b8c1
commit
d0e2cfd225
@ -26,6 +26,11 @@ export const merchantPageGet = (params) => {
|
||||
* @param {string} data.accountNumber - 银行账号
|
||||
* @param {string} data.businessLicenseUrl - 营业执照URL
|
||||
* @param {string} data.contactPhone - 联系电话
|
||||
* @param {Object} [data.weChatPayConfig] - 微信支付配置
|
||||
* @param {string} data.weChatPayConfig.merchantIdValue - 微信支付商户号
|
||||
* @param {string} data.weChatPayConfig.merchantV3Secret - 微信支付APIv3密钥
|
||||
* @param {string} data.weChatPayConfig.merchantCertificateSerialNumber - 微信支付商户证书序列号
|
||||
* @param {string} data.weChatPayConfig.merchantCertificatePrivateKey - 微信支付商户私钥(PEM格式)
|
||||
*/
|
||||
export const merchantAddPost = (data) => {
|
||||
return http.post('/merchant/add', data);
|
||||
@ -41,6 +46,11 @@ export const merchantAddPost = (data) => {
|
||||
* @param {string} data.businessLicenseUrl - 营业执照URL
|
||||
* @param {string} data.contactPhone - 联系电话
|
||||
* @param {number} data.id - 商户ID
|
||||
* @param {Object} [data.weChatPayConfig] - 微信支付配置
|
||||
* @param {string} data.weChatPayConfig.merchantIdValue - 微信支付商户号
|
||||
* @param {string} data.weChatPayConfig.merchantV3Secret - 微信支付APIv3密钥
|
||||
* @param {string} data.weChatPayConfig.merchantCertificateSerialNumber - 微信支付商户证书序列号
|
||||
* @param {string} data.weChatPayConfig.merchantCertificatePrivateKey - 微信支付商户私钥(PEM格式)
|
||||
*/
|
||||
export const merchantEditPut = (data) => {
|
||||
return http.put('/merchant/edit', data);
|
||||
|
||||
@ -28,9 +28,9 @@
|
||||
</ProTable>
|
||||
|
||||
<!-- 弹窗 -->
|
||||
<el-dialog :title="dialogTitle" v-model="isShowDialog">
|
||||
<el-dialog :title="dialogTitle" v-model="isShowDialog" width="900px">
|
||||
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="200px"
|
||||
style="max-width: 600px;margin-bottom: 30px;" v-if="isShowDialog">
|
||||
style="max-width: 800px;margin-bottom: 30px;" v-if="isShowDialog">
|
||||
|
||||
<!-- 商户名称 -->
|
||||
<el-form-item label="商户名称" prop="merchantName">
|
||||
@ -63,11 +63,32 @@
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 费用 -->
|
||||
<!-- 联系电话 -->
|
||||
<el-form-item label="联系电话" prop="contactPhone">
|
||||
<el-input v-model="formData.contactPhone" placeholder="请输入联系电话" class="fee-input">
|
||||
<template slot="append">元</template>
|
||||
</el-input>
|
||||
<el-input v-model="formData.contactPhone" placeholder="请输入联系电话"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 分隔线 -->
|
||||
<el-divider content-position="left">微信支付配置</el-divider>
|
||||
|
||||
<!-- 微信支付商户号 -->
|
||||
<el-form-item label="微信支付商户号" prop="weChatPayConfig.merchantIdValue">
|
||||
<el-input v-model="formData.weChatPayConfig.merchantIdValue" placeholder="请输入微信支付商户号"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 微信支付APIv3密钥 -->
|
||||
<el-form-item label="微信支付APIv3密钥" prop="weChatPayConfig.merchantV3Secret">
|
||||
<el-input v-model="formData.weChatPayConfig.merchantV3Secret" type="password" show-password placeholder="请输入微信支付APIv3密钥"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 微信支付商户证书序列号 -->
|
||||
<el-form-item label="商户证书序列号" prop="weChatPayConfig.merchantCertificateSerialNumber">
|
||||
<el-input v-model="formData.weChatPayConfig.merchantCertificateSerialNumber" placeholder="请输入微信支付商户证书序列号"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 微信支付商户私钥 -->
|
||||
<el-form-item label="商户私钥(PEM格式)" prop="weChatPayConfig.merchantCertificatePrivateKey">
|
||||
<el-input v-model="formData.weChatPayConfig.merchantCertificatePrivateKey" type="textarea" :rows="4" placeholder="请输入微信支付商户私钥(PEM格式)"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
@ -84,7 +105,8 @@
|
||||
<script setup name="sysMenu">
|
||||
import { defineAsyncComponent, ref, reactive } from 'vue';
|
||||
import { ElMessage, ElForm } from 'element-plus';
|
||||
import { merchantPageGet, merchantAddPost ,merchantEditPut ,merchantDeleteDelete} from '/@/api/match/merchant';
|
||||
import { Plus } from '@element-plus/icons-vue';
|
||||
import { merchantPageGet, merchantAddPost, merchantEditPut, merchantDeletePost, merchantDetailGet } from '/@/api/match/merchant';
|
||||
|
||||
import { auths } from '/@/utils/authFunction';
|
||||
import ProTable from '/@/components/ProTable/index.vue';
|
||||
@ -94,22 +116,31 @@ const formRef = ref();
|
||||
const initParam = ref({
|
||||
refresh: false,
|
||||
});
|
||||
const formData = ref({
|
||||
|
||||
const getDefaultFormData = () => ({
|
||||
id: undefined,
|
||||
merchantName: '',
|
||||
creditCode: '',
|
||||
bankName: '',
|
||||
accountNumber: '',
|
||||
businessLicenseUrl: '',
|
||||
durationMinutes: '',
|
||||
contactPhone: ''
|
||||
})
|
||||
contactPhone: '',
|
||||
weChatPayConfig: {
|
||||
merchantIdValue: '',
|
||||
merchantV3Secret: '',
|
||||
merchantCertificateSerialNumber: '',
|
||||
merchantCertificatePrivateKey: ''
|
||||
}
|
||||
});
|
||||
|
||||
const formData = ref(getDefaultFormData());
|
||||
|
||||
const formRules = ref({
|
||||
merchantName: [
|
||||
{ required: true, message: '请输入商户名称', trigger: 'blur' }
|
||||
],
|
||||
creditCode: [
|
||||
{ required: true, message: '请选择统一社会信用代码', trigger: 'blur' }
|
||||
{ required: true, message: '请输入统一社会信用代码', trigger: 'blur' }
|
||||
],
|
||||
bankName: [
|
||||
{ required: true, message: '请输入开户行', trigger: 'blur' }
|
||||
@ -120,7 +151,9 @@ const formRules = ref({
|
||||
businessLicenseUrl: [
|
||||
{ required: true, message: '请上传营业执照', trigger: 'blur' }
|
||||
],
|
||||
|
||||
contactPhone: [
|
||||
{ required: true, message: '请输入联系电话', trigger: 'blur' }
|
||||
],
|
||||
});
|
||||
|
||||
const columns = ref([
|
||||
@ -149,27 +182,34 @@ const columns = ref([
|
||||
const isShowDialog = ref(false);
|
||||
const dialogTitle = ref('新增');
|
||||
|
||||
const onOpenMenu = (data) => {
|
||||
console.log(data)
|
||||
const onOpenMenu = async (data) => {
|
||||
dialogTitle.value = data ? '编辑' : '新增';
|
||||
if (data) {
|
||||
formData.value = data;
|
||||
} else {
|
||||
formData.value = {
|
||||
merchantName: '',
|
||||
creditCode: '',
|
||||
bankName: '',
|
||||
accountNumber: '',
|
||||
businessLicenseUrl: '',
|
||||
phone: ''
|
||||
};
|
||||
formData.value = getDefaultFormData();
|
||||
if (data && data.id) {
|
||||
try {
|
||||
const res = await merchantDetailGet({ id: data.id });
|
||||
if (res && res.succeeded && res.data) {
|
||||
formData.value = {
|
||||
...getDefaultFormData(),
|
||||
...res.data,
|
||||
weChatPayConfig: res.data.weChatPayConfig || {
|
||||
merchantIdValue: '',
|
||||
merchantV3Secret: '',
|
||||
merchantCertificateSerialNumber: '',
|
||||
merchantCertificatePrivateKey: ''
|
||||
}
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取商户详情失败', error);
|
||||
}
|
||||
}
|
||||
isShowDialog.value = true;
|
||||
};
|
||||
|
||||
//删除菜单
|
||||
const onDeleteMenu = async (id) => {
|
||||
const { succeeded, errors } = await merchantDeleteDelete({ id });
|
||||
const { succeeded, errors } = await merchantDeletePost([id]);
|
||||
if (succeeded) {
|
||||
ElMessage.success('删除成功');
|
||||
initParam.value.refresh = !initParam.value.refresh;
|
||||
@ -180,34 +220,34 @@ const onDeleteMenu = async (id) => {
|
||||
|
||||
const handleAvatarSuccess = (response, uploadFile) => {
|
||||
formData.value.businessLicenseUrl = response[0].url;
|
||||
console.log(response, uploadFile)
|
||||
}
|
||||
|
||||
const beforeAvatarUpload = () => {
|
||||
// if (rawFile.type !== 'image/jpeg') {
|
||||
// ElMessage.error('Avatar picture must be JPG format!')
|
||||
// return false
|
||||
// } else if (rawFile.size / 1024 / 1024 > 2) {
|
||||
// ElMessage.error('Avatar picture size can not exceed 2MB!')
|
||||
// return false
|
||||
// }
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
// 表单提交
|
||||
const onSubmit = () => {
|
||||
console.log(formData.value)
|
||||
if (!formRef.value) return;
|
||||
|
||||
formRef.value.validate(async (valid) => {
|
||||
if (!valid) return;
|
||||
try {
|
||||
// 处理微信支付配置 - 如果都是空的,发送null
|
||||
const weChatPayConfig = formData.value.weChatPayConfig;
|
||||
const hasWeChatPayConfig = weChatPayConfig.merchantIdValue || weChatPayConfig.merchantV3Secret ||
|
||||
weChatPayConfig.merchantCertificateSerialNumber || weChatPayConfig.merchantCertificatePrivateKey;
|
||||
|
||||
const payload = {
|
||||
...formData.value,
|
||||
weChatPayConfig: hasWeChatPayConfig ? weChatPayConfig : null
|
||||
};
|
||||
|
||||
let res;
|
||||
if (formData.value.id) {
|
||||
res = await merchantEditPut(formData.value);
|
||||
res = await merchantEditPut(payload);
|
||||
} else {
|
||||
res = await merchantAddPost(formData.value);
|
||||
res = await merchantAddPost(payload);
|
||||
}
|
||||
|
||||
if (res.succeeded) {
|
||||
@ -233,27 +273,6 @@ const onCancel = () => {
|
||||
margin-top: 80px;
|
||||
}
|
||||
|
||||
/* 时长组合框样式 */
|
||||
.duration-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.duration-row .el-input {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.duration-separator {
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.duration-label {
|
||||
color: #909399;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 350px;
|
||||
}
|
||||
@ -280,4 +299,4 @@ const onCancel = () => {
|
||||
height: 178px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user