|
|
|
@ -8,7 +8,7 @@ import { computed, ref } from 'vue'
|
|
|
|
|
// 获取屏幕边界到安全区域距离
|
|
|
|
|
const { safeAreaInsets } = uni.getSystemInfoSync()
|
|
|
|
|
const isDev = import.meta.env.DEV
|
|
|
|
|
|
|
|
|
|
const memberStore = useMemberStore()
|
|
|
|
|
const domain = isDev ? 'http://192.168.0.166:8808' : 'http://222.71.165.188:8808'
|
|
|
|
|
|
|
|
|
|
// 获取个人信息,修改个人信息需提供初始值
|
|
|
|
@ -17,24 +17,20 @@ const headIcon = ref()
|
|
|
|
|
const getMemberProfileData = async () => {
|
|
|
|
|
const res = await getMemberProfileAPI()
|
|
|
|
|
const obj = res.data
|
|
|
|
|
const avatar = domain + JSON.parse(obj.headIcon).url
|
|
|
|
|
const avatar = domain + JSON.parse(obj.headIcon)[0].url
|
|
|
|
|
profile.value = {
|
|
|
|
|
avatar,
|
|
|
|
|
gender: obj.gender + '',
|
|
|
|
|
mobilePhone: obj.mobilePhone,
|
|
|
|
|
nickName: obj.nickName,
|
|
|
|
|
birthday: obj.birthday?.slice(0, 10),
|
|
|
|
|
staffsName: obj.staffsName || '',
|
|
|
|
|
}
|
|
|
|
|
// 头像
|
|
|
|
|
headIcon.value = obj.headIcon
|
|
|
|
|
// 同步 Store 的头像和昵称,用于我的页面展示
|
|
|
|
|
memberStore.profile!.avatar = avatar
|
|
|
|
|
memberStore.profile!.nickName = obj.nickName
|
|
|
|
|
memberStore.profile!.staffsName = obj.staffsName
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onLoad(() => {
|
|
|
|
|
getMemberProfileData()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const memberStore = useMemberStore()
|
|
|
|
|
// 修改头像
|
|
|
|
|
const onAvatarChange = () => {
|
|
|
|
|
uni.chooseMedia({
|
|
|
|
@ -59,7 +55,8 @@ const uploadFile = (file: string) => {
|
|
|
|
|
filePath: file,
|
|
|
|
|
success: (res) => {
|
|
|
|
|
if (res.statusCode === 200) {
|
|
|
|
|
headIcon.value = JSON.stringify(JSON.parse(res.data).data)
|
|
|
|
|
const target = [JSON.parse(res.data).data]
|
|
|
|
|
headIcon.value = JSON.stringify(target)
|
|
|
|
|
const avatar = JSON.parse(res.data).data.url
|
|
|
|
|
// 个人信息页数据更新
|
|
|
|
|
const imgUrl = domain + avatar
|
|
|
|
@ -79,28 +76,26 @@ const onGenderChange: UniHelper.RadioGroupOnChange = (ev) => {
|
|
|
|
|
profile.value.gender = ev.detail.value as Gender
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 修改生日
|
|
|
|
|
const onBirthdayChange: UniHelper.DatePickerOnChange = (ev) => {
|
|
|
|
|
profile.value.birthday = ev.detail.value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 点击保存提交表单
|
|
|
|
|
const onSubmit = async () => {
|
|
|
|
|
const { nickName, gender, birthday } = profile.value
|
|
|
|
|
const { staffsName, gender } = profile.value
|
|
|
|
|
const params = {
|
|
|
|
|
headIcon: headIcon.value,
|
|
|
|
|
nickName,
|
|
|
|
|
staffsName,
|
|
|
|
|
gender,
|
|
|
|
|
birthday: birthday + ' ' + '00:00:01',
|
|
|
|
|
}
|
|
|
|
|
const res = await postMemberProfileAPI(params)
|
|
|
|
|
// 更新Store昵称
|
|
|
|
|
memberStore.profile!.nickName = nickName
|
|
|
|
|
memberStore.profile!.staffsName = staffsName
|
|
|
|
|
uni.showToast({ icon: 'success', title: '保存成功' })
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
uni.navigateBack()
|
|
|
|
|
}, 400)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onLoad(() => {
|
|
|
|
|
getMemberProfileData()
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
@ -127,7 +122,7 @@ const onSubmit = async () => {
|
|
|
|
|
</view>
|
|
|
|
|
<view class="form-item">
|
|
|
|
|
<text class="label">昵称</text>
|
|
|
|
|
<input class="input" type="text" placeholder="请填写昵称" v-model="profile.nickName" />
|
|
|
|
|
<input class="input" type="text" placeholder="请填写昵称" v-model="profile.staffsName" />
|
|
|
|
|
</view>
|
|
|
|
|
<view class="form-item">
|
|
|
|
|
<text class="label">性别</text>
|
|
|
|
@ -142,20 +137,6 @@ const onSubmit = async () => {
|
|
|
|
|
</label>
|
|
|
|
|
</radio-group>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="form-item">
|
|
|
|
|
<text class="label">生日</text>
|
|
|
|
|
<picker
|
|
|
|
|
@change="onBirthdayChange"
|
|
|
|
|
mode="date"
|
|
|
|
|
class="picker"
|
|
|
|
|
:value="profile?.birthday"
|
|
|
|
|
start="1900-01-01"
|
|
|
|
|
:end="formatDate(new Date())"
|
|
|
|
|
>
|
|
|
|
|
<view v-if="profile?.birthday">{{ profile?.birthday }}</view>
|
|
|
|
|
<view class="placeholder" v-else>请选择日期</view>
|
|
|
|
|
</picker>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 提交按钮 -->
|
|
|
|
|
<button @tap="onSubmit" class="form-button">保 存</button>
|
|
|
|
@ -292,5 +273,4 @@ page {
|
|
|
|
|
background: linear-gradient(158deg, #51B6FF -10%, #3775F6 129%);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>import type { parse } from 'path'
|
|
|
|
|
|
|
|
|
|
</style>
|
|
|
|
|