Complete admin counts api

pull/9/head
johnniang 2019-03-21 10:32:06 +08:00
parent 9418d99570
commit 1e11a62381
2 changed files with 25 additions and 2 deletions

14
src/api/admin.js Normal file
View File

@ -0,0 +1,14 @@
import service from '@/utils/service'
const baseUrl = '/admin/api'
const adminApi = {}
adminApi.counts = () => {
return service({
url: `${baseUrl}/counts`,
method: 'get'
})
}
export default adminApi

View File

@ -50,6 +50,7 @@
<script>
import postApi from '@/api/post'
import commentApi from '@/api/comment'
import adminApi from '@/api/admin'
const postColumns = [
{
@ -95,16 +96,18 @@ export default {
components: {},
data() {
return {
loading: true,
postLoading: true,
commentLoading: true,
countsLoading: true,
postColumns,
postData: [],
commentColumns,
commentData: []
commentData: [],
countsData: { attachmentCount: 0, commentCount: 0, establishDays: 0, postCount: 0 }
}
},
created() {
this.getCounts()
this.listLatestPosts()
this.listLatestComments()
},
@ -120,6 +123,12 @@ export default {
this.commentLoading = false
this.commentData = response.data.data
})
},
getCounts() {
adminApi.counts().then(response => {
this.countsLoading = false
this.countsData = response.data.data
})
}
}
}