|
@@ -191,6 +191,41 @@ export default {
|
|
|
this.inputFlag = false
|
|
|
}
|
|
|
},
|
|
|
+ paramsType (t, num, url, name) {
|
|
|
+ let type = 'application/json'
|
|
|
+ let result = ''
|
|
|
+ if (t == 'json') {
|
|
|
+ type = 'application/json'
|
|
|
+ }
|
|
|
+ if (num == 1) {
|
|
|
+ result = axios.get(url, {
|
|
|
+ params: {
|
|
|
+ [name]: sessionStorage.getItem('userName'),
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ unused: 0 //解决请求头无Content-Type
|
|
|
+ },
|
|
|
+ headers: {
|
|
|
+ 'token': sessionStorage.getItem('token'),
|
|
|
+ 'Content-Type': type
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ result = axios.post(url, {
|
|
|
+ [name]: sessionStorage.getItem('userName')
|
|
|
+ }, {
|
|
|
+ headers: {
|
|
|
+ 'token': sessionStorage.getItem('token'),
|
|
|
+ 'Content-Type': type
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ result.then(res => {
|
|
|
+ console.log(res)
|
|
|
+ }).catch(err => {
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
+ },
|
|
|
//应用跳转
|
|
|
toApp (item) {
|
|
|
if (item.appUrl) {
|
|
@@ -198,42 +233,31 @@ export default {
|
|
|
const datas = item.inputs
|
|
|
const arrs = []
|
|
|
if (datas && datas.length) {
|
|
|
- datas.forEach(item => {
|
|
|
- const obj = {}
|
|
|
- if (item.AppInputName == 'token' || item.AppInputName == 'Token' || item.AppInputName == 'TOKEN') {
|
|
|
- obj[item.AppInputName] = sessionStorage.getItem('token')
|
|
|
- } else if (item.AppInputName == 'loginName' || item.AppInputName == 'userName') {
|
|
|
- obj[item.AppInputName] = sessionStorage.getItem('userName')
|
|
|
- }
|
|
|
- arrs.push(obj)
|
|
|
- })
|
|
|
+ const [a1, a2] = [...datas]
|
|
|
if (item.requestType == 1) {
|
|
|
- const getParams = Object.assign(...arrs)
|
|
|
- axios.get(item.appUrl, {
|
|
|
- params: getParams
|
|
|
- }).then(res => {
|
|
|
- console.log(res)
|
|
|
- }).catch(err => {
|
|
|
- console.log(err)
|
|
|
- })
|
|
|
- } else if (item.requestType == 2) {
|
|
|
- const bodyType = item.bodyType
|
|
|
- let type = 'application/json'
|
|
|
- if (bodyType == 'json') {
|
|
|
- type = 'application/json'
|
|
|
+ if (a1.AppInputName == 'token' && a1.AppInputSite == 'Header' && a2.AppInputSite == 'Body') {
|
|
|
+ this.paramsType(item.bodyType, item.requestType, item.appUrl, a2.AppInputName)
|
|
|
+ } else {
|
|
|
+ datas.forEach(item => {
|
|
|
+ const obj = {}
|
|
|
+ if (item.AppInputName == 'token' || item.AppInputName == 'Token' || item.AppInputName == 'TOKEN') {
|
|
|
+ obj[item.AppInputName] = sessionStorage.getItem('token')
|
|
|
+ } else if (item.AppInputName == 'loginName' || item.AppInputName == 'userName') {
|
|
|
+ obj[item.AppInputName] = sessionStorage.getItem('userName')
|
|
|
+ }
|
|
|
+ arrs.push(obj)
|
|
|
+ })
|
|
|
+ const getParams = Object.assign(...arrs)
|
|
|
+ axios.get(item.appUrl, {
|
|
|
+ params: getParams
|
|
|
+ }).then(res => {
|
|
|
+ console.log(res)
|
|
|
+ }).catch(err => {
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
}
|
|
|
- axios.post(item.appUrl, {
|
|
|
- userName: sessionStorage.getItem('userName')
|
|
|
- }, {
|
|
|
- headers: {
|
|
|
- 'token': sessionStorage.getItem('token'),
|
|
|
- 'Content-Type': type
|
|
|
- }
|
|
|
- }).then(res => {
|
|
|
- console.log(res)
|
|
|
- }).catch(err => {
|
|
|
- console.log(err)
|
|
|
- })
|
|
|
+ } else if (item.requestType == 2) {
|
|
|
+ this.paramsType(item.bodyType, item.requestType, item.appUrl, a2.AppInputName)
|
|
|
}
|
|
|
}
|
|
|
}
|