案例随机

This commit is contained in:
lims1@hunktimes.com
2023-08-06 13:26:39 +08:00
parent 5013ac3b9b
commit 1b4ad26708

View File

@@ -393,7 +393,7 @@ export default {
pageSize: 5,
// orderField: "excellent",
majorType: '', //专业分类code
orderAsc: false,
// orderAsc: false,
// isTop: true,
excellent: true,
keyWord: '',
@@ -406,7 +406,11 @@ export default {
parent: '',
children: [],
name: '',
years: []
years: [],
// 随机
notInIds: [],//重复的id
orderField: "id",
orderAsc: false,//排序
},
keyWord: "",
anking: 2,
@@ -487,6 +491,49 @@ export default {
return !this.speciData.some(item => item.fielclass);
}
},
created() {
(() => {
const allArr = [0, 1, 2, 3]
let recordsArr = JSON.parse(sessionStorage.getItem("recordsArr")) || [];
let arr3 = allArr.filter(item => recordsArr.includes(item))
let difference = allArr.filter(element => !arr3.includes(element));
if (recordsArr.length === allArr.length) {
difference = [...allArr]
recordsArr = []
}
let random = Math.floor(Math.random() * difference.length)
difference.forEach((item, index) => {
if (index == random) {
random = item
return
}
})
recordsArr.push(random)
sessionStorage.setItem("recordsArr", JSON.stringify(recordsArr))
switch (random) {
case 1:
console.log('hhahahaha1');
this.queryCondition.orderField = "id"
this.queryCondition.orderAsc = true
break;
case 2:
console.log('hahahhaha2');
this.queryCondition.orderField = "title"
this.queryCondition.orderAsc = true
break;
case 3:
console.log('hahahhaha3');
this.queryCondition.orderField = "title"
this.queryCondition.orderAsc = false
break;
default:
console.log('hahahhaha0');
this.queryCondition.orderField = "id"
this.queryCondition.orderAsc = false
break;
}
})()
},
mounted() {
let $this = this;
// if(this.speciData.length==0){