Selaa lähdekoodia

增加优惠券

15954078560 2 vuotta sitten
vanhempi
commit
45c487b5c8

+ 101 - 0
application/admin/controller/Coupon.php

@@ -0,0 +1,101 @@
+<?php
+
+namespace app\admin\controller;
+
+use app\common\controller\Backend;
+use Think\Db;
+
+/**
+ * 优惠券管理
+ *
+ * @icon fa fa-circle-o
+ */
+class Coupon extends Backend
+{
+
+    /**
+     * Coupon模型对象
+     * @var \app\admin\model\Coupon
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\Coupon;
+        $this->view->assign("typeList", $this->model->getTypeList());
+        $this->view->assign("purposeList", $this->model->getPurposeList());
+        $this->view->assign("statusList", $this->model->getStatusList());
+    }
+
+
+
+    /**
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     */
+
+    //修改优惠券状态
+    public function chanagestatus() {
+        $ids = input('ids', 0, 'intval'); //优惠券id
+        $status = input('status', 0, 'intval'); //状态:1=发布,2=下架
+
+        if (!$ids) {
+            $this->error('参数缺失');
+        }
+        if (!in_array($status, [1, 2])) {
+            $this->error('参数错误');
+        }
+
+        $info = Db::name('coupon')->find($ids);
+        if (!$info) {
+            $this->error('优惠券不存在');
+        }
+        if ($status == 1 && $info['status'] != 0) {
+            $this->error('优惠券状态已改变');
+        }
+        if ($status == 2) {
+            if ($info['status'] != 1) {
+                $this->error('优惠券状态已改变');
+            }
+            if ($info['purpose'] == 0) { //获得方式:0=充值,1=注册,2=推广,3=后台发放,4=轮播图,5=报名活动
+                //判断是否有绑定充值
+                $count = Db::name('recharge')->where(['coupon_id' => $ids])->find();
+                if ($count) {
+                    $this->error('请先取消该优惠券与充值列表的绑定关系');
+                }
+            }
+        }
+
+        $rs = Db::name('coupon')->where(['id' => $ids, 'status' => $info['status']])->setField('status', $status);
+        if (!$rs) {
+            $this->error('操作失败');
+        }
+
+        $this->success('操作成功');
+    }
+
+    /**
+     * 删除
+     */
+    public function delcoupon($ids = "")
+    {
+        if (!$this->request->isPost()) {
+            $this->error(__("Invalid parameters"));
+        }
+        $ids = $ids ? $ids : $this->request->post("ids");
+
+        $info = Db::name('coupon')->find($ids);
+        if (!$info) {
+            $this->error('操作成功');
+        }
+        if ($info['status'] != 2) {
+            $this->error('请先下架优惠券');
+        }
+
+        Db::name('coupon')->delete($ids);
+        $this->success('操作成功');
+    }
+
+}

+ 37 - 0
application/admin/controller/Platforminfo.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace app\admin\controller;
+
+use app\common\controller\Backend;
+
+/**
+ * 平台信息管理
+ *
+ * @icon fa fa-circle-o
+ */
+class Platforminfo extends Backend
+{
+
+    /**
+     * Platforminfo模型对象
+     * @var \app\admin\model\Platforminfo
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\Platforminfo;
+        $this->view->assign("typeList", $this->model->getTypeList());
+    }
+
+
+
+    /**
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     */
+
+
+}

+ 27 - 0
application/admin/lang/zh-cn/coupon.php

@@ -0,0 +1,27 @@
+<?php
+
+return [
+    'Id'           => 'ID',
+    'Title'        => '标题',
+    'Desc'         => '描述',
+    'Type'         => '类型',
+    'Type 1'       => '打折券',
+    'Type 2'       => '抵扣券',
+    'Money'        => '抵扣券面值金额或者打折券(百分比)折数',
+    'Minmoney'     => '抵扣券最低消费金额(满多少可用)',
+    'Purpose'      => '获得方式',
+    'Purpose 0'    => '充值',
+    'Purpose 1'    => '注册',
+    'Purpose 2'    => '推广',
+    'Purpose 3'    => '后台发放',
+    'Purpose 4'    => '轮播图',
+    'Purpose 5'    => '报名活动',
+    'Effectiveday' => '有效天数',
+    'Weigh'        => '权重排序',
+    'Status'       => '状态',
+    'Status 0'     => '待发布',
+    'Status 1'     => '已发布',
+    'Status 2'     => '已下架',
+    'Createtime'   => '创建时间',
+    'Updatetime'   => '更新时间'
+];

