Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
N
newLive
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孟庆瑞
newLive
Commits
71ff1677
Commit
71ff1677
authored
Dec 04, 2022
by
jiaoyahui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
授权下微信支付
parent
0920ef4f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
239 additions
and
56 deletions
+239
-56
api.js
src/axios/api.js
+4
-0
index.js
src/router/index.js
+1
-1
live.vue
src/views/live.vue
+114
-35
sign.vue
src/views/sign.vue
+2
-1
common.js
static/js/common.js
+118
-19
No files found.
src/axios/api.js
View file @
71ff1677
...
@@ -58,7 +58,11 @@ live: {
...
@@ -58,7 +58,11 @@ live: {
},
},
buy
:
function
(
data
){
buy
:
function
(
data
){
return
service
.
post
(
'/oapi/v1/h5/pay/buy'
,
data
)
return
service
.
post
(
'/oapi/v1/h5/pay/buy'
,
data
)
},
buy_code
:
function
(
data
){
return
service
.
post
(
'/wx/code'
,
data
)
}
}
},
},
...
...
src/router/index.js
View file @
71ff1677
...
@@ -184,7 +184,7 @@ router.beforeEach((to, from, next) => {
...
@@ -184,7 +184,7 @@ router.beforeEach((to, from, next) => {
}
else
{
}
else
{
console
.
log
(
'该页面需要登陆'
)
console
.
log
(
'该页面需要登陆'
)
next
({
next
({
path
:
'/login'
,
// path: '/login',进页面直接进去登录页面先隐藏
// query: { redirect: to.fullPath } // 将跳转的路由path作为参数,登录成功后跳转到该路由
// query: { redirect: to.fullPath } // 将跳转的路由path作为参数,登录成功后跳转到该路由
})
})
}
}
...
...
src/views/live.vue
View file @
71ff1677
...
@@ -96,12 +96,12 @@
...
@@ -96,12 +96,12 @@
<div
class=
"div_p"
>
{{
item
.
chargeModeName
}}
</div>
<div
class=
"div_p"
>
{{
item
.
chargeModeName
}}
</div>
<div
class=
"Uimg"
>
<div
class=
"Uimg"
>
<img
src=
"../assets/niu.png"
alt=
""
class=
"sent_r"
>
<img
src=
"../assets/niu.png"
alt=
""
class=
"sent_r"
>
<span>
20
</span>
<span>
{{
item
.
lvrfFee
}}
</span>
</div>
</div>
<div
class=
"Mar_p"
>
<div
class=
"Mar_p"
>
<img
src=
"../assets/niu.png"
alt=
""
class=
"U_both"
>
<img
src=
"../assets/niu.png"
alt=
""
class=
"U_both"
>
<span
class=
"d_num"
>
200/节
</span>
<span
class=
"d_num"
>
{{
item
.
promptFee
}}
/月
</span>
</div>
</div>
</div>
</div>
...
@@ -191,6 +191,7 @@
...
@@ -191,6 +191,7 @@
</div>
</div>
<div
class=
"gr"
><img
src=
"../assets/login.png"
alt=
""
class=
"Pl"
@
click=
"login_t"
></div>
<div
class=
"gr"
><img
src=
"../assets/login.png"
alt=
""
class=
"Pl"
@
click=
"login_t"
></div>
<img
:src=
"'data:image/png;base64,'+ qrcodeSrc"
alt=
""
>
</div>
</div>
...
@@ -216,6 +217,7 @@ export default {
...
@@ -216,6 +217,7 @@ export default {
data
()
{
data
()
{
return
{
return
{
n
:
1
,
n
:
1
,
qrcodeSrc
:
''
,
chargeModeKey
:
'Month'
,
chargeModeKey
:
'Month'
,
is_xuanzhong
:
'Month0'
,
is_xuanzhong
:
'Month0'
,
is_Month
:
'Month'
,
is_Month
:
'Month'
,
...
@@ -269,9 +271,14 @@ export default {
...
@@ -269,9 +271,14 @@ export default {
pmoId
:
''
,
pmoId
:
''
,
pmoOrder
:
''
,
pmoOrder
:
''
,
active_p
:
'Month'
,
active_p
:
'Month'
,
currentIndex
:
0
currentIndex
:
0
,
isMobile
:
false
,
wechatInfo
:
''
,
// is_show_p:false //默认选中按钮隐藏
//is_show_p:false //默认选中按钮隐藏
// orderType : 4, //pc浏览器环境
// orderType : 3, //h5环境
wxOrderType
:
this
.
common
.
isMobile
()
&&
this
.
common
.
isWX
()
?
2
:
(
this
.
common
.
isMobile
()
?
3
:
4
),
};
};
},
},
...
@@ -280,6 +287,8 @@ export default {
...
@@ -280,6 +287,8 @@ export default {
this
.
videoList
()
this
.
videoList
()
this
.
getHeight
()
this
.
getHeight
()
this
.
pay_info
()
this
.
pay_info
()
this
.
isMobile
=
this
.
common
.
isMobile
();
// 连接mqtt
// 连接mqtt
mqtt
.
connect
({
mqtt
.
connect
({
user
:
request
.
mqtt
.
mqttUser
,
user
:
request
.
mqtt
.
mqttUser
,
...
@@ -470,25 +479,19 @@ export default {
...
@@ -470,25 +479,19 @@ export default {
//获取支付信息
//获取支付信息
pay_info
(){
pay_info
(){
let
temp
=
this
.
qs
.
stringify
({
let
temp
=
this
.
qs
.
stringify
({
pmAppVersion
:
'884'
,
pmAppVersion
:
'884'
,
// pmModel:'iPhone 12/13 (Pro)',
// pmSystem:'iOS 10.0.1',
// timestamp:this.timestamp,
// goodsId:115,
// pmOperator:'无运营商',
applicationType
:
4
,
applicationType
:
4
,
pmAppVersion
:
868
,
pmAppVersion
:
868
,
// applicationType: 3,
// applicationType: 3,
goodsType
:
3
,
goodsType
:
3
,
goodsId
:
429
,
goodsId
:
285
,
})
})
this
.
server
.
live
.
payinfo
(
temp
).
then
(
res
=>
{
this
.
server
.
live
.
payinfo
(
temp
).
then
(
res
=>
{
this
.
udRealname
=
res
.
data
.
data
.
udRealname
this
.
udRealname
=
res
.
data
.
data
.
udRealname
this
.
text
=
res
.
data
.
data
.
text
,
this
.
text
=
res
.
data
.
data
.
text
,
this
.
Listfor
=
res
.
data
.
data
.
fees
this
.
Listfor
=
res
.
data
.
data
.
fees
// this.lvrStatus=res.data.data.lvrStatus
// this.lvrStatus=res.data.data.lvrStatus
console
.
log
()
console
.
log
()
})
})
...
@@ -497,7 +500,7 @@ export default {
...
@@ -497,7 +500,7 @@ export default {
// 订单
// 订单
payorder
(){
payorder
(){
let
temp
=
this
.
qs
.
stringify
({
let
temp
=
this
.
qs
.
stringify
({
goodsId
:
429
,
goodsId
:
285
,
goodsType
:
3
,
goodsType
:
3
,
sxUbId
:
26
,
sxUbId
:
26
,
pmoType
:
0
,
pmoType
:
0
,
...
@@ -510,44 +513,70 @@ export default {
...
@@ -510,44 +513,70 @@ export default {
isCheckBuy
:
1
,
isCheckBuy
:
1
,
paySource
:
"douniu_h5"
,
paySource
:
"douniu_h5"
,
chargeModeKey
:
this
.
chargeModeKey
chargeModeKey
:
this
.
chargeModeKey
})
})
this
.
server
.
live
.
order
(
temp
).
then
(
res
=>
{
this
.
server
.
live
.
order
(
temp
).
then
(
res
=>
{
this
.
pmoId
=
res
.
data
.
data
.
pmoId
,
this
.
pmoId
=
res
.
data
.
data
.
pmoId
,
this
.
pmoOrder
=
res
.
data
.
data
.
pmoOrder
this
.
pmoOrder
=
res
.
data
.
data
.
pmoOrder
//order成功判断内置浏览器,在微信就授权,内置微信还是浏览器 微信jsapi 浏览器h5
if
(
res
.
code
=
200
){
if
(
res
.
code
=
200
){
//判断是否为在微信内置浏览器支付
console
.
log
(
res
.
data
.
data
.
pmoOrder
,
'===-'
)
if
(
this
.
common
.
isWX
()){
this
.
paybuy
()
// this.a_go()
// this.pay_code() //授权登录
}
else
{
}
this
.
paybuy
()
}
}
})
})
},
},
paybuy
(){
paybuy
(){
//判断在微信内置浏览器jsapi支付
//jsapi
let
temp
=
this
.
qs
.
stringify
({
let
temp
=
this
.
qs
.
stringify
({
orderId
:
this
.
pmoId
,
orderId
:
this
.
pmoId
,
orderNo
:
this
.
pmoOrder
,
orderNo
:
this
.
pmoOrder
,
payType
:
1
,
payType
:
1
,
orderType
:
3
,
orderType
:
this
.
wxOrderType
,
pmoType
:
0
,
pmoType
:
0
,
goodsType
:
3
,
goodsType
:
3
,
})
})
this
.
server
.
live
.
buy
(
temp
).
then
(
res
=>
{
this
.
server
.
live
.
buy
(
temp
).
then
(
res
=>
{
window
.
location
.
href
=
res
.
data
.
data
.
wechatInfo
.
payUrl
// this.qrcodeSrc=res.data.data.wechatInfo.base64Img;
console
.
log
(
res
.
data
.
data
.
wechatInfo
.
payUrl
,
'==='
)
// alert(11)
// this.codeUrl=res.data.data.wechatInfo.codeUrl
//h5 window.location.href=res.data.data.wechatInfo.payUrl
// window.location.href=res.data.data.wechatInfo.codeUrl
// console.log(res.data.data.wechatInfo.payUrl,'===')
this
.
qrcodeSrc
=
res
.
data
.
data
.
wechatInfo
.
base64Img
;
this
.
wechatInfo
=
res
.
data
.
data
.
wechatInfo
//微信内置jsapi
if
(
this
.
wxOrderType
==
2
){
this
.
onBridgeReady
();
}
//二维码
if
(
this
.
wxOrderType
==
4
){
//弹窗展示二维码
this
.
qrcodeSrc
=
res
.
data
.
data
.
wechatInfo
.
base64Img
;
}
//移动端外部浏览器
if
(
this
.
wxOrderType
==
3
){
//跳转h5支付链接
window
.
location
.
href
=
res
.
data
.
data
.
wechatInfo
.
payUrl
}
})
})
},
},
videoClick
(
lv
){
videoClick
(
lv
){
this
.
playerOptions
.
sources
[
0
].
src
=
lv
this
.
playerOptions
.
sources
[
0
].
src
=
lv
...
@@ -573,8 +602,8 @@ export default {
...
@@ -573,8 +602,8 @@ export default {
}
}
},
},
login_t
(){
login_t
(){
this
.
payorder
()
this
.
payorder
()
// this.pay_code()
if
(
!
this
.
isImg_show
){
if
(
!
this
.
isImg_show
){
this
.
a_plert
=
true
this
.
a_plert
=
true
return
;
return
;
...
@@ -594,8 +623,58 @@ export default {
...
@@ -594,8 +623,58 @@ export default {
pay_p
(){
pay_p
(){
this
.
pten
=
true
this
.
pten
=
true
},
},
onBridgeReady
()
{
WeixinJSBridge
.
invoke
(
'getBrandWCPayRequest'
,
{
"appId"
:
this
.
wechatInfo
.
appId
,
//公众号ID,由商户传入
"timeStamp"
:
this
.
wechatInfo
.
timeStamp
,
//时间戳,自1970年以来的秒数
"nonceStr"
:
this
.
wechatInfo
.
nonceStr
,
//随机串
// "package": `prepay_id=${this.wechatInfo.prepayId}`,
"package"
:
this
.
wechatInfo
.
packAge
,
"signType"
:
this
.
wechatInfo
.
signType
,
//微信签名方式:
"paySign"
:
this
.
wechatInfo
.
sign
// "paySign": "oR9d8PuhnIc+YZ8cBHFCwfgpaK9gd7vaRvkYD7rthRAZ\/X+QBhcCYL21N7cHCTUxbQ+EAt6Uy+lwSN22f5YZvI45MLko8Pfso0jm46v5hqcVwrk6uddkGuT+Cdvu4WBqDzaDjnNa5UK3GfE1Wfl2gHxIIY5lLdUgWFts17D4WuolLLkiFZV+JSHMvH7eaLdT9N5GBovBwu5yYKUR7skR8Fu+LozcSqQixnlEZUfyE55feLOQTUYzLmR9pNtPbPsu6WVhbNHMS3Ss2+AehHvz+n64GDmXxbX++IOBvm2olHu3PsOUGRwhudhVf7UcGcunXt8cqNjKNqZLhLw4jq\/xDg==" //微信签名
},
function
(
res
)
{
if
(
res
.
err_msg
==
"get_brand_wcpay_request:ok"
)
{
// 使用以上方式判断前端返回,微信团队郑重提示:
//res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
}
});
}
// 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();
// }
// a_go(){
// if (this.common.isWX() && this.common.isMobile()) { //微信浏览器
// // 转换为query格式
// var urlParam = this.$route.query.path;
// if(!this.$route.query.path){
// urlParam='undefined'
// }
// var urlTag = this.qs.stringify({
// urlTag: this.getPath(),
// urlParam: urlParam,
// });
// this.server.base.buy_code(urlTag).then(res => {
// location.href = res.data.data;
// })
// } else {
// // this.getLive()
// this.$router.push({
// path:'/live',
// });
// }
// }
},
},
};
};
...
@@ -923,7 +1002,7 @@ display: block;
...
@@ -923,7 +1002,7 @@ display: block;
}
}
.conten
{
.conten
{
position
:
fixed
;
position
:
fixed
;
top
:
24
%
;
top
:
0
%
;
left
:
0%
;
left
:
0%
;
width
:
100%
;
width
:
100%
;
/* background:red */
/* background:red */
...
...
src/views/sign.vue
View file @
71ff1677
...
@@ -296,7 +296,8 @@ export default {
...
@@ -296,7 +296,8 @@ export default {
sessionStorage
.
setItem
(
"ubId"
,
ubId
);
sessionStorage
.
setItem
(
"ubId"
,
ubId
);
window
.
sessionStorage
.
setItem
(
'token'
,
thisToken
);
window
.
sessionStorage
.
setItem
(
'token'
,
thisToken
);
sessionStorage
.
setItem
(
"name"
,
name
);
sessionStorage
.
setItem
(
"name"
,
name
);
store
.
commit
(
"SET_TOKEN"
,
thisToken
);
store
.
commit
(
"SET_TOKEN"
,
thisToken
);
// this.getLive()
// this.getLive()
this
.
$router
.
push
(
this
.
$router
.
push
(
{
{
...
...
static/js/common.js
View file @
71ff1677
// 秒数转时间格式
function
secondToTime
(
item
)
{
if
(
typeof
item
!=
'number'
||
isNaN
(
item
))
{
return
'00:00'
;
}
var
s
=
item
%
60
<
10
?
'0'
+
item
%
60
:
(
item
%
60
).
toString
();
item
=
parseInt
(
item
/
60
);
if
(
item
==
0
)
{
return
'00:'
+
s
;
}
var
m
=
item
<
10
?
'0'
+
item
:
item
.
toString
();
return
m
+
":"
+
s
;
}
// 手机号校验
const
checkPhone
=
(
value
)
=>
{
var
reg
=
/^
((
13
[
0-9
])
|
(
14
[
5,7,9
])
|
(
15
([
0-3
]
|
[
5-9
]))
|
(
166
)
|
(
17
[
0,1,3,5,6,7,8,9
])
|
(
18
[
0-9
])
|
(
19
[
8|9
]))\d{8}
$/
if
(
reg
.
test
(
value
))
{
return
true
;
}
else
{
return
false
;
}
};
// 判断数字
const
checkNumber
=
(
item
)
=>
{
if
(
!
item
)
{
return
''
}
var
reg
=
/^
[
0-9
]
$/
if
(
reg
.
test
(
item
.
charAt
(
item
.
length
-
1
)))
{
return
item
;
}
else
{
return
item
.
slice
(
0
,
item
.
length
-
1
)
}
};
// 判断是否为移动端浏览器
const
isMobile
=
()
=>
{
var
ua
=
navigator
.
userAgent
;
var
ipad
=
ua
.
match
(
/
(
iPad
)
.*OS
\s([\d
_
]
+
)
/
),
isIphone
=
!
ipad
&&
ua
.
match
(
/
(
iPhone
\s
OS
)\s([\d
_
]
+
)
/
),
isAndroid
=
ua
.
match
(
/
(
Android
)\s
+
([\d
.
]
+
)
/
),
isMobile
=
isIphone
||
isAndroid
||
ipad
;
//判断
if
(
isMobile
)
{
return
true
;
}
else
{
return
false
;
}
}
// 判断是否为微信浏览器
// 判断是否为微信浏览器
const
isWX
=
()
=>
{
const
isWX
=
()
=>
{
var
ua
=
navigator
.
userAgent
.
toLowerCase
();
var
ua
=
navigator
.
userAgent
.
toLowerCase
();
if
(
ua
.
match
(
/MicroMessenger/i
)
==
'micromessenger'
)
{
if
(
ua
.
match
(
/MicroMessenger/i
)
==
'micromessenger'
)
{
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
false
;
}
}
}
// 判断是否为移动端浏览器
}
const
isMobile
=
()
=>
{
var
ua
=
navigator
.
userAgent
;
var
ipad
=
ua
.
match
(
/
(
iPad
)
.*OS
\s([\d
_
]
+
)
/
),
// 随机字符串
isIphone
=
!
ipad
&&
ua
.
match
(
/
(
iPhone
\s
OS
)\s([\d
_
]
+
)
/
),
function
randomString
(
length
)
{
isAndroid
=
ua
.
match
(
/
(
Android
)\s
+
([\d
.
]
+
)
/
),
var
chars
=
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
;
isMobile
=
isIphone
||
isAndroid
||
ipad
;
var
result
=
''
;
//判断
for
(
var
i
=
length
;
i
>
0
;
--
i
)
result
+=
chars
[
Math
.
floor
(
Math
.
random
()
*
chars
.
length
)];
if
(
isMobile
)
{
return
result
;
return
true
;
}
}
else
{
return
false
;
// 设置微信分享
function
setWXShare
(
item
)
{
if
(
isWX
()
&&
wx
)
{
var
link
=
window
.
location
.
href
.
split
(
'#/'
)[
0
]
+
'#/'
;
var
acceptPath
=
[
'/NiuCeLue'
,
'/NiuRenKe'
,
'/NiuRenKe/video'
,
'/singleVideo'
,
'/NiuRenKe/audio'
,
'/singleAudio'
,
'/liveDetail'
,
'/repeatDetail'
];
var
schema
=
'http://'
;
if
(
link
.
indexOf
(
'https'
)
!=
-
1
)
{
schema
=
'https://'
;
}
}
}
for
(
var
i
in
acceptPath
)
{
\ No newline at end of file
if
(
window
.
location
.
href
.
split
(
'#'
)[
1
].
split
(
'?'
)[
0
]
==
acceptPath
[
i
])
{
link
=
schema
+
window
.
location
.
host
+
'/#'
+
window
.
location
.
href
.
split
(
'#'
)[
1
];
}
}
link
=
link
.
replace
(
'?from=singlemessage'
,
''
);
wx
.
ready
(()
=>
{
//需在用户可能点击分享按钮前就先调用
wx
.
updateAppMessageShareData
({
title
:
'斗牛财经'
,
// 分享标题
desc
:
item
.
title
,
// 分享描述
link
:
link
,
// 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl
:
item
.
imgUrl
,
// 分享图标
success
:
function
()
{
console
.
log
(
"分享成功"
)
}
})
});
}
}
// 签名
function
sign
(
timestamp
,
type
,
phone
)
{
var
str
=
"timestamp="
+
timestamp
+
"&type="
+
type
+
"&ubPhone="
+
phone
+
"&key="
+
store
.
state
.
signKey
;
return
str
;
}
export
default
{
secondToTime
,
checkPhone
,
checkNumber
,
isMobile
,
isWX
,
randomString
,
setWXShare
,
sign
,
}
\ No newline at end of file
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