Merge remote-tracking branch 'origin/master'
commit
80d500ed00
|
|
@ -98,7 +98,7 @@
|
|||
<view class="ss-m-t-60 ss-flex ss-flex-wrap ss-row-center">
|
||||
<!-- 团长 -->
|
||||
<view class="header-avatar ss-m-r-24 ss-m-b-20">
|
||||
<image :src="sheep.$url.cdn(state.data.headRecord.avatar)" class="avatar-img"></image>
|
||||
<image :src="sheep.$url.cdn(state.data.headRecord.avatar) || sheep.$url.static('/static/img/shop/default_avatar.png')" class="avatar-img"></image>
|
||||
<view class="header-tag ss-flex ss-col-center ss-row-center">团长</view>
|
||||
</view>
|
||||
<!-- 团员 -->
|
||||
|
|
@ -107,7 +107,7 @@
|
|||
v-for="item in state.data.memberRecords"
|
||||
:key="item.id"
|
||||
>
|
||||
<image :src="sheep.$url.cdn(item.avatar)" class="avatar-img"></image>
|
||||
<image :src="sheep.$url.cdn(item.avatar) || sheep.$url.static('/static/img/shop/default_avatar.png')" class="avatar-img"></image>
|
||||
<view
|
||||
class="header-tag ss-flex ss-col-center ss-row-center"
|
||||
v-if="item.is_leader == '1'"
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
class="content-img"
|
||||
isPreview
|
||||
:current="0"
|
||||
:src="state.model?.avatar"
|
||||
:src="state.model?.avatar || sheep.$url.static('/static/img/shop/default_avatar.png')"
|
||||
:height="160"
|
||||
:width="160"
|
||||
:radius="80"
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import sheep from '@/sheep';
|
||||
import { formatImageUrlProtocol, getWxaQrcode } from './index';
|
||||
|
||||
import { measureTextWidth } from '@/utils/textUtils'; // 引入新封装的方法
|
||||
const user = async (poster) => {
|
||||
const width = poster.width;
|
||||
const userInfo = sheep.$store('user').userInfo;
|
||||
const wxa_qrcode = await getWxaQrcode(poster.shareInfo.path, poster.shareInfo.query);
|
||||
const widthNickName = measureTextWidth(userInfo.nickname, 14); // 使用新方法
|
||||
return [
|
||||
{
|
||||
type: 'image',
|
||||
|
|
@ -28,7 +29,7 @@ const user = async (poster) => {
|
|||
fontFamily: 'sans-serif',
|
||||
position: 'fixed',
|
||||
top: width * 0.4,
|
||||
left: width / 2,
|
||||
left: (width-widthNickName) / 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<view class="left-box ss-flex ss-col-center ss-m-l-36">
|
||||
<view class="avatar-box ss-m-r-24">
|
||||
<image class="avatar-img" :src="
|
||||
isLogin
|
||||
isLogin && userInfo.avatar
|
||||
? sheep.$url.cdn(userInfo.avatar)
|
||||
: sheep.$url.static('/static/img/shop/default_avatar.png')"
|
||||
mode="aspectFill" @tap="sheep.$router.go('/pages/user/info')">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
// sheep/utils/textUtils.js
|
||||
export function measureTextWidth(text, fontSize = 14, fontFamily = 'sans-serif') {
|
||||
// 钉钉小程序没有 uni.createCanvasContext 方法
|
||||
if (typeof uni === 'undefined' || typeof uni.createCanvasContext !== 'function') {
|
||||
return estimateTextWidth(text, fontSize);
|
||||
}
|
||||
|
||||
try {
|
||||
const ctx = uni.createCanvasContext('tempCanvasForText');
|
||||
ctx.setFontSize(fontSize);
|
||||
ctx.font = `${fontSize}px ${fontFamily}`;
|
||||
const metrics = ctx.measureText(text);
|
||||
return metrics.width;
|
||||
} catch (e) {
|
||||
// 某些平台可能不支持 measureText,降级使用估算
|
||||
return estimateTextWidth(text, fontSize);
|
||||
}
|
||||
}
|
||||
|
||||
// 简单估算中文和英文字符宽度
|
||||
function estimateTextWidth(text, fontSize = 14) {
|
||||
let width = 0;
|
||||
for (let i = 0; i < text.length; i++) {
|
||||
const charCode = text.charCodeAt(i);
|
||||
if (charCode >= 0x4e00 && charCode <= 0x9fff) {
|
||||
// 中文字符
|
||||
width += fontSize;
|
||||
} else {
|
||||
// 英文字符
|
||||
width += fontSize * 0.5;
|
||||
}
|
||||
}
|
||||
return width;
|
||||
}
|
||||
Loading…
Reference in New Issue