+ 14 - 0
application/admin/lang/zh-cn/platforminfo.php

@@ -0,0 +1,14 @@
+<?php
+
+return [
+    'Id'         => '主键ID',
+    'Type'       => '类型',
+    'Type 1'     => '关于我们',
+    'Type 2'     => '免责协议',
+    'Type 3'     => '用户协议',
+    'Type 4'     => '隐私政策',
+    'Title'      => '标题',
+    'Content'    => '内容',
+    'Createtime' => '创建时间',
+    'Updatetime' => '更新时间'
+];

+ 85 - 0
application/admin/model/Coupon.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+
+class Coupon extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'coupon';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+        'type_text',
+        'purpose_text',
+        'status_text'
+    ];
+    
+
+    protected static function init()
+    {
+        self::afterInsert(function ($row) {
+            $pk = $row->getPk();
+            $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
+        });
+    }
+
+    
+    public function getTypeList()
+    {
+        return ['1' => __('Type 1'), '2' => __('Type 2')];
+    }
+
+    public function getPurposeList()
+    {
+        return ['0' => __('Purpose 0'), '1' => __('Purpose 1'), '2' => __('Purpose 2'), '3' => __('Purpose 3'), '4' => __('Purpose 4'), '5' => __('Purpose 5')];
+    }
+
+    public function getStatusList()
+    {
+        return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2')];
+    }
+
+
+    public function getTypeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
+        $list = $this->getTypeList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+
+    public function getPurposeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['purpose']) ? $data['purpose'] : '');
+        $list = $this->getPurposeList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+
+    public function getStatusTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+        $list = $this->getStatusList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+
+
+
+}

+ 49 - 0
application/admin/model/Platforminfo.php

@@ -0,0 +1,49 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+
+class Platforminfo extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'platform_info';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+        'type_text'
+    ];
+    
+
+    
+    public function getTypeList()
+    {
+        return ['1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3'), '4' => __('Type 4')];
+    }
+
+
+    public function getTypeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
+        $list = $this->getTypeList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+
+
+
+}

+ 27 - 0
application/admin/validate/Coupon.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace app\admin\validate;
+
+use think\Validate;
+
+class Coupon extends Validate
+{
+    /**
+     * 验证规则
+     */
+    protected $rule = [
+    ];
+    /**
+     * 提示消息
+     */
+    protected $message = [
+    ];
+    /**
+     * 验证场景
+     */
+    protected $scene = [
+        'add'  => [],
+        'edit' => [],
+    ];
+    
+}

+ 27 - 0
application/admin/validate/Platforminfo.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace app\admin\validate;
+
+use think\Validate;
+
+class Platforminfo extends Validate
+{
+    /**
+     * 验证规则
+     */
+    protected $rule = [
+    ];
+    /**
+     * 提示消息
+     */
+    protected $message = [
+    ];
+    /**
+     * 验证场景
+     */
+    protected $scene = [
+        'add'  => [],
+        'edit' => [],
+    ];
+    
+}

+ 82 - 0
application/admin/view/coupon/add.html

@@ -0,0 +1,82 @@
+<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">{:__('Title')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Desc')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-desc" data-rule="required" class="form-control" name="row[desc]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
+                {foreach name="typeList" item="vo"}
+                    <option value="{$key}" {in name="key" value="0"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Money')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-money" data-rule="required" class="form-control" name="row[money]" type="number" value="0">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Minmoney')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-minmoney" data-rule="required" class="form-control" name="row[minmoney]" type="number" value="0">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Purpose')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-purpose" data-rule="required" class="form-control selectpicker" name="row[purpose]">
+                {foreach name="purposeList" item="vo"}
+                    <option value="{$key}" {in name="key" value="0"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Effectiveday')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-effectiveday" data-rule="required" class="form-control" name="row[effectiveday]" type="number" value="0">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-weigh" data-rule="required" class="form-control" name="row[weigh]" type="number" value="0">
+        </div>
+    </div>
+    <!--<div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            
+            <div class="radio">
+            {foreach name="statusList" item="vo"}
+            <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="0"}checked{/in} /> {$vo}</label> 
+            {/foreach}
+            </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">
+            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 82 - 0
application/admin/view/coupon/edit.html

