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