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
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
10 deletions
+67
-10
src/api/order.js
+1
-1
src/pages/contact/index.vue
+7
-3
src/pages/wxPay/index.vue
+59
-6
No files found.
src/api/order.js
View file @
db351fea
...
@@ -4,6 +4,6 @@ import { requestPOST, requestGET } from "@/utils/request.js";
...
@@ -4,6 +4,6 @@ import { requestPOST, requestGET } from "@/utils/request.js";
export
default
{
export
default
{
//登录
//登录
orderDetail
(
options
)
{
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 @@
...
@@ -6,10 +6,10 @@
<div
class=
"btn-wrap"
>
<div
class=
"btn-wrap"
>
<button
open-type=
"contact"
>
<button
open-type=
"contact"
>
<div
class=
"btn-main"
>
<div
class=
"btn-main"
>
<div
class=
"main-img"
>
<div
class=
"main-img"
v-if=
"!isTT"
>
<img
src=
"../../../static/images/wx.png"
alt=
""
>
<img
src=
"../../../static/images/wx.png"
alt=
""
>
</div>
</div>
<div
class=
"main-text"
>
官方
微信
客服
</div>
<div
class=
"main-text"
>
官方
{{
!
isTT
?
'微信'
:
''
}}
客服
</div>
</div>
</div>
<img
class=
"btn-next"
src=
"../../../static/images/next.png"
alt=
""
>
<img
class=
"btn-next"
src=
"../../../static/images/next.png"
alt=
""
>
</button>
</button>
...
@@ -19,7 +19,11 @@
...
@@ -19,7 +19,11 @@
<
script
>
<
script
>
export
default
{
export
default
{
data
(){
return
{
isTT
:
MINI_ENV
==
'tt'
,
}
}
}
}
</
script
>
</
script
>
...
...
src/pages/wxPay/index.vue
View file @
db351fea
...
@@ -155,6 +155,7 @@ export default {
...
@@ -155,6 +155,7 @@ export default {
},
},
// 头条支付
// 头条支付
toTtPay
(
orderInfo
){
toTtPay
(
orderInfo
){
let
_this
=
this
;
console
.
log
(
orderInfo
,
'---orderInfo'
)
console
.
log
(
orderInfo
,
'---orderInfo'
)
tt
.
pay
({
tt
.
pay
({
orderInfo
,
orderInfo
,
...
@@ -163,6 +164,7 @@ export default {
...
@@ -163,6 +164,7 @@ export default {
default_pay_channel
:
"wx"
,
// wx || alipay
default_pay_channel
:
"wx"
,
// wx || alipay
},
},
getOrderStatus
(
res
)
{
getOrderStatus
(
res
)
{
console
.
log
(
res
,
'------------------------167'
)
let
{
out_order_no
}
=
res
;
let
{
out_order_no
}
=
res
;
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
// 商户前端根据 out_order_no 请求商户后端查询微信支付订单状态
// 商户前端根据 out_order_no 请求商户后端查询微信支付订单状态
...
@@ -170,8 +172,20 @@ export default {
...
@@ -170,8 +172,20 @@ export default {
orderSn
:
out_order_no
,
orderSn
:
out_order_no
,
}
}
order
.
orderDetail
(
query
).
then
(
res
=>
{
order
.
orderDetail
(
query
).
then
(
res
=>
{
console
.
log
(
res
.
data
,
"------------------------174"
)
if
(
res
.
data
.
code
==
200
){
if
(
res
.
data
.
code
==
200
){
console
.
log
(
res
.
data
.
data
,
'------------------订单信息'
)
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:支付成功
// 0:支付成功
// 1:支付超时
// 1:支付超时
...
@@ -179,7 +193,7 @@ export default {
...
@@ -179,7 +193,7 @@ export default {
// 3:支付关闭
// 3:支付关闭
// 4:支付取消
// 4:支付取消
// 9:订单状态未知/未支付
// 9:订单状态未知/未支付
// resolve({ code: 0 | 1 | 2 | 3 | 9
});
resolve
({
code
});
}
else
{
}
else
{
console
.
log
(
res
.
data
.
msg
,
'------查询订单详情失败'
);
console
.
log
(
res
.
data
.
msg
,
'------查询订单详情失败'
);
reject
(
res
.
data
.
msg
);
reject
(
res
.
data
.
msg
);
...
@@ -188,14 +202,53 @@ export default {
...
@@ -188,14 +202,53 @@ export default {
});
});
},
},
success
(
res
)
{
success
(
res
)
{
console
.
log
(
res
,
'--------------ttpay'
)
order
.
orderDetail
(
_this
.
options
.
orderSn
).
then
(
res
=>
{
if
(
res
.
code
==
0
)
{
if
(
res
.
data
.
code
==
200
){
console
.
log
(
"支付成功处理逻辑,只有res.code=0时,才表示支付成功"
)
console
.
log
(
res
.
data
.
data
,
'------------------订单信息'
)
// 支付成功处理逻辑,只有res.code=0时,才表示支付成功
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
)
{
fail
(
res
)
{
wx
.
hideLoading
();
wx
.
showToast
({
title
:
'支付失败'
,
icon
:
"none"
});
_this
.
toPage
();
console
.
log
(
res
,
'-----------------------201--res'
)
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