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
c0a7907a
Commit
c0a7907a
authored
May 27, 2021
by
程默
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
格式化
parent
f5029451
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
82 deletions
+91
-82
src/pages/wxPay/index.vue
+91
-82
No files found.
src/pages/wxPay/index.vue
View file @
c0a7907a
<
template
>
<
template
>
<div
class=
"domain"
>
{{
message
}}
</div>
<div
class=
"domain"
>
{{
message
}}
</div>
</
template
>
</
template
>
<
script
>
<
script
>
...
@@ -15,44 +15,46 @@ export default {
...
@@ -15,44 +15,46 @@ export default {
shopmixid
:
""
,
shopmixid
:
""
,
openId
:
""
,
openId
:
""
,
options
:
{},
options
:
{},
options_orderType
:
''
,
options_orderType
:
""
,
// 购买会员卡新页面
// 购买会员卡新页面
options_isCard
:
''
,
options_isCard
:
""
,
options_isCardTitle
:
''
,
options_isCardTitle
:
""
,
batchNumber
:
''
,
batchNumber
:
""
,
totalMoney
:
''
totalMoney
:
""
,
};
};
},
},
onLoad
(
options
)
{
onLoad
(
options
)
{
wx
.
showLoading
({
wx
.
showLoading
({
title
:
"加载中"
title
:
"加载中"
,
});
});
Object
.
assign
(
this
.
$data
,
this
.
$options
.
data
());
//mpvue 的混合周期 使用小程序生命周期数据未初始化
Object
.
assign
(
this
.
$data
,
this
.
$options
.
data
());
//mpvue 的混合周期 使用小程序生命周期数据未初始化
console
.
log
(
"onload//"
,
options
);
console
.
log
(
"onload//"
,
options
);
if
(
options
.
batchNumber
){
if
(
options
.
batchNumber
)
{
let
ordercode
=
JSON
.
parse
(
options
.
ordercode
)
let
ordercode
=
JSON
.
parse
(
options
.
ordercode
);
ordercode
.
orderSn
=
''
ordercode
.
orderSn
=
""
;
ordercode
.
batchNumber
=
options
.
batchNumber
ordercode
.
batchNumber
=
options
.
batchNumber
;
this
.
options
=
ordercode
this
.
options
=
ordercode
;
this
.
batchNumber
=
ordercode
.
batchNumber
this
.
batchNumber
=
ordercode
.
batchNumber
;
console
.
log
(
JSON
.
parse
(
options
.
ordercode
).
orderSn
)
console
.
log
(
JSON
.
parse
(
options
.
ordercode
).
orderSn
);
if
(
JSON
.
parse
(
options
.
ordercode
).
orderSn
){
if
(
JSON
.
parse
(
options
.
ordercode
).
orderSn
)
{
this
.
totalMoney
=
Number
(
JSON
.
parse
(
options
.
ordercode
).
orderSn
.
totalAmount
).
toFixed
(
2
)
this
.
totalMoney
=
Number
(
}
JSON
.
parse
(
options
.
ordercode
).
orderSn
.
totalAmount
).
toFixed
(
2
);
}
// }
// }
console
.
log
(
this
.
totalMoney
,
'totalMoney'
)
console
.
log
(
this
.
totalMoney
,
"totalMoney"
);
}
else
{
}
else
{
this
.
options
=
JSON
.
parse
(
options
.
ordercode
);
this
.
options
=
JSON
.
parse
(
options
.
ordercode
);
}
}
this
.
options_orderType
=
options
.
orderType
;
this
.
options_orderType
=
options
.
orderType
;
this
.
options_isCard
=
options
.
isCard
;
this
.
options_isCard
=
options
.
isCard
;
this
.
options_isCardTitle
=
options
.
isCardTit
;
this
.
options_isCardTitle
=
options
.
isCardTit
;
if
(
options
.
sessionid
)
{
if
(
options
.
sessionid
)
{
try
{
try
{
wx
.
setStorageSync
(
'sessionid'
,
options
.
sessionid
)
wx
.
setStorageSync
(
"sessionid"
,
options
.
sessionid
);
}
catch
(
e
)
{
}
}
catch
(
e
)
{
}
}
}
let
that
=
this
;
let
that
=
this
;
wx
.
getStorage
({
wx
.
getStorage
({
...
@@ -65,39 +67,45 @@ export default {
...
@@ -65,39 +67,45 @@ export default {
console
.
log
(
"支付开始"
,
that
.
options
);
console
.
log
(
"支付开始"
,
that
.
options
);
that
.
toPay
();
that
.
toPay
();
},
},
fail
(
err
){
fail
(
err
)
{
console
.
log
(
'获取err'
,
err
)
console
.
log
(
"获取err"
,
err
);
}
}
,
});
});
},
},
methods
:
{
methods
:
{
toPay
()
{
toPay
()
{
wxPay
wxPay
.
to_wx_pay
(
this
.
options
)
.
to_wx_pay
(
this
.
options
)
.
then
(
res
=>
{
.
then
(
(
res
)
=>
{
wx
.
hideLoading
();
wx
.
hideLoading
();
if
(
res
.
data
.
code
==
200
)
{
if
(
res
.
data
.
code
==
200
)
{
let
payData
=
JSON
.
parse
(
res
.
data
.
data
);
let
payData
=
JSON
.
parse
(
res
.
data
.
data
);
console
.
log
(
'wxPay'
,
res
.
data
)
console
.
log
(
"wxPay"
,
res
.
data
);
payData
.
success
=
res
=>
{
payData
.
success
=
(
res
)
=>
{
console
.
log
(
"支付成功"
,
res
,
this
.
options
);
console
.
log
(
"支付成功"
,
res
,
this
.
options
);
this
.
message
=
"支付成功"
;
this
.
message
=
"支付成功"
;
const
orderSn
=
this
.
options
.
orderSn
;
const
orderSn
=
this
.
options
.
orderSn
;
let
vm
=
this
let
vm
=
this
;
try
{
try
{
const
subscribeMessageObj
=
this
.
$store
.
state
const
subscribeMessageObj
=
this
.
$store
.
state
.
subscribeMessageObj
;
.
subscribeMessageObj
;
if
(
subscribeMessageObj
&&
Object
.
keys
(
subscribeMessageObj
).
length
>
0
)
{
if
(
subscribeMessageObj
&&
Object
.
keys
(
subscribeMessageObj
).
length
>
0
)
{
// TODO 小程序订阅消息埋点
// TODO 小程序订阅消息埋点
const
tmplIds
=
[];
const
tmplIds
=
[];
for
(
var
key
in
subscribeMessageObj
)
{
for
(
var
key
in
subscribeMessageObj
)
{
// 送礼订单
// 送礼订单
if
(
this
.
options_orderType
==
5
&&
(
key
==
'gift_be_expire'
||
key
==
'gift_draw'
))
{
if
(
this
.
options_orderType
==
5
&&
(
key
==
"gift_be_expire"
||
key
==
"gift_draw"
)
)
{
tmplIds
.
push
(
subscribeMessageObj
[
key
]);
tmplIds
.
push
(
subscribeMessageObj
[
key
]);
}
}
// 订单发货
// 订单发货
if
(
key
==
'order_shipment'
)
{
if
(
key
==
"order_shipment"
)
{
tmplIds
.
push
(
subscribeMessageObj
[
key
]);
tmplIds
.
push
(
subscribeMessageObj
[
key
]);
}
}
}
}
...
@@ -106,70 +114,69 @@ export default {
...
@@ -106,70 +114,69 @@ export default {
wx
.
requestSubscribeMessage
({
wx
.
requestSubscribeMessage
({
tmplIds
:
tmplIds
,
tmplIds
:
tmplIds
,
success
(
res
)
{
success
(
res
)
{
fn
(
vm
)
fn
(
vm
)
;
console
.
log
(
"message success response: "
,
res
);
console
.
log
(
"message success response: "
,
res
);
},
},
fail
(
res
)
{
fail
(
res
)
{
fn
(
vm
)
fn
(
vm
)
;
console
.
log
(
"message fail response: "
,
res
)
console
.
log
(
"message fail response: "
,
res
)
;
}
}
,
})
})
;
}
else
{
}
else
{
fn
(
vm
)
fn
(
vm
)
;
}
}
}
else
{
}
else
{
console
.
log
(
'来这里了'
)
console
.
log
(
"来这里了"
);
fn
(
this
)
fn
(
this
)
;
}
}
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"subscribeMessage-err"
,
err
);
console
.
error
(
"subscribeMessage-err"
,
err
);
}
}
function
fn
(
_this
){
function
fn
(
_this
)
{
// _this.message = "支付成功";
// _this.message = "支付成功";
if
(
!
_this
.
options_isCard
)
{
if
(
!
_this
.
options_isCard
)
{
let
query
;
let
query
;
if
(
_this
.
batchNumber
)
{
if
(
_this
.
batchNumber
)
{
query
=
{
query
=
{
orderSn
:
_this
.
options
.
orderSn
,
orderSn
:
_this
.
options
.
orderSn
,
batchNumber
:
_this
.
batchNumber
,
batchNumber
:
_this
.
batchNumber
,
multiMerchantsFlag
:
1
,
multiMerchantsFlag
:
1
,
totalMoney
:
_this
.
totalMoney
totalMoney
:
_this
.
totalMoney
,
};
};
}
else
{
}
else
{
query
=
{
query
=
{
orderSn
:
_this
.
options
.
orderSn
orderSn
:
_this
.
options
.
orderSn
,
};
};
}
}
wx
.
redirectTo
({
wx
.
redirectTo
({
url
:
`../index/main?from=wxPay&backpath=/pay/paySuccess¶ms=
${
JSON
.
stringify
(
url
:
`../index/main?from=wxPay&backpath=/pay/paySuccess¶ms=
${
JSON
.
stringify
(
query
query
)}
`
)}
`
,
});
});
}
else
{
}
else
{
let
query
=
{
let
query
=
{
cardTitle
:
_this
.
options_isCardTitle
cardTitle
:
_this
.
options_isCardTitle
,
}
};
wx
.
redirectTo
({
wx
.
redirectTo
({
url
:
`../index/main?from=wxPay&backpath=/pay/payCardSuccess¶ms=
${
JSON
.
stringify
(
url
:
`../index/main?from=wxPay&backpath=/pay/payCardSuccess¶ms=
${
JSON
.
stringify
(
query
query
)}
`
)}
`
,
});
});
}
}
}
}
};
};
payData
.
fail
=
res
=>
{
payData
.
fail
=
(
res
)
=>
{
console
.
log
(
"支付失败"
,
res
,
this
.
options
.
orderSn
);
console
.
log
(
"支付失败"
,
res
,
this
.
options
.
orderSn
);
this
.
message
=
"支付失败"
;
this
.
message
=
"支付失败"
;
if
(
res
.
errMsg
=
'requestPayment:fail cancel'
)
{
if
(
(
res
.
errMsg
=
"requestPayment:fail cancel"
)
)
{
wxPay
.
cancelPayment
(
this
.
options
.
orderSn
).
then
(()
=>
{
wxPay
.
cancelPayment
(
this
.
options
.
orderSn
).
then
(()
=>
{
console
.
log
(
"取消成功"
);
console
.
log
(
"取消成功"
);
});
});
}
}
this
.
toPage
();
this
.
toPage
();
};
};
payData
.
complete
=
res
=>
{
payData
.
complete
=
(
res
)
=>
{
console
.
log
(
"支付completa"
,
res
,
this
.
options
.
orderSn
);
console
.
log
(
"支付completa"
,
res
,
this
.
options
.
orderSn
);
// if (res.errMsg == "requestPayment:fail cancel") {
// if (res.errMsg == "requestPayment:fail cancel") {
// console.log("支付取消", this.options);
// console.log("支付取消", this.options);
...
@@ -182,33 +189,35 @@ export default {
...
@@ -182,33 +189,35 @@ export default {
wx
.
showToast
({
title
:
res
.
data
.
msg
,
icon
:
"none"
});
wx
.
showToast
({
title
:
res
.
data
.
msg
,
icon
:
"none"
});
}
}
})
})
.
catch
(
err
=>
{
.
catch
(
(
err
)
=>
{
wx
.
showToast
({
title
:
res
.
data
.
msg
,
icon
:
"none"
});
wx
.
showToast
({
title
:
res
.
data
.
msg
,
icon
:
"none"
});
});
});
},
},
toPage
()
{
toPage
()
{
console
.
log
(
'支付失败来这里了'
,
this
.
batchNumber
)
console
.
log
(
"支付失败来这里了"
,
this
.
batchNumber
);
if
(
this
.
batchNumber
)
{
if
(
this
.
batchNumber
)
{
let
query
=
{
let
query
=
{
multiMerchantsFlag
:
1
multiMerchantsFlag
:
1
,
}
}
;
wx
.
redirectTo
({
wx
.
redirectTo
({
url
:
`../index/main?from=wxPay&backpath=/order/orderList¶ms=
${
JSON
.
stringify
(
query
)}
`
url
:
`../index/main?from=wxPay&backpath=/order/orderList¶ms=
${
JSON
.
stringify
(
query
)}
`
,
});
});
return
return
;
}
}
let
query
=
{
let
query
=
{
orderSn
:
this
.
options
.
orderSn
,
orderSn
:
this
.
options
.
orderSn
,
payList
:
true
,
payList
:
true
,
orderListToorderDetail
:
true
orderListToorderDetail
:
true
,
};
};
wx
.
redirectTo
({
wx
.
redirectTo
({
url
:
`../index/main?from=wxPay&backpath=/order/orderDetail¶ms=
${
JSON
.
stringify
(
url
:
`../index/main?from=wxPay&backpath=/order/orderDetail¶ms=
${
JSON
.
stringify
(
query
query
)}
`
)}
`
,
});
});
}
}
,
}
}
,
};
};
</
script
>
</
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