接口格式
This commit is contained in:
15
index.html
15
index.html
@@ -8,3 +8,18 @@
|
||||
<div id="app"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<script>
|
||||
(function (doc, win) {
|
||||
var docEl = doc.documentElement,
|
||||
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
|
||||
recalc = function () {
|
||||
var clientWidth = docEl.clientWidth;
|
||||
if (!clientWidth) return;
|
||||
docEl.style.fontSize = 100 * (clientWidth / 1920) + 'px';
|
||||
};
|
||||
if (!doc.addEventListener) return;
|
||||
win.addEventListener(resizeEvt, recalc, false);
|
||||
doc.addEventListener('DOMContentLoaded', recalc, false);
|
||||
})(document, window);
|
||||
</script>
|
||||
5
src/assets/js/getData1.js
Normal file
5
src/assets/js/getData1.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import {post} from '@js/http.js'
|
||||
|
||||
export const workScreen = (wflag) => post('api/bigScreenScreen/workScreen', {
|
||||
web_flag: wflag
|
||||
})
|
||||
10
src/assets/js/getData2.js
Normal file
10
src/assets/js/getData2.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import {post} from '@js/http.js'
|
||||
|
||||
export const screenZK = (id, cid) => post('api/bigScreenScreen/zk', {
|
||||
accountId: id,
|
||||
center_id: cid
|
||||
})
|
||||
export const query3Dcartoon = (id, cid) => post('api/bigScreenScreen/query3Dcartoon', {
|
||||
accountId: id,
|
||||
center_id: cid
|
||||
})
|
||||
78
src/assets/js/http.js
Normal file
78
src/assets/js/http.js
Normal file
@@ -0,0 +1,78 @@
|
||||
import axios from 'axios'
|
||||
import { Dialog, toast } from './mUtils.js'
|
||||
import store from '../../vuex/store'
|
||||
import router from '@/router'
|
||||
|
||||
axios.defaults.timeout = 50000
|
||||
axios.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8'
|
||||
|
||||
axios.interceptors.request.use(
|
||||
config => {
|
||||
if (config.method === 'post') {
|
||||
if (!config.data.flag) {
|
||||
config.data = config.data
|
||||
} else {
|
||||
config.data = config.data.formData
|
||||
}
|
||||
}
|
||||
return config
|
||||
},
|
||||
error => {
|
||||
Dialog('错误的传参')
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
axios.interceptors.response.use(
|
||||
response => {
|
||||
if (response.status === 200) {
|
||||
return Promise.resolve(response)
|
||||
} else {
|
||||
return Promise.reject(response)
|
||||
}
|
||||
},
|
||||
error => {
|
||||
if (error && error.response) {
|
||||
switch (error.response.status) {
|
||||
case 401:
|
||||
toast(error.response.data.message)
|
||||
store.dispatch('setSignOut')
|
||||
router.push('/login')
|
||||
break
|
||||
}
|
||||
return Promise.reject(error.response.data)
|
||||
} else {
|
||||
return Promise.reject(error)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
export const post = (sevmethod, params) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.post(`${store.getters.baseUrl}/` + sevmethod, params)
|
||||
.then(response => {
|
||||
resolve(response.data)
|
||||
}, error => {
|
||||
Dialog(error.message)
|
||||
reject(error.message)
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const post1 = (sevmethod, params) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.post(sevmethod, params)
|
||||
.then(response => {
|
||||
resolve(response.data)
|
||||
}, error => {
|
||||
Dialog(error.message)
|
||||
reject(error.message)
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import store from './vuex/store'
|
||||
import _ from 'lodash'
|
||||
import '@css/reset.css'
|
||||
import '@css/layout.styl'
|
||||
import '@js/rem.js'
|
||||
// import '@js/rem.js'
|
||||
import filter from '@js/filter.js'
|
||||
import { Dialog, toast } from '@js/mUtils.js'
|
||||
import {post} from '@fetch/api.js'
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
|
||||
<script>
|
||||
import NavHeader from '@components/header.vue'
|
||||
import {query3Dcartoon} from '@js/getData2.js'
|
||||
export default {
|
||||
name: 'Animation',
|
||||
components: {
|
||||
@@ -63,24 +64,13 @@ export default {
|
||||
this.getData()
|
||||
},
|
||||
methods: {
|
||||
getData () {
|
||||
let data = {
|
||||
'_SRVNAME': 'server.app.screenAPI',
|
||||
'_SRVMETHOD': 'query3Dcartoon',
|
||||
'_DATA': JSON.stringify({
|
||||
accountId: '',
|
||||
form: {
|
||||
center_id: ''
|
||||
}
|
||||
})
|
||||
}
|
||||
this
|
||||
.$post(data)
|
||||
.then(res => {
|
||||
async getData () {
|
||||
let res = await query3Dcartoon('', '')
|
||||
if (res.code === '1') {
|
||||
this.initInfo = res.result
|
||||
} else {
|
||||
this.Dialog(res.desc)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,6 +175,7 @@
|
||||
import NavHeader from '@components/nav.vue'
|
||||
import NumberGrow from '@/components/NumberGrow'
|
||||
import * as echarts from 'echarts'
|
||||
import {workScreen} from '@js/getData1.js'
|
||||
export default {
|
||||
name: 'producedata',
|
||||
components: {
|
||||
@@ -375,17 +376,9 @@ export default {
|
||||
this.getList()
|
||||
}, this.interTime)
|
||||
},
|
||||
getList () {
|
||||
let data = {
|
||||
'_SRVNAME': 'server.app.LargeScreenAPI',
|
||||
'_SRVMETHOD': 'queryLargeScreen',
|
||||
'_DATA': JSON.stringify({
|
||||
web_flag: this.$route.query.type || '1'
|
||||
})
|
||||
}
|
||||
this
|
||||
.$post(data)
|
||||
.then(res => {
|
||||
async getList () {
|
||||
let type = this.$route.query.type || '1'
|
||||
let res = await workScreen(type)
|
||||
if (res.code === '1') {
|
||||
this.xdata2 = []
|
||||
this.ydata2 = []
|
||||
@@ -412,7 +405,6 @@ export default {
|
||||
} else {
|
||||
// this.toast(res.desc)
|
||||
}
|
||||
})
|
||||
},
|
||||
_getEchart () {
|
||||
let data = this.data
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
<script>
|
||||
import NavHeader from '@components/header.vue'
|
||||
import { maxArr } from '@js/mUtils.js'
|
||||
import {screenZK} from '@js/getData2.js'
|
||||
export default {
|
||||
name: 'WorkShop',
|
||||
components: {
|
||||
@@ -562,20 +563,12 @@ export default {
|
||||
let myChart = this.$echarts.init(echart)
|
||||
myChart.setOption(option)
|
||||
},
|
||||
_getDatas () {
|
||||
let data = {
|
||||
'_SRVNAME': 'server.app.screenAPI',
|
||||
'_SRVMETHOD': 'queryWorkshop',
|
||||
'_DATA': JSON.stringify({
|
||||
accountId: '',
|
||||
form: {
|
||||
center_id: this.$store.getters.workshopId
|
||||
async _getDatas () {
|
||||
let cid = ''
|
||||
if (this.$store.getters.workshopId) {
|
||||
cid = this.$store.getters.equipId
|
||||
}
|
||||
})
|
||||
}
|
||||
this
|
||||
.$post(data)
|
||||
.then(res => {
|
||||
let res = await screenZK('', cid)
|
||||
if (res.code === '1') {
|
||||
this.nameToday = []
|
||||
this.numToday = []
|
||||
@@ -612,9 +605,8 @@ export default {
|
||||
this._getEchart2()
|
||||
this._getEchart3()
|
||||
} else {
|
||||
this.toast(res.desc)
|
||||
this.Dialog(res.desc)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
beforeDestroy () {
|
||||
|
||||
Reference in New Issue
Block a user