|
|
@@ -112,6 +112,7 @@
|
|
|
<script>
|
|
|
import ayToast from '@/components/ay-toast/ay-toast.nvue'
|
|
|
import { addGroupMember, updateGroupMember, getGroupMembers } from '@/utils/api/group.js'
|
|
|
+import { getProfile, updateProfile } from '@/utils/api/user.js'
|
|
|
|
|
|
export default {
|
|
|
components: {
|
|
|
@@ -121,6 +122,7 @@ export default {
|
|
|
return {
|
|
|
statusBarHeight: 44,
|
|
|
mode: 'add', // add / edit
|
|
|
+ source: '', // '' = group member, 'profile' = current user profile
|
|
|
groupId: '',
|
|
|
profileId: '',
|
|
|
form: {
|
|
|
@@ -140,9 +142,13 @@ export default {
|
|
|
const sysInfo = uni.getSystemInfoSync()
|
|
|
this.statusBarHeight = sysInfo.statusBarHeight || 44
|
|
|
this.mode = options.mode || 'add'
|
|
|
+ this.source = options.source || ''
|
|
|
this.groupId = options.groupId || ''
|
|
|
this.profileId = options.profileId || ''
|
|
|
- if (this.mode === 'edit' && this.profileId) {
|
|
|
+ if (this.source === 'profile') {
|
|
|
+ // 公共设备:加载当前账号个人资料
|
|
|
+ this.loadProfileData()
|
|
|
+ } else if (this.mode === 'edit' && this.profileId) {
|
|
|
this.loadUserData()
|
|
|
}
|
|
|
},
|
|
|
@@ -150,6 +156,25 @@ export default {
|
|
|
goBack() {
|
|
|
uni.navigateBack()
|
|
|
},
|
|
|
+ /** 加载个人资料数据(公共设备模式) */
|
|
|
+ async loadProfileData() {
|
|
|
+ try {
|
|
|
+ const profile = await getProfile()
|
|
|
+ if (profile) {
|
|
|
+ this.form.name = profile.name || ''
|
|
|
+ this.form.gender = profile.gender || 1
|
|
|
+ this.form.age = profile.age ? String(profile.age) : ''
|
|
|
+ this.form.phone = profile.phone || ''
|
|
|
+ this.form.shoulderWidth = profile.shoulderWidth ? String(profile.shoulderWidth) : ''
|
|
|
+ this.form.height = profile.height ? String(profile.height) : ''
|
|
|
+ this.form.weight = profile.weight ? String(profile.weight) : ''
|
|
|
+ this.form.bodyHeight = profile.bodyHeight ? String(profile.bodyHeight) : ''
|
|
|
+ this.form.spineLength = profile.spineLength ? String(profile.spineLength) : ''
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.error('加载个人资料失败:', e)
|
|
|
+ }
|
|
|
+ },
|
|
|
/** 加载编辑数据 - 从后端获取群组成员列表中查找当前成员 */
|
|
|
async loadUserData() {
|
|
|
try {
|
|
|
@@ -192,7 +217,11 @@ export default {
|
|
|
if (this.form.spineLength) params.spineLength = Number(this.form.spineLength)
|
|
|
|
|
|
try {
|
|
|
- if (this.mode === 'add') {
|
|
|
+ if (this.source === 'profile') {
|
|
|
+ // 公共设备:调用修改个人资料接口
|
|
|
+ await updateProfile(params)
|
|
|
+ this.$refs.ayToast.success('保存成功')
|
|
|
+ } else if (this.mode === 'add') {
|
|
|
await addGroupMember(this.groupId, params)
|
|
|
this.$refs.ayToast.success('添加成功')
|
|
|
} else {
|