Commit c949337896406827a1267687260415a7914a754f

Authored by liuqimichale
1 parent 9aa901e6

api 接口封装

src/api/api.js 0 → 100644
  1 +import { get, post} from './httpRequest'
  2 +
  3 +//....用户数
  4 +export const memberAddress = p => post('urban/intelligence/appuser/queryUserPersonStatistic',p)
  5 +
  6 +//....收费员
  7 +export const tollmanAddress = p => post('urban/intelligence/employee/queryEmployeeStaByOrgIds',p)
  8 +
  9 +//....设备
  10 +export const deviceAddress = p => post('urban/intelligence/device/queryDeviceStatistic',p)
src/api/httpRequest.js
1 //引入axios 1 //引入axios
2 import axios from 'axios' 2 import axios from 'axios'
3 //import qs from 'qs' 3 //import qs from 'qs'
4 -let cancel ,promiseArr = {} 4 +let cancel
5 const CancelToken = axios.CancelToken; 5 const CancelToken = axios.CancelToken;
6 //请求拦截器 // 在发送请求之前做些什么 6 //请求拦截器 // 在发送请求之前做些什么
7 axios.interceptors.request.use(config => { 7 axios.interceptors.request.use(config => {
8 //发起请求时,取消掉当前正在进行的相同请求 8 //发起请求时,取消掉当前正在进行的相同请求
9 config.headers['x-auth-token'] = '18de1300-c3f2-4365-9f51-62f77614f8c5' 9 config.headers['x-auth-token'] = '18de1300-c3f2-4365-9f51-62f77614f8c5'
10 - // if(config.method === 'post') {  
11 - // let data = qs.parse(config.data)  
12 - //  
13 - // config.data = qs.stringify({  
14 - // sysCode: '1001'  
15 - // })  
16 - // } else if(config.method === 'get') {  
17 - // config.params = {  
18 - // sysCode: '1001'  
19 - // }  
20 - // }  
21 config.data = { 10 config.data = {
22 ...config.data, 11 ...config.data,
23 sysCode: '1001' 12 sysCode: '1001'
@@ -91,35 +80,22 @@ axios.defaults.baseURL = 'http://bcp.service.renniting.cn/'; @@ -91,35 +80,22 @@ axios.defaults.baseURL = 'http://bcp.service.renniting.cn/';
91 // axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'; 80 // axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8';
92 axios.defaults.timeout = 10000 81 axios.defaults.timeout = 10000
93 82
94 -export default {  
95 - //get请求  
96 - get (url,param) {  
97 - return new Promise((resolve,reject) => {  
98 - axios({  
99 - method: 'get',  
100 - url,  
101 - params: param,  
102 - cancelToken: new CancelToken(c => {  
103 - cancel = c  
104 - })  
105 - }).then(res => {  
106 - resolve(res)  
107 - })  
108 - })  
109 - },  
110 - //post请求  
111 - post (url,param) {  
112 - return new Promise((resolve,reject) => {  
113 - axios({  
114 - method: 'post',  
115 - url,  
116 - data: param,  
117 - cancelToken: new CancelToken(c => {  
118 - cancel = c  
119 - })  
120 - }).then(res => {  
121 - resolve(res) 83 +
  84 +function post(url, params) {
  85 + return new Promise((resolve,reject) => {
  86 + axios({
  87 + method: 'post',
  88 + url,
  89 + data: params,
  90 + cancelToken: new CancelToken(c => {
  91 + cancel = c
122 }) 92 })
  93 + }).then(res => {
  94 + resolve(res)
123 }) 95 })
124 - } 96 + })
125 } 97 }
  98 +
  99 +
  100 +export {post}
  101 +
src/components/device/index.vue
@@ -79,41 +79,41 @@ @@ -79,41 +79,41 @@
79 </template> 79 </template>
80 80
81 <script> 81 <script>
82 - import echarts from 'echarts' 82 +import { deviceAddress } from '../../api/api'
83 export default { 83 export default {
84 name: "device", 84 name: "device",
85 data() { 85 data() {
86 return { 86 return {
87 - PDANum:1235,//PDA数 87 + PDANum:'',//PDA数
88 PDAName:'', 88 PDAName:'',
89 - diCiNum:1456,//地磁数 89 + diCiNum:'',//地磁数
90 diCiName:'', 90 diCiName:'',
91 - daoZhaNum:1245,//道闸数 91 + daoZhaNum:'',//道闸数
92 daoZhaName:'', 92 daoZhaName:'',
93 - youDaoNum:1235,//诱导屏 93 + youDaoNum:'',//诱导屏
94 youDaoName:'', 94 youDaoName:'',
95 name: '设备' 95 name: '设备'
96 } 96 }
97 }, 97 },
98 mounted() { 98 mounted() {
99 - this.axios.post('urban/intelligence/device/queryDeviceStatistic',{  
100 - orgIds: this.GLOBAL.paramsvariables  
101 - }).then((response)=>{  
102 - let data = response.data.data  
103 - this.PDANum = data[0].num  
104 - this.PDAName = data[0].deviceName  
105 - this.diCiNum = data[1].num  
106 - this.diCiName = data[1].deviceName  
107 - this.daoZhaNum = data[2].num  
108 - this.daoZhaName = data[2].deviceName  
109 - this.youDaoNum = data[3].num  
110 - this.youDaoName = data[3].deviceName  
111 - }).catch((response)=>{  
112 - console.log(response);  
113 - }) 99 + this.onLoad()
114 }, 100 },
115 methods: { 101 methods: {
116 - 102 + onLoad() {
  103 + deviceAddress({orgIds: this.GLOBAL.paramsvariables}).then((response)=>{
  104 + let data = response.data.data
  105 + this.PDANum = data[0].num
  106 + this.PDAName = data[0].deviceName
  107 + this.diCiNum = data[1].num
  108 + this.diCiName = data[1].deviceName
  109 + this.daoZhaNum = data[2].num
  110 + this.daoZhaName = data[2].deviceName
  111 + this.youDaoNum = data[3].num
  112 + this.youDaoName = data[3].deviceName
  113 + }).catch((response)=>{
  114 + console.log(response);
  115 + })
  116 + }
117 }, 117 },
118 } 118 }
119 </script> 119 </script>
src/components/memberNum/index.vue
@@ -24,38 +24,41 @@ @@ -24,38 +24,41 @@
24 <script> 24 <script>
25 import { mapActions } from 'vuex' 25 import { mapActions } from 'vuex'
26 import common from '../../api/common'; 26 import common from '../../api/common';
27 - import echarts from 'echarts' 27 + import { memberAddress } from '../../api/api'
28 export default { 28 export default {
29 name: "memberNum", 29 name: "memberNum",
30 data() { 30 data() {
31 return { 31 return {
32 demo:'',//示例 总数 32 demo:'',//示例 总数
33 memberNumTotal:"",//会员总数html 33 memberNumTotal:"",//会员总数html
34 - activeUserNum:23454,//日活跃  
35 - newUerNum:521,//新增用户 34 + activeUserNum:'',//日活跃
  35 + newUerNum:'',//新增用户
36 name: '会员数' 36 name: '会员数'
37 } 37 }
38 }, 38 },
39 mounted() { 39 mounted() {
40 //会员总数 40 //会员总数
41 - this.axios.post('urban/intelligence/appuser/queryUserPersonStatistic').then((response)=>{  
42 - let data = response.data.data  
43 - this.registerNum = data.registerNum  
44 - this.memberNumTotal = common.formatNumToStr(this.registerNum);  
45 - this.activeUserNum = data.todayActiveNum  
46 - this.newUerNum = data.todayRegisterNum  
47 - this.$store.dispatch('transferParkingTotal', data.registerNum)  
48 - //this.$store.dispatch('transferParkingTotal',10000);  
49 - //this.transferParkingTotal( data.registerNum);  
50 - console.log(this.$store.state.ParkingTotal)  
51 - }).catch((response)=>{  
52 - console.log(response);  
53 - }) 41 + this.onLoad()
54 }, 42 },
55 methods: { 43 methods: {
56 ...mapActions([ 44 ...mapActions([
57 'transferParkingTotal' 45 'transferParkingTotal'
58 - ]) 46 + ]),
  47 + onLoad() {
  48 + memberAddress().then((response)=>{
  49 + let data = response.data.data
  50 + this.registerNum = data.registerNum
  51 + this.memberNumTotal = common.formatNumToStr(this.registerNum);
  52 + this.activeUserNum = data.todayActiveNum
  53 + this.newUerNum = data.todayRegisterNum
  54 + this.$store.dispatch('transferParkingTotal', data.registerNum)
  55 + //this.$store.dispatch('transferParkingTotal',10000);
  56 + //this.transferParkingTotal( data.registerNum);
  57 + console.log(this.$store.state.ParkingTotal)
  58 + }).catch((response)=>{
  59 + console.log(response);
  60 + })
  61 + }
59 /* 62 /*
60 * 格式化会员总数 63 * 格式化会员总数
61 // * */ 64 // * */
src/components/tollman/index.vue
@@ -27,41 +27,40 @@ @@ -27,41 +27,40 @@
27 27
28 <script> 28 <script>
29 import common from '../../api/common'; 29 import common from '../../api/common';
30 - import echarts from 'echarts' 30 + import { tollmanAddress } from '../../api/api'
31 export default { 31 export default {
32 name: "tollman", 32 name: "tollman",
33 data() { 33 data() {
34 return { 34 return {
35 demo:'',//示例 总数 35 demo:'',//示例 总数
36 tollmanTotal:"",//收费员总数html 36 tollmanTotal:"",//收费员总数html
37 - onDutyNum:254,//值班  
38 - noDutyNum:154,//未值班 37 + onDutyNum:'',//值班
  38 + noDutyNum:'',//未值班
39 name: '折线图' 39 name: '折线图'
40 } 40 }
41 }, 41 },
42 mounted() { 42 mounted() {
43 //this.createLine(); 43 //this.createLine();
44 //收费员总数 44 //收费员总数
45 -  
46 - this.axios.post('urban/intelligence/employee/queryEmployeeStaByOrgIds',{  
47 - orgIds: this.GLOBAL.paramsvariables  
48 - }).then((response)=>{  
49 - let data = response.data.data  
50 - this.tollmanTotal = data.allTollCollector  
51 - this.tollmanTotal = common.formatNumToStr(this.tollmanTotal);  
52 - this.onDutyNum = data.signInTollCollector  
53 - this.noDutyNum = data.unSignInTollCollector  
54 - }).catch((response)=>{  
55 - console.log(response);  
56 - }) 45 + this.onLoad()
57 }, 46 },
58 methods: { 47 methods: {
59 /* 48 /*
60 * 格式化会员总数 49 * 格式化会员总数
61 * */ 50 * */
62 - formatNumToStr:function(){  
63 - return common.formatNumToStr(this.$options.data().demo);  
64 - }, 51 + onLoad() {
  52 + tollmanAddress({
  53 + orgIds: this.GLOBAL.paramsvariables
  54 + }).then((response)=>{
  55 + let data = response.data.data
  56 + this.tollmanTotal = data.allTollCollector
  57 + this.tollmanTotal = common.formatNumToStr(this.tollmanTotal);
  58 + this.onDutyNum = data.signInTollCollector
  59 + this.noDutyNum = data.unSignInTollCollector
  60 + }).catch((response)=>{
  61 + console.log(response);
  62 + })
  63 + }
65 }, 64 },
66 65
67 } 66 }