作者 杨育虎

2

<?php
namespace app\admin\controller;
use app\common\controller\Backend;
/**
*
*
* @icon fa fa-circle-o
*/
class Planename extends Backend
{
/**
* Planename模型对象
* @var \app\admin\model\Planename
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\Planename;
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
}
... ...
<?php
return [
'Id' => 'ID',
'Title' => '飞机类型',
'Name' => '飞机名字',
'Updatetime' => '更改时间'
];
... ...
<?php
namespace app\admin\model;
use think\Model;
class Planename extends Model
{
// 表名
protected $name = 'planename';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = false;
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
];
}
... ...
<?php
namespace app\admin\validate;
use think\Validate;
class Planename extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
... ...
<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">
</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" data-rule="required" 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>
... ...
<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">{:__('Name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-name" data-rule="required" 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>
... ...
<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('planename/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('planename/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('planename/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('planename/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('planename/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('planename/edit')}"
data-operate-del="{:$auth->check('planename/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
... ... @@ -315,7 +315,7 @@ class Index extends Api
}
})
*/
public function TableList()
public function TableList()
{
$date = input('date');
$day = strtotime(date($date));
... ... @@ -328,7 +328,8 @@ class Index extends Api
->where($map)
->where(['s.cloud_type' => 1])
->where(['s.plane_type' => 1])
->field('t.title,s.id,s.plane_type,s.status,s.user_id')
->join('planename p','p.id=s.plane_type')
->field('t.title,p.name,s.id,s.plane_type,s.status,s.user_id')
->select();
foreach ($shangwu1 as $k => $v) {
if ($v['user_id'] != null) {
... ... @@ -347,7 +348,8 @@ class Index extends Api
->where($map)
->where(['s.cloud_type' => 1])
->where(['s.plane_type' => 2])
->field('s.id as fid,s.plane_type as fplane_type,s.status as fstatus,s.user_id as fuser_id')
->join('planename p','p.id=s.plane_type')
->field('s.id as fid,p.name as fname,s.plane_type as fplane_type,s.status as fstatus,s.user_id as fuser_id')
->select();
foreach ($shangwu2 as $k => $v) {
if ($v['fuser_id'] != null) {
... ... @@ -371,7 +373,8 @@ class Index extends Api
->where($map)
->where(['s.cloud_type' => 2])
->where(['s.plane_type' => 1])
->field('t.title,s.id,s.plane_type,s.status,s.user_id')
->join('planename p','p.id=s.plane_type')
->field('t.title,p.name,s.id,s.plane_type,s.status,s.user_id')
->select();
foreach ($xiawu1 as $k => $v) {
if ($v['user_id'] != null) {
... ... @@ -390,7 +393,8 @@ class Index extends Api
->where($map)
->where(['s.cloud_type' => 2])
->where(['s.plane_type' => 2])
->field('s.id as fid,s.plane_type as fplane_type,s.status as fstatus,s.user_id as fuser_id')
->join('planename p','p.id=s.plane_type')
->field('s.id as fid,p.name as fname,s.plane_type as fplane_type,s.status as fstatus,s.user_id as fuser_id')
->select();
foreach ($xiawu2 as $k => $v) {
if ($v['fuser_id'] != null) {
... ... @@ -457,7 +461,7 @@ class Index extends Api
}
})
*/
public function Kill()
public function Kill()
{
$id = input('id');
$user_id = $this->is_token($this->request->header());
... ... @@ -480,19 +484,19 @@ class Index extends Api
}
}
}
foreach ($array as $k => $v) {
$kill = Db::name('yuyue')->where(['sun_id' => $v])->where('user_id', $user_id)->find();
if (!empty($kill)) {
if ($kill['type'] == 1) {
Db::name('sun')->where('user_id', $user_id)->where(['id' => $kill['sun_id'] - 1])->update(['user_id' => '', 'status' => 1]);
}
if ($kill['type'] == 2) {
Db::name('sun')->where('user_id', $user_id)->where(['id' => $kill['sun_id'] + 1])->update(['user_id' => '', 'status' => 1]);
}
Db::name('sun')->where('user_id', $user_id)->where('id', $v)->update(['user_id' => '', 'status' => 1]);
Db::name('yuyue')->where(['sun_id' => $v])->where('user_id', $user_id)->delete();
}
}
// foreach ($array as $k => $v) {
// $kill = Db::name('yuyue')->where(['sun_id' => $v])->where('user_id', $user_id)->find();
// if (!empty($kill)) {
// if ($kill['type'] == 1) {
// Db::name('sun')->where('user_id', $user_id)->where(['id' => $kill['sun_id'] - 1])->update(['user_id' => '', 'status' => 1]);
// }
// if ($kill['type'] == 2) {
// Db::name('sun')->where('user_id', $user_id)->where(['id' => $kill['sun_id'] + 1])->update(['user_id' => '', 'status' => 1]);
// }
Db::name('sun')->where('user_id', $user_id)->where('id', $id)->update(['user_id' => '', 'status' => 1]);
Db::name('yuyue')->where(['sun_id' => $id])->where('user_id', $user_id)->delete();
// }
// }
$this->success('成功', 0);
}
... ...
... ... @@ -49,8 +49,8 @@ class User extends Api
$param = $this->request->param();
// 授权登录
$ch = curl_init();
$appid = "wxa7a9912415b69ce9";
$secret = "bec703ddda0484724e447374c6bd6235";
$appid = "wx243943911c16fbfc";
$secret = "297d8f02691bd23a6fb3828a200d5f7e";
$code = $param['code'];
$url = "https://api.weixin.qq.com/sns/jscode2session?appid=$appid&secret=$secret&js_code=$code&grant_type=authorization_code";
curl_setopt($ch, CURLOPT_URL, $url);
... ... @@ -79,7 +79,7 @@ class User extends Api
}
$token = $this->request->token();
$arr = [
'nickname' => $param['nickname'],
// 'nickname' => $param['nickname'],
'avatar' => $param['avatar'],
'token' => $token,
'updatetime' => time(),
... ...
... ... @@ -571,7 +571,7 @@ class Api
{
if ($vip == 1) {
$data = date('Y-m-d', time());
$catime = strtotime($data) + 86400 * 2;
$catime = strtotime($data) + 86400 * 3;
$time = Db::name('sun')->where(['id' => $id])->value('createtime');
if ($catime < $time) {
$this->error('您不能预约超过两天后的时间', 0);
... ... @@ -579,7 +579,7 @@ class Api
}
if ($vip == 2) {
$data = date('Y-m-d', time());
$catime = strtotime($data) + 86400 * 5;
$catime = strtotime($data) + 86400 * 6;
$time = Db::name('sun')->where(['id' => $id])->value('createtime');
if ($catime < $time) {
$this->error('您不能预约超过五天后的时间', 0);
... ... @@ -634,7 +634,7 @@ class Api
if ($is_week == '周五') {
$count = Db::name('yuyue')->where(['user_id' => $user_id])->where($map)->select();
if (!empty($count)) {
if (count($count) == 1) {
if (count($count) == 2) {
$this->error('超过最大可预约次数', 0);
die;
}
... ... @@ -643,7 +643,7 @@ class Api
if ($is_week == '周六') {
$count = Db::name('yuyue')->where(['user_id' => $user_id])->where($map)->select();
if (!empty($count)) {
if (count($count) == 1) {
if (count($count) == 2) {
$this->error('超过最大可预约次数', 0);
die;
}
... ... @@ -652,7 +652,7 @@ class Api
if ($is_week == '周日') {
$count = Db::name('yuyue')->where(['user_id' => $user_id])->where($map)->select();
if (!empty($count)) {
if (count($count) == 1) {
if (count($count) == 2) {
$this->error('超过最大可预约次数', 0);
die;
}
... ...
<?php
return array (
'name' => '飞机',
'name' => '澄湖基地固定翼飞机飞行计划系统',
'beian' => '',
'cdnurl' => '',
'version' => '1.0.1',
... ...
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'planename/index' + location.search,
add_url: 'planename/add',
edit_url: 'planename/edit',
del_url: 'planename/del',
multi_url: 'planename/multi',
table: 'planename',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'title', title: __('Title')},
{field: 'name', title: __('Name')},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', 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;
});
\ No newline at end of file
... ...