Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
study
Project
Project
Details
Activity
Releases
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
Damon
study
Commits
cce6118d
Commit
cce6118d
authored
Jul 20, 2021
by
Damon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore(pay): appID && Key更新
parent
c2d15fe7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
83 deletions
+64
-83
manifest.json
src/manifest.json
+1
-1
detail copy.vue
src/pages/learn/detail copy.vue
+0
-81
detail.vue
src/pages/learn/detail.vue
+63
-1
No files found.
src/manifest.json
View file @
cce6118d
...
...
@@ -55,7 +55,7 @@
/*
快应用特有相关
*/
"mp-weixin"
:
{
/*
微信小程序特有相关
*/
"appid"
:
"wx
d1d6eede324b0465
"
,
"appid"
:
"wx
4bd80cf10c2a1d14
"
,
"setting"
:
{
"urlCheck"
:
false
,
"es6"
:
true
...
...
src/pages/learn/detail copy.vue
deleted
100644 → 0
View file @
c2d15fe7
<
template
>
<view>
<u-button
type=
"primary"
@
click=
"payOrder"
>
微信支付测试
</u-button>
</view>
</
template
>
<
script
>
import
md5
from
'@/common/md5.js'
export
default
{
components
:
{},
data
()
{
return
{
lists
:
[
{
questionWarehouseId
:
1
,
amount
:
0.01
,
count
:
1
,
},
],
}
},
methods
:
{
payOrder
()
{
const
data
=
{
instrtutionId
:
1
,
orders
:
JSON
.
stringify
(
this
.
lists
),
openId
:
this
.
openId
,
}
this
.
$u
.
api
.
payOrder
(
data
).
then
((
res
)
=>
{
this
.
pay
(
res
)
})
},
pay
(
data
)
{
const
timeStamp
=
String
(
Date
.
now
())
const
paySign
=
md5
.
hexMD5
(
`appId=wxd1d6eede324b0465&nonceStr=
${
data
.
nonce_str
}
&package=prepay_id=
${
data
.
prepay_id
}
&signType=MD5&timeStamp=
${
timeStamp
}
&key=weixiuhui20151a2b3c4d5e6f7g8h9ij`
)
.
toUpperCase
()
uni
.
requestPayment
({
provider
:
'wxpay'
,
timeStamp
:
timeStamp
,
nonceStr
:
data
.
nonce_str
,
package
:
`prepay_id=
${
data
.
prepay_id
}
`
,
signType
:
'MD5'
,
paySign
:
paySign
,
success
:
(
res
)
=>
{
console
.
log
(
'success:'
+
JSON
.
stringify
(
res
))
this
.
checkPayStatus
(
data
.
out_trade_no
)
},
fail
:
(
err
)
=>
{
console
.
log
(
'fail:'
+
JSON
.
stringify
(
err
))
if
(
err
.
errMsg
===
'requestPayment:fail cancel'
)
{
this
.
$u
.
toast
(
'取消支付'
)
}
else
{
this
.
checkPayStatus
(
data
.
out_trade_no
)
}
},
})
},
checkPayStatus
(
no
)
{
const
params
=
{
outTradeNo
:
no
}
this
.
$u
.
api
.
payQuery
(
params
).
then
(
res
=>
{
if
(
res
.
trade_state
===
'SUCCESS'
)
{
this
.
$u
.
toast
(
'支付成功'
)
}
else
if
(
res
.
trade_state
===
'NOTPAY'
)
{
this
.
$u
.
toast
(
'请稍后核实订单状态,不要重复发起支付'
)
}
else
if
(
res
.
trade_state
===
'PAYERROR'
)
{
this
.
$u
.
toast
(
'支付失败'
)
}
else
{
this
.
$u
.
toast
(
res
.
trade_state_desc
)
}
})
}
},
}
</
script
>
<
style
lang=
"scss"
scoped
></
style
>
src/pages/learn/detail.vue
View file @
cce6118d
...
...
@@ -87,6 +87,7 @@
</
template
>
<
script
>
import
md5
from
'@/common/md5.js'
export
default
{
data
()
{
return
{
...
...
@@ -99,6 +100,13 @@ export default {
trueOrFalse
:
526
,
total
:
986
,
},
lists
:
[
{
questionWarehouseId
:
1
,
amount
:
0.01
,
count
:
1
,
},
],
}
},
...
...
@@ -179,7 +187,61 @@ export default {
url
:
'/pages/index/index'
,
})
},
handleClickBuy
()
{},
handleClickBuy
()
{
const
data
=
{
instrtutionId
:
1
,
orders
:
JSON
.
stringify
(
this
.
lists
),
openId
:
this
.
openId
,
}
this
.
$u
.
api
.
payOrder
(
data
).
then
((
res
)
=>
{
this
.
pay
(
res
)
})
},
pay
(
data
)
{
const
timeStamp
=
String
(
Date
.
now
())
const
paySign
=
md5
.
hexMD5
(
`appId=wx4bd80cf10c2a1d14&nonceStr=
${
data
.
nonce_str
}
&package=prepay_id=
${
data
.
prepay_id
}
&signType=MD5&timeStamp=
${
timeStamp
}
&key=304b5d1810e481224d4a9199e8ba6c6e`
)
.
toUpperCase
()
uni
.
requestPayment
({
provider
:
'wxpay'
,
timeStamp
:
timeStamp
,
nonceStr
:
data
.
nonce_str
,
package
:
`prepay_id=
${
data
.
prepay_id
}
`
,
signType
:
'MD5'
,
paySign
:
paySign
,
success
:
(
res
)
=>
{
console
.
log
(
'success:'
+
JSON
.
stringify
(
res
))
this
.
checkPayStatus
(
data
.
out_trade_no
)
},
fail
:
(
err
)
=>
{
console
.
log
(
'fail:'
+
JSON
.
stringify
(
err
))
if
(
err
.
errMsg
===
'requestPayment:fail cancel'
)
{
this
.
$u
.
toast
(
'取消支付'
)
}
else
{
this
.
checkPayStatus
(
data
.
out_trade_no
)
}
},
})
},
checkPayStatus
(
no
)
{
const
params
=
{
outTradeNo
:
no
}
this
.
$u
.
api
.
payQuery
(
params
).
then
(
res
=>
{
if
(
res
.
trade_state
===
'SUCCESS'
)
{
this
.
$u
.
toast
(
'支付成功'
)
}
else
if
(
res
.
trade_state
===
'NOTPAY'
)
{
this
.
$u
.
toast
(
'请稍后核实订单状态,不要重复发起支付'
)
}
else
if
(
res
.
trade_state
===
'PAYERROR'
)
{
this
.
$u
.
toast
(
'支付失败'
)
}
else
{
this
.
$u
.
toast
(
res
.
trade_state_desc
)
}
})
}
},
}
</
script
>
...
...
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