接口修改11

This commit is contained in:
mkm 2023-02-18 10:40:46 +08:00
parent aef4f6f2ed
commit e95a7d3b64
17 changed files with 1769 additions and 0 deletions

View File

@ -0,0 +1,194 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
use app\api\model\Area as AreaModel; // 市场区域模型
use app\api\model\AreaManager as AreaManagerModel; // 区域负责人模型
/**
*
* 时间2023年02月17日
* 作者:墨楠小
* 邮箱monanxiao@qq.com
* 区域负责人控制器
*
*/
class Areamanager extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=354;
$this->url=[
'/admin/nk.areamanager/index?category_id='.$this->category_id,
'/admin/nk.areamanager/add',
'/admin/nk.areamanager/edit',
'/admin/nk.areamanager/del',
'/admin/nk.areamanager/read',
];
}
/**
*
* 区域负责人数据列表
*
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where[]= ['status','=',0];
if (isset($params['keywords']) && !empty($params['keywords'])){
$where[]= ['name','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village_id','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['street_id','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['area_id','=',$user_address['area_id']];
}else{
$where[] = ['village_id','=',$user_address['village_id']];
}
}else{
$where[] = ['village_id','=',''];
}
}
$total = AreaManagerModel::where($where)->count();
// 负责人信息
$list = AreaManagerModel::with('area')
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}else{
return view('nk/areamanager/index',['url'=>$this->url]);
}
}
/**
*
* 区域负责人数据添加
*
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$data['user_id'] = $this->adminInfo['id']; // 操作用户ID
$data['avatar'] = $params['avatar']; // 头像
$data['name'] = $params['name']; // 姓名
$data['duty'] = $params['duty']; // 职务
$data['phone'] = $params['phone']; // 手机号
$data['area_id'] = $params['area_id']; // 区域ID
$area = AreaModel::find($params['area_id']);
$data['farm_product_market_id'] = $area->id; // 市场ID
$data['created_at'] = date('Y-m-d H:i:s');
$res = AreaManagerModel::create($data);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
$area = AreaModel::where('status', 0)->column('id, area_name');
View::assign('editor', get_system_config('other','editor'));
View::assign('area', $area);
return view('nk/areamanager/add');
}
}
/**
*
* 区域负责人数据修改
*
*/
public function edit()
{
$param= get_params();
if (request()->isAjax()) {
$params= get_params();
$data['user_id'] = $this->adminInfo['id']; // 操作用户ID
$data['avatar'] = $params['avatar']; // 头像
$data['name'] = $params['name']; // 姓名
$data['duty'] = $params['duty']; // 职务
$data['phone'] = $params['phone']; // 手机号
$data['area_id'] = $params['area_id']; // 区域ID
$data['updated_at'] = date('Y-m-d H:i:s');
$res = AreaManagerModel::where('id', $params['id'])->update($data);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = AreaManagerModel::find($id);
$area = AreaModel::where('status', 0)->column('id, area_name');
View::assign('editor', get_system_config('other','editor'));
View::assign('area', $area);
if (!empty($detail)) {
View::assign('detail', $detail);
return view();
}else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
*
* 删除区域负责人
*
*/
public function del()
{
$param= get_params();
$areaManager = AreaManagerModel::find($param['id']);
$res = $areaManager->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,172 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
use app\api\model\Area as AreaModel; // 市场区域模型
use think\facade\Log;
/**
* 农贸市场区域管理
*
* @icon fa fa-circle-o
*/
class Farmersarea extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.farmersarea/index',
'/admin/nk.farmersarea/add',
'/admin/nk.farmersarea/edit',
'/admin/nk.farmersarea/del',
'/admin/nk.farmersarea/read',
];
}
/**
* 数据列表
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where[]= ['status','=',0];
if (isset($params['keywords']) && !empty($params['keywords'])){
$where[]= ['area_name','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village_id','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['street_id','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['area_id','=',$user_address['area_id']];
}else{
$where[] = ['village_id','=',$user_address['village_id']];
}
}else{
$where[] = ['village_id','=',''];
}
}
$total = AreaModel::where($where)->count();
$list = AreaModel::with('FarmProductMarket')
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
else{
return view('nk/farmersarea/index',['url'=>$this->url]);
}
}
public function add(){
if (request()->isAjax()) {
$param = get_params();
$data['user_id'] = $this->adminInfo['id']; // 操作用户ID
$data['area_name'] = $param['area_name']; // 区域名称
$data['farm_product_market_id'] = $param['farm_product_market_id']; // 所属农贸市场
$data['created_at'] = date('Y-m-d H:i:s');
$res = AreaModel::create($data); // 数据入库
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
// 农贸市场数据列表
$farmProductMarket = Db::table('cms_farm_product_market')->column('id, title');
View::assign('farmProductMarket', $farmProductMarket);
View::assign('editor', get_system_config('other','editor'));
return view();
}
}
public function edit(){
$param= get_params();
if (request()->isAjax()) {
$param = get_params();
$data['user_id'] = $this->adminInfo['id']; // 操作用户ID
$data['area_name'] = $param['area_name']; // 区域名称
$data['farm_product_market_id'] = $param['farm_product_market_id']; // 所属农贸市场
$data['updated_at'] = date('Y-m-d H:i:s');
$res = AreaModel::where('id', $param['id'])->update($data); // 数据入库
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = AreaModel::find($id);
// 农贸市场数据列表
$farmProductMarket = Db::table('cms_farm_product_market')->column('id, title');
View::assign('farmProductMarket', $farmProductMarket);
View::assign('editor', get_system_config('other','editor'));
if (!empty($detail)) {
View::assign('detail', $detail);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 删除
*/
public function del()
{
$param= get_params();
$area = AreaModel::find($param['id']);
$res = $area->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,138 @@
{extend name="common/base"/}
{block name="style"}
<style type="text/css">
.editormd-code-toolbar select {
display: inline-block
}
.editormd li {
list-style: inherit;
}
.layui-td-gray {
width: 110px;
}
.addrhelper-ok-btn {
display: none;
}
</style>
{/block}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
<h3 class="pb-3">添加</h3>
<table class="layui-table layui-table-form">
<tr>
<td class="layui-td-gray">所属区域<font>*</font></td>
<td colspan="12">
<div class="layui-col-md12">
<select name="area_id" lay-verify="required" lay-search="">
<option value="" >请选择</option>
{volist name='area' id='vo'}
<option value="{$vo.id}" >{$vo.area_name}</option>
{/volist}
</select>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray">姓名<font>*</font></td>
<td colspan="4">
<input type="text" name="name" lay-verify="required" lay-reqText="请输入负责人姓名"
autocomplete="off" placeholder="请输入负责人姓名" class="layui-input">
</td>
<td class="layui-td-gray" style="vertical-align:top;">负责人头像</td>
<td>
<div class="layui-upload">
<button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumb">上传缩略图(尺寸:640x360)</button>
<div class="layui-upload-list" id="upload_box_thumb" style="width: 120px; height:66px; overflow: hidden;">
<img src="" onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;" width="100" style="max-width: 100%; height:66px;"/>
<input type="hidden" name="avatar" value="">
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray">职务<font>*</font></td>
<td colspan="4">
<input type="text" name="duty" lay-verify="required" lay-reqText="请输入负责人职务"
autocomplete="off" placeholder="请输入负责人职务" class="layui-input">
</td>
<td class="layui-td-gray">电话<font>*</td>
<td colspan="4">
<input type="text" name="phone" lay-verify="required" lay-reqText="请输入负责人电话"
autocomplete="off" placeholder="请输入负责人电话" class="layui-input">
</td>
</tr>
</table>
<div class="pt-3">
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</form>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script src="/static/assets/js/jquery.min.js"></script>
<script src="/static/assets/js/addrHelper.js"></script>
<script>
const editorType = '{$editor}';
var moduleInit = ['tool', 'tagpicker', 'tinymce'];
function gouguInit() {
var form = layui.form, tool = layui.tool, laydate = layui.laydate;
var editor = layui.tinymce;
var edit = editor.render({
selector: "#container_content",
height: 500
});
//上传缩略图
var upload_thumb = layui.upload.render({
elem: '#upload_btn_thumb',
url: '/admin/api/upload',
done: function (res) {
//如果上传失败
if (res.code == 1) {
return layer.msg('上传失败');
}
//上传成功
$('#upload_box_thumb input').attr('value', res.data.filepath);
$('#upload_box_thumb img').attr('src', res.data.filepath);
}
});
//监听提交
form.on('submit(webform)', function (data) {
data.field.lng = $('.lng').text();
data.field.lat = $('.lat').text();
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
setTimeout(function () {
parent.location.reload();
}, 1000);
}
}
tool.post('/admin/nk.areamanager/add', data.field, callback);
return false;
});
//日期选择
laydate.render({
elem: '#formDate',
max: 7,
showBottom: false
});
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,133 @@
{extend name="common/base"/}
{block name="style"}
<style type="text/css">
.editormd-code-toolbar select {
display: inline-block
}
.editormd li {
list-style: inherit;
}
.layui-td-gray{
width: 110px;
}
.addrhelper-ok-btn{
display: none;
}
</style>
{/block}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
<h3 class="pb-3">编辑</h3>
<table class="layui-table layui-table-form">
<tr>
<td class="layui-td-gray">所属区域<font>*</font></td>
<td colspan="12">
<div class="layui-col-md12">
<select name="area_id" lay-verify="required" lay-search="">
<option value="" >请选择</option>
{volist name='area' id='vo'}
{if $detail.area_id == $vo.id}
<option value="{$vo.id}" selected>{$vo.area_name}</option>
{else/}
<option value="{$vo.id}">{$vo.area_name}</option>
{/if}
{/volist}
</select>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray">姓名<font>*</font></td>
<td colspan="7">
<input type="text" name="name" lay-verify="required" lay-reqText="请输入负责人姓名"
autocomplete="off" placeholder="请输入负责人姓名" class="layui-input" value="{$detail.name}">
</td>
<td class="layui-td-gray" style="vertical-align:top;">负责人头像</td>
<td>
<div class="layui-upload">
<button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumb">上传缩略图(尺寸:640x360)</button>
<div class="layui-upload-list" id="upload_box_thumb" style="width: 120px; height:66px; overflow: hidden;">
<img src="{$detail.avatar}" onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;" width="100" style="max-width: 100%; height:66px;"/>
<input type="hidden" name="avatar" value="{$detail.avatar}">
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray">职务<font>*</font></td>
<td colspan="4">
<input type="text" name="duty" lay-verify="required" lay-reqText="请输入负责人职务"
autocomplete="off" placeholder="请输入负责人职务" class="layui-input" value="{$detail.duty}">
</td>
<td class="layui-td-gray">电话<font>*</td>
<td colspan="4">
<input type="text" name="phone" lay-verify="required" lay-reqText="请输入负责人电话"
autocomplete="off" placeholder="请输入负责人电话" class="layui-input" value="{$detail.phone}">
</td>
</tr>
</table>
<div class="pt-3">
<input type="hidden" name="id" value="{$detail.id}"/>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</form>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script src="/static/assets/js/jquery.min.js"></script>
<script src="/static/assets/js/addrHelper.js"></script>
<script>
var moduleInit = ['tool', 'tagpicker', 'tinymce'];
function gouguInit() {
var form = layui.form, tool = layui.tool, tagpicker = layui.tagpicker,laydate = layui.laydate;
var editor = layui.tinymce;
var lat = "{$detail.lat}";
var lng = "{$detail.lng}";
var edit = editor.render({
selector: "#container_content",
height: 500
});
//上传缩略图
var upload_thumb = layui.upload.render({
elem: '#upload_btn_thumb',
url: '/admin/api/upload',
done: function (res) {
//如果上传失败
if (res.code == 1) {
layer.msg('上传失败');
return false;
}
//上传成功
$('#upload_box_thumb input').attr('value', res.data.filepath);
$('#upload_box_thumb img').attr('src', res.data.filepath);
}
});
//监听提交
form.on('submit(webform)', function (data) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
tool.sideClose(1000);
}
}
tool.post("/admin/nk.areamanager/edit", data.field, callback);
return false;
});
//日期选择
laydate.render({
elem: '#formDate',
max: 17,
showBottom: false
});
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,187 @@
{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<div class="p-3">
<form class="layui-form gg-form-bar border-t border-x">
<div class="layui-input-inline" style="width:300px;">
<input type="text" name="keywords" placeholder="请输入负责人姓名" class="layui-input" autocomplete="off" />
</div>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="searchform">搜索</button>
</form>
<table class="layui-hide" id="article" lay-filter="article"></table>
</div>
<script type="text/html" id="status">
<i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
</script>
<script type="text/html" id="is_home">
<i class="layui-icon {{# if(d.is_home == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
</script>
<script type="text/html" id="thumb">
</script>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
{if {:auth_cache(session('gougu_admin')['id'],$url[1])}==true}
<span class="layui-btn layui-btn-sm" lay-event="add" data-title="添加">+ 添加</span>
{/if}
</div>
</script>
<script type="text/html" id="barDemo">
<div class="layui-btn-group">
<!-- {if {:auth_cache(session('gougu_admin')['id'],$url[4])}==true}
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="read">查看</a>
{/if} -->
{if {:auth_cache(session('gougu_admin')['id'],$url[2])}==true}
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
{/if}
{if {:auth_cache(session('gougu_admin')['id'],$url[3])}==true}
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
{/if}
</div>
</script>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
const moduleInit = ['tool'];
function gouguInit() {
var table = layui.table,tool = layui.tool, form = layui.form;
layui.pageTable = table.render({
elem: '#article',
title: '列表',
toolbar: '#toolbarDemo',
url: '{$url[0]}',
page: true,
limit: 20,
cols: [
[
{
fixed: 'left',
field: 'id',
title: '编号',
align: 'center',
width:80,
},{
field: 'area',
title: '区域',
align: 'center',
templet: function (d)
{
var html = '【' + d['area']['area_name'] + '】'
return html;
},
width:120,
},{
field: 'name',
title: '姓名',
align: 'center',
width:120,
},{
field: 'duty',
title: '职务',
align: 'center',
width:150,
},{
field: 'phone',
title: '电话',
align: 'center',
width:150,
},{
field: 'status',
title: '状态',
align: 'center',
templet: function (d)
{
var html = '<span style="color:#fbbc05">禁用</span>';
if (d.status == '0') {
html = '<span style="color:#12bb37">正常</span>';
}
return html;
},
},{
field: 'created_at',
title: '添加时间',
align: 'center',
width:150,
},{
field: 'status',
templet: function (d)
{
var html = '<span style="color:#fbbc05">禁用</span>';
if (d.status == '0') {
html = '<span style="color:#12bb37">正常</span>';
}
return html;
},
title: '状态',
align: 'center',
width:100,
},{
fixed: 'right',
field: 'right',
title: '操作',
toolbar: '#barDemo',
align: 'center'
}
]
]
});
//监听表头工具栏事件
table.on('toolbar(article)', function(obj){
if (obj.event === 'add') {
tool.side('{$url[1]}');
return false;
}
});
//监听表格行工具事件
table.on('tool(article)', function(obj) {
var data = obj.data;
if (obj.event === 'read') {
tool.side('{$url[4]}?id='+obj.data.id);
}
else if (obj.event === 'edit') {
tool.side('{$url[2]}?id='+obj.data.id);
}
else if (obj.event === 'del') {
layer.confirm('确定要删除该记录吗?', {
icon: 3,
title: '提示'
}, function(index) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}
tool.delete('{$url[3]}', { id: data.id }, callback);
layer.close(index);
});
}
return false;
});
//监听搜索提交
form.on('submit(searchform)', function(data) {
layui.pageTable.reload({
where: {
keywords: data.field.keywords,
cate_id: data.field.cate_id
},
page: {
curr: 1
}
});
return false;
});
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,67 @@
{extend name="common/base"/}
{block name="style"}
<style>
.content-article img{max-width:88%!important; height:auto!important; margin:6px 0!important; border-radius:4px;}
.layui-td-gray{
width: 110px;
}
</style>
{/block}
<!-- 主体 -->
{block name="body"}
<div class="layui-form p-4">
<h3 class="pb-3">详情</h3>
<table class="layui-table layui-table-form">
<tr>
<td class="layui-td-gray">标题<font>*</font></td>
<td colspan="7"><input type="text" name="title" lay-verify="required" lay-reqText="请输入标题"
autocomplete="off" placeholder="请输入标题" class="layui-input" value="{$detail.title}" readonly></td>
</tr>
<tr>
<td class="layui-td-gray">简介<font>*</font></td>
<td colspan="6">
<textarea class="layui-textarea" name="synopsis" readonly>{$detail.synopsis}</textarea>
</td>
</tr>
<tr>
<td class="layui-td-gray">内容</td>
<td colspan="6">
<textarea class="layui-textarea" name="content" readonly>{$detail.content}</textarea>
</td>
</tr>
<tr>
<td class="layui-td-gray">坐标</td>
<td colspan="6">
<p>经度:{$detail.lng}</p>
<p>纬度:{$detail.lat}</p>
</td>
</tr>
<tr>
<td class="layui-td-gray">运输距离</td>
<td colspan="6">
{volist name='farmers' id='vo'}
<p>距离 {$vo.title} {$vo.juli} 公里</p>
{/volist}
</td>
</tr>
</table>
</div>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
var moduleInit = ['tool', 'tagpicker', 'tinymce'];
function gouguInit() {
var form = layui.form, tool = layui.tool, tagpicker = layui.tagpicker,laydate = layui.laydate;
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,102 @@
{extend name="common/base"/}
{block name="style"}
<style type="text/css">
.editormd-code-toolbar select {
display: inline-block
}
.editormd li {
list-style: inherit;
}
.layui-td-gray{
width: 110px;
}
.addrhelper-ok-btn{
display: none;
}
</style>
{/block}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
<h3 class="pb-3">添加</h3>
<table class="layui-table layui-table-form">
<tr>
<td class="layui-td-gray">所属市场<font>*</font></td>
<td colspan="6">
<div class="layui-col-md6">
<select name="farm_product_market_id" lay-verify="required" lay-search="">
<option value="" >请选择农贸市场</option>
{volist name='farmProductMarket' id='vo'}
<option value="{$vo.id}" >{$vo.title}</option>
{/volist}
</select>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray">区域名称<font>*</font></td>
<td class="layui-col-md6" colspan="6"><input type="text" name="area_name" lay-verify="required" lay-reqText="请输入区域名称"
autocomplete="off" placeholder="请输入区域名称" class="layui-input"></td>
</tr>
</table>
<div class="pt-3">
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</form>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script src="/static/assets/js/jquery.min.js"></script>
<script src="/static/assets/js/addrHelper.js"></script>
<script>
const editorType = '{$editor}';
var moduleInit = ['tool', 'tagpicker', 'tinymce'];
function gouguInit() {
var form = layui.form, tool = layui.tool,laydate = layui.laydate;
var editor = layui.tinymce;
var edit = editor.render({
selector: "#container_content",
height: 500
});
//监听提交
form.on('submit(webform)', function (data) {
data.field.lng = $('.lng').text();
data.field.lat = $('.lat').text();
// if (data.field.lng == '') {
// layer.msg('请选择经纬度');
// return false;
// }
// if (data.field.lat == '') {
// layer.msg('请选择经纬度');
// return false;
// }
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
setTimeout(function () {
parent.location.reload();
}, 1000);
}
}
tool.post('/admin/nk.farmersarea/add', data.field, callback);
return false;
});
//日期选择
laydate.render({
elem: '#formDate',
max: 7,
showBottom: false
});
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,112 @@
{extend name="common/base"/}
{block name="style"}
<style type="text/css">
.editormd-code-toolbar select {
display: inline-block
}
.editormd li {
list-style: inherit;
}
.layui-td-gray{
width: 110px;
}
.addrhelper-ok-btn{
display: none;
}
</style>
{/block}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
<h3 class="pb-3">编辑</h3>
<table class="layui-table layui-table-form">
<tr>
<td class="layui-td-gray">所属市场<font>*</font></td>
<td colspan="6">
<div class="layui-col-md6">
<select name="farm_product_market_id" lay-verify="required" lay-search="">
<option value="" >请选择农贸市场</option>
{volist name='farmProductMarket' id='vo'}
{if $detail.farm_product_market_id == $vo.id}
<option value="{$vo.id}" selected>{$vo.title}</option>
{else/}
<option value="{$vo.id}">{$vo.title}</option>
{/if}
{/volist}
</select>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray">区域名称<font>*</font></td>
<td class="layui-col-md6" colspan="6"><input type="text" name="area_name" lay-verify="required" lay-reqText="请输入区域名称"
autocomplete="off" placeholder="请输入区域名称" value="{$detail.area_name}" class="layui-input"></td>
</tr>
</table>
<div class="pt-3">
<input type="hidden" name="id" value="{$detail.id}"/>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</form>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script src="/static/assets/js/jquery.min.js"></script>
<script src="/static/assets/js/addrHelper.js"></script>
<script>
var moduleInit = ['tool', 'tagpicker', 'tinymce'];
function gouguInit() {
var form = layui.form, tool = layui.tool, tagpicker = layui.tagpicker,laydate = layui.laydate;
var editor = layui.tinymce;
var lat = "{$detail.lat}";
var lng = "{$detail.lng}";
var edit = editor.render({
selector: "#container_content",
height: 500
});
//上传缩略图
var upload_thumb = layui.upload.render({
elem: '#upload_btn_thumb',
url: '/admin/api/upload',
done: function (res) {
//如果上传失败
if (res.code == 1) {
layer.msg('上传失败');
return false;
}
//上传成功
$('#upload_box_thumb input').attr('value', res.data.filepath);
$('#upload_box_thumb img').attr('src', res.data.filepath);
}
});
//监听提交
form.on('submit(webform)', function (data) {
data.field.lng = $('.lng').text();
data.field.lat = $('.lat').text();
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
tool.sideClose(1000);
}
}
tool.post("/admin/nk.farmersarea/edit", data.field, callback);
return false;
});
//日期选择
laydate.render({
elem: '#formDate',
max: 17,
showBottom: false
});
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,162 @@
{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<div class="p-3">
<form class="layui-form gg-form-bar border-t border-x">
<div class="layui-input-inline" style="width:300px;">
<input type="text" name="keywords" placeholder="请输入区域名称" class="layui-input" autocomplete="off" />
</div>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="searchform">搜索</button>
</form>
<table class="layui-hide" id="article" lay-filter="article"></table>
</div>
<script type="text/html" id="status">
<i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
</script>
<script type="text/html" id="is_home">
<i class="layui-icon {{# if(d.is_home == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
</script>
<script type="text/html" id="thumb">
</script>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
{if {:auth_cache(session('gougu_admin')['id'],$url[1])}==true}
<span class="layui-btn layui-btn-sm" lay-event="add" data-title="添加">+ 添加</span>
{/if}
</div>
</script>
<script type="text/html" id="barDemo">
<div class="layui-btn-group">
<!-- {if {:auth_cache(session('gougu_admin')['id'],$url[4])}==true}
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="read">查看</a>
{/if} -->
{if {:auth_cache(session('gougu_admin')['id'],$url[2])}==true}
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
{/if}
{if {:auth_cache(session('gougu_admin')['id'],$url[3])}==true}
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
{/if}
</div>
</script>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
const moduleInit = ['tool'];
function gouguInit() {
var table = layui.table,tool = layui.tool, form = layui.form;
layui.pageTable = table.render({
elem: '#article',
title: '列表',
toolbar: '#toolbarDemo',
url: '{$url[0]}',
page: true,
limit: 20,
cols: [
[
{
fixed: 'left',
field: 'id',
title: '编号',
align: 'center',
width:80,
},{
field: 'FarmProductMarket',
title: '农贸市场',
templet: function (d)
{
var html = '【' + d['FarmProductMarket']['title'] + '】'
return html;
},
align: 'center',
},{
field: 'area_name',
title: '区域名称',
align: 'center',
},{
field: 'status',
templet: function (d)
{
var html = '<span style="color:#fbbc05">禁用</span>';
if (d.status == '0') {
html = '<span style="color:#12bb37">正常</span>';
}
return html;
},
title: '状态',
align: 'center',
width:100,
},{
field: 'created_at',
title: '添加时间',
align: 'center',
},{
fixed: 'right',
field: 'right',
title: '操作',
toolbar: '#barDemo',
align: 'center'
}
]
]
});
//监听表头工具栏事件
table.on('toolbar(article)', function(obj){
if (obj.event === 'add') {
tool.side('{$url[1]}');
return false;
}
});
//监听表格行工具事件
table.on('tool(article)', function(obj) {
var data = obj.data;
if (obj.event === 'read') {
tool.side('{$url[4]}?id='+obj.data.id);
}
else if (obj.event === 'edit') {
tool.side('{$url[2]}?id='+obj.data.id);
}
else if (obj.event === 'del') {
layer.confirm('确定要删除该记录吗?', {
icon: 3,
title: '提示'
}, function(index) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}
tool.delete('{$url[3]}', { id: data.id }, callback);
layer.close(index);
});
}
return false;
});
//监听搜索提交
form.on('submit(searchform)', function(data) {
layui.pageTable.reload({
where: {
keywords: data.field.keywords,
cate_id: data.field.cate_id
},
page: {
curr: 1
}
});
return false;
});
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,67 @@
{extend name="common/base"/}
{block name="style"}
<style>
.content-article img{max-width:88%!important; height:auto!important; margin:6px 0!important; border-radius:4px;}
.layui-td-gray{
width: 110px;
}
</style>
{/block}
<!-- 主体 -->
{block name="body"}
<div class="layui-form p-4">
<h3 class="pb-3">详情</h3>
<table class="layui-table layui-table-form">
<tr>
<td class="layui-td-gray">标题<font>*</font></td>
<td colspan="7"><input type="text" name="title" lay-verify="required" lay-reqText="请输入标题"
autocomplete="off" placeholder="请输入标题" class="layui-input" value="{$detail.title}" readonly></td>
</tr>
<tr>
<td class="layui-td-gray">简介<font>*</font></td>
<td colspan="6">
<textarea class="layui-textarea" name="synopsis" readonly>{$detail.synopsis}</textarea>
</td>
</tr>
<tr>
<td class="layui-td-gray">内容</td>
<td colspan="6">
<textarea class="layui-textarea" name="content" readonly>{$detail.content}</textarea>
</td>
</tr>
<tr>
<td class="layui-td-gray">坐标</td>
<td colspan="6">
<p>经度:{$detail.lng}</p>
<p>纬度:{$detail.lat}</p>
</td>
</tr>
<tr>
<td class="layui-td-gray">运输距离</td>
<td colspan="6">
{volist name='farmers' id='vo'}
<p>距离 {$vo.title} {$vo.juli} 公里</p>
{/volist}
</td>
</tr>
</table>
</div>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
var moduleInit = ['tool', 'tagpicker', 'tinymce'];
function gouguInit() {
var form = layui.form, tool = layui.tool, tagpicker = layui.tagpicker,laydate = layui.laydate;
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,298 @@
<?php
namespace app\api\controller;
use app\api\BaseController;
use think\facade\Cache;
use think\facade\Db;
use think\facade\Log;
use think\Request;
use app\api\model\AreaManager as AreaManagerModel; // 区域负责人信息模型
use app\api\model\ProductOrderLog as ProductOrderLogModel; // 订单快照模型
use app\api\model\StoreProduct as StoreProductModel; // 商品模型
use app\api\model\AgricultureProducts as AgricultureProductsModel; // 农产品结构模型
use app\api\model\Area as AreaModel; // 市场区域模型
/**
* 时间2023年02月16日
* 作者:墨楠小
* 邮箱monanxiao@qq.com
* 可视化数据接口文件
*
*/
class Visual extends BaseController
{
/**
* @var \think\Request Request实例
*/
protected $request;
/**
* 构造方法
* @param Request $request Request对象
* @access public
*/
public function __construct(Request $request)
{
$this->request = $request;
// 记录请求api路径
// Log::recod($this->request->url());
}
/**
* 测试文件
*
*/
public function test()
{
}
/**
*
* 促销产品
*
*/
public function discountsGoods()
{
$num = 10;
$areaId = null;
// 是否获取区域信息
if($this->request->param('areaId'))
{
$query->where('area_id', $areaId);
}
// 获取商品数据
$product = StoreProductModel::where('is_show', 1)
->where('is_benefit', 1)
->field('product_id, store_name, ot_price, price, cost')
->select();
$this->apiSuccess('获取成功', $product);
}
/**
*
* 交易趋势
*
*/
public function trendtrading()
{
$num = 10;
$areaId = null;
// 是否获取区域信息
if($this->request->param('areaId'))
{
$query->where('area_id', $areaId);
}
// 获取商品订单日志->订单快照
$productOrderLog = ProductOrderLogModel::where('status', 1)
->fieldRaw("SUM(total_price) as month_price, month(create_time) as months")
->group('months')
->select();
$this->apiSuccess('获取成功', $productOrderLog);
}
/**
*
* 热销农副产品
*
*/
public function sellLikeGoods()
{
$num = 10;
$areaId = null;
// 是否获取区域信息
if($this->request->param('areaId'))
{
$query->where('area_id', $areaId);
}
// 获取商品数据
$product = StoreProductModel::where('is_show', 1)
->where('is_hot', 1)
->field('product_id, store_name, ot_price, price, cost')
->select();
$this->apiSuccess('获取成功', $product);
}
/**
*
* 区域负责人信息获取控制器
* num 获取数量 默认为10条
* areaId 区域ID 默认为null 获取全部
* AreaManagerModel 隐形路由绑定
*
*/
public function arealist(AreaManagerModel $query)
{
$num = 10;
$areaId = null;
// 是否获取区域负责人信息
if($this->request->param('areaId'))
{
$query->where('area_id', $areaId);
}
// 判断是否获取数量
if($this->request->param('number') != 10)
{
$query->limit($num);
}
$this->apiSuccess('获取成功', $query->select());
}
/**
*
* 实时直播
*
*/
public function realTimeLive()
{
$num = 10;
$areaId = null;
// 是否获取区域信息
if($this->request->param('areaId'))
{
$query->where('area_id', $areaId);
}
// 推流地址
$live = [
'rtmp' => 'rtmp://pull.aliyunlive.com/live/0000?auth_key={鉴权串}',
'flv' => 'http://pull.aliyunlive.com/live/0000.flv?auth_key={鉴权串}',
'm3u8' => 'http://pull.aliyunlive.com/live/0000.m3u8?auth_key={鉴权串}',
'rts' => 'artc://pull.aliyunlive.com/live/0000?auth_key={鉴权串}',
'mp4' => 'https://nk.lihaink.cn/video/test.mp4'
];
$this->apiSuccess('获取成功', $live);
}
/**
*
* 市场人流量
*
*/
public function bazaarPeopleFlow()
{
$num = 10;
$areaId = null;
// 是否获取区域信息
if($this->request->param('areaId'))
{
$query->where('area_id', $areaId);
}
$number = rand(1000000, 9999999); // 当前人流量
$yesterDayNumber = rand(3000000, 9999999); // 昨日人流量
// 人浏览预留接口
$visitorsFlow = [
'number' => $number, // 浏览人流量
'yesterDayNumber' => $yesterDayNumber, // 昨日浏览人流量
];
$this->apiSuccess('获取成功', $visitorsFlow);
}
/**
*
* 实时监控
*
*/
public function realTimeMonitoring()
{
$num = 10;
$areaId = null;
// 是否获取区域信息
if($this->request->param('areaId'))
{
$query->where('area_id', $areaId);
}
// 推流地址
$live = [
[
'rtmp' => 'rtmp://pull.aliyunlive.com/live/0000?auth_key={鉴权串}',
'flv' => 'http://pull.aliyunlive.com/live/0000.flv?auth_key={鉴权串}',
'm3u8' => 'http://pull.aliyunlive.com/live/0000.m3u8?auth_key={鉴权串}',
'rts' => 'artc://pull.aliyunlive.com/live/0000?auth_key={鉴权串}',
'mp4' => 'https://nk.lihaink.cn/video/test.mp4'
],
[
'rtmp' => 'rtmp://pull.aliyunlive.com/live/0000?auth_key={鉴权串}',
'flv' => 'http://pull.aliyunlive.com/live/0000.flv?auth_key={鉴权串}',
'm3u8' => 'http://pull.aliyunlive.com/live/0000.m3u8?auth_key={鉴权串}',
'rts' => 'artc://pull.aliyunlive.com/live/0000?auth_key={鉴权串}',
'mp4' => 'https://nk.lihaink.cn/video/test.mp4'
],
[
'rtmp' => 'rtmp://pull.aliyunlive.com/live/0000?auth_key={鉴权串}',
'flv' => 'http://pull.aliyunlive.com/live/0000.flv?auth_key={鉴权串}',
'm3u8' => 'http://pull.aliyunlive.com/live/0000.m3u8?auth_key={鉴权串}',
'rts' => 'artc://pull.aliyunlive.com/live/0000?auth_key={鉴权串}',
'mp4' => 'https://nk.lihaink.cn/video/test.mp4'
],
[
'rtmp' => 'rtmp://pull.aliyunlive.com/live/0000?auth_key={鉴权串}',
'flv' => 'http://pull.aliyunlive.com/live/0000.flv?auth_key={鉴权串}',
'm3u8' => 'http://pull.aliyunlive.com/live/0000.m3u8?auth_key={鉴权串}',
'rts' => 'artc://pull.aliyunlive.com/live/0000?auth_key={鉴权串}',
'mp4' => 'https://nk.lihaink.cn/video/test.mp4'
],
[
'rtmp' => 'rtmp://pull.aliyunlive.com/live/0000?auth_key={鉴权串}',
'flv' => 'http://pull.aliyunlive.com/live/0000.flv?auth_key={鉴权串}',
'm3u8' => 'http://pull.aliyunlive.com/live/0000.m3u8?auth_key={鉴权串}',
'rts' => 'artc://pull.aliyunlive.com/live/0000?auth_key={鉴权串}',
'mp4' => 'https://nk.lihaink.cn/video/test.mp4'
],
];
$this->apiSuccess('获取成功', $live);
}
/**
*
* 镇农副业特色产品
*
*/
public function featureGoods()
{
$num = 10;
$areaId = null;
// 是否获取区域信息
if($this->request->param('areaId'))
{
$query->where('area_id', $areaId);
}
// 农产品结构
$agricultureProducts = AgricultureProductsModel::where('status', 1)
->field('title, yield, cycle')
->select();
$this->apiSuccess('获取成功', $agricultureProducts);
}
}

View File

@ -0,0 +1,16 @@
<?php
/**
* 时间2023年02月17日
* 作者:墨楠小
* 邮箱monanxiao@qq.com
* CMS农产品结构模型
*
*/
namespace app\api\model;
use think\Model;
class AgricultureProducts extends Model
{
}

35
app/api/model/Area.php Normal file
View File

@ -0,0 +1,35 @@
<?php
/**
* 时间2023年02月16日
* 作者:墨楠小
* 邮箱monanxiao@qq.com
* 区域负责人信息模型
*
*/
namespace app\api\model;
use think\Model;
class Area extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'cms_area';
/**
* 关联拥有区域负责人
* 一对多
*
*/
public function areaManager()
{
return $this->hasManyThrough(AreaManager::class);
}
/**
* 所属农贸市场
*
*/
public function FarmProductMarket(){
return $this->belongsTo(FarmProductMarket::class);
}
}

