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
65e16641
Commit
65e16641
authored
Oct 20, 2016
by
汪波
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev' into dev
parents
2ea0e5c1
3f2c9e4c
Changes
34
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
1036 additions
and
505 deletions
+1036
-505
ApiWeixin.php
src/common/libs/ApiWeixin.php
+195
-0
OAuth2.php
src/common/libs/OAuth2.php
+433
-0
Utils.php
src/common/libs/Utils.php
+17
-2
WxPay.JsApiPay.php
src/common/libs/weixin/WxPay.JsApiPay.php
+1
-1
Member.php
src/common/models/Member.php
+8
-0
composer.lock
src/composer.lock
+2
-56
params-local.php
src/environments/prod/common/config/params-local.php
+1
-1
ClassesFilter.php
src/frontend/components/ClassesFilter.php
+8
-13
main.php
src/frontend/config/main.php
+0
-1
params.php
src/frontend/config/params.php
+1
-1
HomeController.php
src/frontend/controllers/HomeController.php
+2
-39
MyIncomeController.php
src/frontend/controllers/MyIncomeController.php
+56
-2
PayController.php
src/frontend/controllers/PayController.php
+39
-1
SiteController.php
src/frontend/controllers/SiteController.php
+110
-151
PasswordResetRequestForm.php
src/frontend/models/PasswordResetRequestForm.php
+12
-1
ResetPasswordForm.php
src/frontend/models/ResetPasswordForm.php
+1
-1
SignupForm.php
src/frontend/models/SignupForm.php
+15
-2
TokenInputForm.php
src/frontend/models/TokenInputForm.php
+16
-1
blank.php
src/frontend/views/layouts/blank.php
+26
-0
centerHeader.php
src/frontend/views/layouts/centerHeader.php
+1
-1
index.php
src/frontend/views/my-income/index.php
+11
-3
requestPasswordResetToken.php
src/frontend/views/site/requestPasswordResetToken.php
+11
-5
resetPassword.php
src/frontend/views/site/resetPassword.php
+6
-17
signup.php
src/frontend/views/site/signup.php
+11
-6
tokenInput.php
src/frontend/views/site/tokenInput.php
+10
-5
index.php
src/frontend/views/weixin-js-pay/index.php
+10
-58
no-connection.gif
src/frontend/web/img/no-connection.gif
+0
-0
qrcode.jpg
src/frontend/web/img/qrcode.jpg
+0
-0
video-play.vue
src/frontend/web/js/home/components/video-play.vue
+5
-4
index.js
src/frontend/web/js/my-income/index.js
+20
-0
request_password_reset.js
src/frontend/web/js/site/request_password_reset.js
+1
-36
signup.js
src/frontend/web/js/site/signup.js
+4
-60
token_input.js
src/frontend/web/js/site/token_input.js
+1
-36
webpack.config.js
src/frontend/web/webpack.config.js
+2
-1
No files found.
src/common/libs/ApiWeixin.php
0 → 100644
View file @
65e16641
<?php
/**
* 微信 API
*
* $Id$
*/
namespace
common\libs
;
class
ApiWeixin
extends
OAuth2
{
private
$token
;
protected
$_type
=
'weixin'
;
/**
* Set up the API params.
*
* @ignore
*/
protected
$host
=
'https://api.weixin.qq.com/'
;
protected
$format
=
'json'
;
public
$debug
=
false
;
public
function
__construct
(
$accessToken
=
null
,
$refreshToken
=
null
,
$openid
=
null
)
{
$config
=
\Yii
::
$app
->
params
[
'weixinpay'
];
//$this->token = $config['token'];
parent
::
__construct
(
$config
[
'appid'
],
$config
[
'appsecret'
],
$accessToken
,
$refreshToken
,
$openid
);
//不传递 AccessToken 时,默认使用 API AccessToken
if
(
$accessToken
===
null
)
{
$accessToken
=
$this
->
getClientAccessToken
();
parent
::
__construct
(
$config
[
'appid'
],
$config
[
'appsecret'
],
$accessToken
,
$refreshToken
,
$openid
);
}
$this
->
useragent
=
'PHP/'
.
PHP_VERSION
;
}
/**
* 设置 OAuth 认证需要的 Urls
*
* @ignore
*/
public
function
accessTokenURL
(
$type
)
{
if
(
$type
==
'client'
)
{
return
$this
->
host
.
'cgi-bin/token'
;
}
else
{
return
$this
->
host
.
'sns/oauth2/access_token'
;
}
}
public
function
authorizeURL
()
{
return
'https://open.weixin.qq.com/connect/oauth2/authorize'
;
}
public
function
getAuthorizeURLWrapped
(
$url
,
$state
=
''
)
{
return
$this
->
getAuthorizeURL
(
$url
,
'code'
,
'snsapi_userinfo'
,
$state
)
.
'#wechat_redirect'
;
}
/**
* 获取微信API客户端 AccessToken,已进行相应的缓存处理
*
* @throws OAuthException
* @return string
*/
public
function
getClientAccessToken
()
{
$k
=
'yy_wxapi_access_token'
;
$token
=
\Yii
::
$app
->
redis
->
get
(
$k
);
if
(
$token
!==
null
)
{
return
$token
;
}
$ret
=
$this
->
getAccessToken
(
'client'
);
if
(
isset
(
$ret
[
'access_token'
]))
{
\Yii
::
$app
->
redis
->
setex
(
$k
,
$ret
[
'expires_in'
]
-
8
,
$ret
[
'access_token'
]);
}
else
{
throw
new
OAuthException
(
'get client access token failed because: '
.
$ret
[
'errmsg'
]
.
'('
.
$ret
[
'errcode'
]
.
')'
);
}
return
$ret
[
'access_token'
];
}
/**
* 获取用于某些接口使用的 ticket,已作缓存处理
*
* @param string $type
* @throws OAuthException
* @return string
*/
public
function
getTicket
(
$type
=
'jsapi'
)
{
$k
=
'yy_wxapi_ticket_'
.
$type
;
$ticket
=
\Yii
::
$app
->
redis
->
get
(
'get'
,
$k
);
if
(
$ticket
!==
null
)
{
return
$ticket
;
}
$accessToken
=
$this
->
getClientAccessToken
();
$ret
=
$this
->
get
(
'cgi-bin/ticket/getticket'
,
array
(
'access_token'
=>
$accessToken
,
'type'
=>
$type
));
if
(
$ret
[
'errcode'
]
==
0
)
{
\Yii
::
$app
->
redis
->
setex
(
$k
,
$ret
[
'expires_in'
]
-
8
,
$ret
[
'ticket'
]);
}
else
{
throw
new
OAuthException
(
"get
$type
ticket failed because:
{
$ret
[
'errmsg'
]
}
(
{
$ret
[
'errcode'
]
}
)"
);
}
return
$ret
[
'ticket'
];
}
/**
* 获取关注者 openid 列表
*
* @param string $nextOpenId
* @return array
*/
public
function
getUser
(
$nextOpenId
=
''
)
{
return
$this
->
get
(
'cgi-bin/user/get'
,
array
(
'next_openid'
=>
$nextOpenId
));
}
/**
* 通过 openid 获取指定关注者信息
*
* @param $openId
* @return mixed
*/
public
function
userInfo
(
$openId
)
{
//snsapi_userinfo 方式获取信息
return
$this
->
get
(
'sns/userinfo'
,
array
(
'openid'
=>
$openId
,
'lang'
=>
'zh_CN'
));
//snsapi_base 方式获取信息
//return $this->get('cgi-bin/user/info', array('openid'=>$openId));
}
public
function
sendTemplateMessage
(
$openId
,
$templateId
,
$data
,
$url
=
''
,
$topColor
=
'#FF0000'
)
{
$data
=
array
(
'touser'
=>
$openId
,
'template_id'
=>
$templateId
,
'url'
=>
$url
,
'topcolor'
=>
$topColor
,
'data'
=>
$data
);
return
$this
->
post
(
'cgi-bin/message/template/send'
,
$data
);
}
/**
* 创建二维码 Ticket
*
* @param int|string $sceneIdOrStr 当使用永久字符串参数二维码时,此处为字符串 scene_str 值,否则是 scene_id 值
* @param string $actionName QR_SCENE:临时二维码,QR_LIMIT_SCENE:永久二维码,QR_LIMIT_STR_SCENE:永久字符串参数二维码
* @param int $expireSeconds 临时有效期,最长7天,604800秒
* @return mixed
*/
public
function
createQRCode
(
$sceneIdOrStr
,
$actionName
=
'QR_SCENE'
,
$expireSeconds
=
1800
)
{
$data
=
array
(
'expire_seconds'
=>
$expireSeconds
,
'action_name'
=>
$actionName
,
'action_info'
=>
array
()
);
if
(
$actionName
==
'QR_LIMIT_STR_SCENE'
)
{
$data
[
'action_info'
][
'scene_str'
]
=
$sceneIdOrStr
;
}
else
{
$data
[
'action_info'
][
'scene_id'
]
=
$sceneIdOrStr
;
}
return
$this
->
post
(
'cgi-bin/qrcode/create'
,
$data
);
}
/**
* 通过 Ticket 换取二维码
*
* @param $ticket
* @return mixed
*/
public
function
showQRCode
(
$ticket
)
{
return
'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket='
.
urlencode
(
$ticket
);
}
/**
* 发送 POST 请求
*
* 微信接口 POST 包体为 json 数据,此处进行封装
*
* @param string $url
* @param array $parameters
* @param bool $multi
* @return mixed
*/
protected
function
post
(
$url
,
$parameters
=
array
(),
$multi
=
false
)
{
!
$multi
&&
$parameters
=
json_encode
(
$parameters
);
return
parent
::
post
(
$url
,
$parameters
,
$multi
);
}
}
\ No newline at end of file
src/common/libs/OAuth2.php
0 → 100644
View file @
65e16641
This diff is collapsed.
Click to expand it.
src/common/libs/Utils.php
View file @
65e16641
...
...
@@ -8,7 +8,7 @@
namespace
common\libs
;
use
yii\base\ExitException
;
use
yii\web\Response
;
class
Utils
...
...
@@ -76,7 +76,22 @@ class Utils
return
''
;
}
/**
* 显示提示信息页面
*
* @param string $message
* @throws ExitException
*/
public
static
function
showWarn
(
$message
)
{
\Yii
::
$app
->
controller
->
layout
=
'blank'
;
\Yii
::
$app
->
response
->
data
=
\Yii
::
$app
->
controller
->
render
(
'@app/views/site/warn'
,
[
'message'
=>
$message
]);
\Yii
::
$app
->
response
->
send
();
throw
new
ExitException
();
}
/**
* 生成4-6位随机数
...
...
src/common/libs/weixin/WxPay.JsApiPay.php
View file @
65e16641
...
...
@@ -99,7 +99,7 @@ class JsApiPay
//初始化curl
$ch
=
curl_init
();
//设置超时
curl_setopt
(
$ch
,
CURLOPT_TIMEOUT
,
$this
->
curl_timeout
);
curl_setopt
(
$ch
,
CURLOPT_TIMEOUT
,
20
);
curl_setopt
(
$ch
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
FALSE
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYHOST
,
FALSE
);
...
...
src/common/models/Member.php
View file @
65e16641
...
...
@@ -3,7 +3,9 @@
namespace
common\models
;
use
Yii
;
use
yii\behaviors\TimestampBehavior
;
use
yii\data\Pagination
;
use
yii\db\ActiveRecord
;
/**
* This is the model class for table "member".
...
...
@@ -155,6 +157,12 @@ class Member extends \yii\db\ActiveRecord
}
}
/**
* 获取不同类型会员的数量统计
*
* @param int $userId
* @return array
*/
public
static
function
typeCount
(
$userId
)
{
$data
=
self
::
find
()
->
select
(
'COUNT(1) AS count, type'
)
->
where
([
'user_id'
=>
$userId
])
->
groupBy
(
'type'
)
...
...
src/composer.lock
View file @
65e16641
...
...
@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "4
454b16ac08c05c643766291ce0b6335
",
"content-hash": "
7cd14e3280f6fcccf735c7641fab4a28
",
"hash": "4
79a584a432c765bda14b8e45493291a
",
"content-hash": "
b2a9e1b6aa19ba113948022d2525b40b
",
"packages": [
{
"name": "2amigos/yii2-qrcode-helper",
...
...
@@ -572,60 +572,6 @@
],
"time": "2015-08-15 16:07:34"
},
{
"name": "mobiledetect/mobiledetectlib",
"version": "2.8.22",
"source": {
"type": "git",
"url": "https://github.com/serbanghita/Mobile-Detect.git",
"reference": "53cddae0c272a478b24a4b5fb60d0f838caf70b6"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/serbanghita/Mobile-Detect/53cddae0c272a478b24a4b5fb60d0f838caf70b6.zip",
"reference": "53cddae0c272a478b24a4b5fb60d0f838caf70b6",
"shasum": ""
},
"require": {
"php": ">=5.0.0"
},
"require-dev": {
"codeclimate/php-test-reporter": "dev-master",
"johnkary/phpunit-speedtrap": "~1.0@dev",
"phpunit/phpunit": "*"
},
"type": "library",
"autoload": {
"classmap": [
"Mobile_Detect.php"
],
"psr-0": {
"Detection": "namespaced/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Serban Ghita",
"email": "serbanghita@gmail.com",
"homepage": "http://mobiledetect.net",
"role": "Developer"
}
],
"description": "Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.",
"homepage": "https://github.com/serbanghita/Mobile-Detect",
"keywords": [
"detect mobile devices",
"mobile",
"mobile detect",
"mobile detector",
"php mobile detect"
],
"time": "2016-04-24 09:47:16"
},
{
"name": "psr/http-message",
"version": "1.0.1",
...
...
src/environments/prod/common/config/params-local.php
View file @
65e16641
...
...
@@ -9,7 +9,7 @@ return [
'msg.userid'
=>
'78'
,
'msg.account'
=>
'276147613x'
,
'msg.password'
=>
'276147613'
,
'msg.signature'
=>
'【
最课堂
】'
,
'msg.signature'
=>
'【
云涯
】'
,
'alipay'
=>
[
'partner'
=>
'2088701843067550'
,
'seller_id'
=>
'2088701843067550'
,
...
...
src/frontend/components/ClassesFilter.php
View file @
65e16641
...
...
@@ -8,6 +8,7 @@
namespace
frontend\components
;
use
common\libs\Utils
;
use
common\models\Classes
;
use
Yii
;
use
yii\base\ActionFilter
;
...
...
@@ -40,31 +41,25 @@ class ClassesFilter extends ActionFilter
public
function
beforeAction
(
$action
)
{
$uid
=
Yii
::
$app
->
user
->
getId
();
if
(
!
$uid
)
{
return
parent
::
beforeAction
(
$action
);
}
$class
=
Classes
::
getUserClass
(
$uid
);
if
(
!
$class
)
{
$this
->
showAlert
(
0
);
return
false
;
Utils
::
showWarn
(
'您还没有创建课堂,无法访问此页面!'
);
}
if
(
$this
->
_checkStatus
&&
$class
[
'status'
]
!=
Classes
::
STATUS_OK
)
{
$this
->
showAlert
(
1
);
return
false
;
Utils
::
showWarn
(
'您提交的课堂资料尚未通过审核,无法访问此页面!'
);
}
if
(
property_exists
(
Yii
::
$app
->
controller
,
'classStatus'
))
{
Yii
::
$app
->
controller
->
classStatus
=
$class
;
}
return
parent
::
beforeAction
(
$action
);
}
public
function
showAlert
(
$exists
)
{
Yii
::
$app
->
response
->
data
=
Yii
::
$app
->
view
->
renderFile
(
'@app/views/site/error.php'
,
[
'name'
=>
'提示消息'
,
'message'
=>
$exists
?
'您提交的课堂资料尚未通过审核,无法访问此页面!'
:
'您还没有创建课堂,无法访问此页面!'
]);
return
parent
::
beforeAction
(
$action
);
}
}
\ No newline at end of file
src/frontend/config/main.php
View file @
65e16641
...
...
@@ -21,7 +21,6 @@ return [
],
'assetManager'
=>
[
'appendTimestamp'
=>
TRUE
,
//'baseUrl' => 'http://www.baidu.com/',
'bundles'
=>
[
'yii\web\JqueryAsset'
=>
FALSE
,
]
...
...
src/frontend/config/params.php
View file @
65e16641
<?php
return
[
'adminEmail'
=>
'admin@example.com'
,
'signup.msg'
=>
'您正在注册
最课堂
,验证码: xxxxxx,2小时内有效'
,
'signup.msg'
=>
'您正在注册
云涯
,验证码: xxxxxx,2小时内有效'
,
'resetpassword.msg'
=>
'您正在找回密码,验证码: xxxxxx,2小时内有效'
,
];
src/frontend/controllers/HomeController.php
View file @
65e16641
...
...
@@ -403,12 +403,13 @@ class HomeController extends \yii\web\Controller
"subject"
=>
"购买课程-
{
$courseBaseInfo
[
'name'
]
}
"
,
//订单名称
"total_fee"
=>
$price
,
//付款金额
"body"
=>
'云崖购买'
,
//商品描述
'return_url'
=>
Yii
::
$app
->
request
->
hostInfo
.
'/pay/alipay-return-url'
);
if
(
Yii
::
$app
->
deviceDetect
->
isMobile
())
{
$parameter
[
'service'
]
=
\Yii
::
$app
->
params
[
'alipay'
][
'wap_service'
];
$parameter
[
'app_pay'
]
=
'Y'
;
$parameter
[
'return_rul'
]
=
Url
::
base
()
.
'home/video?courseId='
.
$courseId
;
}
$html_text
=
$alipay
->
buildRequestForm
(
$parameter
,
"get"
,
"确认"
);
echo
$html_text
;
...
...
@@ -476,44 +477,6 @@ class HomeController extends \yii\web\Controller
return
QrCode
::
jpg
(
urldecode
(
$url
));
}
/**
* 移动端微信支付
*/
public
function
actionMobilePay
()
{
$weixinpay
=
\Yii
::
$app
->
params
[
'weixinpay'
];
$client
=
new
Client
(
[
'timeout'
=>
8
,
'verify'
=>
FALSE
,
'connect_timeout'
=>
8
]
);
$order_id
=
'12312312323'
;
$uri
=
WeixinPay
::
UNIFIEDORDER
;
$xml
=
[
'appid'
=>
$weixinpay
[
'appid'
],
'mch_id'
=>
$weixinpay
[
'mchid'
],
'device_info'
=>
"WEB"
,
'nonce_str'
=>
Yii
::
$app
->
security
->
generateRandomString
(
16
),
'sign'
=>
''
,
'body'
=>
'最课堂-课程购买'
,
'out_trade_no'
=>
$order_id
,
'total_fee'
=>
1
,
'spbill_create_ip'
=>
$_SERVER
[
'SERVER_ADDR'
],
'notify_url'
=>
WeixinPay
::
NOTIFY_URL
,
'trade_type'
=>
'MWEB'
,
];
$xml
[
'sign'
]
=
WeixinPay
::
makeWeixinPaySign
(
$xml
,
$weixinpay
[
'key'
]);
$xml
=
Utils
::
assocArrayToXML
(
'xml'
,
$xml
);
$reponse
=
$client
->
request
(
'POST'
,
$uri
,
[
'Content-Type'
=>
'text/xml; charset=UTF8'
,
'body'
=>
$xml
]);
$reponse
=
$reponse
->
getBody
();
$result
=
((
string
)
$reponse
);
$result
=
Utils
::
xmlToArray
(
$result
);
var_dump
(
$result
);
}
/**
* 生成订单号
...
...
src/frontend/controllers/MyIncomeController.php
View file @
65e16641
...
...
@@ -2,10 +2,14 @@
namespace
frontend\controllers
;
use
common\libs\Utils
;
use
common\models\Income
;
use
dosamigos\qrcode\lib\Enum
;
use
frontend\components\ClassesFilter
;
use
Yii
;
use
yii\filters\AccessControl
;
use
yii\helpers\Url
;
use
yii\web\Response
;
class
MyIncomeController
extends
\yii\web\Controller
{
...
...
@@ -26,9 +30,12 @@ class MyIncomeController extends \yii\web\Controller
'allow'
=>
true
,
'roles'
=>
[
'@'
]
]
]
],
'except'
=>
[
'weixin-bind'
,
'weixin-callback'
]
],
'classes'
=>
ClassesFilter
::
className
()
'classes'
=>
[
'class'
=>
ClassesFilter
::
className
()
]
];
}
...
...
@@ -47,4 +54,51 @@ class MyIncomeController extends \yii\web\Controller
return
$this
->
render
(
'index'
,
$ret
+
compact
(
'settled'
,
'notSettled'
));
}
public
function
actionWxbindQrcode
()
{
//生成随机的 key 防止被猜测到
$key
=
Yii
::
$app
->
security
->
generateRandomString
();
//记录绑定信息
Yii
::
$app
->
redis
->
setex
(
'yy_wxbind_'
.
$key
,
7200
,
serialize
([
'uid'
=>
Yii
::
$app
->
user
->
getId
()
]));
$url
=
Url
::
to
([
'my-income/weixin-bind'
,
'key'
=>
$key
],
true
);
//输出二维码图像
$response
=
Yii
::
$app
->
response
;
$response
->
format
=
Response
::
FORMAT_RAW
;
$response
->
headers
->
set
(
'Content-Type'
,
'image/jpeg'
);
\dosamigos\qrcode\QrCode
::
encode
(
$url
,
false
,
Enum
::
QR_ECLEVEL_L
,
7
,
2
,
false
,
Enum
::
QR_FORMAT_JPG
);
}
public
function
actionWeixinBind
()
{
$key
=
Yii
::
$app
->
request
->
get
(
'key'
,
''
);
if
(
!
$key
)
{
Utils
::
showWarn
(
'参数缺失!'
);
}
$data
=
Yii
::
$app
->
redis
->
get
(
'yy_wxbind_'
.
$key
);
if
(
!
$data
)
{
Utils
::
showWarn
(
'该地址已失效,请刷新页面后重新扫描!'
);
}
$data
=
unserialize
(
$data
);
$callbackUrl
=
Url
::
to
([
'my-income/weixin-callback'
],
true
);
$wx
=
new
\common\libs\ApiWeixin
();
echo
$wx
->
getAuthorizeURLWrapped
(
$callbackUrl
,
$key
);
}
public
function
actionWeixinCallback
()
{
}
}
src/frontend/controllers/PayController.php
View file @
65e16641
...
...
@@ -27,6 +27,44 @@ class PayController extends Controller
public
$enableCsrfValidation
=
FALSE
;
/**
* return Url
*/
public
function
actionAlipayReturnUrl
()
{
//计算得出通知验证结果
$alipayNotify
=
new
AlipayNotify
();
$verify_result
=
$alipayNotify
->
verifyReturn
();
if
(
$verify_result
)
{
//验证成功
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//请在这里加上商户的业务逻辑程序代
//——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
//获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表
//商户订单号
$out_trade_no
=
$_GET
[
'out_trade_no'
];
$order
=
Orders
::
findOne
([
'number'
=>
$out_trade_no
]);
if
(
$order
!==
NULL
)
{
//交易状态
$this
->
redirect
(
\Yii
::
$app
->
request
->
hostInfo
.
'/home/video?courseId='
.
$order
->
course_id
);
}
//——请根据您的业务逻辑来编写程序(以上代码仅作参考)——
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
else
{
//验证失败
$this
->
redirect
(
\Yii
::
$app
->
request
->
hostInfo
);
//调试用,写文本函数记录程序运行情况是否正常
//logResult("这里写入想要调试的代码变量值,或其他运行的结果记录");
}
}
public
function
actionAlipayNotify
()
{
//计算得出通知验证结果
...
...
@@ -150,7 +188,7 @@ class PayController extends Controller
'sign'
=>
''
,
'body'
=>
'最课堂-课程购买'
,
'out_trade_no'
=>
$order_id
,
'total_fee'
=>
$order
->
price
,
'total_fee'
=>
$order
->
credit
*
100
,
'spbill_create_ip'
=>
$_SERVER
[
'SERVER_ADDR'
],
'notify_url'
=>
WeixinPay
::
NOTIFY_URL
,
'trade_type'
=>
'NATIVE'
,
...
...
src/frontend/controllers/SiteController.php
View file @
65e16641
This diff is collapsed.
Click to expand it.
src/frontend/models/PasswordResetRequestForm.php
View file @
65e16641
...
...
@@ -17,6 +17,7 @@ class PasswordResetRequestForm extends Model
public
$telephone
;
public
$verifyCode
;
/**
* @inheritdoc
*/
...
...
@@ -30,11 +31,21 @@ class PasswordResetRequestForm extends Model
'filter'
=>
[
'status'
=>
User
::
STATUS_ACTIVE
],
'message'
=>
'There is no user with such telephone.'
],
[
'verifyCode'
,
'required'
],
[
'verifyCode'
,
'captcha'
]
];
}
/**
* @inheritdoc
*/
public
function
attributeLabels
()
{
return
[
'verifyCode'
=>
''
];
}
public
function
sendMsg
()
{
...
...
src/frontend/models/ResetPasswordForm.php
View file @
65e16641
...
...
@@ -45,7 +45,7 @@ class ResetPasswordForm extends Model
[
'password'
,
'required'
],
[
'password'
,
'string'
,
'min'
=>
6
],
[
'rePassword'
,
'string'
,
'min'
=>
6
],
[
'rePassword'
,
'compare'
,
'compareAttribute'
=>
'
rePassword
'
],
[
'rePassword'
,
'compare'
,
'compareAttribute'
=>
'
password'
,
'message'
=>
'两次密码输入不一致
'
],
];
}
...
...
src/frontend/models/SignupForm.php
View file @
65e16641
...
...
@@ -20,6 +20,7 @@ class SignupForm extends Model
public
$password
;
public
$rePassword
;
public
$from
;
public
$verifyCode
;
/**
* @inheritdoc
...
...
@@ -34,8 +35,20 @@ class SignupForm extends Model
[[
'password'
,
'rePassword'
],
'required'
],
[
'password'
,
'string'
,
'min'
=>
6
],
[
'rePassword'
,
'string'
,
'min'
=>
6
],
[
'rePassword'
,
'compare'
,
'compareAttribute'
=>
'rePassword'
],
[
'from'
,
'integer'
]
[
'rePassword'
,
'compare'
,
'compareAttribute'
=>
'password'
],
[
'from'
,
'integer'
],
[
'verifyCode'
,
'required'
],
[
'verifyCode'
,
'captcha'
]
];
}
/**
* @return mixed
*/
public
function
attributeLabels
()
{
return
[
'verifyCode'
=>
''
];
}
...
...
src/frontend/models/TokenInputForm.php
View file @
65e16641
...
...
@@ -21,6 +21,7 @@ class TokenInputForm extends Model
{
public
$token
;
public
$verifyCode
;
/**
* @return array
*/
...
...
@@ -29,10 +30,24 @@ class TokenInputForm extends Model
return
[
[
'token'
,
'trim'
],
[
'token'
,
'required'
],
[
'token'
,
'string'
]
[
'token'
,
'string'
],
[
'verifyCode'
,
'required'
],
[
'verifyCode'
,
'captcha'
]
];
}
/**
* @inheritdoc
*/
public
function
attributeLabels
()
{
return
[
'verifyCode'
=>
''
];
}
/**
* @inheritdoc
*/
...
...
src/frontend/views/layouts/blank.php
0 → 100644
View file @
65e16641
<?php
/**
* @var $this \yii\web\View
* @var $content string
*/
use
yii\helpers\Html
;
$this
->
beginPage
()
?>
<!DOCTYPE html>
<html
lang=
"
<?=
\Yii
::
$app
->
language
?>
"
>
<head>
<meta
charset=
"
<?=
\Yii
::
$app
->
charset
?>
"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge,chrome=1"
>
<title>
<?=
(
$this
->
title
?
Html
::
encode
(
$this
->
title
)
.
'-'
:
''
)
?>
最课堂
</title>
<?php
$this
->
head
()
?>
</head>
<body>
<?php
$this
->
beginBody
();
echo
$content
;
$this
->
endBody
();
?>
</body>
</html>
<?php
$this
->
endPage
();
\ No newline at end of file
src/frontend/views/layouts/centerHeader.php
View file @
65e16641
...
...
@@ -8,5 +8,5 @@
?>
<div
class=
"tp-head navbar-fixed-top clearfix"
>
<div
class=
"menu-btn fl"
><a
href=
"javascript:;"
><i
class=
"icon-menu"
></i></a></div>
<div
class=
"avatar fr"
><a
href=
"
<?=
\yii\helpers\Url
::
base
()
.
'user-center'
?>
"
><img
src=
"
<?=
Yii
::
$app
->
assetManager
->
baseUrl
?>
/img/avatar.jpg
"
></a></div>
<div
class=
"avatar fr"
><a
href=
"
<?=
\yii\helpers\Url
::
base
()
.
'user-center'
?>
"
><img
src=
"
<?=
\common\models\User
::
getAvatarUrl
(
Yii
::
$app
->
user
->
identity
->
avatar
)
?>
"
></a></div>
</div>
src/frontend/views/my-income/index.php
View file @
65e16641
<?php
/* @var $this yii\web\View */
/**
* @var $this yii\web\View
* @var $data array
* @var $pagination \yii\data\Pagination
*/
use
frontend\assets\AppAsset
;
$this
->
title
=
'知识有价'
;
AppAsset
::
addScript
(
$this
,
'@web/assets/my_income.js'
);
?>
<div
class=
"buy-recode-top"
>
<div
class=
"col-md-4"
>
<h3>
结算微信
</h3>
<button
class=
"btn btn-save
"
>
绑定
</button>
<button
type=
"button"
class=
"btn btn-save"
@
click=
"bindWeixinClick
"
>
绑定
</button>
</div>
<div
class=
"col-md-4"
>
<h3>
已结算
</h3>
...
...
@@ -40,7 +48,7 @@ $this->title = '知识有价';
<td>
<?=
$row
[
'order'
][
'user'
][
'telephone'
]
?>
/
<?=
$row
[
'order'
][
'user'
][
'username'
]
?>
</td>
<td>
《
<?=
$row
[
'order'
][
'course'
][
'name'
]
?>
》
</td>
<td>
¥
<?=
$row
[
'order'
][
'credit'
]
?>
</td>
<td>
<?=
(
$row
[
'status'
]
?
'
未结算'
:
'已
结算'
)
?>
</td>
<td>
<?=
(
$row
[
'status'
]
?
'
已结算'
:
'未
结算'
)
?>
</td>
</tr>
<?php
}
?>
</tbody>
...
...
src/frontend/views/site/requestPasswordResetToken.php
View file @
65e16641
...
...
@@ -5,6 +5,7 @@
/* @var $model \frontend\models\PasswordResetRequestForm */
use
yii\bootstrap\ActiveForm
;
use
yii\captcha\Captcha
;
$this
->
title
=
'找回密码'
;
\frontend\assets\AppAsset
::
addScript
(
$this
,
'@web/assets/request_password_reset.js'
);
...
...
@@ -36,15 +37,20 @@ $this->registerJsFile('http://static.geetest.com/static/tools/gt.js');
<input
name=
"telephone"
type=
"text"
class=
""
placeholder=
"请输入注册的手机号码"
required=
""
autofocus=
""
>
<!--<span class="tips">手机号或者密码错误</span>-->
</div>
<div
class=
"password input-wrapper last-wrapper"
"
>
<?=
$form
->
field
(
$model
,
'verifyCode'
)
->
widget
(
Captcha
::
className
(),[
'template'
=>
"
{
image
}
"
,
'imageOptions'
=>
[
'alt'
=>
'验证码'
],
'captchaAction'
=>
'site/captcha'
,
])
->
error
(
FALSE
);
?>
<input
id=
"verifyCode"
name=
"verifyCode"
type=
"text"
placeholder=
"输入验证码"
required=
""
>
<span
id=
"verifyCode"
class=
"tips"
>
<?=
$model
->
getFirstError
(
'verifyCode'
)
?>
</span>
</div>
<div
class=
"v-geetest"
>
<div
id=
"embed-captcha"
></div>
<p
id=
"wait"
class=
"show"
>
正在加载验证码......
</p>
<p
id=
"notice"
class=
"hide"
>
请先拖动验证码到相应位置
</p>
</div>
<div
class=
"foot-reg-btn"
>
<button
id=
"submit"
class=
"btn btn-log"
type=
"submit"
>
获取验证码
</button>
</div>
...
...
src/frontend/views/site/resetPassword.php
View file @
65e16641
...
...
@@ -8,18 +8,6 @@ use yii\helpers\Html;
use
yii\bootstrap\ActiveForm
;
$this
->
title
=
'Reset password'
;
$jsString
=
<<<JS
$("#submit").click(function() {
if($("#password").val() !== $("#repassword").val()){
$("#repassword_tips").html('两次密码不一致');
return false;
}
});
JS;
$this
->
registerJs
(
$jsString
);
?>
<div
class=
"container"
>
<div
class=
"z-m-center"
>
...
...
@@ -39,20 +27,21 @@ $this->registerJs($jsString);
<div
class=
"tab-pane fade in active"
id=
"three"
>
<?php
$form
=
ActiveForm
::
begin
([
'id'
=>
'request-password-reset-form'
]);
?>
<div
class=
"reg-box"
>
<div
class=
"password input-wrapper"
>
<input
value=
"
<?=
$model
->
password
?>
"
id=
"password"
name=
"password"
type=
"password"
class=
""
placeholder=
"设置新密码"
required=
""
>
placeholder=
"设置新密码"
>
<span
id=
"repassword_tips"
class=
"tips"
>
<?=
$model
->
getFirstError
(
'password'
)
?>
</span>
</div>
<div
class=
"check-password input-wrapper
last-wrapper
"
>
<input
value=
"
<?=
$model
->
rePassword
?>
"
id
id=
"repassword"
name=
"rePassword"
type=
"password"
class=
""
placeholder=
"重复输入密码"
required=
""
>
<div
class=
"check-password input-wrapper"
>
<input
value=
"
<?=
$model
->
rePassword
?>
"
id=
"repassword"
name=
"rePassword"
type=
"password"
class=
""
placeholder=
"重复输入密码"
>
<span
id=
"repassword_tips"
class=
"tips"
>
<?=
$model
->
getFirstError
(
'rePassword'
)
?>
</span>
</div>
</div>
<div
class=
"foot-reg-btn"
>
<button
id=
"submit"
class=
"btn btn-log"
type=
"submit"
>
确认
</button>
<button
class=
"btn btn-log"
type=
"submit"
>
确认
</button>
</div>
<?php
ActiveForm
::
end
()
?>
</div>
...
...
src/frontend/views/site/signup.php
View file @
65e16641
<?php
use
yii\captcha\Captcha
;
use
yii\widgets\ActiveForm
;
/* @var $this yii\web\View */
...
...
@@ -50,14 +51,18 @@ $this->registerJsFile('http://static.geetest.com/static/tools/gt.js');
<span
class=
"tips tip-vcode"
>
<?=
$model
->
getFirstError
(
'rePassword'
)
?>
</span>
<span
id=
"repassword_tips"
class=
"tips"
>
<?=
$model
->
getFirstError
(
'rePassword'
)
?>
</span>
</div>
</div>
<div
class=
"password input-wrapper"
>
<?=
$form
->
field
(
$model
,
'verifyCode'
)
->
widget
(
Captcha
::
className
(),[
'template'
=>
"
{
image
}
"
,
'imageOptions'
=>
[
'alt'
=>
'验证码'
],
'captchaAction'
=>
'site/captcha'
,
])
->
error
(
FALSE
);
?>
<input
id=
"verifyCode"
name=
"verifyCode"
type=
"text"
placeholder=
"输入验证码"
required=
""
>
<span
id=
"verifyCode"
class=
"tips"
>
<?=
$model
->
getFirstError
(
'verifyCode'
)
?>
</span>
<div
class=
"v-geetest"
>
<div
id=
"embed-captcha"
></div>
<p
id=
"wait"
class=
"show"
>
正在加载验证码......
</p>
<p
id=
"notice"
class=
"hide"
>
请先拖动验证码到相应位置
</p>
</div>
</div>
</div>
<div
id=
"submit"
class=
"foot-reg-btn"
>
<button
class=
"btn btn-reg"
type=
"submit"
>
注册
</button>
</div>
...
...
src/frontend/views/site/tokenInput.php
View file @
65e16641
...
...
@@ -7,6 +7,7 @@
*/
use
yii\captcha\Captcha
;
use
yii\helpers\Html
;
use
yii\bootstrap\ActiveForm
;
...
...
@@ -40,11 +41,15 @@ $this->registerJsFile('http://static.geetest.com/static/tools/gt.js');
<input
name=
"token"
type=
"text"
class=
""
value=
"
<?=
$model
->
token
?>
"
placeholder=
"请输入6位验证码"
required=
""
autofocus=
""
>
<span
class=
"tips"
>
<?=
$model
->
getFirstError
(
'token'
)
?>
</span>
</div>
<div
style=
"margin-top: 20px;margin-bottom: 20px"
>
<div
id=
"embed-captcha"
></div>
<p
id=
"wait"
class=
"show"
>
正在加载验证码......
</p>
<p
id=
"notice"
class=
"hide"
>
请先拖动验证码到相应位置
</p>
</div>
<div
class=
"password input-wrapper last-wrapper"
"
>
<?=
$form
->
field
(
$model
,
'verifyCode'
)
->
widget
(
Captcha
::
className
(),[
'template'
=>
"
{
image
}
"
,
'imageOptions'
=>
[
'alt'
=>
'验证码'
],
'captchaAction'
=>
'site/captcha'
,
])
->
error
(
FALSE
);
?>
<input
id=
"verifyCode"
name=
"verifyCode"
type=
"text"
placeholder=
"输入验证码"
required=
""
>
<span
id=
"verifyCode"
class=
"tips"
>
<?=
$model
->
getFirstError
(
'verifyCode'
)
?>
</span>
</div>
</div>
<div
class=
"foot-reg-btn"
>
<button
id=
"token_input"
class=
"btn btn-log"
type=
"submit"
>
下一步
</button>
...
...
src/frontend/views/weixin-js-pay/index.php
View file @
65e16641
...
...
@@ -2,39 +2,26 @@
//error_reporting(E_ERROR);
use
common\libs\WeixinPay
;
require_once
dirname
(
dirname
(
dirname
(
dirname
(
__FILE__
))))
.
"/common/libs/weixin/libs/WxPay.Api.php"
;
require_once
dirname
(
dirname
(
dirname
(
dirname
(
__FILE__
))))
.
"/common/libs/weixin/WxPay.JsApiPay.php"
;
require_once
dirname
(
dirname
(
dirname
(
dirname
(
__FILE__
))))
.
"/common/libs/weixin/libs/WxPay.Api.php"
;
require_once
dirname
(
dirname
(
dirname
(
dirname
(
__FILE__
))))
.
"/common/libs/weixin/WxPay.JsApiPay.php"
;
//打印输出数组信息
function
printf_info
(
$data
)
{
foreach
(
$data
as
$key
=>
$value
)
{
echo
"<font color='#00ff55;'>
$key
</font> :
$value
<br/>"
;
}
}
//①、获取用户openid
$tools
=
new
JsApiPay
();
$openId
=
$tools
->
GetOpenid
();
//②、统一下单
$input
=
new
WxPayUnifiedOrder
();
$input
->
SetBody
(
"最课堂-课程购买"
);
$input
->
SetOut_trade_no
(
$number
);
$input
->
SetTotal_fee
(
$price
);
$input
->
SetTotal_fee
(
$price
*
100
);
$input
->
SetTime_start
(
date
(
"YmdHis"
));
$input
->
SetTime_expire
(
date
(
"YmdHis"
,
time
()
+
600
));
$input
->
SetNotify_url
(
WeixinPay
::
NOTIFY_URL
);
$input
->
SetTrade_type
(
"JSAPI"
);
$input
->
SetOpenid
(
$openId
);
$order
=
WxPayApi
::
unifiedOrder
(
$input
);
echo
'<font color="#f00"><b>统一下单支付单信息</b></font><br/>'
;
printf_info
(
$order
);
$jsApiParameters
=
$tools
->
GetJsApiParameters
(
$order
);
//获取共享收货地址js函数参数
$editAddress
=
$tools
->
GetEditAddressParameters
();
//③、在支持成功回调通知中处理成功之后的事宜,见 notify.php
/**
...
...
@@ -49,7 +36,7 @@ $editAddress = $tools->GetEditAddressParameters();
<head>
<meta
http-equiv=
"content-type"
content=
"text/html;charset=utf-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
/>
<title>
微信支付
样例-支付
</title>
<title>
微信支付
</title>
<script
type=
"text/javascript"
>
//调用微信JS api 支付
function
jsApiCall
()
{
...
...
@@ -57,8 +44,11 @@ $editAddress = $tools->GetEditAddressParameters();
'getBrandWCPayRequest'
,
<?php
echo
$jsApiParameters
;
?>
,
function
(
res
)
{
WeixinJSBridge
.
log
(
res
.
err_msg
);
alert
(
res
.
err_code
+
res
.
err_desc
+
res
.
err_msg
);
if
(
res
.
err_msg
==
"get_brand_wcpay_request:ok"
)
{
window
.
history
.
go
(
-
1
);
}
else
{
window
.
history
.
go
(
-
1
);
}
//
}
);
}
...
...
@@ -75,48 +65,10 @@ $editAddress = $tools->GetEditAddressParameters();
jsApiCall
();
}
}
</script>
<script
type=
"text/javascript"
>
//获取共享地址
function
editAddress
()
{
WeixinJSBridge
.
invoke
(
'editAddress'
,
<?php
echo
$editAddress
;
?>
,
function
(
res
)
{
var
value1
=
res
.
proviceFirstStageName
;
var
value2
=
res
.
addressCitySecondStageName
;
var
value3
=
res
.
addressCountiesThirdStageName
;
var
value4
=
res
.
addressDetailInfo
;
var
tel
=
res
.
telNumber
;
alert
(
value1
+
value2
+
value3
+
value4
+
":"
+
tel
);
}
);
}
window
.
onload
=
function
()
{
if
(
typeof
WeixinJSBridge
==
"undefined"
)
{
if
(
document
.
addEventListener
)
{
document
.
addEventListener
(
'WeixinJSBridgeReady'
,
editAddress
,
false
);
}
else
if
(
document
.
attachEvent
)
{
document
.
attachEvent
(
'WeixinJSBridgeReady'
,
editAddress
);
document
.
attachEvent
(
'onWeixinJSBridgeReady'
,
editAddress
);
}
}
else
{
editAddress
();
}
};
callpay
();
</script>
</head>
<body>
<br/>
<font
color=
"#9ACD32"
><b>
该笔订单支付金额为
<span
style=
"color:#f00;font-size:50px"
>
<?=
$price
?>
</span
</b
></font><br/><br/>
<div
align=
"center"
>
<button
style=
"width:210px; height:50px; border-radius: 15px;background-color:#FE6714; border:0px #FE6714 solid; cursor: pointer; color:white; font-size:16px;"
type=
"button"
onclick=
"callpay()"
>
立即支付
</button>
</div>
</body>
</html>
\ No newline at end of file
src/frontend/web/img/no-connection.gif
0 → 100644
View file @
65e16641
6.54 KB
src/frontend/web/img/qrcode.jpg
0 → 100644
View file @
65e16641
16.3 KB
src/frontend/web/js/home/components/video-play.vue
View file @
65e16641
...
...
@@ -45,7 +45,7 @@
data-target="
#
pay
">购买 ¥{{coursewareInfo.price
}}
</button>
<button v-if="
isMobile
===
true
&&
isWeixin
===
false
" class="
btn
btn
-
danger
m
-
l
-
20
mb
-
left
"
@click="
alip
ay
(
coursewareInfo
.
course_id
)
">购买 ¥{{coursewareInfo.price
}}
@click="
mobileAliP
ay
(
coursewareInfo
.
course_id
)
">购买 ¥{{coursewareInfo.price
}}
</button>
<button v-if="
isWeixin
===
true
" class="
btn
btn
-
danger
m
-
l
-
20
mb
-
left
"
@click="
weixinJsPay
(
coursewareInfo
.
course_id
)
">购买 ¥{{coursewareInfo.price
}}
...
...
@@ -116,7 +116,7 @@
require('../../libs/videojs/lang/zh-CN.js');
videojs.options.flash.swf = __CDN_URL__ + 'assets/videojs/video-js.swf';
window.VIDEOJS_NO_BASE_THEME = true;
//
import Utils from '../../libs/utils';
export default{
data(){
...
...
@@ -181,10 +181,10 @@
}
,
mobileAliPay(courseId){
var url = __BASE_URL__ + 'home/pay?courseId=' + courseId;
window.location.href
(url)
;
window.location.href
= url
;
}
,
weixinJsPay(courseId){
var url = __BASE_URL__ + '
/
weixin-js-pay/index?courseId=' + courseId;
var url = __BASE_URL__ + 'weixin-js-pay/index?courseId=' + courseId;
window.location.href = url;
}
,
login(){
...
...
@@ -269,5 +269,6 @@
}
);
}
}
</script>
src/frontend/web/js/my-income/index.js
0 → 100644
View file @
65e16641
var
Vue
=
require
(
'vue'
);
var
layer
=
require
(
'layer-js'
);
var
vm
=
new
Vue
({
el
:
".buy-recode-top"
,
methods
:
{
bindWeixinClick
:
function
()
{
var
idx
=
layer
.
open
({
type
:
1
,
title
:
"绑定微信"
,
content
:
'<div class="qrcode-img"><img src="'
+
__BASE_URL__
+
'my-income/wxbind-qrcode" style="margin:0;height:auto;"><p>扫码后,请在手机端“确认”绑定</p></div>'
,
area
:
[
'320px'
,
'380px'
],
cancel
:
function
(
idx
)
{
layer
.
close
(
idx
);
this
.
content
.
show
();
}
});
}
}
});
\ No newline at end of file
src/frontend/web/js/site/request_password_reset.js
View file @
65e16641
/**
* Created by xiabin on 2016/9/26.
*/
var
handlerEmbed
=
function
(
captchaObj
)
{
$
(
"#submit"
).
click
(
function
(
e
)
{
var
validate
=
captchaObj
.
getValidate
();
if
(
!
validate
)
{
$
(
"#notice"
)[
0
].
className
=
"show"
;
setTimeout
(
function
()
{
$
(
"#notice"
)[
0
].
className
=
"hide"
;
},
2000
);
return
false
;
}
});
// 将验证码加到id为captcha的元素里,同时会有三个input的值:geetest_challenge, geetest_validate, geetest_seccode
captchaObj
.
appendTo
(
"#embed-captcha"
);
captchaObj
.
onReady
(
function
()
{
$
(
"#wait"
)[
0
].
className
=
"hide"
;
});
// 更多接口参考:http://www.geetest.com/install/sections/idx-client-sdk.html
};
$
.
ajax
({
// 获取id,challenge,success(是否启用failback)
url
:
__BASE_URL__
+
"site/start-captcha?type=pc&t="
+
(
new
Date
()).
getTime
(),
// 加随机数防止缓存
type
:
"get"
,
dataType
:
"json"
,
success
:
function
(
data
)
{
// 使用initGeetest接口
// 参数1:配置参数
// 参数2:回调,回调的第一个参数验证码对象,之后可以使用它做appendTo之类的事件
initGeetest
({
gt
:
data
.
gt
,
challenge
:
data
.
challenge
,
product
:
"float"
,
// 产品形式,包括:float,embed,popup。注意只对PC版验证码有效
offline
:
!
data
.
success
// 表示用户后台检测极验服务器是否宕机,一般不需要关注
// 更多配置参数请参见:http://www.geetest.com/install/sections/idx-client-sdk.html#config
},
handlerEmbed
);
}
});
src/frontend/web/js/site/signup.js
View file @
65e16641
var
handlerEmbed
=
function
(
captchaObj
)
{
$
(
"#submit"
).
click
(
function
()
{
var
validate
=
captchaObj
.
getValidate
();
if
(
!
validate
)
{
$
(
"#notice"
)[
0
].
className
=
"show"
;
setTimeout
(
function
()
{
$
(
"#notice"
)[
0
].
className
=
"hide"
;
},
2000
);
return
false
;
}
var
telephone
=
$
(
"#telephone"
).
val
();
if
(
telephone
.
length
===
0
)
{
$
(
'#telephone_tips'
).
html
(
'手机号码不能为空'
);
return
false
;
}
var
token
=
$
(
"#token"
).
val
();
if
(
token
.
length
===
0
)
{
$
(
'#token_tips'
).
html
(
'验证码不能为空'
);
return
false
;
}
var
password
=
$
(
"#password"
).
val
();
if
(
password
.
length
===
0
)
{
$
(
'#password_tips'
).
html
(
'密码不能为空'
);
return
false
;
}
var
repassword
=
$
(
"#repassword"
).
val
();
if
(
repassword
!==
password
)
{
$
(
'#repassword_tips'
).
html
(
'两次密码输入不一致'
);
return
false
;
}
});
// 将验证码加到id为captcha的元素里,同时会有三个input的值:geetest_challenge, geetest_validate, geetest_seccode
captchaObj
.
appendTo
(
"#embed-captcha"
);
captchaObj
.
onReady
(
function
()
{
$
(
"#wait"
)[
0
].
className
=
"hide"
;
});
// 更多接口参考:http://www.geetest.com/install/sections/idx-client-sdk.html
};
$
.
ajax
({
// 获取id,challenge,success(是否启用failback)
url
:
__BASE_URL__
+
"site/start-captcha?type=pc&t="
+
(
new
Date
()).
getTime
(),
// 加随机数防止缓存
type
:
"get"
,
dataType
:
"json"
,
success
:
function
(
data
)
{
// 使用initGeetest接口
// 参数1:配置参数
// 参数2:回调,回调的第一个参数验证码对象,之后可以使用它做appendTo之类的事件
initGeetest
({
gt
:
data
.
gt
,
challenge
:
data
.
challenge
,
product
:
"float"
,
// 产品形式,包括:float,embed,popup。注意只对PC版验证码有效
offline
:
!
data
.
success
// 表示用户后台检测极验服务器是否宕机,一般不需要关注
// 更多配置参数请参见:http://www.geetest.com/install/sections/idx-client-sdk.html#config
},
handlerEmbed
);
}
});
// $('#verifycode-image').click(function () {
//
// $(this).attr('src',__BASE_URL__+'site/captcha?v='+Date.parse(new Date()));
// });
//发送短信呢
$
(
'#send_msg'
).
click
(
function
()
{
...
...
src/frontend/web/js/site/token_input.js
View file @
65e16641
...
...
@@ -4,41 +4,6 @@
/**
* Created by xiabin on 2016/9/26.
*/
var
handlerEmbed
=
function
(
captchaObj
)
{
$
(
"#token_input"
).
click
(
function
()
{
var
validate
=
captchaObj
.
getValidate
();
if
(
!
validate
)
{
$
(
"#notice"
)[
0
].
className
=
"show"
;
setTimeout
(
function
()
{
$
(
"#notice"
)[
0
].
className
=
"hide"
;
},
2000
);
return
false
;
}
});
// 将验证码加到id为captcha的元素里,同时会有三个input的值:geetest_challenge, geetest_validate, geetest_seccode
captchaObj
.
appendTo
(
"#embed-captcha"
);
captchaObj
.
onReady
(
function
()
{
$
(
"#wait"
)[
0
].
className
=
"hide"
;
});
// 更多接口参考:http://www.geetest.com/install/sections/idx-client-sdk.html
};
$
.
ajax
({
// 获取id,challenge,success(是否启用failback)
url
:
__BASE_URL__
+
"site/start-captcha?type=pc&t="
+
(
new
Date
()).
getTime
(),
// 加随机数防止缓存
type
:
"get"
,
dataType
:
"json"
,
success
:
function
(
data
)
{
// 使用initGeetest接口
// 参数1:配置参数
// 参数2:回调,回调的第一个参数验证码对象,之后可以使用它做appendTo之类的事件
initGeetest
({
gt
:
data
.
gt
,
challenge
:
data
.
challenge
,
product
:
"float"
,
// 产品形式,包括:float,embed,popup。注意只对PC版验证码有效
offline
:
!
data
.
success
// 表示用户后台检测极验服务器是否宕机,一般不需要关注
// 更多配置参数请参见:http://www.geetest.com/install/sections/idx-client-sdk.html#config
},
handlerEmbed
);
}
});
src/frontend/web/webpack.config.js
View file @
65e16641
...
...
@@ -24,7 +24,8 @@ var entry = {
home_index
:
[
js_dir
+
'/home/index.js'
],
home_video
:
[
js_dir
+
'/home/video.js'
],
course_publish
:
[
js_dir
+
'/my-course/publish.js'
],
teacher_form
:
[
js_dir
+
'/teacher-manager/form.js'
]
teacher_form
:
[
js_dir
+
'/teacher-manager/form.js'
],
my_income
:
[
js_dir
+
'/my-income/index.js'
]
};
var
config
=
{
...
...
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