功能完善

This commit is contained in:
2024-04-13 00:57:24 +08:00
parent 93e9c5227b
commit be328f9243
14 changed files with 244 additions and 107 deletions

View File

@@ -2,7 +2,7 @@
<view class='content'>
<view class='top-card-view'>
<image class='bg-image' :src='companyConfigInfo.userbgcover' />
<image class='avatar-image' :src='params.avatarUrl' />
<image class='avatar-image' :src='params.image' />
<text>{{ userInfo.name }}</text>
<text>{{ userInfo.levelName }}</text>
</view>
@@ -11,7 +11,7 @@
<view class='c-flex-row'>
<text>头像</text>
<view class='avatar-view'>
<image class='avatar-image' :src='params.avatarUrl' />
<image class='avatar-image' :src='params.image' />
<button class='avatar-btn' open-type='chooseAvatar' @chooseavatar='chooseAvatar' />
</view>
</view>
@@ -24,7 +24,9 @@
<view class='divider' />
<view class='c-flex-row'>
<text>手机号</text>
<input placeholder='请输入手机号' v-model='userInfo.telephone' @input='bindTelephone' />
<input placeholder='请输入手机号' :disabled='userInfo.telephone.length!=0'
v-model='params.telephone'
@input='bindTelephone' />
</view>
<view class='divider' />
@@ -32,12 +34,12 @@
<text>性别</text>
<view class='c-flex-row' @click.stop='changeGender(0)'>
<image class='gender-image'
:src='assetsUrl(params?.gender==0?"ic_checkbox_active.png":"ic_checkbox_normal.png")' />
:src='assetsUrl(params?.gender=="男"?"ic_checkbox_active.png":"ic_checkbox_normal.png")' />
<text class='gender-text'></text>
</view>
<view class='c-flex-row' @click.stop='changeGender(1)'>
<image class='gender-image'
:src='assetsUrl(params?.gender==1?"ic_checkbox_active.png":"ic_checkbox_normal.png")' />
:src='assetsUrl(params?.gender=="女"?"ic_checkbox_active.png":"ic_checkbox_normal.png")' />
<text class='gender-text'></text>
</view>
</view>
@@ -45,7 +47,7 @@
<view class='divider' />
<view class='c-flex-row'>
<text>生日</text>
<picker mode='date' @change='changeDate'>
<picker mode='date' :disabled='userInfo.birthday!=""' @change='changeDate'>
<text>{{ params?.birthday || '请选择生日' }}</text>
</picker>
</view>
@@ -59,16 +61,18 @@
import { assetsUrl } from '@/utils/assets';
import { useUserStore } from '@/store';
import { showToast } from '@/utils';
import { updateProfile } from '@/api/user';
import dayjs from 'dayjs';
const store = useUserStore();
const { userInfo,companyConfigInfo } = storeToRefs(store);
const { userInfo, companyConfigInfo } = storeToRefs(store);
const params = ref<{
avatarUrl: string;
avatarUrl: string | undefined;
image: string;
nickName: string;
telephone: string;
gender: number;
gender: string;
birthday: string;
}>({
avatarUrl: userInfo.value.image,
@@ -106,7 +110,6 @@ const chooseAvatar = (e: any) => {
};
const bindNickname = (e: any) => {
console.log('---------->>>>', e.detail.value);
params.value!.nickName = e.detail.value;
};
@@ -115,7 +118,7 @@ const bindTelephone = (e: any) => {
};
const changeGender = (index: number) => {
params.value!.gender = index;
params.value!.gender = index == 0 ? '男' : '女';
};
const changeDate = (e: any) => {
@@ -123,13 +126,30 @@ const changeDate = (e: any) => {
};
const save = async () => {
console.log('---------->>>>', params.value);
const newUserInfo = {
...userInfo.value,
...params.value
};
console.log('---------->>>>', newUserInfo);
store.setUserInfo(newUserInfo);
delete params.value.avatarUrl;
const result = await updateProfile({
...params.value,
birthday: dayjs(params.value.birthday).format('YYYY-MM-DD HH:mm:ss'),
birthdayType: 0
});
if(result) {
await store.setUserInfo(newUserInfo);
uni.showToast({
title: '修改成功',
icon: 'success',
duration: 2000,
success(result) {
uni.navigateBack();
}
});
}
};
</script>