zwesy 2021-11-24 09:38:22 +08:00
commit 23e783b6ab
29 changed files with 1422 additions and 92 deletions

View File

@ -642,4 +642,35 @@ if(!function_exists("createUuid")){
. substr($chars, 20, 12);
return $prefix . str_replace("-", "", $uuid);
}
}
/**
* 格式化黑名单时间
*/
if(!function_exists("formatBlankTime")){
function formatBlankTime($startdate, $enddate) {
if (strtotime($startdate) > strtotime($enddate)) {
$ymd = $enddate;
$enddate = $startdate;
$startdate = $ymd;
}
$date=floor((strtotime($enddate)-strtotime($startdate))/86400);
//echo "相差天数:".$date."天<br/><br/>";
$hour=floor((strtotime($enddate)-strtotime($startdate))%86400/3600);
//echo "相差小时数:".$hour."小时<br/><br/>";
$minute=floor((strtotime($enddate)-strtotime($startdate))%86400/60);
//echo "相差分钟数:".$minute."分钟<br/><br/>";
$second=floor((strtotime($enddate)-strtotime($startdate))%86400%60);
//echo "相差秒数:".$second."秒";
return ($date>0?$date."":'').
($hour>0?$hour."小时":'').
($minute>0?$minute."分钟":'').
($second>0?$second."":'');
}
}

View File

@ -79,45 +79,6 @@ class Category extends Base
return $this->view();
}
/**
* 单个字段编辑
*
* @return Json
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws Exception
*/
public function modify(): Json
{
if ($this->request->isPost()) {
$item = input('post.');
$validate = $this->validateByApi($item, [
'id|ID' => 'require|number',
'field|字段名' => 'require',
'value|值' => 'require',
]);
if ($validate !== true) {
return $validate;
}
if (!$info = CategoryModel::findById($item['id'])) {
return $this->json(4001, '记录不存在');
}
$update = [$item['field'] => $item['value']];
try {
$info->save($update);
return $this->json();
} catch (ValidateException $e) {
return $this->json(4001, $e->getError());
}
}
return $this->json(4000, '非法请求');
}
/**
* 添加
*

View File

@ -0,0 +1,232 @@
<?php
namespace app\controller\manager;
use app\exception\RepositoryException;
use app\model\Comment as CommentModel;
use app\repository\AccountRepository;
use Exception;
use think\facade\Db;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\exception\ValidateException;
use think\response\Json;
use think\response\View;
use think\facade\Config;
/**
* 评论
*
* Class Comment
* @package app\controller\manager
*/
class Comment extends Base
{
protected function initialize()
{
parent::initialize();
Config::load("extra/wechat", "wechat");
}
/**
* 审核
*
* @return Json|View
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws Exception
*/
public function examine()
{
$id = input('id/d', 0);
$state = input('state/d', 0);
if (!in_array($state, array_keys(CommentModel::allState()))) {
return $this->json(4001, '状态错误');
}
if (!$info = CommentModel::findById($id)) {
return $this->json(4001, '记录不存在');
}
if ($this->request->isPost()) {
$data = ['state' => $state];
if ($state == CommentModel::state_hide) {
$data['is_delete'] = CommentModel::COMMON_ON;
}
$info->save($data);
return $this->json();
}
$disabled = CommentModel::getAllChildrenIds($id);
$disabled[] = $id;
$this->data['item'] = $info;
return $this->view();
}
/**
* 恢复
*
* @return Json|View
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws Exception
*/
public function recovery()
{
$id = input('id/d', 0);
if (!$info = CommentModel::findById($id)) {
return $this->json(4001, '记录不存在');
}
if ($this->request->isPost()) {
$data = ["is_delete"=>CommentModel::COMMON_OFF];
$info->save($data);
return $this->json();
}
}
/**
* 加入黑名单
* @return Json
*/
public function addBlack()
{
$id = input("id/d");
$info = CommentModel::findById($id);
if (empty($info)) {
return $this->error('记录不存在');
}
if ($this->request->isPost()) {
if (empty($info)) {
return $this->json(4001, '记录不存在');
}
$time = input("time/d", 0, "abs");
if ($time <= 0) {
return $this->json(4001, "时间输入错误");
}
$account = AccountRepository::getInstance()->findOneByWhere(["user_code" => $info["user_code"]]);
if (empty($account)) {
return $this->json(4001, "用户不存在");
}
$timeSecond = $time * 60;
Db::startTrans();
try {
//如果之前有黑名单设置 如果黑名单时间未过期
if (!empty($account["blank_time"]) && strtotime($account["blank_time"]) && strtotime($account["blank_time"]) > time()) {
$account->save(["blank_time" => date("Y-m-d H:i:s", (strtotime($account["blank_time"]) + $timeSecond)), "blank_total" => (($account["blank_total"] ?? 0) + $time)]);
} else {
$account->save(["blank_time" => date("Y-m-d H:i:s", (time() + $timeSecond)), "blank_total" => (($account["blank_total"] ?? 0) + $time)]);
}
$info->save(["state" => CommentModel::state_hide]);
Db::commit();
return $this->json();
} catch (RepositoryException $e) {
Db::rollback();
return $this->json(5001, "失败");
} catch (Exception $e) {
Db::rollback();
return $this->json(5002, "失败");
}
}
$this->data["id"] = $id;
return $this->view();
}
/**
* 彻底删除
* @return Json
*/
public function del()
{
if (!$this->request->isPost()) {
return $this->json(4000, '非法请求');
}
$ids = $this->request->param('ids/a', []);
CommentModel::destroy($ids);
return $this->json();
}
/**
* 列表
*
* @return Json|View
* @throws Exception
*/
public function index()
{
$stateArray = CommentModel::allState();
$typeArray = CommentModel::allType();
if ($this->request->isPost()) {
$keyword = $this->request->param('keyword/s',);
$state = $this->request->param('state/d', "-1");
$type = $this->request->param('type/d', -1);
$page = $this->request->param('page/d', 1);
$size = $this->request->param('size/d', 30);
$whereMap = [["comment.is_delete", "=", CommentModel::COMMON_OFF]];
$orders = ['comment.id' => 'desc'];
if (!empty($keyword)) {
$whereMap[] = ['account.nick_name', 'like', "%$keyword%"];
}
if ($type >= 0) {
$whereMap[] = ['comment.type', '=', $type];
}
if (isset($stateArray[$state])) {
$whereMap[] = ['comment.state', '=', $state];
}
$list = CommentModel::findList($whereMap, [], $page, $size, function ($q) {
return $q->withJoin("account");
}, $orders);
return $this->json(0, 'success', $list);
}
$this->data["state"] = $stateArray;
$this->data["type"] = $typeArray;
return $this->view();
}
/**
* 列表
*
* @return Json|View
* @throws Exception
*/
public function recycleBin()
{
if ($this->request->isPost()) {
$keyword = $this->request->param('keyword/s',);
$page = $this->request->param('page/d', 1);
$size = $this->request->param('size/d', 30);
$whereMap = [["comment.is_delete", "=", CommentModel::COMMON_ON]];
if (!empty($keyword)) {
$whereMap[] = ['account.nick_name', 'like', "%$keyword%"];
}
$orders = ['comment.id' => 'desc'];
$list = CommentModel::findList($whereMap, [], $page, $size, function ($q) {
return $q->withJoin("account");
}, $orders);
return $this->json(0, 'success', $list);
}
return $this->view();
}
}

