11
This commit is contained in:
parent
d7f7180e80
commit
0b395638ed
File diff suppressed because it is too large
Load Diff
@ -85,12 +85,18 @@
|
|||||||
</view>
|
</view>
|
||||||
</u-modal>
|
</u-modal>
|
||||||
|
|
||||||
<u-modal :show="showPhoneDialog" title="联系社区" confirm-text="拨打" cancel-text="取消" @confirm="callCommunityPhone"
|
<u-modal
|
||||||
@cancel="showPhoneDialog = false">
|
:show="showPhoneDialog"
|
||||||
<view class="phone-dialog-content">
|
title="联系社区"
|
||||||
<text>社区电话:</text>
|
confirm-text="拨打"
|
||||||
<text class="phone-number">{{communityPhone}}</text>
|
cancel-text="取消"
|
||||||
</view>
|
@confirm="callCommunityPhone"
|
||||||
|
@cancel="showPhoneDialog = false"
|
||||||
|
:closeOnClickOverlay="true">
|
||||||
|
<view class="phone-dialog-content">
|
||||||
|
<text>社区电话:</text>
|
||||||
|
<text class="phone-number">{{communityPhone}}</text>
|
||||||
|
</view>
|
||||||
</u-modal>
|
</u-modal>
|
||||||
|
|
||||||
<Footer></Footer>
|
<Footer></Footer>
|
||||||
@ -173,6 +179,9 @@
|
|||||||
this.initData();
|
this.initData();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleCloseModal() {
|
||||||
|
this.showPhoneDialog = false;
|
||||||
|
},
|
||||||
// 初始化数据
|
// 初始化数据
|
||||||
async initData() {
|
async initData() {
|
||||||
const token = uni.getStorageSync('token');
|
const token = uni.getStorageSync('token');
|
||||||
@ -197,15 +206,18 @@
|
|||||||
|
|
||||||
// 更新用户信息
|
// 更新用户信息
|
||||||
updateUserInfo(data) {
|
updateUserInfo(data) {
|
||||||
|
// 显示时拼接IMAGE_BASE_URL
|
||||||
|
const avatarUrl = data.avatar ? `${IMAGE_BASE_URL}${data.avatar}` : '/static/imgs/index/nav.png';
|
||||||
|
|
||||||
this.userInfo = {
|
this.userInfo = {
|
||||||
nickName: data.name || data.nickName || '未命名用户',
|
nickName: data.name || data.nickName || '未命名用户',
|
||||||
avatarUrl: data.avatar || data.avatarUrl || '/static/imgs/index/nav.png',
|
avatarUrl: avatarUrl,
|
||||||
bio: data.introduce || data.bio || '这家伙很懒,什么都没有写~',
|
bio: data.introduce || data.bio || '这家伙很懒,什么都没有写~',
|
||||||
phone: data.phone || ''
|
phone: data.phone || ''
|
||||||
};
|
};
|
||||||
|
|
||||||
// 更新显示头像
|
// 更新显示头像
|
||||||
this.displayAvatar = this.userInfo.avatarUrl || '/static/imgs/index/nav.png';
|
this.displayAvatar = this.userInfo.avatarUrl;
|
||||||
|
|
||||||
this.formData = {
|
this.formData = {
|
||||||
name: this.userInfo.nickName,
|
name: this.userInfo.nickName,
|
||||||
@ -366,13 +378,14 @@
|
|||||||
// 登录完成处理
|
// 登录完成处理
|
||||||
async loginComplete(data) {
|
async loginComplete(data) {
|
||||||
try {
|
try {
|
||||||
// 获取最新用户信息
|
// 获取最新用户信息
|
||||||
|
this.showEditModal = false;
|
||||||
const res = await get('/api/v1/app_auth/mine');
|
const res = await get('/api/v1/app_auth/mine');
|
||||||
if (res && res.success) {
|
if (res && res.success) {
|
||||||
uni.setStorageSync('userInfo', res.data);
|
uni.setStorageSync('userInfo', res.data);
|
||||||
this.updateUserInfo(res.data);
|
this.updateUserInfo(res.data);
|
||||||
this.isLogin = true;
|
this.isLogin = true;
|
||||||
this.showEditModal = false;
|
// this.showEditModal = false;
|
||||||
this.showPhoneButton = false;
|
this.showPhoneButton = false;
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '登录成功'
|
title: '登录成功'
|
||||||
@ -413,7 +426,7 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (fileInfo.size > 2 * 1024 * 1024) {
|
if (fileInfo.size > 3 * 1024 * 1024) {
|
||||||
throw new Error('图片大小不能超过2MB');
|
throw new Error('图片大小不能超过2MB');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,7 +464,7 @@
|
|||||||
try {
|
try {
|
||||||
const res = JSON.parse(uploadRes.data);
|
const res = JSON.parse(uploadRes.data);
|
||||||
if (res && res.success) {
|
if (res && res.success) {
|
||||||
resolve(`${IMAGE_BASE_URL}${res.data}`);
|
resolve(res.data);
|
||||||
} else {
|
} else {
|
||||||
reject(new Error(res.message || '上传失败'));
|
reject(new Error(res.message || '上传失败'));
|
||||||
}
|
}
|
||||||
@ -506,7 +519,12 @@
|
|||||||
name,
|
name,
|
||||||
bio
|
bio
|
||||||
} = this.formData;
|
} = this.formData;
|
||||||
const avatarUrl = this.avatarList.length > 0 ? this.avatarList[0].url : "";
|
console.log("====", this.avatarList)
|
||||||
|
let avatarUrl = this.avatarList.length > 0 ? this.avatarList[0].url : "";
|
||||||
|
|
||||||
|
if (avatarUrl && avatarUrl.includes(IMAGE_BASE_URL)) {
|
||||||
|
avatarUrl = avatarUrl.replace(IMAGE_BASE_URL, '');
|
||||||
|
}
|
||||||
|
|
||||||
if (!name) {
|
if (!name) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@ -534,12 +552,13 @@
|
|||||||
// 3. 更新本地存储和页面数据
|
// 3. 更新本地存储和页面数据
|
||||||
uni.setStorageSync('userInfo', res.data);
|
uni.setStorageSync('userInfo', res.data);
|
||||||
this.updateUserInfo(res.data);
|
this.updateUserInfo(res.data);
|
||||||
|
this.showEditModal = false;
|
||||||
|
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '修改成功'
|
title: '修改成功'
|
||||||
});
|
});
|
||||||
this.showEditModal = false;
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error(res.message || '获取用户信息失败');
|
throw new Error(res.message || '获取用户信息失败');
|
||||||
}
|
}
|
||||||
@ -559,38 +578,49 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 跳转页面
|
// 跳转页面
|
||||||
// 跳转页面
|
// 跳转页面
|
||||||
goPage(item) {
|
goPage(item) {
|
||||||
if (item.key === 6) { // 联系社区的特殊处理
|
if (item.key === 6) { // 联系社区的特殊处理
|
||||||
this.handleContactCommunity();
|
this.handleContactCommunity();
|
||||||
return;
|
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
if (item.key === 5) { // 设置的特殊处理
|
|
||||||
this.handleEditClick(); // 调用编辑用户信息的方法
|
if (item.key === 5) { // 设置的特殊处理
|
||||||
return;
|
this.handleEditClick(); // 调用编辑用户信息的方法
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
if (!this.checkLogin()) {
|
|
||||||
this.showEditModal = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.pageUrl) {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: `/pages/${item.pageUrl}/index`
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// 处理联系社区点击
|
|
||||||
handleContactCommunity() {
|
|
||||||
if (!this.checkLogin()) {
|
if (!this.checkLogin()) {
|
||||||
this.showEditModal = true;
|
this.showEditModal = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showPhoneDialog = true;
|
if (item.pageUrl) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/${item.pageUrl}/index`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 处理联系社区点击
|
||||||
|
handleContactCommunity() {
|
||||||
|
if (!this.checkLogin()) {
|
||||||
|
this.showEditModal = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.showModal({
|
||||||
|
title: '联系社区',
|
||||||
|
content: '是否要拨打社区电话:' + this.communityPhone,
|
||||||
|
confirmText: '拨打',
|
||||||
|
cancelText: '取消',
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
this.callCommunityPhone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 拨打社区电话
|
// 拨打社区电话
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user