Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cauchy-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
ui
cauchy-ui
Commits
e5731692
Commit
e5731692
authored
Nov 08, 2021
by
郭志伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(toPay.mixin): 调整优化
parent
d03a1b85
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
159 deletions
+13
-159
toPay.mixins.js
src/mixins/toPay.mixins.js
+9
-7
pay.js
src/service/pay.js
+0
-150
index.vue
src/views/orderList/index.vue
+1
-1
payResult.vue
src/views/pay/payResult.vue
+3
-1
No files found.
src/mixins/toPay.mixins.js
View file @
e5731692
...
...
@@ -3,14 +3,16 @@ import localStorage from '@/service/localStorage.service';
export
default
{
methods
:
{
toPay
(
orderNo
)
{
toPay
(
orderNo
,
replace
=
true
)
{
const
redirectUrl
=
window
.
location
.
origin
;
// this.$router.push({ name: 'pay', query: { orderNo: data.orderNo } });
window
.
location
.
replace
(
`
${
cfg
.
phobosHost
}
?orderNo=
${
orderNo
}
&vccToken=
${
localStorage
.
get
(
const
payUrl
=
`
${
cfg
.
phobosHost
}
?orderNo=
${
orderNo
}
&vccToken=
${
localStorage
.
get
(
'
vccToken
'
)}
&vccChannel=
${
localStorage
.
get
(
'
vccChannel
'
)}
&hideOrder=true&redirectUrl=
${
redirectUrl
}
`
);
)}
&vccChannel=
${
localStorage
.
get
(
'
vccChannel
'
)}
&hideOrder=true&redirectUrl=
${
redirectUrl
}
`
;
if
(
replace
)
{
window
.
location
.
replace
(
payUrl
);
}
else
{
window
.
location
.
href
=
payUrl
;
}
}
}
};
src/service/pay.js
deleted
100644 → 0
View file @
d03a1b85
/*
* @Description: 支付微信h5, jsapi, 第三方收银台,跳转)
* @Date: 2020-07-28 15:03:52
* @LastEditors: gzw
* @LastEditTime: 2020-10-19 11:33:04
*/
import
qs
from
'
qs
'
;
import
cookies
from
'
@/service/cookieStorage.service
'
;
import
localStorage
from
'
@/service/localStorage.service
'
;
import
{
isApp
as
isXyqb
}
from
'
@/service/validation.service
'
;
/**
* payByWeixinJsapi
* @description: 微信通过jsapi支付
* 可以在微信浏览器调起支付
* @param {type}
* @return:
*/
function
payByWeixinJsapi
(
info
=
{},
callback
)
{
function
onBridgeReady
()
{
// eslint-disable-next-line no-undef
WeixinJSBridge
.
invoke
(
'
getBrandWCPayRequest
'
,
info
,
function
(
res
)
{
if
(
res
.
err_msg
==
'
get_brand_wcpay_request:ok
'
)
{
// 使用以上方式判断前端返回,微信团队郑重提示:
//res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
callback
(
'
ok
'
);
}
else
if
(
res
.
err_msg
==
'
get_brand_wcpay_request:cancel
'
)
{
// 支付取消
callback
(
'
cancel
'
);
}
else
{
// 支付失败
callback
(
'
fail
'
);
}
});
}
if
(
typeof
WeixinJSBridge
==
'
undefined
'
)
{
if
(
document
.
addEventListener
)
{
document
.
addEventListener
(
'
WeixinJSBridgeReady
'
,
onBridgeReady
,
false
);
}
else
if
(
document
.
attachEvent
)
{
document
.
attachEvent
(
'
WeixinJSBridgeReady
'
,
onBridgeReady
);
document
.
attachEvent
(
'
onWeixinJSBridgeReady
'
,
onBridgeReady
);
}
}
else
{
onBridgeReady
();
}
}
/**
* payByWeixinH5
* @description: 微信通过H5支付
* 可以在浏览器调起微信支付
* 在羊小咩(信用钱包)app中调起微信支付,会先唤起微信,原来的页面会自动跳转到redirect_url设定的地址
* @param {type}
* @return:
*/
function
payByWeixinH5
(
info
)
{
if
(
!
info
.
url
)
return
;
if
(
!
info
.
params
)
{
info
.
params
=
{};
}
const
vccToken
=
localStorage
.
get
(
'
vccToken
'
);
const
orderNo
=
cookies
.
get
(
'
orderNo
'
)?.
orderNo
;
info
.
params
.
isXyqb
=
isXyqb
?
1
:
0
;
info
.
params
.
isWxH5
=
1
;
info
.
params
.
vccToken
=
vccToken
;
info
.
params
.
orderNo
=
orderNo
;
const
currentPath
=
encodeURIComponent
(
window
.
location
.
origin
+
'
/payWaiting
'
+
qs
.
stringify
(
info
.
params
,
{
encode
:
true
,
addQueryPrefix
:
true
})
);
// window.location.href = `${info.url}&redirect_url=${currentPath}`;
const
nextPage
=
document
.
createElement
(
'
a
'
);
nextPage
.
setAttribute
(
'
href
'
,
`
${
info
.
url
}
&redirect_url=
${
currentPath
}
`
);
nextPage
.
click
();
}
/**
* payByALIH5
* @description: 支付宝支付
* @param {type}
* @return:
*/
function
payByALIH5
(
info
)
{
if
(
!
info
.
url
)
return
;
const
aliWrap
=
document
.
createElement
(
'
div
'
);
aliWrap
.
id
=
'
ALIWEB_WRAP
'
;
aliWrap
.
setAttribute
(
'
id
'
,
'
ALIWEB_WRAP
'
);
aliWrap
.
innerHTML
=
info
.
url
;
document
.
body
.
appendChild
(
aliWrap
);
document
.
forms
[
0
].
submit
();
setTimeout
(()
=>
{
const
ALIWEB_WRAP
=
document
.
getElementById
(
'
ALIWEB_WRAP
'
);
if
(
ALIWEB_WRAP
!=
null
)
ALIWEB_WRAP
.
parentNode
.
removeChild
(
ALIWEB_WRAP
);
},
500
);
}
/**
* payByThirdPartyCashier
* @description: 第三方收银台
* @param {type}
* @return:
*/
function
payByThirdPartyCashier
(
info
)
{
if
(
!
info
.
url
)
return
;
info
.
params
.
third
=
1
;
const
currentPath
=
encodeURIComponent
(
window
.
location
.
origin
+
'
/payWaiting
'
+
qs
.
stringify
(
info
.
params
,
{
encode
:
true
,
addQueryPrefix
:
true
})
);
const
nextPage
=
document
.
createElement
(
'
a
'
);
nextPage
.
setAttribute
(
'
href
'
,
`
${
info
.
url
}
&redirect_uri=
${
currentPath
}
`
);
nextPage
.
click
();
// window.location.href = `${info.url}&redirect_uri=${currentPath}`;
}
/**
* @description: 支付方式判断, 返回promise
* NATIVE=原生扫码支付.,APP=ap支付,,JSAPI=公众号支付/小程序支付,,MWEB=H5支付.,MICROPAY=刷卡支付,默认JSAPI
* @param {String} type 支付方式,THIRD -> 第三方,MWEB -> H5支付, JSAPI -> jsapi支付,默认支付方式,THIRD
* @param {Object/String} payInfo 支付信息
* @return {Promise} 回调
*/
export
function
payByWay
(
type
=
'
THIRD
'
,
payInfo
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
type
===
'
JSAPI
'
&&
!
payInfo
.
url
)
{
payByWeixinJsapi
(
payInfo
,
function
(
e
)
{
if
(
e
===
'
ok
'
)
{
resolve
();
}
else
{
reject
();
}
});
}
else
{
if
(
payInfo
.
url
.
indexOf
(
'
tenpay
'
)
>
-
1
)
{
payByWeixinH5
(
payInfo
);
reject
();
}
else
if
(
type
===
'
ALIWEB
'
)
{
payByALIH5
(
payInfo
);
resolve
();
}
else
{
payByThirdPartyCashier
(
payInfo
);
reject
();
}
// resolve();
}
});
}
src/views/orderList/index.vue
View file @
e5731692
...
...
@@ -96,7 +96,7 @@ export default {
this
.
orderCancelPopup
();
break
;
case
'
pay
'
:
this
.
toPay
(
this
.
currentOrder
.
orderNo
);
this
.
toPay
(
this
.
currentOrder
.
orderNo
,
false
);
break
;
case
'
notify
'
:
this
.
orderNotify
();
...
...
src/views/pay/payResult.vue
View file @
e5731692
...
...
@@ -58,9 +58,11 @@ import localStorage from '@/service/localStorage.service';
import
{
isApp
}
from
'
@/service/validation.service
'
;
import
{
goUrlExtends
}
from
'
./extends
'
;
import
{
payTypeMap
}
from
'
./STATIC_DATA
'
;
import
toPayMixins
from
'
@/mixins/toPay.mixins
'
;
export
default
{
components
:
{
RecoGoods
},
extends
:
goUrlExtends
,
mixins
:
[
toPayMixins
],
data
()
{
return
{
money
:
'
00.00
'
,
...
...
@@ -110,7 +112,7 @@ export default {
pay_status
:
this
.
payStatus
,
buttons_name
:
'
重新支付
'
});
this
.
$router
.
replace
({
name
:
'
pay
'
,
query
:
{
orderNo
:
this
.
orderNo
}
}
);
this
.
toPay
(
this
.
orderNo
);
}
}
};
...
...
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