View File

@ -62,6 +62,10 @@ class Consumer extends Base
$item->coupon_used_count = Coupon::where(["consumer_code" => $item->user_code])->where("is_verificated", Coupon::is_verificated_on)->count("id");
//优惠券未使用总数
$item->coupon_not_use_count = Coupon::where(["consumer_code" => $item->user_code])->where("is_verificated", Coupon::is_verificated_off)->count("id");
//优惠红包总金额
$item->consumer_coupon_bill_total = AccountRepository::getInstance()->consumerCouponBillTotal($item->user_code);
});
return $this->json(0, 'success', $list);
@ -80,6 +84,7 @@ class Consumer extends Base
public function info()
{
$id = input("id/d", 0);
$sign = input("sign/d", 0);
$consumer = Account::findOne(["id" => $id], [], function ($q) {
return $q->with("tag");
});
@ -88,19 +93,23 @@ class Consumer extends Base
$repo = AccountRepository::getInstance();
$page = $this->request->param('page/d', 1);
$size = $this->request->param('size/d', 30);
$list = $repo->consumerCouponList($consumer['user_code'], $page, $size);
$where = [["consumer_code", "=", $consumer['user_code']]];
if ($sign) {
$where[] = ["is_verificated", "=", Coupon::is_verificated_on];
}
$list = $repo->consumerCouponList($where, $page, $size);
$time = time();
$list["list"]->each(function ($item) use ($time) {
if(strtotime($item['end_time']) < $time){
if (strtotime($item['end_time']) < $time) {
$item->time_state = '已过期';
}else{
} else {
$item->time_state = '未过期';
}
});
return $this->json(0, 'success', $list);
}
if (empty($consumer)) {
return $this->json(4001, "消费者不存在");
}
@ -119,6 +128,7 @@ class Consumer extends Base
$this->data["couponNotUsedTotalCount"] = $rep->consumerNotUsedTotalCoupon($consumer["user_code"]);
$this->data["consumer"] = $consumer->toArray();
$this->data["sign"] = $sign;
return $this->view();
}
@ -150,18 +160,26 @@ class Consumer extends Base
if (isset($stateArray[$state])) {
$whereMap[] = ['state', '=', $state];
}
$list = $repo->findList($whereMap, [], $page, $size, function ($q) {
return $q->with("tag");
}, $orders);
$list["list"]->each(function ($item) {
//优惠券领取总数
$item->coupon_total_count = Coupon::where(["consumer_code" => $item->user_code])->count("id");
//优惠券使用总数
$item->coupon_used_count = Coupon::where(["consumer_code" => $item->user_code])->where("is_verificated", Coupon::is_verificated_on)->count("id");
//优惠券未使用总数
$item->coupon_not_use_count = Coupon::where(["consumer_code" => $item->user_code])->where("is_verificated", Coupon::is_verificated_off)->count("id");
});
$list = $repo->findList($whereMap, [], $page, $size, null, $orders);
$time = time();
$list["list"]->each(function ($item) use ($time) {
//禁言总时长
$item->blank_total_format = formatBlankTime(date("Y-m-d H:i:s",$time + ($item->blank_total * 60)), date("Y-m-d H:i:s",$time ),);
// echo date("Y-m-d H:i:s",$time + $item->blank_total * 60);
// echo date("Y-m-d H:i:s",$time + $item->blank_total * 60);
// echo $item->blank_time;
//剩余禁言总时长
if(!empty($item->blank_time) && strtotime($item->blank_time)>$time){
$item->surplus_blank_total_format = formatBlankTime(
date("Y-m-d H:i:s",$time ),
$item->blank_time);
}else{
$item->surplus_blank_total_format = '';
}
});
return $this->json(0, 'success', $list);
}

View File

