123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- <style type="text/css">
- .pagination{
- margin:0 !important;
- }
- </style>
- <div class="ibox float-e-margins">
- <div class="ibox-content" style="display: block;">
- <form action="{{ route('admin.course.coupons.index') }}" method="get" class="form-horizontal">
- <div class="col-md-9">
- <a href="{{ route('admin.course.coupons.create') }}" method="POST" class="btn btn-primary margin-bottom" no-pjax>添加优惠券</a>
- </div>
- <div class="col-md-3">
- <div class="form-group">
- <div class="input-group search_text">
- <input type="text" name="search" placeholder="优惠券名称" value="{{!empty(request('search'))?request('search'):''}}" class=" form-control"> <span class="input-group-btn"><button type="submit" class="btn btn-primary">查找</button></span>
- </div>
- </div>
- </div>
- </form>
- <div class="box-body table-responsive">
- <table class="table table-hover table-bordered" id="list_table">
- <thead>
- <tr>
- <th>优惠券名称</th>
- <th>类型</th>
- <th>起止时间</th>
- <th>有效时间</th>
- <th>抵用金额</th>
- <th>满*使用</th>
- <th>优惠折扣</th>
- <th>次数/名额</th>
- <th>抵扣类型</th>
- <th>是否启用</th>
- <th>操作</th>
- </tr>
- </thead>
- @if(count($coupons)>0)
- <tbody>
- @foreach($coupons as $value)
- <tr id="{{ $value->id }}">
- <td>
- {{ $value->name }}
- </td>
- <td>
- @if($value->type==1)现金券
- @elseif($value->type==2)活动券
- @elseif($value->type==3)折扣券
- @endif
- </td>
- <td>
- @if(!empty($value->start_time) && !empty($value->end_time))
- {{ $value->start_time }} - {{ $value->end_time }}
- @else
- 无限制
- @endif
- </td>
- <td>
- @if(!empty($value->use_day))
- {{ $value->use_day }}
- @if($value->date=='1')天
- @elseif($value->date=='2')月
- @elseif($value->date=='3')年
- @endif
- @else
- 永久
- @endif
- </td>
- <td>
- {{ $value->amount }}
- </td>
- <td>
- {{ $value->min_limit_amount }}
- </td>
- <td>
- @if($value->discount=='0')
- 无折扣
- @else
- {{ $value->discount }}
- @endif
- </td>
- <td>
- {{ $value->num }}
- </td>
- <td>
- @if(!empty($value->num_type))
- @if($value->num_type=='1')活动
- @elseif($value->num_type=='2')课程
- @elseif($value->num_type=='3')线上博物馆
- @endif
- @else
- 无
- @endif
- </td>
- <td><a class="status" cid="{{$value->id}}" status="{{$value->status}}">
- <i class="fa @if($value->status==1) fa-toggle-on @else fa-toggle-off @endif"></i></a></td>
- <td>
- <a href="{{ route('admin.course.coupons.edit',['id' => $value->id]) }}" class="btn btn-xs btn-primary">
- <i class="fa fa-pencil" data-toggle="tooltip" data-placement="top" title="编辑"></i>
- </a>
- <button onclick="checkCategory({{$value->id}})" class="btn btn-xs btn-danger">
- <i class="fa fa-trash" data-toggle="tooltip" data-placement="top" title="删除"></i>
- </button>
- </td>
- </tr>
- @endforeach
- </tbody>
- <tfoot>
- <tr>
- <td colspan="12">
- <div class="pull-left">
- 共 {!! $coupons->total() !!} 条记录
- </div>
- <div class="pull-right">
- {!! $coupons->appends(request()->except('page'))->render() !!}
- </div>
- </td>
- </tr>
- </tfoot>
- @else
- <tfoot>
- <tr>
- <td colspan="10">
- 当前无数据
- </td>
- </tr>
- </tfoot>
- @endif
- </table>
- </div>
- </div>
- <!-- /.col-lg-12 -->
- </div>
- <!-- /.row -->
- <script language="javascript">
- //折叠展示
- function displayData(_self) {
- if (_self.alt == "关闭") {
- jqshow($(_self).parent().parent().attr('id'), 'hide');
- $(_self).attr("src", "{!! url('assets/backend/images/open.gif') !!}");
- _self.alt = '打开';
- }
- else {
- jqshow($(_self).parent().parent().attr('id'), 'show');
- $(_self).attr("src", "{!! url('assets/backend/images/close.gif') !!}");
- _self.alt = '关闭';
- }
- }
- function jqshow(id, isshow) {
- var obj = $("#list_table tr[parent='" + id + "']");
- if (obj.length > 0) {
- obj.each(function (i) {
- jqshow($(this).attr('id'), isshow);
- });
- if (isshow == 'hide') {
- obj.hide();
- }
- else {
- obj.show();
- }
- }
- }
- //排序
- function toSort(id) {
- if (id != '') {
- var va = $('#s' + id).val();
- var part = /^\d+$/i;
- if (va != '' && va != undefined && part.test(va)) {
- $.get("{{ route('admin.course.advertising.advertising_sort') }}", {
- 'id': id,
- 'sort': va,
- _token: _token
- }, function (data) {
- if (data.status) {
- swal({
- title: "修改分类排序成功!",
- text: "",
- type: "success"
- }, function() {
- location.reload();
- });
- } else {
- swal("修改分类排序失败!", "", "error");
- }
- });
- }
- }
- }
- function checkCategory(id) {
- $.get("{{ route('admin.course.coupons.check') }}", {
- 'id': id,
- _token: _token
- }, function (data) {
- if (data.status) {
- deleteCategory(id);
- } else {
- swal('注意','该优惠券正在使用不能删除','warning');
- }
- });
- }
- function deleteCategory(id) {
- $.post("{{ route('admin.course.coupons.delete') }}", {
- 'id': id,
- _token: _token
- }, function (data) {
- if (data.status) {
- swal({
- title: "删除成功!",
- text: "",
- type: "success"
- }, function() {
- location.reload();
- });
- } else {
- swal("删除失败!", "该广告信息有误", "error");
- }
- });
- }
- $('.status').on('click', function () {
- var value = $(this).attr('status');
- var modelId = $(this).attr('cid');
- value = parseInt(value);
- modelId = parseInt(modelId);
- if (value == 1) {
- value = 0;
- } else {
- value = 1;
- }
- var that = $(this);
- $.post("{{route('admin.course.coupons.status')}}",
- {
- status: value,
- modelId: modelId
- },
- function (data, status) {
- console.log(data,status);
- if (status) {
- if (1 == value) {
- that.children().removeClass('fa-toggle-off');
- that.children().addClass('fa-toggle-on');
- that.attr('status',1);
- } else {
- that.children().removeClass('fa-toggle-on');
- that.children().addClass('fa-toggle-off');
- that.attr('status',0);
- }
- }
- });
- });
- </script>
|