API filter [_in]
parent
5349e735bf
commit
b9e6cbca02
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="flex flex-col h-screen justify-between">
|
||||||
<Header />
|
<Header />
|
||||||
<main>
|
<main>
|
||||||
<router-view />
|
<router-view />
|
||||||
|
|
|
@ -6,47 +6,66 @@
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<div v-html="page[0].content" class="container mx-auto">
|
<div v-html="page[0].content" class="container mx-auto">
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div v-if="page[0].attachments">
|
<div v-if="files">
|
||||||
<div v-html="page[0].attachments"> </div>
|
<h2>Attachments</h2>
|
||||||
|
<div v-for="(file, index) in files">
|
||||||
|
{{index+1}}<a :href="'https://api8.siliconpin.com/assets/' + file.directus_files_id">
|
||||||
|
<h3> {{ file.directus_files_id }}</h3>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div>{{page[0].attachments[0]}}</div>
|
|
||||||
|
</div>
|
||||||
|
<!-- <div>{{page[0].attachments[0]}}</div> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
page: null,
|
page: null,
|
||||||
attachments:[],
|
files: [],
|
||||||
isLoading: true
|
isLoading: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
fetch('https://api8.siliconpin.com/items/scc22?filter[slug][_eq]=' + this.$route.params.id)
|
fetch('https://api8.siliconpin.com/items/scc22?filter[slug][_eq]=' + this.$route.params.id)
|
||||||
// fetch('https://api8.siliconpin.com/items/scc22?slug=about-us')
|
.then(response => response.json())
|
||||||
.then(response => response.json())
|
.then(data => {
|
||||||
.then(data => {
|
this.page = data.data
|
||||||
this.page = data.data
|
let attIDs = ''
|
||||||
this.page[0].attachments.forEach(element => {
|
let t = 0
|
||||||
fetch('https://api8.siliconpin.com/items/scc22_files_1?filter[id][_eq]='+element )
|
this.page[0].attachments.forEach(ids => {
|
||||||
.then(response => response.json())
|
if (t == 0) attIDs = ids
|
||||||
.then(attach => {
|
else attIDs = attIDs + ',' + ids
|
||||||
console.log(attach.data[0].directus_files_id)
|
t++
|
||||||
this.attachments.push(attach.data[0].directus_files_id)
|
// console.log(ids)
|
||||||
})
|
});
|
||||||
console.log(element)
|
// console.log(attIDs)
|
||||||
});
|
// this.getAttachments(this.page[0].attachments)
|
||||||
// this.getAttachments(this.page[0].attachments)
|
// console.log(this.page[0].attachments)
|
||||||
// console.log(this.page[0].attachments)
|
this.isLoading = false
|
||||||
this.isLoading = false
|
|
||||||
|
fetch('https://api8.siliconpin.com/items/scc22_files_1?filter[id][_in]=' + attIDs)
|
||||||
|
.then(resp => resp.json())
|
||||||
|
.then(file => {
|
||||||
|
this.files = file.data
|
||||||
|
// attach.data.forEach(fileID=> this.files.push(fileID.directus_files_id))
|
||||||
|
console.log(file.data)
|
||||||
|
// this.attachments.push(attach.data[0].directus_files_id)
|
||||||
|
})
|
||||||
|
// console.log(Object.assign({}, this.files))
|
||||||
|
// console.log(this.files)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// getAttachments(att) {
|
// getAttachments(att) {
|
||||||
|
|
||||||
// console.log(att)
|
// console.log(att)
|
||||||
|
@ -57,5 +76,5 @@
|
||||||
|
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
Loading…
Reference in New Issue