Commit 38f5bec7 by 杨昕

添加媒资类别模块

parent 2d0f40b4
Pipeline #9840 passed with stages
in 33 seconds
......@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Web;
use App\Model\MediaCategoryModel;
use App\Model\MediaModel;
use App\Tool\SrsHookValidate;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
......@@ -57,4 +58,47 @@ class MediaController extends Controller
return success($res);
}
/**
* 显示
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws \App\Exceptions\ControllerException
*/
public function create(Request $request){
$reslut = handler_drive(function () use($request){
$media_types = MediaCategoryModel::catgList($request);
return $media_types;
});
$data['media_types'] = $reslut;
$data['media_id'] = 'mda-'.generateRandomNum(16);
return view('admin.media.media_add',$data);
}
/**
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public function store(Request $request){
$id = handler_drive(function () use($request){
SrsHookValidate::srsHookCallback($request,[
'media_name' => 'required',
'media_type' => 'required',
'media_id' => 'required',
'access_key' => '',
'secret_key' => '',
'media_url' => 'required',
]);
return MediaModel::hookRestoreMedia($request);
});
return success($id);
}
}
......@@ -40,7 +40,7 @@ class MediaModel extends Eloquent
$tmp[$catg['_id']] = $catg['name'];
}
$medias = MediaModel::where($where)->paginate(10);
$medias = MediaModel::where($where)->orderBy("create_time","desc")->paginate(10);
foreach ($medias as $media){
$media['media_type'] = $tmp[$media['media_type_id']];
......@@ -276,6 +276,9 @@ class MediaModel extends Eloquent
public static function getMediaList($request){
try{
/**
*[{"bookNum":["hb15011","2"],"mediaCatg":"一题一码"}]
*/
$params = json_decode($request->params,true);
if (empty($params)){
......@@ -309,7 +312,10 @@ class MediaModel extends Eloquent
$res[] = $item->groupBy("book_num");
}
if (isset($res[0]) || empty($res[0])){
/**
* 排除res为空
*/
if (!isset($res[0]) || empty($res[0])){
return [];
}
......
......@@ -124,7 +124,7 @@
"id": 11,
"pid": 0,
"name": "媒资管理",
"icon": "",
"icon": "",
"link": "/manager",
"slug": "manager",
"description": "",
......@@ -198,4 +198,82 @@
"sort": 25,
"key_name": "media_create"
}]
},{
"id": 3,
"pid": 0,
"name": "媒资类别管理",
"icon": "",
"link": "/media_category",
"slug": "media_category",
"description": "",
"show": 1,
"sort": 2,
"key_name": "media_category",
"son": [{
"id": 31,
"pid": 3,
"name": "媒资类别列表",
"icon": "",
"link": "/media_category",
"slug": "media_category.index",
"description": "",
"show": 1,
"sort": 25,
"key_name": "media_list"
},{
"id": 31,
"pid": 3,
"name": "媒资类别删除",
"icon": "",
"link": "",
"slug": "media_category.destroy",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_destroy"
}, {
"id": 33,
"pid": 3,
"name": "媒资类别添加保存",
"icon": "",
"link": "",
"slug": "media_category.store",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_store"
}, {
"id": 34,
"pid": 3,
"name": "媒资类别修改保存",
"icon": "",
"link": "",
"slug": "media_category.update",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_update"
}, {
"id": 35,
"pid": 3,
"name": "媒资类别编辑",
"icon": "",
"link": "",
"slug": "media_category.edit",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_edit"
}, {
"id": 36,
"pid": 3,
"name": "媒资类别添加",
"icon": "",
"link": "/media_category/create",
"slug": "media_category.create",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_create"
}]
}]
\ No newline at end of file
......@@ -36,95 +36,58 @@
<div class="col-md-12">
<!--***** FORM GROUP *****-->
<div class="card form">
<div class="card form" id="form5">
<div class="card-header">
<h3><i class="fa fa-user-circle"></i>管理员注册</h3>
<h3>编辑媒资</h3>
</div>
<br>
<form id="newForm">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="form-group">
<label for="uesrname">姓名</label>
<div class="input-group ">
<div class="input-group-addon"><i class="fa fa-user-o"></i></div>
<input type="text" class="form-control" name="name" id="uesrname"
placeholder="姓名">
</div>
</div>
<input type="hidden" name="_token" value="{{csrf_token()}}">
<input type="hidden" name="media_id" value="{{$media_id}}">
{{ method_field('POST')}}
<div class="form-group">
<label for="nickname"></label>
<label for="media_name">媒资名</label>
<div class="input-group ">
<div class="input-group-addon"><i class="fa fa-user-o"></i></div>
<input type="text" class="form-control" name="nickname" id="nickname"
placeholder="昵称">
<div class="input-group-addon"><i class="icon iconfont icon-title">&#xe62b;</i></div>
<input type="text" class="form-control" name="media_name" id="media_name"
placeholder="媒资名称" value="">
</div>
</div>
<div class="form-group">
<label for="formGroupExampleInput2">密码<span class="red">*</span></label>
<div class="input-group ">
<div class="input-group-addon"><i class="fa fa-lock"></i></div>
<input type="password" class="form-control" value="123123" id="inlineFormInputGroup">
<small class="form-text text-muted">6到16个字符</small>
</div>
</div>
<label for="exampleSelect1">媒资类别</label>
<select class="form-control" id="exampleSelect1" name="media_type">
<div class="form-group">
<label for="formGroupExampleInput2">确认密码</label>
<div class="input-group ">
<div class="input-group-addon"><i class="fa fa-lock"></i></div>
<input type="password" name="password" class="form-control" value="123123"
id="inlineFormInputGroup">
</div>
@foreach($media_types as $media_type)
<option value="{{$media_type["name"]}}" >{{$media_type['name']}}</option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="mobile">电话号码</label>
<label for="mobile">媒资视频链接</label>
<div class="input-group ">
<div class="input-group-addon"><i class="fa fa-phone"></i></div>
<input type="text" class="form-control" name="mobile" id="mobile"
placeholder="电话号码">
<div class="input-group-addon"><i class="iconfont">&#xe746;</i></div>
<input type="text" class="form-control" name="media_url" id="media_url" value=""
placeholder="视频链接">
</div>
</div>
<div class="form-group">
<label for="mobile">邮箱</label>
<div class="input-group ">
<div class="input-group-addon"><i class="iconfont">&#xe610;</i></div>
<input type="text" class="form-control" name="email" id="emial"
placeholder="邮箱">
</div>
<label class="access-key">公钥</label>
<textarea class="form-control" name="access_key" id="access-key" rows="5" placeholder="公钥"></textarea>
</div>
<div class="form-group">
<label for="role">角色</label>
<div class="input-group ">
<div class="input-group-addon"><i class="fa fa-phone"></i></div> -->
<div class="checkbox">
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
<span class="mr5" style="margin-right: 20px;">1</span>
</label>
</div>
<div class="checkbox">
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
<span class="mr5" style="margin-right: 20px;">1</span>
</label>
</div>
</div>
<label class="secret-key">私钥</label>
<textarea class="form-control" name="secret_key" id="secret-key" rows="5" placeholder="私钥"></textarea>
</div>
<button type="submit" onclick="registerUser();"
class="btn btn-general btn-blue mr-2">确认
</button>
<button type="reset" class="btn btn-general btn-white">重置 </button>
<button type="submit" onclick="registerUser();" class="btn btn-general btn-blue mr-2">确认</button>
<button type="reset" onclick="cancle()" class="btn btn-general btn-white">取消</button>
</form>
</div>
......@@ -134,14 +97,12 @@
</div>
<!--Global Javascript -->
@include('admin.common_bak.foot')
@include('admin.common.foot')
<script src="{{ asset('xadmin/extra/toast/js/toast.js')}}"></script>
<script src="{{ asset('xadmin/js/jquery.validate.js')}}"></script>
{{--<link rel="stylesheet" href="{{ asset('xadmin/extra/toast/css/toast.css')}}">--}}
<!--Core Javascript -->
<script type="text/javascript">
......@@ -151,51 +112,48 @@
$("#newForm").validate({
rules: {
nickname: "required",
name: {
required: true,
minlength: 2
},
password: {
required: true,
minlength: 5
},
confirm_password: {
required: true,
minlength: 5,
equalTo: "#password"
},
email: {
required: true,
email: true
},
// password: {
// required: true,
// minlength: 5
// },
// confirm_password: {
// required: true,
// minlength: 5,
// equalTo: "#password"
// },
// email: {
// required: true,
// email: true
// },
},
messages: {
nickname: {
required:''
},
name: {
required: "昵称不能为空",
minlength: "昵称至少2个字符"
},
password: {
required: "请输入密码",
minlength: "密码长度不能小于5"
},
confirm_password: {
required: "请输入确认密码",
minlength: "密码长度不能小于5",
equalTo: "两次密码输入不一致"
required: "媒资名称不能为空",
minlength: "Your username must consist of at least 2 characters"
},
email: "请输入有效邮箱",
// password: {
// required: "Please provide a password",
// minlength: "Your password must be at least 5 characters long"
// },
// confirm_password: {
// required: "Please provide a password",
// minlength: "Your password must be at least 5 characters long",
// equalTo: "Please enter the same password as above"
// },
//email: "Please enter a valid email address",
},
submitHandler: function (form) {
var form = document.querySelector("#newForm");
var formdata = new FormData(form);
fetch_response('POST', '/web/member', formdata).then(function (res) {
console.log("formdata",formdata)
fetch_response('POST',"/web/media_manager", formdata).then(function (res) {
if (res.code == 200) {
//console.log('dsfsfsd')
$('body').toast({
position: 'fixed',
content: res.msg,
......@@ -203,7 +161,7 @@
top: '50%'
});
setTimeout(function () {
window.location.href = '/web/member';
window.location.href = '/web/media_manager';
}, 2000)
} else {
......@@ -220,6 +178,18 @@
}
function cancle() {
$('body').toast({
position: 'fixed',
content: '已取消',
duration: 1000,
top: '50%'
});
setTimeout(function () {
window.history.back();
}, 2000)
}
</script>
</body>
......
......@@ -50,7 +50,7 @@
<div class="input-group ">
<div class="input-group-addon"><i class="icon iconfont icon-title">&#xe62b;</i></div>
<input type="text" class="form-control" name="media_name" id="media_name"
placeholder="姓名" value="{{$media['media_name']}}">
placeholder="媒资名称" value="{{$media['media_name']}}">
</div>
</div>
......@@ -61,9 +61,9 @@
@foreach($media_types as $media_type)
@if($media_type['name'] == $media['media_type'])
<option value="{{$media['media_type']}}" selected>{{$media_type['name']}}</option>
<option value="{{$media['media_type_id']}}" selected>{{$media_type['name']}}</option>
@else
<option value="{{$media['media_type']}}">{{$media_type['name']}}</option>
<option value="{{$media['media_type_id']}}">{{$media_type['name']}}</option>
@endif
@endforeach
......
......@@ -36,7 +36,7 @@
<div class="row ml20">
<div class="xblock">
<button class="btn btn-primary" onclick="x_admin_show('/web/member/create')">
<button class="btn btn-primary" onclick="x_admin_show('/web/media_manager/create')">
添加
</button>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment