feat: 删除发现页、添加隐私授权、修复头像上传
This commit is contained in:
@@ -6,5 +6,6 @@
|
|||||||
"connectSocket": 10000,
|
"connectSocket": 10000,
|
||||||
"uploadFile": 10000,
|
"uploadFile": 10000,
|
||||||
"downloadFile": 10000
|
"downloadFile": 10000
|
||||||
}
|
},
|
||||||
|
"__usePrivacyCheck__": true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -374,7 +374,6 @@ export default class HomeScene extends BaseScene {
|
|||||||
|
|
||||||
const tabs = [
|
const tabs = [
|
||||||
{ icon: '🏠', label: '首页' },
|
{ icon: '🏠', label: '首页' },
|
||||||
{ icon: '🔥', label: '发现' },
|
|
||||||
{ icon: '✨', label: '创作' },
|
{ icon: '✨', label: '创作' },
|
||||||
{ icon: '👤', label: '我的' }
|
{ icon: '👤', label: '我的' }
|
||||||
];
|
];
|
||||||
@@ -395,7 +394,7 @@ export default class HomeScene extends BaseScene {
|
|||||||
ctx.fill();
|
ctx.fill();
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.font = index === 2 ? '24px sans-serif' : '20px sans-serif';
|
ctx.font = index === 1 ? '24px sans-serif' : '20px sans-serif';
|
||||||
ctx.textAlign = 'center';
|
ctx.textAlign = 'center';
|
||||||
ctx.fillText(tab.icon, centerX, y + 28);
|
ctx.fillText(tab.icon, centerX, y + 28);
|
||||||
|
|
||||||
@@ -503,7 +502,7 @@ export default class HomeScene extends BaseScene {
|
|||||||
|
|
||||||
// 底部Tab点击
|
// 底部Tab点击
|
||||||
if (y > this.screenHeight - 60) {
|
if (y > this.screenHeight - 60) {
|
||||||
const tabW = this.screenWidth / 4;
|
const tabW = this.screenWidth / 3; // 3个Tab
|
||||||
const tabIndex = Math.floor(x / tabW);
|
const tabIndex = Math.floor(x / tabW);
|
||||||
this.handleBottomTabClick(tabIndex);
|
this.handleBottomTabClick(tabIndex);
|
||||||
return;
|
return;
|
||||||
@@ -551,14 +550,12 @@ export default class HomeScene extends BaseScene {
|
|||||||
if (tabIndex === this.bottomTab && tabIndex === 0) return;
|
if (tabIndex === this.bottomTab && tabIndex === 0) return;
|
||||||
|
|
||||||
if (tabIndex === 0) {
|
if (tabIndex === 0) {
|
||||||
|
// 首页
|
||||||
this.bottomTab = 0;
|
this.bottomTab = 0;
|
||||||
} else if (tabIndex === 1) {
|
} else if (tabIndex === 1) {
|
||||||
// 发现页(可跳转或在本页切换)
|
|
||||||
this.bottomTab = 1;
|
|
||||||
} else if (tabIndex === 2) {
|
|
||||||
// 创作页
|
// 创作页
|
||||||
this.main.sceneManager.switchScene('aiCreate');
|
this.main.sceneManager.switchScene('aiCreate');
|
||||||
} else if (tabIndex === 3) {
|
} else if (tabIndex === 2) {
|
||||||
// 我的
|
// 我的
|
||||||
this.main.sceneManager.switchScene('profile');
|
this.main.sceneManager.switchScene('profile');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1461,6 +1461,42 @@ export default class ProfileScene extends BaseScene {
|
|||||||
// 选择并上传头像
|
// 选择并上传头像
|
||||||
chooseAndUploadAvatar() {
|
chooseAndUploadAvatar() {
|
||||||
console.log('[ProfileScene] 开始选择头像');
|
console.log('[ProfileScene] 开始选择头像');
|
||||||
|
|
||||||
|
// 检查隐私授权状态
|
||||||
|
if (wx.getPrivacySetting) {
|
||||||
|
wx.getPrivacySetting({
|
||||||
|
success: (res) => {
|
||||||
|
console.log('[ProfileScene] 隐私设置:', res);
|
||||||
|
if (res.needAuthorization) {
|
||||||
|
// 需要授权,弹出隐私弹窗
|
||||||
|
wx.requirePrivacyAuthorize({
|
||||||
|
success: () => {
|
||||||
|
console.log('[ProfileScene] 隐私授权成功');
|
||||||
|
this.doChooseMedia();
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.error('[ProfileScene] 隐私授权失败:', err);
|
||||||
|
wx.showToast({ title: '需要授权才能选择图片', icon: 'none' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 已授权,直接选择图片
|
||||||
|
this.doChooseMedia();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
// 获取隐私设置失败,尝试直接调用
|
||||||
|
this.doChooseMedia();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 不支持隐私API,直接调用
|
||||||
|
this.doChooseMedia();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 实际选择图片
|
||||||
|
doChooseMedia() {
|
||||||
wx.chooseMedia({
|
wx.chooseMedia({
|
||||||
count: 1,
|
count: 1,
|
||||||
mediaType: ['image'],
|
mediaType: ['image'],
|
||||||
@@ -1516,7 +1552,7 @@ export default class ProfileScene extends BaseScene {
|
|||||||
uploadAvatar(filePath) {
|
uploadAvatar(filePath) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const token = this.main.userManager.token || '';
|
const token = this.main.userManager.token || '';
|
||||||
const baseUrl = 'http://172.20.10.8:8000'; // 与 http.js 保持一致
|
const baseUrl = 'http://localhost:8002'; // 与 http.js 保持一致
|
||||||
|
|
||||||
wx.uploadFile({
|
wx.uploadFile({
|
||||||
url: `${baseUrl}/api/upload/avatar`,
|
url: `${baseUrl}/api/upload/avatar`,
|
||||||
|
|||||||
Reference in New Issue
Block a user