fix: watch user info
This commit is contained in:
@@ -395,7 +395,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from "vue";
|
||||
import { ref, computed, watch } from "vue";
|
||||
import { getBavBarHeight, getDeviceInfo } from "@/utils/system";
|
||||
import { generateObjectId, getShareToken } from "@/utils/common";
|
||||
|
||||
@@ -406,11 +406,7 @@ import {
|
||||
getCardTemplateContentList,
|
||||
getCardTemplateTitleList,
|
||||
} from "@/api/make";
|
||||
import {
|
||||
abilityCheck,
|
||||
getShareReward,
|
||||
msgCheckApi,
|
||||
} from "@/api/system";
|
||||
import { abilityCheck, getShareReward, msgCheckApi } from "@/api/system";
|
||||
import {
|
||||
onShareAppMessage,
|
||||
onLoad,
|
||||
@@ -425,6 +421,9 @@ const userStore = useUserStore();
|
||||
const loginPopupRef = ref(null);
|
||||
const isLoggedIn = computed(() => !!userStore.userInfo.nickName);
|
||||
|
||||
const DEFAULT_AVATAR =
|
||||
"https://file.lihailezzc.com/resource/96023631c6ab9c3496b7620097af3d6f.png";
|
||||
|
||||
const templatePage = ref(1);
|
||||
const loadingTemplates = ref(false);
|
||||
const hasMoreTemplates = ref(true);
|
||||
@@ -583,10 +582,7 @@ const handleSignatureBlur = async () => {
|
||||
oldSignatureName.value = signatureName.value;
|
||||
}
|
||||
};
|
||||
const userAvatar = ref(
|
||||
userStore?.userInfo?.avatarUrl ||
|
||||
"https://file.lihailezzc.com/resource/96023631c6ab9c3496b7620097af3d6f.png",
|
||||
);
|
||||
const userAvatar = ref(userStore?.userInfo?.avatarUrl || DEFAULT_AVATAR);
|
||||
|
||||
const blessingText = ref({});
|
||||
const fontSize = ref(32);
|
||||
@@ -676,7 +672,30 @@ onLoad((options) => {
|
||||
getTemplateTitleList();
|
||||
});
|
||||
|
||||
const syncUserInfo = () => {
|
||||
if (isLoggedIn.value) {
|
||||
if (signatureName.value === "xxx" || !signatureName.value) {
|
||||
signatureName.value = userStore.userInfo.nickName;
|
||||
oldSignatureName.value = userStore.userInfo.nickName;
|
||||
}
|
||||
if (userAvatar.value === DEFAULT_AVATAR || !userAvatar.value) {
|
||||
userAvatar.value = userStore.userInfo.avatarUrl;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
watch(
|
||||
() => userStore.userInfo,
|
||||
(newVal) => {
|
||||
if (newVal?.nickName) {
|
||||
syncUserInfo();
|
||||
}
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
onShow(() => {
|
||||
syncUserInfo();
|
||||
const recommendData = uni.getStorageSync("RECOMMEND_CARD_DATA");
|
||||
if (recommendData) {
|
||||
uni.removeStorageSync("RECOMMEND_CARD_DATA");
|
||||
@@ -715,7 +734,9 @@ onReachBottom(() => {
|
||||
}
|
||||
});
|
||||
|
||||
const handleLogind = async () => {};
|
||||
const handleLogind = async () => {
|
||||
syncUserInfo();
|
||||
};
|
||||
|
||||
const createCard = () => {
|
||||
const id = generateObjectId();
|
||||
|
||||
Reference in New Issue
Block a user