From f13776f6ee8c136434ed3c10c3c3221c65e6bc3e Mon Sep 17 00:00:00 2001 From: weinan2087 Date: Fri, 21 Oct 2022 14:19:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=BE=E5=BC=80=E5=BC=95=E5=AF=BC=E9=A1=B5?= =?UTF-8?q?=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Index.vue | 108 ++++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 55 deletions(-) diff --git a/src/views/Index.vue b/src/views/Index.vue index e352e617..9771b970 100644 --- a/src/views/Index.vue +++ b/src/views/Index.vue @@ -531,41 +531,38 @@ //检查兴趣爱好是否已填报, //先检查本地session和 local 15天, 这两个值是在组件中设置的 - // let sessionHobby=sessionStorage.getItem('user-hobby-'+this.userInfo.aid); - // let localHobbyTime=localStorage.getItem('notYet'+this.userInfo.aid); - // if(!sessionHobby){ //只有session中不存在,才会验证 - // //本地15天验证,localHobby,后续完善 - // let flag=true;//请求检查 - // if(localHobbyTime) { - // let day = (new Date() - new Date(localHobbyTime))/(1000*60*60*24); - // if(day< 15){ - // flag = false; - // } - // } - // if(flag){ - // apiUserhobby.has().then(res=>{ - // if(res.status == 200) { - // if(!res.result){ - // //设置需要显示兴趣爱好收集窗口 - // this.userHobby.needShow=true; - // } - // }else{ - // console.log('兴趣爱好检查失败'+res.message); - // } - // //检查引导页 - // this.checkAndShowGuide(); - // }); - // }else{ - // this.checkAndShowGuide(); - // } - // }else{ - // //不用检查引导页 - // //this.checkAndShowGuide(); - // } - - //测试环境中 - this.userHobby.needShow=true; - this.checkAndShowGuide(); + let sessionHobby=sessionStorage.getItem('user-hobby-'+this.userInfo.aid); + let localHobbyTime=localStorage.getItem('notYet'+this.userInfo.aid); + console.log("sessionHobby:"+sessionHobby); + if(!sessionHobby){ //只有session中不存在,才会验证 + //本地15天验证,localHobby,后续完善 + let flag=true;//请求检查 + if(localHobbyTime) { + let day = (new Date() - new Date(localHobbyTime))/(1000*60*60*24); + if(day< 15){ + flag = false; + } + } + if(flag){ + apiUserhobby.has().then(res=>{ + if(res.status == 200) { + if(!res.result){ + //设置需要显示兴趣爱好收集窗口 + this.userHobby.needShow=true; + } + }else{ + console.log('兴趣爱好检查失败'+res.message); + } + //检查引导页 + this.checkAndShowGuide(); + }); + }else{ + this.checkAndShowGuide(); + } + }else{ + //检查引导页 + this.checkAndShowGuide(); + } }, computed: { @@ -579,28 +576,29 @@ checkAndShowGuide(){ //引导页弹框是否显示 //检查本地,减少服务器请求的次数 - // let localGuide=localStorage.getItem('user-guide-'+this.userInfo.aid); - // if(!localGuide){ - // apiGuide.hasUser().then(res=>{ - // if(res.status==200){ - // if(!res.result){ - // this.$refs.guide.show(); - // }else{ - // if(this.userHobby.needShow){ this.$refs.userCollection.show();} - // } - // localStorage.setItem('user-guide-'+this.userInfo.aid,1); - // }else{ - // console.log('获取引导页检查失败'+res.message); - // //this.$message.error('') - // if(this.userHobby.needShow){this.$refs.userCollection.show();} - // } - // }); - // }else { - // if(this.userHobby.needShow){ this.$refs.userCollection.show();} - // } + let localGuide=localStorage.getItem('user-guide-'+this.userInfo.aid); + console.log("=== "+localGuide); + if(!localGuide){ + apiGuide.hasUser().then(res=>{ + if(res.status==200){ + if(!res.result){ + this.$refs.guide.show(); + }else{ + if(this.userHobby.needShow){ this.$refs.userCollection.show();} + } + localStorage.setItem('user-guide-'+this.userInfo.aid,1); + }else{ + console.log('获取引导页检查失败'+res.message); + //this.$message.error('') + if(this.userHobby.needShow){this.$refs.userCollection.show();} + } + }); + }else { + if(this.userHobby.needShow){ this.$refs.userCollection.show();} + } //测试情况下 - this.$refs.guide.show(); + // this.$refs.guide.show(); }, closeGuide(){ //关闭引导页 if(this.userHobby.needShow){