后台新增生活服务,新增轮播接口

This commit is contained in:
彭桃 2023-02-25 17:32:47 +08:00
parent a5bb34879e
commit 135e40382d
8 changed files with 1122 additions and 4 deletions

View File

@ -0,0 +1,224 @@
<?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;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Life extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=360;
$this->url=[
'/admin/nk.life/index?category_id='.$this->category_id,
'/admin/nk.life/add',
'/admin/nk.life/edit',
'/admin/nk.life/del',
'/admin/nk.life/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/life/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$param= get_params();
$param['category_id']=$this->category_id;
// 检验完整性
try {
validate(\app\admin\validate\nk\ArticleValidate::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
if($this->adminInfo['position_id'] != 1) { //不是超级管理员
$param['county']=$adds['area_id'];
$param['township']=$adds['street_id'];
$param['village']=$adds['village_id'];
$param['user_id']=$adds['user_id'];
}else{
if(empty($param['county'])){
$param['county']=$adds['area_id'];
}
if(empty($param['township'])){
$param['township']=$adds['street_id'];
}
if(empty($param['village'])){
$param['village']=$adds['village_id'];
}
if(empty($param['user_id'])){
$param['user_id']=$adds['user_id'];
}
}
$param['view_time']=date('Y-m-d H:i:s');
if(empty($param['category_type'])){
$param['category_type'] = 0;
}
if(empty($param['end_time'])){
$param['end_time'] = date('Y-m-d H:i:s');
}
$res=Db::table('fa_article')->strict(false)->field(true)->insertGetId($param);
if ($res){
if(!empty($param['is_vote']) && $param['is_vote']==1){
$data=['start_time'=>date('Y-m-d H:i:s'),'end_time'=>$param['end_time'],'article_id'=>$res,'county'=>$adds['area_id'],'township'=>$adds['street_id'],'village'=>$adds['village_id']];
Db::table('fa_article_vote_side_tables')->insert($data);
}
// 写入关联表
$life_data['article_id'] = $res;
$life_data['price'] = $param['price'];
$life_data['star'] = rtrim($param['star'],'星');
$life_data['lat'] = $param['lat'];
$life_data['lng'] = $param['lng'];
Db::table('fa_article_life')->strict(false)->field(true)->insert($life_data);
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
// (new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/life/add');
}
}
/**
* 修改
*/
public function edit(){
$param= get_params();
if (request()->isAjax()) {
try {
validate(\app\admin\validate\nk\ArticleValidate::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
if($this->adminInfo['position_id'] == 1) { //是超级管理员
if(empty($param['county'])){
$param['county']=$adds['area_id'];
}
if(empty($param['township'])){
$param['township']=$adds['street_id'];
}
if(empty($param['village'])){
$param['village']=$adds['village_id'];
}
if(empty($param['user_id'])){
$param['user_id']=$adds['user_id'];
}
}
$res=Db::table('fa_article')->where('id',$param['id'])->strict(false)->field(true)->update($param);
if(!empty($param['is_vote']) && $param['is_vote']==1){
Db::table('fa_article_vote_side_tables')->where('article_id',$param['id'])->update(['end_time'=>$param['end_time']]);
}
// 写入关联表
$life_data['price'] = $param['price'];
$life_data['star'] = rtrim($param['star'],'星');
$life_data['lat'] = $param['lat'];
$life_data['lng'] = $param['lng'];
Db::table('fa_article_life')->where('article_id',$param['id'])->update($life_data);
return to_assign();
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_article')->where('id',$id)->find();
View::assign('editor', get_system_config('other','editor'));
if (!empty($detail)) {
$ress = Db::table('fa_article_life')->where('article_id',$param['id'])->find();
$detail['price'] = $ress['price'];
$detail['star'] = $ress['star'];
$detail['lat'] = $ress['lat'];
$detail['lng'] = $ress['lng'];
View::assign('detail', $detail);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/life/edit',['url'=>$this->url]);
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param = get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_article')->where('id',$id)->find();
if (!empty($detail)) {
$detail['comment'] = Db::table('fa_article_comment')
->where('vote_id',$id)
->withAttr('user_info',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name');
})
->select();
$ress = Db::table('fa_article_life')->where('article_id',$param['id'])->find();
$detail['price'] = $ress['price'];
$detail['star'] = $ress['star'];
$detail['lat'] = $ress['lat'];
$detail['lng'] = $ress['lng'];
View::assign('detail', $detail);
View::assign('admin_id', $this->adminInfo['id']);
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
return view('nk/life/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,295 @@
{extend name="common/base"/}
{block name="style"}
<style type="text/css">
.editormd-code-toolbar select {display: inline-block}
.editormd li {list-style: inherit;}
.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="7"><input type="text" name="title" lay-verify="required" lay-reqText="请输入文章标题"
autocomplete="off" placeholder="请输入文章标题" class="layui-input"></td>
</tr>
{notempty name="is_vote"}
<tr>
<td class="layui-td-gray">结束时间<font>*</font></td>
<td colspan="7"> <input type="text" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" id="test1" name="end_time">
<input type="hidden" name="is_vote" value="1">
</td>
</tr>
{/notempty}
<tr>
<td class="layui-td-gray" style="vertical-align:top;">文章摘要</td>
<td colspan="3">
<textarea name="describe" placeholder="请输入摘要不能超过200个字" class="layui-textarea"></textarea>
</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="image" value="">
</div>
</div>
</td>
</tr>
{if {:session('gougu_admin')['group_access']==1}
<tr>
<td class="layui-td-gray" style="vertical-align:top;">区县</td>
<td colspan="3">
<div class="layui-col-md6">
<div >
<select name="county" lay-filter="area_id" >
{volist name='street' id='vo'}
<option value="{$vo.code}" >{$vo.name}</option>
{/volist}
</select>
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray" style="vertical-align:top;">街道/镇</td>
<td colspan="3">
<div class="layui-col-md6">
<div >
<div id="demo1" ></div>
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray" style="vertical-align:top;">村/社区</td>
<td colspan="3">
<div class="layui-col-md6">
<div >
<div id="demo2" ></div>
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray">用户<font>*</font></td>
<td colspan="3">
<div class="layui-col-md6">
<select name="user_id" lay-verify="required" lay-search="">
<option value="" >请选择</option>
{volist name='users' id='vo'}
<option value="{$vo.user_id}" >{$vo.name}</option>
{/volist}
</select>
</div>
</td>
</tr>
{/if}
<tr>
<td class="layui-td-gray">价格<font>*</font></td>
<td colspan="3"><input type="text" name="price" lay-verify="required|number" lay-reqText="请输入价格"
autocomplete="off" placeholder="请输入价格" class="layui-input"></td>
</tr>
<tr>
<td class="layui-td-gray">星级<font>*</font></td>
<td colspan="3">
<div id="rate"></div>
</td>
</tr>
<tr>
<td class="layui-td-gray">是否推荐<font>*</font></td>
<td colspan="6">
<input type="radio" name="is_tj" value="0" title="否" checked>
<input type="radio" name="is_tj" value="1" title="是" >
</td>
</tr>
<tr>
<td class="layui-td-gray">坐标</td>
<td colspan="6">
<div id="map"></div>
</td>
</tr>
<tr>
<td colspan="6" class="layui-td-gray" style="text-align:left">文章内容</td>
</tr>
<tr>
<td colspan="6">
<textarea class="layui-textarea" id="container_content"></textarea>
</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/xm-select.js"></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'];
var group_access = "{:session('gougu_admin')['group_access']}"
function gouguInit() {
var form =layui.form, tool = layui.tool,tagspicker = layui.tagpicker,laydate=layui.laydate,rate=layui.rate;
laydate.render({
elem: '#test1' //指定元素
});
var ins1 = rate.render({
elem: '#rate' //绑定元素
, length:5 //星星个数
, value:3 //初始化值
, theme: '#1dc569' //颜色
, half: true //支持半颗星
, text: true //显示文本,默认显示 '3.5星'
, readonly: false //只读
//自定义文本,点击后文本显示的内容
, setText: function (value) {
// if (value < 2 ) {
// this.span.text("差")
// } else if (value <= 3.5) {
// this.span.text("一般")
// } else {
// this.span.text("好")
// }
this.span.text = value;
}
//选定时调用评分时发送一个ajax,readonly设为true
, choose: function (value) {
if (value > 5) alert('么么哒')
}
});
// 打开坐标拾取器
var addr = addrHelper.render({
key: "QNXBZ-GUKEX-I5Q4Q-THKU6-233DK-7ZBG7", //必传腾讯地图api key 申请方法见https://lbs.qq.com/webApi/javascriptGL/glGuide/glBasic
el: '#map', //必选项,渲染容器
lat: 28.913318, //可选项,初始化纬度
lng: 105.437753, //可选项初始化经度28.913318,105.437753
zoom: 13, //可选项,地图缩放级别 默认值13
width: "80vw", //可选项,弹窗的宽度 默认80vw
height: "50vh", //可选项,弹窗的高度 默认80vh
toolbar: false, //可选项,显示工具栏 默认true
created: function () { //可选项,地图被创建后回调
},
});
//上传缩略图
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);
}
});
street();
village();
form.on('select(area_id)', function (data) {
street(data.value)
});
function street (id) {
var demo1 = xmSelect.render({
name: 'township',
el: '#demo1',
initValue: [],
prop: {
name: 'name',
value: 'code',
},
data: [],
radio: true,
disabled: group_access == 2 ||group_access == 4? true : false,
on: function (data) {
var arr = data.arr;
if(arr.length > 0){
village(arr[0]['code']);
}else{
village();
}
},
})
$.get('/api/geo/street?pcode=' + id, function (result) {
demo1.update({
data: result.data
})
});
}
function village (id) {
var demo2 = xmSelect.render({
name: 'village',
el: '#demo2',
initValue: [],
prop: {
name: 'name',
value: 'id',
},
data: [],
radio: true,
disabled: group_access == 2 ? true : false,
})
$.get('/api/geo/village?pcode=' + id, function (result) {
demo2.update({
data: result.data
})
});
}
var editor = layui.tinymce;
var edit = editor.render({
selector: "#container_content",
height: 500
});
//监听提交
form.on('submit(webform)', function (data) {
data.field.content = tinyMCE.editors['container_content'].getContent();
if (data.field.content == '') {
layer.msg('请先完善文章内容');
return false;
}
data.field.lng = $('.lng').text();
data.field.lat = $('.lat').text();
data.field.star = $('#rate').text();
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
tool.tabRefresh(71);
tool.sideClose(1000);
}
}
tool.post('{$url[1]}', data.field, callback);
return false;
});
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,318 @@
{extend name="common/base"/}
{block name="style"}
<style type="text/css">
.editormd-code-toolbar select {
display: inline-block
}
.editormd li {
list-style: inherit;
}
.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="7"><input type="text" name="title" lay-verify="required" lay-reqText="请输入文章标题"
autocomplete="off" placeholder="请输入文章标题" class="layui-input"
value="{$detail.title}"></td>
</tr>
{notempty name="is_vote"}
<tr>
<td class="layui-td-gray">结束时间<font>*</font></td>
<td colspan="7"> <input type="text" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" id="test1" name="end_time">
<input type="hidden" name="is_vote" value="1">
</td>
</tr>
{/notempty}
<tr>
<td class="layui-td-gray" style="vertical-align:top;">摘要</td>
<td colspan="3">
<textarea name="describe" placeholder="请输入摘要不能超过200个字"
class="layui-textarea">{$detail.describe}</textarea>
</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.image}"
onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;"
style="max-width: 100%; height:66px;"/>
<input type="hidden" name="image" value="{$detail.image}">
</div>
</div>
</td>
</tr>
{if {:session('gougu_admin')['group_access']==1}
<tr>
<td class="layui-td-gray" style="vertical-align:top;">区县</td>
<td colspan="3">
<div class="layui-col-md6">
<div >
<select name="county" lay-filter="area_id">
{volist name='street' id='vo'}
<option value="{$vo.code}" {if $detail.county==$vo.code} selected {/if}>{$vo.name}</option>
{/volist}
</select>
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray" style="vertical-align:top;">街道/镇</td>
<td colspan="3">
<div class="layui-col-md6">
<div >
<div id="demo1" ></div>
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray" style="vertical-align:top;">村/社区</td>
<td colspan="3">
<div class="layui-col-md6">
<div >
<div id="demo2" ></div>
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray">用户<font>*</font></td>
<td colspan="3">
<div class="layui-col-md6">
<select name="user_id" lay-verify="required" lay-search="">
<option value="" >请选择</option>
{volist name='users' id='vo'}
<option value="{$vo.user_id}" {if $detail.user_id==$vo.user_id} selected {/if}>{$vo.name}</option>
{/volist}
</select>
</div>
</td>
</tr>
{/if}
<tr>
<td class="layui-td-gray">价格<font>*</font></td>
<td colspan="3"><input type="text" name="price" lay-verify="required|number" lay-reqText="请输入价格"
autocomplete="off" placeholder="请输入价格" class="layui-input" value="{$detail.price}"></td>
</tr>
<tr>
<td class="layui-td-gray">星级<font>*</font></td>
<td colspan="3">
<div id="rate"></div>
</td>
</tr>
<tr>
<td class="layui-td-gray">是否推荐<font>*</font></td>
<td colspan="6">
<input type="radio" name="is_tj" value="0" title="否" {if $detail.is_tj=='0'} checked {/if}>
<input type="radio" name="is_tj" value="1" title="是" {if $detail.is_tj=='1'} checked {/if}>
</td>
</tr>
<tr>
<td class="layui-td-gray">坐标</td>
<td colspan="6">
<div id="map"></div>
</td>
</tr>
<tr>
<td colspan="6" class="layui-td-gray" style="text-align:left">文章内容</td>
</tr>
<tr>
<td colspan="6">
<textarea placeholder="请输入内容" class="layui-textarea"
id="container_content">{$detail.content}</textarea>
</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/xm-select.js"></script>
<script src="/static/assets/js/jquery.min.js"></script>
<script src="/static/assets/js/addrHelper.js"></script>
<script>
const editorType = '{$editor}';
var moduleInit;
if (editorType == 1) {
moduleInit = ['tool', 'tagpicker', 'tinymce'];
} else {
moduleInit = ['tool', 'tagpicker', 'editormd'];
}
var group_access = "{:session('gougu_admin')['group_access']}";
var area_id = "{$detail.county}";
var street_id = "{$detail.township}";
var star = "{$detail.star}";
function gouguInit() {
var form =layui.form, tool = layui.tool,tagspicker = layui.tagpicker,laydate=layui.laydate,rate=layui.rate;
laydate.render({
elem: '#test1' //指定元素
});
var lat = "{$detail.lat}";
var lng = "{$detail.lng}";
var ins1 = rate.render({
elem: '#rate' //绑定元素
, length:5 //星星个数
, value:star //初始化值
, theme: '#1dc569' //颜色
, half: true //支持半颗星
, text: true //显示文本,默认显示 '3.5星'
, readonly: false //只读
//自定义文本,点击后文本显示的内容
, setText: function (value) {
// if (value < 2 ) {
// this.span.text("差")
// } else if (value <= 3.5) {
// this.span.text("一般")
// } else {
// this.span.text("好")
// }
this.span.text = value;
}
//选定时调用评分时发送一个ajax,readonly设为true
, choose: function (value) {
if (value > 5) alert('么么哒')
}
});
// 打开坐标拾取器
var addr = addrHelper.render({
key: "QNXBZ-GUKEX-I5Q4Q-THKU6-233DK-7ZBG7", //必传腾讯地图api key 申请方法见https://lbs.qq.com/webApi/javascriptGL/glGuide/glBasic
el: '#map', //必选项,渲染容器
lat: 28.913318, //可选项,初始化纬度
lng: 105.437753, //可选项初始化经度28.913318,105.437753
zoom: 13, //可选项,地图缩放级别 默认值13
width: "80vw", //可选项,弹窗的宽度 默认80vw
height: "50vh", //可选项,弹窗的高度 默认80vh
toolbar: false, //可选项,显示工具栏 默认true
created: function () { //可选项,地图被创建后回调
},
});
$('.lng').text(lng);
$('.lat').text(lat);
//上传缩略图
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);
}
});
if (area_id != 0) {
street(area_id)
}
if (street_id != 0) {
village(street_id)
}
form.on('select(area_id)', function (data) {
street(data.value)
});
function street (id) {
var demo1 = xmSelect.render({
name: 'township',
el: '#demo1',
initValue: ["{$detail.township}"],
prop: {
name: 'name',
value: 'code',
},
data: [],
radio: true,
disabled: group_access == 2 ||group_access == 4? true : false,
on: function (data) {
var arr = data.arr;
if(arr.length > 0){
village(arr[0]['code']);
}else{
village();
}
},
})
$.get('/api/geo/street?pcode=' + id, function (result) {
demo1.update({
data: result.data
})
});
}
function village (id) {
var demo2 = xmSelect.render({
name: 'village',
el: '#demo2',
initValue: ["{$detail.village}"],
prop: {
name: 'name',
value: 'id',
},
data: [],
radio: true,
disabled: group_access == 2 ? true : false,
})
$.get('/api/geo/village?pcode=' + id, function (result) {
demo2.update({
data: result.data
})
});
}
var editor = layui.tinymce;
var edit = editor.render({
selector: "#container_content",
height: 500
});
//监听提交
form.on('submit(webform)', function (data) {
data.field.content = tinyMCE.editors['container_content'].getContent();
if (data.field.content == '') {
layer.msg('请先完善文章内容');
return false;
}
data.field.lng = $('.lng').text();
data.field.lat = $('.lat').text();
data.field.star = $('#rate').text();
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
tool.sideClose(1000);
}
}
tool.post("{$url[2]}", data.field, callback);
return false;
});
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,144 @@
{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="toolbarDemo">
<div class="layui-btn-container">
<span class="layui-btn layui-btn-sm" lay-event="add" data-title="添加内容">+ 添加内容</span>
</div>
</script>
<script type="text/html" id="barDemo">
<div class="layui-btn-group"><a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="read">查看</a><a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></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:120,
},{
field: 'area',
title: '区县',
align: 'center',
width:120,
},{
field: 'street',
title: '乡镇',
align: 'center',
width:120,
},{
field: 'village',
title: '街道/村',
align: 'center',
width:120,
},{
field: 'title',
title: '文章标题',
},{
field: 'nickname',
title: '用户',
align: 'center',
},{
field: 'view_time',
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,113 @@
{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;}
</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">文章标题</td>
<td colspan="3">{$detail.title}</td>
</tr>
<tr>
<td class="layui-td-gray">创建时间</td>
<td>{$detail.view_time}</td>
<td class="layui-td-gray">状态</td>
<td>
{eq name="$detail.status" value="1"}正常{/eq}
{eq name="$detail.status" value="0"}下架{/eq}
</td>
</tr>
<tr>
<td class="layui-td-gray">文章摘要</td>
<td colspan="3">{$detail.describe}</td>
</tr>
<tr>
<td class="layui-td-gray">价格</td>
<td colspan="3">{$detail.price}"</td>
</tr>
<tr>
<td class="layui-td-gray">星级</td>
<td colspan="3">
<div id="rate">{$detail.star} 星</div>
</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="5" class="content-article">
{$detail.content|raw}
</td>
</tr>
{if in_array($detail.category_id,[149,157,158,148,147,165]) }
<tr >
<td class="layui-td-gray">回复内容:</td>
<td colspan="6">
{volist name="$detail.comment" id="vo"}
{$vo.user_info}的回复:{$vo.content}<br>
{/volist}
</td>
</tr>
{/if}
{if in_array($detail.category_id,[149,157,158,148,147,165]) }
<tr >
<td class="layui-td-gray">回复:</td>
<td colspan="6">
<textarea class="layui-textarea" name="reply" ></textarea>
</td>
</tr>
{/if}
</table>
{if in_array($detail.category_id,[149,157,158,148,147,165]) }
<div class="pt-3">
<input type="hidden" name="id" value="{$detail.id}"/>
<input type="hidden" name="admin_id" value="{$admin_id}"/>
<input type="hidden" name="content" value="{$detail.content}"/>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即回复</button>
</div>
{/if}
</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;
//监听提交
form.on('submit(webform)', function (data) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
tool.sideClose(1000);
}
}
tool.post("/admin/api/reply", data.field, callback);
return false;
});
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -58,8 +58,8 @@
</tr>
<tr>
<td class="layui-td-gray">跳转路径<font>*</font></td>
<td colspan="7"><input type="text" name="src" lay-verify="required" lay-reqText="请输入跳转路径"
<td class="layui-td-gray">跳转路径</td>
<td colspan="7"><input type="text" name="src" lay-reqText="请输入跳转路径"
autocomplete="off" placeholder="请输入跳转路径" class="layui-input"></td>
</tr>

