弹出窗口的逻辑处理

This commit is contained in:
daihh
2022-10-21 11:32:41 +08:00
parent d9f63f3fff
commit 29da8d6b54
3 changed files with 126 additions and 56 deletions

View File

@@ -2,12 +2,8 @@
<el-dialog
:close-on-click-modal="false"
:visible.sync="interestCollection"
:append-to-body="true"
min-width="770px"
max-width="950px"
@close="closeDialog"
>
<div style="margin-top:10px">
:append-to-body="true" @close="closeDialog">
<div style="margin-top:10px;min-width: 770px;max-width:950px;">
<div class="interest" v-for="(sys,index) in sysTypeListMap" :key="sys.id">
<p class="portal-title-tow interest-title">{{sys.name}}</p>
<el-checkbox-group v-model="checkboxGroup" v-if="sys.children.length > 0">
@@ -26,10 +22,10 @@
import apiUserhobby from "@/api/phase2/userhobby.js"
export default {
props:{
show:{
type:Boolean,
default:false
}
// show:{
// type:Boolean,
// default:false
// }
},
data(){
return {
@@ -42,30 +38,30 @@
},
created() {
// this.userAvatar=require("@/assets/images/user/default.png");
apiUserhobby.has().then(res=>{
if(res.status != 200) {return;}
// 1. 判断用户是否选择过兴趣偏好
if(res.result == false){
this.interestCollection = true;
}
if(res.result == true){this.interestCollection = false;return;}
// 2. 判断用户是否点击过"暂不选择"按钮,如果用户点击过"暂不选择"按钮则判断点击"暂不选择"按钮天数是否大于15天如果大于则弹出兴趣偏好框否则不弹
let time = localStorage.getItem('notYet'+this.userInfo.aid);
if(!time == '' || time != null) {
let day = (new Date() - new Date(time))/(1000*60*60*24);
if(day > 15){
this.interestCollection = true;
return;
}
}
// 3. 判断用户是否点击"关闭"按钮,如果点击"关闭"按钮则在当前session不在弹窗
let current_session = sessionStorage.getItem('dialog_session_show'+this.userInfo.aid);
if(current_session == 1){
this.interestCollection = false;
}else {
this.interestCollection = true;
}
})
// apiUserhobby.has().then(res=>{
// if(res.status != 200) {return;}
// // 1. 判断用户是否选择过兴趣偏好
// if(res.result == false){
// this.interestCollection = true;
// }
// if(res.result == true){this.interestCollection = false;return;}
// // 2. 判断用户是否点击过"暂不选择"按钮,如果用户点击过"暂不选择"按钮则判断点击"暂不选择"按钮天数是否大于15天如果大于则弹出兴趣偏好框否则不弹
// let time = localStorage.getItem('notYet'+this.userInfo.aid);
// if(!time == '' || time != null) {
// let day = (new Date() - new Date(time))/(1000*60*60*24);
// if(day > 15){
// this.interestCollection = true;
// return;
// }
// }
// // 3. 判断用户是否点击"关闭"按钮,如果点击"关闭"按钮则在当前session不在弹窗
// let current_session = sessionStorage.getItem('dialog_session_show'+this.userInfo.aid);
// if(current_session == 1){
// this.interestCollection = false;
// }else {
// this.interestCollection = true;
// }
// })
},
mounted() {
this.getSysTypeTree().then(rs => {
@@ -73,17 +69,21 @@
});
},
methods:{
show(){
this.interestCollection=true;
},
notYet() {
//15天控制
this.interestCollection = false;
localStorage.setItem('notYet'+this.userInfo.aid,new Date());
},
...mapActions({
getSysTypeTree: 'sysType/getSysTypeTree',
}),
// 关闭兴趣偏好弹窗
closeDialog() {
sessionStorage.setItem('dialog_session_show'+this.userInfo.aid,1);
//本地登录的设置
sessionStorage.setItem('user-hobby-'+this.userInfo.aid,1);
},
saveInterest() {
let data = []