作者 黎建湛

提交更改axaj方式请求接口更新

  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Admin;
  4 +
  5 +use Illuminate\Http\Request;
  6 +use App\Http\Controllers\Controller;
  7 +
  8 +class CurlController {
  9 + public function curl() {
  10 +
  11 + }
  12 +}
@@ -43,7 +43,7 @@ class InvitationController extends Controller @@ -43,7 +43,7 @@ class InvitationController extends Controller
43 ->select(['T1.id','T1.title','T1.gmt_create','T1.gmt_modified','T1.content','T1.is_audit','T2.email','T3.name']) 43 ->select(['T1.id','T1.title','T1.gmt_create','T1.gmt_modified','T1.content','T1.is_audit','T2.email','T3.name'])
44 ->paginate(10); 44 ->paginate(10);
45 45
46 - $count = $data->sum(); 46 + $count = $data->count();
47 47
48 // 加载视图 渲染页面 48 // 加载视图 渲染页面
49 return view('admin.invitation.invitation',['data'=>$data,'search'=>$search,'count'=> $count]); 49 return view('admin.invitation.invitation',['data'=>$data,'search'=>$search,'count'=> $count]);
@@ -73,9 +73,10 @@ class InvitationController extends Controller @@ -73,9 +73,10 @@ class InvitationController extends Controller
73 73
74 // 返回受影响的行数 74 // 返回受影响的行数
75 if ( $res ) { 75 if ( $res ) {
76 - echo "<script>alert('审核通过成功');location.href='http://8.129.211.201:39006/admin/invitation/invitation'</script>"; 76 + return ['info' => 1];
77 } else { 77 } else {
78 - echo "<script>alert('审核通过失败');location.href='http://8.129.211.201:39006/admin/invitation/invitation'</script>"; 78 + $error = '';
  79 + return ['info'=>0,'error'=>$error];
79 } 80 }
80 } 81 }
81 82
@@ -86,7 +87,7 @@ class InvitationController extends Controller @@ -86,7 +87,7 @@ class InvitationController extends Controller
86 $reson = $request->input('reson', ''); 87 $reson = $request->input('reson', '');
87 88
88 if ($reson == '') { 89 if ($reson == '') {
89 - echo "<script>alert('需要插入内容');location.href='http://8.129.211.201:39006/admin/invitation/invitation'</script>"; 90 + echo "<script>alert('需要插入内容');</script>";
90 } 91 }
91 92
92 $data = DB::table('planet_article')->where('id', $id)->first(); 93 $data = DB::table('planet_article')->where('id', $id)->first();
@@ -104,9 +105,10 @@ class InvitationController extends Controller @@ -104,9 +105,10 @@ class InvitationController extends Controller
104 105
105 // 返回受影响的行数 106 // 返回受影响的行数
106 if ( $res ) { 107 if ( $res ) {
107 - echo "<script>alert('审核成功');location.href='http://8.129.211.201:39006/admin/invitation/invitation'</script>"; 108 + return ['info' => 1];
108 } else { 109 } else {
109 - echo "<script>alert('审核失败');location.href='http://8.129.211.201:39006/admin/invitation/invitation'</script>"; 110 + $error = '';
  111 + return ['info'=>0,'error'=>$error];
110 } 112 }
111 } 113 }
112 } 114 }
@@ -43,9 +43,10 @@ class TagController extends Controller @@ -43,9 +43,10 @@ class TagController extends Controller
43 43
44 // 返回受影响的行数 44 // 返回受影响的行数
45 if ( $res ) { 45 if ( $res ) {
46 - echo "<script>alert('添加成功');location.href='http://8.129.211.201:39006/admin/tag/add'</script>"; 46 + return ['info' => 1];
47 } else { 47 } else {
48 - echo "<script>alert('添加失败');location.href='http://8.129.211.201:39006/admin/tag/add'</script>"; 48 + $error = '';
  49 + return ['info'=>0,'error'=>$error];
49 } 50 }
50 } 51 }
51 52
@@ -57,17 +58,20 @@ class TagController extends Controller @@ -57,17 +58,20 @@ class TagController extends Controller
57 58
58 if ($is_enable == 1) { 59 if ($is_enable == 1) {
59 $data['is_enable'] = 0; 60 $data['is_enable'] = 0;
  61 + $json_res = '禁用成功';
60 } else { 62 } else {
61 $data['is_enable'] = 1; 63 $data['is_enable'] = 1;
  64 + $json_res = '启用成功';
62 } 65 }
63 66
64 $res = DB::table('planet_label')->where('id', $id)->update($data); 67 $res = DB::table('planet_label')->where('id', $id)->update($data);
65 68
66 // 返回受影响的行数 69 // 返回受影响的行数
67 if ( $res ) { 70 if ( $res ) {
68 - echo "<script>alert('禁用成功');location.href='http://8.129.211.201:39006/admin/tag/tag'</script>"; 71 + return ['info' => 1,'res' => $json_res];
69 } else { 72 } else {
70 - echo "<script>alert('禁用失败');location.href='http://8.129.211.201:39006/admin/tag/tag'</script>"; 73 + $error = '';
  74 + return ['info'=>0,'error'=>$error];
71 } 75 }
72 } 76 }
73 77
@@ -80,9 +84,10 @@ class TagController extends Controller @@ -80,9 +84,10 @@ class TagController extends Controller
80 84
81 // 返回受影响的行数 85 // 返回受影响的行数
82 if ( $res ) { 86 if ( $res ) {
83 - echo "<script>alert('删除成功');location.href='http://8.129.211.201:39006/admin/tag/tag'</script>"; 87 + return ['info' => 1];
84 } else { 88 } else {
85 - echo "<script>alert('删除失败');location.href='http://8.129.211.201:39006/admin/tag/tag'</script>"; 89 + $error = '';
  90 + return ['info'=>0,'error'=>$error];
86 } 91 }
87 } 92 }
88 } 93 }
@@ -8,13 +8,12 @@ @@ -8,13 +8,12 @@
8 </head> 8 </head>
9 <body> 9 <body>
10 <article class="cl pd-20"> 10 <article class="cl pd-20">
11 - <form action="/admin/invitation/del" method="post" class="form form-horizontal" id="form-member-add"> 11 + <form action="/admin/invitation/del" method="post" class="form form-horizontal" id="form-admin-del">
12 {{ csrf_field() }} 12 {{ csrf_field() }}
13 <input value="{{$id}}" type="hidden" name="id"> 13 <input value="{{$id}}" type="hidden" name="id">
14 <div class="row cl"> 14 <div class="row cl">
15 <label class="form-label col-xs-4 col-sm-3">审核不通过理由:</label> 15 <label class="form-label col-xs-4 col-sm-3">审核不通过理由:</label>
16 <div class="formControls col-xs-5 col-sm-6"> 16 <div class="formControls col-xs-5 col-sm-6">
17 - <!-- <input type="text" class="input-text" value="{{$id}}" type="hidden" name="id"> -->  
18 <input type="text" class="input-text" value="" placeholder="请输入审核不通过理由" id="label" name="reson"> 17 <input type="text" class="input-text" value="" placeholder="请输入审核不通过理由" id="label" name="reson">
19 <input class="btn btn-primary" style="margin-top:10px;" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;"> 18 <input class="btn btn-primary" style="margin-top:10px;" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
20 </div> 19 </div>
@@ -22,6 +21,22 @@ @@ -22,6 +21,22 @@
22 </form> 21 </form>
23 </article> 22 </article>
24 23
  24 +<!-- 对话框 开始 -->
  25 +<div id="modal-demo" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  26 + <div class="modal-dialog">
  27 + <div class="modal-content radius">
  28 + <div class="modal-body">
  29 + <p>提交成功</p>
  30 + </div>
  31 + <div class="modal-footer">
  32 + <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">确定</button>
  33 + <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
  34 + </div>
  35 + </div>
  36 + </div>
  37 +</div>
  38 +<!-- 对话框 结束 -->
  39 +
