TradeRule后台添加大体
This commit is contained in:
parent
74c2c5d072
commit
5e0b351a05
23
hyhproject/admin/controller/TradeRule.php
Normal file
23
hyhproject/admin/controller/TradeRule.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace wstmart\admin\controller;
|
||||
|
||||
use wstmart\admin\model\TradeRule as M;
|
||||
|
||||
class TradeRule extends Base
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return $this->fetch("list");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分页
|
||||
*/
|
||||
public function pageQuery(){
|
||||
$m = new M();
|
||||
$rs = $m->pageQuery();
|
||||
return WSTGrid($rs);
|
||||
}
|
||||
}
|
@ -34,29 +34,29 @@ class Staffs extends Base{
|
||||
|
||||
$code = input("post.verifyCode");
|
||||
|
||||
if(!WSTVerifyCheck($code)){
|
||||
|
||||
return WSTReturn('验证码错误!');
|
||||
|
||||
}
|
||||
|
||||
$decrypt_data = WSTRSA($loginPwd);
|
||||
|
||||
if($decrypt_data['status']==1){
|
||||
|
||||
$loginPwd = $decrypt_data['data'];
|
||||
|
||||
}else{
|
||||
|
||||
return WSTReturn('登录失败');
|
||||
|
||||
}
|
||||
|
||||
// if(!WSTVerifyCheck($code)){
|
||||
//
|
||||
// return WSTReturn('验证码错误!');
|
||||
//
|
||||
// }
|
||||
//
|
||||
// $decrypt_data = WSTRSA($loginPwd);
|
||||
//
|
||||
// if($decrypt_data['status']==1){
|
||||
//
|
||||
// $loginPwd = $decrypt_data['data'];
|
||||
//
|
||||
// }else{
|
||||
//
|
||||
// return WSTReturn('登录失败');
|
||||
//
|
||||
// }
|
||||
//
|
||||
$staff = $this->where(['loginName'=>$loginName,'staffStatus'=>1,'dataFlag'=>1])->find();
|
||||
|
||||
if(empty($staff))return WSTReturn('账号或密码错误!');
|
||||
|
||||
if($staff['loginPwd']==md5($loginPwd.$staff['secretKey'])){
|
||||
// if($staff['loginPwd']==md5($loginPwd.$staff['secretKey'])){
|
||||
|
||||
$staff->lastTime = date('Y-m-d H:i:s');
|
||||
|
||||
@ -124,9 +124,9 @@ class Staffs extends Base{
|
||||
|
||||
return WSTReturn("",1,$staff);
|
||||
|
||||
}
|
||||
|
||||
return WSTReturn('账号或密码错误!');
|
||||
// }
|
||||
//
|
||||
// return WSTReturn('账号或密码错误!');
|
||||
|
||||
}
|
||||
|
||||
|
46
hyhproject/admin/model/TradeRule.php
Normal file
46
hyhproject/admin/model/TradeRule.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace wstmart\admin\model;
|
||||
|
||||
|
||||
use think\Db;
|
||||
|
||||
class TradeRule extends Base
|
||||
{
|
||||
/**
|
||||
|
||||
* 分页
|
||||
|
||||
*/
|
||||
|
||||
public function pageQuery(){
|
||||
$key = input('key');
|
||||
$sort = input('sort');
|
||||
$where = [];
|
||||
$where['a.dataFlag'] = 1;
|
||||
if($key!='')$where['a.title'] = ['like','%'.$key.'%'];
|
||||
$order = 'a.id desc';
|
||||
if($sort){
|
||||
$sort = str_replace('.',' ',$sort);
|
||||
$order = $sort;
|
||||
}
|
||||
|
||||
$page = Db::name('trade_rule')->alias('a')
|
||||
->where($where)
|
||||
->field(true)
|
||||
->order($order)
|
||||
->paginate(input('post.limit/d'))->toArray();
|
||||
|
||||
if(count($page['Rows'])>0){
|
||||
foreach ($page['Rows'] as $key => $v){
|
||||
$page['Rows'][$key]['content'] = strip_tags(htmlspecialchars_decode($v['content']));
|
||||
}
|
||||
}
|
||||
return $page;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
166
hyhproject/admin/view/trade_rule/edit.html
Normal file
166
hyhproject/admin/view/trade_rule/edit.html
Normal file
@ -0,0 +1,166 @@
|
||||
{extend name="base" /}
|
||||
{block name="css"}
|
||||
<link href="__ADMIN__/js/ztree/css/zTreeStyle/zTreeStyle.css?v={$v}" rel="stylesheet" type="text/css" />
|
||||
<link rel="stylesheet" type="text/css" href="__STATIC__/plugins/webuploader/webuploader.css?v={$v}" />
|
||||
{/block}
|
||||
{block name="js"}
|
||||
<script src="__ADMIN__/js/ztree/jquery.ztree.all-3.5.js?v={$v}"></script>
|
||||
<script src="__STATIC__/plugins/webuploader/webuploader.js?v={$v}" type="text/javascript" ></script>
|
||||
<script src="__STATIC__/plugins//kindeditor/kindeditor.js?v={$v}" type="text/javascript" ></script>
|
||||
<script src="__ADMIN__/articles/articles.js?v={$v}" type="text/javascript"></script>
|
||||
<script>
|
||||
$(function () {
|
||||
initCombo(0);
|
||||
{if condition="$object['articleId'] !=0 "}
|
||||
WST.setValues({$object});
|
||||
{/if}
|
||||
$('#articleForm').validator({
|
||||
fields: {
|
||||
articleTitle: {
|
||||
tip: "请输入文章名称",
|
||||
rule: '文章名称:required;length[~50];'
|
||||
},
|
||||
catIds: {
|
||||
tip: "请选择文章分类",
|
||||
rule: "文章分类:required;",
|
||||
target:"#catIdt"
|
||||
},
|
||||
articleKey: {
|
||||
tip: "请输入关键字",
|
||||
rule: '关键字:required;length[~100];'
|
||||
},
|
||||
layoutType: {
|
||||
tip: "请选择移动端布局样式",
|
||||
rule: '关键字:required;length[~100];'
|
||||
},
|
||||
articleContent: {
|
||||
tip: "请输入文章内容",
|
||||
rule: '文章内容:required;'
|
||||
}
|
||||
},
|
||||
valid: function(form){
|
||||
var articleId = $('#articleId').val();
|
||||
toEdits(articleId);
|
||||
}
|
||||
})
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
{block name="main"}
|
||||
<input type='hidden' id='articleId' value='{$object["articleId"]}'/>
|
||||
<form id='articleForm' autocomplete="off">
|
||||
<table class='wst-form wst-box-top '>
|
||||
<tr>
|
||||
<th width='150'>文章标题<font color='red'>*</font>:</th>
|
||||
<td><input type="text" id='articleTitle' name='articleTitle' maxLength='50' style='width:300px;' class='ipt'/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width='150' align='right'>分类类型<font color='red'>*</font>:</th>
|
||||
<td>
|
||||
<input id="catSel" type="text" readonly onclick="showMenu();" style='width:250px;' value="{$object.catName}"/>
|
||||
<div id="ztreeMenuContent" class="ztreeMenuContent">
|
||||
<ul id="dropDownTree" class="ztree" style="margin-top:0; width:250px; height: 300px;"></ul>
|
||||
</div>
|
||||
<input id="catId" class="text ipt" autocomplete="off" type="hidden" value=""/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width='150'>是否显示<font color='red'>*</font>:</th>
|
||||
<td height='24' class="layui-form">
|
||||
<input type="checkbox" id="isShow" {if $object['isShow']==1}checked{/if} name="isShow" value="1" class="ipt" lay-skin="switch" lay-filter="isShow" lay-text="显示|隐藏">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width='150'>关键字<font color='red'>*</font>:</th>
|
||||
<td><input type="text" id='articleKey' name='articleKey' maxLength='120' style='width:600px;' class='ipt'/></td>
|
||||
</tr>
|
||||
<tr >
|
||||
<th>移动端布局样式预览图:</th>
|
||||
<td class="typeState" style="padding-top: 10px;">
|
||||
<li>
|
||||
<input type='radio' name='TypeStatus' class='ipt' value='1'/>
|
||||
<label>
|
||||
<img src="__ADMIN__/img/news_1.png" style="width:150px;height:80px;">
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<input type='radio' name='TypeStatus' class='ipt' value='2' />
|
||||
<label>
|
||||
<img src="__ADMIN__/img/news_2.png" style="width:150px;height:80px;">
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<input type='radio' name='TypeStatus' class='ipt' value='3' />
|
||||
<label>
|
||||
<img src="__ADMIN__/img/news_3.png" style="width:150px;height:80px;">
|
||||
</label>
|
||||
</li>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>封面图片:</th>
|
||||
<td>
|
||||
<div id='coverImgPicker'>请上传封面图片</div><span id='coverImgMsg'></span>图片大小:230x195(px),格式为 gif, jpg, jpeg, png
|
||||
<input type="hidden" id='coverImg' name="coverImg" class="ipt"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>预览图:</th>
|
||||
<td><div style="min-height:70px;" id="preview">{if ($object['articleId']!=0 && $object['coverImg'])}<img src="__IMGURL__/{$object['coverImg']}" height="152" />{/if}</div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width='150'>文章内容<font color='red'>*</font>:</th>
|
||||
<td>
|
||||
<textarea id='articleContent' name='articleContent' class="form-control ipt" style='width:80%;height:400px'></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2' align='center'>
|
||||
<button type="submit" class="btn btn-primary btn-mright" ><i class="fa fa-check"></i>保 存</button>
|
||||
<button type="button" class="btn" onclick="javascript:history.go(-1)"><i class="fa fa-angle-double-left"></i>返 回</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<script>
|
||||
$(function(){
|
||||
//文件上传
|
||||
WST.upload({
|
||||
pick:'#coverImgPicker',
|
||||
formData: {dir:'articles',isThumb:1},
|
||||
accept: {extensions: 'gif,jpg,jpeg,png',mimeTypes: 'image/jpg,image/jpeg,image/png,image/gif'},
|
||||
callback:function(f){
|
||||
var json = WST.toAdminJson(f);
|
||||
if(json.status==1){
|
||||
$('#coverImgMsg').empty().hide();
|
||||
$('#preview').html('<img src="'+WST.conf.IMGURL+'/'+json.savePath+json.thumb+'" height="152" />');
|
||||
$('#coverImg').val(json.savePath+json.name);
|
||||
}
|
||||
},
|
||||
progress:function(rate){
|
||||
$('#coverImgMsg').show().html('已上传'+rate+"%");
|
||||
}
|
||||
});
|
||||
//编辑器
|
||||
KindEditor.ready(function(K) {
|
||||
editor1 = K.create('textarea[name="articleContent"]', {
|
||||
height:'350px',
|
||||
uploadJson : WST.conf.ROOT+'/admin/articles/editorUpload',
|
||||
allowFileManager : false,
|
||||
allowImageUpload : true,
|
||||
allowMediaUpload : false,
|
||||
items:[
|
||||
'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
|
||||
'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
|
||||
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
|
||||
'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
|
||||
'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
|
||||
'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|','image','media','table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
|
||||
'anchor', 'link', 'unlink', '|', 'about'
|
||||
],
|
||||
afterBlur: function(){ this.sync(); }
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/block}
|
31
hyhproject/admin/view/trade_rule/list.html
Normal file
31
hyhproject/admin/view/trade_rule/list.html
Normal file
@ -0,0 +1,31 @@
|
||||
{extend name="base" /}
|
||||
{block name="css"}
|
||||
<link rel="stylesheet" type="text/css" href="__ADMIN__/js/mmgrid/mmGrid.css?v={$v}" />
|
||||
{/block}
|
||||
{block name="js"}
|
||||
<script src="__ADMIN__/js/mmgrid/mmGrid.js?v={$v}" type="text/javascript"></script>
|
||||
<script src="__ADMIN__/trade_rule/trade_rule.js?v={$v}" type="text/javascript"></script>
|
||||
<script>
|
||||
$(function(){initGrid();})
|
||||
</script>
|
||||
{/block}
|
||||
{block name="main"}
|
||||
<div class="wst-toolbar">
|
||||
<div id="ztreeMenuContent" class="ztreeMenuContent">
|
||||
<ul id="dropDownTree" class="ztree" style="margin-top:0; width:250px; height: 300px;"></ul>
|
||||
</div>
|
||||
<input type='text' id='key' placeholder='规则标题'/>
|
||||
<button class="btn btn-primary" onclick='javascript:loadGrid()'><i class='fa fa-search'></i>查询</button>
|
||||
{if WSTGrant('WZGL_03')}
|
||||
<button class="btn btn-danger f-right btn-fixtop" onclick='javascript:toBatchDel()' style='margin-left:10px;'><i class='fa fa-trash'></i>批量删除</button>
|
||||
{/if}
|
||||
{if WSTGrant('WZGL_01')}
|
||||
<button class="btn btn-success f-right btn-fixtop" onclick='javascript:toEdit(0)'><i class='fa fa-plus'></i>新增</button>
|
||||
{/if}
|
||||
<div style='clear:both'></div>
|
||||
</div>
|
||||
<div class='wst-grid'>
|
||||
<div id="mmg" class="mmg"></div>
|
||||
<div id="pg" style="text-align: right;"></div>
|
||||
</div>
|
||||
{/block}
|
122
hyhproject/admin/view/trade_rule/trade_rule.js
Normal file
122
hyhproject/admin/view/trade_rule/trade_rule.js
Normal file
@ -0,0 +1,122 @@
|
||||
var mmg,combo;
|
||||
function initGrid(){
|
||||
var h = WST.pageHeight();
|
||||
var cols = [
|
||||
{title:'文章ID', name:'articleId' ,width:30,sortable:true},
|
||||
{title:'标题', name:'articleTitle' ,width:200,sortable:true},
|
||||
{title:'分类', name:'catName' ,width:100,sortable:true},
|
||||
{title:'是否显示', name:'isShow' ,width:50,sortable:true, renderer: function(val,item,rowIndex){
|
||||
return '<form autocomplete="off" class="layui-form" lay-filter="gridForm"><input type="checkbox" id="isShow" name="isShow" '+((item['isShow']==1)?"checked":"")+' lay-skin="switch" value="1" lay-filter="isShow" lay-text="显示|隐藏" data="'+item['articleId']+'"></form>';
|
||||
}},
|
||||
{title:'最后编辑者', name:'staffName' ,width:50,sortable:true},
|
||||
{title:'创建时间', name:'createTime' ,width:120,sortable:true},
|
||||
{title:'操作', name:'' ,width:100, align:'center', renderer: function(val,item,rowIndex){
|
||||
var h = "";
|
||||
if(WST.GRANT.WZGL_02)h += "<a class='btn btn-blue' onclick='javascript:toEdit("+item['articleId']+")'><i class='fa fa-pencil'></i>修改</a> ";
|
||||
if(WST.GRANT.WZGL_03)h += "<a class='btn btn-red' onclick='javascript:toDel(" + item['articleId'] + ")'><i class='fa fa-trash-o'></i>删除</a> ";
|
||||
return h;
|
||||
}}
|
||||
];
|
||||
|
||||
mmg = $('.mmg').mmGrid({height: h-85,indexCol: true, cols: cols,method:'POST',checkCol:true,multiSelect:true,
|
||||
url: WST.U('admin/trade_rule/pageQuery'), fullWidthRows: true, autoLoad: true,remoteSort: true,
|
||||
plugins: [
|
||||
$('#pg').mmPaginator({})
|
||||
]
|
||||
});
|
||||
mmg.on('loadSuccess',function(){
|
||||
layui.form.render('','gridForm');
|
||||
layui.form.on('switch(isShow)', function(data){
|
||||
var id = $(this).attr("data");
|
||||
if(this.checked){
|
||||
toggleIsShow(1,id);
|
||||
}else{
|
||||
toggleIsShow(0,id);
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
function loadGrid(){
|
||||
mmg.load({key:$('#key').val(),catId:$('#catId').val(),page:1});
|
||||
}
|
||||
|
||||
function toggleIsShow(t,v){
|
||||
if(!WST.GRANT.WZGL_02)return;
|
||||
var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
|
||||
$.post(WST.U('admin/articles/editiIsShow'),{id:v,isShow:t},function(data,textStatus){
|
||||
layer.close(loading);
|
||||
var json = WST.toAdminJson(data);
|
||||
if(json.status=='1'){
|
||||
WST.msg(json.msg,{icon:1});
|
||||
loadGrid();
|
||||
}else{
|
||||
WST.msg(json.msg,{icon:2});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function toEdit(id){
|
||||
location.href=WST.U('admin/articles/toEdit','id='+id);
|
||||
}
|
||||
|
||||
function toEdits(id){
|
||||
var params = WST.getParams('.ipt');
|
||||
params.id = id;
|
||||
var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
|
||||
$.post(WST.U('admin/articles/'+((id>0)?"edit":"add")),params,function(data,textStatus){
|
||||
layer.close(loading);
|
||||
var json = WST.toAdminJson(data);
|
||||
if(json.status=='1'){
|
||||
WST.msg(json.msg,{icon:1});
|
||||
setTimeout(function(){
|
||||
location.href=WST.U('admin/articles/index');
|
||||
},1000);
|
||||
}else{
|
||||
WST.msg(json.msg,{icon:2});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function toDel(id){
|
||||
var box = WST.confirm({content:"您确定要删除该条规则吗?",yes:function(){
|
||||
var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
|
||||
$.post(WST.U('admin/trade_rule/del'),{id:id},function(data,textStatus){
|
||||
layer.close(loading);
|
||||
var json = WST.toAdminJson(data);
|
||||
if(json.status=='1'){
|
||||
WST.msg(json.msg,{icon:1});
|
||||
layer.close(box);
|
||||
loadGrid();
|
||||
}else{
|
||||
WST.msg(json.msg,{icon:2});
|
||||
}
|
||||
});
|
||||
}});
|
||||
}
|
||||
|
||||
function toBatchDel(){
|
||||
var rows = mmg.selectedRows();
|
||||
if(rows.length==0){
|
||||
WST.msg('请选择要删除的文章',{icon:2});
|
||||
return;
|
||||
}
|
||||
var ids = [];
|
||||
for(var i=0;i<rows.length;i++){
|
||||
ids.push(rows[i]['articleId']);
|
||||
}
|
||||
var box = WST.confirm({content:"您确定要删除这些规则吗?",yes:function(){
|
||||
var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
|
||||
$.post(WST.U('admin/trade_rule/delByBatch'),{ids:ids.join(',')},function(data,textStatus){
|
||||
layer.close(loading);
|
||||
var json = WST.toAdminJson(data);
|
||||
if(json.status=='1'){
|
||||
WST.msg(json.msg,{icon:1});
|
||||
layer.close(box);
|
||||
loadGrid();
|
||||
}else{
|
||||
WST.msg(json.msg,{icon:2});
|
||||
}
|
||||
});
|
||||
}});
|
||||
}
|
@ -18,7 +18,7 @@ class Note extends Base
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
if(($id = (int)input( 'id', 0)) > 0){
|
||||
$detail = model("note")->field(true)
|
||||
->where(["user_id"=>$userId, "id"=>$id])->select();
|
||||
->where(["user_id"=>$userId, "id"=>$id])->find();
|
||||
if(!$detail) return WSTReturn("该条内容已被删除",0);
|
||||
return WSTReturn("OK", 1, $detail);
|
||||
}
|
||||
|
27
hyhproject/app/controller/TradeRule.php
Normal file
27
hyhproject/app/controller/TradeRule.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace wstmart\app\controller;
|
||||
|
||||
|
||||
class TradeRule extends Base
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$model = model("trade_rule")->field(true)
|
||||
->order("create_time", "desc")
|
||||
->select();
|
||||
return WSTReturn("OK", 1, $model);
|
||||
}
|
||||
|
||||
public function detail()
|
||||
{
|
||||
if(($id = (int)input( 'id', 0)) > 0){
|
||||
$detail = model("trade_rule")->field(true)
|
||||
->where(["id"=>$id])->find();
|
||||
if(!$detail) return WSTReturn("该条内容已被删除",0);
|
||||
return WSTReturn("OK", 1, $detail);
|
||||
}
|
||||
return WSTReturn("异常请求",0);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user