sc
This commit is contained in:
@@ -40,3 +40,11 @@ export const getAccountInfo = async 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-control">
|
||||
<input
|
||||
v-model="userInfo.name"
|
||||
v-model="userInfo.nickname"
|
||||
class="form-input"
|
||||
placeholder="请输入姓名"
|
||||
maxlength="20"
|
||||
@@ -40,7 +40,7 @@
|
||||
<view class="form-label">手机号</view>
|
||||
<view class="form-control">
|
||||
<input
|
||||
v-model="userInfo.phone"
|
||||
v-model="userInfo.mobile"
|
||||
class="form-input"
|
||||
placeholder="请输入手机号"
|
||||
maxlength="15"
|
||||
@@ -60,11 +60,12 @@
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<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 class="info-item">
|
||||
<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>
|
||||
@@ -73,33 +74,35 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from "vue"
|
||||
|
||||
// 性别选项
|
||||
const genders = ['男', '女', '保密']
|
||||
import { getPersonAccount, updateAccount } from "@/api/account"
|
||||
|
||||
// 用户信息
|
||||
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 userInfo = ref({})
|
||||
|
||||
// 计算用户名首字母
|
||||
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(() => {
|
||||
// 实际项目中应从接口获取用户信息
|
||||
// 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() {
|
||||
uni.navigateBack({ delta: 1 })
|
||||
@@ -121,11 +124,11 @@
|
||||
// 保存个人信息
|
||||
function saveInfo() {
|
||||
// 表单验证
|
||||
if (!userInfo.value.name) {
|
||||
if (!userInfo.value.nickname) {
|
||||
uni.showToast({ title: '请输入姓名', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!userInfo.value.phone) {
|
||||
if (!userInfo.value.mobile) {
|
||||
uni.showToast({ title: '请输入手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
@@ -133,12 +136,25 @@
|
||||
// 实际项目中应调用接口保存信息
|
||||
uni.showLoading({ title: '保存中...' })
|
||||
|
||||
setTimeout(() => {
|
||||
updateAccount({
|
||||
id: userInfo.value.id,
|
||||
nickname: userInfo.value.nickname,
|
||||
mobile: userInfo.value.mobile
|
||||
}).then(res => {
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: '保存成功', icon: 'success' })
|
||||
console.log(res)
|
||||
if (res.code == '0000') {
|
||||
uni.showToast({
|
||||
title: '保存成功',
|
||||
icon: 'success'
|
||||
})
|
||||
// 保存成功后返回上一页
|
||||
setTimeout(() => {
|
||||
goBack()
|
||||
}, 1000)
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -59,6 +59,7 @@ const request = config => {
|
||||
resolve(res.data);
|
||||
})
|
||||
.catch(error => {
|
||||
debugger;
|
||||
let { message } = error;
|
||||
if (message === 'Network Error') {
|
||||
message = '后端接口连接异常';
|
||||
|
||||
Reference in New Issue
Block a user