25 <!-- footer 开始 --> 40 <!-- footer 开始 -->
26 @include('admin.common.footer') 41 @include('admin.common.footer')
27 <!-- footer 结束 --> 42 <!-- footer 结束 -->
@@ -30,10 +45,44 @@ @@ -30,10 +45,44 @@
30 <script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script> 45 <script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
31 <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 46 <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
32 <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script> 47 <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
33 -<script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script> 48 +<script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
  49 +<!--/请在上方写此页面业务相关的脚本-->
34 <script type="text/javascript"> 50 <script type="text/javascript">
  51 + $('#form-admin-del').submit(function(event){
  52 + //阻止表单的默认提交
  53 + event.preventDefault();
  54 + //获取表单数据
  55 + var data = $(this).serialize();
35 56
36 -</script>  
37 -<!--/请在上方写此页面业务相关的脚本--> 57 + //ajax提交
  58 + $.ajax({
  59 + type: 'post',
  60 + url: '{{url("admin/invitation/del")}}',
  61 + data: data,
  62 + dataType: 'json',
  63 + success:function(msg){
  64 + //msg服务器返回json格式数据
  65 + if(msg.info == 1){
  66 + // $("#modal-demo").modal("show")
  67 + $("body").Huimodalalert({
  68 + content: '提交成功',
  69 + speed: 500
  70 + })
  71 +
  72 + setTimeout (function(){
  73 + //插入成功
  74 + parent.window.location.href = parent.window.location.href;
  75 + layer_close();
  76 + },1000);
  77 + }
  78 + else{
  79 + //插入失败
  80 + layer.msg('提交失败'+msg.error,{icon:5,time:2000});
  81 + }
  82 + }
  83 +
  84 + });
  85 + });
  86 +</script>
