Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
E
ehall-show-h5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
ehall-show-h5
Commits
f2ea0059
提交
f2ea0059
authored
1月 08, 2021
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加微信JSAPI支付
上级
7aa53761
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
109 行增加
和
8 行删除
+109
-8
.env
.env
+2
-2
index.js
src/api/index.js
+6
-0
pay.js
src/mixins/pay.js
+83
-0
Login.vue
src/views/Login.vue
+1
-1
PaperEdit.vue
src/views/report/PaperEdit.vue
+10
-3
Edit.vue
src/views/retake/Edit.vue
+7
-2
没有找到文件。
.env
浏览文件 @
f2ea0059
VUE_APP_BASE_API=
VUE_APP_BASE_API=
VUE_APP_WECHAT_REDIRECT_URL=
VUE_APP_WECHAT_REDIRECT_URL=https://passport2.ezijing.com/rest/wechat/oauth-callback
\ No newline at end of file
\ No newline at end of file
src/api/index.js
浏览文件 @
f2ea0059
...
@@ -109,3 +109,9 @@ export function getOrder(orderId) {
...
@@ -109,3 +109,9 @@ export function getOrder(orderId) {
export
function
paySuccess
(
id
)
{
export
function
paySuccess
(
id
)
{
return
httpRequest
.
get
(
`/api/ehall/v2/lobby/update-status-api/
${
id
}
`
)
return
httpRequest
.
get
(
`/api/ehall/v2/lobby/update-status-api/
${
id
}
`
)
}
}
/**
* 获取openId
*/
export
function
getOpenId
(
data
)
{
return
httpRequest
.
post
(
'/api/usercenter/v1/wechat/get-openid'
,
data
)
}
src/mixins/pay.js
0 → 100644
浏览文件 @
f2ea0059
import
*
as
api
from
'../api'
export
default
{
data
()
{
const
UA
=
window
.
navigator
.
userAgent
const
isMobile
=
/android|iphone|ipad|ipod/i
.
test
(
UA
)
return
{
isMobile
,
isWechat
:
/micromessenger/i
.
test
(
UA
),
openId
:
window
.
localStorage
.
getItem
(
'open_id'
)
}
},
watch
:
{
code
:
{
immediate
:
true
,
handler
(
code
)
{
if
(
code
&&
!
this
.
openId
)
{
this
.
handlePay
()
}
}
},
orderNo
:
{
immediate
:
true
,
handler
(
orderNo
)
{
orderNo
&&
this
.
getOrder
()
}
}
},
computed
:
{
code
()
{
return
this
.
$route
.
query
.
code
},
orderNo
()
{
return
this
.
$route
.
query
.
order_no
}
},
methods
:
{
// 创建微信订单
createWxPayOrder
(
productId
,
num
=
1
)
{
return
api
.
createWxpayOrder
(
'ezijing'
,
productId
,
{
num
,
openid
:
this
.
openId
}).
then
(
order
=>
{
const
redirectURI
=
`
${
location
.
href
}
&order_no=
${
order
.
order_no
}
`
// 去支付
window
.
location
.
href
=
`https://web-pay.ezijing.com/wxpay/h5?prepay_id=
${
order
.
prepay_id
}
&open_id=
${
this
.
openId
}
&redirect_uri=
${
encodeURIComponent
(
redirectURI
)}
`
})
},
// 获取微信code
getCode
()
{
const
redirectURI
=
`https://pages.ezijing.com/given/auth.html?redirect_uri=
${
encodeURIComponent
(
location
.
href
)}
`
window
.
location
.
href
=
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx451c01d40d090d7a&redirect_uri=
${
redirectURI
}
&response_type=code&scope=snsapi_base#wechat_redirect`
},
// 获取微信openid
getOpenId
(
callback
)
{
if
(
!
this
.
code
)
{
this
.
getCode
()
return
}
api
.
getOpenId
({
code
:
this
.
code
,
identity
:
'ezijing'
}).
then
(
response
=>
{
if
(
response
.
code
===
0
)
{
this
.
openId
=
response
.
openid
window
.
localStorage
.
setItem
(
'open_id'
,
this
.
openId
)
callback
&&
callback
(
response
)
}
else
{
this
.
getCode
()
}
})
},
getOrder
()
{
return
api
.
getOrder
(
this
.
orderNo
).
then
(
response
=>
{
const
{
order
}
=
response
if
(
response
.
status
===
1
)
{
// 支付成功
this
.
handlePaySuccess
()
}
return
order
})
},
// 微信JSAPI支付
handleWxJSAPIPay
(
productId
,
num
)
{
this
.
openId
?
this
.
createWxPayOrder
(
productId
,
num
)
:
this
.
getOpenId
(
this
.
createWxPayOrder
(
productId
,
num
))
}
}
}
src/views/Login.vue
浏览文件 @
f2ea0059
...
@@ -137,7 +137,7 @@ export default {
...
@@ -137,7 +137,7 @@ export default {
},
},
created
()
{
created
()
{
if
(
this
.
isWechat
&&
!
this
.
checkWechatLogin
())
{
if
(
this
.
isWechat
&&
!
this
.
checkWechatLogin
())
{
this
.
wechatLogin
()
//
this.wechatLogin()
}
}
}
}
}
}
...
...
src/views/report/PaperEdit.vue
浏览文件 @
f2ea0059
...
@@ -19,10 +19,11 @@
...
@@ -19,10 +19,11 @@
<
script
>
<
script
>
import
editMixins
from
'@/mixins/edit'
import
editMixins
from
'@/mixins/edit'
import
payMixins
from
'@/mixins/pay'
import
*
as
api
from
'@/api/index'
import
*
as
api
from
'@/api/index'
import
Pay
from
'@/components/Pay'
import
Pay
from
'@/components/Pay'
export
default
{
export
default
{
mixins
:
[
editMixins
],
mixins
:
[
editMixins
,
payMixins
],
metaInfo
:
{
title
:
'纸质成绩单'
},
metaInfo
:
{
title
:
'纸质成绩单'
},
components
:
{
Pay
},
components
:
{
Pay
},
data
()
{
data
()
{
...
@@ -50,7 +51,9 @@ export default {
...
@@ -50,7 +51,9 @@ export default {
'$route.query'
:
{
'$route.query'
:
{
immediate
:
true
,
immediate
:
true
,
handler
(
query
)
{
handler
(
query
)
{
this
.
payVisible
=
query
.
pay
===
'1'
if
(
query
.
pay
===
'1'
&&
!
query
.
order_no
&&
!
query
.
code
)
{
this
.
handlePay
()
}
}
}
}
}
},
},
...
@@ -129,7 +132,11 @@ export default {
...
@@ -129,7 +132,11 @@ export default {
},
},
// 去支付
// 去支付
handlePay
()
{
handlePay
()
{
this
.
payVisible
=
true
if
(
this
.
isWechat
)
{
this
.
handleWxJSAPIPay
(
this
.
productId
)
}
else
{
this
.
payVisible
=
true
}
},
},
// 支付成功
// 支付成功
handlePaySuccess
()
{
handlePaySuccess
()
{
...
...
src/views/retake/Edit.vue
浏览文件 @
f2ea0059
...
@@ -17,10 +17,11 @@
...
@@ -17,10 +17,11 @@
<
script
>
<
script
>
import
editMixins
from
'@/mixins/edit'
import
editMixins
from
'@/mixins/edit'
import
payMixins
from
'@/mixins/pay'
import
*
as
api
from
'@/api/index'
import
*
as
api
from
'@/api/index'
import
Pay
from
'@/components/Pay'
import
Pay
from
'@/components/Pay'
export
default
{
export
default
{
mixins
:
[
editMixins
],
mixins
:
[
editMixins
,
payMixins
],
metaInfo
:
{
title
:
'申请重修'
},
metaInfo
:
{
title
:
'申请重修'
},
components
:
{
Pay
},
components
:
{
Pay
},
data
()
{
data
()
{
...
@@ -140,7 +141,11 @@ export default {
...
@@ -140,7 +141,11 @@ export default {
},
},
// 去支付
// 去支付
handlePay
()
{
handlePay
()
{
this
.
payVisible
=
true
if
(
this
.
isWechat
)
{
this
.
handleWxJSAPIPay
(
this
.
productId
)
}
else
{
this
.
payVisible
=
true
}
},
},
// 支付成功
// 支付成功
handlePaySuccess
()
{
handlePaySuccess
()
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论