fix: make content api
This commit is contained in:
@@ -71,15 +71,11 @@
|
|||||||
<view v-if="activeTool === 'avatar'" class="section">
|
<view v-if="activeTool === 'avatar'" class="section">
|
||||||
<view class="section-title">选择头像</view>
|
<view class="section-title">选择头像</view>
|
||||||
<view class="grid">
|
<view class="grid">
|
||||||
<view class="grid-item upload-card">
|
<view class="grid-item upload-card" @tap="onChooseAlbum">
|
||||||
<button
|
<view class="wechat-avatar-btn">
|
||||||
class="wechat-avatar-btn"
|
|
||||||
open-type="chooseAvatar"
|
|
||||||
@chooseavatar="onChooseAvatar"
|
|
||||||
>
|
|
||||||
<view class="upload-icon">✨</view>
|
<view class="upload-icon">✨</view>
|
||||||
<text class="upload-text">微信头像</text>
|
<text class="upload-text">上传头像</text>
|
||||||
</button>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
v-for="item in systemAvatars"
|
v-for="item in systemAvatars"
|
||||||
@@ -201,6 +197,7 @@ import {
|
|||||||
uploadImage,
|
uploadImage,
|
||||||
} from "@/utils/common.js";
|
} from "@/utils/common.js";
|
||||||
import NavBar from "@/components/NavBar/NavBar.vue";
|
import NavBar from "@/components/NavBar/NavBar.vue";
|
||||||
|
import LoginPopup from "@/components/LoginPopup/LoginPopup.vue";
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const loginPopupRef = ref(null);
|
const loginPopupRef = ref(null);
|
||||||
@@ -462,16 +459,38 @@ const handleLogind = async () => {
|
|||||||
// Logic after successful login if needed
|
// Logic after successful login if needed
|
||||||
};
|
};
|
||||||
|
|
||||||
const onChooseAvatar = async (e) => {
|
const onChooseAlbum = () => {
|
||||||
const avatarUrl = e.detail.avatarUrl;
|
uni.chooseImage({
|
||||||
if (!avatarUrl) return;
|
count: 1,
|
||||||
|
sizeType: ["original", "compressed"],
|
||||||
|
sourceType: ["album"],
|
||||||
|
success: (res) => {
|
||||||
|
const path = res.tempFilePaths[0];
|
||||||
|
// 调用系统裁剪,强制 1:1
|
||||||
|
uni.cropImage({
|
||||||
|
src: path,
|
||||||
|
aspectRatio: "1:1",
|
||||||
|
success: (cropRes) => {
|
||||||
|
onAvatarSelect(cropRes.tempFilePath);
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.warn("Crop failed or cancelled", err);
|
||||||
|
onAvatarSelect(path);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const onAvatarSelect = async (url) => {
|
||||||
|
if (!url) return;
|
||||||
|
|
||||||
uni.showLoading({ title: "上传中...", mask: true });
|
uni.showLoading({ title: "上传中...", mask: true });
|
||||||
try {
|
try {
|
||||||
const imageUrl = await uploadImage(avatarUrl);
|
const imageUrl = await uploadImage(url);
|
||||||
|
|
||||||
currentAvatar.value = {
|
currentAvatar.value = {
|
||||||
id: "wechat_" + Date.now(),
|
id: "custom_" + Date.now(),
|
||||||
imageUrl: imageUrl,
|
imageUrl: imageUrl,
|
||||||
};
|
};
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const BASE_URL = "https://api.ai-meng.com";
|
// const BASE_URL = "https://api.ai-meng.com";
|
||||||
// const BASE_URL = 'http://127.0.0.1:3999'
|
// const BASE_URL = 'http://127.0.0.1:3999'
|
||||||
// const BASE_URL = "http://192.168.1.3:3999";
|
const BASE_URL = "http://192.168.1.3:3999";
|
||||||
// const BASE_URL = "http://192.168.31.253:3999";
|
// const BASE_URL = "http://192.168.31.253:3999";
|
||||||
import { useUserStore } from "@/stores/user";
|
import { useUserStore } from "@/stores/user";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user