1. 前端个人中心新增真实姓名输入与实名状态展示,支持微信提现核验 2. 后端Auth接口新增真实姓名修改与手机号冲突校验逻辑 3. 后台新增用户详情综合看板,展示佣金、提现、分销等全量数据 4. 优化微信转账逻辑,支持paying状态重试时查询微信单号避免重复创建 5. 新增数据库ALTER脚本同步transfer_status字段结构 6. 新增部署与数据库变更工具脚本,支持线上线下环境同步
545 行
12 KiB
Vue
545 行
12 KiB
Vue
<template>
|
||
<view class="profile fc-page">
|
||
<!-- 沉浸式导航栏 -->
|
||
<fc-navbar title="编辑个人资料" theme="gradient" :show-back="true" />
|
||
|
||
<view class="profile__body">
|
||
<!-- 头像设置卡片 -->
|
||
<view class="fc-card profile__card profile__card--avatar">
|
||
<view class="profile__avatar-wrap">
|
||
<!-- #ifdef MP-WEIXIN -->
|
||
<button class="profile__avatar-btn" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
|
||
<image v-if="avatarDisplay" class="profile__avatar-img" :src="avatarDisplay" mode="aspectFill" />
|
||
<text v-else class="profile__avatar-char">{{ avatarChar }}</text>
|
||
<view class="profile__avatar-badge">
|
||
<image class="profile__avatar-camera" :src="iconUrl('edit')" mode="aspectFit" />
|
||
</view>
|
||
</button>
|
||
<!-- #endif -->
|
||
|
||
<!-- #ifndef MP-WEIXIN -->
|
||
<view class="profile__avatar-btn" @click="chooseAvatarH5">
|
||
<image v-if="avatarDisplay" class="profile__avatar-img" :src="avatarDisplay" mode="aspectFill" />
|
||
<text v-else class="profile__avatar-char">{{ avatarChar }}</text>
|
||
<view class="profile__avatar-badge">
|
||
<image class="profile__avatar-camera" :src="iconUrl('edit')" mode="aspectFit" />
|
||
</view>
|
||
</view>
|
||
<!-- #endif -->
|
||
</view>
|
||
<text class="profile__avatar-tip">点击头像可更换(支持同步微信头像或相册上传)</text>
|
||
</view>
|
||
|
||
<!-- 资料编辑表单卡片 -->
|
||
<view class="fc-card profile__card">
|
||
<!-- 用户昵称 -->
|
||
<view class="profile__field">
|
||
<text class="profile__label">用户昵称</text>
|
||
<view class="profile__input-wrap">
|
||
<input
|
||
class="profile__input"
|
||
type="nickname"
|
||
v-model="form.nickname"
|
||
placeholder="请输入昵称"
|
||
placeholder-class="profile__placeholder"
|
||
maxlength="20"
|
||
/>
|
||
</view>
|
||
<text class="profile__field-tip">可直接点击输入框自动填入微信昵称</text>
|
||
</view>
|
||
|
||
<!-- 收款人真实姓名(提现实名认证) -->
|
||
<view class="profile__field">
|
||
<view class="profile__label-row">
|
||
<text class="profile__label">收款人真实姓名</text>
|
||
<view v-if="userInfo && userInfo.realnameStatus" class="profile__tag profile__tag--verified">
|
||
<text class="profile__tag-text">已实名认证</text>
|
||
</view>
|
||
<view v-else class="profile__tag profile__tag--pending">
|
||
<text class="profile__tag-text">未实名</text>
|
||
</view>
|
||
</view>
|
||
<view class="profile__input-wrap">
|
||
<input
|
||
class="profile__input"
|
||
type="text"
|
||
v-model="form.realname"
|
||
placeholder="请输入您的真实姓名(如:张三)"
|
||
placeholder-class="profile__placeholder"
|
||
maxlength="20"
|
||
/>
|
||
</view>
|
||
<text class="profile__field-tip">用于微信零钱提现核验,须与微信支付实名姓名完全一致</text>
|
||
</view>
|
||
|
||
<!-- 绑定手机号(只读展示) -->
|
||
<view class="profile__field">
|
||
<text class="profile__label">绑定手机号</text>
|
||
<view class="profile__readonly-box">
|
||
<text class="profile__readonly-text">{{ displayPhone }}</text>
|
||
<text class="profile__verified-tag">已绑定</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 身份状态 -->
|
||
<view class="profile__field profile__field--last">
|
||
<text class="profile__label">当前身份</text>
|
||
<view class="profile__readonly-box" @click="goMerchant">
|
||
<view class="profile__role-info">
|
||
<text class="profile__readonly-text">{{ isBusiness ? '已认证同城商家' : '个人用户' }}</text>
|
||
<text v-if="isBusiness" class="profile__role-badge profile__role-badge--biz">已认证</text>
|
||
</view>
|
||
<text class="profile__arrow-link">{{ isBusiness ? '查看商家信息 ›' : '申请商家入驻 ›' }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 保存按钮 -->
|
||
<view class="profile__action">
|
||
<button
|
||
class="profile__btn profile__btn--primary"
|
||
:class="{ 'profile__btn--disabled': saving }"
|
||
@click="handleSave"
|
||
>
|
||
<text class="profile__btn-text">{{ saving ? '保存中…' : '保存修改' }}</text>
|
||
</button>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
/**
|
||
* 个人资料编辑页面
|
||
* 包含头像更换、微信快捷昵称同步与手动编辑。
|
||
* 遵循春绿视觉规范与函数级注释要求。
|
||
*/
|
||
import { useUserStore } from '@/common/store/index.js'
|
||
import authApi from '@/common/api/auth.js'
|
||
import { iconUrl } from '@/common/store/ui.js'
|
||
import { assetUrl, maskPhone } from '@/common/utils/format.js'
|
||
import FcNavbar from '@/components/fc-navbar/fc-navbar.vue'
|
||
|
||
export default {
|
||
components: { FcNavbar },
|
||
data() {
|
||
return {
|
||
saving: false,
|
||
pendingAvatar: '',
|
||
previewAvatar: '',
|
||
form: {
|
||
nickname: '',
|
||
realname: '',
|
||
},
|
||
}
|
||
},
|
||
computed: {
|
||
/**
|
||
* 用户全局信息
|
||
* @returns {Object}
|
||
*/
|
||
userInfo() {
|
||
try {
|
||
return useUserStore().state.userInfo || {}
|
||
} catch (e) {
|
||
return {}
|
||
}
|
||
},
|
||
/**
|
||
* 是否为已认证商家
|
||
* @returns {boolean}
|
||
*/
|
||
isBusiness() {
|
||
try {
|
||
return useUserStore().isBusiness.value
|
||
} catch (e) {
|
||
return false
|
||
}
|
||
},
|
||
/**
|
||
* 头像预览图
|
||
* @returns {string}
|
||
*/
|
||
avatarDisplay() {
|
||
if (this.previewAvatar) return this.previewAvatar
|
||
if (this.userInfo && this.userInfo.avatar) {
|
||
return assetUrl(this.userInfo.avatar)
|
||
}
|
||
return ''
|
||
},
|
||
/**
|
||
* 头像首字兜底
|
||
* @returns {string}
|
||
*/
|
||
avatarChar() {
|
||
const n = String(this.form.nickname || this.userInfo.nickname || '').trim()
|
||
return n ? n.slice(0, 1) : '用'
|
||
},
|
||
/**
|
||
* 脱敏手机号
|
||
* @returns {string}
|
||
*/
|
||
displayPhone() {
|
||
if (this.userInfo && this.userInfo.phone) {
|
||
return maskPhone(this.userInfo.phone)
|
||
}
|
||
return '未绑定'
|
||
},
|
||
},
|
||
/**
|
||
* 页面加载
|
||
*/
|
||
onLoad() {
|
||
this.initData()
|
||
},
|
||
methods: {
|
||
iconUrl,
|
||
/**
|
||
* 初始化表单数据
|
||
*/
|
||
initData() {
|
||
if (this.userInfo) {
|
||
this.form.nickname = this.userInfo.nickname || ''
|
||
this.form.realname = this.userInfo.realname || ''
|
||
}
|
||
},
|
||
/**
|
||
* 微信原生选择头像回调
|
||
* @param {Object} e 微信原生 chooseAvatar 回调事件
|
||
*/
|
||
onChooseAvatar(e) {
|
||
const temp = (e && e.detail && e.detail.avatarUrl) || ''
|
||
if (!temp) return
|
||
this.pendingAvatar = temp
|
||
this.previewAvatar = temp
|
||
},
|
||
/**
|
||
* 非小程序端选择头像
|
||
*/
|
||
chooseAvatarH5() {
|
||
uni.chooseImage({
|
||
count: 1,
|
||
success: (res) => {
|
||
const temp = (res.tempFilePaths && res.tempFilePaths[0]) || ''
|
||
if (!temp) return
|
||
this.pendingAvatar = temp
|
||
this.previewAvatar = temp
|
||
},
|
||
})
|
||
},
|
||
/**
|
||
* 跳转商家信息或商家认证
|
||
*/
|
||
goMerchant() {
|
||
uni.navigateTo({ url: '/pages/merchant/info' })
|
||
},
|
||
/**
|
||
* 保存个人资料修改
|
||
*/
|
||
async handleSave() {
|
||
if (this.saving) return
|
||
const nickname = this.form.nickname.trim()
|
||
if (!nickname) {
|
||
uni.showToast({ title: '请输入用户昵称', icon: 'none' })
|
||
return
|
||
}
|
||
const realname = (this.form.realname || '').trim()
|
||
if (realname && !/^[\u4e00-\u9fa5·]{2,20}$/.test(realname)) {
|
||
uni.showToast({ title: '真实姓名需为2-20位中文', icon: 'none' })
|
||
return
|
||
}
|
||
|
||
this.saving = true
|
||
try {
|
||
let avatarUrl = ''
|
||
// 若更换了头像,先上传临时文件到服务器
|
||
if (this.pendingAvatar) {
|
||
uni.showLoading({ title: '上传头像中…' })
|
||
const up = await authApi.uploadAvatar(this.pendingAvatar)
|
||
avatarUrl = (up && up.avatar) || ''
|
||
uni.hideLoading()
|
||
}
|
||
|
||
const payload = {
|
||
nickname,
|
||
realname,
|
||
}
|
||
if (avatarUrl) {
|
||
payload.avatar = avatarUrl
|
||
}
|
||
|
||
await authApi.saveProfile(payload)
|
||
await useUserStore().fetchProfile()
|
||
uni.showToast({ title: '资料保存成功', icon: 'success' })
|
||
|
||
setTimeout(() => {
|
||
uni.navigateBack()
|
||
}, 600)
|
||
} catch (err) {
|
||
uni.showToast({ title: (err && err.message) || '保存失败,请重试', icon: 'none' })
|
||
} finally {
|
||
this.saving = false
|
||
}
|
||
},
|
||
},
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.profile {
|
||
min-height: 100vh;
|
||
background-color: $fc-bg;
|
||
}
|
||
|
||
.profile__body {
|
||
padding: 24rpx 28rpx 60rpx;
|
||
}
|
||
|
||
.profile__card {
|
||
background: #ffffff;
|
||
border-radius: 28rpx;
|
||
padding: 36rpx 32rpx;
|
||
margin-bottom: 24rpx;
|
||
box-shadow: $fc-shadow-sm;
|
||
|
||
&--avatar {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
padding: 48rpx 32rpx 36rpx;
|
||
}
|
||
}
|
||
|
||
/* 头像外框与徽章 */
|
||
.profile__avatar-wrap {
|
||
position: relative;
|
||
width: 160rpx;
|
||
height: 160rpx;
|
||
}
|
||
|
||
.profile__avatar-btn {
|
||
width: 100%;
|
||
height: 100%;
|
||
border-radius: 50%;
|
||
background: #eef5f1;
|
||
border: 4rpx solid #ffffff;
|
||
box-shadow: 0 6rpx 20rpx rgba(4, 48, 30, 0.12);
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding: 0;
|
||
margin: 0;
|
||
overflow: hidden;
|
||
|
||
&::after {
|
||
border: none;
|
||
}
|
||
}
|
||
|
||
.profile__avatar-img {
|
||
width: 100%;
|
||
height: 100%;
|
||
}
|
||
|
||
.profile__avatar-char {
|
||
font-size: 64rpx;
|
||
font-weight: 700;
|
||
color: $fc-primary-text;
|
||
}
|
||
|
||
.profile__avatar-badge {
|
||
position: absolute;
|
||
right: 0;
|
||
bottom: 0;
|
||
width: 44rpx;
|
||
height: 44rpx;
|
||
border-radius: 50%;
|
||
background: #00e070;
|
||
border: 3rpx solid #ffffff;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.profile__avatar-camera {
|
||
width: 24rpx;
|
||
height: 24rpx;
|
||
}
|
||
|
||
.profile__avatar-tip {
|
||
margin-top: 18rpx;
|
||
font-size: 24rpx;
|
||
color: $fc-text-placeholder;
|
||
}
|
||
|
||
/* 表单字段 */
|
||
.profile__field {
|
||
margin-bottom: 32rpx;
|
||
|
||
&--last {
|
||
margin-bottom: 0;
|
||
}
|
||
}
|
||
|
||
.profile__label {
|
||
display: block;
|
||
font-size: 26rpx;
|
||
font-weight: 600;
|
||
color: $fc-text;
|
||
margin-bottom: 12rpx;
|
||
}
|
||
|
||
.profile__label-row {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
margin-bottom: 12rpx;
|
||
|
||
.profile__label {
|
||
margin-bottom: 0;
|
||
}
|
||
}
|
||
|
||
.profile__tag {
|
||
padding: 4rpx 14rpx;
|
||
border-radius: 8rpx;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
|
||
&--verified {
|
||
background: #e8fbf1;
|
||
.profile__tag-text {
|
||
font-size: 22rpx;
|
||
font-weight: 600;
|
||
color: #00a854;
|
||
}
|
||
}
|
||
|
||
&--pending {
|
||
background: #f1f5f9;
|
||
.profile__tag-text {
|
||
font-size: 22rpx;
|
||
color: #94a3b8;
|
||
}
|
||
}
|
||
}
|
||
|
||
.profile__input-wrap {
|
||
width: 100%;
|
||
height: 88rpx;
|
||
background: #f7faf8;
|
||
border-radius: 16rpx;
|
||
padding: 0 24rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.profile__input {
|
||
width: 100%;
|
||
height: 100%;
|
||
font-size: 28rpx;
|
||
color: $fc-text;
|
||
}
|
||
|
||
.profile__placeholder {
|
||
color: $fc-text-placeholder;
|
||
font-size: 26rpx;
|
||
}
|
||
|
||
.profile__field-tip {
|
||
display: block;
|
||
margin-top: 8rpx;
|
||
font-size: 22rpx;
|
||
color: $fc-text-placeholder;
|
||
}
|
||
|
||
/* 只读展示盒 */
|
||
.profile__readonly-box {
|
||
width: 100%;
|
||
height: 88rpx;
|
||
background: #f7faf8;
|
||
border-radius: 16rpx;
|
||
padding: 0 24rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.profile__readonly-text {
|
||
font-size: 28rpx;
|
||
color: $fc-text;
|
||
}
|
||
|
||
.profile__verified-tag {
|
||
font-size: 20rpx;
|
||
color: #04874a;
|
||
background: #e4fdf0;
|
||
padding: 4rpx 14rpx;
|
||
border-radius: $fc-radius-pill;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.profile__role-info {
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.profile__role-badge {
|
||
margin-left: 12rpx;
|
||
font-size: 20rpx;
|
||
padding: 2rpx 12rpx;
|
||
border-radius: $fc-radius-pill;
|
||
font-weight: 700;
|
||
|
||
&--biz {
|
||
background: #00e070;
|
||
color: #04301e;
|
||
}
|
||
}
|
||
|
||
.profile__arrow-link {
|
||
font-size: 24rpx;
|
||
color: $fc-primary-text;
|
||
font-weight: 500;
|
||
}
|
||
|
||
/* 底部按钮 */
|
||
.profile__action {
|
||
margin-top: 48rpx;
|
||
}
|
||
|
||
.profile__btn {
|
||
width: 100%;
|
||
height: 92rpx;
|
||
border-radius: 46rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
border: none;
|
||
box-sizing: border-box;
|
||
|
||
&::after {
|
||
border: none;
|
||
}
|
||
|
||
&--primary {
|
||
background: $fc-primary; /* #00E070 春绿 */
|
||
box-shadow: 0 8rpx 24rpx rgba(0, 224, 112, 0.32);
|
||
|
||
.profile__btn-text {
|
||
color: #04301e; /* 深墨绿 */
|
||
font-size: 32rpx;
|
||
font-weight: 700;
|
||
letter-spacing: 1rpx;
|
||
}
|
||
}
|
||
|
||
&--disabled {
|
||
opacity: 0.6;
|
||
pointer-events: none;
|
||
}
|
||
}
|
||
</style>
|