sc
This commit is contained in:
@@ -40,3 +40,11 @@ export const getAccountInfo = async id => {
|
|||||||
params: { id }
|
params: { id }
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 获取个人账号详情
|
||||||
|
export const getPersonAccount = async () => {
|
||||||
|
return request({
|
||||||
|
url: '/applet/xunjia/account/person/get',
|
||||||
|
method: 'get'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
<view class="form-label">姓名</view>
|
<view class="form-label">姓名</view>
|
||||||
<view class="form-control">
|
<view class="form-control">
|
||||||
<input
|
<input
|
||||||
v-model="userInfo.name"
|
v-model="userInfo.nickname"
|
||||||
class="form-input"
|
class="form-input"
|
||||||
placeholder="请输入姓名"
|
placeholder="请输入姓名"
|
||||||
maxlength="20"
|
maxlength="20"
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
<view class="form-label">手机号</view>
|
<view class="form-label">手机号</view>
|
||||||
<view class="form-control">
|
<view class="form-control">
|
||||||
<input
|
<input
|
||||||
v-model="userInfo.phone"
|
v-model="userInfo.mobile"
|
||||||
class="form-input"
|
class="form-input"
|
||||||
placeholder="请输入手机号"
|
placeholder="请输入手机号"
|
||||||
maxlength="15"
|
maxlength="15"
|
||||||
@@ -60,11 +60,12 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="info-item">
|
<view class="info-item">
|
||||||
<view class="info-label">注册时间</view>
|
<view class="info-label">注册时间</view>
|
||||||
<view class="info-value">{{ userInfo.registerTime || '2026-01-01' }}</view>
|
<!-- 时间转YYYY-MM-DD -->
|
||||||
|
<view class="info-value">{{ new Date(userInfo.createTime).toLocaleDateString() }}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="info-item">
|
<view class="info-item">
|
||||||
<view class="info-label">最后登录</view>
|
<view class="info-label">最后登录</view>
|
||||||
<view class="info-value">{{ userInfo.lastLogin || '2026-01-29' }}</view>
|
<view class="info-value">{{ new Date(userInfo.loginDate).toLocaleDateString() }}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -73,33 +74,35 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onMounted } from "vue"
|
import { ref, computed, onMounted } from "vue"
|
||||||
|
import { getPersonAccount, updateAccount } from "@/api/account"
|
||||||
|
|
||||||
// 性别选项
|
|
||||||
const genders = ['男', '女', '保密']
|
|
||||||
|
|
||||||
// 用户信息
|
// 用户信息
|
||||||
const userInfo = ref({
|
const userInfo = ref({})
|
||||||
name: '李教练',
|
|
||||||
phone: '13900139000',
|
|
||||||
gender: '男',
|
|
||||||
school: '顺达驾校',
|
|
||||||
position: '科目二教练',
|
|
||||||
bio: '拥有10年驾驶教学经验,擅长科目二倒车入库教学',
|
|
||||||
id: '10002',
|
|
||||||
registerTime: '2026-01-15',
|
|
||||||
lastLogin: '2026-01-29 10:30:00'
|
|
||||||
})
|
|
||||||
|
|
||||||
// 计算用户名首字母
|
// 计算用户名首字母
|
||||||
const userInitial = computed(() => {
|
const userInitial = computed(() => {
|
||||||
return userInfo.value.name ? userInfo.value.name.charAt(0).toUpperCase() : 'U'
|
return userInfo.value.nickname ? userInfo.value.nickname.charAt(0).toUpperCase() : 'U'
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// 实际项目中应从接口获取用户信息
|
// 实际项目中应从接口获取用户信息
|
||||||
// loadUserInfo()
|
loadUserInfo()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const loadUserInfo = async () => {
|
||||||
|
try {
|
||||||
|
const res = await getPersonAccount()
|
||||||
|
if (res.code == '0000') {
|
||||||
|
userInfo.value = res.data || {}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
uni.showToast({
|
||||||
|
title: err.message || '获取用户信息失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 返回上一页
|
// 返回上一页
|
||||||
function goBack() {
|
function goBack() {
|
||||||
uni.navigateBack({ delta: 1 })
|
uni.navigateBack({ delta: 1 })
|
||||||
@@ -121,11 +124,11 @@
|
|||||||
// 保存个人信息
|
// 保存个人信息
|
||||||
function saveInfo() {
|
function saveInfo() {
|
||||||
// 表单验证
|
// 表单验证
|
||||||
if (!userInfo.value.name) {
|
if (!userInfo.value.nickname) {
|
||||||
uni.showToast({ title: '请输入姓名', icon: 'none' })
|
uni.showToast({ title: '请输入姓名', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!userInfo.value.phone) {
|
if (!userInfo.value.mobile) {
|
||||||
uni.showToast({ title: '请输入手机号', icon: 'none' })
|
uni.showToast({ title: '请输入手机号', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -133,11 +136,24 @@
|
|||||||
// 实际项目中应调用接口保存信息
|
// 实际项目中应调用接口保存信息
|
||||||
uni.showLoading({ title: '保存中...' })
|
uni.showLoading({ title: '保存中...' })
|
||||||
|
|
||||||
setTimeout(() => {
|
updateAccount({
|
||||||
|
id: userInfo.value.id,
|
||||||
|
nickname: userInfo.value.nickname,
|
||||||
|
mobile: userInfo.value.mobile
|
||||||
|
}).then(res => {
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
uni.showToast({ title: '保存成功', icon: 'success' })
|
console.log(res)
|
||||||
goBack()
|
if (res.code == '0000') {
|
||||||
}, 1000)
|
uni.showToast({
|
||||||
|
title: '保存成功',
|
||||||
|
icon: 'success'
|
||||||
|
})
|
||||||
|
// 保存成功后返回上一页
|
||||||
|
setTimeout(() => {
|
||||||
|
goBack()
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ const request = config => {
|
|||||||
resolve(res.data);
|
resolve(res.data);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
debugger;
|
||||||
let { message } = error;
|
let { message } = error;
|
||||||
if (message === 'Network Error') {
|
if (message === 'Network Error') {
|
||||||
message = '后端接口连接异常';
|
message = '后端接口连接异常';
|
||||||
|
|||||||
Reference in New Issue
Block a user