Commit d11265df authored by lipengcheng 's avatar lipengcheng

chore: some changes

parent 4be751b4
...@@ -19,14 +19,12 @@ const apiMap = { ...@@ -19,14 +19,12 @@ const apiMap = {
login: { method: 'post', url: '/login' } login: { method: 'post', url: '/login' }
} }
// const requestMap = {}
function injectRequest(apiObj) { function injectRequest(apiObj) {
const requestObj = {} const requestMap = {}
Object.keys(apiObj).forEach((alias) => { Object.keys(apiObj).forEach((alias) => {
let { method, url, config } = apiObj[alias] let { method, url, config } = apiObj[alias]
method = method.toUpperCase() method = method.toUpperCase()
requestObj[alias] = (dataOrParams = {}, instanceConf = {}) => { requestMap[alias] = (dataOrParams = {}, instanceConf = {}) => {
const keyName = ['PUT', 'POST', 'PATCH'].includes(method) ? 'data' : 'params' const keyName = ['PUT', 'POST', 'PATCH'].includes(method) ? 'data' : 'params'
return request({ return request({
method, method,
...@@ -36,7 +34,7 @@ function injectRequest(apiObj) { ...@@ -36,7 +34,7 @@ function injectRequest(apiObj) {
}) })
} }
}) })
return requestObj return requestMap
} }
export default injectRequest(apiMap) export default injectRequest(apiMap)
...@@ -58,7 +58,7 @@ export default { ...@@ -58,7 +58,7 @@ export default {
async mounted() { async mounted() {
let xx = await this.$api.getBanner({ pageSize: 20, pIndex: 2 }) let xx = await this.$api.getBanner({ pageSize: 20, pIndex: 2 })
console.log('xx:', xx) console.log('xx:', xx)
let vv = await this.$api.login({ account: '18038018084', psw: '2' }) let vv = await this.$api.login({ account: '18038018084', psw: '123456' })
console.log('vv:', vv) console.log('vv:', vv)
}, },
methods: { methods: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment