Commit 8d460662 authored by xiabin's avatar xiabin

讲师介绍,需要有个简易版的编辑器。

需要支持以下功能:
​加粗,倾斜,下划线,字体颜色,有序列表,无需列表
parent 2ad0080d
<?php
/**
* Created by PhpStorm.
* User: xiabin
* Date: 2016/10/13
* Time: 上午9:57
*/
namespace frontend\controllers;
use common\libs\Utils;
use GuzzleHttp\Client;
use yii\web\Controller;
class TestController extends Controller
{
public $enableCsrfValidation = FALSE;
public function actionIndex2()
{
$data = (\Yii::$app->request->post());
$order_id = date("YmdHis");
$order_id = '20161013135950';
//发送统一下单请求
$client = new Client(
[
'timeout' => 8,
'verify' => FALSE,
'connect_timeout' => 8
]
);
$uri = 'https://api.mch.weixin.qq.com/pay/unifiedorder';
$weixinpay = \Yii::$app->params['weixinpay'];
$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' => '114.112.65.4',
'notify_url' => 'http://c.pp.cc/frontend/web/index.php/pay/weixin-notify',
'trade_type' => 'NATIVE',
];
$xml['sign'] = Utils::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 = simplexml_load_string($result);
$prepay_id = (string)$result->prepay_id;
$return = [
'return_code' => 'SUCCESS',
'appid'=>$weixinpay['appid'],
'mch_id'=>$weixinpay['mchid'],
'nonce_str'=>(string)$result->nonce_str,
'prepay_id'=>(string)$result->prepay_id,
'result_code'=>'SUCCESS',
'sign'=>''
];
$return['sign'] = Utils::makeWeixinPaySign($return,$weixinpay['key']);
return \Yii::createObject([
'class' => 'yii\web\Response',
'format' => \yii\web\Response::FORMAT_XML,
'formatters' => [
\yii\web\Response::FORMAT_XML => [
'class' => 'yii\web\XmlResponseFormatter',
'rootTag' => 'xml', //根节点
],
],
'data' => $return
]);
// var_dump(Yii::$app->request->post());
// $log = \Yii::$app->log->getLogger();
// $log->log(json_encode($data),Logger::LEVEL_ERROR);
}
public function actionIndex(){
return $this->render('index');
}
}
opcache_invalidate(__FILE__);
\ No newline at end of file
...@@ -81,3 +81,13 @@ AppAsset::addCss($this, '@web/assets/css/course_publish.css'); ...@@ -81,3 +81,13 @@ AppAsset::addCss($this, '@web/assets/css/course_publish.css');
</div> </div>
</form> </form>
</div> </div>
<script type="text/javascript">
$(function(){
$( window ).unload(function() {
// return "Bye now!";
alert("Goodbye!");
return false;
});
});
</script>
\ No newline at end of file
...@@ -7,6 +7,8 @@ use frontend\assets\AppAsset; ...@@ -7,6 +7,8 @@ use frontend\assets\AppAsset;
$this->title = '添加讲师'; $this->title = '添加讲师';
AppAsset::addScript($this, '@web/assets/teacher_form.js'); AppAsset::addScript($this, '@web/assets/teacher_form.js');
AppAsset::addCss($this, '@web/assets/css/teacher_form.css');
?> ?>
<div class="add-box"> <div class="add-box">
<div class="add-box-main"> <div class="add-box-main">
...@@ -20,7 +22,7 @@ AppAsset::addScript($this, '@web/assets/teacher_form.js'); ...@@ -20,7 +22,7 @@ AppAsset::addScript($this, '@web/assets/teacher_form.js');
</div> </div>
<div class="teacher-info"> <div class="teacher-info">
<textarea name="intro" placeholder="请输入讲师介绍..."></textarea> <textarea id="teacher-intro" name="intro" placeholder="请输入讲师介绍..."></textarea>
<p class="text-number">20 / 500</p> <p class="text-number">20 / 500</p>
</div> </div>
......
...@@ -4,6 +4,8 @@ use frontend\assets\AppAsset; ...@@ -4,6 +4,8 @@ use frontend\assets\AppAsset;
$this->title = '修改讲师信息'; $this->title = '修改讲师信息';
AppAsset::addScript($this, '@web/assets/teacher_form.js'); AppAsset::addScript($this, '@web/assets/teacher_form.js');
AppAsset::addCss($this, '@web/assets/css/teacher_form.css');
?> ?>
<div class="add-box"> <div class="add-box">
<div class="add-box-main"> <div class="add-box-main">
...@@ -17,7 +19,7 @@ AppAsset::addScript($this, '@web/assets/teacher_form.js'); ...@@ -17,7 +19,7 @@ AppAsset::addScript($this, '@web/assets/teacher_form.js');
</div> </div>
<div class="teacher-info"> <div class="teacher-info">
<textarea name="intro" placeholder="请输入讲师介绍..."><?=$teacher->intro?></textarea> <textarea id="teacher-intro" name="intro" placeholder="请输入讲师介绍..."><?=$teacher->intro?></textarea>
<p class="text-number">20 / 500</p> <p class="text-number">20 / 500</p>
</div> </div>
......
...@@ -57,3 +57,27 @@ var vm = new Vue({ ...@@ -57,3 +57,27 @@ var vm = new Vue({
}); });
} }
}); });
var Simditor = require("../utils/simditor");
//添加编辑器部分
var editor = new Simditor({
textarea: $('#teacher-intro'),
upload: false,
tabIndent: true,
toolbar: [
'bold',
'italic',
'underline',
'color',
'ol',
'ul'
],
toolbarFloat: true,
toolbarFloatOffset: 0,
toolbarHidden: false,
pasteImage: false,
cleanPaste: false,
//optional options
});
\ No newline at end of file
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