Commit dd751d5d authored by 汪波's avatar 汪波
parents 998e8657 33733ea3
......@@ -12,7 +12,6 @@ class AppAsset extends AssetBundle
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',
];
public $js = [
];
......
......@@ -134,14 +134,16 @@ class Qiniu extends Object
$config = $this->storages[$storage];
$callbackUrl = Url::to(['qiniu-callback/rem-upload'], true);
$callbackUrl = YII_ENV == 'dev'
? 'http://t.pp.cc/tmp/qiniu_callback.php'
: Url::to(['qiniu-callback/rem-upload'], true);
$policy = [
'returnBody' => '{"key":$(key)}',
'saveKey' => $filename,
'fsizeLimit' => $config['fsizeLimit'],
'mimeLimit' => $config['mimeLimit'],
'callbackUrl' => 'http://t.pp.cc/tmp/qiniu_callback.php',
'callbackUrl' => $callbackUrl,
'callbackBody' => 'key=$(key)&storage='.$storage.'&bucket='.$config['bucket']
.'&uuid=$(uuid)&time=$(year)-$(mon)-$(day)+$(hour)%3A$(min)%3A$(sec)&fsize=$(fsize)'
.'&w=$(imageInfo.width)&h=$(imageInfo.height)'
......
......@@ -119,7 +119,7 @@ class Course extends \yii\db\ActiveRecord
* @param $id
* @return array|null|\yii\db\ActiveRecord
*/
public static function getBasicData($id)
public static function findBaseInfoByCourseId($id)
{
$query = self::find();
return $query->select('id,user_id,class_id,name,price,preview_pic,recommend,status,created_at,updated_at')
......@@ -189,4 +189,33 @@ class Course extends \yii\db\ActiveRecord
{
return $this->hasOne(User::className(), ['id' => 'user_id'])->select('id,username,role,avatar');;
}
/**
* 统计指定用户发布的课程数量
*
* @param int $userId
* @param int $status 默认只统计审核通过的,设为 null 则统计全部
* @return int
*/
public static function countCourseByUserId($userId, $status=self::STATUS_OK)
{
$where = ['user_id'=>$userId];
$status !== null && $where['status'] = $status;
return self::find()->where($where)->count();
}
/**
* 统计指定用户发布课程的评论总数
*
* @param int $userId
* @param int $status 默认只统计审核通过的课程评论,设为 null 则统计全部
* @return int
*/
public static function countCommentsByUserId($userId, $status=self::STATUS_OK)
{
$where = ['user_id'=>$userId];
$status !== null && $where['status'] = $status;
return self::find()->where($where)->sum('comment_count');
}
}
......@@ -75,6 +75,7 @@ class Income extends \yii\db\ActiveRecord
}
/**
* 关联订单详细数据
* @return $this
*/
public function getOrder()
......@@ -83,16 +84,18 @@ class Income extends \yii\db\ActiveRecord
}
/**
* @param $userId
* @param int $page
* @param int $num
* @param int $status
* 获取指定用户已出售课程的订单列表
*
* @param int $userId
* @param int $page 页数,默认0为第1页,传null则使用系统自动分页
* @param int $num 每页数量
* @param int $status 要获取的状态,默认为全部
* @return array
*/
public static function getIncomeListByUserId($userId, $page=0, $num=10, $status=self::STATUS_NOT_SETTLED)
public static function getIncomeListByUserId($userId, $page=0, $num=10, $status=null)
{
$where = ['user_id'=>$userId];
$status != null && $where['status'] = $status;
$status !== null && $where['status'] = $status;
$count = self::find()->where($where)->count();
$return = ['count'=>$count, 'data' =>[]];
......@@ -112,4 +115,37 @@ class Income extends \yii\db\ActiveRecord
return $return;
}
/**
* 获取售出课程订单的资金统计
*
* @param int $userId
* @param int $status
* @return float
*/
public static function getMoneyTotal($userId, $status=null)
{
$where = ['i.user_id'=>$userId];
$status !== null && $where['i.status'] = $status;
return (float)self::find()->alias('i')->where($where)
->join('LEFT JOIN', Orders::tableName().' o', 'o.id=i.orders_id')
->sum('o.credit');
}
/**
* 统计指定用户时间范围内的收入
*
* @param int $userId
* @param int $timeBetween 起始时间戳
* @param int $timeAnd 结束时间戳
* @return float
*/
public static function getMoneyTotalByTime($userId, $timeBetween, $timeAnd)
{
return (float)self::find()->alias('i')
->join('LEFT JOIN', Orders::tableName().' o', 'o.id=i.orders_id')
->where(['i.user_id'=>$userId])->andWhere(['between', 'i.updated_at', $timeBetween, $timeAnd])
->sum('o.credit');
}
}
......@@ -125,6 +125,7 @@ class Orders extends \yii\db\ActiveRecord
}
/**
* 关联下单用户信息
* @return $this
*/
public function getUser()
......@@ -133,6 +134,7 @@ class Orders extends \yii\db\ActiveRecord
}
/**
* 关联课程信息
* @return $this
*/
public function getCourse()
......@@ -141,6 +143,7 @@ class Orders extends \yii\db\ActiveRecord
}
/**
* 关联课程信息(包括课程的讲师列表)
* @return $this
*/
public function getCourseWithTeachers()
......
<?php
return [
$config = [
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
......@@ -7,3 +8,6 @@ return [
],
],
];
return $config;
<?php
// NOTE: Make sure this file is not accessible when deployed to production
if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
die('You are not allowed to access this file.');
}
if(!function_exists('fnmatch')) {
function fnmatch($pattern, $string) {
return preg_match("#^".strtr(preg_quote($pattern, '#'), array('\*' => '.*', '\?' => '.'))."$#i", $string);
} // end
} // end if
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../../common/config/bootstrap.php');
require(__DIR__ . '/../config/bootstrap.php');
$config = require(__DIR__ . '/../../tests/codeception/config/backend/acceptance.php');
(new yii\web\Application($config))->run();
<?php
defined('YII_DEBUG') or define('YII_DEBUG', false);
defined('YII_ENV') or define('YII_ENV', 'prod');
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
if(!function_exists('fnmatch')) {
function fnmatch($pattern, $string) {
return preg_match("#^".strtr(preg_quote($pattern, '#'), array('\*' => '.*', '\?' => '.'))."$#i", $string);
} // end
} // end if
require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../../common/config/bootstrap.php');
......
<?php
return [
'components' => [
'cache' => [
'class' => 'yii\redis\Cache',
'redis' => [
'hostname' => '192.168.1.12',
'port' => 6380,
'database' => 2,
]
],
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
'username' => 'root',
'password' => '',
'dsn' => 'mysql:host=192.168.1.7;port:3305;dbname=pp_c',
'username' => 'pp_c',
'password' => 'nF@V5LK#ilb!NEvZ@1Ze#rWm#H',
'charset' => 'utf8',
],
'redis' => [
'class' => 'yii\redis\Connection',
'hostname' => '192.168.1.21',
'port' => 6380,
'database' => 2,
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => TRUE,
],
'qiniu' => [
'class' => 'common\components\Qiniu',
'accessKey' => 'n85SCPB9uO2v32az-3TRFsZCXwJu7YddyzLRYXg-',
'secretKey' => 'KDl3b7aLpj7n9YZ07lHGivVY4c_Q-0QSM0TZ_-XS',
'storages' => [
'public' => [
'bucket' => 'pp-classroom',
'fsizeLimit' => pow(1024, 2) * 5, //5MB
'mimeLimit' => 'image/jpeg;image/png;image/gif',
'url' => 'http://dev.qdn.pp.cc/'
],
'video' => [
'bucket' => 'pp-classroom-private',
'fsizeLimit' => pow(1024, 3) * 2, //2GB
'mimeLimit' => 'video/*;flv-application/octet-stream',
'url' => 'http://oe9d6dr84.bkt.clouddn.com/'
]
]
]
],
];
<?php
return [
'adminEmail' => 'admin@example.com',
'supportEmail' => 'support@example.com',
'user.passwordResetTokenExpire' => 3600,
'captchaId' => '4d6ad870bf63a30be3d22c92925b04ca',
'privateKey' => 'a2ca5e5139d1f43ac4e1cd248f3e52e4',
'msg.host' => 'http://114.55.132.75:7893/sms.aspx',
'msg.userid' => '78',
'msg.account' => '276147613x',
'msg.password' => '276147613',
'msg.signature' => '【最课堂】',
'alipay' => [
'partner' => '2088701843067550',
'seller_id' => '2088701843067550',
'key' => '12vr33u4g314hytde3g81oao9dfdarm6',
'notify_url' => 'http://c.pp.cc/pay/alipay-notify',
'return_url' => 'http://商户网址/create_direct_pay_by_user-PHP-UTF-8/return_url.php',
'sign_type' => strtoupper('MD5'),
'input_charset' => strtolower('utf-8'),
'cacert' => getcwd() . '\\cacert.pem',
'transport' => 'http',
'payment_type' => '1',
'service' => 'create_direct_pay_by_user',
],
// 'weixinpay'=>[
// 'appid'=>'wx180521eb22e9d7af',
// 'mchid'=>'1295461001',
// 'key'=>'ejg0l9phOAkp021qB54shz0Q8Tiscwzy',
// 'appsecret'=>'f20293c9548c469fb8b855fc98c4ef3c',
//
// ]
'weixinpay' => [
'appid' => 'wx5714a24a60083b2a',
'mchid' => '1399794002',
'key' => '8934e7d15453e97507ef794cf7b0519d',
'appsecret' => '7c18222c6ec31efa65d21606a629585d',
]
];
<?php
return [
$config = [
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => '',
'cookieValidationKey' => '1o1zEUf8jdBvsnZy_JygPUO5_sZ7zBci',
],
'session' => [
'timeout' => 3600,
'name' => 'zuiektang-frontend',
'class' => 'yii\redis\Session',
'redis' => [
'hostname' => '192.168.1.21',
'port' => 6380,
'database' => 2,
]
],
],
];
return $config;
<?php
// NOTE: Make sure this file is not accessible when deployed to production
if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
die('You are not allowed to access this file.');
}
if(!function_exists('fnmatch')) {
function fnmatch($pattern, $string) {
return preg_match("#^".strtr(preg_quote($pattern, '#'), array('\*' => '.*', '\?' => '.'))."$#i", $string);
} // end
} // end if
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../../common/config/bootstrap.php');
require(__DIR__ . '/../config/bootstrap.php');
$config = require(__DIR__ . '/../../tests/codeception/config/frontend/acceptance.php');
(new yii\web\Application($config))->run();
<?php
defined('YII_DEBUG') or define('YII_DEBUG', false);
defined('YII_ENV') or define('YII_ENV', 'prod');
if(!function_exists('fnmatch')) {
function fnmatch($pattern, $string) {
return preg_match("#^".strtr(preg_quote($pattern, '#'), array('\*' => '.*', '\?' => '.'))."$#i", $string);
} // end
} // end if
require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../../common/config/bootstrap.php');
......
......@@ -21,7 +21,8 @@ class AppAsset extends AssetBundle
];
public $depends = [
'yii\bootstrap\BootstrapAsset'
'yii\bootstrap\BootstrapAsset',
'yii\bootstrap\BootstrapPluginAsset'
];
//定义按需加载JS方法,注意加载顺序在最后
......
......@@ -3,6 +3,8 @@
namespace frontend\controllers;
use common\models\Classes;
use common\models\Course;
use common\models\Income;
use frontend\components\ClassesFilter;
use Yii;
use yii\filters\AccessControl;
......@@ -36,10 +38,29 @@ class ClassesInfoController extends \yii\web\Controller
];
}
/**
* 课堂概况
* @return string
*/
public function actionIndex()
{
$uid = Yii::$app->user->getId();
//课堂信息
$model = Classes::findOne($this->classStatus['id']);
return $this->render('index', compact('model'));
//统计课程数量
$courseCount = Course::countCourseByUserId($uid);
//统计今日收
$timeBetween = strtotime('Today');
$timeAnd = strtotime('Tomorrow') - 1;
$todayIncome = Income::getMoneyTotalByTime($uid, $timeBetween, $timeAnd);
//统计评论数量
$commentCount = Course::countCommentsByUserId($uid);
return $this->render('index', compact('model', 'courseCount', 'todayIncome', 'commentCount'));
}
/**
......@@ -60,9 +81,7 @@ class ClassesInfoController extends \yii\web\Controller
} else {
$agreement = 1;
}
echo $model->status;
if (Yii::$app->request->getIsPost()) {
$model->load(Yii::$app->request->post());
$model->user_id = Yii::$app->user->getId();
......
......@@ -36,11 +36,11 @@ class HomeController extends \yii\web\Controller
//权限限制
'access' => [
'class' => AccessControl::className(),
'only' => ['support', 'favorite', 'comments', 'pay'],
'only' => ['support', 'favorite', 'comments', 'pay', 'weixin-pay', 'browse-record', 'weixin-pay-qrcode'],
'rules' => [
[
'allow' => TRUE,
'actions' => ['support', 'favorite', 'pay'],
'actions' => ['support', 'favorite', 'pay', 'weixin-pay', 'browse-record', 'weixin-pay-qrcode'],
'roles' => ['@'],
],
[
......@@ -142,9 +142,10 @@ class HomeController extends \yii\web\Controller
if (!Yii::$app->user->isGuest) {
$coursewareInfo['userAvatar'] = User::getAvatarUrl(Yii::$app->user->identity->avatar);
}
$coursewareInfo['price'] = $course->price;
$coursewareInfo['classId'] = $course->class_id;
$coursewareInfo['className'] = Classes::findOne(['id' => $course->class_id])->name;
return $this->render('video', [
'coursewareInfo' => $coursewareInfo
]);
......
......@@ -3,21 +3,48 @@
namespace frontend\controllers;
use common\models\Income;
use frontend\components\ClassesFilter;
use Yii;
use yii\filters\AccessControl;
class MyIncomeController extends \yii\web\Controller
{
public $layout = 'classCenter';
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
//'only' => ['index', 'publish', 'submit'],
'rules' => [
[
'allow' => true,
'roles' => ['@']
]
]
],
'classes' => ClassesFilter::className()
];
}
/**
* 售课记录
* @return string
*/
public function actionIndex()
{
$ret = Income::getIncomeListByUserId(Yii::$app->user->getId(), null, 20);
return $this->render('index', $ret);
$uid = Yii::$app->user->getId();
$ret = Income::getIncomeListByUserId($uid, null, 20);
$settled = Income::getMoneyTotal($uid, Income::STATUS_IS_SETTLED);
$notSettled = Income::getMoneyTotal($uid, Income::STATUS_NOT_SETTLED);
return $this->render('index', $ret + compact('settled', 'notSettled'));
}
}
......@@ -4,6 +4,9 @@ namespace frontend\controllers;
class MyMemberController extends \yii\web\Controller
{
public $layout = 'classCenter';
public function actionIndex()
{
return $this->render('index');
......
......@@ -31,9 +31,10 @@ class QiniuCallbackController extends \yii\web\Controller
//验证回调请求
$requestBody = file_get_contents('php://input');
$authorization = isset($_SERVER['HTTP_AUTHORIZATION']) ? $_SERVER['HTTP_AUTHORIZATION'] : '';
$currentUrl = Yii::$app->request->hostInfo.Yii::$app->request->getUrl();
$currentUrl = 'http://t.pp.cc/tmp/qiniu_callback.php';
$currentUrl = YII_ENV == 'dev'
? 'http://t.pp.cc/tmp/qiniu_callback.php'
: Yii::$app->request->hostInfo.Yii::$app->request->getUrl();
if (!$auth->verifyCallback($_SERVER['CONTENT_TYPE'], $authorization, $currentUrl, $requestBody)) {
return ['error'=>'回调验证失败!'];
......
......@@ -2,26 +2,31 @@
/**
* @var $this yii\web\View
* @var \common\models\Classes $model
* @var $courseCount int
* @var $todayIncome float
* @var $commentCount int
*/
use yii\helpers\Url;
$this->title = '我的课堂';
?>
<div class="class-name"><?=$model->name?></div>
<div class="class-intro">
<div class="col-md-4">
<h3>课程总数</h3>
<p>10<small>讲</small></p>
<a href="#">发布课程</a>
<p><?=$courseCount?><small>讲</small></p>
<a href="<?=Url::to(['my-course/publish'])?>">发布课程</a>
<i class="icon-play"></i>
</div>
<div class="col-md-4">
<h3>今日收益</h3>
<p>192.00<small>元</small></p>
<a href="#">查看账单</a>
<p><?=$todayIncome?><small>元</small></p>
<a href="<?=Url::to(['my-income/index'])?>">查看账单</a>
<i class="icon-clipboard"></i>
</div>
<div class="col-md-4">
<h3>今日发言</h3>
<p>891<small>条</small></p>
<p><?=$commentCount?><small>条</small></p>
<i class="icon-speech-bubble"></i>
</div>
</div>
\ No newline at end of file
......@@ -6,6 +6,24 @@
* Time: 下午5:39
*/
$this->title = "视频播放";
\backend\assets\AppAsset::register($this);
$js = <<<JS
window._bd_share_config = {
"common": {
"bdSnsKey": {},
"bdText": "",
"bdMini": "1",
"bdMiniList": ["qzone", "tsina", "weixin"],
"bdPic": "",
"bdStyle": "2",
"bdSize": "24"
}, "share": {}
};
with (document)0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];
JS;
$this->registerJs($js);
\frontend\assets\AppAsset::addCss($this, '@web/assets/css/main.css');
\frontend\assets\AppAsset::addScript($this, '@web/assets/home_video.js');
\frontend\assets\AppAsset::addCss($this, '@web/assets/css/home_video.css');
......
......@@ -33,7 +33,7 @@ $this->beginContent('@app/views/layouts/center.php');
<li>
<div class="link"><i class="icon-fingerprint"></i>我的会员<i class="icon-navigate_next"></i></div>
<ul class="submenu">
<li><a href="#">会员列表</a></li>
<li><a href="/my-member">会员列表</a></li>
</ul>
</li>
<li>
......
......@@ -36,4 +36,7 @@ $qiniu = \Yii::$app->qiniu;
</div>
<?php } ?>
</div>
<?=LinkPager::widget(['pagination'=>$pagination])?>
\ No newline at end of file
<div class="text-center">
<?=LinkPager::widget(['pagination'=>$pagination])?>
</div>
......@@ -10,11 +10,11 @@ $this->title = '知识有价';
</div>
<div class="col-md-4">
<h3>已结算</h3>
<p>¥162.03</p>
<p>¥<?=$settled?></p>
</div>
<div class="col-md-4">
<h3>待结算</h3>
<p>¥1829.00</p>
<p>¥<?=$notSettled?></p>
</div>
</div>
......
<?php
/* @var $this yii\web\View */
?>
<h1>my-member/index</h1>
<div class="vip-top clearfix">
<div class="col-md-6">
<div class="reg-vip-box">
<b>47</b>
<span>全部会员</span>
<i class="icon-verified_user"></i>
</div>
</div>
<div class="col-md-6">
<div class="money-vip-box">
<b>23</b>
<span>付费会员</span>
<i class="icon-heart"></i>
</div>
</div>
</div>
<p>
You may change the content of this page by modifying
the file <code><?= __FILE__; ?></code>.
</p>
<div class="con-md-12">
<div class="table-responsive table-box">
<table class="table table-hover">
<thead>
<tr>
<th>注册时间</th>
<th>会员信息</th>
<th>来自</th>
<th>首次购买</th>
<th>累计消费</th>
</tr>
</thead>
<tbody>
<tr>
<td>2016-12-11</td>
<td>18788860327 / 百丐洪七公</td>
<td>推广</td>
<td>《中国为什么这么久还没有进入社会主义社会》</td>
<td>¥123.00</td>
</tr>
<tr>
<td>2016-12-11</td>
<td>18788860327 / 百丐洪七公</td>
<td>推广</td>
<td>《中国为什么这么久还没有进入社会主义社会》</td>
<td>¥123.00</td>
</tr>
</tbody>
</table>
<div class="text-center hide">
<ul class="pagination pagination-sm">
<li><a href="#">&laquo;</a></li>
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">5</a></li>
<li><a href="#">&raquo;</a></li>
</ul>
</div>
</div>
</div>
\ No newline at end of file
......@@ -2,10 +2,10 @@
<div class="container">
<div class="cnt-tit">
<h3>{{coursewareInfo.courseName}}</h3>
<div class="tit-share hidden-xs">
<a href="javascript:;" class="wechat post-icons"></a>
<a href="javascript:;" class="weibo post-icons"></a>
<a href="javascript:;" class="qzone post-icons"></a>
<div class="tit-share hidden-xs bdsharebuttonbox">
<a href="javascript:;" class="wechat post-icons bds_weixin" data-cmd="weixin" title="分享到微信"></a>
<a href="javascript:;" class="weibo post-icons bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
<a href="javascript:;" class="qzone post-icons bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
</div>
</div>
......@@ -17,20 +17,81 @@
</div>
<div class="video-detail-info">
<div v-for="item in coursewareInfo.teachers" class="video-teacher">
<a href="javascript:;" data-toggle="modal" data-target="#myModal2"><img
<div v-for="(index,item) in coursewareInfo.teachers" class="video-teacher">
<a data-toggle="modal" data-target="{{{'#teacherInfo'+index}}}"><img
:src="getFullPic(item.avatar)"></a>
<p><a href="javascript:;" data-toggle="modal" data-target="#myModal2">{{item.name}}</a></p>
</div>
<div class="video-sm-info">
<div class="video-sm-info pull-left">
<a href="javascript:;"><i class="icon-comment-empty"></i>{{coursewareInfo.comment_count}}</a>
<a @click="favorite" href="javascript:;"><i
:class="{'icon-fav-full':coursewareInfo.isFavorite,'icon-fav-empty':!coursewareInfo.isFavorite}"></i>{{coursewareInfo.favorite_count}}</a>
<a @click="support" href="javascript:;"><i
:class="{'icon-zan-full':coursewareInfo.isSupport,'icon-zan-empty':!coursewareInfo.isSupport}"></i>{{coursewareInfo.support_count}}</a>
<button v-if="coursewareInfo.isGuest" @click="login" class="btn btn-danger m-l-20 hidden-xs">购买
¥{{coursewareInfo.price}}
</button>
<button v-else class="btn btn-danger m-l-20 hidden-xs" data-toggle="modal"
data-target="#pay">购买 ¥{{coursewareInfo.price}}
</button>
</div>
</div>
</div>
<div v-if="!coursewareInfo.isGuest" class="modal fade" id="pay" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span
aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">在线支付</h4>
</div>
<div class="modal-body">
<div class="pay-style">
<h3>¥{{coursewareInfo.price}}</h3>
<button data-dismiss="modal" @click="alipay(coursewareInfo.course_id)" class="btn btn-alipay">支付宝支付</button>
<button @click="showQrcode=true" class="btn btn-wecat">微信支付</button>
</div>
</div>
</div>
<div v-show="showQrcode" class="wecat-qrcode">
<div class="top-back-a">
<a href="javascript:;" @click="showQrcode = false">< 返回支付渠道选择</a>
</div>
<div class="qrcode-img">
<img :src="getWeixinPayQrcode(coursewareInfo.course_id)">
<p>请使用微信扫一扫付款</p>
</div>
</div>
</div>
</div>
<div v-for="(index,item) in coursewareInfo.teachers" class="modal fade" id="{{{'teacherInfo'+index}}}" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span
aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title">讲师信息</h4>
</div>
<div class="modal-body">
<div class="teacher-info text-center">
<img :src="getFullPic(item.avatar)">
<h3>{{item.name}}</h3>
<p class="teacher-detail">
{{item.intro}}
</p>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
......@@ -43,9 +104,35 @@
export default{
data(){
return {}
return {
showQrcode: false
}
},
methods: {
getWeixinPayQrcode(courseId){
return __BASE_URL__ + 'home/weixin-pay-qrcode?courseId=' + courseId;
},
alipay(courseId){
var url = __BASE_URL__ + 'home/pay?courseId=' + courseId;
window.open(url);
layer.confirm('是否已经完成支付?', {
btn: ['是的', '没有'] //按钮
}, function () {
window.location.reload();
}, function () {
});
},
login(){
var returnUrl = __BASE_URL__ + 'home/video?courseId=' + this.coursewareInfo.course_id;
var url = __BASE_URL__ + 'site/set-return-url?url=' + returnUrl;
$.getJSON(url, function () {
window.location.href = __BASE_URL__ + 'site/login';
}).error(function () {
layer.alert('设置登录回调url错误', {'icon': 2, 'title': '提示'})
});
},
favorite(){
if (this.coursewareInfo.isGuest != true) {
var self = this;
......@@ -109,3 +196,4 @@
}
}
</script>
......@@ -23,16 +23,18 @@ $("#main-login").attr('href', 'javascript:;').click(function () {
});
if(!coursewareInfo.isGuest){
//记录浏览记录
var url = __BASE_URL__ + 'home/browse-record?coursewareId=' + coursewareInfo.id;
$.getJSON(url, function (response) {
if (response.status === false) {
layer.alert('浏览记录添加逻辑错误', {'icon': 2, 'title': '提示'})
}
}).error(function () {
layer.alert('添加浏览记录错误', {'icon': 2, 'title': '提示'})
var url = __BASE_URL__ + 'home/browse-record?coursewareId=' + coursewareInfo.id;
$.getJSON(url, function (response) {
if (response.status === false) {
layer.alert('浏览记录添加逻辑错误', {'icon': 2, 'title': '提示'})
}
}).error(function () {
layer.alert('添加浏览记录错误', {'icon': 2, 'title': '提示'})
});
});
}
var href = $('#main-sign').attr("href");
$('#main-sign').attr('href', href + '?from=' + coursewareInfo.user_id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment