Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mayi-mp-shop
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
程默
mayi-mp-shop
Commits
db351fea
Commit
db351fea
authored
Jul 15, 2020
by
李嘉林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支付功能
parent
bd5297f9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
11 deletions
+68
-11
src/api/order.js
+1
-1
src/pages/contact/index.vue
+7
-3
src/pages/wxPay/index.vue
+60
-7
No files found.
src/api/order.js
View file @
db351fea
...
...
@@ -4,6 +4,6 @@ import { requestPOST, requestGET } from "@/utils/request.js";
export
default
{
//登录
orderDetail
(
options
)
{
return
request
GET
(
`
${
process
.
env
.
OLSHOP_URL
}
/order/detail`
,
options
);
return
request
POST
(
`
${
process
.
env
.
OLSHOP_URL
}
/order/detail?orderSn=
${
options
}
`
);
}
};
src/pages/contact/index.vue
View file @
db351fea
...
...
@@ -6,10 +6,10 @@
<div
class=
"btn-wrap"
>
<button
open-type=
"contact"
>
<div
class=
"btn-main"
>
<div
class=
"main-img"
>
<div
class=
"main-img"
v-if=
"!isTT"
>
<img
src=
"../../../static/images/wx.png"
alt=
""
>
</div>
<div
class=
"main-text"
>
官方
微信
客服
</div>
<div
class=
"main-text"
>
官方
{{
!
isTT
?
'微信'
:
''
}}
客服
</div>
</div>
<img
class=
"btn-next"
src=
"../../../static/images/next.png"
alt=
""
>
</button>
...
...
@@ -19,7 +19,11 @@
<
script
>
export
default
{
data
(){
return
{
isTT
:
MINI_ENV
==
'tt'
,
}
}
}
</
script
>
...
...
src/pages/wxPay/index.vue
View file @
db351fea
...
...
@@ -155,6 +155,7 @@ export default {
},
// 头条支付
toTtPay
(
orderInfo
){
let
_this
=
this
;
console
.
log
(
orderInfo
,
'---orderInfo'
)
tt
.
pay
({
orderInfo
,
...
...
@@ -163,6 +164,7 @@ export default {
default_pay_channel
:
"wx"
,
// wx || alipay
},
getOrderStatus
(
res
)
{
console
.
log
(
res
,
'------------------------167'
)
let
{
out_order_no
}
=
res
;
return
new
Promise
(
function
(
resolve
,
reject
)
{
// 商户前端根据 out_order_no 请求商户后端查询微信支付订单状态
...
...
@@ -170,8 +172,20 @@ export default {
orderSn
:
out_order_no
,
}
order
.
orderDetail
(
query
).
then
(
res
=>
{
console
.
log
(
res
.
data
,
"------------------------174"
)
if
(
res
.
data
.
code
==
200
){
console
.
log
(
res
.
data
.
data
,
'------------------订单信息'
)
let
code
=
""
;
if
(
res
.
data
.
data
){
let
{
paymentStatus
}
=
res
.
data
.
data
;
if
(
paymentStatus
==
2
){
code
=
0
;
}
else
if
(
paymentStatus
-
0
==
0
){
code
=
4
;
}
else
{
code
=
9
;
}
}
// 商户后端查询的微信支付状态,通知收银台支付结果
// 0:支付成功
// 1:支付超时
...
...
@@ -179,7 +193,7 @@ export default {
// 3:支付关闭
// 4:支付取消
// 9:订单状态未知/未支付
// resolve({ code: 0 | 1 | 2 | 3 | 9
});
resolve
({
code
});
}
else
{
console
.
log
(
res
.
data
.
msg
,
'------查询订单详情失败'
);
reject
(
res
.
data
.
msg
);
...
...
@@ -188,14 +202,53 @@ export default {
});
},
success
(
res
)
{
console
.
log
(
res
,
'--------------ttpay'
)
if
(
res
.
code
==
0
)
{
console
.
log
(
"支付成功处理逻辑,只有res.code=0时,才表示支付成功"
)
// 支付成功处理逻辑,只有res.code=0时,才表示支付成功
// 但是最终状态要以商户后端结果为准
}
order
.
orderDetail
(
_this
.
options
.
orderSn
).
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
){
console
.
log
(
res
.
data
.
data
,
'------------------订单信息'
)
if
(
res
.
data
.
data
){
let
{
paymentStatus
}
=
res
.
data
.
data
;
if
(
paymentStatus
==
2
){
wx
.
hideLoading
();
wx
.
showToast
({
title
:
'支付成功'
,
icon
:
"none"
});
if
(
!
_this
.
options_isCard
){
let
query
=
{
orderSn
:
_this
.
options
.
orderSn
};
wx
.
redirectTo
({
url
:
`../index/main?from=wxPay&backpath=/pay/paySuccess¶ms=
${
JSON
.
stringify
(
query
)}
`
});
}
else
{
let
query
=
{
cardTitle
:
_this
.
options_isCardTitle
};
wx
.
redirectTo
({
url
:
`../index/main?from=wxPay&backpath=/pay/payCardSuccess¶ms=
${
JSON
.
stringify
(
query
)}
`
});
}
}
else
if
(
paymentStatus
-
0
==
0
){
wx
.
hideLoading
();
wx
.
showToast
({
title
:
'支付失败'
,
icon
:
"none"
});
_this
.
toPage
();
}
else
{
wx
.
hideLoading
();
wx
.
showToast
({
title
:
'支付失败'
,
icon
:
"none"
});
_this
.
toPage
();
}
}
}
else
{
console
.
log
(
res
.
data
.
msg
,
'------查询订单详情失败'
);
reject
(
res
.
data
.
msg
);
}
})
},
fail
(
res
)
{
wx
.
hideLoading
();
wx
.
showToast
({
title
:
'支付失败'
,
icon
:
"none"
});
_this
.
toPage
();
console
.
log
(
res
,
'-----------------------201--res'
)
// 调起收银台失败处理逻辑
},
...
...
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