38 </body> 87 </body>
39 </html> 88 </html>
@@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
34 <table class="table table-border table-bordered table-hover table-bg table-sort"> 34 <table class="table table-border table-bordered table-hover table-bg table-sort">
35 <thead> 35 <thead>
36 <tr class="text-c"> 36 <tr class="text-c">
37 - <th width="25">全选<input type="checkbox" name="checkbox" value=""></th> 37 +{{-- <th width="25">全选<input type="checkbox" name="checkbox" value=""></th>--}}
38 <th width="80">ID</th> 38 <th width="80">ID</th>
39 <th width="100">账号</th> 39 <th width="100">账号</th>
40 <th width="150">帖子标题</th> 40 <th width="150">帖子标题</th>
@@ -49,7 +49,7 @@ @@ -49,7 +49,7 @@
49 <?php $n = 1; ?> 49 <?php $n = 1; ?>
50 @foreach($data as $k => $v) 50 @foreach($data as $k => $v)
51 <tr class="text-c"> 51 <tr class="text-c">
52 - <td><input type="checkbox" value="1" name=""></td> 52 +{{-- <td><input type="checkbox" value="1" name=""></td>--}}
53 <td><?php echo $n; ?></td> 53 <td><?php echo $n; ?></td>
54 <td>{{ $v->email }}</td> 54 <td>{{ $v->email }}</td>
55 <td>{{ $v->title }}</td> 55 <td>{{ $v->title }}</td>
@@ -63,7 +63,20 @@ @@ -63,7 +63,20 @@
63 <span class="label btn-warning radius">待审核</span> 63 <span class="label btn-warning radius">待审核</span>
64 @endif 64 @endif
65 </td> 65 </td>
66 - <td class="td-manage"> <!-- <a href="javascript:;" onclick="invitation_show('查看帖子','/admin/invitation/detail','','510')" class="btn btn-secondary radius">查看</a> --><a href="/admin/invitation/check/{{ $v->id }}" class="btn btn-secondary radius">审核通过</a>&nbsp;<a href="javascript:;" onclick="invitation_show('查看帖子','<?php echo '/admin/invitation/dels/'.$v->id ?>','','1000')" class="btn btn-danger radius">审核不通过</a></td> 66 + <td class="td-manage">
  67 + <!-- <a href="javascript:;" onclick="invitation_show('查看帖子','/admin/invitation/detail','','510')" class="btn btn-secondary radius">查看</a> -->
  68 + @if ($v->is_audit == 0)
  69 + <a onClick="submitTiJiao({{$v->id}})" class="btn btn-secondary radius">审核通过</a>
  70 + @else
  71 + <a href="/" class="btn btn-default radius disabled">审核通过</a>
  72 + @endif
  73 + &nbsp;
  74 + @if ($v->is_audit == 0)
  75 + <a href="javascript:;" onclick="invitation_show('查看帖子','<?php echo '/admin/invitation/dels/'.$v->id ?>','','1000')" class="btn btn-danger radius">审核不通过</a>
  76 + @else
  77 + <a href="/" class="btn btn-default radius disabled">审核不通过</a>
  78 + @endif
  79 + </td>
