From 134267fcd9c2488abb24fad7b47bc8583c548682 Mon Sep 17 00:00:00 2001 From: MiAn Date: Thu, 19 Nov 2026 09:16:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E4=B8=BE=E6=8A=A5?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E5=8A=9F=E8=83=BD=E5=8F=8A=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E3=80=81=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增举报详情页面路由与配置 新增举报详情接口及路由规则 新增举报列表状态筛选功能 新增错误信息标准化处理方法 优化举报列表页面UI交互 完善微信登录异常提示处理 --- application/admin/controller/fc/Area.php | 10 + application/admin/controller/fc/Banner.php | 45 ++ application/admin/controller/fc/Category.php | 9 + application/admin/controller/fc/Comment.php | 52 ++ application/admin/controller/fc/Dashboard.php | 724 +++++++++++++----- application/admin/controller/fc/Post.php | 46 ++ application/admin/controller/fc/Postaudit.php | 6 + application/admin/controller/fc/Report.php | 16 + application/admin/lang/zh-cn/fc/dashboard.php | 35 + application/admin/view/fc/comment/index.html | 2 + .../admin/view/fc/dashboard/index.html | 201 +++-- application/admin/view/fc/message/index.html | 2 +- application/admin/view/fc/post/index.html | 2 +- application/api/controller/Auth.php | 72 +- application/api/controller/Post.php | 86 ++- application/api/controller/Report.php | 140 +++- application/common/library/WxMini.php | 115 ++- application/route.php | 5 +- public/assets/css/backend-theme.css | 176 +++++ public/assets/js/backend/fc/comment.js | 68 ++ public/assets/js/backend/fc/dashboard.js | 448 +++++++---- uniapp/common/api/post.js | 2 + uniapp/common/api/report.js | 12 +- uniapp/common/utils/request.js | 38 +- .../fc-area-picker/fc-area-picker.vue | 1 + .../fc-report-modal/fc-report-modal.vue | 8 +- uniapp/pages.json | 9 + uniapp/pages/detail/detail.vue | 53 +- uniapp/pages/mine/report-detail.vue | 688 +++++++++++++++++ uniapp/pages/mine/reports.vue | 343 ++++++--- uniapp/pages/post/create.vue | 7 +- 31 files changed, 2849 insertions(+), 572 deletions(-) create mode 100644 uniapp/pages/mine/report-detail.vue diff --git a/application/admin/controller/fc/Area.php b/application/admin/controller/fc/Area.php index 43648e4..89fb35e 100644 --- a/application/admin/controller/fc/Area.php +++ b/application/admin/controller/fc/Area.php @@ -19,6 +19,12 @@ class Area extends Backend */ protected $model = null; + /** + * 快速搜索字段 + * @var string + */ + protected $searchFields = 'id,province,city,district'; + public function _initialize() { parent::_initialize(); @@ -101,5 +107,9 @@ class Area extends Backend $this->error($field === 'lat' ? '纬度格式不正确' : '经度格式不正确'); } } + + if (isset($params['sort']) && $params['sort'] !== '' && (int)$params['sort'] < 0) { + $this->error('排序权重不能为负数'); + } } } diff --git a/application/admin/controller/fc/Banner.php b/application/admin/controller/fc/Banner.php index 4bae53f..4701325 100644 --- a/application/admin/controller/fc/Banner.php +++ b/application/admin/controller/fc/Banner.php @@ -18,11 +18,56 @@ class Banner extends Backend */ protected $model = null; + /** + * 快速搜索字段 + * @var string + */ + protected $searchFields = 'id,title'; + public function _initialize() { parent::_initialize(); $this->model = new \app\admin\model\FcBanner; + } + /** + * 新增轮播图前校验排序权重等边界值 + * + * @return string + */ + public function add() + { + if ($this->request->isPost()) { + $this->validateBannerParams($this->request->post('row/a', [])); + } + return parent::add(); + } + + /** + * 编辑轮播图前校验排序权重等边界值 + * + * @param mixed $ids + * @return string + */ + public function edit($ids = null) + { + if ($this->request->isPost()) { + $this->validateBannerParams($this->request->post('row/a', [])); + } + return parent::edit($ids); + } + + /** + * 校验轮播图表单边界参数 + * + * @param array $params + * @return void + */ + protected function validateBannerParams(array $params) + { + if (isset($params['sort']) && $params['sort'] !== '' && (int)$params['sort'] < 0) { + $this->error('排序权重不能为负数'); + } } diff --git a/application/admin/controller/fc/Category.php b/application/admin/controller/fc/Category.php index 0eb34e8..25fa0fa 100644 --- a/application/admin/controller/fc/Category.php +++ b/application/admin/controller/fc/Category.php @@ -19,6 +19,12 @@ class Category extends Backend */ protected $model = null; + /** + * 快速搜索字段 + * @var string + */ + protected $searchFields = 'id,name,icon_key'; + protected $noNeedRight = ['selectpage']; /** @@ -225,6 +231,9 @@ class Category extends Backend */ protected function normalizeCategoryParams(array $params, $currentId = 0) { + if (isset($params['sort']) && $params['sort'] !== '' && (int)$params['sort'] < 0) { + $this->error('排序权重不能为负数'); + } $pid = isset($params['pid']) ? max(0, (int)$params['pid']) : 0; if ($currentId > 0 && $pid === $currentId) { $pid = 0; diff --git a/application/admin/controller/fc/Comment.php b/application/admin/controller/fc/Comment.php index 63499a0..0ab8a67 100644 --- a/application/admin/controller/fc/Comment.php +++ b/application/admin/controller/fc/Comment.php @@ -93,6 +93,58 @@ class Comment extends Backend $this->success($top === 1 ? '置顶成功' : '取消置顶成功'); } + /** + * 切换评价显示/隐藏状态(支持单条与批量) + * + * @return void + */ + public function status() + { + $ids = $this->request->post('ids'); + $status = (int)$this->request->post('status', -1); + $reason = trim((string)$this->request->post('reason', '')); + if (!in_array($status, [0, 1], true)) { + $this->error('状态参数错误'); + } + $ids = is_array($ids) ? $ids : explode(',', (string)$ids); + $ids = array_filter(array_map('intval', $ids)); + if (!$ids) { + $this->error('请选择要操作的评价'); + } + + $now = time(); + $comments = $status === 0 + ? Db::name('fc_comment')->where('id', 'in', $ids)->field('id,user_id,post_id,content,status')->select() + : []; + + Db::name('fc_comment')->where('id', 'in', $ids)->update([ + 'status' => $status, + 'updatetime' => $now, + ]); + + // 隐藏评价时,向对应评价发布者发送系统站内信通知 + if ($status === 0 && $comments) { + foreach ($comments as $cmt) { + if ((int)$cmt['status'] === 0 || (int)$cmt['user_id'] <= 0) { + continue; + } + $snippet = mb_substr((string)$cmt['content'], 0, 20) . (mb_strlen((string)$cmt['content']) > 20 ? '...' : ''); + $reasonText = $reason !== '' ? ",原因:{$reason}" : ''; + Db::name('fc_message')->insert([ + 'user_id' => (int)$cmt['user_id'], + 'type' => 'system', + 'title' => '评价隐藏通知', + 'content' => "您发布的评价「{$snippet}」已被管理员隐藏{$reasonText}。您仍可在原信息详情页查看或删除该评价。", + 'extra' => json_encode(['path' => '/pages/detail/detail', 'id' => (int)$cmt['post_id']], JSON_UNESCAPED_UNICODE), + 'isread' => 0, + 'createtime' => $now, + 'updatetime' => $now, + ]); + } + } + + $this->success($status === 1 ? '已恢复显示' : '已隐藏评价'); + } } diff --git a/application/admin/controller/fc/Dashboard.php b/application/admin/controller/fc/Dashboard.php index 51403cb..9bcdfd3 100644 --- a/application/admin/controller/fc/Dashboard.php +++ b/application/admin/controller/fc/Dashboard.php @@ -9,123 +9,463 @@ use think\Db; * 同城分类信息 - 数据总览与运营看板 * * 后台核心运营仪表盘: - * 1. 今日核心指标与昨日对比(发布量 / 订单额 / 新增用户 / 浏览曝光量) + * 1. 核心 KPI 双维展示(累计总计 + 今日新增 + 较昨日对比 + 选中日期区间统计) * 2. 待办督办中心(帖子待审 / 商家待审 / 提现待审 / 举报待处理) - * 3. 多时段多维趋势分析(近 7 天 / 14 天 / 30 天,支持发布量、订单额、新增用户、浏览量平滑折线图) - * 4. 营收来源构成分析(会员购买 / 发帖付费 / 置顶推广 / 付费查看等占比环形图) - * 5. 热门分类发帖分布与同城区域活跃排行 - * 6. 用户、会员、商户与分销生态资产全景 + * 3. 全局日期统计切换(全部累计 / 今日 / 昨日 / 近7天 / 近14天 / 近30天 / 本月 / 自定义区间) + * 4. 营收来源构成、热门分类发帖分布、同城区域排行(支持按所选日期动态联动) + * 5. 多维趋势分析图与每日数据明细表 + * 6. 会员、商户与分销生态资产(累计总计 + 今日新增) * * @icon fa fa-dashboard */ class Dashboard extends Backend { /** - * 数据总览首页入口与数据下发 + * 数据总览首页入口与 AJAX 筛选接口 * * @return string|\think\response\Json */ public function index() { - $todayStart = strtotime('today'); - $todayEnd = $todayStart + 86400 - 1; + $todayStart = strtotime('today'); + $todayEnd = $todayStart + 86400 - 1; $yesterdayStart = $todayStart - 86400; $yesterdayEnd = $todayStart - 1; - /* ========================================================= - * 1. 核心 KPI(今日、较昨日对比、累计总量) - * ========================================================= */ - // 发布量 - $todayPost = (int)Db::name('fc_post')->where('createtime', 'between', [$todayStart, $todayEnd])->count(); - $yesterdayPost = (int)Db::name('fc_post')->where('createtime', 'between', [$yesterdayStart, $yesterdayEnd])->count(); - $totalPost = (int)Db::name('fc_post')->count(); + // 解析日期筛选参数(默认全部累计,支持按日期切换) + $rangeKey = $this->request->get('range', 'all'); + $startDate = $this->request->get('start_date', ''); + $endDate = $this->request->get('end_date', ''); + $period = $this->resolveDateRange($rangeKey, $startDate, $endDate, $todayStart, $todayEnd); - // 订单额与笔数(仅统计已支付订单) - $todayOrderAmount = round((float)Db::name('fc_order')->where('status', 'paid') - ->whereTime('paytime|createtime', 'between', [$todayStart, $todayEnd])->sum('amount'), 2); - $yesterdayOrderAmount = round((float)Db::name('fc_order')->where('status', 'paid') - ->whereTime('paytime|createtime', 'between', [$yesterdayStart, $yesterdayEnd])->sum('amount'), 2); - $totalOrderAmount = round((float)Db::name('fc_order')->where('status', 'paid')->sum('amount'), 2); - $todayOrderCount = (int)Db::name('fc_order')->where('status', 'paid') - ->whereTime('paytime|createtime', 'between', [$todayStart, $todayEnd])->count(); - $totalOrderCount = (int)Db::name('fc_order')->where('status', 'paid')->count(); + // 如果是 AJAX 局部筛选请求,直接返回对应日期区间的完整数据包 + if ($this->request->isAjax() && $this->request->get('action') === 'filter') { + $filterData = $this->buildPeriodPayload( + $period, + $todayStart, + $todayEnd, + $yesterdayStart, + $yesterdayEnd + ); + return json(['code' => 1, 'msg' => 'ok', 'data' => $filterData]); + } - // 用户与会员 - $todayUser = (int)Db::name('user')->where('createtime', 'between', [$todayStart, $todayEnd])->count(); - $yesterdayUser = (int)Db::name('user')->where('createtime', 'between', [$yesterdayStart, $yesterdayEnd])->count(); + // 首屏全量数据组装 + $metrics = $this->getCoreMetrics($todayStart, $todayEnd, $yesterdayStart, $yesterdayEnd, $period); + $pending = $this->getPendingSummary(); + $ecosystem = $this->getEcosystemStats($todayStart, $todayEnd, $period, $metrics['rangeUser']); + + // 区间联动模块(营收构成、分类分布、区域排行、趋势图) + $rangeStart = $period['is_all'] ? null : $period['start']; + $rangeEnd = $period['is_all'] ? null : $period['end']; + + $revenueData = $this->getRevenueBreakdown($rangeStart, $rangeEnd); + $categoryData = $this->getCategoryRanks($rangeStart, $rangeEnd); + $areaRanks = $this->getAreaRanks($rangeStart, $rangeEnd); + $trendData = $this->getTrendSeries($period['trend_start'], $period['trend_end']); + + $this->view->assign('metrics', $metrics); + $this->view->assign('pending', $pending); + $this->view->assign('ecosystem', $ecosystem); + $this->view->assign('period', $period); + $this->view->assign('revenueTypes', $revenueData['items']); + $this->view->assign('revenueTotal', $revenueData['total']); + $this->view->assign('categoryRanks', $categoryData['items']); + $this->view->assign('categoryTotal', $categoryData['total']); + $this->view->assign('areaRanks', $areaRanks); + $this->view->assign('trendRows', $trendData['rows']); + $this->view->assign('updatedAt', date('Y-m-d H:i')); + + // 向前端 RequireJS 传入初始配置 + $this->assignconfig('initialTrend', $trendData); + $this->assignconfig('revenueTypes', $revenueData['items']); + $this->assignconfig('initialPeriod', $period); + + return $this->view->fetch(); + } + + /** + * 组装 AJAX 日期切换时的响应数据包 + * + * @param array $period 解析后的日期区间信息 + * @param int $todayStart 今日开始时间戳 + * @param int $todayEnd 今日结束时间戳 + * @param int $yesterdayStart 昨日开始时间戳 + * @param int $yesterdayEnd 昨日结束时间戳 + * @return array + */ + protected function buildPeriodPayload(array $period, $todayStart, $todayEnd, $yesterdayStart, $yesterdayEnd) + { + $metrics = $this->getCoreMetrics($todayStart, $todayEnd, $yesterdayStart, $yesterdayEnd, $period); + $ecosystem = $this->getEcosystemStats($todayStart, $todayEnd, $period, $metrics['rangeUser']); + $rangeStart = $period['is_all'] ? null : $period['start']; + $rangeEnd = $period['is_all'] ? null : $period['end']; + $revenueData = $this->getRevenueBreakdown($rangeStart, $rangeEnd); + $categoryData = $this->getCategoryRanks($rangeStart, $rangeEnd); + $areaRanks = $this->getAreaRanks($rangeStart, $rangeEnd); + $trendData = $this->getTrendSeries($period['trend_start'], $period['trend_end']); + + return [ + 'period' => $period, + 'metrics' => $metrics, + 'ecosystem' => $ecosystem, + 'revenueTypes' => $revenueData['items'], + 'revenueTotal' => $revenueData['total'], + 'categoryRanks' => $categoryData['items'], + 'categoryTotal' => $categoryData['total'], + 'areaRanks' => $areaRanks, + 'trend' => $trendData, + 'updatedAt' => date('Y-m-d H:i'), + ]; + } + + /** + * 解析日期统计切换参数,统一返回区间起止时间戳与展示标签 + * + * @param string $rangeKey 预设标识 (today/yesterday/7d/14d/30d/month/all/custom) + * @param string $startDate 自定义开始日期 Y-m-d + * @param string $endDate 自定义结束日期 Y-m-d + * @param int $todayStart 今日零点时间戳 + * @param int $todayEnd 今日末点时间戳 + * @return array + */ + protected function resolveDateRange($rangeKey, $startDate, $endDate, $todayStart, $todayEnd) + { + $isAll = false; + $label = '近 14 天'; + $start = $todayStart - 13 * 86400; + $end = $todayEnd; + + switch ($rangeKey) { + case 'today': + $start = $todayStart; + $end = $todayEnd; + $label = '今日'; + break; + case 'yesterday': + $start = $todayStart - 86400; + $end = $todayStart - 1; + $label = '昨日'; + break; + case '7d': + $start = $todayStart - 6 * 86400; + $end = $todayEnd; + $label = '近 7 天'; + break; + case '30d': + $start = $todayStart - 29 * 86400; + $end = $todayEnd; + $label = '近 30 天'; + break; + case 'month': + $start = strtotime(date('Y-m-01 00:00:00')); + $end = $todayEnd; + $label = '本月'; + break; + case 'all': + $isAll = true; + $start = 0; + $end = $todayEnd; + $label = '全部累计'; + break; + case 'custom': + $sTs = $startDate ? strtotime($startDate . ' 00:00:00') : false; + $eTs = $endDate ? strtotime($endDate . ' 23:59:59') : false; + if ($sTs !== false && $eTs !== false) { + if ($sTs > $eTs) { + $tmp = $sTs; + $sTs = strtotime(date('Y-m-d 00:00:00', $eTs)); + $eTs = strtotime(date('Y-m-d 23:59:59', $tmp)); + } + // 自定义跨度最大限制 90 天,防止图表过密 + if (($eTs - $sTs) > 90 * 86400) { + $sTs = strtotime(date('Y-m-d 00:00:00', $eTs - 89 * 86400)); + } + $start = $sTs; + $end = $eTs; + $label = date('Y-m-d', $start) . ' ~ ' . date('Y-m-d', $end); + } else { + $rangeKey = '14d'; + } + break; + case '14d': + default: + $rangeKey = '14d'; + $start = $todayStart - 13 * 86400; + $end = $todayEnd; + $label = '近 14 天'; + break; + } + + // 趋势图时间范围:全部累计时展示近 30 天趋势,其余展示所选区间 + $trendStart = $isAll ? ($todayStart - 29 * 86400) : $start; + $trendEnd = $end; + $days = (int)floor(($trendEnd - $trendStart) / 86400) + 1; + + return [ + 'key' => $rangeKey, + 'label' => $label, + 'is_all' => $isAll, + 'start' => $start, + 'end' => $end, + 'start_date' => $isAll ? '' : date('Y-m-d', $start), + 'end_date' => date('Y-m-d', $end), + 'trend_start' => $trendStart, + 'trend_end' => $trendEnd, + 'days' => max(1, $days), + ]; + } + + /** + * 获取订单实际支付归属时间 SQL 表达式(优先取非 0 的 paytime,否则取 createtime) + * + * @param string $alias 表别名(可选) + * @return string + */ + protected function getOrderTimeExpr($alias = '') + { + $prefix = $alias ? $alias . '.' : ''; + return "COALESCE(NULLIF({$prefix}paytime, 0), {$prefix}createtime)"; + } + + /** + * 获取用户注册归属时间 SQL 表达式(优先取非 0 的 createtime,否则取 jointime) + * + * @param string $alias 表别名(可选) + * @return string + */ + protected function getUserTimeExpr($alias = '') + { + $prefix = $alias ? $alias . '.' : ''; + return "COALESCE(NULLIF({$prefix}createtime, 0), {$prefix}jointime)"; + } + + /** + * 计算指定时间区间内的已支付订单净实收金额(已扣除退款) + * + * @param int|null $startTs 开始时间戳(null 表示不限) + * @param int|null $endTs 结束时间戳(null 表示不限) + * @return float + */ + protected function sumNetOrderAmount($startTs = null, $endTs = null) + { + $orderTimeExpr = $this->getOrderTimeExpr(); + $netAmountExpr = "GREATEST(amount - IFNULL(refund_amount, 0), 0)"; + $query = Db::name('fc_order')->where('status', 'paid'); + if ($startTs !== null && $endTs !== null) { + $s = (int)$startTs; + $e = (int)$endTs; + $query->whereRaw("{$orderTimeExpr} BETWEEN {$s} AND {$e}"); + } + return round((float)$query->value("SUM({$netAmountExpr})"), 2); + } + + /** + * 统计核心 KPI 指标(累计总计 + 今日新增 + 较昨日对比 + 所选日期区间) + * + * @param int $todayStart 今日开始时间戳 + * @param int $todayEnd 今日结束时间戳 + * @param int $yesterdayStart 昨日开始时间戳 + * @param int $yesterdayEnd 昨日结束时间戳 + * @param array $period 当前选中的日期区间 + * @return array + */ + protected function getCoreMetrics($todayStart, $todayEnd, $yesterdayStart, $yesterdayEnd, array $period) + { + $orderTimeExpr = $this->getOrderTimeExpr(); + $userTimeExpr = $this->getUserTimeExpr(); + + // 1. 发布量(过滤软删除) + $totalPost = (int)Db::name('fc_post')->whereNull('deletetime')->count(); + $todayPost = (int)Db::name('fc_post')->whereNull('deletetime')->where('createtime', 'between', [$todayStart, $todayEnd])->count(); + $yesterdayPost = (int)Db::name('fc_post')->whereNull('deletetime')->where('createtime', 'between', [$yesterdayStart, $yesterdayEnd])->count(); + $rangePost = $period['is_all'] + ? $totalPost + : (int)Db::name('fc_post')->whereNull('deletetime')->where('createtime', 'between', [$period['start'], $period['end']])->count(); + + // 2. 订单实收与笔数(仅统计已支付,扣除退款金额,按实际支付时间归属) + $totalOrderAmount = $this->sumNetOrderAmount(); + $todayOrderAmount = $this->sumNetOrderAmount($todayStart, $todayEnd); + $yesterdayOrderAmount = $this->sumNetOrderAmount($yesterdayStart, $yesterdayEnd); + $rangeOrderAmount = $period['is_all'] + ? $totalOrderAmount + : $this->sumNetOrderAmount($period['start'], $period['end']); + + $totalOrderCount = (int)Db::name('fc_order')->where('status', 'paid')->count(); + $todayOrderCount = (int)Db::name('fc_order')->where('status', 'paid') + ->whereRaw("{$orderTimeExpr} BETWEEN " . (int)$todayStart . " AND " . (int)$todayEnd)->count(); + $rangeOrderCount = $period['is_all'] + ? $totalOrderCount + : (int)Db::name('fc_order')->where('status', 'paid') + ->whereRaw("{$orderTimeExpr} BETWEEN " . (int)$period['start'] . " AND " . (int)$period['end'])->count(); + + // 3. 注册用户 $totalUser = (int)Db::name('user')->count(); - $memberCount = (int)Db::name('fc_user_ext')->where('is_member', 1)->count(); - $merchantCount = (int)Db::name('fc_merchant')->count(); - $recommendMerchantCount = (int)Db::name('fc_merchant')->where('recommend', 1)->count(); + $todayUser = (int)Db::name('user')->whereRaw("{$userTimeExpr} BETWEEN " . (int)$todayStart . " AND " . (int)$todayEnd)->count(); + $yesterdayUser = (int)Db::name('user')->whereRaw("{$userTimeExpr} BETWEEN " . (int)$yesterdayStart . " AND " . (int)$yesterdayEnd)->count(); + $rangeUser = $period['is_all'] + ? $totalUser + : (int)Db::name('user')->whereRaw("{$userTimeExpr} BETWEEN " . (int)$period['start'] . " AND " . (int)$period['end'])->count(); - // 浏览量 PV + // 4. 浏览曝光量(全部累计取帖子总 views,按时间筛选时取 fc_view_log 浏览记录) + $totalViews = (int)Db::name('fc_post')->whereNull('deletetime')->sum('views'); $todayViews = (int)Db::name('fc_view_log')->where('createtime', 'between', [$todayStart, $todayEnd])->count(); $yesterdayViews = (int)Db::name('fc_view_log')->where('createtime', 'between', [$yesterdayStart, $yesterdayEnd])->count(); - $totalViews = (int)Db::name('fc_post')->sum('views'); + $rangeViews = $period['is_all'] + ? $totalViews + : (int)Db::name('fc_view_log')->where('createtime', 'between', [$period['start'], $period['end']])->count(); - $metrics = [ + return [ 'todayPost' => $todayPost, 'yesterdayPost' => $yesterdayPost, 'postDelta' => $todayPost - $yesterdayPost, 'totalPost' => $totalPost, + 'rangePost' => $rangePost, 'todayOrderAmount' => $todayOrderAmount, 'yesterdayOrderAmount' => $yesterdayOrderAmount, 'orderDelta' => round($todayOrderAmount - $yesterdayOrderAmount, 2), 'totalOrderAmount' => $totalOrderAmount, + 'rangeOrderAmount' => $rangeOrderAmount, 'todayOrderCount' => $todayOrderCount, 'totalOrderCount' => $totalOrderCount, + 'rangeOrderCount' => $rangeOrderCount, 'todayUser' => $todayUser, 'yesterdayUser' => $yesterdayUser, 'userDelta' => $todayUser - $yesterdayUser, 'totalUser' => $totalUser, - 'memberCount' => $memberCount, - 'merchantCount' => $merchantCount, - 'recommendMerchant' => $recommendMerchantCount, + 'rangeUser' => $rangeUser, 'todayViews' => $todayViews, 'yesterdayViews' => $yesterdayViews, 'viewsDelta' => $todayViews - $yesterdayViews, 'totalViews' => $totalViews, + 'rangeViews' => $rangeViews, ]; + } - /* ========================================================= - * 2. 待办督办中心(待审核事项与预警) - * ========================================================= */ - $pendingPost = (int)Db::name('fc_post')->where('audit_status', 0)->count(); - $pendingMerchant = (int)Db::name('fc_merchant')->where('audit_status', 0)->count(); - $pendingWithdraw = (int)Db::name('fc_withdraw')->where('status', 'auditing')->count(); + /** + * 获取待办督办统计数据 + * + * @return array + */ + protected function getPendingSummary() + { + $pendingPost = (int)Db::name('fc_post')->whereNull('deletetime')->where('audit_status', 0)->count(); + $pendingMerchant = (int)Db::name('fc_merchant')->where('audit_status', 0)->count(); + $pendingWithdraw = (int)Db::name('fc_withdraw')->where('status', 'auditing')->count(); $pendingWithdrawAmount = round((float)Db::name('fc_withdraw')->where('status', 'auditing')->sum('amount'), 2); - $pendingReport = (int)Db::name('fc_report')->where('status', 'pending')->count(); - $pendingTotal = $pendingPost + $pendingMerchant + $pendingWithdraw + $pendingReport; + $pendingReport = (int)Db::name('fc_report')->where('status', 'pending')->count(); - $pending = [ - 'total' => $pendingTotal, - 'post' => $pendingPost, - 'merchant' => $pendingMerchant, - 'withdraw' => $pendingWithdraw, - 'withdrawAmount' => $pendingWithdrawAmount, - 'report' => $pendingReport, + return [ + 'total' => $pendingPost + $pendingMerchant + $pendingWithdraw + $pendingReport, + 'post' => $pendingPost, + 'merchant' => $pendingMerchant, + 'withdraw' => $pendingWithdraw, + 'withdrawAmount' => $pendingWithdrawAmount, + 'report' => $pendingReport, ]; + } - /* ========================================================= - * 3. 平台生态与分销资产 - * ========================================================= */ - $commissionPending = round((float)Db::name('fc_commission')->where('status', 0)->sum('amount'), 2); - $commissionSettled = round((float)Db::name('fc_commission')->where('status', 1)->sum('amount'), 2); - $distributorCount = (int)Db::name('fc_dist_relation')->distinct(true)->field('parent_id')->count(); + /** + * 获取平台生态资产统计(主指标随筛选时间区间变化,同时保留今日新增) + * + * @param int $todayStart 今日开始时间戳 + * @param int $todayEnd 今日结束时间戳 + * @param array $period 当前选中的日期区间 + * @param int $rangeUser 当前选定区间的新增/总用户数 + * @return array + */ + protected function getEcosystemStats($todayStart, $todayEnd, array $period, $rangeUser) + { + $now = time(); + $orderTimeExpr = $this->getOrderTimeExpr(); + $isAll = !empty($period['is_all']); + $s = (int)$period['start']; + $e = (int)$period['end']; - $ecosystem = [ - 'commissionPending' => $commissionPending, - 'commissionSettled' => $commissionSettled, - 'distributorCount' => $distributorCount, - 'memberRate' => $totalUser > 0 ? round(($memberCount / $totalUser) * 100, 1) : 0, + // VIP 会员:全部累计时取当前有效 VIP 会员总数;按时间筛选时取区间内支付开通/续费的去重会员数 + if ($isAll) { + $memberCount = (int)Db::name('fc_user_ext') + ->where('is_member', 1) + ->where(function ($query) use ($now) { + $query->where('member_expiretime', '>', $now) + ->whereOr('member_expiretime', 0) + ->whereOr('member_expiretime', 'null'); + }) + ->count(); + } else { + $memberCount = (int)Db::name('fc_order') + ->where('status', 'paid') + ->where('type', 'member') + ->whereRaw("{$orderTimeExpr} BETWEEN {$s} AND {$e}") + ->count('DISTINCT user_id'); + } + + // 今日新开通/续费会员人数(按今日已支付 member 订单去重统计) + $todayMemberCount = (int)Db::name('fc_order') + ->where('status', 'paid') + ->where('type', 'member') + ->whereRaw("{$orderTimeExpr} BETWEEN " . (int)$todayStart . " AND " . (int)$todayEnd) + ->count('DISTINCT user_id'); + + // 已审核通过的入驻商户(按筛选时间) + $merchantQuery = Db::name('fc_merchant')->where('audit_status', 1); + $recommendQuery = Db::name('fc_merchant')->where('audit_status', 1)->where('recommend', 1); + if (!$isAll) { + $merchantQuery->where('createtime', 'between', [$s, $e]); + $recommendQuery->where('createtime', 'between', [$s, $e]); + } + $merchantCount = (int)$merchantQuery->count(); + $recommendMerchantCount = (int)$recommendQuery->count(); + $todayMerchantCount = (int)Db::name('fc_merchant')->where('audit_status', 1)->where('createtime', 'between', [$todayStart, $todayEnd])->count(); + + // 推广分销员人数(按筛选时间,按 parent_id 去重) + $distQuery = Db::name('fc_dist_relation')->where('parent_id', '>', 0); + if (!$isAll) { + $distQuery->where('createtime', 'between', [$s, $e]); + } + $distributorCount = (int)$distQuery->count('DISTINCT parent_id'); + $todayDistributorCount = (int)Db::name('fc_dist_relation')->where('parent_id', '>', 0)->where('createtime', 'between', [$todayStart, $todayEnd])->count('DISTINCT parent_id'); + + // 佣金统计(按筛选时间 + 今日新增) + $settledQuery = Db::name('fc_commission')->where('status', 1); + $pendingQuery = Db::name('fc_commission')->where('status', 0); + if (!$isAll) { + $settledQuery->where('createtime', 'between', [$s, $e]); + $pendingQuery->where('createtime', 'between', [$s, $e]); + } + $commissionSettled = round((float)$settledQuery->sum('amount'), 2); + $commissionPending = round((float)$pendingQuery->sum('amount'), 2); + $todayCommissionPending = round((float)Db::name('fc_commission')->where('status', 0)->where('createtime', 'between', [$todayStart, $todayEnd])->sum('amount'), 2); + $todayCommissionSettled = round((float)Db::name('fc_commission')->where('status', 1)->where('createtime', 'between', [$todayStart, $todayEnd])->sum('amount'), 2); + + return [ + 'memberCount' => $memberCount, + 'todayMemberCount' => $todayMemberCount, + 'memberRate' => $rangeUser > 0 ? min(100, round(($memberCount / $rangeUser) * 100, 1)) : 0, + 'merchantCount' => $merchantCount, + 'todayMerchantCount' => $todayMerchantCount, + 'recommendMerchant' => $recommendMerchantCount, + 'distributorCount' => $distributorCount, + 'todayDistributorCount' => $todayDistributorCount, + 'commissionPending' => $commissionPending, + 'commissionSettled' => $commissionSettled, + 'todayCommissionPending' => $todayCommissionPending, + 'todayCommissionSettled' => $todayCommissionSettled, ]; + } - /* ========================================================= - * 4. 营收构成分析(按订单类型统计已支付实收) - * ========================================================= */ + /** + * 获取营收来源构成(支持按日期范围筛选,null 表示全部累计) + * + * @param int|null $startTs 开始时间戳 + * @param int|null $endTs 结束时间戳 + * @return array + */ + protected function getRevenueBreakdown($startTs = null, $endTs = null) + { $orderTypeLabels = [ 'member' => 'VIP会员购买', 'post' => '发布信息付费', @@ -135,21 +475,26 @@ class Dashboard extends Backend 'refresh' => '信息刷新', ]; - $rawRevenue = Db::name('fc_order') - ->where('status', 'paid') - ->fieldRaw("type, count(*) as count, sum(amount) as amount") + $query = Db::name('fc_order')->where('status', 'paid'); + if ($startTs !== null && $endTs !== null) { + $orderTimeExpr = $this->getOrderTimeExpr(); + $query->whereRaw("{$orderTimeExpr} BETWEEN " . (int)$startTs . " AND " . (int)$endTs); + } + + $rawRevenue = $query + ->fieldRaw("type, count(*) as count, sum(GREATEST(amount - IFNULL(refund_amount, 0), 0)) as amount") ->group('type') ->order('amount', 'desc') ->select(); - $revenueTotalSum = 0; - $revenueTypes = []; + $totalSum = 0; + $items = []; foreach ($rawRevenue as $r) { - $amt = round((float)$r['amount'], 2); - $cnt = (int)$r['count']; - $label = isset($orderTypeLabels[$r['type']]) ? $orderTypeLabels[$r['type']] : ($r['type'] ? $r['type'] : '其他服务'); - $revenueTotalSum += $amt; - $revenueTypes[] = [ + $amt = round((float)$r['amount'], 2); + $cnt = (int)$r['count']; + $label = isset($orderTypeLabels[$r['type']]) ? $orderTypeLabels[$r['type']] : ($r['type'] ?: '其他服务'); + $totalSum += $amt; + $items[] = [ 'type' => $r['type'], 'label' => $label, 'count' => $cnt, @@ -157,75 +502,122 @@ class Dashboard extends Backend ]; } - foreach ($revenueTypes as &$item) { - $item['percent'] = $revenueTotalSum > 0 ? round(($item['amount'] / $revenueTotalSum) * 100, 1) : 0; + $totalSum = round($totalSum, 2); + foreach ($items as &$item) { + $item['percent'] = $totalSum > 0 ? round(($item['amount'] / $totalSum) * 100, 1) : 0; } unset($item); - /* ========================================================= - * 5. 热门分类发帖分布与同城区域排行 - * ========================================================= */ - // 一级分类发帖分布 + return ['total' => $totalSum, 'items' => $items]; + } + + /** + * 获取一级分类发帖分布(过滤软删除帖子,支持日期范围筛选) + * + * @param int|null $startTs 开始时间戳 + * @param int|null $endTs 结束时间戳 + * @return array + */ + protected function getCategoryRanks($startTs = null, $endTs = null) + { + $prefix = config('database.prefix'); + $joinCond = "(p.category_id = c.id OR p.category_id IN (SELECT sub.id FROM {$prefix}fc_category sub WHERE sub.pid = c.id)) AND p.deletetime IS NULL"; + if ($startTs !== null && $endTs !== null) { + $joinCond .= " AND p.createtime BETWEEN " . (int)$startTs . " AND " . (int)$endTs; + } + $rawCategories = Db::name('fc_category') ->alias('c') - ->join('__FC_POST__ p', '(p.category_id = c.id OR p.category_id IN (SELECT sub.id FROM ' . config('database.prefix') . 'fc_category sub WHERE sub.pid = c.id))', 'LEFT') + ->join('__FC_POST__ p', $joinCond, 'LEFT') ->where('c.pid', 0) ->field('c.id, c.name, count(p.id) as post_count') ->group('c.id') ->order('post_count', 'desc') ->select(); - $categoryTotal = 0; - $categoryRanks = []; + $total = 0; + $items = []; foreach ($rawCategories as $c) { - $cnt = (int)$c['post_count']; - $categoryTotal += $cnt; - $categoryRanks[] = [ + $cnt = (int)$c['post_count']; + $total += $cnt; + $items[] = [ 'id' => $c['id'], 'name' => $c['name'], 'count' => $cnt, ]; } - foreach ($categoryRanks as &$cItem) { - $cItem['percent'] = $categoryTotal > 0 ? round(($cItem['count'] / $categoryTotal) * 100, 1) : 0; + + foreach ($items as &$cItem) { + $cItem['percent'] = $total > 0 ? round(($cItem['count'] / $total) * 100, 1) : 0; } unset($cItem); - // 同城热门地区 Top 5 - $rawAreas = Db::name('fc_post') + return ['total' => $total, 'items' => $items]; + } + + /** + * 获取同城热门活跃区域 Top 5(过滤软删除帖子,支持日期范围筛选) + * + * @param int|null $startTs 开始时间戳 + * @param int|null $endTs 结束时间戳 + * @return array + */ + protected function getAreaRanks($startTs = null, $endTs = null) + { + $query = Db::name('fc_post') + ->whereNull('deletetime') + ->where("area != '' OR city != ''"); + + if ($startTs !== null && $endTs !== null) { + $query->where('createtime', 'between', [$startTs, $endTs]); + } + + $rawAreas = $query ->fieldRaw("IF(area != '', area, city) as region_name, count(*) as count") - ->where("area != '' OR city != ''") ->group('region_name') ->order('count', 'desc') ->limit(5) ->select(); - $areaRanks = []; - $areaMaxCount = 1; + + $items = []; + $maxCount = 1; foreach ($rawAreas as $ar) { $cnt = (int)$ar['count']; - if ($cnt > $areaMaxCount) { - $areaMaxCount = $cnt; + if ($cnt > $maxCount) { + $maxCount = $cnt; } - $areaRanks[] = [ - 'region_name' => $ar['region_name'] ? $ar['region_name'] : '未知区域', + $items[] = [ + 'region_name' => $ar['region_name'] ?: '未知区域', 'count' => $cnt, ]; } - foreach ($areaRanks as &$arItem) { - $arItem['percent'] = round(($arItem['count'] / $areaMaxCount) * 100, 1); + + foreach ($items as &$arItem) { + $arItem['percent'] = round(($arItem['count'] / $maxCount) * 100, 1); } unset($arItem); - /* ========================================================= - * 6. 多时段趋势数据计算(近 7 天 / 14 天 / 30 天) - * ========================================================= */ - $maxTrendDays = 30; - $trendStart = $todayStart - ($maxTrendDays - 1) * 86400; + return $items; + } + + /** + * 按起止时间戳生成多维度分日趋势序列与明细表行 + * + * @param int $startTs 开始时间戳 + * @param int $endTs 结束时间戳 + * @return array + */ + protected function getTrendSeries($startTs, $endTs) + { + $orderTimeExpr = $this->getOrderTimeExpr(); + $userTimeExpr = $this->getUserTimeExpr(); + $netAmountExpr = "GREATEST(amount - IFNULL(refund_amount, 0), 0)"; // 发帖趋势 - $postsMap = []; + $postsMap = []; $postsQuery = Db::name('fc_post') - ->where('createtime', 'between', [$trendStart, $todayEnd]) + ->whereNull('deletetime') + ->where('createtime', 'between', [$startTs, $endTs]) ->fieldRaw("FROM_UNIXTIME(`createtime`,'%Y-%m-%d') AS day, COUNT(*) AS num") ->group('day') ->select(); @@ -233,12 +625,12 @@ class Dashboard extends Backend $postsMap[$row['day']] = (int)$row['num']; } - // 订单额趋势 - $ordersMap = []; + // 订单实收趋势 + $ordersMap = []; $ordersQuery = Db::name('fc_order') ->where('status', 'paid') - ->whereTime('paytime|createtime', 'between', [$trendStart, $todayEnd]) - ->fieldRaw("FROM_UNIXTIME(IFNULL(`paytime`,`createtime`),'%Y-%m-%d') AS day, SUM(`amount`) AS num") + ->whereRaw("{$orderTimeExpr} BETWEEN " . (int)$startTs . " AND " . (int)$endTs) + ->fieldRaw("FROM_UNIXTIME({$orderTimeExpr},'%Y-%m-%d') AS day, SUM({$netAmountExpr}) AS num") ->group('day') ->select(); foreach ($ordersQuery as $row) { @@ -246,10 +638,10 @@ class Dashboard extends Backend } // 新增用户趋势 - $usersMap = []; + $usersMap = []; $usersQuery = Db::name('user') - ->where('createtime', 'between', [$trendStart, $todayEnd]) - ->fieldRaw("FROM_UNIXTIME(`createtime`,'%Y-%m-%d') AS day, COUNT(*) AS num") + ->whereRaw("{$userTimeExpr} BETWEEN " . (int)$startTs . " AND " . (int)$endTs) + ->fieldRaw("FROM_UNIXTIME({$userTimeExpr},'%Y-%m-%d') AS day, COUNT(*) AS num") ->group('day') ->select(); foreach ($usersQuery as $row) { @@ -257,9 +649,9 @@ class Dashboard extends Backend } // 浏览量趋势 - $viewsMap = []; + $viewsMap = []; $viewsQuery = Db::name('fc_view_log') - ->where('createtime', 'between', [$trendStart, $todayEnd]) + ->where('createtime', 'between', [$startTs, $endTs]) ->fieldRaw("FROM_UNIXTIME(`createtime`,'%Y-%m-%d') AS day, COUNT(*) AS num") ->group('day') ->select(); @@ -267,74 +659,44 @@ class Dashboard extends Backend $viewsMap[$row['day']] = (int)$row['num']; } - // 计算 7/14/30 天数据包 - $ranges = [7, 14, 30]; - $allTrends = []; - foreach ($ranges as $span) { - $startTs = $todayStart - ($span - 1) * 86400; - $dates = []; - $posts = []; - $orders = []; - $users = []; - $views = []; - $rows = []; - for ($i = 0; $i < $span; $i++) { - $day = date('Y-m-d', $startTs + $i * 86400); - $p = isset($postsMap[$day]) ? $postsMap[$day] : 0; - $o = isset($ordersMap[$day]) ? $ordersMap[$day] : 0; - $u = isset($usersMap[$day]) ? $usersMap[$day] : 0; - $v = isset($viewsMap[$day]) ? $viewsMap[$day] : 0; + $dates = []; + $posts = []; + $orders = []; + $users = []; + $views = []; + $rows = []; - $dates[] = $day; - $posts[] = $p; - $orders[] = $o; - $users[] = $u; - $views[] = $v; - $rows[] = [ - 'date' => $day, - 'posts' => $p, - 'orders' => $o, - 'users' => $u, - 'views' => $v, - ]; - } - $allTrends[$span] = [ - 'dates' => $dates, - 'posts' => $posts, - 'orders' => $orders, - 'users' => $users, - 'views' => $views, - 'rows' => array_reverse($rows), + $cursor = strtotime(date('Y-m-d 00:00:00', $startTs)); + $limit = strtotime(date('Y-m-d 00:00:00', $endTs)); + while ($cursor <= $limit) { + $day = date('Y-m-d', $cursor); + $p = isset($postsMap[$day]) ? $postsMap[$day] : 0; + $o = isset($ordersMap[$day]) ? $ordersMap[$day] : 0; + $u = isset($usersMap[$day]) ? $usersMap[$day] : 0; + $v = isset($viewsMap[$day]) ? $viewsMap[$day] : 0; + + $dates[] = $day; + $posts[] = $p; + $orders[] = $o; + $users[] = $u; + $views[] = $v; + $rows[] = [ + 'date' => $day, + 'posts' => $p, + 'orders' => $o, + 'users' => $u, + 'views' => $v, ]; + $cursor += 86400; } - // 如果是 AJAX 请求局部刷新趋势,可直接返回对应时段数据 - if ($this->request->isAjax() && $this->request->get('action') === 'trend') { - $days = (int)$this->request->get('days', 14); - $trendData = isset($allTrends[$days]) ? $allTrends[$days] : $allTrends[14]; - return json(['code' => 1, 'msg' => 'ok', 'data' => $trendData]); - } - - // 默认 14 天用于模板首屏初始化 - $defaultTrend = $allTrends[14]; - - /* ========================================================= - * 7. 视图变量绑定与前端配置传递 - * ========================================================= */ - $this->view->assign('metrics', $metrics); - $this->view->assign('pending', $pending); - $this->view->assign('ecosystem', $ecosystem); - $this->view->assign('revenueTypes', $revenueTypes); - $this->view->assign('categoryRanks', $categoryRanks); - $this->view->assign('areaRanks', $areaRanks); - $this->view->assign('trendRows', $defaultTrend['rows']); - $this->view->assign('updatedAt', date('Y-m-d H:i')); - - // 向前端 RequireJS 传入完整时段数据包及分类分布,供平滑渲染交互 - $this->assignconfig('allTrends', $allTrends); - $this->assignconfig('revenueTypes', $revenueTypes); - $this->assignconfig('categoryRanks', $categoryRanks); - - return $this->view->fetch(); + return [ + 'dates' => $dates, + 'posts' => $posts, + 'orders' => $orders, + 'users' => $users, + 'views' => $views, + 'rows' => array_reverse($rows), + ]; } } diff --git a/application/admin/controller/fc/Post.php b/application/admin/controller/fc/Post.php index 71b56f8..98528fd 100644 --- a/application/admin/controller/fc/Post.php +++ b/application/admin/controller/fc/Post.php @@ -20,6 +20,12 @@ class Post extends Backend */ protected $model = null; + /** + * 快速搜索字段 + * @var string + */ + protected $searchFields = 'id,title,content,contact,phone'; + /** * 无需鉴权的方法(只读辅助接口;审核/置顶/下架/上架必须走权限节点) * @var array @@ -32,6 +38,46 @@ class Post extends Backend $this->model = new \app\admin\model\FcPost; } + /** + * 新增信息前校验价格等边界参数 + * + * @return string + */ + public function add() + { + if ($this->request->isPost()) { + $this->validatePostParams($this->request->post('row/a', [])); + } + return parent::add(); + } + + /** + * 编辑信息前校验价格等边界参数 + * + * @param mixed $ids + * @return string + */ + public function edit($ids = null) + { + if ($this->request->isPost()) { + $this->validatePostParams($this->request->post('row/a', [])); + } + return parent::edit($ids); + } + + /** + * 校验信息表单边界参数(如价格不可为负数) + * + * @param array $params + * @return void + */ + protected function validatePostParams(array $params) + { + if (isset($params['price']) && $params['price'] !== '' && (float)$params['price'] < 0) { + $this->error('价格不能为负数'); + } + } + /** * 查看信息列表 * diff --git a/application/admin/controller/fc/Postaudit.php b/application/admin/controller/fc/Postaudit.php index 3680e6f..989cde7 100644 --- a/application/admin/controller/fc/Postaudit.php +++ b/application/admin/controller/fc/Postaudit.php @@ -19,6 +19,12 @@ class Postaudit extends Backend */ protected $model = null; + /** + * 快速搜索字段 + * @var string + */ + protected $searchFields = 'id,title,content,contact,phone'; + /** * 无需鉴权的方法(只读辅助接口) * @var array diff --git a/application/admin/controller/fc/Report.php b/application/admin/controller/fc/Report.php index 62cbccc..6421161 100644 --- a/application/admin/controller/fc/Report.php +++ b/application/admin/controller/fc/Report.php @@ -405,6 +405,22 @@ class Report extends Backend 'status' => 0, 'updatetime' => $now, ]); + + // 通知被隐藏评价的发布者 + if ($cmt && (int)$cmt['user_id'] > 0 && (int)$cmt['status'] !== 0) { + $cmtSnippet = mb_substr((string)$cmt['content'], 0, 20) . (mb_strlen((string)$cmt['content']) > 20 ? '...' : ''); + $reasonNote = $remark !== '' ? $remark : $report['reason']; + Db::name('fc_message')->insert([ + 'user_id' => (int)$cmt['user_id'], + 'type' => 'system', + 'title' => '评价违规隐藏通知', + 'content' => "您发布的评价「{$cmtSnippet}」因被举报核实违规({$reasonNote})已被平台隐藏。您仍可在原信息详情页查看或删除该评价。", + 'extra' => json_encode(['path' => '/pages/detail/detail', 'id' => (int)$cmt['post_id']], JSON_UNESCAPED_UNICODE), + 'isread' => 0, + 'createtime' => $now, + 'updatetime' => $now, + ]); + } } } else { if ($report['target_type'] === 'post') { diff --git a/application/admin/lang/zh-cn/fc/dashboard.php b/application/admin/lang/zh-cn/fc/dashboard.php index 79fb3fc..b98b508 100644 --- a/application/admin/lang/zh-cn/fc/dashboard.php +++ b/application/admin/lang/zh-cn/fc/dashboard.php @@ -90,4 +90,39 @@ return [ '信息曝光量 (次)' => '信息曝光量 (次)', '暂无明细数据' => '暂无明细数据', '元' => '元', + '订单额仅统计已支付实收净额(已扣退款)' => '订单额仅统计已支付实收净额(已扣退款)', + '日期统计切换' => '日期统计切换', + '统计周期' => '统计周期', + '选择统计周期' => '选择统计周期', + '全部累计' => '全部累计', + '今日' => '今日', + '昨日' => '昨日', + '本月' => '本月', + '开始日期' => '开始日期', + '至' => '至', + '结束日期' => '结束日期', + '筛选' => '筛选', + '当前:' => '当前:', + '核心运营指标' => '核心运营指标', + '信息发布量' => '信息发布量', + '累计总计' => '累计总计', + '今日新增' => '今日新增', + '订单实收' => '订单实收', + '注册用户' => '注册用户', + '信息曝光量' => '信息曝光量', + '今日浏览' => '今日浏览', + '该时段暂无已支付订单数据' => '该时段暂无已支付订单数据', + '该时段暂无分类发帖数据' => '该时段暂无分类发帖数据', + '该时段暂无地区发布数据' => '该时段暂无地区发布数据', + '会员沉淀、商户入驻及分销裂变体系(累计总计 / 今日新增)' + => '会员沉淀、商户入驻及分销裂变体系(累计总计 / 今日新增)', + '已审入驻商户' => '已审入驻商户', + '每日数据明细' => '每日数据明细', + '暂无数据' => '暂无数据', + '数据加载失败' => '数据加载失败', + '网络异常,请稍后重试' => '网络异常,请稍后重试', + '请选择完整的开始和结束日期' => '请选择完整的开始和结束日期', + '全站累计' => '全站累计', + '会员沉淀、商户入驻及分销裂变体系(所选周期统计 / 今日新增)' + => '会员沉淀、商户入驻及分销裂变体系(所选周期统计 / 今日新增)', ]; diff --git a/application/admin/view/fc/comment/index.html b/application/admin/view/fc/comment/index.html index 8cb38c4..3f4824f 100644 --- a/application/admin/view/fc/comment/index.html +++ b/application/admin/view/fc/comment/index.html @@ -7,6 +7,8 @@

{:__('业务总览与运营看板')}

- {:__('同城便民生活服务平台')} · {:__('数据更新于')} {$updatedAt} · {:__('订单额仅统计已支付实收口径')} + {:__('同城便民生活服务平台')} · {:__('数据更新于')} {$updatedAt} · {:__('订单额仅统计已支付实收净额(已扣退款)')}

{/if} - -
- + +
+
+ {:__('统计周期')} +
+ + + + + + + +
+
+
+
+ + {:__('至')} + + +
+ {:__('当前:')}{$period.label} +
+
+ + +
+
- {:__('今日发布量')} + {:__('信息发布量')}
-

{$metrics.todayPost} {:__('篇')}

+
+
+ {$period.label} +

{$metrics.rangePost} {:__('篇')}

+
+
+ {:__('今日新增')} +

+{$metrics.todayPost} {:__('篇')}

+
+
+
+ {:__('全站累计')}:{$metrics.totalPost} {:__('篇')} +
{if $metrics.postDelta > 0} {$metrics.postDelta} - {:__('较昨日')} {elseif $metrics.postDelta < 0} {:abs($metrics['postDelta'])} - {:__('较昨日')} {else} {:__('持平')} - {:__('较昨日')} {/if} -
-
- {:__('累计')} {$metrics.totalPost} {:__('篇')} + {:__('较昨日')}
- +
- {:__('今日订单实收')} + {:__('订单实收')}
-

¥{$metrics.todayOrderAmount|number_format=2}

+
+
+ {$period.label} ({$metrics.rangeOrderCount}{:__('笔')}) +

¥{$metrics.rangeOrderAmount|number_format=2}

+
+
+ {:__('今日')} ({$metrics.todayOrderCount}{:__('笔')}) +

¥{$metrics.todayOrderAmount|number_format=2}

+
+
+
+ {:__('全站累计')}:¥{$metrics.totalOrderAmount|number_format=2} ({$metrics.totalOrderCount}{:__('笔')}) +
{if $metrics.orderDelta > 0} ¥{$metrics.orderDelta|number_format=2} - {:__('较昨日')} {elseif $metrics.orderDelta < 0} ¥{:number_format(abs($metrics['orderDelta']), 2)} - {:__('较昨日')} {else} {:__('持平')} - {:__('较昨日')} {/if} -
-
- {:__('累计')} ¥{$metrics.totalOrderAmount|number_format=2} + {:__('较昨日')}
- +
- {:__('今日新增用户')} + {:__('注册用户')}
-

{$metrics.todayUser} {:__('人')}

+
+
+ {$period.label} +

{$metrics.rangeUser} {:__('人')}

+
+
+ {:__('今日新增')} +

+{$metrics.todayUser} {:__('人')}

+
+
+
+ {:__('全站累计')}:{$metrics.totalUser} {:__('人')} +
{if $metrics.userDelta > 0} {$metrics.userDelta} - {:__('较昨日')} {elseif $metrics.userDelta < 0} {:abs($metrics['userDelta'])} - {:__('较昨日')} {else} {:__('持平')} - {:__('较昨日')} {/if} -
-
- {:__('累计注册')} {$metrics.totalUser} {:__('人')} + {:__('较昨日')}
- +
- {:__('今日信息曝光量')} + {:__('信息曝光量')}
-

{$metrics.todayViews} {:__('次')}

+
+
+ {$period.label} +

{$metrics.rangeViews} {:__('次')}

+
+
+ {:__('今日浏览')} +

+{$metrics.todayViews} {:__('次')}

+
+
+
+ {:__('全站累计')}:{$metrics.totalViews} {:__('次')} +
{if $metrics.viewsDelta > 0} {$metrics.viewsDelta} - {:__('较昨日')} {elseif $metrics.viewsDelta < 0} {:abs($metrics['viewsDelta'])} - {:__('较昨日')} {else} {:__('持平')} - {:__('较昨日')} {/if} -
-
- {:__('累计曝光')} {$metrics.totalViews} {:__('次')} + {:__('较昨日')}
@@ -192,16 +245,10 @@
-

{:__('业务多维趋势透视')}

+

{:__('业务多维趋势透视')} {$period.label}

{:__('发布量按发布时间归属,订单额按实际支付时间归属')}

- -
- - - -
@@ -238,13 +285,13 @@

{:__('营收来源构成')}

- {:__('实收合计')} ¥{$metrics.totalOrderAmount|number_format=2} + {$period.label} · ¥{$revenueTotal|number_format=2}
-
+
{if count($revenueTypes) > 0} {foreach $revenueTypes as $rev}
@@ -259,7 +306,7 @@
{/foreach} {else} -
{:__('暂无已支付订单数据')}
+
{:__('该时段暂无已支付订单数据')}
{/if}
@@ -269,9 +316,9 @@

{:__('热门分类发帖分布')}

- {:__('累计发帖')} {$metrics.totalPost} {:__('篇')} + {$period.label} · {$categoryTotal} {:__('篇')}
-
+
{if count($categoryRanks) > 0} {foreach $categoryRanks as $cat}
@@ -285,7 +332,7 @@
{/foreach} {else} -
{:__('暂无分类数据')}
+
{:__('该时段暂无分类发帖数据')}
{/if}
@@ -298,12 +345,12 @@
-

{:__('同城活跃区域 Top 5')}

+

{:__('同城活跃区域 Top 5')} {$period.label}

{:__('基于信息发布所处行政区/县的热度分布')}

- {:__('全部帖子')} + {:__('全部帖子')}
-
+
{if count($areaRanks) > 0}
{foreach $areaRanks as $idx => $area} @@ -318,17 +365,17 @@ {/foreach}
{else} -
{:__('暂无地区发布数据')}
+
{:__('该时段暂无地区发布数据')}
{/if}
- +
-

{:__('平台商业与生态资产')}

-

{:__('会员沉淀、商户入驻及分销裂变体系')}

+

{:__('平台商业与生态资产')} {$period.label}

+

{:__('会员沉淀、商户入驻及分销裂变体系(所选周期统计 / 今日新增)')}

@@ -338,11 +385,11 @@
{:__('VIP会员体系')}
- {$metrics.memberCount} + {$ecosystem.memberCount} +{:$ecosystem['todayMemberCount']} {:__('今日')} {:__('有效VIP会员')}
- {$ecosystem.memberRate}% + {$ecosystem.memberRate}% {:__('会员转化率')}
@@ -353,11 +400,11 @@
{:__('商户入驻生态')}
- {$metrics.merchantCount} - {:__('入驻商户数')} + {$ecosystem.merchantCount} +{:$ecosystem['todayMerchantCount']} {:__('今日')} + {:__('已审入驻商户')}
- {$metrics.recommendMerchant} + {$ecosystem.recommendMerchant} {:__('推荐商家数')}
@@ -368,15 +415,15 @@
{:__('二级分销裂变')}
- {$ecosystem.distributorCount} + {$ecosystem.distributorCount} +{:$ecosystem['todayDistributorCount']} {:__('今日')} {:__('推广分销员')}
- ¥{$ecosystem.commissionSettled|number_format=2} + ¥{$ecosystem.commissionSettled|number_format=2} +{:__('今日')} ¥{$ecosystem.todayCommissionSettled|number_format=2} {:__('已结佣金')}
- ¥{$ecosystem.commissionPending|number_format=2} + ¥{$ecosystem.commissionPending|number_format=2} +{:__('今日')} ¥{$ecosystem.todayCommissionPending|number_format=2} {:__('待结佣金')}
@@ -386,12 +433,12 @@
- +
- {:__('每日数据明细 (近 14 天)')} + {:__('每日数据明细')} ({$period.label})
{:__('展开明细')} diff --git a/application/admin/view/fc/message/index.html b/application/admin/view/fc/message/index.html index aab9001..e2486f6 100644 --- a/application/admin/view/fc/message/index.html +++ b/application/admin/view/fc/message/index.html @@ -10,7 +10,7 @@ 添加 {:__('Edit')} {:__('Delete')} - 回收站 + 回收站
{:__('Refresh')}{:__('Add')} - 回收站 + 回收站删除所选 diff --git a/application/api/controller/Auth.php b/application/api/controller/Auth.php index 26c64a6..50c9394 100644 --- a/application/api/controller/Auth.php +++ b/application/api/controller/Auth.php @@ -29,7 +29,7 @@ class Auth extends V1 { $code = trim((string)$this->input('code', '')); if (!$code) { - $this->fail('缺少微信授权 code'); + $this->fail('缺少微信授权凭证,请重试'); } // 频率限制:同一 IP 每分钟最多 30 次授权登录 @@ -159,7 +159,7 @@ class Auth extends V1 } catch (\Throwable $e) { Db::rollback(); Db::query('SELECT RELEASE_LOCK(?)', [$lockName]); - $this->fail($e->getMessage() ?: '微信登录失败,请重试'); + $this->fail($this->friendlyAuthError($e, '微信登录失败,请重试')); } Db::query('SELECT RELEASE_LOCK(?)', [$lockName]); @@ -208,14 +208,14 @@ class Auth extends V1 $code = trim((string)$this->input('code', '')); if ($code === '') { - $this->fail('缺少手机号授权 code'); + $this->fail('缺少手机号授权凭证,请重试'); } try { $phone = WxMini::phoneNumber($code); } catch (\Throwable $e) { // 常见原因:手机号快捷验证未开通/额度用尽、code 已失效、用户拒绝授权 - $this->fail($e->getMessage() ?: '微信手机号获取失败,请改用手动输入'); + $this->fail($this->friendlyAuthError($e, '微信手机号获取失败,请改用手动输入')); } $conflict = Db::name('user')->where('mobile', $phone)->where('id', '<>', $user['id'])->find(); @@ -372,10 +372,22 @@ class Auth extends V1 if (!WxMini::isConfigured() && config('app_debug')) { return strpos($code, 'openid_') === 0 ? $code : 'openid_' . md5($code); } - $this->fail($e->getMessage() ?: '微信登录失败,请重试'); + $this->fail($this->friendlyAuthError($e, '微信登录失败,请重试')); } } + /** + * 将登录与认证过程中的异常信息转换为用户可理解的中文提示 + * + * @param \Throwable $e 捕获到的异常对象 + * @param string $fallback 默认中文兜底文案 + * @return string 中文错误提示 + */ + protected function friendlyAuthError(\Throwable $e, $fallback = '登录失败,请稍后重试') + { + return WxMini::translateException($e, $fallback); + } + /** * A7 获取当前用户商家认证与商铺资料 * GET /api/v1/auth/merchant @@ -552,12 +564,12 @@ class Auth extends V1 { $refresh = trim((string)$this->input('refreshToken', $this->input('refresh_token', ''))); if ($refresh === '') { - $this->fail('缺少 refreshToken'); + $this->fail('登录凭证缺失,请重新登录'); } $this->rateLimit('refresh:' . $this->request->ip(), 20, 60); if (strpos($refresh, 'rf_') !== 0) { - $this->fail('refreshToken 无效'); + $this->fail('登录凭证无效,请重新登录'); } $row = Db::name('user_token')->where('token', $refresh)->find(); @@ -603,28 +615,34 @@ class Auth extends V1 // 频率限制:同一手机号 + IP,1 分钟最多 5 次 $this->rateLimit('pwdlogin:' . $phone . ':' . $this->request->ip(), 5, 60); - // 查用户:不存在直接失败,不再自动注册(防止批量造号) - $user = Db::name('user')->where('mobile', $phone)->find(); - if (!$user) { - $this->fail('手机号未注册,请先使用微信登录'); - } + try { + // 查用户:不存在直接失败,不再自动注册(防止批量造号) + $user = Db::name('user')->where('mobile', $phone)->find(); + if (!$user) { + $this->fail('手机号未注册,请先使用微信登录'); + } - // 校验密码:只认加盐哈希(已移除历史遗留的 123456 万能密码) - $salt = isset($user['salt']) ? (string)$user['salt'] : ''; - $checkHash = md5(md5($password) . $salt); - if ((string)$user['password'] !== $checkHash) { - $this->fail('密码错误,请重新输入'); - } + // 校验密码:只认加盐哈希(已移除历史遗留的 123456 万能密码) + $salt = isset($user['salt']) ? (string)$user['salt'] : ''; + $checkHash = md5(md5($password) . $salt); + if ((string)$user['password'] !== $checkHash) { + $this->fail('密码错误,请重新输入'); + } - if ($user['status'] !== 'normal') { - $this->fail('账号已被禁用,请联系客服'); - } + if ($user['status'] !== 'normal') { + $this->fail('账号已被禁用,请联系客服'); + } - $token = $this->issueToken($user['id']); - $this->ok([ - 'token' => $token, - 'refreshToken' => $this->issueRefreshToken($user['id']), - 'userInfo' => $this->userInfo($user), - ]); + $token = $this->issueToken($user['id']); + $this->ok([ + 'token' => $token, + 'refreshToken' => $this->issueRefreshToken($user['id']), + 'userInfo' => $this->userInfo($user), + ]); + } catch (\think\exception\HttpResponseException $e) { + throw $e; + } catch (\Throwable $e) { + $this->fail($this->friendlyAuthError($e, '登录失败,请稍后重试')); + } } } diff --git a/application/api/controller/Post.php b/application/api/controller/Post.php index 60d394c..ff811ec 100644 --- a/application/api/controller/Post.php +++ b/application/api/controller/Post.php @@ -158,12 +158,18 @@ class Post extends V1 } // 若传入的 categoryId 是二级分类(pid > 0),自动归属其一级大类与二级分类 $catRow = Db::name('fc_category')->where('id', $categoryId)->find(); - if ($catRow && !empty($catRow['pid']) && (int)$catRow['pid'] > 0) { + if (!$catRow || (isset($catRow['enabled']) && (int)$catRow['enabled'] === 0)) { + $this->fail('所选分类不存在或已停用'); + } + if (!empty($catRow['pid']) && (int)$catRow['pid'] > 0) { $subCategoryId = (int)$catRow['id']; $categoryId = (int)$catRow['pid']; } elseif ($subCategoryId > 0) { $subRow = Db::name('fc_category')->where('id', $subCategoryId)->find(); - if ($subRow && !empty($subRow['pid']) && (int)$subRow['pid'] > 0) { + if (!$subRow || (isset($subRow['enabled']) && (int)$subRow['enabled'] === 0)) { + $this->fail('所选子分类不存在或已停用'); + } + if (!empty($subRow['pid']) && (int)$subRow['pid'] > 0) { $categoryId = (int)$subRow['pid']; } } @@ -290,7 +296,11 @@ class Post extends V1 $identityType = 1; } } - $price = max(0, round((float)$this->input('price', 0), 2)); + $rawPrice = $this->input('price', 0); + if ($rawPrice !== '' && $rawPrice !== null && (float)$rawPrice < 0) { + $this->fail('价格不能为负数'); + } + $price = max(0, round((float)$rawPrice, 2)); $priceUnit = mb_substr(trim((string)$this->input('priceUnit', '')), 0, 16); if ($price > 0 && $priceUnit === '') { $priceUnit = '元/斤'; @@ -1375,10 +1385,13 @@ class Post extends V1 $user = $this->auth(); $id = $this->routeId(); - $content = trim((string)$this->input('content', '')); + $content = trim(strip_tags((string)$this->input('content', ''))); if ($content === '') { $this->fail('评价内容不能为空'); } + if (mb_strlen($content) > 500) { + $this->fail('评价内容不能超过 500 字'); + } $score = (int)$this->input('score', 5); if ($score < 1 || $score > 5) { @@ -1485,9 +1498,9 @@ class Post extends V1 /** * P10 评价列表(详情页「用户评价」) - * GET /api/v1/post/:id/comments → [{id,user,score,content,reply,createdAt}] - * 规则:仅 status=1(正常/审核通过)的评价;置顶优先,其余按时间倒序。 - * 替代前端详情页原先写死的两条假评价。 + * GET /api/v1/post/:id/comments → [{id,user,score,content,reply,status,isMine,createdAt}] + * 规则:正常评价(status=1)对所有人可见;被隐藏评价(status=0)仅评价发布者本人可见; + * 置顶优先,其余按时间倒序。 */ public function comments() { @@ -1496,11 +1509,23 @@ class Post extends V1 $this->fail('信息不存在', 404); } - $rows = Db::name('fc_comment')->alias('co') + $currentUser = $this->user(); + $currentUserId = $currentUser ? (int)$currentUser->id : 0; + + $query = Db::name('fc_comment')->alias('co') ->join('user u', 'u.id = co.user_id', 'LEFT') - ->where('co.post_id', $id) - ->where('co.status', 1) - ->field('co.id, co.user_id, co.score, co.content, co.reply, co.replytime, co.top, co.createtime, u.nickname AS nickname') + ->where('co.post_id', $id); + + if ($currentUserId > 0) { + $query->where(function ($q) use ($currentUserId) { + $q->where('co.status', 1)->whereOr('co.user_id', $currentUserId); + }); + } else { + $query->where('co.status', 1); + } + + $rows = $query + ->field('co.id, co.user_id, co.score, co.content, co.reply, co.replytime, co.top, co.status, co.createtime, u.nickname AS nickname') ->order('co.top desc, co.id desc') ->select(); @@ -1514,6 +1539,8 @@ class Post extends V1 'content' => (string)$row['content'], 'reply' => (string)$row['reply'], 'replytime' => !empty($row['replytime']) ? $this->iso($row['replytime']) : '', + 'status' => (int)$row['status'], + 'isMine' => ($currentUserId > 0 && (int)$row['user_id'] === $currentUserId), 'createdAt' => $this->iso($row['createtime']), ]; } @@ -1521,6 +1548,43 @@ class Post extends V1 $this->ok($list); } + /** + * P12 删除自己的评价 + * POST /api/v1/post/comment/:id/delete + * + * @return void + */ + public function deleteComment() + { + $user = $this->auth(); + $commentId = $this->routeId(); + if ($commentId <= 0) { + $this->fail('评价不存在', 404); + } + + $comment = Db::name('fc_comment')->where('id', $commentId)->find(); + if (!$comment) { + $this->fail('评价不存在', 404); + } + if ((int)$comment['user_id'] !== (int)$user['id']) { + $this->fail('无权删除他人的评价', 403); + } + + Db::name('fc_comment')->where('id', $commentId)->delete(); + + // 同步刷新对应信息的有效评价数 + $validCount = (int)Db::name('fc_comment') + ->where('post_id', (int)$comment['post_id']) + ->where('status', 1) + ->count(); + Db::name('fc_post')->where('id', (int)$comment['post_id'])->update([ + 'comment_count' => $validCount, + 'updatetime' => time(), + ]); + + $this->ok(['commentId' => $commentId]); + } + /** * 读取路由 :id 参数(兼容 POST 体/查询串传入) * @return int diff --git a/application/api/controller/Report.php b/application/api/controller/Report.php index 4bce4b5..217255c 100644 --- a/application/api/controller/Report.php +++ b/application/api/controller/Report.php @@ -7,8 +7,9 @@ use think\Db; /** * 用户端 · 举报(Module-REPORT) * 路由: - * POST /api/v1/report 举报信息/评价 - * GET /api/v1/report/my 我的举报记录 + * POST /api/v1/report 举报信息/评价 + * GET /api/v1/report/my 我的举报记录 + * GET /api/v1/report/:id 我的举报记录详情 * * 说明:举报原因字典由后台配置 fc_config 的 report.reasons(JSON 数组)维护, * 小程序端从站点配置读取;本接口做「必填 + 类型合法 + 对象存在 + 防重复提交」校验, @@ -127,9 +128,13 @@ class Report extends V1 public function my() { $user = $this->auth(); + $status = trim((string)$this->input('status', '')); - list($rows, $total, $page, $size) = $this->pageQuery(function ($forCount) use ($user) { + list($rows, $total, $page, $size) = $this->pageQuery(function ($forCount) use ($user, $status) { $q = Db::name('fc_report')->where('reporter_id', (int)$user['id']); + if (in_array($status, ['pending', 'handled'], true)) { + $q->where('status', $status); + } if ($forCount) { return $q; } @@ -138,40 +143,105 @@ class Report extends V1 $list = []; foreach ($rows as $row) { - $targetTitle = ''; - if ($row['target_type'] === 'post') { - $postTitle = Db::name('fc_post')->where('id', $row['target_id'])->value('title'); - $targetTitle = $postTitle ? (string)$postTitle : '信息已下架或删除'; - } elseif ($row['target_type'] === 'comment') { - $commentContent = Db::name('fc_comment')->where('id', $row['target_id'])->value('content'); - $targetTitle = $commentContent ? (mb_substr($commentContent, 0, 30) . (mb_strlen($commentContent) > 30 ? '...' : '')) : '评价已删除'; - } - - $rawImages = !empty($row['images']) ? explode(',', (string)$row['images']) : []; - $imgUrls = []; - foreach ($rawImages as $img) { - $img = trim((string)$img); - if ($img !== '') { - $imgUrls[] = cdnurl($img, true); - } - } - - $list[] = [ - 'id' => (int)$row['id'], - 'targetType' => (string)$row['target_type'], - 'targetId' => (int)$row['target_id'], - 'targetTitle' => $targetTitle, - 'reason' => (string)$row['reason'], - 'images' => $imgUrls, - 'detail' => (string)$row['remark'], - 'status' => (string)$row['status'], - 'statusText' => $row['status'] === 'handled' ? '已处理' : '核实中', - 'handleRemark' => (string)($row['handle_remark'] ?? ''), - 'createdAt' => $this->iso($row['createtime']), - 'updatedAt' => $this->iso($row['updatetime']), - ]; + $list[] = $this->formatReportRow($row, false); } $this->ok($this->paginate($list, $total, $page, $size)); } + + /** + * 获取当前用户的单条举报记录详情 + * GET /api/v1/report/:id + * + * @param int $id 举报记录 ID + * @return void + */ + public function detail($id = 0) + { + $user = $this->auth(); + $reportId = (int)$id ?: (int)$this->input('id', 0); + if ($reportId <= 0) { + $this->fail('举报记录不存在', 404); + } + + $row = Db::name('fc_report') + ->where('id', $reportId) + ->where('reporter_id', (int)$user['id']) + ->find(); + if (!$row) { + $this->fail('举报记录不存在', 404); + } + + $this->ok($this->formatReportRow($row, true)); + } + + /** + * 格式化单条举报记录输出结构(列表与详情共用) + * + * @param array $row fc_report 数据行 + * @param bool $includeFullTarget 是否附带完整被举报对象内容与存在状态 + * @return array + */ + private function formatReportRow(array $row, $includeFullTarget = false) + { + $targetTitle = ''; + $targetContent = ''; + $targetExists = false; + + if ($row['target_type'] === 'post') { + $post = Db::name('fc_post') + ->where('id', $row['target_id']) + ->field('id,title,content,deletetime,status') + ->find(); + $targetExists = !empty($post) && empty($post['deletetime']); + $targetTitle = !empty($post['title']) ? (string)$post['title'] : '信息已下架或删除'; + if ($includeFullTarget && !empty($post['content'])) { + $targetContent = (string)$post['content']; + } + } elseif ($row['target_type'] === 'comment') { + $comment = Db::name('fc_comment') + ->where('id', $row['target_id']) + ->field('id,content') + ->find(); + $targetExists = !empty($comment); + $commentContent = !empty($comment['content']) ? (string)$comment['content'] : ''; + $targetTitle = $commentContent !== '' + ? (mb_substr($commentContent, 0, 30) . (mb_strlen($commentContent) > 30 ? '...' : '')) + : '评价已删除'; + if ($includeFullTarget) { + $targetContent = $commentContent; + } + } + + $rawImages = !empty($row['images']) ? explode(',', (string)$row['images']) : []; + $imgUrls = []; + foreach ($rawImages as $img) { + $img = trim((string)$img); + if ($img !== '') { + $imgUrls[] = cdnurl($img, true); + } + } + + $item = [ + 'id' => (int)$row['id'], + 'targetType' => (string)$row['target_type'], + 'targetId' => (int)$row['target_id'], + 'targetTitle' => $targetTitle, + 'targetExists' => $targetExists, + 'reason' => (string)$row['reason'], + 'images' => $imgUrls, + 'detail' => (string)$row['remark'], + 'status' => (string)$row['status'], + 'statusText' => $row['status'] === 'handled' ? '已处理' : '核实中', + 'handleRemark' => (string)($row['handle_remark'] ?? ''), + 'createdAt' => $this->iso($row['createtime']), + 'updatedAt' => $this->iso($row['updatetime']), + ]; + + if ($includeFullTarget) { + $item['targetContent'] = $targetContent; + } + + return $item; + } } diff --git a/application/common/library/WxMini.php b/application/common/library/WxMini.php index 61673c2..3a31dc3 100644 --- a/application/common/library/WxMini.php +++ b/application/common/library/WxMini.php @@ -134,10 +134,15 @@ class WxMini { $code = trim((string)$code); if ($code === '') { - throw new \RuntimeException('缺少微信授权 code'); + throw new \RuntimeException('缺少微信授权凭证,请重试'); + } + + try { + $res = self::toArray(self::app()->auth->session($code)); + } catch (\Throwable $e) { + throw new \RuntimeException(self::translateException($e, '微信登录失败,请重试')); } - $res = self::toArray(self::app()->auth->session($code)); if (empty($res['openid'])) { throw new \RuntimeException(self::errorMessage($res, '微信登录失败,请重试')); } @@ -171,13 +176,17 @@ class WxMini { $code = trim((string)$code); if ($code === '') { - throw new \RuntimeException('缺少手机号授权 code'); + throw new \RuntimeException('缺少手机号授权凭证,请重试'); } // SDK 的 BaseClient 会自动带上 access_token(含缓存与 401 重试) - $res = self::toArray( - self::app()->getClient()->httpPostJson('wxa/business/getuserphonenumber', ['code' => $code]) - ); + try { + $res = self::toArray( + self::app()->getClient()->httpPostJson('wxa/business/getuserphonenumber', ['code' => $code]) + ); + } catch (\Throwable $e) { + throw new \RuntimeException(self::translateException($e, '微信手机号获取失败,请改用手动输入')); + } $info = (isset($res['phone_info']) && is_array($res['phone_info'])) ? $res['phone_info'] : []; $phone = ''; @@ -284,7 +293,7 @@ class WxMini * * @param array $res 微信应答 * @param string $fallback 兜底文案 - * @return string + * @return string 用户可理解的中文提示 */ protected static function errorMessage(array $res, $fallback) { @@ -292,16 +301,98 @@ class WxMini $msg = isset($res['errmsg']) ? (string)$res['errmsg'] : ''; $known = [ - 40029 => '微信登录凭证已失效,请重新授权', - 40163 => '微信登录凭证已被使用,请重新授权', - 41004 => '小程序 AppSecret 不正确,请在后台检查微信登录配置', - 45011 => '微信接口调用过于频繁,请稍后再试', -1 => '微信服务繁忙,请稍后再试', + 40001 => '微信授权凭证无效,请联系管理员检查小程序配置', + 40002 => '微信授权参数异常,请重新尝试', + 40013 => '小程序 AppID 配置无效,请联系管理员检查', + 40029 => '微信登录凭证已失效,请重新授权', + 40125 => '小程序 AppSecret 配置无效,请联系管理员检查', + 40163 => '微信登录凭证已被使用,请重新授权', + 40164 => '服务器 IP 未加入微信白名单,请联系管理员处理', + 40226 => '当前微信账号存在安全风险,暂无法登录', + 41002 => '缺少小程序 AppID 配置,请联系管理员检查', + 41004 => '小程序 AppSecret 不正确,请在后台检查微信登录配置', + 43002 => '微信接口请求方式异常,请重试', + 45009 => '今日微信接口调用次数已达上限,请稍后再试', + 45011 => '微信接口调用过于频繁,请稍后再试', + 48001 => '当前小程序暂未开通该接口权限,请联系管理员', + 50002 => '当前微信账号状态受限,无法完成操作', + 89503 => '微信接口调用受限,请稍后再试', + 89506 => '微信接口调用受限,请稍后再试', + 89507 => '微信接口调用受限,请稍后再试', ]; if (isset($known[$code])) { return $known[$code]; } - return $msg !== '' ? $fallback . '(' . $code . ': ' . $msg . ')' : $fallback; + if ($msg !== '') { + $lower = strtolower($msg); + if (strpos($lower, 'invalid appid') !== false) { + return '小程序 AppID 配置无效,请联系管理员检查'; + } + if (strpos($lower, 'invalid appsecret') !== false) { + return '小程序 AppSecret 配置无效,请联系管理员检查'; + } + if (strpos($lower, 'invalid code') !== false) { + return '微信登录凭证已失效,请重新授权'; + } + if (strpos($lower, 'code been used') !== false) { + return '微信登录凭证已被使用,请重新授权'; + } + if (strpos($lower, 'freq') !== false || strpos($lower, 'limit') !== false) { + return '微信接口调用过于频繁,请稍后再试'; + } + if (strpos($lower, 'system error') !== false || strpos($lower, 'busy') !== false) { + return '微信服务繁忙,请稍后再试'; + } + \think\Log::error('[WxMini] 微信接口返回未映射错误: errcode=' . $code . ', errmsg=' . $msg); + } + + return $code !== 0 ? $fallback . '(错误码:' . $code . ')' : $fallback; + } + + /** + * 将微信 SDK / 网络 / 系统异常转换为用户可理解的中文提示 + * + * @param \Throwable $e 捕获的异常 + * @param string $fallback 默认中文兜底文案 + * @return string 中文错误提示 + */ + public static function translateException(\Throwable $e, $fallback = '微信服务异常,请稍后再试') + { + $raw = trim((string)$e->getMessage()); + if ($raw === '') { + return $fallback; + } + + // 若消息本身已包含中文且不含底层英文错误特征(如 SQLSTATE / cURL / JSON 报错),直接透传 + if (preg_match('/[\x{4e00}-\x{9fa5}]/u', $raw) + && stripos($raw, 'SQLSTATE') === false + && stripos($raw, 'cURL error') === false + && stripos($raw, 'Request access_token fail') === false + ) { + return $raw; + } + + // 尝试从 EasyWeChat 异常消息中解析微信 JSON 错误(如 Request access_token fail: {"errcode":40013,"errmsg":"invalid appid"}) + if (preg_match('/\{.*"errcode"\s*:\s*-?\d+.*\}/s', $raw, $matches)) { + $decoded = json_decode($matches[0], true); + if (is_array($decoded) && isset($decoded['errcode'])) { + return self::errorMessage($decoded, $fallback); + } + } + + $lower = strtolower($raw); + if (strpos($lower, 'timed out') !== false || strpos($lower, 'timeout') !== false || strpos($lower, 'curl error 28') !== false) { + \think\Log::error('[WxMini] 请求微信超时: ' . $raw); + return '连接微信服务器超时,请稍后重试'; + } + if (strpos($lower, 'curl error') !== false || strpos($lower, 'could not resolve') !== false || strpos($lower, 'failed to connect') !== false || strpos($lower, 'ssl') !== false) { + \think\Log::error('[WxMini] 请求微信网络异常: ' . $raw); + return '网络连接微信服务器失败,请稍后重试'; + } + + \think\Log::error('[WxMini] 微信调用异常: ' . $raw); + return $fallback; } } diff --git a/application/route.php b/application/route.php index 9135113..8a10f94 100755 --- a/application/route.php +++ b/application/route.php @@ -55,6 +55,7 @@ return [ 'api/v1/post/:id/dial' => 'api/Post/dial', 'api/v1/post/:id/pay-view' => 'api/Post/payView', 'api/v1/post/comment/:id/reply' => 'api/Post/replyComment', + 'api/v1/post/comment/:id/delete' => 'api/Post/deleteComment', 'api/v1/post/:id/comment' => 'api/Post/comment', 'api/v1/post/:id/comments' => 'api/Post/comments', 'api/v1/post/create' => 'api/Post/create', @@ -77,8 +78,10 @@ return [ * favorite/status、follow/toggle、follow/list),彼此不构成前缀包含关系,注册顺序互不吞并; * 且本表未登记 favorite/:id、follow/:id、report/:id 之类通配规则,不存在被吞风险。 */ - 'api/v1/report' => 'api/Report/create', 'api/v1/report/my' => 'api/Report/my', + 'api/v1/report/detail' => 'api/Report/detail', + 'api/v1/report/:id' => 'api/Report/detail', + 'api/v1/report' => 'api/Report/create', 'api/v1/favorite/list' => 'api/Favorite/list', 'api/v1/favorite/toggle' => 'api/Favorite/toggle', 'api/v1/favorite/status' => 'api/Favorite/status', diff --git a/public/assets/css/backend-theme.css b/public/assets/css/backend-theme.css index 2e3df8b..1309bb7 100644 --- a/public/assets/css/backend-theme.css +++ b/public/assets/css/backend-theme.css @@ -1013,6 +1013,182 @@ body.inside-header .content { font-weight: 600; } +/* ---------- 全局日期统计切换栏 ---------- */ +.fc-dash.is-loading { + opacity: 0.72; + transition: opacity .15s ease; + pointer-events: none; +} + +.fc-filter-bar { + display: flex; + align-items: center; + justify-content: space-between; + flex-wrap: wrap; + gap: 12px; + margin-bottom: 16px; + padding: 10px 14px; + border: 1px solid #E2E8F0; + border-radius: 12px; + background: #FFFFFF; + box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03); +} + +.fc-filter-bar__left, +.fc-filter-bar__right { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 10px; +} + +.fc-filter-bar__label { + display: inline-flex; + align-items: center; + gap: 6px; + color: #334155; + font-size: 13px; + font-weight: 600; +} + +.fc-filter-bar__label .fa { + color: #00A854; +} + +.fc-date-custom { + display: inline-flex; + align-items: center; + gap: 6px; +} + +.fc-date-input { + height: 30px; + padding: 0 8px; + border: 1px solid #CBD5E1; + border-radius: 6px; + background: #F8FAFC; + color: #1E293B; + font-size: 12px; + outline: none; + transition: border-color .15s ease, background .15s ease; +} + +.fc-date-input:focus { + border-color: #00D26A; + background: #FFFFFF; +} + +.fc-date-sep { + color: #94A3B8; + font-size: 12px; +} + +.fc-btn--sm { + height: 30px; + padding: 0 12px; + font-size: 12px; +} + +.fc-filter-bar__current { + display: inline-flex; + align-items: center; + padding: 4px 10px; + border-radius: 6px; + background: #E6FBF0; + color: #00A854; + font-size: 12px; + font-weight: 600; +} + +/* ---------- KPI 双维展示(累计总计 + 今日新增) ---------- */ +.fc-kpi__dual { + display: flex; + align-items: flex-end; + justify-content: space-between; + gap: 10px; + margin: 10px 0 12px; +} + +.fc-kpi__main { + min-width: 0; +} + +.fc-kpi__subtag { + display: block; + color: #94A3B8; + font-size: 11px; + font-weight: 500; + line-height: 1.2; + margin-bottom: 3px; +} + +.fc-kpi__main .fc-kpi__value { + margin: 0; + font-size: 26px; + line-height: 1.1; +} + +.fc-kpi__today { + text-align: right; + padding: 6px 10px; + border-radius: 8px; + background: #F8FAFC; + border: 1px solid #F1F5F9; + flex-shrink: 0; +} + +.fc-kpi__today-val { + margin: 0; + font-size: 15px; + font-weight: 700; + line-height: 1.2; + font-variant-numeric: tabular-nums; +} + +.fc-kpi__today-val small { + font-size: 11px; + font-weight: 500; + color: #64748B; +} + +.fc-kpi__today-val.is-green { + color: #00A854; +} + +.fc-kpi__today-val.is-gold { + color: #D97706; +} + +.fc-kpi__today-val.is-blue { + color: #2563EB; +} + +.fc-kpi__today-val.is-purple { + color: #7C3AED; +} + +.fc-kpi__range { + color: #64748B; + font-size: 12px; +} + +.fc-kpi__range strong { + color: #1E293B; + font-weight: 600; +} + +.fc-eco-today { + display: inline-block; + margin-left: 4px; + padding: 1px 6px; + border-radius: 999px; + background: #E6FBF0; + color: #00A854; + font-size: 11px; + font-weight: 600; + vertical-align: middle; +} + /* ---------- 响应式布局 ---------- */ @media (max-width: 1100px) { .fc-dash__middle-grid { diff --git a/public/assets/js/backend/fc/comment.js b/public/assets/js/backend/fc/comment.js index 29bbccb..005a14b 100644 --- a/public/assets/js/backend/fc/comment.js +++ b/public/assets/js/backend/fc/comment.js @@ -113,6 +113,44 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], fu return false; }); } + }, + { + name: 'hide', + text: '隐藏', + title: '隐藏评价', + classname: 'btn btn-xs btn-warning btn-click', + visible: function (row) { + return Number(row.status) === 1; + }, + confirm: '确认隐藏该评价?隐藏后前台将不再展示。', + click: function (options, row) { + Fast.api.ajax({ + url: 'fc/comment/status', + data: {ids: row.id, status: 0} + }, function () { + $('#' + options.tableId).bootstrapTable('refresh'); + return false; + }); + } + }, + { + name: 'show', + text: '显示', + title: '恢复显示评价', + classname: 'btn btn-xs btn-primary btn-click', + visible: function (row) { + return Number(row.status) !== 1; + }, + confirm: '确认恢复显示该评价?恢复后将在前台展示。', + click: function (options, row) { + Fast.api.ajax({ + url: 'fc/comment/status', + data: {ids: row.id, status: 1} + }, function () { + $('#' + options.tableId).bootstrapTable('refresh'); + return false; + }); + } } ] } @@ -153,6 +191,36 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], fu }); }); + /** + * 批量切换选中评价的显示/隐藏状态 + * @param {number} status 目标状态(1=显示,0=隐藏) + * @param {string} confirmText 确认弹窗文案 + */ + function batchToggleStatus(status, confirmText) { + var ids = Table.api.selectedids(table); + if (!ids.length) return; + Layer.confirm(confirmText, {icon: 3, title: __('提示')}, function (index) { + Fast.api.ajax({ + url: 'fc/comment/status', + data: {ids: ids.join(','), status: status} + }, function () { + table.bootstrapTable('refresh'); + return false; + }); + Layer.close(index); + }); + } + + // 批量显示 + $(document).on('click', '.btn-show', function () { + batchToggleStatus(1, '确认恢复显示选中的评价?'); + }); + + // 批量隐藏 + $(document).on('click', '.btn-hide', function () { + batchToggleStatus(0, '确认隐藏选中的评价?隐藏后前台将不再展示。'); + }); + }, add: function () { Controller.api.bindevent(); diff --git a/public/assets/js/backend/fc/dashboard.js b/public/assets/js/backend/fc/dashboard.js index 8831c26..bbc4c44 100644 --- a/public/assets/js/backend/fc/dashboard.js +++ b/public/assets/js/backend/fc/dashboard.js @@ -5,55 +5,20 @@ define(['jquery', 'bootstrap', 'backend', 'echarts', 'echarts-theme'], function */ var Controller = { /** - * 看板首页初始化与图表联动逻辑 + * 看板首页初始化、日期筛选与图表联动逻辑 */ index: function () { - var allTrends = (typeof Config !== 'undefined' && Config.allTrends) ? Config.allTrends : null; - var revenueTypes = (typeof Config !== 'undefined' && Config.revenueTypes) ? Config.revenueTypes : []; - var categoryRanks = (typeof Config !== 'undefined' && Config.categoryRanks) ? Config.categoryRanks : []; - - // 页面刷新按钮 - $(document).on('click', '.fc-dash__refresh', function () { - var $btn = $(this); - $btn.find('.fa').addClass('fa-spin'); - window.location.reload(); - }); - - // 当前状态 - var currentDays = 14; + var currentTrend = (typeof Config !== 'undefined' && Config.initialTrend) ? Config.initialTrend : null; + var currentRev = (typeof Config !== 'undefined' && Config.revenueTypes) ? Config.revenueTypes : []; + var currentPeriod = (typeof Config !== 'undefined' && Config.initialPeriod) ? Config.initialPeriod : {key: 'all', label: '全部累计'}; var currentMetric = 'posts'; - // 工具:格式化千分位数值 - var formatNum = function (n, isMoney) { - var val = Number(n) || 0; - if (isMoney) { - return '¥' + val.toLocaleString('zh-CN', {minimumFractionDigits: 2, maximumFractionDigits: 2}); - } - return val.toLocaleString('zh-CN'); - }; + var trendChartInstance = null; + var revenueChartInstance = null; + var $trendChartEl = $('#fc-trend-chart'); + var $revenueChartEl = $('#fc-revenue-chart'); - // 工具:数组求和 - var sumArray = function (arr) { - var sum = 0; - $.each(arr || [], function (i, v) { - sum += (Number(v) || 0); - }); - return sum; - }; - - // 工具:数组求峰值 - var peakArray = function (arr) { - var max = 0; - $.each(arr || [], function (i, v) { - var n = Number(v) || 0; - if (n > max) { - max = n; - } - }); - return max; - }; - - // 指标元数据配置(符合轻氧浅绿与品牌规范) + // 指标元数据配置(轻氧浅绿品牌规范) var METRIC_CONFIG = { posts: { label: __('发布量'), @@ -89,10 +54,65 @@ define(['jquery', 'bootstrap', 'backend', 'echarts', 'echarts-theme'], function } }; - var trendChartInstance = null; - var revenueChartInstance = null; - var $trendChartEl = $('#fc-trend-chart'); - var $revenueChartEl = $('#fc-revenue-chart'); + /** + * HTML 特殊字符转义,防止动态渲染注入 + * + * @param {string} str + * @return {string} + */ + var escapeHtml = function (str) { + return String(str || '') + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); + }; + + /** + * 格式化数字或金额 + * + * @param {number} n + * @param {boolean} isMoney + * @return {string} + */ + var formatNum = function (n, isMoney) { + var val = Number(n) || 0; + if (isMoney) { + return '¥' + val.toLocaleString('zh-CN', {minimumFractionDigits: 2, maximumFractionDigits: 2}); + } + return val.toLocaleString('zh-CN'); + }; + + /** + * 计算数组元素总和 + * + * @param {Array} arr + * @return {number} + */ + var sumArray = function (arr) { + var sum = 0; + $.each(arr || [], function (i, v) { + sum += (Number(v) || 0); + }); + return sum; + }; + + /** + * 计算数组最大值 + * + * @param {Array} arr + * @return {number} + */ + var peakArray = function (arr) { + var max = 0; + $.each(arr || [], function (i, v) { + var n = Number(v) || 0; + if (n > max) { + max = n; + } + }); + return max; + }; /** * 构建趋势折线/面积图配置项 @@ -102,10 +122,10 @@ define(['jquery', 'bootstrap', 'backend', 'echarts', 'echarts-theme'], function * @return {Object} */ var buildTrendOption = function (trendData, metricKey) { - var meta = METRIC_CONFIG[metricKey]; + var meta = METRIC_CONFIG[metricKey]; var rawDates = trendData.dates || []; - var dates = $.map(rawDates, function (d) { - return d.slice(5); // 截取 MM-DD + var dates = $.map(rawDates, function (d) { + return d.slice(5); }); var data = trendData[metricKey] || []; @@ -131,10 +151,10 @@ define(['jquery', 'bootstrap', 'backend', 'echarts', 'echarts-theme'], function lineStyle: {color: meta.color, width: 1.5, type: 'dashed'} }, formatter: function (params) { - var item = params[0]; + var item = params[0]; var fullDate = rawDates[item.dataIndex] || item.axisValue; - var valStr = meta.isMoney ? ('¥' + Number(item.data).toFixed(2)) : (item.data + ' ' + meta.unit); - var dot = ''; return '
' + fullDate + '
' + dot + meta.label + ':' + valStr + ''; @@ -142,7 +162,7 @@ define(['jquery', 'bootstrap', 'backend', 'echarts', 'echarts-theme'], function }, xAxis: { type: 'category', - boundaryGap: false, + boundaryGap: rawDates.length <= 1, data: dates, axisLine: {lineStyle: {color: '#E2E8F0'}}, axisTick: {show: false}, @@ -164,19 +184,20 @@ define(['jquery', 'bootstrap', 'backend', 'echarts', 'echarts-theme'], function }, series: [{ name: meta.label, - type: 'line', + type: rawDates.length <= 1 ? 'bar' : 'line', + barMaxWidth: 36, smooth: 0.35, symbol: 'circle', symbolSize: 6, - showSymbol: false, + showSymbol: rawDates.length <= 7, lineStyle: {width: 2.5, color: meta.color}, - itemStyle: {color: meta.color, borderColor: '#FFFFFF', borderWidth: 2}, + itemStyle: {color: meta.color, borderColor: '#FFFFFF', borderWidth: 2, borderRadius: [6, 6, 0, 0]}, emphasis: { focus: 'series', scale: true, itemStyle: {color: meta.color, borderColor: '#FFFFFF', borderWidth: 3} }, - areaStyle: { + areaStyle: rawDates.length <= 1 ? null : { color: new Echarts.graphic.LinearGradient(0, 0, 0, 1, [ {offset: 0, color: meta.fillStart}, {offset: 1, color: meta.fillEnd} @@ -184,22 +205,20 @@ define(['jquery', 'bootstrap', 'backend', 'echarts', 'echarts-theme'], function }, data: data }], - animationDuration: 400 + animationDuration: 350 }; }; /** - * 更新图表及上方统计卡 + * 渲染趋势图、顶部汇总数值与明细表 */ var renderTrend = function () { - if (!allTrends || !allTrends[currentDays]) { + if (!currentTrend) { return; } - var trendData = allTrends[currentDays]; - var meta = METRIC_CONFIG[currentMetric]; - var data = trendData[currentMetric] || []; + var meta = METRIC_CONFIG[currentMetric]; + var data = currentTrend[currentMetric] || []; - // 1. 计算时段总计、日均、峰值 var total = sumArray(data); var avg = data.length > 0 ? (total / data.length) : 0; var peak = peakArray(data); @@ -214,13 +233,11 @@ define(['jquery', 'bootstrap', 'backend', 'echarts', 'echarts-theme'], function $('#fc-trend-peak').text(formatNum(peak, false) + ' ' + meta.unit); } - // 2. 更新 Echarts if (trendChartInstance) { - trendChartInstance.setOption(buildTrendOption(trendData, currentMetric), true); + trendChartInstance.setOption(buildTrendOption(currentTrend, currentMetric), true); } - // 3. 同步更新底表明细 - updateDetailTable(trendData.rows || []); + updateDetailTable(currentTrend.rows || []); }; /** @@ -229,7 +246,8 @@ define(['jquery', 'bootstrap', 'backend', 'echarts', 'echarts-theme'], function * @param {Array} rows */ var updateDetailTable = function (rows) { - $('#fc-table-title').text(__('每日数据明细 (近 %s 天)', currentDays)); + var periodLabel = currentPeriod && currentPeriod.label ? currentPeriod.label : ''; + $('#fc-table-title').text(__('每日数据明细') + ' (' + periodLabel + ')'); var $tbody = $('#fc-table-body'); $tbody.empty(); @@ -239,14 +257,10 @@ define(['jquery', 'bootstrap', 'backend', 'echarts', 'echarts-theme'], function } $.each(rows, function (idx, item) { - var orderStr = '¥' + Number(item.orders || 0).toLocaleString('zh-CN', { - minimumFractionDigits: 2, - maximumFractionDigits: 2 - }); var tr = '' - + '' + + '' + '' - + '' + + '' + '' + '' + ''; @@ -255,29 +269,54 @@ define(['jquery', 'bootstrap', 'backend', 'echarts', 'echarts-theme'], function }; /** - * 初始化营收构成环形饼图 + * 渲染营收构成环形图与右侧列表 + * + * @param {Array} revenueTypes + * @param {number} revenueTotal + * @param {string} periodLabel */ - var initRevenueChart = function () { + var renderRevenueSection = function (revenueTypes, revenueTotal, periodLabel) { + $('#fc-revenue-tag').text(periodLabel + ' · ' + formatNum(revenueTotal, true)); + + var $list = $('#fc-revenue-list'); + $list.empty(); + + if (!revenueTypes || revenueTypes.length === 0) { + $list.append('
' + __('该时段暂无已支付订单数据') + '
'); + } else { + $.each(revenueTypes, function (i, rev) { + var html = '
' + + '
' + + '' + escapeHtml(rev.label) + '' + + '(' + (rev.count || 0) + __('笔') + ')' + + '
' + + '
' + + '' + formatNum(rev.amount, true) + '' + + '' + rev.percent + '%' + + '
' + + '
'; + $list.append(html); + }); + } + if (!$revenueChartEl.length || !Echarts) { return; } - - revenueChartInstance = Echarts.init($revenueChartEl[0]); - - if (!revenueTypes || revenueTypes.length === 0) { - return; + if (!revenueChartInstance) { + revenueChartInstance = Echarts.init($revenueChartEl[0]); } - var chartData = $.map(revenueTypes, function (item) { - return { - name: item.label, - value: item.amount - }; - }); + var chartData = (revenueTypes && revenueTypes.length > 0) + ? $.map(revenueTypes, function (item) { + return {name: item.label, value: item.amount}; + }) + : [{name: __('暂无数据'), value: 0}]; - var palette = ['#00D26A', '#F5A623', '#3B82F6', '#8B5CF6', '#EC4899', '#14B8A6']; + var palette = (revenueTypes && revenueTypes.length > 0) + ? ['#00D26A', '#F5A623', '#3B82F6', '#8B5CF6', '#EC4899', '#14B8A6'] + : ['#E2E8F0']; - var option = { + revenueChartInstance.setOption({ color: palette, tooltip: { trigger: 'item', @@ -288,12 +327,10 @@ define(['jquery', 'bootstrap', 'backend', 'echarts', 'echarts-theme'], function textStyle: {color: '#1E293B', fontSize: 12}, extraCssText: 'border-radius:8px;box-shadow:0 6px 18px rgba(15,23,42,0.08);', formatter: function (p) { - return p.name + '
¥' + Number(p.value).toFixed(2) + ' (' + p.percent + '%)'; + return escapeHtml(p.name) + '
¥' + Number(p.value).toFixed(2) + ' (' + p.percent + '%)'; } }, - legend: { - show: false - }, + legend: {show: false}, series: [{ type: 'pie', radius: ['52%', '76%'], @@ -304,9 +341,7 @@ define(['jquery', 'bootstrap', 'backend', 'echarts', 'echarts-theme'], function borderColor: '#FFFFFF', borderWidth: 2 }, - label: { - show: false - }, + label: {show: false}, emphasis: { scale: true, scaleSize: 6, @@ -320,46 +355,175 @@ define(['jquery', 'bootstrap', 'backend', 'echarts', 'echarts-theme'], function labelLine: {show: false}, data: chartData }] - }; - - revenueChartInstance.setOption(option); + }, true); }; - // 初始化趋势主图 - if ($trendChartEl.length && Echarts) { - trendChartInstance = Echarts.init($trendChartEl[0]); - renderTrend(); - } + /** + * 渲染热门分类发帖分布 + * + * @param {Array} categoryRanks + * @param {number} categoryTotal + * @param {string} periodLabel + */ + var renderCategorySection = function (categoryRanks, categoryTotal, periodLabel) { + $('#fc-category-tag').text(periodLabel + ' · ' + (categoryTotal || 0) + ' ' + __('篇')); + var $list = $('#fc-category-list'); + $list.empty(); - // 初始化营收环形图 - initRevenueChart(); - - // 监听窗口尺寸变化自适应 - $(window).on('resize', function () { - if (trendChartInstance) { - trendChartInstance.resize(); - } - if (revenueChartInstance) { - revenueChartInstance.resize(); - } - }); - - // 时段切换点击(近 7 / 14 / 30 天) - $(document).on('click', '.fc-range-btn', function () { - var $btn = $(this); - var days = parseInt($btn.data('days'), 10) || 14; - if (days === currentDays) { + if (!categoryRanks || categoryRanks.length === 0) { + $list.append('
' + __('该时段暂无分类发帖数据') + '
'); return; } - currentDays = days; - $('.fc-range-btn').removeClass('is-active'); - $btn.addClass('is-active'); - renderTrend(); + + $.each(categoryRanks, function (i, cat) { + var html = '
' + + '
' + + '' + escapeHtml(cat.name) + '' + + '' + (cat.count || 0) + ' ' + __('篇') + ' (' + cat.percent + '%)' + + '
' + + '
' + + '
' + + '
' + + '
'; + $list.append(html); + }); + }; + + /** + * 渲染同城活跃区域 Top 5 + * + * @param {Array} areaRanks + * @param {string} periodLabel + */ + var renderAreaSection = function (areaRanks, periodLabel) { + $('#fc-area-tag').text(periodLabel); + var $wrap = $('#fc-area-list'); + $wrap.empty(); + + if (!areaRanks || areaRanks.length === 0) { + $wrap.append('
' + __('该时段暂无地区发布数据') + '
'); + return; + } + + var html = '
'; + $.each(areaRanks, function (idx, area) { + var badgeCls = idx < 3 ? ' is-top' : ''; + html += '
' + + '' + (idx + 1) + '' + + '' + escapeHtml(area.region_name) + '' + + '
' + + '
' + + '
' + + '' + (area.count || 0) + ' ' + __('篇') + '' + + '
'; + }); + html += '
'; + $wrap.html(html); + }; + + /** + * 按日期统计切换参数发起 AJAX 请求并更新看板视图 + * + * @param {Object} params + */ + var fetchAndApplyRange = function (params) { + var query = $.extend({action: 'filter'}, params); + $('.fc-dash').addClass('is-loading'); + + $.get(window.location.pathname, query, function (res) { + $('.fc-dash').removeClass('is-loading'); + if (!res || res.code !== 1 || !res.data) { + Toastr.error(res && res.msg ? res.msg : __('数据加载失败')); + return; + } + var d = res.data; + currentPeriod = d.period; + currentTrend = d.trend; + currentRev = d.revenueTypes; + + // 更新周期显示与输入框 + $('#fc-updated-at').text(d.updatedAt || ''); + $('#fc-current-period-badge').text(__('当前:') + d.period.label); + $('#fc-trend-period-tag').text(d.period.label); + $('.fc-period-name').text(d.period.label); + if (d.period.start_date) { + $('#fc-start-date').val(d.period.start_date); + } else { + $('#fc-start-date').val(''); + } + if (d.period.end_date) { + $('#fc-end-date').val(d.period.end_date); + } + + // 更新 4 大 KPI 主统计数(随筛选时间动态变化) + var m = d.metrics; + $('#fc-kpi-post').text(formatNum(m.rangePost, false)); + $('#fc-kpi-order').text(formatNum(m.rangeOrderAmount, true)); + $('#fc-kpi-order-cnt').text(m.rangeOrderCount); + $('#fc-kpi-user').text(formatNum(m.rangeUser, false)); + $('#fc-kpi-views').text(formatNum(m.rangeViews, false)); + + // 更新商业与生态资产统计(随筛选时间动态变化) + if (d.ecosystem) { + var eco = d.ecosystem; + $('#fc-eco-tag').text(d.period.label); + $('#fc-eco-member').text(formatNum(eco.memberCount, false)); + $('#fc-eco-member-rate').text(eco.memberRate + '%'); + $('#fc-eco-merchant').text(formatNum(eco.merchantCount, false)); + $('#fc-eco-recommend').text(formatNum(eco.recommendMerchant, false)); + $('#fc-eco-dist').text(formatNum(eco.distributorCount, false)); + $('#fc-eco-settled').text(formatNum(eco.commissionSettled, true)); + $('#fc-eco-pending').text(formatNum(eco.commissionPending, true)); + } + + // 更新图表与分布 + renderTrend(); + renderRevenueSection(d.revenueTypes, d.revenueTotal, d.period.label); + renderCategorySection(d.categoryRanks, d.categoryTotal, d.period.label); + renderAreaSection(d.areaRanks, d.period.label); + }, 'json').fail(function () { + $('.fc-dash').removeClass('is-loading'); + Toastr.error(__('网络异常,请稍后重试')); + }); + }; + + // 页面刷新按钮 + $(document).on('click', '.fc-dash__refresh', function () { + $(this).find('.fa').addClass('fa-spin'); + window.location.reload(); }); - // 指标切换点击(发布量 / 订单额 / 新增用户 / 信息曝光) + // 预设日期切换点击 + $(document).on('click', '.fc-date-btn', function () { + var $btn = $(this); + var range = $btn.data('range'); + if (!range) { + return; + } + $('.fc-date-btn').removeClass('is-active'); + $btn.addClass('is-active'); + fetchAndApplyRange({range: range}); + }); + + // 自定义起止日期筛选 + $(document).on('click', '#fc-custom-apply', function () { + var startDate = $('#fc-start-date').val(); + var endDate = $('#fc-end-date').val(); + if (!startDate || !endDate) { + Toastr.warning(__('请选择完整的开始和结束日期')); + return; + } + $('.fc-date-btn').removeClass('is-active'); + fetchAndApplyRange({ + range: 'custom', + start_date: startDate, + end_date: endDate + }); + }); + + // 趋势指标切换(发布量 / 订单额 / 新增用户 / 信息曝光) $(document).on('click', '.fc-metric-btn', function () { - var $btn = $(this); + var $btn = $(this); var metric = $btn.data('metric'); if (metric === currentMetric) { return; @@ -369,6 +533,28 @@ define(['jquery', 'bootstrap', 'backend', 'echarts', 'echarts-theme'], function $btn.addClass('is-active'); renderTrend(); }); + + // 初始化图表 + if ($trendChartEl.length && Echarts) { + trendChartInstance = Echarts.init($trendChartEl[0]); + renderTrend(); + } + + var initialRevTotal = 0; + $.each(currentRev, function (i, item) { + initialRevTotal += (Number(item.amount) || 0); + }); + renderRevenueSection(currentRev, initialRevTotal, currentPeriod.label || ''); + + // 自适应窗口尺寸变化 + $(window).on('resize', function () { + if (trendChartInstance) { + trendChartInstance.resize(); + } + if (revenueChartInstance) { + revenueChartInstance.resize(); + } + }); } }; diff --git a/uniapp/common/api/post.js b/uniapp/common/api/post.js index ff723b6..cf6a5d3 100644 --- a/uniapp/common/api/post.js +++ b/uniapp/common/api/post.js @@ -68,6 +68,8 @@ export const postApi = { comment: (id, payload) => post(`/post/${id}/comment`, payload, { silent: true }), /** 发布者回复评价 */ replyComment: (commentId, payload) => post(`/post/comment/${commentId}/reply`, payload, { silent: true }), + /** 删除自己的评价 */ + deleteComment: (commentId) => post(`/post/comment/${commentId}/delete`, {}, { silent: true }), /** 评价列表(详情页「用户评价」,替代前端写死的假评价) */ comments: (id) => get(`/post/${id}/comments`, {}, { silent: true }), } diff --git a/uniapp/common/api/report.js b/uniapp/common/api/report.js index 1015377..f0eab7e 100644 --- a/uniapp/common/api/report.js +++ b/uniapp/common/api/report.js @@ -1,8 +1,9 @@ /** * 接口模块 · 举报(用户端) * 对应接口契约: - * - POST /report 提交举报 {targetType:'post'|'comment', targetId, reason, detail?, images?} → {reportId} - * - GET /report/my 查询我的举报记录 {page, size} → 分页列表 + * - POST /report 提交举报 {targetType:'post'|'comment', targetId, reason, detail?, images?} → {reportId} + * - GET /report/my 查询我的举报记录 {page, size} → 分页列表 + * - GET /report/:id 查询单条举报记录详情 → 举报详情对象 */ import { post, get } from '../utils/request.js' import { REPORT_REASONS } from '../constants/report.js' @@ -29,6 +30,13 @@ export const reportApi = { */ my: (params = {}) => get('/report/my', params, { silent: true }), + /** + * 查询单条举报记录详情 + * @param {number|string} id 举报记录 ID + * @returns {Promise} + */ + detail: (id) => get(`/report/${id}`, {}, { silent: true }), + /** 举报原因默认清单 */ reasons: REPORT_REASONS, } diff --git a/uniapp/common/utils/request.js b/uniapp/common/utils/request.js index 59582e2..4b594c1 100644 --- a/uniapp/common/utils/request.js +++ b/uniapp/common/utils/request.js @@ -141,7 +141,8 @@ export function request(options = {}) { if (body.code === 0 || body.code === 200) { resolve(body.data !== undefined ? body.data : body) } else { - const err = toErr(body.message || body.msg || '请求失败', body.code) + const msg = normalizeErrorMessage(body.message || body.msg, '请求失败,请稍后重试') + const err = toErr(msg, body.code) if (!silent) runtime.showToast({ title: err.message, icon: 'none' }) reject(err) } @@ -153,6 +154,38 @@ export function request(options = {}) { }) } +/** + * 将底层英文网络或系统错误消息转换为用户可理解的中文提示 + * @param {string} raw 原始错误消息 + * @param {string} fallback 默认中文兜底文案 + * @returns {string} 中文错误提示 + */ +function normalizeErrorMessage(raw, fallback = '网络请求失败,请稍后重试') { + const text = typeof raw === 'string' ? raw.trim() : '' + if (!text) return fallback + + const lower = text.toLowerCase() + if (lower.includes('timeout') || lower.includes('timed out')) { + return '网络请求超时,请稍后重试' + } + if (lower.includes('domain list')) { + return '服务域名配置异常,请联系管理员' + } + if (lower.includes('ssl') || lower.includes('certificate')) { + return '安全连接异常,请稍后重试' + } + if (lower.startsWith('request:fail') || lower.includes('network error') || lower.includes('failed to fetch')) { + return '网络连接失败,请检查网络后重试' + } + + // 若包含中文且不含常见底层技术报错特征,直接展示 + if (/[\u4e00-\u9fa5]/.test(text) && !/sqlstate|curl error|exception/i.test(text)) { + return text + } + + return fallback +} + /** * 失败处理:抛出异常(必要时弹 toast 提示) * @param {Object} err 错误对象 @@ -160,7 +193,8 @@ export function request(options = {}) { */ function handleFail(err, ctx) { const { silent, runtime, reject } = ctx - const e = toErr(err && (err.errMsg || err.message) ? err.errMsg || err.message : '网络请求失败') + const rawMsg = err && (err.errMsg || err.message) ? err.errMsg || err.message : '' + const e = toErr(normalizeErrorMessage(rawMsg, '网络请求失败,请检查网络后重试')) if (!silent) runtime.showToast({ title: e.message, icon: 'none' }) reject(e) } diff --git a/uniapp/components/fc-area-picker/fc-area-picker.vue b/uniapp/components/fc-area-picker/fc-area-picker.vue index 1f4d6fb..739d3f5 100644 --- a/uniapp/components/fc-area-picker/fc-area-picker.vue +++ b/uniapp/components/fc-area-picker/fc-area-picker.vue @@ -30,6 +30,7 @@ import { groupAreaTree } from '@/common/utils/area.js' */ export default { name: 'FcAreaPicker', + emits: ['change'], props: { // 平铺服务区域:[{ id, province, city, district }] areas: { type: Array, default: () => [] }, diff --git a/uniapp/components/fc-report-modal/fc-report-modal.vue b/uniapp/components/fc-report-modal/fc-report-modal.vue index 03d87c2..a41ac2f 100644 --- a/uniapp/components/fc-report-modal/fc-report-modal.vue +++ b/uniapp/components/fc-report-modal/fc-report-modal.vue @@ -349,6 +349,7 @@ export default { .report-modal__panel { width: 100%; max-height: 85vh; + overflow: hidden; background: #ffffff; border-radius: 36rpx 36rpx 0 0; box-shadow: 0 -8rpx 36rpx rgba(15, 23, 42, 0.12); @@ -361,6 +362,7 @@ export default { } .report-modal__handle-bar { + flex-shrink: 0; width: 72rpx; height: 8rpx; background: #e2e8f0; @@ -369,6 +371,7 @@ export default { } .report-modal__header { + flex-shrink: 0; display: flex; align-items: flex-start; justify-content: space-between; @@ -437,9 +440,11 @@ export default { .report-modal__scroll { flex: 1; - max-height: 58vh; + min-height: 0; + max-height: 50vh; padding: 0 32rpx; box-sizing: border-box; + overflow-y: auto; } .report-modal__section { @@ -644,6 +649,7 @@ export default { } .report-modal__footer { + flex-shrink: 0; padding: 18rpx 32rpx 20rpx; background: #ffffff; border-top: 1rpx solid #f1f5f9; diff --git a/uniapp/pages.json b/uniapp/pages.json index dd7b861..9c2a0ce 100644 --- a/uniapp/pages.json +++ b/uniapp/pages.json @@ -224,6 +224,15 @@ "backgroundColor": "#f2fef7" } }, + { + "path": "pages/mine/report-detail", + "style": { + "navigationBarTitleText": "举报详情", + "navigationStyle": "custom", + "enablePullDownRefresh": true, + "backgroundColor": "#f2fef7" + } + }, { "path": "pages/order/detail", "style": { diff --git a/uniapp/pages/detail/detail.vue b/uniapp/pages/detail/detail.vue index 3bd36dd..73a98d3 100644 --- a/uniapp/pages/detail/detail.vue +++ b/uniapp/pages/detail/detail.vue @@ -372,7 +372,10 @@ - {{ c.user }} + + {{ c.user }} + 已隐藏(仅自己可见) + {{ c.reply ? '修改回复' : '回复' }} - + + 删除 + + 举报 @@ -1412,6 +1418,30 @@ export default { this.reportTargetTitle = comment.content || '用户评价' this.reportModalVisible = true }, + /** + * 删除自己发表的评价 + * @param {Object} comment 评价对象 + */ + onDeleteComment(comment) { + if (!comment || !comment.id) return + if (!this.ensureLogin()) return + uni.showModal({ + title: '删除评价', + content: '确认删除这条评价?删除后不可恢复。', + confirmText: '删除', + confirmColor: '#EF4444', + success: async (res) => { + if (!res.confirm) return + try { + await postApi.deleteComment(comment.id) + this.comments = this.comments.filter((item) => item.id !== comment.id) + uni.showToast({ title: '已删除', icon: 'success' }) + } catch (e) { + uni.showToast({ title: (e && e.message) || '删除失败', icon: 'none' }) + } + }, + }) + }, /** * 举报成功后回调处理 * @param {Object} payload 提交的举报载荷 @@ -2845,11 +2875,26 @@ export default { align-items: center; justify-content: space-between; } +.detail__cmt-user-wrap { + display: flex; + align-items: center; + gap: 12rpx; + flex: 1; + min-width: 0; +} .detail__cmt-user { font-size: $fc-font; font-weight: 600; color: $fc-text; } +.detail__cmt-hidden-tag { + font-size: 20rpx; + color: #D97706; + background: #FEF3C7; + padding: 2rpx 10rpx; + border-radius: 6rpx; + flex-shrink: 0; +} .detail__cmt-score { display: flex; align-items: center; @@ -2905,6 +2950,10 @@ export default { color: $fc-text-secondary; } } +.detail__cmt-del-text { + font-size: $fc-font-xs; + color: #EF4444; +} .detail__cmt-action-btn { display: inline-flex; align-items: center; diff --git a/uniapp/pages/mine/report-detail.vue b/uniapp/pages/mine/report-detail.vue new file mode 100644 index 0000000..5fc0a4b --- /dev/null +++ b/uniapp/pages/mine/report-detail.vue @@ -0,0 +1,688 @@ + + + + + diff --git a/uniapp/pages/mine/reports.vue b/uniapp/pages/mine/reports.vue index 77d4cb9..e664869 100644 --- a/uniapp/pages/mine/reports.vue +++ b/uniapp/pages/mine/reports.vue @@ -3,6 +3,19 @@ + + + + {{ tab.label }} + + + @@ -12,15 +25,20 @@ - - + + @@ -28,57 +46,65 @@ {{ item.reason }} - - {{ item.statusText }} - + + {{ item.statusText }} + - - + + {{ item.targetTitle }} - › + + 原信息 + › + - + - 补充说明: - {{ item.detail }} + 说明: + {{ item.detail }} - + - - - - - 提交时间:{{ item.createdAt }} - - - - - - - 平台处理反馈 - {{ item.updatedAt }} + + +{{ item.images.length - 3 }} - - {{ item.handleRemark ? item.handleRemark : '平台已核实并对违规行为进行了严肃处置,感谢您对维护社区健康环境的支持!' }} + + + + + + + {{ item.handleRemark || '平台已核实并完成处置' }} + + + + {{ formatTime(item.createdAt) }} + + 查看详情 + › + + @@ -95,14 +121,20 @@ import FcNavbar from '@/components/fc-navbar/fc-navbar.vue' import FcEmpty from '@/components/fc-empty/fc-empty.vue' import reportApi from '@/common/api/report.js' -import { safeNavigateTo, safeNavigateBack, safeBack } from '@/common/utils/nav.js' +import { safeNavigateTo, safeBack } from '@/common/utils/nav.js' import { iconUrl } from '@/common/store/ui.js' -import { assetUrl } from '@/common/utils/format.js' +import { assetUrl, formatTime } from '@/common/utils/format.js' export default { components: { FcNavbar, FcEmpty }, data() { return { + tabs: [ + { label: '全部', value: '' }, + { label: '核实中', value: 'pending' }, + { label: '已处理', value: 'handled' }, + ], + activeStatus: '', list: [], page: 1, size: 10, @@ -111,6 +143,17 @@ export default { loading: false, } }, + computed: { + /** + * 根据当前筛选状态返回空状态提示文案 + * @returns {string} + */ + emptyText() { + if (this.activeStatus === 'pending') return '暂无核实中的举报' + if (this.activeStatus === 'handled') return '暂无已处理的举报' + return '暂无举报记录' + }, + }, /** * 页面加载生命周期 */ @@ -134,6 +177,16 @@ export default { methods: { iconUrl, assetUrl, + formatTime, + /** + * 切换顶部状态筛选标签 + * @param {string} status 状态值 + */ + switchTab(status) { + if (this.activeStatus === status) return + this.activeStatus = status + this.fetchList(true) + }, /** * 拉取我的举报列表数据 * @param {boolean} [reset=false] 是否重置为第一页 @@ -146,7 +199,11 @@ export default { if (this.loading) return this.loading = true try { - const res = await reportApi.my({ page: this.page, size: this.size }) + const params = { page: this.page, size: this.size } + if (this.activeStatus) { + params.status = this.activeStatus + } + const res = await reportApi.my(params) const rows = (res && res.list) || [] this.total = (res && res.total) || 0 this.list = reset ? rows : [...this.list, ...rows] @@ -166,6 +223,19 @@ export default { this.page += 1 this.fetchList(false) }, + /** + * 判断是否支持直接跳转到被举报原信息 + * @param {Object} item 举报项对象 + * @returns {boolean} + */ + canJumpTarget(item) { + return !!( + item && + item.targetType === 'post' && + item.targetId > 0 && + item.targetExists !== false + ) + }, /** * 预览凭证图片 * @param {string[]} images 图片数组 @@ -179,14 +249,24 @@ export default { current: fullUrls[current] || fullUrls[0], }) }, + /** + * 跳转至举报记录详情页 + * @param {Object} item 举报项对象 + */ + goReportDetail(item) { + if (!item || !item.id) return + safeNavigateTo(`/pages/mine/report-detail?id=${item.id}`) + }, /** * 点击被举报对象(如果是信息且未删除,可跳转查看) * @param {Object} item 举报项对象 */ handleTargetClick(item) { - if (item.targetType === 'post' && item.targetId > 0) { + if (this.canJumpTarget(item)) { safeNavigateTo(`/pages/detail/detail?id=${item.targetId}`) + return } + this.goReportDetail(item) }, /** * 返回上一页 @@ -215,24 +295,53 @@ export default { } &__list { - padding: 24rpx; + padding: 20rpx 24rpx 24rpx; } &__more { text-align: center; - padding: 30rpx 0 10rpx; + padding: 24rpx 0 10rpx; font-size: $fc-font-xs; color: $fc-text-placeholder; } } +.report-tabs { + display: flex; + align-items: center; + gap: 16rpx; + padding: 16rpx 24rpx 4rpx; + + &__item { + padding: 10rpx 26rpx; + border-radius: 999rpx; + font-size: $fc-font-sm; + color: #64748B; + background: rgba(255, 255, 255, 0.85); + border: 1rpx solid #E2E8F0; + transition: all 0.2s; + + &--active { + background: #00D26A; + color: #FFFFFF; + border-color: #00D26A; + font-weight: 600; + box-shadow: 0 4rpx 12rpx rgba(0, 210, 106, 0.22); + } + } +} + .report-card { - background: #ffffff; + background: #FFFFFF; border-radius: $fc-radius; padding: 24rpx; - margin-bottom: 24rpx; + margin-bottom: 20rpx; box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.03); + &:active { + transform: scale(0.992); + } + &__header { display: flex; align-items: center; @@ -243,7 +352,8 @@ export default { &__tags { display: flex; align-items: center; - gap: 12rpx; + gap: 10rpx; + flex-wrap: wrap; } &__type-tag { @@ -269,15 +379,37 @@ export default { } &__status { - font-size: 24rpx; + display: inline-flex; + align-items: center; + gap: 8rpx; + padding: 4rpx 14rpx; + border-radius: 999rpx; + font-size: 22rpx; font-weight: 600; + flex-shrink: 0; + + &-dot { + width: 10rpx; + height: 10rpx; + border-radius: 50%; + } &--pending { - color: #F59E0B; + background: #FEF3C7; + color: #D97706; + + .report-card__status-dot { + background: #F59E0B; + } } &--handled { + background: #E8F9F0; color: #00A854; + + .report-card__status-dot { + background: #00D26A; + } } } @@ -285,91 +417,128 @@ export default { display: flex; align-items: center; justify-content: space-between; + gap: 16rpx; background: #F8FAFC; border-radius: 10rpx; - padding: 16rpx 20rpx; - margin-bottom: 16rpx; + padding: 16rpx 18rpx; + margin-bottom: 14rpx; + + &--link:active { + background: #F1F5F9; + } &-title { font-size: $fc-font; font-weight: 500; color: #1E293B; - line-height: 1.4; + line-height: 1.45; flex: 1; } + &-link { + display: flex; + align-items: center; + flex-shrink: 0; + font-size: $fc-font-xs; + color: #00A854; + font-weight: 500; + } + &-arrow { - font-size: 32rpx; - color: #94A3B8; - margin-left: 12rpx; + font-size: 28rpx; + margin-left: 4rpx; + line-height: 1; } } &__detail { - margin-bottom: 16rpx; + display: flex; + align-items: center; + margin-bottom: 14rpx; font-size: $fc-font-sm; - line-height: 1.5; + line-height: 1.4; &-label { color: #64748B; + flex-shrink: 0; } &-text { color: #334155; + flex: 1; + min-width: 0; } } &__images { display: flex; - flex-wrap: wrap; + align-items: center; gap: 12rpx; - margin-bottom: 16rpx; + margin-bottom: 14rpx; } &__img { - width: 140rpx; - height: 140rpx; + width: 104rpx; + height: 104rpx; border-radius: 8rpx; background: #E2E8F0; } + &__img-more { + width: 104rpx; + height: 104rpx; + border-radius: 8rpx; + background: #F1F5F9; + color: #64748B; + font-size: $fc-font-sm; + font-weight: 600; + display: flex; + align-items: center; + justify-content: center; + } + + &__result { + display: flex; + align-items: center; + gap: 10rpx; + padding: 12rpx 16rpx; + margin-bottom: 14rpx; + background: #F2FEF7; + border-radius: 8rpx; + border-left: 4rpx solid #00D26A; + + &-text { + flex: 1; + min-width: 0; + font-size: $fc-font-xs; + color: #00A854; + } + } + + &__footer { + display: flex; + align-items: center; + justify-content: space-between; + padding-top: 12rpx; + border-top: 1rpx solid #F1F5F9; + } + &__time { font-size: $fc-font-xs; color: $fc-text-placeholder; - margin-bottom: 12rpx; } - &__result { - margin-top: 16rpx; - padding: 20rpx; - background: #F2FEF7; - border-radius: 12rpx; - border-left: 6rpx solid #00D26A; + &__more { + display: flex; + align-items: center; + font-size: $fc-font-xs; + color: #00A854; + font-weight: 600; - &-head { - display: flex; - align-items: center; - gap: 8rpx; - margin-bottom: 8rpx; - } - - &-title { - font-size: $fc-font-sm; - font-weight: 600; - color: #00A854; - flex: 1; - } - - &-time { - font-size: 20rpx; - color: #94A3B8; - } - - &-content { - display: block; - font-size: $fc-font-sm; - color: #334155; - line-height: 1.5; + &-arrow { + font-size: 28rpx; + margin-left: 4rpx; + line-height: 1; } } } diff --git a/uniapp/pages/post/create.vue b/uniapp/pages/post/create.vue index 8104d58..ed7b2d9 100644 --- a/uniapp/pages/post/create.vue +++ b/uniapp/pages/post/create.vue @@ -1773,8 +1773,13 @@ export default { }, }) }, - /** 级联选择器选中服务区域 */ + /** + * 级联选择器选中服务区域 + * @param {Object|null} area + */ onRegionPicked(area) { + // 防御:忽略根元素原生 picker 透传的无 areaId 事件对象 + if (area && area.detail && area.areaId === undefined) return this.form.areaId = area ? Number(area.areaId) || 0 : 0 this.form.area = area ? area.district || '' : '' this.form.province = area ? area.province || '' : ''
' + item.date + '' + escapeHtml(item.date) + '' + (item.posts || 0) + '' + orderStr + '' + formatNum(item.orders || 0, true) + '' + (item.users || 0) + '' + (item.views || 0) + '