增加广告跳转,增加现金红包配置
This commit is contained in:
@@ -1,19 +1,25 @@
|
||||
class API {
|
||||
constructor(url,req) {
|
||||
import $http from '@/utils/httpRequest'
|
||||
|
||||
class API {
|
||||
constructor(constructorData) {
|
||||
const map={
|
||||
add:'POST',
|
||||
del:'DELETE',
|
||||
update:'PUT',
|
||||
get:'GET'
|
||||
add:'post',
|
||||
del:'post',
|
||||
update:'post',
|
||||
get:'get',
|
||||
getList:'get'
|
||||
}
|
||||
this.url=url
|
||||
for(let key in map){
|
||||
let url=constructorData[key].url||constructorData[key]
|
||||
const method=constructorData[key].method||map[key]
|
||||
this[key]=function(data){
|
||||
data=Array.isArray(data)?data:{...data,shopId:uni.getStorageSync('shopId')}
|
||||
if(key==='del'){
|
||||
delete data.shopId
|
||||
}
|
||||
return req(url, data,map[key])
|
||||
console.log(data)
|
||||
return $http({
|
||||
url: (key=='get'?(url+'/'+data.id||data):url) +(key=='del'?'?id='+(data.id||data):''),
|
||||
method:method,
|
||||
params:(method=='get'&&key!='del')?data:{},
|
||||
data: (method=='post'&&key!='del')?data:{}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user