feat: 新增大量服务类图标及相关接口配置

- 新增20+家电维修类图标(电视、空调、冰箱等)
- 新增短信发送、微信手机号登录接口
- 新增服务规格查询接口
- 更新后台配置与菜单结构
- 移除支付插件相关配置
这个提交包含在:
YuanWen
2026-11-03 11:19:24 +08:00
父节点 9ae2b976a8
当前提交 c01e8fc7d9
共有 79 个文件被更改,包括 5934 次插入 和 1921 次删除

查看文件

@@ -11,7 +11,7 @@ use think\Validate;
*/
class Auth extends Base
{
protected $noNeedLogin = ['login', 'wxlogin'];
protected $noNeedLogin = ['login', 'wxlogin', 'wxPhoneLogin'];
/**
* 手机号 + 验证码登录(兜底通道)
@@ -21,8 +21,64 @@ class Auth extends Base
*/
public function login()
{
$mobile = $this->request->post('mobile');
$code = $this->request->post('code');
$mobile = trim((string)$this->request->post('mobile', $this->request->post('account', '')));
$mobile = preg_replace('/[^\d]/', '', $mobile);
$password = (string)$this->request->post('password', '');
$code = trim((string)$this->request->post('code', ''));
// 1. 手机号 + 密码登录(直连真实数据库)
if ($password !== '' || ($mobile !== '' && $code === '')) {
if ($mobile === '') {
$this->error('请填写手机号');
}
if (!preg_match('/^1[3-9]\d{9}$/', $mobile)) {
$this->error('手机号格式不正确');
}
if ($password === '') {
$this->error('请填写登录密码');
}
// 直接查询真实数据库 fa_user 表
$user = Db::name('user')->where('mobile', $mobile)->find();
if (!$user) {
// 若数据库中无此手机号:直连数据库插入注册新会员
$ret = $this->auth->register($mobile, $password, '', $mobile, []);
if (!$ret) {
$this->error($this->auth->getError() ?: '注册登录失败');
}
} else {
if ($user['status'] !== 'normal') {
$this->error('账号已被禁用');
}
// 若微信手机号快捷登录初始化的用户未设密码,直接落库更新密码
if (empty($user['password'])) {
$salt = Random::alnum();
$encryptPassword = $this->auth->getEncryptPassword($password, $salt);
Db::name('user')->where('id', $user['id'])->update([
'password' => $encryptPassword,
'salt' => $salt,
'updatetime' => time(),
]);
$this->auth->direct($user['id']);
} else {
$encryptPassword = $this->auth->getEncryptPassword($password, $user['salt']);
if ($user['password'] !== $encryptPassword) {
$this->error('手机号或密码不正确');
}
$this->auth->direct($user['id']);
}
}
// 直查真实数据库返回用户完整信息
$this->success('登录成功', [
'token' => $this->auth->getToken(),
'expires' => 2592000,
'userinfo' => $this->profileData(),
]);
}
// 2. 手机号 + 验证码登录(向下兼容)
if (!$mobile || !$code) {
$this->error('请填写手机号和验证码');
}
@@ -162,6 +218,61 @@ class Auth extends Base
* 切换角色(用户 / 师傅)
* @ApiMethod (POST)
*/
/**
* 微信手机号授权快捷登录
* @ApiMethod (POST)
*/
public function wxPhoneLogin()
{
$phoneCode = trim((string)$this->request->post('phone_code'));
$loginCode = trim((string)$this->request->post('login_code'));
if ($phoneCode === '') {
$this->error('缺少微信手机号授权凭证');
}
// 1. 换取手机号
$phoneInfo = \app\common\library\WxLogin::getPhoneNumber($phoneCode);
if (isset($phoneInfo['error'])) {
$this->error('获取微信手机号失败:' . $phoneInfo['error'], ['wx_errcode' => isset($phoneInfo['errcode']) ? (int)$phoneInfo['errcode'] : 0]);
}
$mobile = isset($phoneInfo['purePhoneNumber']) ? (string)$phoneInfo['purePhoneNumber'] : (string)$phoneInfo['phoneNumber'];
if (!$mobile) {
$this->error('解析手机号失败');
}
// 2. 如果传了 login_code,换取 openid
$openid = '';
$sessionKey = '';
$unionid = '';
if ($loginCode !== '') {
$wx = \app\common\library\WxLogin::jscode2session($loginCode);
if (!isset($wx['error']) && !empty($wx['openid'])) {
$openid = $wx['openid'];
$sessionKey = isset($wx['session_key']) ? $wx['session_key'] : '';
$unionid = isset($wx['unionid']) ? $wx['unionid'] : '';
}
}
// 3. 落库与关联登录
$ret = \app\common\library\WxLogin::provisionWithMobile(
$mobile,
$openid,
$unionid,
$sessionKey
);
$this->auth->direct($ret['user_id']);
$this->success('登录成功', [
'token' => $this->auth->getToken(),
'expires' => 2592000,
'userinfo' => $this->profileData(),
'is_new' => $ret['is_new'],
'mobile' => $mobile,
]);
}
public function switchRole()
{
$role = $this->request->post('role', 'user');