xxxrrrdddd 2 年之前
父节点
当前提交
781328e425

+ 74 - 0
application/admin/controller/Network.php

@@ -0,0 +1,74 @@
+<?php
+
+namespace app\admin\controller;
+
+use app\common\controller\Backend;
+
+/**
+ * 运营商
+ *
+ * @icon fa fa-circle-o
+ */
+class Network extends Backend
+{
+    
+    /**
+     * Network模型对象
+     * @var \app\admin\model\Network
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\Network;
+
+    }
+
+    public function import()
+    {
+        parent::import();
+    }
+
+    /**
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     */
+    
+
+    /**
+     * 查看
+     */
+    public function index()
+    {
+        //当前是否为关联查询
+        $this->relationSearch = false;
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if ($this->request->isAjax()) {
+            //如果发送的来源是Selectpage,则转发到Selectpage
+            if ($this->request->request('keyField')) {
+                return $this->selectpage();
+            }
+            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+
+            $list = $this->model
+                    
+                    ->where($where)
+                    ->order($sort, $order)
+                    ->paginate($limit);
+
+            foreach ($list as $row) {
+                $row->visible(['id','no_field','name','create_time','update_time']);
+                
+            }
+
+            $result = array("total" => $list->total(), "rows" => $list->items());
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+
+}

+ 1 - 0
application/admin/lang/zh-cn.php

@@ -96,6 +96,7 @@ return [
     'Begin time'                                            => '开始时间',
     'End time'                                              => '结束时间',
     'Create time'                                           => '创建时间',
+    'Create_time'                                           => '创建时间',
     'Update time'                                           => '更新时间',
     'Createtime'                                            => '创建时间',
     'Updatetime'                                            => '更新时间',

+ 6 - 0
application/admin/lang/zh-cn/network.php

@@ -0,0 +1,6 @@
+<?php
+
+return [
+    'No_field' => '号段',
+    'Name'     => '运营商名称'
+];

+ 12 - 0
application/admin/model/Network.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+
+class Network extends Model
+{
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = true;
+}

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

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

+ 22 - 0
application/admin/view/network/add.html

@@ -0,0 +1,22 @@
+<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">{:__('No_field')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-no_field" class="form-control" name="row[no_field]" type="number">
+        </div>
+    </div>
+    <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 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>

+ 22 - 0
application/admin/view/network/edit.html

@@ -0,0 +1,22 @@
+<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">{:__('No_field')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-no_field" class="form-control" name="row[no_field]" type="number" value="{$row.no_field|htmlentities}">
+        </div>
+    </div>
+    <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 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>

+ 35 - 0
application/admin/view/network/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('network/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('network/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('network/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('network/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('network/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('network/edit')}" 
+                           data-operate-del="{:$auth->check('network/del')}" 
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 1 - 0
application/api/controller/MobileController.php

@@ -65,6 +65,7 @@ class MobileController extends UserApi
      * @ApiReturnParams (name=is_activity,description=是否特价号)
      * @ApiReturnParams (name=activity_time_end,description=特价过期时间null永不过期)
      * @ApiReturnParams (name=view_count,description=正在浏览人数)
+     * @ApiReturnParams (name=is_private,description=是否民营运营商)
      * @ApiReturnParams (name="info.free_app",description=免流APP列表)
      * @ApiReturnParams (name="info.describe",description="套餐说明|资费详情")
      * @ApiReturnParams (name="info.content",description="详细内容|注意事项")

+ 6 - 0
application/common/model/Mobile.php

@@ -29,6 +29,7 @@ class Mobile extends Model
     ];
     protected $append=[
         'saled',
+        'is_private',
     ];
     protected $autoWriteTimestamp='int';
     protected $hidden=[];
@@ -52,6 +53,11 @@ class Mobile extends Model
         $s=$b['status']??0;
         return $s===1?1:0;
     }
+    #是否是民营
+    public function getIsPrivateAttr($_,$data){
+        $network=$data['network']?:'';
+        return mb_strpos($network,'中国')!==false;
+    }
     public function getLogoAttr($logo,$data=[]){
         if($logo){
             $arr=explode(',',$logo);

+ 52 - 0
public/assets/js/backend/network.js

@@ -0,0 +1,52 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'network/index' + location.search,
+                    add_url: 'network/add',
+                    edit_url: 'network/edit',
+                    del_url: 'network/del',
+                    multi_url: 'network/multi',
+                    import_url: 'network/import',
+                    table: 'network',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id')},
+                        {field: 'no_field', title: __('No_field')},
+                        {field: 'name', title: __('Name')},
+                        {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;
+});