View File

@ -0,0 +1,25 @@
<?php
/**
* 时间2023年02月16日
* 作者:墨楠小
* 邮箱monanxiao@qq.com
* 区域负责人信息模型
*
*/
namespace app\api\model;
use think\Model;
class AreaManager extends Model
{
/**
* 关联所属区域
* 一对一
*
*/
public function area()
{
return $this->belongsTo(Area::class);
}
}

View File

@ -0,0 +1,25 @@
<?php
/**
* 时间2023年02月17日
* 作者:墨楠小
* 邮箱monanxiao@qq.com
* 农贸市场模型
*
*/
namespace app\api\model;
use think\Model;
class FarmProductMarket extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'cms_farm_product_market';
/**
* 所属拥有区域信息
*
*/
public function area(){
return $this->belongsTo(Area::class);
}
}

View File

@ -0,0 +1,18 @@
<?php
/**
* 时间2023年02月17日
* 作者:墨楠小
* 邮箱monanxiao@qq.com
* 商品订单日志模型
* 订单快照模型
*
*/
namespace app\api\model;
use think\Model;
class ProductOrderLog extends Model
{
// 设置当前模型的数据库连接
protected $connection = 'sznk_shop';
}

View File

@ -0,0 +1,18 @@
<?php
/**
* 时间2023年02月17日
* 作者:墨楠小
* 邮箱monanxiao@qq.com
* 商品订单日志模型
* 商品模型
*
*/
namespace app\api\model;
use think\Model;
class StoreProduct extends Model
{
// 设置当前模型的数据库连接
protected $connection = 'sznk_shop';
}