xjc 5 years ago
parent
commit
b34ffb5a3b
2 changed files with 46 additions and 8 deletions
  1. 4 0
      src/api.js
  2. 42 8
      src/views/Index.vue

+ 4 - 0
src/api.js

@@ -298,4 +298,8 @@ export default {
 			params: params
 		})
 	},
+	//获取首页数据
+	getIndexData: params => {
+		return axios.get(`${baseURL}/api/admin/index`, params)
+	},
 }

+ 42 - 8
src/views/Index.vue

@@ -40,39 +40,73 @@
           <li>
             用户总数
             <img width="40" src="../images/curstom.png" alt="">
-            <p>123</p>
+            <p>{{info.user_count}}</p>
           </li>
           <li>
             报名总数
             <img width="40" src="../images/curstom.png" alt="">
-            <p>123</p>
+            <p>{{info.signup_count}}</p>
           </li>
           <li>
             试卷总数
             <img width="40" src="../images/curstom.png" alt="">
-            <p>123</p>
+            <p>{{info.paper_count}}</p>
           </li>
           <li>
             视频总数
             <img width="40" src="../images/curstom.png" alt="">
-            <p>123</p>
+            <p>{{info.videos_count}}</p>
           </li>
         </ul>
         <h1 class="title">待办事项</h1>
         <ul class="datas">
           <li>
             报名待付款
-            <p>3045</p>
+            <p>{{info.waiting_pay_count}}</p>
           </li>
           <li>
             待审核
-            <p>3045</p>
+            <p>{{info.waiting_audit_count}}</p>
           </li>
           <li>
             待考试
-            <p>3045</p>
+            <p>{{info.waiting_exam_count}}</p>
           </li>
         </ul>
     </div>
   </section>
-</template>
+</template>
+<script>
+export default {
+	filters: {
+    	ellipsis (value) {
+		if (!value) return ''
+		if (value.length > 8) {
+			return value.slice(0,8) + '...'
+		}
+		return value
+		}
+	},
+	name: 'home',
+	data() {
+		return {
+			menuList:[],
+			path:'',
+			info:{},
+			community_list:[],
+			community:{},
+      menu:[]
+		};
+	},
+	methods: {
+		getData(){
+			this.$api.getIndexData().then(res=>{
+				this.info=res.data.data
+      })
+    }
+	},
+	created(){
+		this.getData()
+	}
+};
+</script>