Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
transport-show-h5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
transport-show-h5
Commits
c8c67f87
提交
c8c67f87
authored
12月 01, 2021
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
对接微信支付
上级
f7ede5c9
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
27 行增加
和
23 行删除
+27
-23
h5Pay.vue
src/pages/buy/components/h5Pay.vue
+25
-19
index.vue
src/pages/buy/index.vue
+2
-4
没有找到文件。
src/pages/buy/components/h5Pay.vue
浏览文件 @
c8c67f87
...
@@ -7,9 +7,6 @@ import * as api from '../api.js'
...
@@ -7,9 +7,6 @@ import * as api from '../api.js'
export
default
{
export
default
{
name
:
'wxPay'
,
name
:
'wxPay'
,
props
:
{
productId
:
{
type
:
String
,
required
:
true
}
},
data
()
{
data
()
{
return
{
return
{
openId
:
''
,
openId
:
''
,
...
@@ -29,7 +26,7 @@ export default {
...
@@ -29,7 +26,7 @@ export default {
methods
:
{
methods
:
{
// 获取openid
// 获取openid
getOpenId
()
{
getOpenId
()
{
api
.
getOpenId
({
id
:
this
.
user
.
id
,
identity
:
'transport'
}).
then
(
response
=>
{
api
.
getOpenId
({
id
:
this
.
user
.
id
,
identity
:
'transport
-mini
'
}).
then
(
response
=>
{
this
.
openId
=
response
.
data
.
openid
this
.
openId
=
response
.
data
.
openid
// 生成订单
// 生成订单
this
.
genOrder
()
this
.
genOrder
()
...
@@ -38,14 +35,22 @@ export default {
...
@@ -38,14 +35,22 @@ export default {
// 生成订单
// 生成订单
genOrder
()
{
genOrder
()
{
const
params
=
{
const
params
=
{
product_id
:
this
.
productId
,
open_id
:
this
.
openId
,
open_id
:
this
.
openId
,
type
:
'certs-h5'
buy_count
:
'1'
,
payment_method
:
'3'
,
shop_id
:
webConf
.
others
.
PAY_SHOP_ID
,
spu_id
:
webConf
.
others
.
PAY_SPU_ID
,
sku_id
:
webConf
.
others
.
PAY_SKU_ID
}
}
api
.
genOrder
(
params
).
then
(
response
=>
{
api
.
createOrder
(
params
).
then
(
response
=>
{
this
.
order
=
response
.
data
if
(
response
.
code
===
0
)
{
// 调起微信支付
const
options
=
JSON
.
parse
(
response
.
payment_more_info
)
this
.
wxPay
()
this
.
order
=
Object
.
assign
(
response
,
{
options
})
// 调起微信支付
this
.
wxPay
()
}
else
{
this
.
$toast
(
response
.
msg
)
}
})
})
},
},
// 微信支付
// 微信支付
...
@@ -53,15 +58,16 @@ export default {
...
@@ -53,15 +58,16 @@ export default {
const
options
=
this
.
order
.
options
const
options
=
this
.
order
.
options
WeixinJSBridge
.
invoke
(
WeixinJSBridge
.
invoke
(
'getBrandWCPayRequest'
,
'getBrandWCPayRequest'
,
{
options
,
appId
:
options
.
appId
,
// 公众号名称,由商户传入
// {
timeStamp
:
options
.
timeStamp
,
// 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
// appId: options.appId, // 公众号名称,由商户传入
nonceStr
:
options
.
nonceStr
,
// 支付签名随机串,不长于 32 位
// timeStamp: options.timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
package
:
`prepay_id=
${
this
.
order
.
prepay_id
}
`
,
// 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
// nonceStr: options.nonceStr, // 支付签名随机串,不长于 32 位
signType
:
options
.
signType
,
// 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
// package: `prepay_id=${this.order.prepay_id}`, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
paySign
:
options
.
paySign
// 支付签名
// signType: options.signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
},
// paySign: options.paySign // 支付签名
function
(
res
)
{
// },
function
(
res
)
{
if
(
res
.
err_msg
===
'get_brand_wcpay_request:ok'
)
{
if
(
res
.
err_msg
===
'get_brand_wcpay_request:ok'
)
{
// 使用以上方式判断前端返回,微信团队郑重提示:
// 使用以上方式判断前端返回,微信团队郑重提示:
// res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
// res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
...
...
src/pages/buy/index.vue
浏览文件 @
c8c67f87
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
<div
class=
"c"
>
199.00
</div>
<div
class=
"c"
>
199.00
</div>
<div
class=
"r"
>
原价999.00
</div>
<div
class=
"r"
>
原价999.00
</div>
</div>
</div>
<div
class=
"new-b"
v-if=
"orderStatus === 0"
>
课程有效期剩余
{{
expireDay
}}
天
</div>
<div
class=
"new-b"
v-if=
"orderStatus === 0"
>
课程有效期剩余
{{
expireDay
}}
天
</div>
</div>
</div>
<div
class=
"btn"
@
click=
"goPay"
v-if=
"orderStatus === 100"
>
立即购买
</div>
<div
class=
"btn"
@
click=
"goPay"
v-if=
"orderStatus === 100"
>
立即购买
</div>
<div
class=
"btn"
v-if=
"orderStatus === 1"
@
click=
"goHome"
>
已购买
</div>
<div
class=
"btn"
v-if=
"orderStatus === 1"
@
click=
"goHome"
>
已购买
</div>
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
/>
/>
</div>
</div>
</div>
</div>
<h5-pay
:productId=
"productId"
ref=
"h5pay"
></h5-pay>
<h5-pay
ref=
"h5pay"
></h5-pay>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
...
@@ -49,9 +49,7 @@ import h5Pay from './components/h5Pay.vue'
...
@@ -49,9 +49,7 @@ import h5Pay from './components/h5Pay.vue'
export
default
{
export
default
{
components
:
{
h5Pay
},
components
:
{
h5Pay
},
data
()
{
data
()
{
const
productId
=
webConf
.
isDev
===
'production'
?
'6684359515615264768'
:
'6682927830365372416'
return
{
return
{
productId
,
popVisible
:
false
,
popVisible
:
false
,
expireDay
:
0
,
expireDay
:
0
,
orderStatusTimer
:
null
,
orderStatusTimer
:
null
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论