Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
project-online-fi
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
project-online-fi
Commits
0c683568
提交
0c683568
authored
11月 25, 2022
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: 修改h5微信支付
上级
08936e03
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
22 行增加
和
7 行删除
+22
-7
usePay.ts
src/modules/pay/composables/usePay.ts
+22
-7
没有找到文件。
src/modules/pay/composables/usePay.ts
浏览文件 @
0c683568
...
...
@@ -18,6 +18,10 @@ export function usePay() {
const
openId
=
useStorage
(
'openId'
,
''
)
const
redirectURL
=
computed
(()
=>
{
return
`
${
location
.
origin
}
/shop/order/
${
shopStore
.
shopItem
?.
id
}
`
})
// 支付
async function pay(options = {}) {
// 默认参数
...
...
@@ -26,7 +30,7 @@ export function usePay() {
spu_id: shopStore.shopItem?.spu_id || '6998525810348916736',
sku_id: shopStore.shopItem?.sku_id || '6998525810365693952',
buy_count: '1',
redirect_url
:
`
${
location
.
origin
}
/shop/order/
${
shopStore
.
shopItem
?.
id
}
`
,
redirect_url:
redirectURL.value
,
notify_url: `
https
:
//ep-lms-api.ezijing.com/v2/student/push?tenant=paa&sso_id=${userStore.user?.id}&class_id=${shopStore.shopItem?.class_id}&course_flag=1&course_id=${shopStore.shopItem?.course_id}`
}
)
const params = Object.assign(defaultParams, options)
...
...
@@ -42,10 +46,20 @@ export function usePay() {
if (!payOrder.value) return
// 网页支付,直接唤起对应支付网页
if (params.payment_method === '
4' || params.payment_method === '
12') {
if (params.payment_method === '12') {
location.href = payOrder.value.payment_url
return
}
// 微信h5支付
if (params.payment_method === '4') {
const paymentUrl = `
$
{
payOrder
.
value
.
payment_url
}
&
redirect_url
=
$
{
encodeURIComponent
(
`https://pages.ezijing.com/base/auth.html?redirect_uri=
${
encodeURIComponent
(
redirectURL
.
value
)}
`
)}
`
location.href = `
https
:
//pages.ezijing.com/base/pay.html?payment_url=${encodeURIComponent(
paymentUrl
)}
&
redirect_url
=
$
{
redirectURL
.
value
}
`
return
}
// 微信JS支付
if (params.payment_method === '3') {
wxJSPay()
...
...
@@ -91,7 +105,7 @@ export function usePay() {
// 获取code
function getCode() {
const href = location.href.includes('?') ? `
$
{
location
.
href
}
&
is_pay
=
true
` : `
$
{
location
.
href
}?
is_pay
=
true
`
const redirectURI = `
https
:
//pages.ezijing.com/
given
/auth.html?redirect_uri=${encodeURIComponent(href)}`
const redirectURI = `
https
:
//pages.ezijing.com/
base
/auth.html?redirect_uri=${encodeURIComponent(href)}`
location
.
href
=
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx451c01d40d090d7a&redirect_uri=
${
redirectURI
}
&response_type=code&scope=snsapi_base`
}
...
...
@@ -113,10 +127,11 @@ export function usePay() {
alert
(
'订单创建错误'
)
return
}
const
payInfo
:
any
=
JSON
.
parse
(
payOrder
.
value
.
payment_more_info
)
;(
window
as
any
).
WeixinJSBridge
?.
invoke
(
'getBrandWCPayRequest'
,
payInfo
,
(
res
:
any
)
=>
{
console
.
log
(
res
)
})
location
.
href
=
`https://pages.ezijing.com/base/pay.html?payment_more_info=
${
payOrder
.
value
.
payment_more_info
}
&redirect_url=
${
redirectURL
.
value
}
`
// const payInfo: any = JSON.parse(payOrder.value.payment_more_info)
// ;(window as any).WeixinJSBridge?.invoke('getBrandWCPayRequest', payInfo, (res: any) => {
// console.log(res)
// })
}
return
{
order
,
payOrder
,
pay
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论