Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zuiketang
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
zuiketang
Commits
73a8b7d6
Commit
73a8b7d6
authored
Oct 19, 2016
by
xiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改微信支付接口
parent
a1e80c8c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
11 deletions
+68
-11
HomeController.php
src/frontend/controllers/HomeController.php
+25
-5
video-play.vue
src/frontend/web/js/home/components/video-play.vue
+43
-6
No files found.
src/frontend/controllers/HomeController.php
View file @
73a8b7d6
...
...
@@ -411,10 +411,9 @@ class HomeController extends \yii\web\Controller
}
/**
* 获取微信支付的
二维码
* 获取微信支付的
数据
*/
public
function
actionWeixinPayQrcode
(
$courseId
)
public
function
actionWeixinPayQrcode
(
$courseId
)
{
$courseBaseInfo
=
Course
::
findBaseInfoByCourseId
(
$courseId
);
if
(
$courseBaseInfo
!==
NULL
)
{
...
...
@@ -439,14 +438,35 @@ class HomeController extends \yii\web\Controller
$order
->
update
();
}
}
$weixinPay
=
WeixinPay
::
getInstance
();
return
QrCode
::
jpg
(
$weixinPay
->
makePayUrl
(
$number
)
);
Utils
::
ajaxResponse
(
TRUE
,
'ok'
,
[
'number'
=>
$number
]
);
}
else
{
throw
new
InvalidParamException
(
'参数错误'
);
}
}
/**
* 判断支付状态
* @param $number
*/
public
function
actionCheckPayStatus
(
$number
)
{
$order
=
Orders
::
findOne
([
'number'
=>
$number
]);
$result
=
(
$order
!==
NULL
and
$order
->
status
===
Orders
::
PAID
)
?
TRUE
:
FALSE
;
Utils
::
ajaxResponse
(
TRUE
,
'ok'
,
$result
);
}
/**
* @param $number
* 生成二维码
*/
public
function
actionGetQrcode
(
$number
)
{
$weixinPay
=
WeixinPay
::
getInstance
();
$url
=
$weixinPay
->
makePayUrl
(
$number
);
return
QrCode
::
jpg
(
urldecode
(
$url
));
}
/**
* 移动端微信支付
...
...
src/frontend/web/js/home/components/video-play.vue
View file @
73a8b7d6
<
template
>
<
template
xmlns:v-el=
"http://www.w3.org/1999/xhtml"
>
<div
class=
"container"
>
<div
class=
"cnt-tit"
>
<h3>
{{
coursewareInfo
.
courseName
}}
</h3>
...
...
@@ -68,9 +68,8 @@
<div class="
top
-
back
-
a
">
<a href="
javascript
:;
" @click="
showQrcode
=
false
"> < 返回支付渠道选择</a>
</div>
<div class="
qrcode
-
img
">
<img v-if="
showQrcode
" :src="
getWeixinPayQrcode
(
coursewareInfo
.
course_id
)
">
<p>请使用微信扫一扫付款</p>
<div v-el:weixin-qrcode class="
qrcode
-
img
">
正在加载
</div>
</div>
</div>
...
...
@@ -110,12 +109,50 @@
export default{
data(){
return {
showQrcode: false
showQrcode: false,
weixinCheckHandler: false,
reload:false
}
}
,
watch: {
reload(){
window.location.reload();
}
,
showQrcode(){
if (this.showQrcode === true) {
var self = this;
var url = __BASE_URL__ + 'home/weixin-pay-qrcode?courseId=' + self.coursewareInfo.course_id;
$.getJSON(url, function (response) {
if (response.status !== false) {
var imgUrl = __BASE_URL__ + 'home/get-qrcode?number=' + response.data.number;
$(self.$els.weixinQrcode).html('<img src="
' + imgUrl + '
"/> <p>请使用微信扫一扫付款</p>');
//添加监听
clearInterval(self.weixinCheckHandler);
self.weixinCheckHandler = setInterval(function () {
var checkUrl = __BASE_URL__ + 'home/check-pay-status?number=' + response.data.number;
$.getJSON(checkUrl, function (response) {
if (response.status) {
if (response.data) {
self.reload = true;
}
}
}
);
}
, 1500);
}
}
).error(function () {
layer.alert('获取微信url信息错误', {
'icon': 2, 'title': '提示'
}
)
}
);
}
else {
clearInterval(this.weixinCheckHandler);
}
}
}
,
methods: {
getWeixinPayQrcode(courseId){
return __BASE_URL__ + 'home/weixin-pay-qrcode?courseId=' + courseId;
}
,
alipay(courseId){
var url = __BASE_URL__ + 'home/pay?courseId=' + courseId;
...
...
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