67 </tr> 80 </tr>
68 <?php $n++; ?> 81 <?php $n++; ?>
69 @endforeach 82 @endforeach
@@ -88,25 +101,6 @@ @@ -88,25 +101,6 @@
88 <script type="text/javascript" src="/admin/lib/datatables/1.10.15/jquery.dataTables.min.js"></script> 101 <script type="text/javascript" src="/admin/lib/datatables/1.10.15/jquery.dataTables.min.js"></script>
89 <script type="text/javascript" src="/admin/lib/laypage/1.2/laypage.js"></script> 102 <script type="text/javascript" src="/admin/lib/laypage/1.2/laypage.js"></script>
90 <script type="text/javascript"> 103 <script type="text/javascript">
91 -// $(function(){  
92 -// $('.table-sort').dataTable({  
93 -// "aaSorting": [[ 1, "desc" ]],//默认第几个排序  
94 -// "bStateSave": true,//状态保存  
95 -// "aoColumnDefs": [  
96 -// //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示  
97 -// {"orderable":false,"aTargets":[0,8,9]}// 制定列不参与排序  
98 -// ]  
99 -// });  
100 -// $('.table-sort tbody').on( 'click', 'tr', function () {  
101 -// if ( $(this).hasClass('selected') ) {  
102 -// $(this).removeClass('selected');  
103 -// }  
104 -// else {  
105 -// table.$('tr.selected').removeClass('selected');  
106 -// $(this).addClass('selected');  
107 -// }  
108 -// });  
109 -// });  
110 /*帖子-添加*/ 104 /*帖子-添加*/
111 function member_add(title,url,w,h){ 105 function member_add(title,url,w,h){
112 layer_show(title,url,w,h); 106 layer_show(title,url,w,h);
@@ -115,6 +109,37 @@ function member_add(title,url,w,h){ @@ -115,6 +109,37 @@ function member_add(title,url,w,h){
115 function invitation_show(title,url,id,w,h){ 109 function invitation_show(title,url,id,w,h){
116 layer_show(title,url,w,h); 110 layer_show(title,url,w,h);
117 } 111 }
  112 +
  113 +function submitTiJiao(id) {
  114 +
  115 + //ajax提交
  116 + $.ajax({
  117 + type: 'get',
  118 + url: '{{url("admin/invitation/check/")}}'+'/'+id,
  119 + dataType: 'json',
  120 + success:function(msg){
  121 + //msg服务器返回json格式数据
  122 + if(msg.info == 1){
  123 + // $("#modal-demo").modal("show")
  124 + $("body").Huimodalalert({
  125 + content: '提交成功',
  126 + speed: 300
  127 + })
  128 +
  129 + setTimeout (function(){
  130 + //插入成功
  131 + parent.window.location.href = parent.window.location.href;
  132 + layer_close();
  133 + },800);
  134 + }
  135 + else{
  136 + //插入失败
  137 + layer.msg('提交失败'+msg.error,{icon:5,time:2000});
  138 + }
  139 + }
  140 +
  141 + });
  142 +}
118 </script> 143 </script>
119 <!--/请在上方写此页面业务相关的脚本--> 144 <!--/请在上方写此页面业务相关的脚本-->
120 </body> 145 </body>
@@ -30,7 +30,41 @@ @@ -30,7 +30,41 @@
30 <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script> 30 <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
31 <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script> 31 <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
32 <script type="text/javascript"> 32 <script type="text/javascript">
  33 + $('#form-member-add').submit(function(event){
  34 + //阻止表单的默认提交
  35 + event.preventDefault();
  36 + //获取表单数据
  37 + var data = $(this).serialize();
33 38
  39 + //ajax提交
  40 + $.ajax({
  41 + type: 'post',
  42 + url: '{{url("admin/tag/create")}}',
  43 + data: data,
  44 + dataType: 'json',
  45 + success:function(msg){
  46 + //msg服务器返回json格式数据
  47 + if(msg.info == 1){
  48 + // $("#modal-demo").modal("show")
  49 + $("body").Huimodalalert({
  50 + content: '提交成功',
  51 + speed: 500
  52 + })
  53 +
  54 + setTimeout (function(){
  55 + //插入成功
  56 + parent.window.location.href = parent.window.location.href;
  57 + layer_close();
  58 + },1000);
  59 + }
  60 + else{
  61 + //插入失败
  62 + layer.msg('提交失败'+msg.error,{icon:5,time:2000});
  63 + }
  64 + }
  65 +
  66 + });
  67 + });
34 </script> 68 </script>
35 <!--/请在上方写此页面业务相关的脚本--> 69 <!--/请在上方写此页面业务相关的脚本-->
36 </body> 70 </body>
@@ -45,11 +45,11 @@ @@ -45,11 +45,11 @@
45 <td>{{$v->name}}</td> 45 <td>{{$v->name}}</td>
46 <td class="td-manage"> 46 <td class="td-manage">
47 @if($v->is_enable == 1) 47 @if($v->is_enable == 1)
48 - <a href="/admin/tag/status/{{ $v->id }}/{{ $v->is_enable }}" class="btn btn-warning radius">禁用</a> 48 + <a onClick="submitStatus({{$v->id}}, {{ $v->is_enable }})" class="btn btn-warning radius">禁用</a>
49 @else 49 @else
50 - <a href="/admin/tag/status/{{ $v->id }}/{{ $v->is_enable }}" class="btn btn-success radius">启用</a> 50 + <a onClick="submitStatus({{$v->id}}, {{ $v->is_enable }})" class="btn btn-success radius">启用</a>
51 @endif 51 @endif
52 - &nbsp;<a href="/admin/tag/del/{{ $v->id }}" class="btn btn-danger radius">删除</a></td> 52 + &nbsp;<a onClick="submitDel({{$v->id}})" class="btn btn-danger radius">删除</a></td>
53 </tr> 53 </tr>
54 <?php $n++; ?> 54 <?php $n++; ?>
55 @endforeach 55 @endforeach
@@ -81,6 +81,68 @@ @@ -81,6 +81,68 @@
81 function tag_add(title,url,w,h){ 81 function tag_add(title,url,w,h){
82 layer_show(title,url,w,h); 82 layer_show(title,url,w,h);
83 } 83 }
  84 +
  85 +function submitDel(id) {
  86 +
  87 + //ajax提交
  88 + $.ajax({
  89 + type: 'get',
  90 + url: '{{url("admin/tag/del/")}}'+'/'+id,
  91 + dataType: 'json',
  92 + success:function(msg){
  93 + //msg服务器返回json格式数据
  94 + if(msg.info == 1){
  95 + // $("#modal-demo").modal("show")
  96 + $("body").Huimodalalert({
  97 + content: '删除成功',
  98 + speed: 300
  99 + })
  100 +
  101 + setTimeout (function(){
  102 + //插入成功
  103 + parent.window.location.href = parent.window.location.href;
  104 + layer_close();
  105 + },800);
  106 + }
  107 + else{
  108 + //插入失败
  109 + layer.msg('删除失败'+msg.error,{icon:5,time:2000});
  110 + }
  111 + }
  112 +
  113 + });
  114 +}
  115 +
  116 +function submitStatus(id, entable) {
  117 +
  118 + //ajax提交
  119 + $.ajax({
  120 + type: 'get',
  121 + url: '{{url("admin/tag/status/")}}' + '/' + id + '/'+ entable,
  122 + dataType: 'json',
  123 + success:function(msg){
  124 + //msg服务器返回json格式数据
  125 + if(msg.info == 1){
  126 + // $("#modal-demo").modal("show")
  127 + $("body").Huimodalalert({
  128 + content: msg.res,
  129 + speed: 300
  130 + })
  131 +
  132 + setTimeout (function(){
  133 + //插入成功
  134 + parent.window.location.href = parent.window.location.href;
  135 + layer_close();
  136 + },800);
  137 + }
  138 + else{
  139 + //插入失败
  140 + layer.msg('更改状态失败'+msg.error,{icon:5,time:2000});
  141 + }
  142 + }
  143 +
  144 + });
  145 +}
84 </script> 146 </script>
85 <!--/请在上方写此页面业务相关的脚本--> 147 <!--/请在上方写此页面业务相关的脚本-->
86 </body> 148 </body>