View File

@ -58,7 +58,7 @@
</tr>
<tr>
<td class="layui-td-gray">跳转路径<font>*</font></td>
<td class="layui-td-gray">跳转路径</td>
<td colspan="7"><input type="text" name="src" lay-reqText="请输入跳转路径"
autocomplete="off" placeholder="请输入跳转路径" class="layui-input" value="{$detail.src}"></td>
</tr>

View File

@ -18,7 +18,7 @@ class Slide extends BaseController
* @var array
*/
protected $middleware = [
Auth::class => ['except' => ['get_slide'] ]
Auth::class => ['except' => ['get_slide','get_slide_two'] ]
];
/**
* 获取轮播
@ -52,4 +52,28 @@ class Slide extends BaseController
}
}
//获取轮播,不管区域
public function get_slide_two()
{
$township = get_params('township'); // 乡镇
if($township){
$where['township'] = $township;
}
$slide_id = get_params('slide_id'); // 位置
if($slide_id){
$where['slide_id'] = $slide_id;
}
$where['status'] = 1;
$list = Db::table('fa_slide_info')->where($where)
->order('sort desc')
->select();
$is_arr = $list->toarray();
if($is_arr){
$this->apiSuccess('获取成功',$list);
}else{
$this->apiError('暂无数据',[]);
}
}
}