优化:资料弹窗使用圆形默认头像
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 9.0 KiB |
@@ -0,0 +1,16 @@
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const pageDirectory = __dirname
|
||||
const projectDirectory = path.resolve(pageDirectory, '../..')
|
||||
const template = fs.readFileSync(path.join(pageDirectory, 'index.wxml'), 'utf8')
|
||||
const styles = fs.readFileSync(path.join(pageDirectory, 'index.wxss'), 'utf8')
|
||||
const defaultAvatar = path.join(projectDirectory, 'assets/images/default-user-avatar.png')
|
||||
|
||||
assert.strictEqual(fs.existsSync(defaultAvatar), true)
|
||||
assert.match(template, /profileForm\.avatar \|\| '\/assets\/images\/default-user-avatar\.png'/)
|
||||
assert.match(template, /open-type="chooseAvatar"/)
|
||||
assert.match(template, /点击更换/)
|
||||
assert.match(styles, /\.wechat-avatar\s*\{[\s\S]*?width:\s*144rpx;[\s\S]*?height:\s*144rpx;[\s\S]*?border-radius:\s*50%;/)
|
||||
assert.doesNotMatch(template, /wx:else>选择头像/)
|
||||
@@ -33,7 +33,10 @@
|
||||
<view wx:if="{{profilePromptVisible}}" class="profile-prompt-mask">
|
||||
<view class="profile-prompt">
|
||||
<text class="profile-prompt-title">完善你的工作名片</text><text class="profile-prompt-desc">头像和昵称会用于门店协作展示,可暂时跳过。</text>
|
||||
<button class="wechat-avatar" open-type="chooseAvatar" bindchooseavatar="chooseWechatAvatar"><image wx:if="{{profileForm.avatar}}" src="{{profileForm.avatar}}" mode="aspectFill"></image><text wx:else>选择头像</text></button>
|
||||
<button class="wechat-avatar" open-type="chooseAvatar" bindchooseavatar="chooseWechatAvatar" disabled="{{profileSaving}}">
|
||||
<image class="wechat-avatar-image {{profileForm.avatar ? 'is-real' : 'is-default'}}" src="{{profileForm.avatar || '/assets/images/default-user-avatar.png'}}" mode="aspectFill"></image>
|
||||
<view class="wechat-avatar-hint">{{profileSaving ? '上传中' : '点击更换'}}</view>
|
||||
</button>
|
||||
<input class="wechat-nickname" type="nickname" value="{{profileForm.nickname}}" bindinput="onNicknameInput" placeholder="填写微信昵称" />
|
||||
<button class="profile-save" loading="{{profileSaving}}" bindtap="saveWechatProfile">保存资料</button><button class="profile-skip" bindtap="skipProfilePrompt">暂时跳过</button>
|
||||
</view>
|
||||
|
||||
@@ -2,7 +2,55 @@
|
||||
padding-top: 18rpx;
|
||||
}
|
||||
|
||||
.phone-banner { display:flex; align-items:center; margin-bottom:18rpx; padding:16rpx 18rpx; border-radius:14rpx; background:#fff2d8; color:#815f2b; overflow:hidden; }.phone-banner-track { display:flex; flex:1; width:0; gap:50rpx; white-space:nowrap; animation:phoneBannerScroll 10s linear infinite; font-size:22rpx; }.phone-banner-close { position:relative; z-index:2; margin-left:18rpx; padding:6rpx; background:#fff2d8; font-size:32rpx; }.profile-prompt-mask { position:fixed; z-index:30; inset:0; display:flex; align-items:center; justify-content:center; padding:40rpx; background:rgba(25,41,33,.55); }.profile-prompt { box-sizing:border-box; display:flex; width:100%; flex-direction:column; align-items:center; padding:36rpx; border-radius:24rpx; background:#fff; }.profile-prompt-title { color:#30483c; font-size:32rpx; font-weight:800; }.profile-prompt-desc { margin-top:10rpx; color:#89988f; font-size:22rpx; text-align:center; }.wechat-avatar { display:flex; align-items:center; justify-content:center; width:128rpx; height:128rpx; margin-top:28rpx; padding:0; border-radius:50%; background:#e6f0e9; color:#416c56; font-size:22rpx; overflow:hidden; }.wechat-avatar image { width:100%; height:100%; }.wechat-nickname { box-sizing:border-box; width:100%; height:80rpx; margin-top:24rpx; padding:0 22rpx; border:1rpx solid #dce8df; border-radius:13rpx; background:#f7faf8; }.profile-save { width:100%; height:80rpx; margin-top:22rpx; border-radius:14rpx; background:#35634d; color:#fff; line-height:80rpx; }.profile-skip { margin-top:12rpx; background:transparent; color:#7e8e85; font-size:23rpx; }
|
||||
.phone-banner { display:flex; align-items:center; margin-bottom:18rpx; padding:16rpx 18rpx; border-radius:14rpx; background:#fff2d8; color:#815f2b; overflow:hidden; }.phone-banner-track { display:flex; flex:1; width:0; gap:50rpx; white-space:nowrap; animation:phoneBannerScroll 10s linear infinite; font-size:22rpx; }.phone-banner-close { position:relative; z-index:2; margin-left:18rpx; padding:6rpx; background:#fff2d8; font-size:32rpx; }.profile-prompt-mask { position:fixed; z-index:30; inset:0; display:flex; align-items:center; justify-content:center; padding:40rpx; background:rgba(25,41,33,.55); }.profile-prompt { box-sizing:border-box; display:flex; width:100%; flex-direction:column; align-items:center; padding:36rpx; border-radius:24rpx; background:#fff; }.profile-prompt-title { color:#30483c; font-size:32rpx; font-weight:800; }.profile-prompt-desc { margin-top:10rpx; color:#89988f; font-size:22rpx; text-align:center; }.wechat-nickname { box-sizing:border-box; width:100%; height:80rpx; margin-top:24rpx; padding:0 22rpx; border:1rpx solid #dce8df; border-radius:13rpx; background:#f7faf8; }.profile-save { width:100%; height:80rpx; margin-top:22rpx; border-radius:14rpx; background:#35634d; color:#fff; line-height:80rpx; }.profile-skip { margin-top:12rpx; background:transparent; color:#7e8e85; font-size:23rpx; }
|
||||
|
||||
.wechat-avatar {
|
||||
position: relative;
|
||||
display: block;
|
||||
flex: none;
|
||||
width: 144rpx;
|
||||
min-width: 144rpx;
|
||||
max-width: 144rpx;
|
||||
height: 144rpx;
|
||||
min-height: 144rpx;
|
||||
max-height: 144rpx;
|
||||
margin-top: 28rpx;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
border: 2rpx solid #d8dfdb;
|
||||
border-radius: 50%;
|
||||
background: #f3f4f3;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.wechat-avatar[disabled] {
|
||||
opacity: 0.78;
|
||||
}
|
||||
|
||||
.wechat-avatar-image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.wechat-avatar-image.is-default {
|
||||
box-sizing: border-box;
|
||||
padding: 12rpx;
|
||||
}
|
||||
|
||||
.wechat-avatar-hint {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
height: 38rpx;
|
||||
background: rgba(22, 27, 25, 0.68);
|
||||
color: #fff;
|
||||
font-size: 19rpx;
|
||||
font-weight: 600;
|
||||
line-height: 38rpx;
|
||||
text-align: center;
|
||||
}
|
||||
@keyframes phoneBannerScroll { from { transform:translateX(0); } to { transform:translateX(-48%); } }
|
||||
|
||||
.today-btn {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
## 方案
|
||||
|
||||
- 将头像入口固定为圆形,图片使用 `aspectFill` 覆盖整个区域。
|
||||
- 新增本地黑白人物轮廓默认头像资源,避免依赖网络外链和首字生成。
|
||||
- 新增本地 PNG 黑白人物轮廓默认头像资源,避免依赖网络外链、首字生成和 SVG 兼容差异。
|
||||
- `profileForm.avatar` 继续只保存真实头像地址;默认头像仅作为模板展示资源,保存时仍要求用户选择真实头像。
|
||||
- 圆形头像底部覆盖半透明“点击更换”提示,真实头像和默认头像下均可识别入口用途。
|
||||
- 上传期间禁止重复选择并显示“上传中”,上传失败后保留选择前状态。
|
||||
|
||||
Reference in New Issue
Block a user