Commit 14b006f1 by 胡悦

提交api接口调用,

1 parent b7fb30f9
......@@ -12,9 +12,10 @@
"dependencies": {
"axios": "^0.18.0",
"element-ui": "^2.15.1",
"glsx-vue-common": "^1.2.8",
"glsx-vue-common": "^2.0.5",
"lodash": "^4.17.10",
"sass-loader": "^7.1.0",
"sha1": "^1.1.1",
"vue": "^2.5.17"
},
"devDependencies": {
......
import RequestMethods from './request.methods'
import axios from 'axios'
import qs from 'qs'
// import GlsxVueCommon from 'glsx-vue-common'
import sign from './sign'
import {
GlAxios
} from 'glsx-vue-common'
const request = (params = {}, method = RequestMethods.GET, noSignAttr = [], url = '') => {
params.source = 'glsx-oss-merchant-data'
params.appKey = '48e5e13229b82c1b4e6e8c96151f0637'
params.timestamp = new Date().getTime()
params.v = '1.0.0'
params.format = 'json'
// params.createBy = this.$get_session_config().user.id
var data = sign(params, noSignAttr)
if (url) {
return axios.post(`${url}/router?method=${method}`, qs.stringify(data))
}
return method === RequestMethods.GET ? GlAxios.get('router', {
params: sign(params, noSignAttr)
}) : GlAxios.post('router', data)
}
export default request
const RequestMethods = {
POST: 'post',
GET: 'get',
PUT: 'put',
DELETE: 'delete'
}
export default RequestMethods
import sha1 from 'sha1'
import qs from 'qs'
import _ from 'lodash'
const secret = window.location.href.includes('dj.glsx.com.cn') ? '4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353' : 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
const sign = (params, noSignAttr = []) => {
delete params.sign
var objStr = qs.stringify(_.cloneDeep(params), {
arrayFormat: 'indices',
allowDots: true,
encodeValuesOnly: true
})
var objVal = objStr.split('&')
var realObj = {}
objVal.forEach(item => {
const idx = item.indexOf('=')
realObj[item.split('=')[0]] = decodeURIComponent(item.slice(idx + 1))
})
const keys = Object.keys(realObj).sort()
var str = []
var obj = null
for (const key in realObj) {
obj = realObj[key]
if (obj === null) {
obj = ''
} else if (typeof obj === 'object') {
obj = JSON.stringify(obj)
}
realObj[key] = obj
}
keys.forEach(e => {
!noSignAttr.includes(e) && str.push(e + realObj[e])
})
realObj.sign = sha1(secret + str.join('') + secret).toUpperCase()
return realObj
}
export default sign
import request from './request'
const path = 'merchants.api.accountype.'
const accountApi = {
/** 账户类型分页数据*/
getPageApi(data = {}) {
data.method = `${path}page`
return request(data)
}
}
export { accountApi }
......@@ -12,10 +12,15 @@ import '@/components'
// import _ from 'lodash'
// import axios from 'axios'
Vue.prototype.btn_size = 'mini'
Vue.use(ElementUI)
var mixin = {
data() {
return {
eventBus: new Vue()
}
},
mounted() {
const _this = this
const theme = new this.$Theme()
......@@ -26,6 +31,9 @@ var mixin = {
},
height() {
return document.height || document.body.offsetHeight // document.documentElement.clientHeight || document.body.clientHeight //
},
translate(params) {
_this.eventBus.$emit('params', params)
}
}
})
......@@ -36,6 +44,29 @@ var mixin = {
_this.$set_session_config(config)
})
})
},
methods: {
/**
* 页面跳转方法 用法 :
* this.$root.to(['MOCK系统A', '一键导航', '导航数据', 'MOCK数据B', 'localhost'],'1123')
* 或:
* this.$parent.to(['MOCK系统A', '一键导航', '导航数据', 'MOCK数据B', 'localhost'],'1123')
*
* @param {*} path 如: ['一级菜单名称','二级菜单名称','三级菜单名称','四级菜单名称','五级菜单名称']
* @param {*} params 传给下一个页面的参数
*/
to(path, params) {
if (this.$$parent) {
this.$$parent.to(path, params)
} else {
this.$$connection.promise.then(parent => {
parent.to(path, params)
})
}
},
close() {
this.$$parent.close()
}
}
}
const URL = 'http://oss-config.dev.glsx.com.cn/mock/5be17454f31545347559d499/config'
......
......@@ -21,7 +21,7 @@ module.exports = {
},
devServer: {
port: 8085,
host: 'localhost',
host: '0.0.0.0',
open: true,
proxy: {
'/api': {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!