From 68f1fe3a40e808d925ae0c19eea8bea53591e4ea Mon Sep 17 00:00:00 2001 From: xioayue Date: Tue, 20 Jun 2023 19:53:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=BB=E8=A7=88=E6=8E=A5=E5=8F=A3=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/index.js | 1 + public/config.js | 6 +++ src/api/home.js | 12 +++--- src/components/index/index.vue | 4 +- src/components/zongLan/zongLan.vue | 65 ++++++++++++++++-------------- src/main.js | 6 ++- src/utils/request.js | 12 +++--- 7 files changed, 61 insertions(+), 45 deletions(-) create mode 100644 public/config.js diff --git a/config/index.js b/config/index.js index c5eded7..b1a3a3c 100644 --- a/config/index.js +++ b/config/index.js @@ -10,6 +10,7 @@ module.exports = { // Paths assetsSubDirectory: 'static', assetsPublicPath: '/', + // 代理 proxyTable: {}, // Various Dev Server settings diff --git a/public/config.js b/public/config.js new file mode 100644 index 0000000..034da03 --- /dev/null +++ b/public/config.js @@ -0,0 +1,6 @@ +window.publicConfig = { + // 必填: api地址, 换成自己的域名即可 + // BASE_API: '../index.php?s=/store' + BASE_API: 'http://btgym.xingtongworld.com/' + } + \ No newline at end of file diff --git a/src/api/home.js b/src/api/home.js index 1535169..cf7de56 100644 --- a/src/api/home.js +++ b/src/api/home.js @@ -7,11 +7,11 @@ const api={ daily_klqs:'index.php/allGroupTimeNum?granularity=daily' } -// 获取用户信息 -export function apiGetUserInfo() { - return httpRequest({ - url: 'your api url', - method: 'post', - data: param, +// 获取群组 +export function allGroupTimeNum(param) { + return request({ + url: api.daily_klqs, + method: 'get', + param, }) } diff --git a/src/components/index/index.vue b/src/components/index/index.vue index 7d5afba..ae4560d 100644 --- a/src/components/index/index.vue +++ b/src/components/index/index.vue @@ -14,10 +14,10 @@
体育
-
+
总览
-
+
文化
diff --git a/src/components/zongLan/zongLan.vue b/src/components/zongLan/zongLan.vue index f2a62f8..6653b69 100644 --- a/src/components/zongLan/zongLan.vue +++ b/src/components/zongLan/zongLan.vue @@ -5,19 +5,14 @@
客流趋势
-
+
{{ item.unit }}
-
+
@@ -101,20 +96,12 @@
今日各场馆人数趋势
-
+
-
+
345,235
// 引入echarts import * as echarts from "echarts"; +// 引入api +import * as homeApi from '@/api/home' var uChartsInstance = {}; export default { @@ -260,6 +249,10 @@ export default { unit: "日", }, ], + // 条线图 + bar_data:[], + // 柱子图x轴 + bar_tdata:[], selectVal1: "年", }; }, @@ -268,6 +261,8 @@ export default { this.home_bar(); // 折线图 this.line_zone(); + + this.getStat(); }, methods: { clickItme(val) { @@ -277,27 +272,34 @@ export default { this.selectVal1 = val; }, + //获取统计数据 + getStat(){ + let that = this + homeApi.allGroupTimeNum().then(res=>{ + // get allTimeData + const tmpdata = res.data.allTimeData + let btdata = new Array(); + let bvdata = new Array(); + tmpdata.foreach(function(item,index){ + console.log(item); + }); + + }); + }, + // 透明背景柱状统计图 home_bar() { var chartDom = document.getElementById("homebar"); var myChart = echarts.init(chartDom); var option; + // + let that = this + option = { xAxis: { type: "category", - data: [ - "Mon", - "Tue", - "Wed", - "Thu", - "Fri", - "Sat", - "Sun", - "0c", - "90", - "10", - ], + data: that.bar_tdata, }, yAxis: { type: "value", @@ -311,7 +313,8 @@ export default { }, series: [ { - data: [120, 200, 150, 80, 70, 110, 130, 630, 530, 460], + //data: [120, 200, 150, 80, 70, 110, 130, 630, 530, 460], + data: that.bar_data, type: "bar", showBackground: true, // 设置顶部圆形 diff --git a/src/main.js b/src/main.js index d8f187c..1f30159 100644 --- a/src/main.js +++ b/src/main.js @@ -4,10 +4,14 @@ import Vue from 'vue' import App from './App' import router from './router' import less from 'less' -Vue.config.productionTip = false +//axios +import axios from 'axios' +Vue.config.productionTip = false Vue.use(less) +Vue.use(axios) + /* eslint-disable no-new */ new Vue({ el: '#app', diff --git a/src/utils/request.js b/src/utils/request.js index b77a513..4d14201 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,14 +1,17 @@ import axios from 'axios' + +//https://www.jb51.net/article/246548.htm + // 创建一个 axios 实例 const service = axios.create({ - baseURL: '/api', // 所有的请求地址前缀部分 + //baseURL: '/api', // 所有的请求地址前缀部分 + //baseURL: publicConfig.BASE_API, + //baseURL:ahost, timeout: 60000, // 请求超时时间毫秒 withCredentials: true, // 异步请求携带cookie headers: { // 设置后端需要的传参类型 'Content-Type': 'application/json', - 'token': 'your token', - 'X-Requested-With': 'XMLHttpRequest', }, }) @@ -20,7 +23,6 @@ service.interceptors.request.use( }, function (error) { // 对请求错误做些什么 - console.log(error) return Promise.reject(error) } ) @@ -28,7 +30,7 @@ service.interceptors.request.use( // 添加响应拦截器 service.interceptors.response.use( function (response) { - console.log(response) + //console.log(response) // 2xx 范围内的状态码都会触发该函数。 // 对响应数据做点什么 // dataAxios 是 axios 返回数据中的 data