Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
project-online-old
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
project-online-old
Commits
7bf6785a
提交
7bf6785a
authored
12月 21, 2020
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增微信支付
上级
b4645f11
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
205 行增加
和
90 行删除
+205
-90
my.js
src/api/my.js
+7
-0
h5Pay.vue
src/pages/my/welcome/components/h5Pay.vue
+78
-0
qrcodePay.vue
src/pages/my/welcome/components/qrcodePay.vue
+102
-0
indexPay.vue
src/pages/my/welcome/indexPay.vue
+18
-90
没有找到文件。
src/api/my.js
浏览文件 @
7bf6785a
...
@@ -122,3 +122,10 @@ export function changeFileStatus(userId, recordId, status) {
...
@@ -122,3 +122,10 @@ export function changeFileStatus(userId, recordId, status) {
{
status
}
{
status
}
)
)
}
}
/**
* 修改用户信息
*/
export
function
getOpenId
(
data
)
{
return
httpRequest
.
post
(
'/usercenter/v1/wechat/get-openid'
,
data
)
}
src/pages/my/welcome/components/h5Pay.vue
0 → 100644
浏览文件 @
7bf6785a
<
template
>
<div
class=
"h5pay"
>
<el-button
type=
"primary"
@
click=
"handlePay"
>
去支付
</el-button>
</div>
</
template
>
<
script
>
import
*
as
api
from
'@/api/my'
export
default
{
data
()
{
return
{
openId
:
window
.
localStorage
.
getItem
(
'open_id'
),
errorMessage
:
''
}
},
computed
:
{
pageUrl
()
{
return
window
.
location
.
origin
+
this
.
$route
.
path
}
},
methods
:
{
// 获取订单
getOrder
()
{
api
.
getOrder
({
wx_open_id
:
this
.
openId
,
payment_method
:
'WX_PAY'
}).
then
(
response
=>
{
const
{
data
,
error
,
message
}
=
response
if
(
error
.
toString
()
===
'0'
)
{
this
.
order
=
data
this
.
$emit
(
'update'
,
this
.
order
)
}
else
{
this
.
errorMessage
=
message
}
})
},
// 获取微信code
getCode
()
{
const
redirectURI
=
`https://pages.ezijing.com/given/auth.html?redirect_uri=
${
encodeURIComponent
(
this
.
pageUrl
)}
`
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
(
code
)
{
api
.
getOpenId
({
code
,
identity
:
'ezijing'
}).
then
(
response
=>
{
if
(
response
.
code
===
0
)
{
this
.
openId
=
response
.
openid
window
.
localStorage
.
setItem
(
'open_id'
,
this
.
openId
)
this
.
getOrder
()
}
else
{
this
.
getCode
()
}
})
},
// 去支付
handlePay
()
{
if
(
this
.
order
.
wx_prepay_id
)
{
window
.
location
.
href
=
`https://web-pay.ezijing.com/wxpay/h5?prepay_id=
${
this
.
order
.
wx_prepay_id
}
&open_id=
${
this
.
openId
}
&redirect_uri=
${
encodeURIComponent
(
this
.
pageUrl
)}
`
}
else
{
this
.
$message
.
error
(
this
.
errorMessage
)
}
}
},
beforeMount
()
{
if
(
this
.
openId
)
{
this
.
getOrder
()
return
}
const
{
code
}
=
this
.
$route
.
query
code
?
this
.
getOpenId
(
code
)
:
this
.
getCode
()
}
}
</
script
>
<
style
scoped
>
.h5pay
{
padding
:
40px
;
text-align
:
center
;
}
</
style
>
src/pages/my/welcome/components/qrcodePay.vue
0 → 100644
浏览文件 @
7bf6785a
<
template
>
<div
class=
"qrpay"
>
<div
class=
"qrpay-hd"
>
<div
class=
"pic"
>
<img
src=
"../../../../assets/images/my_pay_02.png"
height=
"160"
/>
</div>
<h1>
请使用微信扫描下方二维码
</h1>
</div>
<div
class=
"qrcode-error"
v-if=
"qrcodeError"
>
生成二维码失败请刷新
<i
class=
"el-icon-refresh-left"
@
click=
"getOrder"
title=
"刷新"
></i>
</div>
<div
class=
"qrcode"
v-else
>
<qrcode-vue
:value=
"qrcodeValue"
size=
"100"
></qrcode-vue>
<span
@
click=
"getOrder"
>
刷新
</span>
</div>
</div>
</
template
>
<
script
>
import
QrcodeVue
from
'qrcode.vue'
import
*
as
api
from
'@/api/my'
export
default
{
components
:
{
QrcodeVue
},
data
()
{
return
{
order
:
{
id
:
''
,
payment_url
:
''
},
qrcodeError
:
false
}
},
computed
:
{
// 二维码地址
qrcodeValue
()
{
return
this
.
order
.
payment_url
}
},
methods
:
{
// 获取订单
getOrder
()
{
api
.
getOrder
({
payment_method
:
'WX_PAY_QR'
}).
then
(
response
=>
{
const
{
data
,
error
,
message
}
=
response
this
.
qrcodeError
=
error
.
toString
()
===
'1'
if
(
error
.
toString
()
===
'0'
)
{
this
.
order
=
data
this
.
$emit
(
'update'
,
this
.
order
)
}
else
{
this
.
$message
.
error
(
message
)
}
})
}
},
beforeMount
()
{
this
.
getOrder
()
}
}
</
script
>
<
style
lang=
"scss"
scoped
>
.qrpay-hd
{
.pic
{
text-align
:
center
;
}
h1
{
margin-top
:
40px
;
font-size
:
24px
;
font-weight
:
500
;
color
:
#222
;
line-height
:
1
;
text-align
:
center
;
}
}
.qrcode
{
padding
:
20px
0
;
text-align
:
center
;
span
{
margin-top
:
10px
;
font-size
:
12px
;
color
:
#999
;
cursor
:
pointer
;
}
}
.qrcode-error
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
flex-direction
:
column
;
width
:
100px
;
height
:
100px
;
padding
:
10px
;
margin
:
20px
auto
;
color
:
var
(
--
main-color
);
border-style
:
dashed
;
border-width
:
1px
;
border-color
:
var
(
--
main-color
);
box-sizing
:
border-box
;
text-align
:
center
;
i
{
margin-top
:
10px
;
cursor
:
pointer
;
}
}
</
style
>
src/pages/my/welcome/indexPay.vue
浏览文件 @
7bf6785a
<
template
>
<
template
>
<div
class=
"pay"
>
<div
class=
"pay"
>
<div
class=
"pay-hd"
>
<h5-pay
@
update=
"handleUpdateOrder"
v-if=
"isWechat"
></h5-pay>
<div
class=
"pic"
>
<qrcode-pay
@
update=
"handleUpdateOrder"
v-else
></qrcode-pay>
<img
src=
"../../../assets/images/my_pay_02.png"
height=
"160"
/>
</div>
<h1>
请使用微信扫描下方二维码
</h1>
</div>
<div
class=
"qrcode-error"
v-if=
"qrcodeError"
>
生成二维码失败请刷新
<i
class=
"el-icon-refresh-left"
@
click=
"refreshQrcode"
title=
"刷新"
></i>
</div>
<div
class=
"qrcode"
v-else
>
<qrcode-vue
:value=
"qrcodeValue"
size=
"100"
></qrcode-vue>
<span
@
click=
"refreshQrcode"
>
刷新
</span>
</div>
<div
class=
"pay-ft"
>
<div
class=
"pay-ft"
>
<p
class=
"t2"
>
注释:在提交600元申请费后,申请人需上传并提交如下文件。
</p>
<p
class=
"t2"
>
注释:在提交600元申请费后,申请人需上传并提交如下文件。
</p>
<p
class=
"t2"
>
①填写报名表、②完成推荐信2封、③本科学历学位证书、④中英文成绩单、⑤个人证件照
</p>
<p
class=
"t2"
>
①填写报名表、②完成推荐信2封、③本科学历学位证书、④中英文成绩单、⑤个人证件照
</p>
...
@@ -37,17 +26,17 @@
...
@@ -37,17 +26,17 @@
</template>
</template>
<
script
>
<
script
>
import
QrcodeVue
from
'qrcode.vue'
import
*
as
api
from
'@/api/my'
import
*
as
api
from
'@/api/my'
import
qrcodePay
from
'./components/qrcodePay'
import
h5Pay
from
'./components/h5Pay'
export
default
{
export
default
{
name
:
'AppPay'
,
name
:
'AppPay'
,
components
:
{
QrcodeVue
},
components
:
{
qrcodePay
,
h5Pay
},
data
()
{
data
()
{
const
UA
=
window
.
navigator
.
userAgent
return
{
return
{
is
Pass
:
false
,
is
Wechat
:
/micromessenger/i
.
test
(
UA
)
,
order
:
{
id
:
''
,
payment_url
:
''
},
order
:
{
id
:
''
,
payment_url
:
''
},
qrcodeError
:
false
,
dialogVisible
:
false
,
dialogVisible
:
false
,
timer
:
null
,
timer
:
null
,
paymentRecords
:
[]
// 所有订单
paymentRecords
:
[]
// 所有订单
...
@@ -96,55 +85,37 @@ export default {
...
@@ -96,55 +85,37 @@ export default {
}
}
})
})
},
},
// 获取订单
async
getOrder
()
{
if
(
this
.
paySuccess
)
{
return
}
await
api
.
getOrder
({
payment_method
:
'WX_PAY_QR'
}).
then
(
response
=>
{
const
{
data
,
error
,
message
}
=
response
this
.
qrcodeError
=
error
.
toString
()
===
'1'
if
(
error
.
toString
()
===
'0'
)
{
this
.
order
=
data
}
else
{
this
.
$message
.
error
(
message
)
}
})
},
// 刷新二维码
refreshQrcode
()
{
this
.
getOrder
()
},
// 检查支付状态
// 检查支付状态
async
checkPay
(
order
)
{
checkPay
(
order
)
{
if
(
this
.
paySuccess
)
{
this
.
timer
&&
clearInterval
(
this
.
timer
)
return
}
const
userId
=
window
.
G
.
UserInfo
.
id
const
userId
=
window
.
G
.
UserInfo
.
id
a
wait
a
pi
.
checkPay
(
order
.
id
,
{
user_id
:
userId
}).
then
(
response
=>
{
api
.
checkPay
(
order
.
id
,
{
user_id
:
userId
}).
then
(
response
=>
{
if
(
response
.
data
.
payment_status
===
'SUCCESS'
)
{
if
(
response
.
data
.
payment_status
===
'SUCCESS'
)
{
this
.
timer
&&
clearInterval
(
this
.
timer
)
this
.
timer
&&
clearInterval
(
this
.
timer
)
this
.
dialogVisible
=
true
this
.
dialogVisible
=
true
}
}
})
})
},
},
// 检测支付状态定时器
setCheckPayTimer
()
{
setCheckPayTimer
()
{
this
.
timer
&&
clearInterval
(
this
.
timer
)
this
.
timer
&&
clearInterval
(
this
.
timer
)
this
.
timer
=
setInterval
(()
=>
{
this
.
timer
=
setInterval
(()
=>
{
this
.
orderList
.
forEach
(
order
=>
{
if
(
this
.
paySuccess
)
{
this
.
checkPay
(
order
)
this
.
timer
&&
clearInterval
(
this
.
timer
)
})
return
}
this
.
orderList
.
forEach
(
order
=>
this
.
checkPay
(
order
))
},
3000
)
},
3000
)
},
},
// 填写个人资料
// 填写个人资料
toApplication
()
{
toApplication
()
{
this
.
$router
.
push
(
'/my/application?active=application_info'
)
this
.
$router
.
push
(
'/my/application?active=application_info'
)
},
handleUpdateOrder
(
order
)
{
this
.
order
=
order
}
}
},
},
async
mounted
()
{
async
mounted
()
{
await
this
.
getApplication
()
await
this
.
getApplication
()
await
this
.
getOrder
()
this
.
setCheckPayTimer
()
this
.
setCheckPayTimer
()
},
},
destroyed
()
{
destroyed
()
{
...
@@ -159,49 +130,6 @@ export default {
...
@@ -159,49 +130,6 @@ export default {
margin
:
0
auto
;
margin
:
0
auto
;
padding
:
40px
0
;
padding
:
40px
0
;
}
}
.pay-hd
{
.pic
{
text-align
:
center
;
}
h1
{
margin-top
:
40px
;
font-size
:
24px
;
font-weight
:
500
;
color
:
#222
;
line-height
:
1
;
text-align
:
center
;
}
}
.qrcode
{
padding
:
20px
0
;
text-align
:
center
;
span
{
margin-top
:
10px
;
font-size
:
12px
;
color
:
#999
;
cursor
:
pointer
;
}
}
.qrcode-error
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
flex-direction
:
column
;
width
:
100px
;
height
:
100px
;
padding
:
10px
;
margin
:
20px
auto
;
color
:
var
(
--
main-color
);
border-style
:
dashed
;
border-width
:
1px
;
border-color
:
var
(
--
main-color
);
box-sizing
:
border-box
;
text-align
:
center
;
i
{
margin-top
:
10px
;
cursor
:
pointer
;
}
}
.t1
{
.t1
{
font-size
:
14px
;
font-size
:
14px
;
color
:
#303030
;
color
:
#303030
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论