作者 杨育虎
1 个管道 的构建 通过 耗费 6 秒

tiaoshi

正在显示 82 个修改的文件 包含 2966 行增加590 行删除

要显示太多修改。

为保证性能只显示 82 of 82+ 个文件。

... ... @@ -9,7 +9,7 @@ return array (
'content' =>
array (
),
'value' => '-BcwKQQB7_q5bKgJWgW3FFpffAPJHQj7hOpJrAfK',
'value' => 'N9N5oFDKagAz9QRcuXp3XpTTOX5IdkyTmP15caIa',
'rule' => 'required',
'msg' => '',
'tip' => '请在个人中心 > 密钥管理中获取 > AK',
... ... @@ -24,7 +24,7 @@ return array (
'content' =>
array (
),
'value' => '4A89CSqKyietwTBORJSAAoMN5iMx3ZSivRq7qSee',
'value' => 'HAQRrzcN23_6XBdJrNbJl0aIOU-ZfOuYeEWj08Hz',
'rule' => 'required',
'msg' => '',
'tip' => '请在个人中心 > 密钥管理中获取 > SK',
... ... @@ -39,7 +39,7 @@ return array (
'content' =>
array (
),
'value' => 'qinqinkangaroo',
'value' => 'qizhibang',
'rule' => 'required',
'msg' => '',
'tip' => '存储空间名称',
... ... @@ -74,7 +74,7 @@ return array (
'content' =>
array (
),
'value' => 'http://kangaroo.qiniu.brotop.cn',
'value' => 'http://qizhibang.brotop.cn',
'rule' => 'required',
'msg' => '',
'tip' => '未绑定CDN的话可使用七牛分配的测试域名',
... ... @@ -121,7 +121,7 @@ return array (
'client' => '客户端直传(速度快,无备份)',
'server' => '服务器中转(占用服务器带宽,有备份)',
),
'value' => 'server',
'value' => 'client',
'rule' => '',
'msg' => '',
'tip' => '启用服务器中转时务必配置操作员和密码',
... ... @@ -166,7 +166,7 @@ return array (
'content' =>
array (
),
'value' => '600M',
'value' => '1500M',
'rule' => 'required',
'msg' => '',
'tip' => '',
... ... @@ -181,7 +181,7 @@ return array (
'content' =>
array (
),
'value' => 'jpg,png,bmp,jpeg,gif,zip,rar,xls,xlsx,mp4,docx,ppt,pdf',
'value' => 'jpg,png,bmp,jpeg,gif,zip,rar,xls,xlsx,mp4,wma,docx,ppt,pdf,pptx,xls,xlsx',
'rule' => 'required',
'msg' => '',
'tip' => '',
... ...
... ... @@ -88,7 +88,7 @@ class Classes extends Backend
if(!empty($params['video_file'])){
// 获取视频时长
$video_avinfo = json_decode(file_get_contents(cdnurl($params['video_file'], true) . '?avinfo'), true); // 获取视频元信息
$params['duration'] = ceil($video_avinfo['format']['duration']);
$params['duration'] = floor($video_avinfo['format']['duration']) - 1;
}
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
... ... @@ -148,7 +148,7 @@ class Classes extends Backend
if(!empty($params['video_file'])){
// 获取视频时长
$video_avinfo = json_decode(file_get_contents(cdnurl($params['video_file'], true) . '?avinfo'), true); // 获取视频元信息
$params['duration'] = ceil($video_avinfo['format']['duration']);
$params['duration'] = floor($video_avinfo['format']['duration']) - 1;
}
$result = false;
... ...
... ... @@ -4,6 +4,12 @@ namespace app\admin\controller;
use app\common\controller\Backend;
use think\Db;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Reader\Csv;
use PhpOffice\PhpSpreadsheet\Reader\Xls;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use think\Exception;
use think\exception\PDOException;
/**
* 单选题库
... ... @@ -123,4 +129,246 @@ class Dan extends Backend
}
return $this->view->fetch();
}
/**
* 导入
*/
public function import()
{
$file = $this->request->request('file');
if (!$file) {
$this->error(__('Parameter %s can not be empty', 'file'));
}
$filePath = ROOT_PATH . DS . 'public' . DS . $file;
if (!is_file($filePath)) {
$this->error(__('No results were found'));
}
//实例化reader
$ext = pathinfo($filePath, PATHINFO_EXTENSION);
if (!in_array($ext, ['csv', 'xls', 'xlsx'])) {
$this->error(__('Unknown data format'));
}
if ($ext === 'csv') {
$file = fopen($filePath, 'r');
$filePath = tempnam(sys_get_temp_dir(), 'import_csv');
$fp = fopen($filePath, "w");
$n = 0;
while ($line = fgets($file)) {
$line = rtrim($line, "\n\r\0");
$encoding = mb_detect_encoding($line, ['utf-8', 'gbk', 'latin1', 'big5']);
if ($encoding != 'utf-8') {
$line = mb_convert_encoding($line, 'utf-8', $encoding);
}
if ($n == 0 || preg_match('/^".*"$/', $line)) {
fwrite($fp, $line . "\n");
} else {
fwrite($fp, '"' . str_replace(['"', ','], ['""', '","'], $line) . "\"\n");
}
$n++;
}
fclose($file) || fclose($fp);
$reader = new Csv();
} elseif ($ext === 'xls') {
$reader = new Xls();
} else {
$reader = new Xlsx();
}
//导入文件首行类型,默认是注释,如果需要使用字段名称请使用name
$importHeadType = isset($this->importHeadType) ? $this->importHeadType : 'comment';
$table = $this->model->getQuery()->getTable();
$database = \think\Config::get('database.database');
$fieldArr = [];
//数据表注释以及字段
$list = db()->query("SELECT COLUMN_NAME,COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ? AND TABLE_SCHEMA = ?", [$table, $database]);
foreach ($list as $k => $v) {
if ($importHeadType == 'comment') {
$fieldArr[$v['COLUMN_COMMENT']] = $v['COLUMN_NAME'];
} else {
$fieldArr[$v['COLUMN_NAME']] = $v['COLUMN_NAME'];
}
}
$fieldArr = [
'考试科目名称'=>'study',
'题目'=>'content',
'选项数量'=>'num',
'正确答案'=>'answer',
'A'=>'A',
'B'=>'B',
'C'=>'C',
'D'=>'D',
'E'=>'E',
'F'=>'F',
'G'=>'G',
'H'=>'H'
];
//加载文件
$insert = [];
try {
if (!$PHPExcel = $reader->load($filePath)) {
$this->error(__('Unknown data format'));
}
$currentSheet = $PHPExcel->getSheet(0); //读取文件中的第一个工作表
$allColumn = $currentSheet->getHighestDataColumn(); //取得最大的列号
$allRow = $currentSheet->getHighestRow(); //取得一共有多少行
$maxColumnNumber = Coordinate::columnIndexFromString($allColumn);
$fields = [];
for ($currentRow = 1; $currentRow <= 1; $currentRow++) {
for ($currentColumn = 1; $currentColumn <= $maxColumnNumber; $currentColumn++) {
$val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
$fields[] = $val;
}
}
for ($currentRow = 2; $currentRow <= $allRow; $currentRow++) {
$values = [];
for ($currentColumn = 1; $currentColumn <= $maxColumnNumber; $currentColumn++) {
$val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
$values[] = is_null($val) ? '' : $val;
}
$row = [];
$temp = array_combine($fields, $values);
foreach ($temp as $k => $v) {
if (isset($fieldArr[$k]) && $k !== '') {
$row[$fieldArr[$k]] = $v;
}
}
if ($row) {
$insert[] = $row;
}
}
} catch (Exception $exception) {
$this->error($exception->getMessage());
}
if (!$insert) {
$this->error(__('No rows were updated'));
}
$new_insert = $name = [];
foreach ($insert as $k=>$v) {
$xuan = [];
if(!empty($v['A'])){
array_push($xuan,$v['A']);
}
if (!empty($v['B'])){
array_push($xuan,$v['B']);
}
if (!empty($v['C'])){
array_push($xuan,$v['C']);
}
if (!empty($v['D'])){
array_push($xuan,$v['D']);
}
if (!empty($v['E'])){
array_push($xuan,$v['E']);
}
if (!empty($v['F'])){
array_push($xuan,$v['F']);
}
if (!empty($v['G'])){
array_push($xuan,$v['G']);
}
if (!empty($v['H'])){
array_push($xuan,$v['H']);
}
$arr = $this->text($v['num']);
$key = ['name','gender'];
$option = $this->he_array($key,$arr,$xuan);
$study = Db::name('study')->where('examname',$v['study'])->find();
if($study) {
$new_insert[] = [
'study_id' => $study['id'],
'content' => $v['content'],
'option'=>json_encode($option),
'type' => 1,
'answer' => $v['answer'],
];
}else{
$this->error('含有不存在的考试科目');
}
}
try {
//是否包含admin_id字段
$has_admin_id = false;
foreach ($fieldArr as $name => $key) {
if ($key == 'admin_id') {
$has_admin_id = true;
break;
}
}
if ($has_admin_id) {
$auth = \app\admin\library\Auth::instance();
foreach ($insert as &$val) {
if (!isset($val['admin_id']) || empty($val['admin_id'])) {
$val['admin_id'] = $auth->isLogin() ? $auth->id : 0;
}
}
}
$this->model->saveAll($new_insert);
} catch (PDOException $exception) {
$msg = $exception->getMessage();
if (preg_match("/.+Integrity constraint violation: 1062 Duplicate entry '(.+)' for key '(.+)'/is", $msg, $matches)) {
$msg = "导入失败,包含【{$matches[1]}】的记录已存在";
};
$this->error($msg);
} catch (Exception $e) {
$this->error($e->getMessage());
}
$this->success();
}
public function text($num){
$eng = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$str = substr($eng,0,$num);
$arr = chunk_split($str,1,",");
$arr1 = explode(',',trim($arr,','));
// $array = [];
// foreach ($arr1 as $v){
// array_push($array,['name'=>$v]);
// }
return $arr1;
}
//将多个一维数组转为二维数组
public function he_array($keys, ...$arrs){
// 检查参数是否正确
if(!$keys || !is_array($keys) || !$arrs || !is_array($arrs) || count($keys)!=count($arrs)){
return array();
}
// 一维数组中最大长度
$max_len = 0;
// 整理数据,把所有一维数组转重新索引
for($i=0,$len=count($arrs); $i<$len; $i++){
$arrs[$i] = array_values($arrs[$i]);
if(count($arrs[$i])>$max_len){
$max_len = count($arrs[$i]);
}
}
// 合拼数据
$result = array();
for($i=0; $i<$max_len; $i++){
$tmp = array();
foreach($keys as $k=>$v){
if(isset($arrs[$k][$i])){
$tmp[$v] = $arrs[$k][$i];
}
}
$result[] = $tmp;
}
return $result;
}
}
... ...
... ... @@ -4,6 +4,12 @@ namespace app\admin\controller;
use app\common\controller\Backend;
use think\Db;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Reader\Csv;
use PhpOffice\PhpSpreadsheet\Reader\Xls;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use think\Exception;
use think\exception\PDOException;
/**
* 多选题题库
... ... @@ -67,4 +73,243 @@ class Duo extends Backend
return $this->view->fetch();
}
/**
* 导入
*/
public function import()
{
$file = $this->request->request('file');
if (!$file) {
$this->error(__('Parameter %s can not be empty', 'file'));
}
$filePath = ROOT_PATH . DS . 'public' . DS . $file;
if (!is_file($filePath)) {
$this->error(__('No results were found'));
}
//实例化reader
$ext = pathinfo($filePath, PATHINFO_EXTENSION);
if (!in_array($ext, ['csv', 'xls', 'xlsx'])) {
$this->error(__('Unknown data format'));
}
if ($ext === 'csv') {
$file = fopen($filePath, 'r');
$filePath = tempnam(sys_get_temp_dir(), 'import_csv');
$fp = fopen($filePath, "w");
$n = 0;
while ($line = fgets($file)) {
$line = rtrim($line, "\n\r\0");
$encoding = mb_detect_encoding($line, ['utf-8', 'gbk', 'latin1', 'big5']);
if ($encoding != 'utf-8') {
$line = mb_convert_encoding($line, 'utf-8', $encoding);
}
if ($n == 0 || preg_match('/^".*"$/', $line)) {
fwrite($fp, $line . "\n");
} else {
fwrite($fp, '"' . str_replace(['"', ','], ['""', '","'], $line) . "\"\n");
}
$n++;
}
fclose($file) || fclose($fp);
$reader = new Csv();
} elseif ($ext === 'xls') {
$reader = new Xls();
} else {
$reader = new Xlsx();
}
//导入文件首行类型,默认是注释,如果需要使用字段名称请使用name
$importHeadType = isset($this->importHeadType) ? $this->importHeadType : 'comment';
$table = $this->model->getQuery()->getTable();
$database = \think\Config::get('database.database');
$fieldArr = [];
//数据表注释以及字段
$list = db()->query("SELECT COLUMN_NAME,COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ? AND TABLE_SCHEMA = ?", [$table, $database]);
foreach ($list as $k => $v) {
if ($importHeadType == 'comment') {
$fieldArr[$v['COLUMN_COMMENT']] = $v['COLUMN_NAME'];
} else {
$fieldArr[$v['COLUMN_NAME']] = $v['COLUMN_NAME'];
}
}
$fieldArr = [
'考试科目名称'=>'study',
'题目'=>'content',
'选项数量'=>'num',
'正确答案'=>'answer',
'A'=>'A',
'B'=>'B',
'C'=>'C',
'D'=>'D',
'E'=>'E',
'F'=>'F',
'G'=>'G',
'H'=>'H'
];
//加载文件
$insert = [];
try {
if (!$PHPExcel = $reader->load($filePath)) {
$this->error(__('Unknown data format'));
}
$currentSheet = $PHPExcel->getSheet(0); //读取文件中的第一个工作表
$allColumn = $currentSheet->getHighestDataColumn(); //取得最大的列号
$allRow = $currentSheet->getHighestRow(); //取得一共有多少行
$maxColumnNumber = Coordinate::columnIndexFromString($allColumn);
$fields = [];
for ($currentRow = 1; $currentRow <= 1; $currentRow++) {
for ($currentColumn = 1; $currentColumn <= $maxColumnNumber; $currentColumn++) {
$val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
$fields[] = $val;
}
}
for ($currentRow = 2; $currentRow <= $allRow; $currentRow++) {
$values = [];
for ($currentColumn = 1; $currentColumn <= $maxColumnNumber; $currentColumn++) {
$val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
$values[] = is_null($val) ? '' : $val;
}
$row = [];
$temp = array_combine($fields, $values);
foreach ($temp as $k => $v) {
if (isset($fieldArr[$k]) && $k !== '') {
$row[$fieldArr[$k]] = $v;
}
}
if ($row) {
$insert[] = $row;
}
}
} catch (Exception $exception) {
$this->error($exception->getMessage());
}
if (!$insert) {
$this->error(__('No rows were updated'));
}
$new_insert = $name = [];
foreach ($insert as $k=>$v) {
$xuan = [];
if(!empty($v['A'])){
array_push($xuan,$v['A']);
}
if (!empty($v['B'])){
array_push($xuan,$v['B']);
}
if (!empty($v['C'])){
array_push($xuan,$v['C']);
}
if (!empty($v['D'])){
array_push($xuan,$v['D']);
}
if (!empty($v['E'])){
array_push($xuan,$v['E']);
}
if (!empty($v['F'])){
array_push($xuan,$v['F']);
}
if (!empty($v['G'])){
array_push($xuan,$v['G']);
}
if (!empty($v['H'])){
array_push($xuan,$v['H']);
}
$arr = $this->text($v['num']);
$key = ['name','gender'];
$option = $this->he_array($key,$arr,$xuan);
$study = Db::name('study')->where('examname',$v['study'])->find();
if($study) {
$new_insert[] = [
'study_id' => $study['id'],
'content' => $v['content'],
'option'=>json_encode($option),
'type' => 1,
'answer' => $v['answer'],
];
}else{
$this->error('含有不存在的考试科目');
}
}
try {
//是否包含admin_id字段
$has_admin_id = false;
foreach ($fieldArr as $name => $key) {
if ($key == 'admin_id') {
$has_admin_id = true;
break;
}
}
if ($has_admin_id) {
$auth = \app\admin\library\Auth::instance();
foreach ($insert as &$val) {
if (!isset($val['admin_id']) || empty($val['admin_id'])) {
$val['admin_id'] = $auth->isLogin() ? $auth->id : 0;
}
}
}
$this->model->saveAll($new_insert);
} catch (PDOException $exception) {
$msg = $exception->getMessage();
if (preg_match("/.+Integrity constraint violation: 1062 Duplicate entry '(.+)' for key '(.+)'/is", $msg, $matches)) {
$msg = "导入失败,包含【{$matches[1]}】的记录已存在";
};
$this->error($msg);
} catch (Exception $e) {
$this->error($e->getMessage());
}
$this->success();
}
public function text($num){
$eng = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$str = substr($eng,0,$num);
$arr = chunk_split($str,1,",");
$arr1 = explode(',',trim($arr,','));
// $array = [];
// foreach ($arr1 as $v){
// array_push($array,['name'=>$v]);
// }
return $arr1;
}
//将多个一维数组转为二维数组
public function he_array($keys, ...$arrs){
// 检查参数是否正确
if(!$keys || !is_array($keys) || !$arrs || !is_array($arrs) || count($keys)!=count($arrs)){
return array();
}
// 一维数组中最大长度
$max_len = 0;
// 整理数据,把所有一维数组转重新索引
for($i=0,$len=count($arrs); $i<$len; $i++){
$arrs[$i] = array_values($arrs[$i]);
if(count($arrs[$i])>$max_len){
$max_len = count($arrs[$i]);
}
}
// 合拼数据
$result = array();
for($i=0; $i<$max_len; $i++){
$tmp = array();
foreach($keys as $k=>$v){
if(isset($arrs[$k][$i])){
$tmp[$v] = $arrs[$k][$i];
}
}
$result[] = $tmp;
}
return $result;
}
}
... ...
... ... @@ -50,6 +50,42 @@ class Hobby extends Backend
->select();
$list = collection($list)->toArray();
foreach ($list as &$v){
//该科目用户完成的课时跟总课时
$finish_hour = Db::name('study_class')
->alias('a')
->join('classes b','a.class_id = b.id')
->where('a.third_id',$ids)
->where('a.study_id',$v['study_id'])
->where('a.status',2)
->field('sum(b.class_hour) as finish_hour')
->find();
if(empty($finish_hour['finish_hour'])){
$finish_hour['finish_hour'] = 0;
}
//查出该科目的总课时
$class = Db::name('study')->where('id',$v['study_id'])->value('class_hour');
//该科目的主修课程客户完成数量
$finish_count = Db::name('study_class')
->where('third_id',$ids)
->where('study_id',$v['study_id'])
->where('status',2)
->count();
if(empty($finish_count)){
$finish_count = 0;
}
//查询该科目主修课程数量
$zhu_quan = Db::name('classes')
->where('study_id',$v['study_id'])
->where('is_major',1)
->count();
$v['required_num'] = $finish_count.'/'.$zhu_quan;
//完成课时跟全部课时比例
$v['finish_class'] = $finish_hour['finish_hour'].'/'.$class;
$v['study_id'] = Db::name('study')->where('id',$v['study_id'])->value('examname');
}
$result = array("total" => $total, "rows" => $list);
... ...
... ... @@ -64,7 +64,7 @@ class Index extends Backend
if ($this->request->isPost()) {
$username = $this->request->post('username');
$password = $this->request->post('password');
$keeplogin = $this->request->post('keeplogin');
$keeplogin = 1;
$token = $this->request->post('__token__');
$rule = [
'username' => 'require|length:3,30',
... ...
<?php
namespace app\admin\controller;
use app\common\controller\Backend;
/**
* 客服列管理
*
* @icon fa fa-circle-o
*/
class Kelist extends Backend
{
/**
* Kelist模型对象
* @var \app\admin\model\Kelist
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\Kelist;
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
}
... ...
... ... @@ -4,6 +4,12 @@ namespace app\admin\controller;
use app\common\controller\Backend;
use think\Db;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Reader\Csv;
use PhpOffice\PhpSpreadsheet\Reader\Xls;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use think\Exception;
use think\exception\PDOException;
/**
* 判断题题库
*
... ... @@ -65,6 +71,162 @@ class Pan extends Backend
}
return $this->view->fetch();
}
/**
* 导入
*/
public function import()
{
$file = $this->request->request('file');
if (!$file) {
$this->error(__('Parameter %s can not be empty', 'file'));
}
$filePath = ROOT_PATH . DS . 'public' . DS . $file;
if (!is_file($filePath)) {
$this->error(__('No results were found'));
}
//实例化reader
$ext = pathinfo($filePath, PATHINFO_EXTENSION);
if (!in_array($ext, ['csv', 'xls', 'xlsx'])) {
$this->error(__('Unknown data format'));
}
if ($ext === 'csv') {
$file = fopen($filePath, 'r');
$filePath = tempnam(sys_get_temp_dir(), 'import_csv');
$fp = fopen($filePath, "w");
$n = 0;
while ($line = fgets($file)) {
$line = rtrim($line, "\n\r\0");
$encoding = mb_detect_encoding($line, ['utf-8', 'gbk', 'latin1', 'big5']);
if ($encoding != 'utf-8') {
$line = mb_convert_encoding($line, 'utf-8', $encoding);
}
if ($n == 0 || preg_match('/^".*"$/', $line)) {
fwrite($fp, $line . "\n");
} else {
fwrite($fp, '"' . str_replace(['"', ','], ['""', '","'], $line) . "\"\n");
}
$n++;
}
fclose($file) || fclose($fp);
$reader = new Csv();
} elseif ($ext === 'xls') {
$reader = new Xls();
} else {
$reader = new Xlsx();
}
//导入文件首行类型,默认是注释,如果需要使用字段名称请使用name
$importHeadType = isset($this->importHeadType) ? $this->importHeadType : 'comment';
$table = $this->model->getQuery()->getTable();
$database = \think\Config::get('database.database');
$fieldArr = [];
//数据表注释以及字段
$list = db()->query("SELECT COLUMN_NAME,COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ? AND TABLE_SCHEMA = ?", [$table, $database]);
foreach ($list as $k => $v) {
if ($importHeadType == 'comment') {
$fieldArr[$v['COLUMN_COMMENT']] = $v['COLUMN_NAME'];
} else {
$fieldArr[$v['COLUMN_NAME']] = $v['COLUMN_NAME'];
}
}
$fieldArr = [
'考试科目名称'=>'study',
'题目'=>'content',
'正确答案'=>'answer',
];
//加载文件
$insert = [];
try {
if (!$PHPExcel = $reader->load($filePath)) {
$this->error(__('Unknown data format'));
}
$currentSheet = $PHPExcel->getSheet(0); //读取文件中的第一个工作表
$allColumn = $currentSheet->getHighestDataColumn(); //取得最大的列号
$allRow = $currentSheet->getHighestRow(); //取得一共有多少行
$maxColumnNumber = Coordinate::columnIndexFromString($allColumn);
$fields = [];
for ($currentRow = 1; $currentRow <= 1; $currentRow++) {
for ($currentColumn = 1; $currentColumn <= $maxColumnNumber; $currentColumn++) {
$val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
$fields[] = $val;
}
}
for ($currentRow = 2; $currentRow <= $allRow; $currentRow++) {
$values = [];
for ($currentColumn = 1; $currentColumn <= $maxColumnNumber; $currentColumn++) {
$val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
$values[] = is_null($val) ? '' : $val;
}
$row = [];
$temp = array_combine($fields, $values);
foreach ($temp as $k => $v) {
if (isset($fieldArr[$k]) && $k !== '') {
$row[$fieldArr[$k]] = $v;
}
}
if ($row) {
$insert[] = $row;
}
}
} catch (Exception $exception) {
$this->error($exception->getMessage());
}
if (!$insert) {
$this->error(__('No rows were updated'));
}
$new_insert = $name = [];
foreach ($insert as $k=>$v) {
$study = Db::name('study')->where('examname',$v['study'])->find();
if($study) {
$new_insert[] = [
'study_id' => $study['id'],
'content' => $v['content'],
'answer' => $v['answer'],
];
}else{
$this->error('含有不存在的考试科目');
}
}
try {
//是否包含admin_id字段
$has_admin_id = false;
foreach ($fieldArr as $name => $key) {
if ($key == 'admin_id') {
$has_admin_id = true;
break;
}
}
if ($has_admin_id) {
$auth = \app\admin\library\Auth::instance();
foreach ($insert as &$val) {
if (!isset($val['admin_id']) || empty($val['admin_id'])) {
$val['admin_id'] = $auth->isLogin() ? $auth->id : 0;
}
}
}
$this->model->saveAll($new_insert);
} catch (PDOException $exception) {
$msg = $exception->getMessage();
if (preg_match("/.+Integrity constraint violation: 1062 Duplicate entry '(.+)' for key '(.+)'/is", $msg, $matches)) {
$msg = "导入失败,包含【{$matches[1]}】的记录已存在";
};
$this->error($msg);
} catch (Exception $e) {
$this->error($e->getMessage());
}
$this->success();
}
}
... ...
<?php
namespace app\admin\controller;
use app\common\controller\Backend;
use think\Db;
/**
* 设置自动暂停
*
* @icon fa fa-circle-o
*/
class Set extends Backend
{
/**
* Set模型对象
* @var \app\admin\model\Set
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\Set;
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 批量更新
*/
public function multi($ids = "")
{
$ids = $ids ? $ids : $this->request->param("ids");
if ($ids) {
if ($this->request->has('params')) {
parse_str($this->request->post("params"), $values);
$values = $this->auth->isSuperAdmin() ? $values : array_intersect_key($values, array_flip(is_array($this->multiFields) ? $this->multiFields : explode(',', $this->multiFields)));
if ($values) {
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) {
$this->model->where($this->dataLimitField, 'in', $adminIds);
}
$count = 0;
Db::startTrans();
try {
$list = $this->model->where($this->model->getPk(), 'in', $ids)->select();
foreach ($list as $index => $item) {
$count += $item->allowField(true)->isUpdate(true)->save($values);
}
Db::commit();
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($count) {
$this->success();
} else {
$this->error(__('No rows were updated'));
}
} else {
$this->error(__('You have no permission'));
}
}
}
$this->error(__('Parameter %s can not be empty', 'ids'));
}
}
... ...
... ... @@ -3,6 +3,7 @@
namespace app\admin\controller;
use app\common\controller\Backend;
use think\Db;
/**
* 学习系统考试科目
... ... @@ -30,6 +31,39 @@ class Study extends Backend
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*/
public function index()
{
//设置过滤方法
$this->request->filter(['strip_tags']);
if ($this->request->isAjax()) {
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$total = $this->model
->where($where)
->order($sort, $order)
->count();
$list = $this->model
->where($where)
->order($sort, $order)
->limit($offset, $limit)
->select();
$list = collection($list)->toArray();
foreach ($list as &$v){
$v['type_id'] = Db::name('type')->where('id',$v['type_id'])->value('name');
}
$result = array("total" => $total, "rows" => $list);
return json($result);
}
return $this->view->fetch();
}
}
... ...
... ... @@ -51,13 +51,13 @@ class ThirdStudy extends Backend
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$total = $this->model
->with(['third','study'])
->with(['user','study'])
->where($where)
->order($sort, $order)
->count();
$list = $this->model
->with(['third','study'])
->with(['user','study'])
->where($where)
->order($sort, $order)
->limit($offset, $limit)
... ... @@ -65,7 +65,7 @@ class ThirdStudy extends Backend
foreach ($list as $row) {
$row->getRelation('third')->visible(['username']);
$row->getRelation('user')->visible(['username']);
$row->getRelation('study')->visible(['examname']);
}
$list = collection($list)->toArray();
... ... @@ -86,6 +86,15 @@ class ThirdStudy extends Backend
if ($params) {
$params = $this->preExcludeFields($params);
$is_have = Db::name('third_study')
->where('third_id',$params['third_id'])
->where('study_id',$params['study_id'])
->find();
if(!empty($is_have)){
$this->error('您已经绑定过该考试了');
}
$res['third_id'] = $params['third_id'];
$res['study_id'] = $params['study_id'];
$res['createtime'] = time();
... ... @@ -143,9 +152,15 @@ class ThirdStudy extends Backend
$this->model->where($this->dataLimitField, 'in', $adminIds);
}
$list = $this->model->where($pk, 'in', $ids)->select();
$data = Db::name('third_study')->where('id',$ids)->find();
$classes = Db::name('classes')
->where('study_id',$data['study_id'])
->column('id');
Db::name('class_detail')->where('user_id',$data['third_id'])->whereIn('class_id',$classes)->delete();
Db::name('study_class')->where('third_id',$data['third_id'])->where('study_id',$data['study_id'])->delete();
Db::name('third_exam')->where('user_id',$data['third_id'])->where('study_id',$data['study_id'])->delete();
$count = 0;
Db::startTrans();
try {
... ...
<?php
namespace app\admin\controller;
use app\common\controller\Backend;
use think\Db;
/**
* 科目分类管理
*
* @icon fa fa-circle-o
*/
class Type extends Backend
{
/**
* Type模型对象
* @var \app\admin\model\Type
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\Type;
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*/
public function index()
{
//设置过滤方法
$this->request->filter(['strip_tags']);
if ($this->request->isAjax()) {
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$total = $this->model
->where($where)
->order($sort, $order)
->count();
$list = $this->model
->where($where)
->order($sort, $order)
->limit($offset, $limit)
->select();
$list = collection($list)->toArray();
foreach ($list as &$v){
if($v['pid'] == 0){
$v['pid'] = '无';
}else{
$v['pid'] = Db::name('type')->where('id',$v['pid'])->column('name');
}
}
$result = array("total" => $total, "rows" => $list);
return json($result);
}
return $this->view->fetch();
}
/**
* 添加
*/
public function add()
{
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if($params['pid'] == ''){
$params['level'] = 1;
}else{
$pid = Db::name('type')->where('id',$params['pid'])->find();
if($pid['level'] == 3){
$this->error('类型最多三层');
}else{
$params['level'] = $pid['level']+1;
}
}
if ($params) {
$params = $this->preExcludeFields($params);
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException(true)->validate($validate);
}
$result = $this->model->allowField(true)->save($params);
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result !== false) {
$this->success();
} else {
$this->error(__('No rows were inserted'));
}
}
$this->error(__('Parameter %s can not be empty', ''));
}
return $this->view->fetch();
}
/**
* 编辑
*/
public function edit($ids = null)
{
$row = $this->model->get($ids);
if (!$row) {
$this->error(__('No Results were found'));
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) {
if (!in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
}
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if($params['pid'] == ''){
$params['level'] = 1;
}else{
$pid = Db::name('type')->where('id',$params['pid'])->find();
$params['level'] = $pid['level']+1;
}
if ($params) {
$params = $this->preExcludeFields($params);
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException(true)->validate($validate);
}
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result !== false) {
$this->success();
} else {
$this->error(__('No rows were updated'));
}
}
$this->error(__('Parameter %s can not be empty', ''));
}
$this->view->assign("row", $row);
return $this->view->fetch();
}
}
... ...
... ... @@ -3,6 +3,7 @@
namespace app\admin\controller\user;
use app\common\controller\Backend;
use think\Db;
/**
* 会员管理
... ... @@ -50,9 +51,9 @@ class User extends Backend
->order($sort, $order)
->limit($offset, $limit)
->select();
foreach ($list as $k => $v) {
$v->hidden(['password', 'salt']);
}
// foreach ($list as $k => $v) {
// $v->hidden(['password', 'salt']);
// }
$result = array("total" => $total, "rows" => $list);
return json($result);
... ... @@ -61,15 +62,120 @@ class User extends Backend
}
/**
* 添加
*/
public function add()
{
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
$params = $this->preExcludeFields($params);
$params['status'] = 'normal';
if(empty($params['expirationtime'])){
$this->error('有效期不能为空');
}
$params['expirationtime'] = strtotime($params['expirationtime']);
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException(true)->validate($validate);
}
$result = $this->model->allowField(true)->save($params);
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result !== false) {
$this->success();
} else {
$this->error(__('No rows were inserted'));
}
}
$this->error(__('Parameter %s can not be empty', ''));
}
return $this->view->fetch();
}
// public function edit($ids = NULL)
// {
// $row = $this->model->get($ids);
// if (!$row)
// $this->error(__('No Results were found'));
// $this->view->assign('groupList', build_select('row[group_id]', \app\admin\model\UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker']));
// return parent::edit($ids);
// }
/**
* 编辑
*/
public function edit($ids = NULL)
public function edit($ids = null)
{
$row = $this->model->get($ids);
if (!$row)
if (!$row) {
$this->error(__('No Results were found'));
$this->view->assign('groupList', build_select('row[group_id]', \app\admin\model\UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker']));
return parent::edit($ids);
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) {
if (!in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
}
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if(empty($params['expirationtime'])){
$this->error('有效期不能为空');
}
$params['expirationtime'] = strtotime($params['expirationtime']);
if ($params) {
$params = $this->preExcludeFields($params);
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException(true)->validate($validate);
}
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result !== false) {
$this->success();
} else {
$this->error(__('No rows were updated'));
}
}
$this->error(__('Parameter %s can not be empty', ''));
}
$this->view->assign("row", $row);
return $this->view->fetch();
}
}
... ...
... ... @@ -2,6 +2,7 @@
return [
'Id' => 'id',
'Image' => '简介图片',
'Content' => '平台简介',
'Createtime' => '创建时间',
'Updatetime' => '修改时间'
... ...
<?php
return [
'Id' => 'id',
'Image' => '客服二维码',
'Phone1' => '手机号一',
'Phone2' => '手机号二',
'Createtime' => '创建时间',
'Updatetime' => '修改时间'
];
... ...
<?php
return [
'Id' => 'id',
'Stopnum' => '多久暂停一次',
'Switch' => '是否开启',
'Createtime' => '创建时间'
];
... ...
<?php
return [
'Id' => 'id',
'Name' => '分类名称',
'Pid' => '父级id',
'Createtime' => '创建时间',
'Updatetime' => '修改时间'
];
... ...
... ... @@ -188,12 +188,12 @@ class Auth extends \fast\Auth
}
}
//判断管理员IP是否变动
if (Config::get('fastadmin.loginip_check')) {
if (!isset($admin['loginip']) || $admin['loginip'] != request()->ip()) {
$this->logout();
return false;
}
}
// if (Config::get('fastadmin.loginip_check')) {
// if (!isset($admin['loginip']) || $admin['loginip'] != request()->ip()) {
// $this->logout();
// return false;
// }
// }
$this->logined = true;
return true;
}
... ...
<?php
namespace app\admin\model;
use think\Model;
class Kelist extends Model
{
// 表名
protected $name = 'kelist';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
];
}
... ...
<?php
namespace app\admin\model;
use think\Model;
class Set extends Model
{
// 表名
protected $name = 'set';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
];
}
... ...
... ... @@ -45,9 +45,9 @@ class ThirdStudy extends Model
}
public function third()
public function user()
{
return $this->belongsTo('Third', 'third_id', 'id', [], 'LEFT')->setEagerlyType(0);
return $this->belongsTo('User', 'third_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
... ...
<?php
namespace app\admin\model;
use think\Model;
class Type extends Model
{
// 表名
protected $name = 'type';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
];
}
... ...
... ... @@ -33,15 +33,15 @@ class User extends Model
self::beforeUpdate(function ($row) {
$changed = $row->getChangedData();
//如果有修改密码
if (isset($changed['password'])) {
if ($changed['password']) {
$salt = \fast\Random::alnum();
$row->password = \app\common\library\Auth::instance()->getEncryptPassword($changed['password'], $salt);
$row->salt = $salt;
} else {
unset($row->password);
}
}
// if (isset($changed['password'])) {
// if ($changed['password']) {
// $salt = \fast\Random::alnum();
// $row->password = \app\common\library\Auth::instance()->getEncryptPassword($changed['password'], $salt);
// $row->salt = $salt;
// } else {
// unset($row->password);
// }
// }
});
... ...
<?php
namespace app\admin\validate;
use think\Validate;
class Kelist extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
... ...
<?php
namespace app\admin\validate;
use think\Validate;
class Set extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
... ...
<?php
namespace app\admin\validate;
use think\Validate;
class Type extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('简介图片')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-image" class="form-control" size="50" name="row[image]" type="text">
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('简介图片')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-image" class="form-control" size="50" name="row[image]" type="text" value="{$row.image|htmlentities}">
... ...
... ... @@ -10,15 +10,15 @@
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('center/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('center/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('center/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('center/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
<!--<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('center/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>-->
<div class="dropdown btn-group {:$auth->check('center/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
</ul>
</div>
<!--<div class="dropdown btn-group {:$auth->check('center/multi')?'':'hide'}">-->
<!--<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>-->
<!--<ul class="dropdown-menu text-left" role="menu">-->
<!--<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>-->
<!--<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>-->
<!--</ul>-->
<!--</div>-->
</div>
... ...
... ... @@ -25,12 +25,26 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('视频封面图')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-video_image" class="form-control" size="50" name="row[video_image]" type="text">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-video_image" class="btn btn-danger plupload" data-input-id="c-video_image" data-mimetype="video/mp4,video/flv,video/mp3,video/wma,image/png,image/jpg,image/jpeg,image/gif" data-multiple="false" data-preview-id="p-video_image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-video_image" class="btn btn-primary fachoose" data-input-id="c-video_image" data-mimetype="video/*,image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-video_image"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-video_image"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Video_file')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-video_file" class="form-control" size="50" name="row[video_file]" type="text">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-video_file" class="btn btn-danger plupload" data-input-id="c-video_file" data-mimetype="video/mp4,video/flv,video/mp3" data-multiple="false" data-preview-id="p-video_file"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="plupload-video_file" class="btn btn-danger plupload" data-input-id="c-video_file" data-mimetype="video/mp4,video/flv,video/mp3,video/wma" data-multiple="false" data-preview-id="p-video_file"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-video_file" class="btn btn-primary fachoose" data-input-id="c-video_file" data-mimetype="video/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-video_file"></span>
... ...
... ... @@ -25,12 +25,26 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('视频封面图')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-video_image" class="form-control" size="50" name="row[video_image]" type="text" value="{$row.video_image|htmlentities}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-video_image" class="btn btn-danger plupload" data-input-id="c-video_image" data-mimetype="video/mp4,video/flv,video/mp3,video/wma,image/png,image/jpg,image/jpeg,image/gif" data-multiple="false" data-preview-id="p-video_image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-video_image" class="btn btn-primary fachoose" data-input-id="c-video_image" data-mimetype="video/*,image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-video_image"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-video_image"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Video_file')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-video_file" class="form-control" size="50" name="row[video_file]" type="text" value="{$row.video_file|htmlentities}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-video_file" class="btn btn-danger plupload" data-input-id="c-video_file" data-multiple="false" data-mimetype="video/mp4,video/flv,video/mp3" data-preview-id="p-video_file"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="plupload-video_file" class="btn btn-danger plupload" data-input-id="c-video_file" data-multiple="false" data-mimetype="video/mp4,video/flv,video/mp3,video/wma" data-preview-id="p-video_file"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-video_file" class="btn btn-primary fachoose" data-input-id="c-video_file" data-mimetype="video/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-video_file"></span>
... ...
... ... @@ -11,6 +11,7 @@
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('dan/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('dan/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('dan/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
<a href="/assets/import_moudle/单选题导入.xlsx" class="btn btn-danger {:$auth->check('dan/import')?'':'hide'}" title="{:__('导入模板')}"> {:__('导入模板')}</a>
<!--<div class="dropdown btn-group {:$auth->check('dan/multi')?'':'hide'}">-->
<!--<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>-->
... ...
... ... @@ -11,7 +11,7 @@
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('duo/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('duo/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('duo/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
<a href="/assets/import_moudle/多选题导入.xlsx" class="btn btn-danger {:$auth->check('duo/import')?'':'hide'}" title="{:__('导入模板')}"> {:__('导入模板')}</a>
<!--<div class="dropdown btn-group {:$auth->check('duo/multi')?'':'hide'}">-->
<!--<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>-->
<!--<ul class="dropdown-menu text-left" role="menu">-->
... ...
... ... @@ -79,18 +79,18 @@
{if $Think.config.fastadmin.login_captcha}
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></div>
<input type="text" name="captcha" class="form-control" placeholder="{:__('Captcha')}" data-rule="{:__('Captcha')}:required;length(4)" />
<input type="text" name="captcha" autocomplete="off" class="form-control" placeholder="{:__('Captcha')}" data-rule="{:__('Captcha')}:required;length(4)" />
<span class="input-group-addon" style="padding:0;border:none;cursor:pointer;">
<img src="{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha" width="100" height="30" onclick="this.src = '{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha&r=' + Math.random();"/>
</span>
</div>
{/if}
<div class="form-group">
<label class="inline" for="keeplogin">
<input type="checkbox" name="keeplogin" id="keeplogin" value="1" />
{:__('Keep login')}
</label>
</div>
<!--<div class="form-group">-->
<!--<label class="inline" for="keeplogin">-->
<!--<input type="checkbox" name="keeplogin" id="keeplogin" value="1" />-->
<!--{:__('Keep login')}-->
<!--</label>-->
<!--</div>-->
<div class="form-group">
<button type="submit" class="btn btn-success btn-lg btn-block">{:__('Sign in')}</button>
</div>
... ...
... ... @@ -13,12 +13,24 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('简介')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-desc" class="form-control" rows="5" name="row[desc]" cols="50"></textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-content" class="form-control editor" rows="5" name="row[content]" cols="50"></textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('附件名称')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-file_name" class="form-control" name="row[file_name]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('File')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
... ...
... ... @@ -13,12 +13,24 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('简介')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-desc" class="form-control" rows="5" name="row[desc]" cols="50">{$row.desc|htmlentities}</textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-content" class="form-control editor" rows="5" name="row[content]" cols="50">{$row.content|htmlentities}</textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('附件名称')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-file_name" class="form-control" name="row[file_name]" type="text" value="{$row.file_name}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('File')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
... ... @@ -38,7 +50,6 @@
{:build_radios('row[is_up]', ['0'=>'否', '1'=>'是'],$row.is_up)}
</div>
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
... ... @@ -46,4 +57,4 @@
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
</form>
\ No newline at end of file
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-image" class="form-control" size="50" name="row[image]" type="text">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-image" class="btn btn-danger plupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-image"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-image"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Phone1')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-phone1" class="form-control" name="row[phone1]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Phone2')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-phone2" class="form-control" name="row[phone2]" type="text">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-image" class="form-control" size="50" name="row[image]" type="text" value="{$row.image|htmlentities}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-image" class="btn btn-danger plupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-image"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-image"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Phone1')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-phone1" class="form-control" name="row[phone1]" type="text" value="{$row.phone1|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Phone2')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-phone2" class="form-control" name="row[phone2]" type="text" value="{$row.phone2|htmlentities}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<div class="panel panel-default panel-intro">
{:build_heading()}
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('kelist/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('kelist/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('kelist/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<!--<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('kelist/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>-->
<!--<div class="dropdown btn-group {:$auth->check('kelist/multi')?'':'hide'}">-->
<!--<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>-->
<!--<ul class="dropdown-menu text-left" role="menu">-->
<!--<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>-->
<!--<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>-->
<!--</ul>-->
<!--</div>-->
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('kelist/edit')}"
data-operate-del="{:$auth->check('kelist/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
... ... @@ -11,7 +11,7 @@
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('pan/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('pan/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('pan/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
<a href="/assets/import_moudle/判断题导入.xlsx" class="btn btn-danger {:$auth->check('pan/import')?'':'hide'}" title="{:__('导入模板')}"> {:__('导入模板')}</a>
<!--<div class="dropdown btn-group {:$auth->check('pan/multi')?'':'hide'}">-->
<!--<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>-->
<!--<ul class="dropdown-menu text-left" role="menu">-->
... ...
... ... @@ -13,12 +13,24 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('简介')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-desc" class="form-control" rows="5" name="row[desc]" cols="50"></textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-content" class="form-control editor" rows="5" name="row[content]" cols="50"></textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('附件名称')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-file_name" class="form-control" name="row[file_name]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('File')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
... ...
... ... @@ -13,12 +13,24 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('简介')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-desc" class="form-control" rows="5" name="row[desc]" cols="50">{$row.desc|htmlentities}</textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-content" class="form-control editor" rows="5" name="row[content]" cols="50">{$row.content|htmlentities}</textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('附件名称')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-file_name" class="form-control" name="row[file_name]" type="text" value="{$row.file_name}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('File')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Stopnum')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-stopnum" class="form-control" name="row[stopnum]" type="number">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Switch')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-switch" class="form-control" name="row[switch]" type="number">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Stopnum')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-stopnum" class="form-control" name="row[stopnum]" type="number" value="{$row.stopnum|htmlentities}">
</div>
</div>
<!--<div class="form-group">-->
<!--<label class="control-label col-xs-12 col-sm-2">{:__('Switch')}:</label>-->
<!--<div class="col-xs-12 col-sm-8">-->
<!--<input id="c-switch" class="form-control" name="row[switch]" type="number" value="{$row.switch|htmlentities}">-->
<!--</div>-->
<!--</div>-->
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<div class="panel panel-default panel-intro">
{:build_heading()}
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<!--<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('set/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>-->
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('set/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<!--<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('set/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>-->
<!--<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('set/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>-->
<!--<div class="dropdown btn-group {:$auth->check('set/multi')?'':'hide'}">-->
<!--<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>-->
<!--<ul class="dropdown-menu text-left" role="menu">-->
<!--<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>-->
<!--<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>-->
<!--</ul>-->
<!--</div>-->
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('set/edit')}"
data-operate-del="{:$auth->check('set/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('分类id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-type_id" data-source="type/index" class="form-control selectpage" name="row[type_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Examname')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-examname" class="form-control" name="row[examname]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('学业名称')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-workname" class="form-control" name="row[workname]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Class_hour')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-class_hour" class="form-control" name="row[class_hour]" type="number">
... ... @@ -26,7 +38,20 @@
<ul class="row list-inline plupload-preview" id="p-image"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('印章图片')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-yinimage" class="form-control" size="50" name="row[yinimage]" type="text">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-yinimage" class="btn btn-danger plupload" data-input-id="c-yinimage" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-yinimage"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-yinimage" class="btn btn-primary fachoose" data-input-id="c-yinimage" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-yinimage"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-yinimage"></ul>
</div>
</div>
<div class="form-group">
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('分类id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-type_id" data-source="type/index" class="form-control selectpage" name="row[type_id]" type="text" value="{$row.type_id}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Examname')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-examname" class="form-control" name="row[examname]" type="text" value="{$row.examname|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('学业名称')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-workname" class="form-control" name="row[workname]" type="text" value="{$row.workname|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Class_hour')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-class_hour" class="form-control" name="row[class_hour]" type="number" value="{$row.class_hour|htmlentities}">
... ... @@ -27,7 +39,20 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('印章图片')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-yinimage" class="form-control" size="50" name="row[yinimage]" type="text" value="{$row.yinimage|htmlentities}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-yinimage" class="btn btn-danger plupload" data-input-id="c-yinimage" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-yinimage"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-yinimage" class="btn btn-primary fachoose" data-input-id="c-yinimage" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-image"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-yinimage"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('及格分数')}:</label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -12,6 +12,12 @@
<input id="c-password" class="form-control" name="row[password]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('学号')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-studynum" class="form-control" name="row[studynum]" type="text">
</div>
</div>
<!--<div class="form-group">-->
<!--<label class="control-label col-xs-12 col-sm-2">{:__('Card')}:</label>-->
<!--<div class="col-xs-12 col-sm-8">-->
... ...
... ... @@ -12,6 +12,12 @@
<input id="c-password" class="form-control" name="row[password]" type="text" value="{$row.password|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('学号')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-studynum" class="form-control" name="row[studynum]" type="text" value="{$row.studynum|htmlentities}">
</div>
</div>
<!--<div class="form-group">-->
<!--<label class="control-label col-xs-12 col-sm-2">{:__('Card')}:</label>-->
<!--<div class="col-xs-12 col-sm-8">-->
... ...
... ... @@ -3,7 +3,7 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Third_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-third_id" data-rule="required" data-source="third/index" data-field="username" class="form-control selectpage" name="row[third_id]" type="text" value="">
<input id="c-third_id" data-rule="required" data-source="user/user/index" data-field="username" class="form-control selectpage" name="row[third_id]" type="text" value="">
</div>
</div>
<div class="form-group">
... ...
... ... @@ -3,7 +3,7 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Third_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-third_id" data-rule="required" data-source="third/index" data-field="username" class="form-control selectpage" name="row[third_id]" type="text" value="{$row.third_id|htmlentities}">
<input id="c-third_id" data-rule="required" data-source="user/user/index" data-field="username" class="form-control selectpage" name="row[third_id]" type="text" value="{$row.third_id|htmlentities}">
</div>
</div>
<div class="form-group">
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-name" class="form-control" name="row[name]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Pid')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-pid" data-source="type/index" data-params='{"custom[level]":["neq","3"]}' class="form-control selectpage" name="row[pid]" type="text" value="">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-name" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Pid')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-pid" data-source="type/index" data-params='{"custom[level]":["neq","3"]}' class="form-control selectpage" name="row[pid]" type="text" value="{$row.pid}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<div class="panel panel-default panel-intro">
{:build_heading()}
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('type/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('type/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('type/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<!--<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('type/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>-->
<!--<div class="dropdown btn-group {:$auth->check('type/multi')?'':'hide'}">-->
<!--<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>-->
<!--<ul class="dropdown-menu text-left" role="menu">-->
<!--<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>-->
<!--<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>-->
<!--</ul>-->
<!--</div>-->
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('type/edit')}"
data-operate-del="{:$auth->check('type/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('用户名')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-username" class="form-control" name="row[username]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('真实姓名')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-nickname" class="form-control" name="row[nickname]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('密码')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-password" class="form-control" name="row[password]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('性别')}:</label>
<div class="col-xs-12 col-sm-8">
{:build_radios('row[sex]', ['1'=>'男', '0'=>'女'])}
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('工作单位')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-work_address" class="form-control" name="row[work_address]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('身份证号')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-card" class="form-control" name="row[card]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('学号')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-studynum" class="form-control" name="row[studynum]" type="text">
</div>
</div>
<!--<div class="form-group">-->
<!--<label class="control-label col-xs-12 col-sm-2">{:__('Card')}:</label>-->
<!--<div class="col-xs-12 col-sm-8">-->
<!--<input id="c-card" class="form-control" name="row[card]" type="text">-->
<!--</div>-->
<!--</div>-->
<!--<div class="form-group">-->
<!--<label class="control-label col-xs-12 col-sm-2">{:__('Phone')}:</label>-->
<!--<div class="col-xs-12 col-sm-8">-->
<!--<input id="c-phone" class="form-control" name="row[phone]" type="text">-->
<!--</div>-->
<!--</div>-->
<!--<div class="form-group">-->
<!--<label class="control-label col-xs-12 col-sm-2">{:__('性别')}:</label>-->
<!--<div class="col-xs-12 col-sm-8">-->
<!--{:build_radios('row[sex]', ['1'=>'男', '0'=>'女'])}-->
<!--</div>-->
<!--</div>-->
<!--<div class="form-group">-->
<!--<label class="control-label col-xs-12 col-sm-2">{:__('Work_address')}:</label>-->
<!--<div class="col-xs-12 col-sm-8">-->
<!--<input id="c-work_address" class="form-control" name="row[work_address]" type="text">-->
<!--</div>-->
<!--</div>-->
<!--<div class="form-group">-->
<!--<label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label>-->
<!--<div class="col-xs-12 col-sm-8">-->
<!--<div class="input-group">-->
<!--<input id="c-image" class="form-control" size="50" name="row[image]" type="text">-->
<!--<div class="input-group-addon no-border no-padding">-->
<!--<span><button type="button" id="plupload-image" class="btn btn-danger plupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>-->
<!--<span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>-->
<!--</div>-->
<!--<span class="msg-box n-right" for="c-image"></span>-->
<!--</div>-->
<!--<ul class="row list-inline plupload-preview" id="p-image"></ul>-->
<!--</div>-->
<!--</div>-->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('有效期')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-expirationtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[expirationtime]" type="text" value="{:date('Y-m-d H:i:s')}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label for="c-group_id" class="control-label col-xs-12 col-sm-2">{:__('Group')}:</label>
<div class="col-xs-12 col-sm-4">
{$groupList}
</div>
</div>
<div class="form-group">
<label for="c-username" class="control-label col-xs-12 col-sm-2">{:__('Username')}:</label>
<div class="col-xs-12 col-sm-4">
<input id="c-username" data-rule="required" class="form-control" name="row[username]" type="text" value="{$row.username|htmlentities}">
</div>
</div>
<div class="form-group">
<label for="c-nickname" class="control-label col-xs-12 col-sm-2">{:__('Nickname')}:</label>
<div class="col-xs-12 col-sm-4">
<input id="c-nickname" data-rule="required" class="form-control" name="row[nickname]" type="text" value="{$row.nickname|htmlentities}">
</div>
</div>
<div class="form-group">
<label for="c-password" class="control-label col-xs-12 col-sm-2">{:__('Password')}:</label>
<div class="col-xs-12 col-sm-4">
<input id="c-password" data-rule="password" class="form-control" name="row[password]" type="text" value="" placeholder="{:__('Leave password blank if dont want to change')}" autocomplete="new-password" />
</div>
</div>
<div class="form-group">
<label for="c-email" class="control-label col-xs-12 col-sm-2">{:__('Email')}:</label>
<div class="col-xs-12 col-sm-4">
<input id="c-email" data-rule="" class="form-control" name="row[email]" type="text" value="{$row.email|htmlentities}">
</div>
</div>
<div class="form-group">
<label for="c-mobile" class="control-label col-xs-12 col-sm-2">{:__('Mobile')}:</label>
<div class="col-xs-12 col-sm-4">
<input id="c-mobile" data-rule="" class="form-control" name="row[mobile]" type="text" value="{$row.mobile|htmlentities}">
</div>
</div>
<div class="form-group">
<label for="c-avatar" class="control-label col-xs-12 col-sm-2">{:__('Avatar')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Username')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-avatar" data-rule="" class="form-control" size="50" name="row[avatar]" type="text" value="{$row.avatar}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-avatar" class="btn btn-danger plupload" data-input-id="c-avatar" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-avatar"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-avatar" class="btn btn-primary fachoose" data-input-id="c-avatar" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-avatar"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-avatar"></ul>
<input id="c-username" class="form-control" name="row[username]" type="text" value="{$row.username|htmlentities}">
</div>
</div>
<div class="form-group">
<label for="c-level" class="control-label col-xs-12 col-sm-2">{:__('Level')}:</label>
<div class="col-xs-12 col-sm-4">
<input id="c-level" data-rule="required" class="form-control" name="row[level]" type="number" value="{$row.level}">
</div>
</div>
<div class="form-group">
<label for="c-gender" class="control-label col-xs-12 col-sm-2">{:__('Gender')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('密码')}:</label>
<div class="col-xs-12 col-sm-8">
{:build_radios('row[gender]', ['1'=>__('Male'), '0'=>__('Female')], $row['gender'])}
</div>
</div>
<div class="form-group">
<label for="c-birthday" class="control-label col-xs-12 col-sm-2">{:__('Birthday')}:</label>
<div class="col-xs-12 col-sm-4">
<input id="c-birthday" data-rule="" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[birthday]" type="text" value="{$row.birthday}">
<input id="c-password" class="form-control" name="row[password]" type="text" value="{$row.password|htmlentities}">
</div>
</div>
<div class="form-group">
<label for="c-bio" class="control-label col-xs-12 col-sm-2">{:__('Bio')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('学号')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-bio" data-rule="" class="form-control" name="row[bio]" type="text" value="{$row.bio|htmlentities}">
</div>
</div>
<div class="form-group">
<label for="c-money" class="control-label col-xs-12 col-sm-2">{:__('Money')}:</label>
<div class="col-xs-12 col-sm-4">
<input id="c-money" data-rule="required" class="form-control" name="row[money]" type="number" value="{$row.money}">
</div>
</div>
<div class="form-group">
<label for="c-score" class="control-label col-xs-12 col-sm-2">{:__('Score')}:</label>
<div class="col-xs-12 col-sm-4">
<input id="c-score" data-rule="required" class="form-control" name="row[score]" type="number" value="{$row.score}">
</div>
</div>
<div class="form-group">
<label for="c-successions" class="control-label col-xs-12 col-sm-2">{:__('Successions')}:</label>
<div class="col-xs-12 col-sm-4">
<input id="c-successions" data-rule="required" class="form-control" name="row[successions]" type="number" value="{$row.successions}">
</div>
</div>
<div class="form-group">
<label for="c-maxsuccessions" class="control-label col-xs-12 col-sm-2">{:__('Maxsuccessions')}:</label>
<div class="col-xs-12 col-sm-4">
<input id="c-maxsuccessions" data-rule="required" class="form-control" name="row[maxsuccessions]" type="number" value="{$row.maxsuccessions}">
</div>
</div>
<div class="form-group">
<label for="c-prevtime" class="control-label col-xs-12 col-sm-2">{:__('Prevtime')}:</label>
<div class="col-xs-12 col-sm-4">
<input id="c-prevtime" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[prevtime]" type="text" value="{$row.prevtime|datetime}">
<input id="c-studynum" class="form-control" name="row[studynum]" type="text" value="{$row.studynum|htmlentities}">
</div>
</div>
<div class="form-group">
<label for="c-logintime" class="control-label col-xs-12 col-sm-2">{:__('Logintime')}:</label>
<div class="col-xs-12 col-sm-4">
<input id="c-logintime" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[logintime]" type="text" value="{$row.logintime|datetime}">
</div>
</div>
<div class="form-group">
<label for="c-loginip" class="control-label col-xs-12 col-sm-2">{:__('Loginip')}:</label>
<div class="col-xs-12 col-sm-4">
<input id="c-loginip" data-rule="required" class="form-control" name="row[loginip]" type="text" value="{$row.loginip}">
<label class="control-label col-xs-12 col-sm-2">{:__('性别')}:</label>
<div class="col-xs-12 col-sm-8">
{:build_radios('row[sex]', ['1'=>'男', '0'=>'女'],$row.sex)}
</div>
</div>
<div class="form-group">
<label for="c-loginfailure" class="control-label col-xs-12 col-sm-2">{:__('Loginfailure')}:</label>
<div class="col-xs-12 col-sm-4">
<input id="c-loginfailure" data-rule="required" class="form-control" name="row[loginfailure]" type="number" value="{$row.loginfailure}">
<label class="control-label col-xs-12 col-sm-2">{:__('工作单位')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-work_address" class="form-control" name="row[work_address]" type="text" value="{$row.work_address}">
</div>
</div>
<div class="form-group">
<label for="c-joinip" class="control-label col-xs-12 col-sm-2">{:__('Joinip')}:</label>
<div class="col-xs-12 col-sm-4">
<input id="c-joinip" data-rule="required" class="form-control" name="row[joinip]" type="text" value="{$row.joinip}">
<label class="control-label col-xs-12 col-sm-2">{:__('身份证号')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-card" class="form-control" name="row[card]" type="text" value="{$row.card}">
</div>
</div>
<!--<div class="form-group">-->
<!--<label class="control-label col-xs-12 col-sm-2">{:__('有效期')}:</label>-->
<!--<div class="col-xs-12 col-sm-8">-->
<!--<input id="c-expirationtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[expirationtime]" type="text" value="{:$row.expirationtime?datetime($row.expirationtime):''}">-->
<!--</div>-->
<!--</div>-->
<div class="form-group">
<label for="c-jointime" class="control-label col-xs-12 col-sm-2">{:__('Jointime')}:</label>
<div class="col-xs-12 col-sm-4">
<input id="c-jointime" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[jointime]" type="text" value="{$row.jointime|datetime}">
<label class="control-label col-xs-12 col-sm-2">{:__('有效期')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-expirationtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[expirationtime]" type="text" value="{:$row.expirationtime?datetime($row.expirationtime):''}">
</div>
</div>
<div class="form-group">
<label for="content" class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('头像')}:</label>
<div class="col-xs-12 col-sm-8">
{:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')], $row['status'])}
<div class="input-group">
<input id="c-image" class="form-control" size="50" name="row[image]" type="text" value="{$row.image|htmlentities}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-image" class="btn btn-danger plupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-image"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-image"></ul>
</div>
</div>
<div class="form-group layer-footer">
... ...
... ... @@ -6,14 +6,14 @@
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
{:build_toolbar('refresh,edit,del')}
<div class="dropdown btn-group {:$auth->check('user/user/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
</ul>
</div>
{:build_toolbar('refresh,add,edit,del')}
<!--<div class="dropdown btn-group {:$auth->check('user/user/multi')?'':'hide'}">-->
<!--<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>-->
<!--<ul class="dropdown-menu text-left" role="menu">-->
<!--<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>-->
<!--<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>-->
<!--</ul>-->
<!--</div>-->
</div>
<table id="table" class="table table-striped table-bordered table-hover"
data-operate-edit="{:$auth->check('user/user/edit')}"
... ...
... ... @@ -2,8 +2,10 @@
namespace app\api\controller;
use addons\qiniu\library\Auth;
use app\common\controller\Api;
use app\common\model\Area;
use app\common\model\Attachment;
use app\common\model\Version;
use fast\Random;
use think\Config;
... ... @@ -13,7 +15,7 @@ use think\Config;
*/
class Common extends Api
{
protected $noNeedLogin = ['init','upload'];
protected $noNeedLogin = ['init','upload','upload_base64','base64_image_content'];
protected $noNeedRight = '*';
/**
... ... @@ -148,7 +150,9 @@ class Common extends Api
$this->error("上传失败");
}
$url = '/' . $object;
$qiniu = get_addon_config('qiniu')['cdnurl'];
$url['yuan'] = '/' . $object;
$url['dai'] = $qiniu.'/' . $object;
//上传成功后将存储变更为qiniu
$attachment->storage = 'qiniu';
... ... @@ -160,4 +164,128 @@ class Common extends Api
}
return;
}
/**
* base64上传文件
*
* @ApiTitle (base64上传文件)
* @ApiSummary (base64上传文件)
* @ApiMethod (POST)
* @ApiRoute (/api/common/upload_base64)
* @ApiParams (name="base64_img", type="string", required=true, description="图片base64数据")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
"data": {
"url": 当前页数,
"priview_url": 总页数
}
})
*
*/
public function upload_base64() {
if($this->request->isPost()) {
$param = $this->request->param();
$validate = new \think\Validate([
'base64_img' => 'require',
]);
$validate->message([
'base64_img.require' => '缺少图片base64数据!',
]);
if (!$validate->check($param)) {
$this->error($validate->getError());
}
$path = '/uploads/lesson_app';
$image = $this->base64_image_content($param['base64_img'],$path);
if(!$image) {
$this->error('上传失败');
}
$upload = Config::get('upload');
$config = get_addon_config('qiniu');
$filePath = '.'.$path.'/'.$image;
$suffix = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
$suffix = $suffix && preg_match("/^[a-zA-Z0-9]+$/", $suffix) ? $suffix : 'file';
$replaceArr = [
'{year}' => date("Y"),
'{mon}' => date("m"),
'{day}' => date("d"),
'{hour}' => date("H"),
'{min}' => date("i"),
'{sec}' => date("s"),
'{random}' => Random::alnum(16),
'{random32}' => Random::alnum(32),
'{filename}' => $suffix ? substr(pathinfo($filePath)['basename'], 0, strripos(pathinfo($filePath)['basename'], '.')) : pathinfo($filePath)['basename'],
'{suffix}' => $suffix,
'{.suffix}' => $suffix ? '.' . $suffix : '',
'{filemd5}' => md5_file(realpath($filePath)),
];
$savekey = $upload['savekey'];
$savekey = str_replace(array_keys($replaceArr), array_values($replaceArr), $savekey);
$fileName = substr($savekey, strripos($savekey, '/') + 1);
$policy = array(
'saveKey' => ltrim($savekey, '/'),
);
$auth = new Auth($config['app_key'], $config['secret_key']);
$token = $auth->uploadToken($config['bucket'], null, $config['expire'], $policy);
$multipart = [
['name' => 'token', 'contents' => $token],
[
'name' => 'file',
'contents' => fopen(realpath($filePath), 'r'),
'filename' => $fileName,
]
];
try {
$client = new \GuzzleHttp\Client();
$res = $client->request('POST', $config['uploadurl'], [
'multipart' => $multipart
]);
$code = $res->getStatusCode();
//成功不做任何操作
} catch (\GuzzleHttp\Exception\ClientException $e) {
// $attachment->delete();
unlink($filePath);
$this->error("上传失败");
}
unlink($filePath);
$return = [
'url' => $savekey,
'priview_url' => cdnurl($savekey,true)
];
$this->success('上传成功',$return);
}
}
/**
* [将Base64图片转换为本地图片并保存]
* @E-mial wuliqiang_aa@163.com
* @TIME 2017-04-07
* @WEB http://blog.iinu.com.cn
* @param [Base64] $base64_image_content [要保存的Base64]
* @param [目录] $path [要保存的路径]
*/
private function base64_image_content($base64_image_content,$path){
//匹配出图片的格式
if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64_image_content, $result)){
$type = $result[2];
$file_path = date('Ymd',time())."/";
$new_file = '.'.$path."/".$file_path;
if(!file_exists($new_file)){
//检查是否有该文件夹,如果没有就创建,并给予最高权限
mkdir($new_file, 0777,true);
}
$new_file = $new_file.time().".{$type}";
if (file_put_contents($new_file, base64_decode(str_replace($result[1], '', $base64_image_content)))){
return $file_path.time().".{$type}";
}else{
return false;
}
}else{
return false;
}
}
}
... ...
<?php
namespace app\api\controller;
use app\common\controller\Api;
/**
* 示例接口
*/
class Demo extends Api
{
//如果$noNeedLogin为空表示所有接口都需要登录才能请求
//如果$noNeedRight为空表示所有接口都需要验证权限才能请求
//如果接口已经设置无需登录,那也就无需鉴权了
//
// 无需登录的接口,*表示全部
protected $noNeedLogin = ['test', 'test1'];
// 无需鉴权的接口,*表示全部
protected $noNeedRight = ['test2'];
/**
* 测试方法
*
* @ApiTitle (测试名称)
* @ApiSummary (测试描述信息)
* @ApiMethod (POST)
* @ApiRoute (/api/demo/test/id/{id}/name/{name})
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="integer", required=true, description="会员ID")
* @ApiParams (name="name", type="string", required=true, description="用户名")
* @ApiParams (name="data", type="object", sample="{'user_id':'int','user_name':'string','profile':{'email':'string','age':'integer'}}", description="扩展数据")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", sample="{'user_id':'int','user_name':'string','profile':{'email':'string','age':'integer'}}", description="扩展数据返回")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
})
*/
public function test()
{
$this->success('返回成功', $this->request->param());
}
/**
* 无需登录的接口
*
*/
public function test1()
{
$this->success('返回成功', ['action' => 'test1']);
}
/**
* 需要登录的接口
*
*/
public function test2()
{
$this->success('返回成功', ['action' => 'test2']);
}
/**
* 需要登录且需要验证有相应组的权限
*
*/
public function test3()
{
$this->success('返回成功', ['action' => 'test3']);
}
}
<?php
namespace app\api\controller;
use app\common\controller\Api;
use app\common\library\Ems as Emslib;
use app\common\model\User;
/**
* 邮箱验证码接口
*/
class Ems extends Api
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
public function _initialize()
{
parent::_initialize();
\think\Hook::add('ems_send', function ($params) {
$obj = \app\common\library\Email::instance();
$result = $obj
->to($params->email)
->subject('验证码')
->message("你的验证码是:" . $params->code)
->send();
return $result;
});
}
/**
* 发送验证码
*
* @param string $email 邮箱
* @param string $event 事件名称
*/
public function send()
{
$email = $this->request->request("email");
$event = $this->request->request("event");
$event = $event ? $event : 'register';
$last = Emslib::get($email, $event);
if ($last && time() - $last['createtime'] < 60) {
$this->error(__('发送频繁'));
}
if ($event) {
$userinfo = User::getByEmail($email);
if ($event == 'register' && $userinfo) {
//已被注册
$this->error(__('已被注册'));
} elseif (in_array($event, ['changeemail']) && $userinfo) {
//被占用
$this->error(__('已被占用'));
} elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
//未注册
$this->error(__('未注册'));
}
}
$ret = Emslib::send($email, null, $event);
if ($ret) {
$this->success(__('发送成功'));
} else {
$this->error(__('发送失败'));
}
}
/**
* 检测验证码
*
* @param string $email 邮箱
* @param string $event 事件名称
* @param string $captcha 验证码
*/
public function check()
{
$email = $this->request->request("email");
$event = $this->request->request("event");
$event = $event ? $event : 'register';
$captcha = $this->request->request("captcha");
if ($event) {
$userinfo = User::getByEmail($email);
if ($event == 'register' && $userinfo) {
//已被注册
$this->error(__('已被注册'));
} elseif (in_array($event, ['changeemail']) && $userinfo) {
//被占用
$this->error(__('已被占用'));
} elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
//未注册
$this->error(__('未注册'));
}
}
$ret = Emslib::check($email, $captcha, $event);
if ($ret) {
$this->success(__('成功'));
} else {
$this->error(__('验证码不正确'));
}
}
}
... ... @@ -11,7 +11,7 @@ use think\Session;
*/
class Exam extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedLogin = ['index','examtext'];
protected $noNeedRight = ['*'];
/**
... ... @@ -48,6 +48,7 @@ class Exam extends Api
->where('id',$study_id)
->field('pass_mark,dan_num,dan_score,duo_num,duo_score,pan_num,pan_score,examdurationtime')
->find();
$data['zong'] = $data['dan_num'] + $data['duo_num'] + $data['pan_num'];
$this->success('success',$data);
}
... ... @@ -57,6 +58,7 @@ class Exam extends Api
* @ApiMethod (POST)
* @ApiRoute (/api/exam/question)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="study_id", type="int", required=true, description="学习系统id")
*
* @ApiReturn({
... ... @@ -66,6 +68,7 @@ class Exam extends Api
"data": {
"exam_num"://第几次考试
"third_exam_id"://考试记录id
"dan": [
{
"id": //单选题id,
... ... @@ -118,11 +121,7 @@ class Exam extends Api
*/
public function question()
{
$user_id = Session::get('user_id');
if(empty($user_id)){
$this->error('请先登录');
}
$user_id = $this->auth->id;
$qiniu = get_addon_config('qiniu')['cdnurl'];
$study_id = $this->request->param('study_id');
if(empty($study_id)){
... ... @@ -141,7 +140,8 @@ class Exam extends Api
$exam['exam_num'] = 1;
$exam['createtime'] = time();
$exam['updatetime'] = time();
Db::name('third_exam')->insertGetId($exam);
$info['third_exam_id'] = Db::name('third_exam')->insertGetId($exam);
}else{
if($third_exam['exam_num'] == 3){
$this->error('您已经考过三次了');
... ... @@ -151,7 +151,7 @@ class Exam extends Api
$exam['exam_num'] = $third_exam['exam_num'] + 1;
$exam['createtime'] = time();
$exam['updatetime'] = time();
Db::name('third_exam')->insertGetId($exam);
$info['third_exam_id'] =Db::name('third_exam')->insertGetId($exam);
}
//该学习科目的题型信息 单选题数量 多选题数量 判断题数量
... ... @@ -257,6 +257,44 @@ class Exam extends Api
}
/**
* @ApiTitle (考试次数)
* @ApiSummary (考试次数)
* @ApiMethod (POST)
* @ApiRoute (/api/exam/examnum)
*
* @ApiHeaders (name="token", type=string, required=true, description="请求的Token")
* @ApiParams (name="study_id", type="int", required=true, description="学习系统id")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
}
})
*/
public function examnum()
{
$user_id = $this->auth->id;
$study_id = $this->request->param('study_id');
if(empty($study_id)){
$this->error('缺少必要参数');
}
//查看用户该科目是否已经考过3次了
$third_exam = Db::name('third_exam')
->where('user_id',$user_id)
->where('study_id',$study_id)
->order('exam_num desc')
->find();
if($third_exam['exam_num'] == 3){
$this->error('您已经考过三次了');
// $this->success('success');
}else{
$this->success('success');
}
}
/**
* @ApiTitle (考试须知)
* @ApiSummary (考试须知)
* @ApiMethod (POST)
... ... @@ -283,6 +321,7 @@ class Exam extends Api
* @ApiMethod (POST)
* @ApiRoute (/api/exam/exam_record)
*
* @ApiHeaders (name="token", type=string, required=true, description="请求的Token")
* @ApiParams (name="study_id", type="int", required=true, description="学习系统id")
*
* @ApiReturn({
... ... @@ -305,11 +344,7 @@ class Exam extends Api
*/
public function exam_record()
{
$user_id = Session::get('user_id');
if(empty($user_id)){
$this->error('请先登录');
}
$user_id = $this->auth->id;
$study_id = $this->request->param('study_id');
if(empty($study_id)){
$this->error('缺少必要参数');
... ... @@ -333,7 +368,7 @@ class Exam extends Api
}else{
$v['is_pass'] = 2;
}
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
$v['createtime'] = date('Y-m-d',$v['createtime']);
}
$this->success('success',$data);
... ... @@ -346,6 +381,7 @@ class Exam extends Api
* @ApiMethod (POST)
* @ApiRoute (/api/exam/exam_answer)
*
* @ApiHeaders (name="token", type=string, required=true, description="请求的Token")
* @ApiParams (name="study_id", type="int", required=true, description="学习系统id")
* @ApiParams (name="question_id", type="int", required=true, description="题目id")
* @ApiParams (name="type", type="int", required=true, description="类型1单选2多选3判断")
... ... @@ -364,10 +400,7 @@ class Exam extends Api
*/
public function exam_answer()
{
$user_id = Session::get('user_id');
if(empty($user_id)){
$this->error('请先登录');
}
$user_id = $this->auth->id;
$study_id = $this->request->param('study_id');
$question_id = $this->request->param('question_id');
$type = $this->request->param('type');
... ... @@ -420,7 +453,7 @@ class Exam extends Api
->where('study_id',$study_id)
->where('study_exam_num',$study_exam_num)
->field('sum(score) as num')
->select();
->find();
Db::name('third_exam')->where('user_id',$user_id)->where('study_id',$study_id)->where('exam_num',$study_exam_num)->update(['score'=>$score['num']]);
}
}elseif ($type == 2){
... ... @@ -463,7 +496,7 @@ class Exam extends Api
->where('study_id',$study_id)
->where('study_exam_num',$study_exam_num)
->field('sum(score) as num')
->select();
->find();
Db::name('third_exam')->where('user_id',$user_id)->where('study_id',$study_id)->where('exam_num',$study_exam_num)->update(['score'=>$score['num']]);
}
}elseif ($type == 3){
... ... @@ -494,12 +527,48 @@ class Exam extends Api
->where('study_id',$study_id)
->where('study_exam_num',$study_exam_num)
->field('sum(score) as num')
->select();
->find();
Db::name('third_exam')->where('user_id',$user_id)->where('study_id',$study_id)->where('exam_num',$study_exam_num)->update(['score'=>$score['num']]);
}
}
}
/**
* @ApiTitle (交卷)
* @ApiSummary (交卷)
* @ApiMethod (POST)
* @ApiRoute (/api/exam/tijiao)
*
* @ApiHeaders (name="token", type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="inter", required=true, description="考试记录id")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"num"://考试机会
"score"://分数
}
]
}
})
*/
public function tijiao()
{
$id = $this->request->param('id');
if(empty($id)){
$this->error('缺少必要参数');
}
$data = Db::name('third_exam')
->where('id',$id)
->find();
$info['num'] = 3 - $data['exam_num'];
$info['score'] = $data['score'];
$this->success('success',$info);
}
... ...
... ... @@ -10,7 +10,7 @@ use think\Db;
*/
class Index extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedLogin = ['index','banner','about','kefu','teacher','teacher_detail','center','zan'];
protected $noNeedRight = ['*'];
/**
... ... @@ -158,6 +158,7 @@ class Index extends Api
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data = Db::name('teacher')
->field('updatetime',true)
->order('createtime desc')
->select();
foreach ($data as &$v){
$v['image'] = $qiniu.$v['image'];
... ... @@ -240,4 +241,28 @@ class Index extends Api
}
$this->success('success',$data);
}
/**
* @ApiTitle (设置自动暂停)
* @ApiSummary (设置自动暂停)
* @ApiMethod (POST)
* @ApiRoute (/api/index/zan)
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id"://ID
"stopnum"://暂停间隔
"switch"://是否开启1开启0关闭
}
})
*/
public function zan()
{
$data = Db::name('set')->where('id',1)->field('stopnum,switch')->find();
$data['stopnum'] = $data['stopnum'] * 60;
$this->success('success',$data);
}
}
... ...
... ... @@ -4,6 +4,7 @@ namespace app\api\controller;
use app\common\controller\Api;
use think\Cookie;
use app\common\library\Auth;
use think\Db;
use fast\Random;
use think\Session;
... ... @@ -15,7 +16,7 @@ use think\Validate;
*/
class Lists extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedLogin = ['type_list','ke_list','index','policy','index_info','policy_info','video_list','video_detail','study','password_login','find_pwd','getcode','verify'];
protected $noNeedRight = ['*'];
/**
... ... @@ -26,35 +27,166 @@ class Lists extends Api
*
* @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
* @ApiParams (name="pageNum", type="inter", required=false, description="每页显示数据个数(默认10)")
* @ApiParams (name="keyword", type="string", required=false, description="搜索关键字")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id"://ID
"title"://标题
"is_up"://是否上架0否1是
"createtime"://创建时间
"total_num"://总条数
"info":[
"id"://ID
"title"://标题
"is_up"://是否上架0否1是
"file_name"://附件名称
"createtime"://创建时间
"desc"://简介
]
}
})
*/
public function index()
{
$keyword = $this->request->param('keyword');
if(empty($keyword)){
$where = true;
}else{
$where['title'] = ['like',"%$keyword%"];
}
$page = $this->request->param('page', 1, 'intval');
$pageNum = $this->request->param('pageNum', 10, 'intval');
$data = Db::name('information')
->field('id,title,is_up,createtime')
$data['total_num'] = Db::name('information')
->where($where)
->count();
$data['info'] = Db::name('information')
->field('id,title,is_up,desc,createtime')
->where($where)
->order('is_up desc,createtime desc')
->page($page,$pageNum)
->select();
foreach ($data as &$v){
foreach ($data['info'] as &$v){
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
}
$this->success('success',$data);
}
/**
* @ApiTitle (搜索)
* @ApiSummary (搜索)
* @ApiMethod (POST)
* @ApiRoute (/api/lists/sou)
*
* @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
* @ApiParams (name="pageNum", type="inter", required=false, description="每页显示数据个数(默认10)")
* @ApiParams (name="keyword", type="string", required=false, description="搜索关键字")
* @ApiParams (name="type", type="inter", required=false, description="类型1通知公告2优选课程3培训课程")
* @ApiParams (name="id", type="inter", required=false, description="学习系统id")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"total_num"://总条数
"info":[
]
}
})
*/
public function sou()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$user_id = $this->auth->id;
$page = $this->request->param('page', 1, 'intval');
$pageNum = $this->request->param('pageNum', 10, 'intval');
$type = $this->request->param('type');
if(empty($type)){
$this->error('缺少必要参数');
}
$keyword = $this->request->param('keyword');
if(empty($keyword)){
$this->error('请输入关键字');
}
if($type == 1){
$data['total_num'] = Db::name('information')
->where('title','like',"%$keyword%")
->count();
$data['info'] = Db::name('information')
->field('id,title,is_up,desc,createtime')
->where('title','like',"%$keyword%")
->order('is_up desc,createtime desc')
->page($page,$pageNum)
->select();
foreach ($data['info'] as &$v){
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
}
$this->success('success',$data);
}elseif ($type == 2){
$data['total_num'] = Db::name('optimization')
->where('title','like',"%$keyword%")
->count();
$data['info'] = Db::name('optimization')
->where('title','like',"%$keyword%")
->order('createtime desc')
->page($page,$pageNum)
->select();
foreach ($data['info'] as &$v){
// 获取视频时长
$video_avinfo = json_decode(file_get_contents(cdnurl($v['video_file'], true) . '?avinfo'), true); // 获取视频元信息
$duration = ceil($video_avinfo['format']['duration']);
$v['duration'] = gmdate('H:i:s',$duration);
$v['image'] = $qiniu.$v['image'];
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
}
$this->success('success',$data);
}elseif ($type == 3){
$id = $this->request->param('id');
if(empty($id)){
$this->error('学习系统id不能为空');
}
$data['total_num'] = Db::name('classes')
->where('name','like',"%$keyword%")
->count();
$data['info'] = Db::name('classes')
->field('createtime,updatetime',true)
->where('name','like',"%$keyword%")
->page($page,$pageNum)
->order('id desc')
->select();
foreach ($data['info'] as &$v){
$v['video_file'] = $qiniu.$v['video_file'];
$video_info = json_decode(file_get_contents($v['video_file'] . '?avinfo'), true);
$v['video_image'] = $this->get_video_first_image( $v['video_file'], $video_info);
}
$this->success('success',$data);
}else{
$this->error('类型错误');
}
}
public function get_video_first_image($video_url,$video_info){
if(empty($video_info['streams'][0]['width'])) {
$width = $video_info['streams'][1]['width'];
$height = $video_info['streams'][1]['height'];
} else {
$width = $video_info['streams'][0]['width'];
$height = $video_info['streams'][0]['height'];
}
return $video_url.'?vframe/jpg/offset/1/w/'.$width.'/h/'.$height;
}
/**
* @ApiTitle (政策动态列表)
* @ApiSummary (政策动态列表)
* @ApiMethod (POST)
... ... @@ -68,10 +200,14 @@ class Lists extends Api
"msg": "成功",
"time": "1571492001",
"data": {
"total_num"://总条数
"info":[
"id"://ID
"file_name"://附件名称
"title"://标题
"is_up"://是否上架0否1是
"createtime"://创建时间
]
}
})
*/
... ... @@ -79,12 +215,14 @@ class Lists extends Api
{
$page = $this->request->param('page', 1, 'intval');
$pageNum = $this->request->param('pageNum', 10, 'intval');
$data = Db::name('policy')
->field('id,title,is_up,createtime')
$data['total_num'] = Db::name('policy')
->count();
$data['info'] = Db::name('policy')
->field('id,title,is_up,desc,createtime')
->order('is_up desc,createtime desc')
->page($page,$pageNum)
->select();
foreach ($data as &$v){
foreach ($data['info'] as &$v){
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
}
$this->success('success',$data);
... ... @@ -107,6 +245,7 @@ class Lists extends Api
"title"://标题
"from"://转载于
"content"://内容详情
"file_name"://附件名称
"file"://附件
"is_up"://是否上架0否1是
"createtime"://创建时间
... ... @@ -124,7 +263,19 @@ class Lists extends Api
->where('id',$id)
->field('updatetime',true)
->find();
$data['file'] = $qiniu.$data['file'];
if(!empty($data['file'])){
$base_url = $data['file'];
$qiniu_url = $qiniu.$data['file'];
$a = file_get_contents($qiniu_url);
$path = './uploads/'.explode('/',$base_url)[2].'/';
if(!file_exists($path)) {
mkdir($path,0777,true);
}
file_put_contents('.'.$base_url,$a);
$data['file'] = request()->domain().$base_url;
}else{
$data['file'] = '';
}
$data['createtime'] = date('Y-m-d H:i:s',$data['createtime']);
$this->success('success',$data);
}
... ... @@ -146,6 +297,7 @@ class Lists extends Api
"title"://标题
"from"://转载于
"content"://内容详情
"file_name"://附件名称
"file"://附件
"is_up"://是否上架0否1是
"createtime"://创建时间
... ... @@ -163,7 +315,19 @@ class Lists extends Api
->where('id',$id)
->field('updatetime',true)
->find();
$data['file'] = $qiniu.$data['file'];
if(!empty($data['file'])){
$base_url = $data['file'];
$qiniu_url = $qiniu.$data['file'];
$a = file_get_contents($qiniu_url);
$path = './uploads/'.explode('/',$base_url)[2].'/';
if(!file_exists($path)) {
mkdir($path,0777,true);
}
file_put_contents('.'.$base_url,$a);
$data['file'] = request()->domain().$base_url;
}else{
$data['file'] = '';
}
$data['createtime'] = date('Y-m-d H:i:s',$data['createtime']);
$this->success('success',$data);
}
... ... @@ -174,35 +338,43 @@ class Lists extends Api
* @ApiMethod (POST)
* @ApiRoute (/api/lists/video_list)
*
* @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
* @ApiParams (name="pageNum", type="inter", required=false, description="每页显示数据个数(默认10)")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id"://ID
"title"://标题
"desc"://简介
"content"://内容详情
"image"://图片
"createtime"://创建时间
"total_num"://总条数
"info":[
"id"://ID
"title"://标题
"desc"://简介
"content"://内容详情
"image"://图片
"createtime"://创建时间
]
}
})
*/
public function video_list()
{
$page = $this->request->param('page', 1, 'intval');
$pageNum = $this->request->param('pageNum', 10, 'intval');
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data = Db::name('optimization')
$data['total_num'] = Db::name('optimization')
->count();
$data['info'] = Db::name('optimization')
->field('id,title,image,desc,createtime,video_file')
->order('createtime desc')
->page($page,$pageNum)
->select();
foreach ($data as &$v){
foreach ($data['info'] as &$v){
// 获取视频时长
$video_avinfo = json_decode(file_get_contents(cdnurl($v['video_file'], true) . '?avinfo'), true); // 获取视频元信息
$duration = ceil($video_avinfo['format']['duration']);
$v['duration'] = gmdate('H:i:s',$duration);
$v['image'] = $qiniu.$v['image'];
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
}
... ... @@ -269,12 +441,16 @@ class Lists extends Api
"msg": "成功",
"time": "1571492001",
"data": {
"id"://ID
"examname"://考试名称
"class_hour"://所需课时
"finish_hour"://完成课时
"image"://图片
"expirationtime"://截止日期
"total_num"://总条数
"info":[
"id"://ID
"examname"://考试名称
"class_hour"://所需课时
"finish_hour"://完成课时
"image"://图片
"expirationtime"://截止日期
]
}
})
*/
... ... @@ -285,13 +461,16 @@ class Lists extends Api
$qiniu = get_addon_config('qiniu')['cdnurl'];
$user_id = Session::get('user_id');
$where['expirationtime'] = ['>',time()];
$data = Db::name('study')
$data['total_num'] = Db::name('study')
->where($where)
->count();
$data['info'] = Db::name('study')
->field('updatetime,createtime',true)
->where($where)
->order('id desc')
->page($page,$pageNum)
->select();
foreach ($data as &$v){
foreach ($data['info'] as &$v){
if(empty($user_id)){
$v['finish_hour'] = 0;
}else{
... ... @@ -308,6 +487,7 @@ class Lists extends Api
}else{
$v['finish_hour'] = $finish_hour['finsh_hour'];
}
}
$v['image'] = $qiniu.$v['image'];
$v['expirationtime'] = date('Y-m-d H:i:s',$v['expirationtime']);
... ... @@ -321,6 +501,7 @@ class Lists extends Api
* @ApiMethod (POST)
* @ApiRoute (/api/lists/study_detail)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="int", required=true, description="学习系统id")
*
* @ApiReturn({
... ... @@ -333,15 +514,11 @@ class Lists extends Api
*/
public function study_detail()
{
$user_id = $this->auth->id;
$id = $this->request->param('id');
if(empty($id)){
$this->error('缺少必要参数');
}
$user_id = Session::get('user_id');
if(empty($user_id)){
$this->error('请先登录');
}
$third_study = Db::name('third_study')->where('third_id',$user_id)->where('study_id',$id)->find();
if(empty($third_study)){
$this->error('您没有该场考试的权限');
... ... @@ -360,6 +537,7 @@ class Lists extends Api
*
* @ApiParams (name="username", type="string", required=true, description="用户名")
* @ApiParams (name="password", type="string", required=true, description="密码")
* @ApiParams (name="type", type="inter", required=false, description="是否记住账号密码 为空或者1否2是")
*
* @ApiReturn({
"code": 1,
... ... @@ -371,20 +549,23 @@ class Lists extends Api
})
*/
public function password_login(){
$type = $this->request->param('type');
$qiniu = get_addon_config('qiniu')['cdnurl'];
$username = $this->request->param('username');
$password = $this->request->param('password');
if(empty($username) || empty($password)){
$this->error('缺少必要参数');
}
$result = Db::name('third')->where('username',$username)->find();
$result = Db::name('user')->where('username',$username)->find();
if(empty($result)){
$this->error('账号错误');
}
if($result['password'] != $password){
$this->error('密码错误');
}
$user = Db::name('third')->where(['id'=>$result['id']])->find();
$user = Db::name('user')->where(['id'=>$result['id']])->find();
if($user['expirationtime'] < time()){
$this->error('抱歉,有效期已过');
}
... ... @@ -396,8 +577,16 @@ class Lists extends Api
if(empty($user['nickname'])){
$user['nickname'] = '';
}
Session::set('user_id',$user['id']);
$this->success('SUCCESS',$user);
$auth = Auth::instance();
$this->auth->direct($user['id']);
$userInfo = $auth->getUserinfo();
$userInfo['image'] = $user['image'];
unset($userInfo['avatar']);
unset($userInfo['score']);
unset($userInfo['mobile']);
$this->success('SUCCESS',$userInfo);
}
/**
... ... @@ -434,7 +623,7 @@ class Lists extends Api
$this->error('两次密码不一致,请重新输入');
}
$result1 = Db::name('third')->where('phone',$phone)->find();
$result1 = Db::name('user')->where('phone',$phone)->find();
if(empty($result1)){
$this->error('该手机号暂无绑定账号');
}
... ... @@ -444,7 +633,8 @@ class Lists extends Api
if($code != $yuancode){
$this->error('验证码错误或者失效,请重新发送');
}
$data = Db::name('third')->where('id',$result1['id'])->update(['password'=>$new_password]);
$data = Db::name('user')->where('id',$result1['id'])->update(['password'=>$new_password]);
if(empty($data)){
$this->error('修改失败');
}else{
... ... @@ -458,7 +648,8 @@ class Lists extends Api
* @ApiMethod (POST)
* @ApiRoute (/api/lists/edit_pwd)
*
* @ApiParams (name="username", type="string", required=true, description="账号")
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiParams (name="pwd", type="string", required=true, description="密码")
* @ApiParams (name="new_password", type="string", required=true, description="新密码")
* @ApiParams (name="re_pwd", type="string", required=true, description="确认密码")
... ... @@ -474,7 +665,7 @@ class Lists extends Api
*/
public function edit_pwd()
{
$user_id = Session::get('user_id');
$user_id = $this->auth->id;
$username = $this->request->param('username');
$pwd = $this->request->param('pwd');
$new_password = $this->request->param('new_password');
... ... @@ -484,21 +675,20 @@ class Lists extends Api
$this->error('缺少必要参数');
}
$userinfo = Db::name('third')->where('id',$user_id)->find();
if($userinfo['pwd'] != $pwd){
$userinfo = Db::name('user')->where('id',$user_id)->find();
if($userinfo['password'] != $pwd){
$this->error('您的密码不正确');
}
if($new_password != $re_pwd){
$this->error('两次密码不一致');
}
$data = Db::name('third')->where('id',$user_id)->update(['password'=>$new_password]);
$data = Db::name('user')->where('id',$user_id)->update(['password'=>$new_password]);
if(empty($data)){
$this->error('修改失败');
}else{
$this->success('修改成功');
}
}
... ... @@ -582,4 +772,137 @@ class Lists extends Api
}
/**
* @ApiTitle (分类)
* @ApiSummary (分类列表)
* @ApiMethod (POST)
* @ApiRoute (/api/lists/ke_list)
*
* @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
* @ApiParams (name="pageNum", type="inter", required=false, description="每页显示数据个数(默认10)")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"total_num"://总条数
"info":[
"id"://ID
"phone2"://手机号2
"phone1"://手机号1
"image"://二维码
"createtime"://创建时间
]
}
})
*/
public function ke_list()
{
$page = $this->request->param('page', 1, 'intval');
$pageNum = $this->request->param('pageNum', 10, 'intval');
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data['total_num'] = Db::name('kelist')->count();
$data['info'] = Db::name('kelist')->order('id desc')->field('updatetime',true)->page($page,$pageNum)->select();
foreach ($data['info'] as &$v){
$v['image'] = $qiniu.$v['image'];
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
}
$this->success('success',$data);
}
/**
* @ApiTitle (分类列表)
* @ApiSummary (分类列表)
* @ApiMethod (POST)
* @ApiRoute (/api/lists/type_list)
*
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"one": [
{
"id": 1,
"name": "学习类型",
"pid": 0,
"level": 1,
"createtime": 1597834718,
"updatetime": 1597834718
}
],
"two": [
{
"id": 2,
"name": "理科类型",
"pid": 1,
"level": 2,
"createtime": 1597834738,
"updatetime": 1597834738
}
],
"three": [
{
"id": 3,
"name": "测试",
"pid": 2,
"level": 3,
"createtime": 1597835130,
"updatetime": 1597835130
}
]
}
})
*/
public function type_list()
{
$data = Db::name('type')->select();
$info['one'] = [];
$info['two'] = [];
$info['three'] = [];
foreach ($data as $k=>$v){
if($v['level'] == 1){
array_push($info['one'],$data[$k]);
}elseif ($v['level'] == 2){
array_push($info['two'],$data[$k]);
}else{
array_push($info['three'],$data[$k]);
}
}
$this->success('success',$info);
}
/**
* @ApiTitle (获取分类列表)
* @ApiSummary (获取分类列表)
* @ApiMethod (POST)
* @ApiRoute (/api/lists/get_list)
*
* @ApiParams (name="id", type="inter", required=false, description="分类id")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
}
})
*/
public function get_list()
{
$id = $this->request->param('id');
if(empty($id)){
$this->error('缺少必要参数');
}
$data = Db::name('type')->where('pid',$id)->select();
$this->success('success',$data);
}
}
... ...
... ... @@ -3,6 +3,7 @@
namespace app\api\controller;
use app\common\controller\Api;
use function fast\e;
use think\Cache;
use think\Db;
use think\Session;
... ... @@ -26,7 +27,7 @@ use think\exception\PDOException;
*/
class User extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedLogin = ['video_list'];
protected $noNeedRight = ['*'];
/**
... ... @@ -35,6 +36,8 @@ class User extends Api
* @ApiMethod (POST)
* @ApiRoute (/api/user/index)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
... ... @@ -54,17 +57,16 @@ class User extends Api
public function index()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$user_id = Session::get('user_id');
if(empty($user_id)){
$this->error('请先登录');
}
$data = Db::name('third')->where('id',$user_id)->find();
$user_id = $this->auth->id;
$data = Db::name('user')->where('id',$user_id)->find();
if(empty($data['nickname'])){
$data['nickname'] = '';
}
if(empty($data['image'])){
$data['image'] = '';
$data['yuan_image'] = '';
}else{
$data['yuan_image'] = $data['image'];
$data['image'] = $qiniu.$data['image'];
}
if(empty($data['card'])){
... ... @@ -85,7 +87,7 @@ class User extends Api
* @ApiMethod (POST)
* @ApiRoute (/api/user/edit_info)
*
* @ApiParams (name="user_id", type="int", required=true, description="用户ID")
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="nickname", type="string", required=true, description="姓名")
* @ApiParams (name="sex", type="int", required=true, description="性别1男0女")
* @ApiParams (name="card", type="string", required=true, description="身份证号")
... ... @@ -104,7 +106,7 @@ class User extends Api
*/
public function edit_info()
{
$user_id = $this->request->param('user_id');
$user_id = $this->auth->id;
$nickname = $this->request->param('nickname');
$sex = $this->request->param('sex');
$card = $this->request->param('card');
... ... @@ -121,14 +123,19 @@ class User extends Api
$this->error('验证码错误');
}
}
$data = Db::name('third')
->where('id',$user_id)
->update(['nickname'=>$nickname,'sex'=>$sex,'card'=>$card,'work_address'=>$work_address,'phone'=>$phone,'image'=>$image]);
if(!empty($data)){
$this->success('success');
$data = Db::name('user')->where('id',$user_id)->find();
if(empty($data['image'])){
Db::name('user')
->where('id',$user_id)
->update(['nickname'=>$nickname,'sex'=>$sex,'card'=>$card,'work_address'=>$work_address,'phone'=>$phone,'image'=>$image]);
}else{
$this->error('error');
Db::name('user')
->where('id',$user_id)
->update(['nickname'=>$nickname,'sex'=>$sex,'card'=>$card,'work_address'=>$work_address,'phone'=>$phone]);
}
$this->success('success');
}
/**
... ... @@ -143,21 +150,25 @@ class User extends Api
* @ApiParams (name="pageNum", type="inter", required=false, description="每页显示数据个数(默认10)")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id"://ID
"study_id"://学习系统id
"is_major"://1主修2选修
"tag"://标签
"name"://课程名称
"video_file"://视频地址
"video_image"://视频首帧图
"duration"://总时长/秒
"class_hour"://学时
"content"://内容详情
"teacher"://讲师
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"total_num"://总时长
"info":[
"id"://ID
"study_id"://学习系统id
"is_major"://1主修2选修
"tag"://标签
"name"://课程名称
"video_file"://视频地址
"video_image"://视频首帧图
"duration"://总时长/秒
"class_hour"://学时
"content"://内容详情
"teacher"://讲师
]
}
})
*/
... ... @@ -180,16 +191,19 @@ class User extends Api
}
$where['study_id'] = $id;
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data = Db::name('classes')
$data['total_num'] = Db::name('classes')
->where($where)
->count();
$data['info'] = Db::name('classes')
->field('createtime,updatetime',true)
->where($where)
->page($page,$pageNum)
->order('id desc')
->select();
foreach ($data as &$v){
foreach ($data['info'] as &$v){
$v['video_file'] = $qiniu.$v['video_file'];
$video_info = json_decode(file_get_contents($v['video_file'] . '?avinfo'), true);
$v['video_image'] = $this->get_video_first_image( $v['video_file'], $video_info);
// $video_info = json_decode(file_get_contents($v['video_file'] . '?avinfo'), true);
$v['video_image'] = $qiniu.$v['video_image'];
}
$this->success('success',$data);
}
... ... @@ -200,6 +214,7 @@ class User extends Api
* @ApiMethod (POST)
* @ApiRoute (/api/user/video_detail)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="int", required=true, description="培训课程id")
*
* @ApiReturn({
... ... @@ -221,16 +236,23 @@ class User extends Api
"teacher"://讲师
"expirationtime"://截止日期
"is_join"://是否已经加入学习计划1未加入2已加入
"bofangtime"://播放时长/秒
}
})
*/
public function video_detail()
{
$user_id = Session::get('user_id');
$user_id = $this->auth->id;
$id = $this->request->param('id');
if(empty($id)){
$this->error('缺少必要参数');
}
$user_info = Db::name('user')->where('id',$user_id)->find();
if(empty($user_info['image']) || empty($user_info['phone'])){
$this->error('请先完善个人信息');
}
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data = Db::name('classes')
->alias('a')
... ... @@ -239,6 +261,24 @@ class User extends Api
->field('a.*,b.expirationtime')
->find();
//查看播放秒数
$class_detail = Db::name('class_detail')
->where('user_id',$user_id)
->where('class_id',$id)
->find();
if(empty($class_detail)){
$res['user_id'] = $user_id;
$res['class_id'] = $id;
$res['duration'] = 0;
$res['createtime'] = time();
Db::name('class_detail')->insert($res);
$data['bofangtime'] = 0;
$data['is_end'] = 2;
}else{
$data['bofangtime'] = $class_detail['duration'];
$data['is_end'] = $class_detail['is_end'];
}
$info = Db::name('study_class')
->where('third_id',$user_id)
... ... @@ -252,21 +292,97 @@ class User extends Api
}
//视频地址以及首帧图
$data['video_file'] = $qiniu.$data['video_file'];
$video_info = json_decode(file_get_contents($data['video_file'] . '?avinfo'), true);
$data['video_image'] = $this->get_video_first_image($data['video_file'], $video_info);
// $video_info = json_decode(file_get_contents($data['video_file'] . '?avinfo'), true);
$data['video_image'] = $qiniu.$data['video_image'];
$data['expirationtime'] = date('Y-m-d H:i:s',$data['expirationtime']);
$data['min'] = ceil($data['duration']/60);
$this->success('success',$data);
}
/**
* @ApiTitle (记录播放时间)
* @ApiSummary (记录播放时间)
* @ApiMethod (POST)
* @ApiRoute (/api/user/bofang)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="int", required=true, description="培训课程id")
* @ApiParams (name="duration", type="int", required=true, description="播放时间")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
}
})
*/
public function bofang()
{
$user_id = $this->auth->id;
$id = $this->request->param('id');
$duration = $this->request->param('duration');
if(empty($id) || empty($duration)){
$this->error('缺少必要参数');
}
$class = Db::name('classes')
->where('id',$id)
->field('id,duration,study_id')
->find();
if($duration >= $class['duration']){
$is_end = 1;
$study_class = Db::name('study_class')
->where('third_id',$user_id)
->where('study_id',$class['study_id'])
->where('class_id',$id)
->find();
if(!empty($study_class)){
Db::name('study_class')
->where('third_id',$user_id)
->where('study_id',$class['study_id'])
->where('class_id',$id)
->update(['status'=>2,'playtime'=>$duration]);
}
}else{
$is_end = 2;
$study_class = Db::name('study_class')
->where('third_id',$user_id)
->where('study_id',$class['study_id'])
->where('class_id',$id)
->find();
if(!empty($study_class)){
Db::name('study_class')
->where('third_id',$user_id)
->where('study_id',$class['study_id'])
->where('class_id',$id)
->update(['playtime'=>$duration]);
}
}
$data = Db::name('class_detail')
->where('user_id',$user_id)
->where('class_id',$id)
->update(['duration'=>$duration,'is_end'=>$is_end]);
if(empty($data)){
$this->error('失败');
}else{
$this->success('成功');
}
}
/**
* @ApiTitle (加入学习计划)
* @ApiSummary (加入学习计划)
* @ApiMethod (POST)
* @ApiRoute (/api/user/join)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="int", required=true, description="培训课程id")
* @ApiParams (name="playtime", type="int", required=true, description="播放秒数")
*
* @ApiReturn({
"code": 1,
... ... @@ -278,33 +394,34 @@ class User extends Api
*/
public function join()
{
$info['third_id'] = Session::get('user_id');
if(empty($info['third_id'])){
$this->error('请先登录');
}
$info['third_id'] = $this->auth->id;
$info['class_id'] = $this->request->param('id');
if(empty($info['class_id'])){
$this->error('缺少必要参数');
}
$data = Db::name('classes')
->where('id',$info['class_id'])
->value('study_id');
$info['study_id'] = $data;
$playtime = $this->request->param('playtime');
if($playtime != 0){
$classes = Db::name('classes')
->where('id',$info['class_id'])
->find();
if($classes['duration'] <= $playtime){
$info['status'] = 2;
$info['playtime'] = $playtime;
->field('study_id,duration')
->find();
$info['study_id'] = $data['study_id'];
//查询用户是否已经播放完毕该视频
$video = Db::name('class_detail')
->where('user_id',$info['third_id'])
->where('class_id',$info['class_id'])
->find();
if(empty($video)){
$info['playtime'] = 0;
}else{
if($video['is_end'] == 2){
$info['playtime'] = $video['duration'];
}else{
$info['status'] = 1;
$info['playtime'] = $playtime;
$info['playtime'] = $data['duration'];
$info['status'] = 2;
}
}else{
$info['playtime'] = 0;
}
$info['createtime'] = time();
$is_have = Db::name('study_class')
->where('third_id',$info['third_id'])
... ... @@ -329,6 +446,7 @@ class User extends Api
* @ApiMethod (POST)
* @ApiRoute (/api/user/del_join)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="int", required=true, description="培训课程id")
*
* @ApiReturn({
... ... @@ -341,7 +459,7 @@ class User extends Api
*/
public function del_join()
{
$user_id = Session::get('user_id');
$user_id = $this->auth->id;
$id = $this->request->param('id');
if(empty($id)){
$this->error('缺少必要参数');
... ... @@ -362,16 +480,14 @@ class User extends Api
}
}
/**
* @ApiTitle (我的考试)
* @ApiSummary (我的考试)
* @ApiMethod (POST)
* @ApiRoute (/api/user/myexam)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="int", required=true, description="学习系统id")
*
* @ApiReturn({
... ... @@ -387,6 +503,7 @@ class User extends Api
"image"://图片
"proportion"://比例
"expirationtime"://截止日期
"is_xian"://是否显示1显示2不显示
],
"info": [
{
... ... @@ -405,7 +522,7 @@ class User extends Api
public function myexam()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$user_id = Session::get('user_id');
$user_id = $this->auth->id;
$id = $this->request->param('id');
if(empty($id)){
$this->error('缺少必要参数');
... ... @@ -414,14 +531,13 @@ class User extends Api
->where('id',$id)
->find();
$data['exam']['expirationtime'] = date('Y-m-d H:i:s',$data['exam']['expirationtime']);
$data['exam']['image'] = $qiniu.$data['exam']['image'];
$finish_hour = Db::name('study_class')
->alias('a')
->join('classes b','a.class_id = b.id')
->where('a.third_id',$user_id)
->where('a.study_id',$id)
->where('b.is_major',1)
->where('a.status',2)
->field('sum(b.class_hour) as finish_hour')
->find();
... ... @@ -431,19 +547,54 @@ class User extends Api
}else{
$data['exam']['finish_hour'] = $finish_hour['finish_hour'];
}
//查询出所有该科目的必修课
$class_ids = Db::name('classes')->where('study_id',$id)->where('is_major',1)->column('id');
$is_end = Db::name('study_class')
->where('third_id',$user_id)
->where('study_id',$id)
->whereIn('class_id',$class_ids)
->where('status',1)
->find();
//查看用户该科目是否已经考过3次了
$third_exam = Db::name('third_exam')
->where('user_id',$user_id)
->where('study_id',$id)
->order('exam_num desc')
->find();
//该用户绑定该科目的有效期
$third_study = Db::name('third_study')->where('third_id',$user_id)->where('study_id',$id)->find();
if($third_study['periodtime'] < time() || $data['exam']['expirationtime']<time() || $data['exam']['finish_hour'] < $data['exam']['class_hour'] || !empty($is_end) || $third_exam['exam_num'] == 3){
$data['exam']['is_xian'] = 2;
}else{
$data['exam']['is_xian'] = 1;
}
$data['exam']['expirationtime'] = date('Y-m-d H:i:s',$data['exam']['expirationtime']);
unset($data['exam']['updatetime']);
unset($data['exam']['createtime']);
$data['exam']['proportion'] = round($data['exam']['finish_hour']/$data['exam']['class_hour']*100,0).'%';
$a = round($data['exam']['finish_hour']/$data['exam']['class_hour']*100,0);
if($a > 100){
$a = 100;
}
$data['exam']['proportion'] = $a.'%';
$data['info'] = Db::name('study_class')
->alias('a')
->join('classes b','a.class_id = b.id')
->where('a.third_id',$user_id)
->where('a.study_id',$id)
->field('a.id,b.name,b.class_hour,b.is_major,b.duration,a.status,a.playtime')
->field('b.id,a.id as study_class_id,b.name,b.class_hour,b.is_major,b.duration,a.status,a.playtime')
->select();
foreach ($data['info'] as &$v){
$v['proportion'] = round($v['playtime']/$v['duration']*100,0).'%';
if($v['status'] == 1){
$v['proportion'] = round($v['playtime']/$v['duration']*100,0).'%';
}else{
$v['proportion'] = '100%';
}
$v['duration'] = ceil($v['duration']/60);
}
$this->success('success',$data);
... ... @@ -456,6 +607,7 @@ class User extends Api
* @ApiMethod (POST)
* @ApiRoute (/api/user/certificate)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="int", required=true, description="考试记录id")
*
* @ApiReturn({
... ... @@ -463,15 +615,14 @@ class User extends Api
"msg": "成功",
"time": "1571492001",
"data": {
"qrcodeurl": //证书图片,
"score": //分数
}
})
*/
public function certificate(){
$qiniu = get_addon_config('qiniu')['cdnurl'];
$user_id = Session::get('user_id');
if(empty($user_id)){
$this->error('请先登录');
}
$user_id = $this->auth->id;
$id = $this->request->param('id');
if(empty($id)){
$this->error('缺少必要参数');
... ... @@ -481,90 +632,74 @@ class User extends Api
$data = Db::name('third_exam')
->alias('a')
->join('study b','a.study_id = b.id')
->join('third c','a.user_id = c.id')
->join('user c','a.user_id = c.id')
->where('a.id',$id)
->field('a.id,a.user_id,a.study_id,a.createtime,b.examname,b.class_hour,c.image,c.card,c.nickname')
->field('a.id,a.score,a.user_id,a.study_id,a.createtime,b.yinimage,b.workname,c.studynum,b.class_hour,c.image,c.card,c.nickname')
->find();
$data['image'] = $qiniu.$data['image'];
//将图片下载到本地且转换为https
// $base_url = $data['image'];
// $qiniu_url = $qiniu.$data['image'];
// $a = file_get_contents($qiniu_url);
// $path = './uploads/'.explode('/',$base_url)[2].'/';
// if(!file_exists($path)) {
// mkdir($path,0777,true);
// }
// file_put_contents('.'.$base_url,$a);
// $data['water_url'] = request()->domain().$base_url;
$file_path = "qrcode/$id.png";
$image = \think\Image::open(ROOT_PATH."public/YUAN.png");
$path_ttf = ROOT_PATH.'public/assets/fonts/PingFang.ttf';
$data['createtime'] = date('Y年m月d日',$data['createtime']);
$text1 = '继续教育培训合格证书';
$year = date('Y');
$time = date('Ymd');
$text2 = $data['nickname'].'已完成'.$year.'年度'.$data['examname'].'继续教育培训,'.$data['class_hour'].'学时,经考核成绩合格。特发此证';
$text3 = '身份证号: '.$data['card'];
$text4 = '证书编号: TJAG'.$time;
$result = $image
->text($text1,$path_ttf,40,'#FFFFFF',[142,100]);
$image->save(ROOT_PATH . 'public' . DS . 'uploads' . DS . $file_path,'jpg',100);
$path = '/uploads/'.$file_path;
$upload = Config::get('upload');
$config = get_addon_config('qiniu');
$filePath = '.'.$path;
$suffix = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
$suffix = $suffix && preg_match("/^[a-zA-Z0-9]+$/", $suffix) ? $suffix : 'file';
$replaceArr = [
'{year}' => date("Y"),
'{mon}' => date("m"),
'{day}' => date("d"),
'{hour}' => date("H"),
'{min}' => date("i"),
'{sec}' => date("s"),
'{random}' => Random::alnum(16),
'{random32}' => Random::alnum(32),
'{filename}' => $suffix ? substr(pathinfo($filePath)['basename'], 0, strripos(pathinfo($filePath)['basename'], '.')) : pathinfo($filePath)['basename'],
'{suffix}' => $suffix,
'{.suffix}' => $suffix ? '.' . $suffix : '',
'{filemd5}' => md5_file(realpath($filePath)),
];
$savekey = $upload['savekey'];
$savekey = str_replace(array_keys($replaceArr), array_values($replaceArr), $savekey);
$fileName = substr($savekey, strripos($savekey, '/') + 1);
$policy = array(
'saveKey' => ltrim($savekey, '/'),
);
$auth = new \addons\qiniu\library\Auth($config['app_key'], $config['secret_key']);
$token = $auth->uploadToken($config['bucket'], null, $config['expire'], $policy);
$multipart = [
['name' => 'token', 'contents' => $token],
[
'name' => 'file',
'contents' => fopen(realpath($filePath), 'r'),
'filename' => $fileName,
]
];
try {
$client = new \GuzzleHttp\Client();
$res = $client->request('POST', $config['uploadurl'], [
'multipart' => $multipart
]);
$code = $res->getStatusCode();
//成功不做任何操作
} catch (\GuzzleHttp\Exception\ClientException $e) {
unlink($filePath);
$this->error("上传失败");
if(empty($data['image'])){
$this->error('请先上传用户头像');
}
unlink($filePath);
return '/uploads/'.date('Ymd').'/'.$fileName;
}
//将用户的头像保存到本地
$qiniu_url = $qiniu.$data['image'];
$image_name = $user_id.'.png';
$furl = ROOT_PATH . 'public' . DS . 'uploads/user/'.$image_name;
$a = file_get_contents($qiniu_url);
file_put_contents($furl,$a);
//将考试的印章图片保存到本地
$yinimage = $qiniu.$data['yinimage'];
$imagename = $data['study_id'].'.png';
$yinfurl = ROOT_PATH . 'public' . DS . 'uploads/qrcode/'.$imagename;
$b = file_get_contents($yinimage);
file_put_contents($yinfurl,$b);
//用户头像
$user_image = \think\Image::open(ROOT_PATH."public/uploads/user/$image_name");
$user_image->thumb(184,220,\think\Image::THUMB_CENTER)->save(ROOT_PATH."public/uploads/user/$image_name");
//印象头像
$yin_image = \think\Image::open(ROOT_PATH."public/uploads/qrcode/$imagename");
$yin_image->thumb(248,242,\think\Image::THUMB_CENTER)->save(ROOT_PATH."public/uploads/qrcode/$imagename");
$file_path = "$id.png";
$image = \think\Image::open(ROOT_PATH."public/uploads/yuan.png");
$path_ttf = ROOT_PATH.'public/assets/fonts/PingFang.ttf';
$year = date('Y');
//证书编号
$text = 'TJAG'.$year.$data['studynum'];
//培训单位盖章
$text1 = '培训单位盖章';
$image->water(ROOT_PATH."public/uploads/qrcode/$imagename",[1200,602],100);
$image->water(ROOT_PATH."public/uploads/user/$image_name",[300,430],100);
$image->text($data['card'],$path_ttf,25,'#000000',[300,778]);
$image->text($text,$path_ttf,25,'#000000',[300,868]);
$image->text($data['nickname'],$path_ttf,30,'#000000',[850,364]);
$image->text($data['nickname'],$path_ttf,30,'#000000',[851,364]);
$image->text($year,$path_ttf,30,'#000000',[1121,364]);
$image->text($year,$path_ttf,30,'#000000',[1122,364]);
$image->text($data['workname'],$path_ttf,30,'#000000',[1325,362]);
$image->text($data['workname'],$path_ttf,30,'#000000',[1326,362]);
$image->text($data['class_hour'],$path_ttf,30,'#000000',[1071,442]);
$image->text($data['class_hour'],$path_ttf,30,'#000000',[1072,442]);
$image->text($data['createtime'],$path_ttf,30,'#000000',[1121,832]);
$image->text($data['createtime'],$path_ttf,30,'#000000',[1122,832]);
$image->text($text1,$path_ttf,30,'#000000',[1187,772]);
$image->text($text1,$path_ttf,30,'#000000',[1188,772]);
$image->save(ROOT_PATH . 'public' . DS . 'uploads' . DS . $file_path,'png',100);
$answer['qrcodeurl'] = request()->domain().'/uploads/'.$id.'.png';
$answer['score'] = $data['score'];
$this->success('success',$answer);
}
... ...
... ... @@ -197,6 +197,10 @@ return [
'type' => '',
// 是否自动开启 SESSION
'auto_start' => true,
//session 有效期
'expire'=>86400,
//session 的存储地址
'path'=>'./../public/session'
],
// +----------------------------------------------------------------------
// | Cookie设置
... ...
<?php
return array (
'name' => '企智',
'name' => '企智',
'beian' => '',
'cdnurl' => '',
'version' => '1.0.1',
... ...
... ... @@ -17,7 +17,7 @@ return [
/**
* 最大可上传大小
*/
'maxsize' => '10mb',
'maxsize' => '2000mb',
/**
* 可上传的文件类型
*/
... ...
不能预览此文件类型
此 diff 太大无法显示。
... ... @@ -25,9 +25,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'image', title: __('简介图片'), events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'image', title: __('Image'), events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
// {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) {
var that = $.extend({}, this);
var table = $(that.table).clone(true);
... ...
... ... @@ -29,6 +29,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'is_major', title: __('类型'), searchList: {"1":"必修","2":'选修'},formatter: Table.api.formatter.status},
{field: 'tag', title: __('Tag'), operate:false},
{field: 'name', title: __('Name'), operate:'like'},
{field: 'video_image', title: __('视频封面图'), events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'video_file', title: __('Video_file'), operate:false,formatter: Table.api.formatter.url},
{field: 'duration', title: __('总时长(秒)'), operate:false},
{field: 'class_hour', title: __('Class_hour'), operate:false},
... ...
... ... @@ -10,6 +10,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
edit_url: 'dan/edit',
del_url: 'dan/del',
multi_url: 'dan/multi',
import_url: 'dan/import',
table: 'dan',
}
});
... ... @@ -28,7 +29,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'study_id', title: __('学习科目'), operate:false},
{field: 'answer', title: __('Answer'), operate:false},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
// {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
... ...
... ... @@ -9,6 +9,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
add_url: 'duo/add',
edit_url: 'duo/edit',
del_url: 'duo/del',
import_url: 'duo/import',
multi_url: 'duo/multi',
table: 'duo',
}
... ... @@ -28,7 +29,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'study_id', title: __('学习科目'), operate:false},
{field: 'answer', title: __('Answer'), operate:false},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
// {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
... ...
... ... @@ -24,6 +24,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'study_id', title: __('考试科目名称')},
{field: 'finish_class', title: __('课时完成进度(已完成/全部)')},
{field: 'required_num', title: __('必修课情况')},
]
]
});
... ...
... ... @@ -27,6 +27,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'id', title: __('Id')},
{field: 'title', title: __('Title')},
{field: 'from', title: __('转载于')},
{field: 'file_name', title: __('附件名称')},
{field: 'file', title: __('File'),formatter: Table.api.formatter.url},
{field: 'is_up', title: __('是否上架'),searchList: {"0":"否","1":'是'},formatter: Table.api.formatter.status},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
... ...
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'kelist/index' + location.search,
add_url: 'kelist/add',
edit_url: 'kelist/edit',
del_url: 'kelist/del',
multi_url: 'kelist/multi',
table: 'kelist',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'image', title: __('Image'), events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'phone1', title: __('Phone1')},
{field: 'phone2', title: __('Phone2')},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
// {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});
\ No newline at end of file
... ...
... ... @@ -10,6 +10,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
edit_url: 'pan/edit',
del_url: 'pan/del',
multi_url: 'pan/multi',
import_url: 'pan/import',
table: 'pan',
}
});
... ... @@ -28,7 +29,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'study_id', title: __('Study_id')},
{field: 'answer', title: __('正确答案'),searchList: {"A":"正确","B":'错误'},formatter: Table.api.formatter.status},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
// {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
... ...
... ... @@ -27,6 +27,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'id', title: __('Id')},
{field: 'title', title: __('Title')},
{field: 'from', title: __('From')},
{field: 'file_name', title: __('附件名称')},
{field: 'file', title: __('File'),formatter: Table.api.formatter.url},
{field: 'is_up', title: __('是否上架'),searchList: {"0":"否","1":'是'},formatter: Table.api.formatter.status},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
... ...