接口格式

This commit is contained in:
2022-07-13 14:21:40 +08:00
parent ae871a642f
commit 9332d9304a
8 changed files with 187 additions and 105 deletions

View File

@@ -8,3 +8,18 @@
<div id="app"></div> <div id="app"></div>
</body> </body>
</html> </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>

View 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
View 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
View 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)
})
})
}

View File

@@ -6,7 +6,7 @@ import store from './vuex/store'
import _ from 'lodash' import _ from 'lodash'
import '@css/reset.css' import '@css/reset.css'
import '@css/layout.styl' import '@css/layout.styl'
import '@js/rem.js' // import '@js/rem.js'
import filter from '@js/filter.js' import filter from '@js/filter.js'
import { Dialog, toast } from '@js/mUtils.js' import { Dialog, toast } from '@js/mUtils.js'
import {post} from '@fetch/api.js' import {post} from '@fetch/api.js'

View File

@@ -44,6 +44,7 @@
<script> <script>
import NavHeader from '@components/header.vue' import NavHeader from '@components/header.vue'
import {query3Dcartoon} from '@js/getData2.js'
export default { export default {
name: 'Animation', name: 'Animation',
components: { components: {
@@ -63,24 +64,13 @@ export default {
this.getData() this.getData()
}, },
methods: { methods: {
getData () { async getData () {
let data = { let res = await query3Dcartoon('', '')
'_SRVNAME': 'server.app.screenAPI',
'_SRVMETHOD': 'query3Dcartoon',
'_DATA': JSON.stringify({
accountId: '',
form: {
center_id: ''
}
})
}
this
.$post(data)
.then(res => {
if (res.code === '1') { if (res.code === '1') {
this.initInfo = res.result this.initInfo = res.result
} else {
this.Dialog(res.desc)
} }
})
} }
} }
} }

View File

@@ -175,6 +175,7 @@
import NavHeader from '@components/nav.vue' import NavHeader from '@components/nav.vue'
import NumberGrow from '@/components/NumberGrow' import NumberGrow from '@/components/NumberGrow'
import * as echarts from 'echarts' import * as echarts from 'echarts'
import {workScreen} from '@js/getData1.js'
export default { export default {
name: 'producedata', name: 'producedata',
components: { components: {
@@ -375,17 +376,9 @@ export default {
this.getList() this.getList()
}, this.interTime) }, this.interTime)
}, },
getList () { async getList () {
let data = { let type = this.$route.query.type || '1'
'_SRVNAME': 'server.app.LargeScreenAPI', let res = await workScreen(type)
'_SRVMETHOD': 'queryLargeScreen',
'_DATA': JSON.stringify({
web_flag: this.$route.query.type || '1'
})
}
this
.$post(data)
.then(res => {
if (res.code === '1') { if (res.code === '1') {
this.xdata2 = [] this.xdata2 = []
this.ydata2 = [] this.ydata2 = []
@@ -412,7 +405,6 @@ export default {
} else { } else {
// this.toast(res.desc) // this.toast(res.desc)
} }
})
}, },
_getEchart () { _getEchart () {
let data = this.data let data = this.data

View File

@@ -88,6 +88,7 @@
<script> <script>
import NavHeader from '@components/header.vue' import NavHeader from '@components/header.vue'
import { maxArr } from '@js/mUtils.js' import { maxArr } from '@js/mUtils.js'
import {screenZK} from '@js/getData2.js'
export default { export default {
name: 'WorkShop', name: 'WorkShop',
components: { components: {
@@ -562,20 +563,12 @@ export default {
let myChart = this.$echarts.init(echart) let myChart = this.$echarts.init(echart)
myChart.setOption(option) myChart.setOption(option)
}, },
_getDatas () { async _getDatas () {
let data = { let cid = ''
'_SRVNAME': 'server.app.screenAPI', if (this.$store.getters.workshopId) {
'_SRVMETHOD': 'queryWorkshop', cid = this.$store.getters.equipId
'_DATA': JSON.stringify({
accountId: '',
form: {
center_id: this.$store.getters.workshopId
} }
}) let res = await screenZK('', cid)
}
this
.$post(data)
.then(res => {
if (res.code === '1') { if (res.code === '1') {
this.nameToday = [] this.nameToday = []
this.numToday = [] this.numToday = []
@@ -612,9 +605,8 @@ export default {
this._getEchart2() this._getEchart2()
this._getEchart3() this._getEchart3()
} else { } else {
this.toast(res.desc) this.Dialog(res.desc)
} }
})
} }
}, },
beforeDestroy () { beforeDestroy () {