@ -0,0 +1,205 @@
<?php
namespace app\controller\manager;
use app\repository\CmsRepository;
use app\model\Tag as TagModel;
use Exception;
use think\facade\Db;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\exception\ValidateException;
use think\response\Json;
use think\response\View;
/**
* 消费者标签
*
* Class Category
* @package app\controller\manager
*/
class ConsumerTag extends Base
{
/**
* 编辑
*
* @return Json|View
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws Exception
*/
public function edit()
{
$id = input('id/d', 0);
if (!$info = TagModel::findById($id)) {
return $this->json(4001, '记录不存在');
}
if ($this->request->isPost()) {
$item = input('post.');
$validate = $this->validateByApi($item, [
'pid|父级分类' => 'require|number',
'name|标题' => 'require|max:100',
]);
if ($validate !== true) {
return $validate;
}
Db::startTrans();
try {
$info->save($item);
Db::commit();
return $this->json();
} catch (ValidateException $e) {
Db::rollback();
return $this->json(4001, $e->getError());
}
}
$disabled = TagModel::getAllChildrenIds($id);
$disabled[] = $id;
$this->data['jsonList'] = $this->categoryJson([$info['pid']], $disabled);
$this->data['item'] = $info;
return $this->view();
}
/**
* 单个字段编辑
*
* @return Json
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws Exception
*/
public function modify(): Json
{
if ($this->request->isPost()) {
$item = input('post.');
$validate = $this->validateByApi($item, [
'id|ID' => 'require|number',
'field|字段名' => 'require',
'value|值' => 'require',
]);
if ($validate !== true) {
return $validate;
}
if (!$info = TagModel::findById($item['id'])) {
return $this->json(4001, '记录不存在');
}
$update = [$item['field'] => $item['value']];
try {
$info->save($update);
return $this->json();
} catch (ValidateException $e) {
return $this->json(4001, $e->getError());
}
}
return $this->json(4000, '非法请求');
}
/**
* 添加
*
* @return Json|View
* @throws Exception
*/
public function add()
{
if ($this->request->isPost()) {
$item = input('post.');
$validate = $this->validateByApi($item, [
'pid|父级分类' => 'require|number',
'name|标题' => 'require|max:100',
]);
if ($validate !== true) {
return $validate;
}
try {
TagModel::create($item);
return $this->json();
} catch (ValidateException $e) {
return $this->json(4001, $e->getError());
}
}
$this->data['jsonList'] = $this->categoryJson();
return $this->view();
}
/**
* 删除
* @return Json
*/
public function del()
{
if (!$this->request->isPost()) {
return $this->json(4000, '非法请求');
}
$ids = $this->request->param('ids/a', []);
if(!empty(TagModel::findOne([["pid","in",$ids]]))){
return $this->json(5001,"该栏目还有下级 不能删除");
}
TagModel::destroy($ids);
return $this->json();
}
/**
* 列表
*
* @return Json|View
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function index()
{
if ($this->request->isPost()) {
$menus = TagModel::getList();
$res = [
'code' => 0,
'msg' => 'success',
'count' => $menus->count(),
'data' => $menus->toArray(),
];
return json($res);
}
return $this->view();
}
/**
* @param array $selected
* @param array $disabled
* @return false|string
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
private function categoryJson(array $selected = [], array $disabled = [])
{
$categoryList[] = ['name' => '顶级分类', 'id' => 0, 'disabled' => false, 'selected' => in_array(0, $selected)];
$list = TagModel::getListByPid();
$list = $list->toArray();
foreach ($list as $k => $m) {
$list[$k]['selected'] = in_array($m['id'], $selected);
$list[$k]['disabled'] = in_array($m['id'], $disabled);
}
$list = CmsRepository::getInstance()->buildMenuChild(0, $list);
$categoryList = array_merge($categoryList, CmsRepository::getInstance()->handleSelectedList($list));
return json_encode($categoryList, JSON_UNESCAPED_UNICODE);
}
}

View File

@ -322,22 +322,7 @@ class Base extends Model
return $path;
}
/**
* 刷新路径
*
* @param int $pid
* @param array $data 默认全部 若data不为空 至少包含[id,path, $pidField]
* @param string $pidField 父级ID字段名 默认 pid
* @throws Exception
*/
public static function refreshPath(int $pid = 0, array $data = [], string $pidField = 'pid')
{
$data = !empty($data) ? $data : self::column('id,path,'.$pidField);
$updateAllPaths = [];
self::recursionPath($pid, $data, $updateAllPaths);
(new static())->saveAll($updateAllPaths);
}
/**
* 获取递归最新路径

View File

@ -30,7 +30,7 @@ class Category extends Base
}
/**
* 获取全部病种列表
* 获取全部列表
*
* @return Disease[]|array|Collection
* @throws DataNotFoundException

View File

@ -1,8 +1,39 @@
<?php
namespace app\model;
//评论表
class Comment extends Base
{
//评论表
public const state_default = 0;// 待审核
public const state_success = 1;// 3审核通过
public const state_hide = 2;// 2隐藏
public const type_text = 0;// 文本
public const type_img = 1;// 图片
public const type_voice = 2;// 语音
public static function allState(){
return [
self::state_default=>"待审核",
self::state_success=>"审核通过",
self::state_hide=>"隐藏",
];
}
public static function allType(){
return [
self::type_text=>"文本",
self::type_img=>"图片",
self::type_voice=>"语音",
];
}
public function account()
{
return $this->hasOne(Account::class,"user_code","user_code");
}
public function business()
{
return $this->hasOne(Business::class,"code","business_code");
}
}

View File

@ -17,4 +17,10 @@ class Coupon extends Base
//是否验证
const is_verificated_on = 1;//1已验证
const is_verificated_off = 0;//0未验证
public function couponBill()
{
return $this->hasOne(CouponBill::class,"coupon_id","id");
}
}

18
app/model/CouponBill.php Normal file
View File

@ -0,0 +1,18 @@
<?php
namespace app\model;
use think\Collection;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
/**
* 优惠券验证记录 各个角色的提成
* Class Coupon
* @package app\model
*/
class CouponBill extends Base
{
}

View File

@ -3,8 +3,61 @@
namespace app\model;
use Exception;
use think\Collection;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\exception\ValidateException;
class Tag extends Base
{
/**
* 根据父级ID 获取病种列表
*
* @param int $pid
* @param string[] $fields
* @return Disease[]|array|Collection
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public static function getListByPid(int $pid = 0, array $fields = ['pid', 'name', 'id'])
{
return self::where('pid', $pid)->order('id', 'desc')->field($fields)->select();
}
/**
* 获取全部列表
*
* @return Disease[]|array|Collection
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public static function getList()
{
return self::field('id,pid,name')->order('id', 'desc')->order('id')->select();
}
/**
* 病种 xmSelect json数据
*
* @param int $pid
* @param array $selected
* @param array $disabled
* @return array|Disease[]|Collection
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public static function diseaseXmJson(int $pid = 0, array $selected = [], array $disabled = [])
{
$list = self::getListByPid($pid);
foreach ($list as $k => $m) {
$list[$k]['selected'] = in_array($m['id'], $selected);
$list[$k]['disabled'] = in_array($m['id'], $disabled);
}
return $list;
}
}

View File

@ -6,6 +6,7 @@ use app\exception\RepositoryException;
use app\service\Repository;
use app\traits\CommentTrait;
use app\traits\CouponBillTrait;
use app\traits\CouponTrait;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
@ -23,6 +24,7 @@ class AccountRepository extends Repository
{
use CommentTrait;
use CouponTrait;
use CouponBillTrait;
/**
* 获取指定账户记录By手机号
*

View File

@ -0,0 +1,18 @@
<?php
namespace app\traits;
use think\Model;
use app\model\CouponBill;
trait CouponBillTrait
{
//消费者 验证优惠券获得的红包总数
public function consumerCouponBillTotal($userCode)
{
return CouponBill::where("user_code",$userCode)->sum("consumer_money");
}
}

View File

@ -48,9 +48,11 @@ trait CouponTrait
* @return array
* @throws \Exception
*/
public function consumerCouponList($userCode, $page, $size)
public function consumerCouponList($where, $page, $size)
{
return Coupon::findList(["consumer_code" => $userCode], [], $page, $size, null, ["id" => "desc"]);
return Coupon::findList($where, [], $page, $size, function ($q){
return $q->with("couponBill");
}, ["id" => "desc"]);
}

View File

@ -0,0 +1,109 @@
layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function () {
let $ = layui.jquery,
form = layui.form,
table = layui.table,
layer = layui.layer,
xmSelect = layui.xmSelect,
miniTab = layui.miniTab;
/**** index begin ***/
//index页面
if ($('.location-index-page').length > 0) {
miniTab.listen();
// 渲染表格
let listUrl = $('#table-container').data('url');
let insTb = table.render({
elem: '#table-container',
toolbar: '#toolbar-tpl',
defaultToolbar: [{ //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可
title: '搜索'
, layEvent: 'search'
, icon: 'layui-icon-search'
}],
url: listUrl,
method: 'post',
even: true,
limits: [10,20,50,100,200,500,1000],
request: {
pageName: 'page',
limitName: 'size',
},
parseData: function (res) {
return {
"code": res.code, //解析接口状态
"msg": res.msg, //解析提示文本
"count": res.data.total, //解析数据长度
"data": res.data.list //解析数据列表
};
},
page: true,
cols: [[
// {type: 'checkbox'},
{field: 'id' , width: 80, title: 'ID'},
{templet: '#row-cover', title: '头像', style: 'height: 90px;'},
{templet:function(d){
if( d.account != undefined){
return d.account.nick_name
}
return '';
},title: '昵称'},
{templet: '#row-gender', title: '性别'},
{field: 'create_time', title: '评论时间'},
{templet: '#row-comment', minWidth: 350, title: '评论内容'},
{templet: '#row-state', title: '状态'},
{templet: '#row-operate', field: 'right', align: 'center', title: '操作', fixed: 'right'}
]],
done: function () {
Tools.setInsTb(insTb);
}
});
// 监听搜索操作
form.on('submit(data-search-btn)', function (data) {
//执行搜索重载
table.reload('table-container', {
page: {curr: 1}
, where: data.field
}, 'data');
return false;
});
//监听行工具条
table.on('tool(table-container)', function (obj) {
let data = obj.data;
let layEvent = obj.event;
let url = $($(this).context).data('href');
let title = $($(this).context).data('title');
let width = $($(this).context).data('width') ? $($(this).context).data('width') : '100%';
let height = $($(this).context).data('height') ? $($(this).context).data('height') : '100%';
let insTb = Tools.getInsTb();
switch (layEvent) {
// 行 删除
case 'examine':
$.post(url, {}, function (res) {
layer.msg(res.msg)
if (res.code === 0) {
insTb.reload();
}
})
return false; // 行 删除
case 'black':
openLayer(url, title, width, height);
return false;
case 'del':
delRow(url, [data.id], insTb);
return false;
}
});
}
/*** index end ***/
});

View File

@ -0,0 +1,72 @@
layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function () {
let $ = layui.jquery,
form = layui.form,
table = layui.table,
layer = layui.layer,
xmSelect = layui.xmSelect,
miniTab = layui.miniTab;
/**** index begin ***/
//index页面
if ($('.location-index-page').length > 0) {
miniTab.listen();
// 渲染表格
let listUrl = $('#table-container').data('url');
let insTb = table.render({
elem: '#table-container',
toolbar: '#toolbar-tpl',
defaultToolbar: [{ //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可
title: '搜索'
, layEvent: 'search'
, icon: 'layui-icon-search'
}],
url: listUrl,
method: 'post',
even: true,
limits: [10,20,50,100,200,500,1000],
request: {
pageName: 'page',
limitName: 'size',
},
parseData: function (res) {
return {
"code": res.code, //解析接口状态
"msg": res.msg, //解析提示文本
"count": res.data.total, //解析数据长度
"data": res.data.list //解析数据列表
};
},
page: true,
cols: [[
// {type: 'checkbox'},
{field: 'id' , width: 80, title: 'ID'},
{templet: '#row-cover', title: '头像', style: 'height: 90px;'},
{field: 'nick_name', title: '昵称'},
{templet: '#row-gender', title: '性别'},
{field: 'blank_total_format', title: '禁言总时长'},
{field: 'surplus_blank_total_format', title: '剩余禁言时长'},
{templet: '#row-operate', minWidth: 350, field: 'right', align: 'center', title: '操作', fixed: 'right'}
]],
done: function () {
Tools.setInsTb(insTb);
}
});
// 监听搜索操作
form.on('submit(data-search-btn)', function (data) {
//执行搜索重载
table.reload('table-container', {
page: {curr: 1}
, where: data.field
}, 'data');
return false;
});
}
/*** index end ***/
});

