Commit 2b3396de authored by 张九刚's avatar 张九刚

优化 Home 组件的状态管理,修复 setHomeInfo 方法中的逻辑顺序,并在 Home.vue 中添加对 homeInfo 的监控,确保初始化信息的正确加载

parent b5b7aa20
......@@ -21,12 +21,13 @@ export const useHomeStore = defineStore('homeInfo', {
* @param {Object} homeInfo
*/
setHomeInfo(homeInfo) {
this.homeInfo = homeInfo;
if(homeInfo?.memberId === "not_login"){
this.isLogin = false;
}else{
this.isLogin = true;
}
this.homeInfo = homeInfo;
},
setBabyExistence(babyExistence){
console.log('setBabyExistence', babyExistence);
......
......@@ -191,12 +191,16 @@ export default {
this.statusBarHeight = menuButtonInfo.top;
this.isClickPhoneAuth = false;
this.initHomeInfo();
},
watch: {
homeStore:{
handler(newVal){
this.showRegisterLayer =this.isClickPhoneAuth &&newVal.isLogin && !newVal.babyExistence;
console.log('newVal.homeInfo',newVal.homeInfo);
if(newVal.homeInfo !== null){
this.initHomeInfo();
}
},
deep:true,
immediate: true
......@@ -204,14 +208,10 @@ export default {
},
methods: {
async initHomeInfo() {
// try{
// await this.homeStore.loadHomeInfo();
// }catch(e){
// console.log('loadHomeInfo error',e);
// }
const { data } = await fetchHomeJSON();
console.log('111111111111',data);
if (data) {
this.swiperList = data.swiperList;
this.vipConfigList = data.vipConfigList;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment