Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b3b1d974
authored
Aug 05, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支付应用:微信支付的添加代码优化
parent
86e0a375
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
68 deletions
+61
-68
src/views/pay/app/components/channel/AlipayChannelForm.vue
+4
-9
src/views/pay/app/components/channel/WeixinChannelForm.vue
+51
-52
src/views/pay/app/index.vue
+6
-7
No files found.
src/views/pay/app/components/channel/AlipayChannelForm.vue
View file @
b3b1d974
<
template
>
<
template
>
<div>
<div>
<Dialog
<Dialog
v-model=
"dialogVisible"
:title=
"dialogTitle"
@
closed=
"close"
width=
"830px"
>
v-model=
"dialogVisible"
:title=
"dialogTitle"
@
closed=
"close"
append-to-body
destroy-on-close
width=
"830px"
>
<el-form
<el-form
ref=
"formRef"
ref=
"formRef"
:model=
"formData"
:model=
"formData"
...
@@ -164,11 +157,13 @@
...
@@ -164,11 +157,13 @@
</Dialog>
</Dialog>
</div>
</div>
</template>
</template>
<
script
lang=
"ts"
setup
name=
"AlipayChannelForm"
>
<
script
lang=
"ts"
setup
>
import
{
CommonStatusEnum
}
from
'@/utils/constants'
import
{
CommonStatusEnum
}
from
'@/utils/constants'
import
{
DICT_TYPE
,
getDictOptions
}
from
'@/utils/dict'
import
{
DICT_TYPE
,
getDictOptions
}
from
'@/utils/dict'
import
*
as
ChannelApi
from
'@/api/pay/channel'
import
*
as
ChannelApi
from
'@/api/pay/channel'
defineOptions
({
name
:
'AlipayChannelForm'
})
const
{
t
}
=
useI18n
()
// 国际化
const
{
t
}
=
useI18n
()
// 国际化
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
...
...
src/views/pay/app/components/
w
eixinChannelForm.vue
→
src/views/pay/app/components/
channel/W
eixinChannelForm.vue
View file @
b3b1d974
<
template
>
<
template
>
<div>
<div>
<el-dialog
<Dialog
v-model=
"dialogVisible"
:title=
"dialogTitle"
@
close=
"close"
width=
"800px"
>
v-model=
"dialogVisible"
:title=
"title"
@
close=
"close"
append-to-body
destroy-on-close
width=
"800px"
>
<el-form
<el-form
ref=
"formRef"
ref=
"formRef"
:model=
"formData"
:model=
"formData"
:rules=
"
r
ules"
:rules=
"
formR
ules"
label-width=
"120px"
label-width=
"120px"
v-loading=
"formLoading"
v-loading=
"formLoading"
>
>
...
@@ -86,7 +79,9 @@
...
@@ -86,7 +79,9 @@
:before-upload=
"p12FileBeforeUpload"
:before-upload=
"p12FileBeforeUpload"
:http-request=
"keyContentUpload"
:http-request=
"keyContentUpload"
>
>
<el-button
size=
"small"
type=
"primary"
icon=
"el-icon-upload"
>
点击上传
</el-button>
<el-button
type=
"primary"
>
<Icon
icon=
"ep:upload"
class=
"mr-5px"
/>
点击上传
</el-button>
</el-upload>
</el-upload>
</el-form-item>
</el-form-item>
</div>
</div>
...
@@ -124,7 +119,9 @@
...
@@ -124,7 +119,9 @@
:before-upload=
"pemFileBeforeUpload"
:before-upload=
"pemFileBeforeUpload"
:http-request=
"privateKeyContentUpload"
:http-request=
"privateKeyContentUpload"
>
>
<el-button
size=
"small"
type=
"primary"
icon=
"el-icon-upload"
>
点击上传
</el-button>
<el-button
type=
"primary"
>
<Icon
icon=
"ep:upload"
class=
"mr-5px"
/>
点击上传
</el-button>
</el-upload>
</el-upload>
</el-form-item>
</el-form-item>
<el-form-item
<el-form-item
...
@@ -150,7 +147,9 @@
...
@@ -150,7 +147,9 @@
:before-upload=
"pemFileBeforeUpload"
:before-upload=
"pemFileBeforeUpload"
:http-request=
"privateCertContentUpload"
:http-request=
"privateCertContentUpload"
>
>
<el-button
size=
"small"
type=
"primary"
icon=
"el-icon-upload"
>
点击上传
</el-button>
<el-button
type=
"primary"
>
<Icon
icon=
"ep:upload"
class=
"mr-5px"
/>
点击上传
</el-button>
</el-upload>
</el-upload>
</el-form-item>
</el-form-item>
</div>
</div>
...
@@ -162,19 +161,22 @@
...
@@ -162,19 +161,22 @@
<el-button
@
click=
"close"
>
取消
</el-button>
<el-button
@
click=
"close"
>
取消
</el-button>
<el-button
type=
"primary"
@
click=
"submitForm"
>
确定
</el-button>
<el-button
type=
"primary"
@
click=
"submitForm"
>
确定
</el-button>
</
template
>
</
template
>
</
el-d
ialog>
</
D
ialog>
</div>
</div>
</template>
</template>
<
script
lang=
"ts"
setup
name=
"WeixinChannelForm"
>
<
script
lang=
"ts"
setup
>
import
{
createChannel
,
getChannel
,
updateChannel
}
from
'@/api/pay/channel'
import
{
CommonStatusEnum
}
from
'@/utils/constants'
import
{
CommonStatusEnum
}
from
'@/utils/constants'
import
{
DICT_TYPE
,
getDictOptions
}
from
'@/utils/dict'
import
{
DICT_TYPE
,
getDictOptions
}
from
'@/utils/dict'
import
*
as
ChannelApi
from
'@/api/pay/channel'
defineOptions
({
name
:
'WeixinChannelForm'
})
const
{
t
}
=
useI18n
()
// 国际化
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
const
dialogVisible
=
ref
(
false
)
const
dialogVisible
=
ref
(
false
)
// 弹窗的是否展示
const
formLoading
=
ref
(
false
)
const
dialogTitle
=
ref
(
''
)
// 弹窗的标题
const
title
=
ref
(
''
)
const
formLoading
=
ref
(
false
)
// 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
const
formData
=
ref
<
any
>
({
const
formData
=
ref
<
any
>
({
appId
:
''
,
appId
:
''
,
code
:
''
,
code
:
''
,
...
@@ -192,11 +194,7 @@ const formData = ref<any>({
...
@@ -192,11 +194,7 @@ const formData = ref<any>({
apiV3Key
:
''
apiV3Key
:
''
}
}
})
})
const
formRef
=
ref
()
const
formRules
=
{
const
emit
=
defineEmits
([
'success'
])
const
rules
=
{
feeRate
:
[{
required
:
true
,
message
:
'请输入渠道费率'
,
trigger
:
'blur'
}],
feeRate
:
[{
required
:
true
,
message
:
'请输入渠道费率'
,
trigger
:
'blur'
}],
status
:
[{
required
:
true
,
message
:
'渠道状态不能为空'
,
trigger
:
'blur'
}],
status
:
[{
required
:
true
,
message
:
'渠道状态不能为空'
,
trigger
:
'blur'
}],
'config.mchId'
:
[{
required
:
true
,
message
:
'请传入商户号'
,
trigger
:
'blur'
}],
'config.mchId'
:
[{
required
:
true
,
message
:
'请传入商户号'
,
trigger
:
'blur'
}],
...
@@ -214,53 +212,56 @@ const rules = {
...
@@ -214,53 +212,56 @@ const rules = {
],
],
'config.apiV3Key'
:
[{
required
:
true
,
message
:
'请上传 api V3 密钥值'
,
trigger
:
'blur'
}]
'config.apiV3Key'
:
[{
required
:
true
,
message
:
'请上传 api V3 密钥值'
,
trigger
:
'blur'
}]
}
}
const
formRef
=
ref
()
// 表单 Ref
/** 打开弹窗 */
const
open
=
async
(
appId
,
code
)
=>
{
const
open
=
async
(
appId
,
code
)
=>
{
dialogVisible
.
value
=
true
dialogVisible
.
value
=
true
formLoading
.
value
=
true
formLoading
.
value
=
true
reset
(
appId
,
code
)
reset
Form
(
appId
,
code
)
// 加载数据
try
{
try
{
const
data
=
await
getChannel
(
appId
,
code
)
const
data
=
await
ChannelApi
.
getChannel
(
appId
,
code
)
if
(
data
&&
data
.
id
)
{
if
(
data
&&
data
.
id
)
{
formData
.
value
=
data
formData
.
value
=
data
formData
.
value
.
config
=
JSON
.
parse
(
data
.
config
)
formData
.
value
.
config
=
JSON
.
parse
(
data
.
config
)
}
}
t
itle
.
value
=
!
formData
.
value
.
id
?
'创建支付渠道'
:
'编辑支付渠道'
dialogT
itle
.
value
=
!
formData
.
value
.
id
?
'创建支付渠道'
:
'编辑支付渠道'
}
finally
{
}
finally
{
formLoading
.
value
=
false
formLoading
.
value
=
false
}
}
}
}
defineExpose
({
open
})
// 提供 open 方法,用于打开弹窗
const
close
=
()
=>
{
/** 提交表单 */
dialogVisible
.
value
=
false
const
emit
=
defineEmits
([
'success'
])
// 定义 success 事件,用于操作成功后的回调
reset
(
undefined
,
undefined
)
}
const
submitForm
=
async
()
=>
{
const
submitForm
=
async
()
=>
{
// 校验表单
if
(
!
formRef
)
return
const
valid
=
await
formRef
.
value
.
validate
()
const
valid
=
await
formRef
.
value
.
validate
()
if
(
!
valid
)
{
if
(
!
valid
)
return
return
// 提交请求
}
formLoading
.
value
=
true
const
data
:
any
=
{
...
formData
.
value
}
try
{
data
.
config
=
JSON
.
stringify
(
formData
.
value
.
config
)
const
data
=
{
...
formData
.
value
}
as
unknown
as
ChannelApi
.
ChannelVO
if
(
!
data
.
id
)
{
data
.
config
=
JSON
.
stringify
(
formData
.
value
.
config
)
createChannel
(
data
).
then
(()
=>
{
if
(
!
data
.
id
)
{
message
.
alertSuccess
(
'新增成功'
)
await
ChannelApi
.
createChannel
(
data
)
emit
(
'success'
)
message
.
success
(
t
(
'common.createSuccess'
))
close
()
}
else
{
})
await
ChannelApi
.
updateChannel
(
data
)
}
else
{
message
.
success
(
t
(
'common.updateSuccess'
))
updateChannel
(
data
).
then
(()
=>
{
}
message
.
alertSuccess
(
'修改成功'
)
dialogVisible
.
value
=
false
emit
(
'success'
)
// 发送操作成功的事件
close
()
emit
(
'success'
)
})
}
finally
{
formLoading
.
value
=
false
}
}
}
}
/** 重置表单 */
/** 重置表单 */
const
reset
=
(
appId
,
code
)
=>
{
const
reset
Form
=
(
appId
,
code
)
=>
{
formData
.
value
=
{
formData
.
value
=
{
appId
:
appId
,
appId
:
appId
,
code
:
code
,
code
:
code
,
...
@@ -338,6 +339,4 @@ const keyContentUpload = (event) => {
...
@@ -338,6 +339,4 @@ const keyContentUpload = (event) => {
}
}
readFile
.
readAsDataURL
(
event
.
file
)
// 读成 base64
readFile
.
readAsDataURL
(
event
.
file
)
// 读成 base64
}
}
defineExpose
({
open
})
</
script
>
</
script
>
src/views/pay/app/index.vue
View file @
b3b1d974
...
@@ -305,11 +305,11 @@
...
@@ -305,11 +305,11 @@
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
{
DICT_TYPE
,
getIntDictOptions
}
from
'@/utils/dict'
import
{
DICT_TYPE
,
getIntDictOptions
}
from
'@/utils/dict'
import
download
from
'@/utils/download'
import
download
from
'@/utils/download'
import
*
as
Paya
ppApi
from
'@/api/pay/app'
import
*
as
A
ppApi
from
'@/api/pay/app'
import
AppForm
from
'./components/AppForm.vue'
import
AppForm
from
'./components/AppForm.vue'
import
{
PayChannelEnum
,
PayType
}
from
'@/utils/constants'
import
{
PayChannelEnum
,
PayType
}
from
'@/utils/constants'
import
AlipayChannelForm
from
'./components/channel/AlipayChannelForm.vue'
import
AlipayChannelForm
from
'./components/channel/AlipayChannelForm.vue'
import
WeixinChannelForm
from
'./components/
w
eixinChannelForm.vue'
import
WeixinChannelForm
from
'./components/
channel/W
eixinChannelForm.vue'
import
MockChannelForm
from
'./components/mockChannelForm.vue'
import
MockChannelForm
from
'./components/mockChannelForm.vue'
import
{
CommonStatusEnum
}
from
'@/utils/constants'
import
{
CommonStatusEnum
}
from
'@/utils/constants'
...
@@ -333,7 +333,6 @@ const queryParams = reactive({
...
@@ -333,7 +333,6 @@ const queryParams = reactive({
remark
:
undefined
,
remark
:
undefined
,
payNotifyUrl
:
undefined
,
payNotifyUrl
:
undefined
,
refundNotifyUrl
:
undefined
,
refundNotifyUrl
:
undefined
,
merchantName
:
undefined
,
createTime
:
[]
createTime
:
[]
})
})
const
queryFormRef
=
ref
()
// 搜索的表单
const
queryFormRef
=
ref
()
// 搜索的表单
...
@@ -343,7 +342,7 @@ const exportLoading = ref(false) // 导出的加载中
...
@@ -343,7 +342,7 @@ const exportLoading = ref(false) // 导出的加载中
const
getList
=
async
()
=>
{
const
getList
=
async
()
=>
{
loading
.
value
=
true
loading
.
value
=
true
try
{
try
{
const
data
=
await
Paya
ppApi
.
getAppPage
(
queryParams
)
const
data
=
await
A
ppApi
.
getAppPage
(
queryParams
)
list
.
value
=
data
.
list
list
.
value
=
data
.
list
total
.
value
=
data
.
total
total
.
value
=
data
.
total
}
finally
{
}
finally
{
...
@@ -368,7 +367,7 @@ const handleStatusChange = async (row: any) => {
...
@@ -368,7 +367,7 @@ const handleStatusChange = async (row: any) => {
let
text
=
row
.
status
===
CommonStatusEnum
.
ENABLE
?
'启用'
:
'停用'
let
text
=
row
.
status
===
CommonStatusEnum
.
ENABLE
?
'启用'
:
'停用'
try
{
try
{
await
message
.
confirm
(
'确认要"'
+
text
+
'""'
+
row
.
name
+
'"应用吗?'
)
await
message
.
confirm
(
'确认要"'
+
text
+
'""'
+
row
.
name
+
'"应用吗?'
)
await
Paya
ppApi
.
changeAppStatus
({
id
:
row
.
id
,
status
:
row
.
status
})
await
A
ppApi
.
changeAppStatus
({
id
:
row
.
id
,
status
:
row
.
status
})
message
.
success
(
text
+
'成功'
)
message
.
success
(
text
+
'成功'
)
}
catch
{
}
catch
{
row
.
status
=
row
.
status
=
...
@@ -393,7 +392,7 @@ const handleDelete = async (id: number) => {
...
@@ -393,7 +392,7 @@ const handleDelete = async (id: number) => {
// 删除的二次确认
// 删除的二次确认
await
message
.
delConfirm
()
await
message
.
delConfirm
()
// 发起删除
// 发起删除
await
Paya
ppApi
.
deleteApp
(
id
)
await
A
ppApi
.
deleteApp
(
id
)
message
.
success
(
t
(
'common.delSuccess'
))
message
.
success
(
t
(
'common.delSuccess'
))
// 刷新列表
// 刷新列表
await
getList
()
await
getList
()
...
@@ -407,7 +406,7 @@ const handleExport = async () => {
...
@@ -407,7 +406,7 @@ const handleExport = async () => {
await
message
.
exportConfirm
()
await
message
.
exportConfirm
()
// 发起导出
// 发起导出
exportLoading
.
value
=
true
exportLoading
.
value
=
true
const
data
=
await
Paya
ppApi
.
exportApp
(
queryParams
)
const
data
=
await
A
ppApi
.
exportApp
(
queryParams
)
download
.
excel
(
data
,
'支付应用信息.xls'
)
download
.
excel
(
data
,
'支付应用信息.xls'
)
}
finally
{
}
finally
{
exportLoading
.
value
=
false
exportLoading
.
value
=
false
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment