feat: 后端补齐前端所需模块 + 后台登录页品牌化重构

后端(补齐前端已入口但无接口的模块):
- Coupon 控制器:center 领券中心 / my 我的券(未使用·已使用·已过期+计数)/ receive 领取
  含库存与过期校验、重复领取拦截、领券后自动发消息
- Message 控制器:index 列表(分类筛选)/ read 单条已读 / readAll 全部已读 / unread 角标
  支持 user 与 master 两种归属

前端(对应页面,全部接真接口):
- pages/address/list  服务地址:列表 / 新增·编辑弹层 / 设为默认 / 删除
- pages/coupon/coupon 领券中心 + 我的券(双 Tab + 状态筛选 + 计数)
- pages/message/message 消息中心:分类 / 未读圆点 / 点开自动已读 / 全部已读 / 跳订单
- mine.vue 三个入口(地址·优惠券·消息)由「开发中」改为真实路由
- merchant/workbench 服务地址入口接真实路由
- 首页 TabBar「消息」接入消息中心
- api.js 新增 coupon/message 共 7 个接口

后台登录页(UI 与前端主色调统一):
- 左侧橙金渐变品牌区:logo 徽标 + 「优匠优服」立体字 + slogan + 460万+/99.9%/1762万 平台实力 + 保障条
- 右侧白色登录卡:橙色渐变按钮、圆角输入框、错误提示条
- 保留 FastAdmin 全部挂钩(token/验证码/keeplogin/@AdminLoginFormBegin 等 14 项)

验证:5 套用例 178 项断言全通过(47+65+27+24+15),配置自检 8/8
这个提交包含在:
linda
2026-10-28 16:51:45 +08:00
父节点 2af4cf72b5
当前提交 4734724ed2
共有 12 个文件被更改,包括 890 次插入 和 125 次删除

251
server/application/admin/view/index/login.html 可执行文件 -> 普通文件
查看文件