@@ -0,0 +1,82 @@
+<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">{:__('Title')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Desc')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-desc" data-rule="required" class="form-control" name="row[desc]" type="text" value="{$row.desc|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
+                {foreach name="typeList" item="vo"}
+                    <option value="{$key}" {in name="key" value="$row.type"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Money')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-money" data-rule="required" class="form-control" name="row[money]" type="number" value="{$row.money|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Minmoney')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-minmoney" data-rule="required" class="form-control" name="row[minmoney]" type="number" value="{$row.minmoney|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Purpose')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-purpose" data-rule="required" class="form-control selectpicker" name="row[purpose]">
+                {foreach name="purposeList" item="vo"}
+                    <option value="{$key}" {in name="key" value="$row.purpose"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Effectiveday')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-effectiveday" data-rule="required" class="form-control" name="row[effectiveday]" type="number" value="{$row.effectiveday|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-weigh" data-rule="required" class="form-control" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            
+            <div class="radio">
+            {foreach name="statusList" item="vo"}
+            <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label> 
+            {/foreach}
+            </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">
+            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 45 - 0
application/admin/view/coupon/index.html

@@ -0,0 +1,45 @@
+<div class="panel panel-default panel-intro">
+    
+    <div class="panel-heading">
+        {:build_heading(null,FALSE)}
+        <ul class="nav nav-tabs" data-field="status">
+            <li class="{:$Think.get.status === null ? 'active' : ''}"><a href="#t-all" data-value="" data-toggle="tab">{:__('All')}</a></li>
+            {foreach name="statusList" item="vo"}
+            <li class="{:$Think.get.status === (string)$key ? 'active' : ''}"><a href="#t-{$key}" data-value="{$key}" data-toggle="tab">{$vo}</a></li>
+            {/foreach}
+        </ul>
+    </div>
+
+
+    <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('coupon/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('coupon/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('coupon/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>-->
+                        
+
+                        <!--<div class="dropdown btn-group {:$auth->check('coupon/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('coupon/edit')}"
+                           data-operate-del="{:$auth->check('coupon/del')}"
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 34 - 0
application/admin/view/platforminfo/add.html

@@ -0,0 +1,34 @@
+<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">{:__('Type')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
+                {foreach name="typeList" item="vo"}
+                    <option value="{$key}" {in name="key" value="1"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="">
+        </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 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-primary btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 34 - 0
application/admin/view/platforminfo/edit.html

@@ -0,0 +1,34 @@
+<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">{:__('Type')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
+                {foreach name="typeList" item="vo"}
+                    <option value="{$key}" {in name="key" value="$row.type"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>-->
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-title" data-rule="required" readonly class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}">
+        </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 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-primary btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 35 - 0
application/admin/view/platforminfo/index.html

@@ -0,0 +1,35 @@
+<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('platforminfo/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('platforminfo/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('platforminfo/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>-->
+                        
+
+                       <!-- <div class="dropdown btn-group {:$auth->check('platforminfo/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('platforminfo/edit')}"
+                           data-operate-del="{:$auth->check('platforminfo/del')}"
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 162 - 0
public/assets/js/backend/coupon.js

@@ -0,0 +1,162 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'coupon/index' + location.search,
+                    add_url: 'coupon/add',
+                    // edit_url: 'coupon/edit',
+                    // del_url: 'coupon/del',
+                    multi_url: 'coupon/multi',
+                    import_url: 'coupon/import',
+                    table: 'coupon',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'weigh',
+                fixedColumns: true,
+                fixedRightNumber: 1,
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id')},
+                        {field: 'title', title: __('Title'), operate: 'LIKE'},
+                        {field: 'desc', title: __('Desc'), operate: 'LIKE'},
+                        {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
+                        {field: 'money', title: __('Money')},
+                        {field: 'minmoney', title: __('Minmoney')},
+                        {field: 'purpose', title: __('Purpose'), searchList: {"0":__('Purpose 0'),"1":__('Purpose 1'),"2":__('Purpose 2'),"3":__('Purpose 3'),"4":__('Purpose 4'),"5":__('Purpose 5')}, formatter: Table.api.formatter.normal},
+                        {field: 'effectiveday', title: __('Effectiveday')},
+                        {field: 'weigh', title: __('Weigh'), operate: false},
+                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
+                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
+                            buttons: [
+                                {
+                                    name: 'chanagestatus',
+                                    text: '发布',
+                                    title: __('发布'),
+                                    extend: 'data-area=\'["85%", "85%"]\'',
+                                    classname: 'btn btn-xs btn-success btn-ajax',
+                                    icon: 'fa fa-pencil',
+                                    confirm: '确认发布?',
+                                    url: 'coupon/chanagestatus/status/1',
+                                    refresh: true,
+                                    // success: function (data, ret) {
+                                    //     // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
+                                    //     Layer.alert(ret.msg);
+                                    //     //如果需要阻止成功提示,则必须使用return false;
+                                    //     return false;
+                                    // },
+                                    // error: function (data, ret) {
+                                    //     // console.log(data, ret);
+                                    //     Layer.alert(ret.msg);
+                                    //     return false;
+                                    // },
+                                    // callback: function (data) {
+                                    //     Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
+                                    // },
+                                    visible: function (row) {
+                                        if (row.status == 0) {
+                                            return true;
+                                        } else  {
+                                            return false;
+                                        }
+                                    }
+                                },
+                                {
+                                    name: 'chanagestatus',
+                                    text: '下架',
+                                    title: __('下架'),
+                                    extend: 'data-area=\'["85%", "85%"]\'',
+                                    classname: 'btn btn-xs btn-danger btn-ajax',
+                                    icon: 'fa fa-pencil',
+                                    confirm: '确认下架?',
+                                    url: 'coupon/chanagestatus/status/2',
+                                    refresh: true,
+                                    // success: function (data, ret) {
+                                    //     // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
+                                    //     Layer.alert(ret.msg);
+                                    //     //如果需要阻止成功提示,则必须使用return false;
+                                    //     return false;
+                                    // },
+                                    // error: function (data, ret) {
+                                    //     // console.log(data, ret);
+                                    //     Layer.alert(ret.msg);
+                                    //     return false;
+                                    // },
+                                    // callback: function (data) {
+                                    //     Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
+                                    // }
+                                    visible : function (row) {
+                                        if (row.status == 1) {
+                                            return true;
+                                        } else  {
+                                            return false;
+                                        }
+                                    }
+                                },
+                                {
+                                    name: 'delcoupon',
+                                    text: '删除',
+                                    title: __('删除'),
+                                    extend: 'data-area=\'["85%", "85%"]\'',
+                                    classname: 'btn btn-xs btn-danger btn-ajax',
+                                    icon: 'fa fa-trash',
+                                    confirm: '确认删除?',
+                                    url: 'coupon/delcoupon',
+                                    refresh: true,
+                                    // success: function (data, ret) {
+                                    //     // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
+                                    //     Layer.alert(ret.msg);
+                                    //     //如果需要阻止成功提示,则必须使用return false;
+                                    //     return false;
+                                    // },
+                                    // error: function (data, ret) {
+                                    //     // console.log(data, ret);
+                                    //     Layer.alert(ret.msg);
+                                    //     return false;
+                                    // },
+                                    // callback: function (data) {
+                                    //     Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
+                                    // }
+                                    visible : function (row) {
+                                        if (row.status == 2) {
+                                            return true;
+                                        } else  {
+                                            return false;
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            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;
+});

+ 55 - 0
public/assets/js/backend/platforminfo.js

@@ -0,0 +1,55 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'platforminfo/index' + location.search,
+                    // add_url: 'platforminfo/add',
+                    edit_url: 'platforminfo/edit',
+                    // del_url: 'platforminfo/del',
+                    multi_url: 'platforminfo/multi',
+                    import_url: 'platforminfo/import',
+                    table: 'platform_info',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                sortOrder: 'asc',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id')},
+                        // {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3'),"4":__('Type 4')}, formatter: Table.api.formatter.normal},
+                        {field: 'title', title: __('Title'), operate: 'LIKE'},
+                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, 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;
+});