Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
ydl-group-course
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄志
ydl-group-course
Commits
8b8a24fe
Commit
8b8a24fe
authored
Mar 07, 2023
by
huangzhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 微信支付
parent
57d42869
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
33 deletions
+51
-33
config.js
src/config.js
+5
-5
my.vue
src/pages/my/my.vue
+12
-10
pay.vue
src/pages/pay/pay.vue
+34
-18
No files found.
src/config.js
View file @
8b8a24fe
...
@@ -6,11 +6,11 @@ let h2Prefix
...
@@ -6,11 +6,11 @@ let h2Prefix
let
ydlH5Prefix
let
ydlH5Prefix
if
(
isDevelopment
)
{
if
(
isDevelopment
)
{
//
hostPrefix = 'https://testnewm.ydl.com'
hostPrefix
=
'https://testnewm.ydl.com'
//
//
hostPrefix = 'http://192.168.211.138'
// hostPrefix = 'http://192.168.211.138'
//
apiPrefix = 'https://testapi.ydl.com'
apiPrefix
=
'https://testapi.ydl.com'
hostPrefix
=
'https://newm-test.ydl.com'
// 下云
//
hostPrefix = 'https://newm-test.ydl.com' // 下云
apiPrefix
=
'https://api-test.ydl.com'
// 下云
//
apiPrefix = 'https://api-test.ydl.com' // 下云
h2Prefix
=
'https://h2.yidianling.com'
h2Prefix
=
'https://h2.yidianling.com'
ydlH5Prefix
=
'https://testh5.ydl.com'
ydlH5Prefix
=
'https://testh5.ydl.com'
}
else
{
}
else
{
...
...
src/pages/my/my.vue
View file @
8b8a24fe
...
@@ -208,18 +208,20 @@ export default {
...
@@ -208,18 +208,20 @@ export default {
},
},
// 跳转订单
// 跳转订单
navigateToOrder
()
{
navigateToOrder
()
{
uni
.
navigateTo
({
// const aa =
url
:
`/pages/pay/pay?title=支付&id=
${
1123
}
`
,
// 'orderId=90230307003008&totalAmount=0.03&balance=9779&payType=5&title=%E6%94%AF%E4%BB%98%E4%B8%AD%E9%97%B4%E9%A1%B5%E9%9D%A2'
})
// if (!this.isLogin) {
// this.handleLogin()
// return
// }
// const url = `${hostPrefix}/h5-course/my/components/Buylist`
// uni.navigateTo({
// uni.navigateTo({
// url: `/pages/
web/web?title=已购订单&loadUrl=${encodeURIComponent(url)
}`,
// url: `/pages/
pay/pay?${aa
}`,
// })
// })
if
(
!
this
.
isLogin
)
{
this
.
handleLogin
()
return
}
const
url
=
`
${
hostPrefix
}
/h5-course/my/components/Buylist`
uni
.
navigateTo
({
url
:
`/pages/web/web?title=已购订单&loadUrl=
${
encodeURIComponent
(
url
)}
`
,
})
},
},
},
},
}
}
...
...
src/pages/pay/pay.vue
View file @
8b8a24fe
...
@@ -10,9 +10,16 @@
...
@@ -10,9 +10,16 @@
import
{
hostPrefix
}
from
'@/config'
import
{
hostPrefix
}
from
'@/config'
import
Decimal
from
'decimal.js'
import
Decimal
from
'decimal.js'
//
要付款的前 要付款totalAmount
//
totalAmount 活动后实际的商品价格
// balance 可用余额
// balance 可用余额
const
computeAmountForCombination
=
(
totalAmount
,
balance
)
=>
{
// payType 微信只有三种支付模式 1: 余额 5: 微信 7: 微信 + 余额
const
computeAmountForCombination
=
(
totalAmount
,
balance
,
payType
)
=>
{
if
(
payType
===
1
)
{
return
{
payAmount
:
0
,
payBalance
:
totalAmount
}
}
if
(
payType
===
5
)
{
return
{
payAmount
:
totalAmount
,
payBalance
:
0
}
}
let
payBalance
=
0
let
payBalance
=
0
let
payAmount
=
0
let
payAmount
=
0
if
(
balance
===
0
)
{
if
(
balance
===
0
)
{
...
@@ -25,7 +32,7 @@ const computeAmountForCombination = (totalAmount, balance) => {
...
@@ -25,7 +32,7 @@ const computeAmountForCombination = (totalAmount, balance) => {
}
else
{
}
else
{
payBalance
=
totalAmount
payBalance
=
totalAmount
}
}
//
真实要额外付款微信,
从余额扣款
//
payAmount 真实要微信付款的钱, payBalance
从余额扣款
return
{
payAmount
,
payBalance
}
return
{
payAmount
,
payBalance
}
}
}
...
@@ -35,18 +42,22 @@ export default {
...
@@ -35,18 +42,22 @@ export default {
return
{
return
{
orderId
:
''
,
// 订单id
orderId
:
''
,
// 订单id
payType
:
1
,
// 支付方式,1: 余额 5: 微信 7: 微信 + 余额
payType
:
1
,
// 支付方式,1: 余额 5: 微信 7: 微信 + 余额
payAmount
:
0
,
// 支付方式 还需支付(除去余额扣款后,微信需要支付)
totalAmount
:
0
,
// 活动后实际的商品价格
payBalance
:
0
,
// 从余额扣款
balance
:
0
,
// 账户余额
loading
:
false
,
loading
:
false
,
openId
:
this
.
$store
.
state
.
user
.
openId
,
buyType
:
1
,
// 1 是拼团购买,其他是 单独或券后购买
}
}
},
},
onLoad
(
options
)
{
onLoad
(
options
)
{
// 赋值
const
{
orderId
,
totalAmount
,
balance
,
payType
}
=
options
const
{
orderId
,
payType
,
payAmount
,
payBalance
}
=
options
this
.
orderId
=
orderId
this
.
orderId
=
orderId
this
.
totalAmount
=
totalAmount
?
Number
(
totalAmount
)
:
0
this
.
balance
=
balance
?
Number
(
balance
)
:
0
this
.
payType
=
Number
(
payType
)
this
.
payType
=
Number
(
payType
)
this
.
payAmount
=
Number
(
payAmount
)
// this.buyType = Number(buyType)
this
.
payBalance
=
Number
(
payBalance
)
// this.payAmount = Number(payAmount)
// this.payBalance = Number(payBalance)
// // 页面访问埋点
// // 页面访问埋点
// setTrackData({
// setTrackData({
// events: [
// events: [
...
@@ -86,24 +97,26 @@ export default {
...
@@ -86,24 +97,26 @@ export default {
// })
// })
this
.
loading
=
true
this
.
loading
=
true
const
{
orderId
,
payType
}
=
this
const
{
o
penId
,
o
rderId
,
payType
}
=
this
// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line no-unused-vars
const
{
payAmount
,
payBalance
}
=
computeAmountForCombination
(
this
.
totalAmount
,
this
.
balance
)
const
{
payAmount
,
payBalance
}
=
computeAmountForCombination
(
this
.
totalAmount
,
this
.
balance
,
this
.
payType
,
)
try
{
try
{
const
wxUrl
=
encodeURIComponent
(
'http://m.ydl.com?backPayId='
+
this
.
payId
)
const
wxUrl
=
encodeURIComponent
(
'http://m.ydl.com?backPayId='
+
this
.
payId
)
const
parmas
=
{
const
parmas
=
{
openId
,
returnUrl
:
wxUrl
,
// 支付完成
returnUrl
:
wxUrl
,
// 支付完成
quitUrl
:
wxUrl
,
// 中断支付
quitUrl
:
wxUrl
,
// 中断支付
orderId
,
orderId
,
payType
,
payType
,
// todo
payAmount
,
// 支付方式 还需支付(除去余额扣款后,微信需要支付)
payAmount
:
0.01
,
payBalance
,
// 从账户余额中要扣款的钱
// payAmount,
payBalance
,
payChannel
:
'WX_MINI_APP'
,
payChannel
:
'WX_MINI_APP'
,
// appId: appId,??
}
}
console
.
log
(
'请求parmas::payAmount'
,
payAmount
)
console
.
log
(
'请求parmas::'
,
parmas
)
console
.
log
(
'请求parmas::'
,
parmas
)
const
res
=
await
this
.
$request
.
post
(
'/auth/cashierV2/unityPay'
,
parmas
,
{
const
res
=
await
this
.
$request
.
post
(
'/auth/cashierV2/unityPay'
,
parmas
,
{
...
@@ -179,7 +192,10 @@ export default {
...
@@ -179,7 +192,10 @@ export default {
title
:
'支付成功'
,
title
:
'支付成功'
,
duration
:
1500
,
duration
:
1500
,
})
})
const
url
=
`
${
hostPrefix
}
/h5-course/pay/groupSuccess`
// 当前只有拼团业务才会被分享出来,在微信小程序中支付
const
url
=
`
${
hostPrefix
}
/h5-course/pay/groupSuccess?ccc=qwe&ttt=123`
uni
.
navigateTo
({
uni
.
navigateTo
({
url
:
`/pages/web/web?title=
${
url
:
`/pages/web/web?title=
${
this
.
doctor
.
name
?
`
${
this
.
doctor
.
name
}
的评价`
:
''
this
.
doctor
.
name
?
`
${
this
.
doctor
.
name
}
的评价`
:
''
...
...
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