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