@@ -4,139 +4,148 @@
{include file="common/meta" /}
<style type="text/css">
body {
color: #999;
background-color: #f1f4fd;
background-size: cover;
* { box-sizing: border-box; }
body { margin: 0; color: #333; background: #FFF7F0;
font-family: -apple-system, "PingFang SC", "Microsoft YaHei", Arial, sans-serif; }
a { color: #E36B0C; }
.login-page { min-height: 100vh; display: flex; }
/* ---------- 左侧品牌区 ---------- */
.brand { position: relative; width: 54%; min-height: 100vh; overflow: hidden; color: #fff;
padding: 0 72px; display: flex; flex-direction: column; justify-content: center;
background: linear-gradient(160deg, #FFB85C 0%, #F98D25 46%, #ED6F0E 100%); }
.brand .deco { position: absolute; border-radius: 50%; background: rgba(255,255,255,.13); }
.brand .d1 { width: 520px; height: 520px; right: -180px; top: -200px; }
.brand .d2 { width: 320px; height: 320px; left: -120px; bottom: -120px; background: rgba(255,255,255,.10); }
.brand .d3 { width: 160px; height: 160px; right: 90px; bottom: 90px; background: rgba(255,255,255,.08); }
.logo-mark { position: relative; width: 64px; height: 64px; border-radius: 18px;
background: rgba(255,255,255,.94); color: #EE7412; font-size: 34px; font-weight: 800;
display: flex; align-items: center; justify-content: center;
box-shadow: 0 10px 24px rgba(170,70,10,.22); }
.wordmark { position: relative; margin-top: 30px; font-size: 60px; font-weight: 800;
letter-spacing: 10px; line-height: 1.1; color: #fff;
text-shadow: 0 2px 0 #E9721A, 0 5px 0 #D9630E, 0 10px 24px rgba(150,60,0,.35); }
.slogan { position: relative; margin-top: 18px; font-size: 17px;
letter-spacing: 4px; color: rgba(255,255,255,.92); }
.stats { position: relative; display: flex; margin-top: 54px; }
.stat { margin-right: 56px; }
.stat b { display: block; font-size: 30px; font-weight: 800; letter-spacing: 1px; }
.stat span { display: block; margin-top: 6px; font-size: 13px; color: rgba(255,255,255,.85); letter-spacing: 1px; }
.brand-tip { position: relative; margin-top: 46px; font-size: 13px;
color: rgba(255,255,255,.82); letter-spacing: 1px; }
/* ---------- 右侧表单区 ---------- */
.panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-screen { width: 100%; max-width: 380px; }
.login-screen .well { padding: 40px 34px 32px; background: #fff; border: none; border-radius: 20px;
box-shadow: 0 18px 48px rgba(226,120,26,.16); }
.panel-title { margin: 0 0 6px; font-size: 24px; font-weight: 700; color: #1F1F1F; }
.panel-sub { margin: 0 0 26px; font-size: 13px; color: #9A9A9A; }
#login-form .input-group { display: flex; margin-bottom: 16px; }
#login-form .input-group-addon { width: 46px; flex: none; background: #FFF7F0;
border: 1px solid #F2E3D6; border-right: none; border-radius: 12px 0 0 12px;
color: #E07A2E; display: flex; align-items: center; justify-content: center; }
#login-form .form-control { flex: 1; height: 46px; padding: 0 14px; font-size: 14px;
border: 1px solid #F2E3D6; border-radius: 0 12px 12px 0; box-shadow: none; }
#login-form .input-group .form-control:not(:last-child) { border-radius: 0; }
#login-form .form-control:focus { border-color: #F5861F; outline: none; }
#login-form .btn-submit { width: 100%; height: 48px; margin-top: 6px; border: none; border-radius: 24px;
color: #fff; font-size: 16px; font-weight: 700; letter-spacing: 2px; cursor: pointer;
background: linear-gradient(135deg, #FFA93F 0%, #F0710D 100%);
box-shadow: 0 10px 22px rgba(240,113,13,.32); }
#login-form .btn-submit:hover { filter: brightness(1.04); }
#login-form .checkbox { margin: 2px 0 16px; color: #8A8A8A; font-size: 13px; }
#errtips { margin-bottom: 14px; padding: 10px 14px; border-radius: 10px;
background: #FFF1EF; color: #E8331B; font-size: 13px; }
.foot { margin-top: 22px; text-align: center; font-size: 12px; color: #B9B9B9; line-height: 20px; }
#profile-img, #profile-name { display: none !important; }
@media (max-width: 900px) {
.login-page { flex-direction: column; }
.brand { width: 100%; min-height: auto; padding: 40px 28px 34px; }
.wordmark { margin-top: 18px; font-size: 38px; letter-spacing: 6px; }
.stats { margin-top: 26px; }
.stat { margin-right: 30px; }
.stat b { font-size: 22px; }
.brand-tip { margin-top: 24px; }
.panel { padding: 26px 20px 40px; }
}
a {
color: #444;
}
.login-screen {
max-width: 430px;
padding: 0;
margin: 100px auto 0 auto;
}
.login-screen .well {
border-radius: 3px;
-webkit-box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
background: rgba(255, 255, 255, 1);
border: none;
/*overflow: hidden;*/
padding: 0;
}
@media (max-width: 767px) {
.login-screen {
padding: 0 20px;
}
}
.profile-img-card {
width: 100px;
height: 100px;
display: block;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
margin: -93px auto 30px;
border: 5px solid #fff;
}
.profile-name-card {
text-align: center;
}
.login-head {
background: #899fe1;
border-radius: 3px 3px 0 0;
}
.login-form {
padding: 40px 30px;
position: relative;
z-index: 99;
}
#login-form {
margin-top: 20px;
}
#login-form .input-group {
margin-bottom: 15px;
}
#login-form .form-control {
font-size: 13px;
}
</style>
<!--@formatter:off-->
{if $background}
<style type="text/css">
body{
background-image: url('{$background|htmlentities}');
}
</style>
<style type="text/css">
.brand { background-image: url('{$background|htmlentities}'); background-size: cover; background-position: center; }
</style>
{/if}
<!--@formatter:on-->
</head>
<body>
<div class="container">
<div class="login-wrapper">
<div class="login-page">
<!-- 左侧:品牌 + 平台实力 -->
<div class="brand">
<div class="deco d1"></div>
<div class="deco d2"></div>
<div class="deco d3"></div>
<div class="logo-mark">优</div>
<div class="wordmark">优匠优服</div>
<div class="slogan">专业师傅 · 上门到家</div>
<div class="stats">
<div class="stat"><b>460万+</b><span>专业师傅</span></div>
<div class="stat"><b>99.9%</b><span>区域覆盖到村镇</span></div>
<div class="stat"><b>1762万</b><span>成功订单</span></div>
</div>
<div class="brand-tip">平台认证 · 先行赔付 · 极速上门 · 售后无忧</div>
</div>
<!-- 右侧:登录表单 -->
<div class="panel">
<div class="login-screen">
<div class="well">
<div class="login-head">
<img src="__CDN__/assets/img/login-head.png" style="width:100%;"/>
</div>
<div class="login-form">
<img id="profile-img" class="profile-img-card" src="__CDN__/assets/img/avatar.png"/>
<p id="profile-name" class="profile-name-card"></p>
<p class="panel-title">平台管理后台</p>
<p class="panel-sub">请使用管理员账号登录</p>
<form action="" method="post" id="login-form">
<!--@AdminLoginFormBegin-->
<div id="errtips" class="hide"></div>
{:token()}
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-user" aria-hidden="true"></span></div>
<input type="text" class="form-control" id="pd-form-username" placeholder="{:__('Username')}" name="username" autocomplete="off" value="" data-rule="{:__('Username')}:required;username"/>
</div>
<img id="profile-img" class="profile-img-card" src="__CDN__/assets/img/avatar.png"/>
<p id="profile-name" class="profile-name-card"></p>
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span></div>
<input type="password" class="form-control" id="pd-form-password" placeholder="{:__('Password')}" name="password" autocomplete="off" value="" data-rule="{:__('Password')}:required;password"/>
</div>
<!--@CaptchaBegin-->
{if $Think.config.fastadmin.login_captcha}
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></div>
<input type="text" name="captcha" class="form-control" placeholder="{:__('Captcha')}" data-rule="{:__('Captcha')}:required;length({$Think.config.captcha.length|htmlentities})" autocomplete="off"/>
<span class="input-group-addon" style="padding:0;border:none;cursor:pointer;">
<img src="{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha" width="100" height="30" onclick="this.src = '{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha&r=' + Math.random();"/>
</span>
</div>
{/if}
<!--@CaptchaEnd-->
{if $keeyloginhours>0}
<div class="form-group checkbox">
<label class="inline" for="keeplogin" data-toggle="tooltip" title="{:__('The duration of the session is %s hours', $keeyloginhours)}">
<input type="checkbox" name="keeplogin" id="keeplogin" value="1"/>
{:__('Keep login')}
</label>
</div>
{/if}
<div class="form-group">
<button type="submit" class="btn btn-success btn-lg btn-block" style="background:#708eea;">{:__('Sign in')}</button>
</div>
<!--@AdminLoginFormEnd-->
</form>
</div>
<form action="" method="post" id="login-form">
<!--@AdminLoginFormBegin-->
<div id="errtips" class="hide"></div>
{:token()}
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-user" aria-hidden="true"></span></div>
<input type="text" class="form-control" id="pd-form-username" placeholder="{:__('Username')}" name="username" autocomplete="off" value="" data-rule="{:__('Username')}:required;username"/>
</div>
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span></div>
<input type="password" class="form-control" id="pd-form-password" placeholder="{:__('Password')}" name="password" autocomplete="off" value="" data-rule="{:__('Password')}:required;password"/>
</div>
<!--@CaptchaBegin-->
{if $Think.config.fastadmin.login_captcha}
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></div>
<input type="text" name="captcha" class="form-control" placeholder="{:__('Captcha')}" data-rule="{:__('Captcha')}:required;length({$Think.config.captcha.length|htmlentities})" autocomplete="off"/>
<span class="input-group-addon" style="width:106px;border:1px solid #F2E3D6;border-left:none;border-radius:0 12px 12px 0;background:#fff;padding:0;cursor:pointer;">
<img src="{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha" width="100" height="30" onclick="this.src = '{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha&r=' + Math.random();"/>
</span>
</div>
{/if}
<!--@CaptchaEnd-->
{if $keeyloginhours>0}
<div class="form-group checkbox">
<label class="inline" for="keeplogin" data-toggle="tooltip" title="{:__('The duration of the session is %s hours', $keeyloginhours)}">
<input type="checkbox" name="keeplogin" id="keeplogin" value="1"/>
{:__('Keep login')}
</label>
</div>
{/if}
<button type="submit" class="btn-submit">{:__('Sign in')}</button>
<!--@AdminLoginFormEnd-->
</form>
<div class="foot">优匠优服 · 让手艺人有活干,让家有温度<br/>© {:date('Y')} 优匠优服 平台管理后台</div>
</div>
</div>
</div>

查看文件

@@ -0,0 +1,133 @@
<?php
namespace app\api\controller;
use think\Db;
/**
* 优惠券:领券中心 / 我的券 / 领取
*/
class Coupon extends Base
{
/**
* 领券中心(可领取的券)
*/
public function center()
{
$uid = $this->uid();
$now = time();
$list = Db::name('coupon')
->where('status', 'normal')
->where(function ($q) use ($now) {
$q->where('end_time', 0)->whereOr('end_time', '>', $now);
})
->order('amount desc,id desc')
->select();
$receivedIds = Db::name('user_coupon')->where('user_id', $uid)->column('coupon_id');
foreach ($list as &$row) {
$row['amount'] = (float)$row['amount'];
$row['min_amount'] = (float)$row['min_amount'];
$row['discount'] = (float)$row['discount'];
$row['total'] = (int)$row['total'];
$row['received'] = (int)$row['received'];
$row['received_by_me'] = in_array((int)$row['id'], array_map('intval', $receivedIds), true);
$row['sold_out'] = $row['total'] > 0 && $row['received'] >= $row['total'];
$row['time_text'] = (int)$row['end_time'] > 0 ? date('Y.m.d', (int)$row['end_time']) . ' 到期' : '长期有效';
$row['value_text'] = $row['type'] === 'cash'
? ('¥' . (float)$row['amount'])
: (rtrim(rtrim(number_format((float)$row['discount'] * 10, 1, '.', ''), '0'), '.') . ' 折');
$row['rule_text'] = $row['min_amount'] > 0 ? ('满 ¥' . (float)$row['min_amount'] . ' 可用') : '无门槛';
}
unset($row);
$this->success('', ['list' => $list]);
}
/**
* 我的优惠券
* @ApiParams (name="status", type="string", required=false, description="unused|used|expired")
*/
public function my()
{
$status = $this->request->param('status', 'unused');
if (!in_array($status, ['unused', 'used', 'expired'], true)) {
$status = 'unused';
}
$uid = $this->uid();
$now = time();
$list = Db::name('user_coupon')->alias('uc')
->join('coupon c', 'c.id = uc.coupon_id', 'LEFT')
->field('uc.id,uc.status,uc.use_time,uc.createtime,c.name,c.type,c.amount,c.discount,c.min_amount,c.end_time')
->where('uc.user_id', $uid)
->where('uc.status', $status)
->order('uc.id desc')
->select();
$counts = ['unused' => 0, 'used' => 0, 'expired' => 0];
$all = Db::name('user_coupon')->where('user_id', $uid)->field('status,count(*) as c')->group('status')->select();
foreach ($all as $r) {
$counts[$r['status']] = (int)$r['c'];
}
foreach ($list as &$row) {
$row['amount'] = (float)$row['amount'];
$row['min_amount'] = (float)$row['min_amount'];
$row['discount'] = (float)$row['discount'];
$row['value_text'] = $row['type'] === 'cash'
? ('¥' . (float)$row['amount'])
: (rtrim(rtrim(number_format((float)$row['discount'] * 10, 1, '.', ''), '0'), '.') . ' 折');
$row['rule_text'] = $row['min_amount'] > 0 ? ('满 ¥' . (float)$row['min_amount'] . ' 可用') : '无门槛';
$row['time_text'] = (int)$row['end_time'] > 0 ? ('有效期至 ' . date('Y.m.d', (int)$row['end_time'])) : '长期有效';
$row['expired'] = (int)$row['end_time'] > 0 && (int)$row['end_time'] < $now;
}
unset($row);
$this->success('', ['list' => $list, 'counts' => $counts]);
}
/**
* 领取优惠券
* @ApiMethod (POST)
*/
public function receive()
{
$couponId = (int)$this->request->post('coupon_id');
$coupon = Db::name('coupon')->where('id', $couponId)->where('status', 'normal')->find();
if (!$coupon) {
$this->error('优惠券不存在或已下架');
}
if ((int)$coupon['end_time'] > 0 && (int)$coupon['end_time'] < time()) {
$this->error('优惠券已过期');
}
if ((int)$coupon['total'] > 0 && (int)$coupon['received'] >= (int)$coupon['total']) {
$this->error('优惠券已被领完');
}
$has = Db::name('user_coupon')->where('user_id', $this->uid())->where('coupon_id', $couponId)->find();
if ($has) {
$this->error('您已领取过该优惠券');
}
Db::startTrans();
try {
Db::name('user_coupon')->insert([
'user_id' => $this->uid(),
'coupon_id' => $couponId,
'status' => 'unused',
'createtime' => time(),
]);
Db::name('coupon')->where('id', $couponId)->setInc('received');
Db::commit();
} catch (\Exception $e) {
Db::rollback();
$this->error('领取失败:' . $e->getMessage());
}
$this->notify('user', $this->uid(), '优惠券领取成功', '「' . $coupon['name'] . '」已放入我的优惠券', 'system', 0);
$this->success('领取成功');
}
}

查看文件

@@ -0,0 +1,114 @@
<?php
namespace app\api\controller;
use think\Db;
/**
* 消息中心(用户 / 师傅共用)
*/
class Message extends Base
{
/**
* 消息列表
* @ApiParams (name="type", type="string", required=false, description="user|master,默认 user")
* @ApiParams (name="category", type="string", required=false, description="all|order|system|audit|remind")
*/
public function index()
{
$type = $this->request->param('type', 'user');
$type = $type === 'master' ? 'master' : 'user';
$category = $this->request->param('category', 'all');
$page = max(1, (int)$this->request->param('page', 1));
$limit = min(50, max(1, (int)$this->request->param('limit', 20)));
$receiveId = $this->receiveId($type);
$build = function () use ($type, $receiveId, $category) {
$q = Db::name('message')->where('receive_type', $type)->where('receive_id', $receiveId);
if ($category !== 'all' && $category !== '') {
$q->where('type', $category);
}
return $q;
};
$total = $build()->count();
$list = $build()->order('id desc')->page($page, $limit)->select();
foreach ($list as &$row) {
$row['time_text'] = date('m-d H:i', (int)$row['createtime']);
$row['is_read'] = (int)$row['is_read'];
}
unset($row);
$this->success('', [
'list' => $list,
'total' => (int)$total,
'unread' => $this->unreadCount($type, $receiveId),
'page' => $page,
]);
}
/**
* 标记单条已读
* @ApiMethod (POST)
*/
public function read()
{
$id = (int)$this->request->post('id');
$type = $this->request->post('type', 'user') === 'master' ? 'master' : 'user';
$receiveId = $this->receiveId($type);
$row = Db::name('message')->where('id', $id)->where('receive_type', $type)->where('receive_id', $receiveId)->find();
if (!$row) {
$this->error('消息不存在');
}
Db::name('message')->where('id', $id)->update(['is_read' => 1]);
$this->success('已读');
}
/**
* 全部标记已读
* @ApiMethod (POST)
*/
public function readAll()
{
$type = $this->request->post('type', 'user') === 'master' ? 'master' : 'user';
$receiveId = $this->receiveId($type);
$affected = Db::name('message')
->where('receive_type', $type)->where('receive_id', $receiveId)->where('is_read', 0)
->update(['is_read' => 1]);
$this->success('已全部标记为已读', ['count' => (int)$affected]);
}
/**
* 未读数(供 Tab 角标)
*/
public function unread()
{
$type = $this->request->param('type', 'user') === 'master' ? 'master' : 'user';
$this->success('', ['unread' => $this->unreadCount($type, $this->receiveId($type))]);
}
/**
* 消息归属ID:用户=uid,师傅=master.id
*/
protected function receiveId($type)
{
if ($type === 'master') {
$master = $this->masterInfo();
return $master ? (int)$master['id'] : 0;
}
return $this->uid();
}
protected function unreadCount($type, $receiveId)
{
if (!$receiveId) {
return 0;
}
return (int)Db::name('message')
->where('receive_type', $type)->where('receive_id', $receiveId)->where('is_read', 0)
->count();
}
}