feat(common): 新增师傅头像URL处理类统一生成头像地址

- 新增MasterAvatar类统一处理师傅头像URL生成逻辑
- 替换所有分散的cdnurl调用为统一类方法
- 优化后台师傅详情页表格响应式布局
- 更新应用版本号至1.0.92
这个提交包含在:
2026-11-20 11:27:56 +08:00
父节点 07f3349dd0
当前提交 8af5672aeb
共有 10 个文件被更改,包括 151 次插入 和 66 次删除

查看文件

@@ -35,7 +35,20 @@
.md-card-header { padding: 10px 16px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: space-between; }
.md-card-title { font-size: 13.5px; font-weight: 700; color: #1e293b; margin: 0; display: flex; align-items: center; gap: 8px; }
.md-card-title i { color: #f97316; }
.md-card-body { padding: 16px; }
.md-card-body { padding: 16px; min-width: 0; }
.md-table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.md-table-scroll table { min-width: 560px; }
.md-grid-list { min-width: 0; }
.md-item-v { min-width: 0; }
.master-detail-container .md-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 0 24px; }
@media (max-width: 900px) {
.master-detail-container > .row > .col-sm-6 { width: 100%; float: none; }
}
@media (max-width: 500px) {
.md-grid-list { grid-template-columns: 1fr !important; }
.md-grid-list .md-item { grid-column: auto !important; }
.md-kpi-grid { flex-wrap: wrap; }
}
.md-grid-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 18px; }
.md-item { display: flex; align-items: baseline; font-size: 13px; line-height: 1.5; }
@@ -48,11 +61,12 @@
.idcard-img-wrap .tag { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(15, 23, 42, 0.72); color: #fff; font-size: 11px; text-align: center; padding: 2px 0; }
</style>
<?php $masterAvatarUrl = \app\common\library\MasterAvatar::url($row['avatar']); ?>
<div class="master-detail-container">
<!-- 1. Hero 师傅名片 -->
<div class="md-hero">
<div class="md-hero-left">
<img class="md-avatar" src="{$row.avatar|default='/assets/img/avatar.png'|htmlentities}" onerror="this.src='/assets/img/avatar.png'" />
<img class="md-avatar" src="{$masterAvatarUrl|default='/assets/img/avatar.png'|htmlentities}" onerror="this.src='/assets/img/avatar.png'" />
<div>
<div class="md-info-name">
<span class="name-txt">{$row.realname|htmlentities}</span>
@@ -163,7 +177,7 @@
</div>
<div class="md-card-body">
{if !empty($certs)}
<table class="table table-bordered table-condensed" style="font-size: 12px; margin-bottom: 0;">
<div class="md-table-scroll"><table class="table table-bordered table-condensed" style="font-size: 12px; margin-bottom: 0;">
<thead><tr class="active"><th>证书名称</th><th>证件照片</th><th>有效期至</th><th>状态</th></tr></thead>
<tbody>
{foreach name="certs" item="ct"}
@@ -183,7 +197,7 @@
</tr>
{/foreach}
</tbody>
</table>
</table></div>
{else /}
<div style="text-align: center; color: #94a3b8; padding: 14px 0;">暂未上传技能资质证书</div>
{/if}
@@ -214,7 +228,7 @@
<div style="font-size: 12px; font-weight: 600; color: #475569; margin-bottom: 6px;">近期工单结算分成:</div>
{if !empty($recentSettles)}
<table class="table table-bordered table-condensed" style="font-size: 12px; margin-bottom: 12px;">
<div class="md-table-scroll"><table class="table table-bordered table-condensed" style="font-size: 12px; margin-bottom: 12px;">
<thead><tr class="active"><th>工单号</th><th>订单总额</th><th>抽成</th><th>师傅所得</th><th>状态</th></tr></thead>
<tbody>
{foreach name="recentSettles" item="st"}
@@ -231,14 +245,14 @@
</tr>
{/foreach}
</tbody>
</table>
</table></div>
{else /}
<div class="text-muted" style="font-size:12px; margin-bottom:12px;">暂无结算入账记录</div>
{/if}
<div style="font-size: 12px; font-weight: 600; color: #475569; margin-bottom: 6px;">近期提现申请记录:</div>
{if !empty($recentWithdraws)}
<table class="table table-bordered table-condensed" style="font-size: 12px; margin-bottom: 0;">
<div class="md-table-scroll"><table class="table table-bordered table-condensed" style="font-size: 12px; margin-bottom: 0;">
<thead><tr class="active"><th>申请金额</th><th>手续费</th><th>实到金额</th><th>渠道</th><th>状态</th></tr></thead>
<tbody>
{foreach name="recentWithdraws" item="w"}
@@ -256,7 +270,7 @@
</tr>
{/foreach}
</tbody>
</table>
</table></div>
{else /}
<div class="text-muted" style="font-size:12px;">暂无提现申请记录</div>
{/if}
@@ -272,7 +286,7 @@
</div>
<div class="md-card-body" style="padding: 12px 16px;">
{if !empty($recentReviews)}
<table class="table table-bordered table-condensed" style="font-size:12px; margin-bottom:0;">
<div class="md-table-scroll"><table class="table table-bordered table-condensed" style="font-size:12px; margin-bottom:0;">
<thead>
<tr class="active">
<th style="width:155px;">关联工单</th>
@@ -299,7 +313,7 @@
</tr>
{/foreach}
</tbody>
</table>
</table></div>
{else /}
<div style="text-align: center; color: #94a3b8; padding: 14px 0;">暂无客户评价记录</div>
{/if}
@@ -313,7 +327,7 @@
</div>
<div class="md-card-body" style="padding: 12px 16px;">
{if !empty($recentOrders)}
<table class="table table-bordered table-hover table-condensed" style="font-size: 12px; margin-bottom: 0;">
<div class="md-table-scroll"><table class="table table-bordered table-hover table-condensed" style="font-size: 12px; margin-bottom: 0;">
<thead>
<tr class="active">
<th>工单编号</th>
@@ -340,22 +354,19 @@
</tr>
{/foreach}
</tbody>
</table>
</table></div>
{else /}
<div style="text-align: center; color: #94a3b8; padding: 16px 0;">暂无接单履约历史</div>
{/if}
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-10" style="display:flex; gap:10px; align-items:center;">
<div class="md-footer">
{if $row.verify_status == 'pending'}
<a href="master/audit?ids={$row.id}" class="btn btn-warning btn-embossed btn-dialog" data-area='["920px", "88%"]' title="师傅资质审核 - {$row.realname|htmlentities}">
<i class="fa fa-check-square-o"></i> 立即审核该师傅
</a>
{/if}
<button type="button" class="btn btn-default btn-embossed" onclick="parent.Layer.closeAll();"><i class="fa fa-close"></i> 关闭档案</button>
</div>
</div>
</div>

查看文件

@@ -272,7 +272,8 @@
<div class="od-card-body">
{if $row.master_id && $row.master}
<div style="display:flex; align-items:center; gap:14px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid #f1f5f9;">
<img src="{$row.master.avatar|default='/assets/img/avatar.png'|htmlentities}" onerror="this.src='/assets/img/avatar.png'" style="width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 2px solid #fed7aa;" />
<?php $orderMasterAvatarUrl = \app\common\library\MasterAvatar::url($row['master']['avatar']); ?>
<img src="{$orderMasterAvatarUrl|default='/assets/img/avatar.png'|htmlentities}" onerror="this.src='/assets/img/avatar.png'" style="width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 2px solid #fed7aa;" />
<div>
<div style="font-size: 15px; font-weight: 700; color: #1e293b; display:flex; align-items:center; gap:8px;">
<span>{$row.master.realname|htmlentities}</span>

查看文件

@@ -1538,6 +1538,11 @@ class Home extends Base
$this->error('该晒单不存在或已取消公开');
}
// 晒单保存师傅称呼快照,头像从关联订单读取当前师傅资料。
$caseMasterAvatar = Db::name('order')->alias('o')
->join('master m', 'm.id = o.master_id', 'LEFT')
->where('o.id', (int)$sc['order_id'])->value('m.avatar');
$service = Db::name('service')->where('id', (int)$sc['service_id'])->find();
$basePrice = $service ? (float)$service['base_price'] : 0.00;
@@ -1587,6 +1592,7 @@ class Home extends Base
],
'master' => [
'realname' => (string)$sc['master_name'],
'avatar' => \app\common\library\MasterAvatar::url($caseMasterAvatar),
'score' => (float)$sc['master_score'],
],
'review' => [

查看文件

@@ -263,7 +263,7 @@ class Master extends Base
'idcard_front_raw' => (string)($master['idcard_front'] ?? ''),
'idcard_back_raw' => (string)($master['idcard_back'] ?? ''),
'cert_images' => (string)($master['cert_images'] ?? ''),
'avatar' => !empty($master['avatar']) ? (strpos((string)$master['avatar'], 'http') === 0 ? $master['avatar'] : cdnurl($master['avatar'], true)) : '',
'avatar' => \app\common\library\MasterAvatar::url($master['avatar']),
'city' => $master['city'],
'lng' => (string)($master['lng'] ?? ''),
'lat' => (string)($master['lat'] ?? ''),

查看文件

@@ -987,7 +987,7 @@ class Order extends Base
$master = [
'id' => (int)$m['id'],
'realname' => $m['realname'],
'avatar' => !empty($m['avatar']) ? (strpos((string)$m['avatar'], 'http') === 0 ? $m['avatar'] : cdnurl($m['avatar'], true)) : '',
'avatar' => \app\common\library\MasterAvatar::url($m['avatar']),
'mobile' => $canSeeRealMobile ? $rawM : $maskedM,
'mobile_raw' => $masterMobileRaw,
'mobile_mask' => $maskedM,
@@ -1020,7 +1020,7 @@ class Order extends Base
'id' => (int)$q['id'],
'master_id' => (int)$q['master_id'],
'realname' => $q['realname'] ?: '师傅',
'avatar' => $q['avatar'],
'avatar' => \app\common\library\MasterAvatar::url($q['avatar']),
'score' => (float)$q['score'],
'order_count' => (int)$q['order_count'],
'level' => (int)$q['level'],
@@ -1271,7 +1271,7 @@ class Order extends Base
'id' => (int)$q['id'],
'master_id' => (int)$q['master_id'],
'realname' => $q['realname'] ?: '师傅',
'avatar' => $q['avatar'],
'avatar' => \app\common\library\MasterAvatar::url($q['avatar']),
'score' => (float)$q['score'],
'order_count' => (int)$q['order_count'],
'amount' => (float)$q['amount'],

查看文件

@@ -0,0 +1,16 @@
<?php
namespace app\common\library;
/** 师傅头像在各展示入口使用相同的资源地址规则。 */
class MasterAvatar
{
public static function url($value)
{
$value = trim((string)$value);
if ($value === '' || strpos($value, '/assets/') === 0 || preg_match('~^(?:https?:)?//~i', $value)) {
return $value;
}
return cdnurl($value, true);
}
}

查看文件

@@ -4,7 +4,7 @@ return array (
'name' => '优匠优服',
'beian' => '',
'cdnurl' => '',
'version' => '1.0.90',
'version' => '1.0.92',
'timezone' => 'Asia/Shanghai',
'forbiddenip' => '',
'languages' =>

16
tests/master_avatar_url.php 普通文件
查看文件

@@ -0,0 +1,16 @@
<?php
function cdnurl($url, $domain = false) { return 'https://cdn.example.test' . $url; }
require __DIR__ . '/../server/application/common/library/MasterAvatar.php';
use app\common\library\MasterAvatar;
$cases = [
'' => '',
'/avatar/u104/photo.jpg' => 'https://cdn.example.test/avatar/u104/photo.jpg',
'https://images.example.test/a.png' => 'https://images.example.test/a.png',
'//images.example.test/a.png' => '//images.example.test/a.png',
'/assets/img/avatar.png' => '/assets/img/avatar.png',
];
foreach ($cases as $input => $expected) {
$actual = MasterAvatar::url($input);
if ($actual !== $expected) { fwrite(STDERR, "Avatar URL mismatch for $input\n"); exit(1); }
}
echo "Master avatar URL tests passed\n";

查看文件

@@ -51,7 +51,9 @@
<view class="hero-body">
<view class="user-block">
<view class="avatar-wrap clickable-hover" @tap="go('/pages/master/apply')">
<image class="avatar-img" :src="(info && info.avatar) || '/static/icons/avatar-master.svg'" mode="aspectFill" />
<view class="avatar-clip">
<image class="avatar-img" :src="(info && info.avatar) || '/static/icons/avatar-master.svg'" mode="aspectFill" />
</view>
<view class="v-auth-badge">
<image class="v-badge-ico" src="/static/icons/v-auth.svg" mode="aspectFit" />
<text class="v-badge-txt">{{ verifyStatusMeta.text }}</text>
@@ -756,9 +758,18 @@
position: relative;
}
.avatar-clip {
width: 100%;
height: 100%;
border-radius: 50%;
overflow: hidden;
}
.avatar-img {
width: 76rpx;
height: 76rpx;
display: block;
width: 100%;
height: 100%;
border-radius: 50%;
}
.v-auth-badge {

查看文件

@@ -1,6 +1,6 @@
<template>
<view class="page">
<YjyfNavBar theme="white" title="师傅入驻" :border="true" />
<YjyfNavBar theme="white" :title="info && info.master && info.master.verify_status === 'pass' ? '师傅资料' : '师傅入驻'" :border="true" />
<view class="loading-box" v-if="loading">
<text class="loading-txt">正在加载认证信息...</text>
@@ -8,7 +8,7 @@
<template v-else>
<!-- 审核状态提示条 -->
<view class="status-banner" v-if="info && info.master" :class="'st-' + info.master.verify_status">
<view class="status-banner" v-if="info && info.master && info.master.verify_status !== 'pass'" :class="'st-' + info.master.verify_status">
<view class="sb-top">
<text class="sb-title">审核状态:{{ statusText }}</text>
</view>
@@ -156,18 +156,51 @@
</view>
</template>
<!-- 已提交待审或已认证档案卡 -->
<!-- 已认证师傅:可编辑资料与实名档案分别展示 -->
<template v-else-if="info && info.master && info.master.verify_status === 'pass'">
<view class="card profile-card">
<view class="profile-heading">
<text class="profile-title">基本资料</text>
<text class="profile-subtitle">设置头像与接单联系电话</text>
</view>
<view class="profile-avatar-row clickable-hover" @tap="chooseProfileAvatar" role="button" aria-label="更换师傅头像">
<text class="profile-label">头像</text>
<view class="profile-avatar-action">
<image class="profile-avatar-image" :src="info.master.avatar || '/static/icons/avatar-master.svg'" mode="aspectFill" />
<text class="profile-action-text">{{ profileUploading ? '上传中...' : '更换' }}</text>
<image class="profile-arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" />
</view>
</view>
<view class="profile-phone-row">
<text class="profile-label">接单电话</text>
<input class="profile-input" v-model="profileMobile" type="number" maxlength="11" placeholder="请输入接单手机号" />
</view>
</view>
<view class="card profile-card identity-card">
<view class="profile-heading">
<text class="profile-title">实名档案</text>
<text class="identity-status">已认证</text>
</view>
<view class="identity-row"><text class="identity-label">真实姓名</text><text class="identity-value">{{ info.master.realname }}</text></view>
<view class="identity-row"><text class="identity-label">身份证号</text><text class="identity-value">{{ info.master.idcard_no }}</text></view>
<view class="identity-row"><text class="identity-label">服务城市</text><text class="identity-value">{{ info.master.city || '-' }}</text></view>
<view class="identity-row"><text class="identity-label">综合评分</text><text class="identity-value">{{ info.master.score }} 分</text></view>
<view class="identity-row identity-row-last"><text class="identity-label">累计完单</text><text class="identity-value">{{ info.master.order_count }} 单</text></view>
</view>
<view class="profile-save clickable-hover" :class="{ disabled: profileSaving || profileUploading }" @tap="saveProfile">
<text>{{ profileSaving ? '保存中...' : '保存资料' }}</text>
</view>
</template>
<!-- 已提交待审档案 -->
<view class="card badge-card" v-else-if="info && info.master">
<view class="badge-top">
<view class="badge-avatar-wrap">
<image
class="badge-avatar-img"
:src="info.master.avatar || '/static/icons/avatar-master.svg'"
mode="aspectFill"
/>
<image class="badge-avatar-img" :src="info.master.avatar || '/static/icons/avatar-master.svg'" mode="aspectFill" />
<view class="v-auth-badge">
<image class="v-badge-ico" src="/static/icons/v-auth.svg" mode="aspectFit" />
<text class="v-badge-txt">{{ info.master.verify_status === 'pass' ? '已实名' : '审核中' }}</text>
<text class="v-badge-txt">审核中</text>
</view>
</view>
</view>
@@ -176,37 +209,11 @@
<text class="badge-master-mobile">{{ info.master.mobile }}</text>
</view>
<view class="badge-divider"></view>
<view class="li">
<text class="k">真实姓名</text>
<text class="v">{{ info.master.realname }}</text>
</view>
<view class="li">
<text class="k">身份证号</text>
<text class="v">{{ info.master.idcard_no }}</text>
</view>
<view class="li">
<text class="k">服务城市</text>
<text class="v">{{ info.master.city || '-' }}</text>
</view>
<view class="li">
<text class="k">综合评分</text>
<text class="v">{{ info.master.score }} 分</text>
</view>
<view class="li no-border">
<text class="k">累计完单</text>
<text class="v">{{ info.master.order_count }} 单</text>
</view>
<template v-if="info.master.verify_status === 'pass'">
<view class="li clickable-hover" @tap="chooseProfileAvatar">
<text class="k">师傅头像</text><text class="v">{{ profileUploading ? '上传中...' : '点击更换' }}</text>
</view>
<view class="li">
<text class="k">接单电话</text>
<input class="profile-input" v-model="profileMobile" type="number" maxlength="11" placeholder="请输入接单手机号" />
</view>
<view class="go-btn clickable-hover" @tap="saveProfile"><text class="go-txt">{{ profileSaving ? '保存中...' : '保存资料' }}</text></view>
</template>
<view class="li"><text class="k">真实姓名</text><text class="v">{{ info.master.realname }}</text></view>
<view class="li"><text class="k">身份证号</text><text class="v">{{ info.master.idcard_no }}</text></view>
<view class="li"><text class="k">服务城市</text><text class="v">{{ info.master.city || '-' }}</text></view>
<view class="li"><text class="k">综合评分</text><text class="v">{{ info.master.score }} 分</text></view>
<view class="li no-border"><text class="k">累计完单</text><text class="v">{{ info.master.order_count }} 单</text></view>
<view class="go-btn clickable-hover" @tap="goWorkbench">
<text class="go-txt">进入师傅工作台</text>
<image class="go-arrow" src="/static/icons/arrow-right-white.svg" mode="aspectFit" />
@@ -616,7 +623,24 @@
<style lang="scss" scoped>
@import '@/uni.scss';
.profile-input { text-align: right; flex: 1; color: $yjyf-text-main; }
.profile-card { padding: 0 32rpx; }
.profile-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16rpx; padding: 30rpx 0 20rpx; }
.profile-title { font-size: $yjyf-font-title; color: $yjyf-text-main; font-weight: 700; flex-shrink: 0; }
.profile-subtitle { font-size: $yjyf-font-sub; color: $yjyf-text-secondary; text-align: right; }
.profile-avatar-row, .profile-phone-row { min-height: 108rpx; display: flex; align-items: center; justify-content: space-between; border-top: 1rpx solid $yjyf-border-color; }
.profile-avatar-row { min-height: 136rpx; }
.profile-label { font-size: $yjyf-font-body; color: $yjyf-text-regular; flex-shrink: 0; }
.profile-avatar-action { display: flex; align-items: center; gap: 16rpx; }
.profile-avatar-image { width: 88rpx; height: 88rpx; border-radius: 50%; background: $yjyf-primary-bg; }
.profile-action-text { font-size: $yjyf-font-body; color: $yjyf-text-secondary; }
.profile-arrow { width: 24rpx; height: 24rpx; }
.profile-input { text-align: right; flex: 1; min-width: 0; height: 100rpx; font-size: $yjyf-font-body; color: $yjyf-text-main; }
.identity-status { font-size: $yjyf-font-sub; color: $yjyf-success; }
.identity-row { display: flex; justify-content: space-between; align-items: center; gap: 20rpx; min-height: 84rpx; border-top: 1rpx solid $yjyf-border-color; }
.identity-label { font-size: $yjyf-font-body; color: $yjyf-text-secondary; flex-shrink: 0; }
.identity-value { font-size: $yjyf-font-body; color: $yjyf-text-main; text-align: right; word-break: break-all; }
.profile-save { height: 88rpx; margin: 40rpx $yjyf-space-md 0; border-radius: $yjyf-radius-pill; background: $yjyf-gradient-primary; color: $yjyf-text-inverse; display: flex; align-items: center; justify-content: center; font-size: $yjyf-font-body; font-weight: 700; }
.profile-save.disabled { opacity: 0.6; }
.page {
min-height: 100vh;
background: $yjyf-bg-page;