18315626215 5 rokov pred
rodič
commit
3620e9ceb3

+ 76 - 0
application/admin/controller/agreemen/Agreem.php

@@ -0,0 +1,76 @@
+<?php
+
+namespace app\admin\controller\agreemen;
+
+use app\common\controller\Backend;
+
+/**
+ * 
+ *
+ * @icon fa fa-circle-o
+ */
+class Agreem extends Backend
+{
+    
+    /**
+     * Agreem模型对象
+     * @var \app\admin\model\agreemen\Agreem
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\agreemen\Agreem;
+
+    }
+    
+    /**
+     * 默认生成的控制器所继承的父类中有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();
+            $total = $this->model
+                    
+                    ->where($where)
+                    ->order($sort, $order)
+                    ->count();
+
+            $list = $this->model
+                    
+                    ->where($where)
+                    ->order($sort, $order)
+                    ->limit($offset, $limit)
+                    ->select();
+
+            foreach ($list as $row) {
+                $row->visible(['a_id','agreement_content']);
+                
+            }
+            $list = collection($list)->toArray();
+            $result = array("total" => $total, "rows" => $list);
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+}

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

@@ -0,0 +1,6 @@
+<?php
+
+return [
+    'Agreement_content' => '注册协议',
+    'Type'              => '0协议'
+];

+ 22 - 0
application/admin/view/agreemen/agreem/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">{:__('Agreement_content')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <textarea id="c-agreement_content" data-rule="required" class="form-control editor" rows="5" name="row[agreement_content]" cols="50"></textarea>
+        </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">
+            <input id="c-type" data-rule="required" class="form-control" name="row[type]" type="number">
+        </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/agreemen/agreem/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">{:__('Agreement_content')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <textarea id="c-agreement_content" data-rule="required" class="form-control editor" rows="5" name="row[agreement_content]" cols="50">{$row.agreement_content|htmlentities}</textarea>
+        </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">
+            <input id="c-type" data-rule="required" class="form-control" name="row[type]" type="number" value="{$row.type|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/agreemen/agreem/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('agreemen/agreem/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('agreemen/agreem/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('agreemen/agreem/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('agreemen/agreem/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('agreemen/agreem/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('agreemen/agreem/edit')}" 
+                           data-operate-del="{:$auth->check('agreemen/agreem/del')}" 
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 78 - 0
application/api/controller/Login.php

@@ -0,0 +1,78 @@
+<?php
+
+namespace app\api\controller;
+
+use app\api\model\UsersModel;
+use app\common\controller\Api;
+use think\Db;
+
+/**
+ * 登录接口
+ */
+class Login extends Api
+{
+    protected $noNeedLogin = '*';
+    protected $noNeedRight = '*';
+
+    /**
+     * 会员登录
+     *
+     * @param string $user_tel 账号
+     * @param string $user_pwd 密码
+     * @param string $user_openid qq或者微信openID
+     */
+    public function Login()
+    {
+        $data = $this->request->post();
+        $rules = [
+            'user_tel' => 'require|max:11|number|min:11',
+            'user_pwd' => 'require|max:25|min:6'
+        ];
+        $msg = [
+            'user_tel.require' => '手机号不能为空',
+            'user_tel.max'     => '手机号长度不正确',
+            'user_tel.min'     => '手机号长度不正确',
+            'user_tel.number'  => '手机号必须为数字',
+            'user_pwd.require' => '密码不能为空',
+            'user_pwd.max'     => '密码长度过长',
+            'user_pwd.min'     => '密码长度不足',
+        ];
+        if (isset($data['user_tel']) && isset($data['user_pwd'])) {
+            $validata = $this->validate($data, $rules, $msg); //验证数据规则
+            if (is_string($validata)) {
+                return $this->result($validata, [], 100);
+            }
+            $valdatatel = UsersModel::where('user_tel', $data['user_tel'])->find();  //判断手机号是否存在
+            if ($valdatatel) {
+                $data['user_pwd'] = sha1(md5($data['user_pwd']));                                                              //加密验证密码
+                $validatapwd = UsersModel::where('user_pwd', $data['user_pwd'])->where('user_tel', $data['user_tel'])->find(); //判断密码是否正确
+                if ($validatapwd) {
+                    return $this->result('登录成功,欢迎回来', $validatapwd, 200);
+                } else {
+                    return $this->result('密码错误', [], 100);
+                }
+            } else {
+                return $this->result('手机号不存在', [], 100);
+            }
+        }
+        if (isset($data['openid'])) {
+            $validataopenid = UsersModel::where('user_openid', $data['openid'])->find();  //判断QQ或者微信登录的openid是否正确
+            if ($validataopenid) {
+                return $this->result('登陆成功,欢迎回来', $validataopenid, 200);
+            } else {
+                return $this->result('暂无该用户', [], 100);
+            }
+        }
+
+    }
+
+    //验证手机号是否已存在
+    public function validatatel($tel)
+    {
+        $tel = UsersModel::where('user_tel', $tel)->find();
+        $num = count($tel);
+        if ($num > 0) {
+            return $this->result('手机号已存在', [], 100);
+        }
+    }
+}

+ 2 - 1
application/api/controller/Validate.php

@@ -13,7 +13,8 @@ class Validate extends Api
     protected $noNeedLogin = '*';
     protected $layout = '';
     protected $error = null;
-
+    protected $rules = '';
+    protected $msg   = '';
     public function _initialize()
     {
         parent::_initialize();

+ 8 - 0
application/api/model/UsersModel.php

@@ -0,0 +1,8 @@
+<?php
+namespace app\api\model;
+use think\Model;
+
+class UsersModel extends Model
+{
+    protected $name = "Users";
+}

+ 50 - 0
public/assets/js/backend/agreemen/agreem.js

@@ -0,0 +1,50 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'agreemen/agreem/index' + location.search,
+                    add_url: 'agreemen/agreem/add',
+                    edit_url: 'agreemen/agreem/edit',
+                    del_url: 'agreemen/agreem/del',
+                    multi_url: 'agreemen/agreem/multi',
+                    table: 'agreement',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'a_id',
+                sortName: 'a_id',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'a_id', title: __('A_id')},
+                        {field: 'agreement_content', title: __('协议内容')},
+                        {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;
+});