View File

@ -43,10 +43,11 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function
{field: 'id' , width: 80, title: 'ID'},
{templet: '#row-cover', title: '头像', style: 'height: 90px;'},
{field: 'nick_name', title: '昵称'},
{field: 'gender', title: '性别'},
{templet: '#row-gender', title: '性别'},
{field: 'coupon_total_count', title: '优惠券领取数'},
{field: 'coupon_used_count', title: '优惠券使用数'},
{field: 'coupon_not_use_count', title: '优惠券未使用数'},
{field: 'consumer_coupon_bill_total', title: '红包总数'},
{field: 'login_time', title: '最近登录'},

View File

@ -39,8 +39,11 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function
{field: 'id' , width: 80, title: 'ID'},
{field: 'name', title: '名称'},
{field: 'type_name', title: '优惠券类型'},
{templet: '#row-received_map', title: '领取位置'},
{field: 'money', title: '金额'},
{field: 'business_name', title: '商家名称'},
{field: 'business_name', title: '商家名称'},
{templet: '#row-sign_map', title: '签到位置'},
{templet: '#row-state', title: '状态'},
]],
done: function () {

View File

@ -0,0 +1,189 @@
layui.use(['laytpl', 'treeTable','jquery', 'form', 'miniTab', 'xmSelect'], function () {
let $ = layui.jquery,
form = layui.form,
treeTable = layui.treeTable,
layer = layui.layer,
miniTab = layui.miniTab,
xmSelect = layui.xmSelect;
let modifyUrl = $('#row-modify').data('url');
/**** index begin ***/
//index页面
if ($('.location-index-page').length > 0) {
miniTab.listen();
// 渲染表格
let listUrl = $('#menu-table').data('url');
let insTb = treeTable.render({
elem: '#menu-table',
toolbar: '#toolbar-tpl',
defaultToolbar: [],
method: 'POST',
skin: 'line',
url: listUrl,
page: false,
tree: {
iconIndex: 1, // 折叠图标显示在第几列
isPidData: true, // 是否是id、pid形式数据
idName: 'id', // id字段名称
pidName: 'pid' // pid字段名称
},
cols: [[
{type: 'checkbox'},
{field: 'name', minWidth: 200, title: '名称'},
{field: 'commision', width: 80, align: 'center', title: '默认佣金', edit: 'text'},
{templet: '#menu-operate', width: 150, align: 'center', title: '操作'}
]],
done: function () {
}
});
//监听单元格编辑
treeTable.on('edit(menu-table)', function(obj){
$.post(modifyUrl, {id: obj.data.id, field: obj.field, value: obj.value}, function (res) {
layer.msg(res.msg)
if (res.code === 0) {
insTb.refresh();
}
})
});
//监听工具条 注意区别toolbar和tool toolbar是表头上的工具条 tool是行中的工具条
treeTable.on('toolbar(menu-table)', function (obj) {
let layEvent = obj.event;
if (layEvent === 'expand') {
insTb.expandAll();
return false;
}
if (layEvent === 'fold') {
insTb.foldAll();
return false;
}
if (layEvent === 'del') {
let selected = insTb.checkStatus(false);
let ids = [];
let url = $(obj.elem.context).data('href')
$.each(selected, function (index, val) {
ids.push(val.id);
})
del(url, ids);
return false;
}
if (layEvent === 'add') {
let url = $(obj.elem.context).data('href');
let title = $(obj.elem.context).data('title');
let index = layer.open({
title: title,
type: 2,
shade: 0.2,
maxmin: true,
shadeClose: true,
area: ['100%', '100%'],
content: url,
});
$(window).on("resize", function () {
layer.full(index);
});
return false;
}
});
//刷新
$('body').on('click', '[data-table-refresh]', function () {
insTb.refresh();
});
//删除
function del(url, ids) {
let index = layer.confirm('确认删除吗?', {
btn: ['确认','取消'], //按钮
title: '操作提示',
}, function() {
$.post(url, {ids: ids}, function (res) {
layer.msg(res.msg)
if (res.code === 0) {
insTb.refresh();
}
})
}, function(){
layer.close(index)
return false;
});
}
//监听工具条
treeTable.on('tool(menu-table)', function (obj) {
let data = obj.data;
let layEvent = obj.event;
let url = $(obj.tr.context).data('href');
let title = $(obj.tr.context).data('title');
if (layEvent === 'del') {
let ids = [data.id];
del(url, ids);
return false;
}
if (layEvent === 'edit') {
let index = layer.open({
title: title,
type: 2,
shade: 0.2,
maxmin: true,
shadeClose: true,
area: ['100%', '100%'],
content: url,
});
$(window).on("resize", function () {
layer.full(index);
});
return false;
}
});
}
/*** index end ***/
// add和edit页面
if ($('.location-operate-page').length > 0) {
let parentMenu = $('#parent-menu');
let menuList = parentMenu.data('menu') ? parentMenu.data('menu') : [];
xmSelect.render({
el: '#parent-menu',
paging: false,
autoRow: true,
radio: true,
clickClose: true,
name: 'pid',
tips: '请选择上级分类',
direction: 'auto',
height: 'auto',
model: {
icon: 'hidden',
},
prop: {
name: 'name',
value: 'id',
},
tree: {
show: true,
strict: false,
clickCheck: true,
expandedKeys: true,
clickExpand: false
},
theme: {
color: '#1e84ff',
},
data: menuList
});
}
});

View File

@ -0,0 +1,21 @@
{layout name="manager/layout" /}
<div class="layuimini-container location-operate-page">
<div class="layuimini-main">
<div class="layui-form layuimini-form">
<div class="layui-form-item">
<label class="layui-form-label required">黑名单时间(分)</label>
<div class="layui-input-block">
<input type="number" name="time" lay-verify="required" lay-reqtext="标题不能为负数" placeholder="请输入" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<input type="hidden" name="id" value="{$id}">
<button class="layui-btn layui-btn-normal" data-url="/manager/comment/add-black" lay-submit lay-filter="saveBtn">确认保存</button>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,137 @@
{layout name="manager/layout" /}
<style>
.layui-table-cell{
height: auto;
white-space: normal;
}
.layui-table .layui-layer-photos {height: 90px;}
.layui-table img{
max-height: 100%;
object-fit: cover;
margin-left: auto;
margin-right: auto;
display: block;
max-width: 150px;
vertical-align: middle;
border: 0;
}
</style>
<div class="layui-row layui-col-space12">
<div class="layui-col-xs12 layui-col-md12">
<div id="echarts-records" style="background-color:#ffffff;min-height:600px;">
<div class="layuimini-container location-index-page">
<div class="layuimini-main">
<fieldset class="table-search-fieldset" style="display: none">
<legend>搜索信息</legend>
<div style="margin: 10px 10px 10px 10px">
<form class="layui-form layui-form-pane" action="">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">关键词</label>
<div class="layui-inline">
<input type="text" name="keyword" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">状态</label>
<div class="layui-inline">
<select name="state" >
<option value=""></option>
{foreach $state as $key=> $sitem }
<option value="{$key}">{$sitem}</option>
{/foreach}
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">类型</label>
<div class="layui-inline">
<select name="type" >
<option value=""></option>
{foreach $type as $key=> $sitem }
<option value="{$key}">{$sitem}</option>
{/foreach}
</select>
</div>
</div>
<div class="layui-inline">
<button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
</div>
</div>
</form>
</div>
</fieldset>
<div>
<table id="table-container" class="layui-table" data-url="/manager/comment/index" lay-filter="table-container"></table>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 操作列 -->
<script type="text/html" id="row-operate">
{{# if(d.state==0){ }}
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/comment/examine.html?id={{d.id}}&&state=1" lay-event="examine">通过</a>
{{# } }}
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/comment/add-black.html?id={{d.id}}&&sign=1" data-title="加入黑名单" lay-event="black">加入黑名单</a>
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/comment/examine.html?id={{d.id}}&&state=2" lay-event="examine">删除</a>
</script>
<!-- toolbar -->
<script type="text/html" id="toolbar-tpl">
<a class="layui-btn layui-btn-primary layui-btn-sm" data-table-refresh lay-event="refresh"><i class="fa fa-refresh"></i></a>
</script>
<!-- 列 性别 -->
<script type="text/html" id="row-gender">
{{# if(d.account.gender==1){ }}
{{# }else{ }}
{{# } }}
</script>
<!-- 列 性别 -->
<script type="text/html" id="row-state">
{{# if(d.state==0){ }}
待审核
{{# }else if(d.state==1){ }}
显示
{{# }else if(d.state==2){ }}
隐藏
{{# } }}
{{# if(d.is_blank==1){ }}
| 已禁言
{{# } }}
</script>
<!---->
<script type="text/html" id="row-comment">
{{# if(d.type==1){ }}
<div class="layui-layer-photos">
<img src="{{ d.comment }}" layer-src="{{ d.comment }}" alt="">
</div>
{{# }else if(d.type==0){ }}
{{ d.comment }}
{{# }else if (d.type==1){ }}
<div class="layui-layer-photos">
<img src="{{ d.comment }}" layer-src="{{ d.account }}" alt="">
</div>
{{# }else{ }}
<audio src="{{ d.comment }}" controls="controls">Your browser does not support the audio element.</audio>
{{# } }}
</script>
<!-- 列 轮播图 -->
<script type="text/html" id="row-cover">
<div class="layui-layer-photos">
<img src="{{ d.account.avatar_url }}" layer-src="{{ d.account.avatar_url }}" alt="">
</div>
</script>
<script src="__MANAGER__/js/business/comment.js?v={:mt_rand()}"></script>

View File

@ -0,0 +1,113 @@
{layout name="manager/layout" /}
<style>
.layui-table-cell{
height: auto;
white-space: normal;
}
.layui-table .layui-layer-photos {height: 90px;}
.layui-table img{
max-height: 100%;
object-fit: cover;
margin-left: auto;
margin-right: auto;
display: block;
max-width: 150px;
vertical-align: middle;
border: 0;
}
</style>
<div class="layui-row layui-col-space12">
<div class="layui-col-xs12 layui-col-md12">
<div id="echarts-records" style="background-color:#ffffff;min-height:600px;">
<div class="layuimini-container location-index-page">
<div class="layuimini-main">
<fieldset class="table-search-fieldset" style="display: none">
<legend>搜索信息</legend>
<div style="margin: 10px 10px 10px 10px">
<form class="layui-form layui-form-pane" action="">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">关键词</label>
<div class="layui-inline">
<input type="text" name="keyword" class="layui-input">
</div>
</div>
<div class="layui-inline">
<button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
</div>
</div>
</form>
</div>
</fieldset>
<div>
<table id="table-container" class="layui-table" data-url="/manager/comment/recycle-bin" lay-filter="table-container"></table>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 操作列 -->
<script type="text/html" id="row-operate">
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/comment/recovery.html?id={{d.id}}" lay-event="examine">恢复</a>
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/comment/del.html" data-id="{{d.id}}" lay-event="del">删除</a>
</script>
<!-- toolbar -->
<script type="text/html" id="toolbar-tpl">
<a class="layui-btn layui-btn-primary layui-btn-sm" data-table-refresh lay-event="refresh"><i class="fa fa-refresh"></i></a>
</script>
<!-- 列 性别 -->
<script type="text/html" id="row-gender">
{{# if(d.account.gender==1){ }}
{{# }else{ }}
{{# } }}
</script>
<!---->
<script type="text/html" id="row-state">
{{# if(d.state==0){ }}
待审核
{{# }else if(d.state==1){ }}
显示
{{# }else if(d.state==2){ }}
隐藏
{{# } }}
{{# if(d.is_blank==1){ }}
| 已禁言
{{# } }}
</script>
<!---->
<script type="text/html" id="row-comment">
{{# if(d.type==1){ }}
<div class="layui-layer-photos">
<img src="{{ d.comment }}" layer-src="{{ d.comment }}" alt="">
</div>
{{# }else if(d.type==0){ }}
{{ d.comment }}
{{# }else if (d.type==1){ }}
<div class="layui-layer-photos">
<img src="{{ d.comment }}" layer-src="{{ d.account }}" alt="">
</div>
{{# }else{ }}
<audio src="{{ d.comment }}" controls="controls">Your browser does not support the audio element.</audio>
{{# } }}
</script>
<!-- 列 轮播图 -->
<script type="text/html" id="row-cover">
<div class="layui-layer-photos">
<img src="{{ d.account.avatar_url }}" layer-src="{{ d.account.avatar_url }}" alt="">
</div>
</script>
<script src="__MANAGER__/js/business/comment.js?v={:mt_rand()}"></script>

View File

@ -126,7 +126,7 @@
</div>
<div class="layui-form-item layui-form-item-lg">
<label class="layui-form-label">加入黑名单时长:</label>
<label class="layui-form-label">加入黑名单时长</label>
<div class="layui-input-inline">
<input class="layui-input" type="text" name="blackTime" value="{$item.blackTime ?? ''}"/>
</div>
@ -134,7 +134,7 @@
</div>
<div class="layui-form-item layui-form-item-lg">
<label class="layui-form-label">评论显示数::</label>
<label class="layui-form-label">评论显示数</label>
<div class="layui-input-inline">
<input class="layui-input" type="text" name="commentNum" value="{$item.commentNum ?? 10}"/>
</div>

View File

@ -49,7 +49,7 @@
</div>
</fieldset>
<div>
<table id="table-container" class="layui-table" data-url="/manager/consumer/index" lay-filter="table-container"></table>
<table id="table-container" class="layui-table" data-url="/manager/consumer/blank_list" lay-filter="table-container"></table>
</div>
</div>
</div>
@ -60,8 +60,9 @@
<!-- 操作列 -->
<script type="text/html" id="row-operate">
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/consumer/info.html?id={{d.id}}" data-title="消费者【{{ d.nick_name }}】详情" lay-event="">详情</a>
<!-- <a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/consumer/edit.html?id={{d.id}}" data-title="消费者【{{ d.nick_name }}】审核修改" lay-event="">审核修改</a>-->
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/consumer/info.html?id={{d.id}}" data-title="消费者【{{ d.nick_name }}】领取日志" lay-event="">领取日志</a>
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/consumer/info.html?id={{d.id}}&&sign=1" data-title="消费者【{{ d.nick_name }}】签到日志" lay-event="">签到日志</a>
<!-- <a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/consumer/edit.html?id={{d.id}}" data-title="消费者【{{ d.nick_name }}】审核修改" lay-event="">审核修改</a>-->
</script>
<!-- toolbar -->
@ -69,6 +70,16 @@
<a class="layui-btn layui-btn-primary layui-btn-sm" data-table-refresh lay-event="refresh"><i class="fa fa-refresh"></i></a>
</script>
<!-- 列 性别 -->
<script type="text/html" id="row-gender">
{{# if(d.gender==1){ }}
{{# }else{ }}
{{# } }}
</script>
<!-- 列 轮播图 -->
<script type="text/html" id="row-cover">
<div class="layui-layer-photos">
@ -76,4 +87,4 @@
</div>
</script>
<script src="__MANAGER__/js/consumer/index.js?v={:mt_rand()}"></script>
<script src="__MANAGER__/js/consumer/blank_list.js?v={:mt_rand()}"></script>

View File

@ -27,20 +27,26 @@
<div style="margin: 10px 10px 10px 10px">
<form class="layui-form layui-form-pane" action="">
<div class="layui-form-item">
<label class="layui-form-label">关键词</label>
<div class="layui-inline">
<input type="text" name="keyword" class="layui-input">
<label class="layui-form-label">关键词</label>
<div class="layui-inline">
<input type="text" name="keyword" class="layui-input">
</div>
</div>
<label class="layui-form-label">状态</label>
<div class="layui-inline">
<select name="state" id="">
<option value=""></option>
{foreach $state as $key=> $sitem }
<option value="{$key}">{$sitem}</option>
{/foreach}
</select>
<label class="layui-form-label">状态</label>
<div class="layui-inline">
<select name="state" id="">
<option value=""></option>
{foreach $state as $key=> $sitem }
<option value="{$key}">{$sitem}</option>
{/foreach}
</select>
</div>
</div>
<div class="layui-inline">
<button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
</div>
@ -60,7 +66,8 @@
<!-- 操作列 -->
<script type="text/html" id="row-operate">
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/consumer/info.html?id={{d.id}}" data-title="消费者【{{ d.nick_name }}】详情" lay-event="">详情</a>
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/consumer/info.html?id={{d.id}}" data-title="消费者【{{ d.nick_name }}】领取日志" lay-event="">领取日志</a>
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/consumer/info.html?id={{d.id}}&&sign=1" data-title="消费者【{{ d.nick_name }}】签到日志" lay-event="">签到日志</a>
<!-- <a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/consumer/edit.html?id={{d.id}}" data-title="消费者【{{ d.nick_name }}】审核修改" lay-event="">审核修改</a>-->
</script>
@ -68,6 +75,14 @@
<script type="text/html" id="toolbar-tpl">
<a class="layui-btn layui-btn-primary layui-btn-sm" data-table-refresh lay-event="refresh"><i class="fa fa-refresh"></i></a>
</script>
<!-- 列 性别 -->
<script type="text/html" id="row-gender">
{{# if(d.gender==1){ }}
{{# }else{ }}
{{# } }}
</script>
<!-- 列 轮播图 -->
<script type="text/html" id="row-cover">

View File

@ -95,7 +95,7 @@
<div class="layuimini-container location-index-page">
<div class="layuimini-main">
<div>
<table id="table-container" class="layui-table" data-url="/manager/consumer/info.html?id={$consumer.id}" lay-filter="table-container"></table>
<table id="table-container" class="layui-table" data-url="/manager/consumer/info.html?id={$consumer.id}&&sign={$sign}" lay-filter="table-container"></table>
</div>
</div>
</div>
@ -115,6 +115,16 @@
{{# } }}
</script>
<!-- 领取位置 -->
<script type="text/html" id="row-received_map">
<a href="" target="_blank">点击查看</a>
</script>
<!-- 签到位置 -->
<script type="text/html" id="row-sign_map">
<a href="" target="_blank">点击查看</a>
</script>
<!-- toolbar -->
<script type="text/html" id="toolbar-tpl">
<a class="layui-btn layui-btn-primary layui-btn-sm" data-table-refresh lay-event="refresh"><i class="fa fa-refresh"></i></a>

View File

@ -0,0 +1,29 @@
{layout name="manager/layout" /}
<style>
.layui-iconpicker-body.layui-iconpicker-body-page .hide {display: none;}
</style>
<div class="layuimini-container location-operate-page">
<div class="layuimini-main">
<div class="layui-form layuimini-form">
<div class="layui-form-item">
<label class="layui-form-label required">上级</label>
<div class="layui-input-block">
<div id="parent-menu" data-menu="{$jsonList ?? ''}" class="xm-select-demo"></div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">标题</label>
<div class="layui-input-block">
<input type="text" name="name" lay-verify="required" lay-reqtext="标题不能为空" placeholder="请输入标题" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn layui-btn-normal" data-url="/manager/consumer-tag/add" lay-submit lay-filter="saveBtn">确认保存</button>
</div>
</div>
</div>
</div>
</div>
<script src="__MANAGER__/js/consumer_tag.js?v={:mt_rand()}"></script>

View File

@ -0,0 +1,29 @@
{layout name="manager/layout" /}
<style>
.layui-iconpicker-body.layui-iconpicker-body-page .hide {display: none;}
</style>
<div class="layuimini-container location-operate-page">
<div class="layuimini-main">
<div class="layui-form layuimini-form">
<div class="layui-form-item">
<label class="layui-form-label required">上级</label>
<div class="layui-input-block">
<div id="parent-menu" data-menu="{$jsonList ?? ''}" class="xm-select-demo"></div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">标题</label>
<div class="layui-input-block">
<input type="text" name="name" lay-verify="required" value="{$item.name ?? ''}" lay-reqtext="标题不能为空" placeholder="请输入标题" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn layui-btn-normal" data-url="/manager/consumer-tag/edit?id={$item.id}" lay-submit lay-filter="saveBtn">确认保存</button>
</div>
</div>
</div>
</div>
</div>
<script src="__MANAGER__/js/consumer_tag.js?v={:mt_rand()}"></script>

View File

@ -0,0 +1,29 @@
{layout name="manager/layout" /}
<div class="layuimini-container location-index-page">
<div class="layuimini-main">
<div>
<table id="menu-table" class="layui-table" data-url="/manager/consumer-tag" lay-filter="menu-table"></table>
</div>
</div>
</div>
<!-- 隐藏列 -->
<!-- 编辑单元格提交url -->
<input type="hidden" id="row-modify" data-url="/manager/consumer-tag/modify">
<!-- 操作列 -->
<script type="text/html" id="menu-operate">
<a class="layui-btn layui-btn-primary layui-btn-xs menu-edit" data-href="/manager/consumer-tag/edit.html?id={{d.id}}" data-title="编辑" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" data-href="/manager/consumer-tag/del.html" lay-event="del">删除</a>
</script>
<!-- toolbar -->
<script type="text/html" id="toolbar-tpl">
<a class="layui-btn layui-btn-primary layui-btn-sm" data-table-refresh><i class="fa fa-refresh"></i></a>
<a class="layui-btn layui-btn-warm layui-btn-sm" lay-event="expand">全部展开</a>
<a class="layui-btn layui-btn-info layui-btn-sm" lay-event="fold">全部折叠</a>
<a class="layui-btn layui-btn-normal layui-btn-sm" data-href="/manager/consumer-tag/add.html" data-title="添加" lay-event="add">添加</a>
<!-- <a class="layui-btn layui-btn-danger layui-btn-sm" data-href="/manager/consumer-tag/del.html" lay-event="del">批量删除</a>-->
</script>
<script src="__MANAGER__/js/consumer_tag.js?v={:mt_rand()}"></script>