import http from './http.js'
|
|
|
|
|
|
let limit = {}
|
|
let debounce = {}
|
|
|
|
const config = {
|
|
// 示例
|
|
// wxLogin : {url : '/api/wxLogin', method : 'POST',
|
|
// auth : false, showLoading : true, loadingTitle : '加载中...',
|
|
// limit : 1500
|
|
// },
|
|
|
|
getConfig: {url: '/index/getSysText', method: 'POST', limit: 1500},
|
|
|
|
|
|
// 微信登录接口
|
|
wxLogin: {
|
|
url: '/login/login',
|
|
method: 'POST',
|
|
limit: 1500,
|
|
showLoading: true,
|
|
},
|
|
// 修改个人信息接口
|
|
updateInfo: {
|
|
url: '/info/updateInfo',
|
|
method: 'POST',
|
|
auth: true,
|
|
limit: 1500,
|
|
showLoading: true,
|
|
},
|
|
//隐私政策
|
|
getPrivacyPolicy: {
|
|
url: '/login/getPrivacyPolicy',
|
|
method: 'GET',
|
|
},
|
|
//用户协议
|
|
getUserAgreement: {
|
|
url: '/login/getUserAgreement',
|
|
method: 'GET',
|
|
},
|
|
|
|
// ========================用户登录注册===============================
|
|
//用户登录
|
|
loginUser: {
|
|
url: '/alUser/login',
|
|
method: 'POST',
|
|
limit: 1500,
|
|
showLoading: true,
|
|
},
|
|
//用户注册
|
|
registerUser: {
|
|
url: '/alUser/regUesr',
|
|
method: 'POST',
|
|
limit: 1500,
|
|
showLoading: true,
|
|
},
|
|
// 发送短信接口
|
|
sendSms: {
|
|
url: '/alUser/sendSms',
|
|
method: 'POST',
|
|
limit: 1500,
|
|
showLoading: true,
|
|
},
|
|
// 选择身份
|
|
roleOption: {
|
|
url: '/alUser/role',
|
|
method: 'POST',
|
|
limit : 1500,
|
|
showLoading: true,
|
|
},
|
|
// 修改身份信息
|
|
updateRoleInfo: {
|
|
url: '/alUser/updateRoleInfo',
|
|
method: 'POST',
|
|
limit : 1500,
|
|
showLoading: true,
|
|
},
|
|
// 忘记密码
|
|
newPassword: {
|
|
url: '/alUser/newPassword',
|
|
method: 'POST',
|
|
limit : 1500,
|
|
showLoading: true,
|
|
},
|
|
|
|
// ========================产品报价===============================
|
|
// 清关申请
|
|
addCustoms: {
|
|
url: '/product/addCustoms',
|
|
method: 'POST',
|
|
limit : 1500,
|
|
showLoading: true,
|
|
},
|
|
// 清关申请
|
|
myCustoms: {
|
|
url: '/product/myCustoms',
|
|
method: 'POST',
|
|
limit : 1500,
|
|
showLoading: true,
|
|
},
|
|
// 产品报价
|
|
addProduct: {
|
|
url: '/product/addProduct',
|
|
method: 'POST',
|
|
limit: 1500,
|
|
showLoading: true,
|
|
},
|
|
// 修改产品报价
|
|
updateProduct: {
|
|
url: '/product/updateProduct',
|
|
method: 'POST',
|
|
limit: 1500,
|
|
showLoading: true,
|
|
},
|
|
// 下订单
|
|
addProductOrder: {
|
|
url: '/product/addProductOrder',
|
|
method: 'POST',
|
|
limit: 1500,
|
|
showLoading: true,
|
|
},
|
|
// 确认-取消订单
|
|
updateOrder: {
|
|
url: '/product/updateOrder',
|
|
method: 'POST',
|
|
limit: 1500,
|
|
showLoading: true,
|
|
},
|
|
// 我的挂单列表
|
|
getMyProductlist: {
|
|
url: '/product/myProductlist',
|
|
method: 'GET',
|
|
},
|
|
// 撤单
|
|
noShow: {
|
|
url: '/product/noShow',
|
|
method: 'GET',
|
|
limit: 1500,
|
|
showLoading: true,
|
|
},
|
|
// 现货/期货列表
|
|
productList: {
|
|
url: '/product/productList',
|
|
method: 'GET',
|
|
},
|
|
// 交易平台挂单列表
|
|
productlist: {
|
|
url: '/product/productlist',
|
|
method: 'GET',
|
|
},
|
|
// ========================用户地址===============================
|
|
// 用户地址表-添加
|
|
addAddress: {
|
|
url: '/address/add',
|
|
method: 'POST',
|
|
limit: 1500,
|
|
showLoading: true,
|
|
},
|
|
// 用户地址表-编辑
|
|
editAddress: {
|
|
url: '/address/edit',
|
|
method: 'POST',
|
|
limit: 1500,
|
|
showLoading: true,
|
|
},
|
|
// 用户地址表-删除
|
|
deleteAddress: {
|
|
url: '/address/edit',
|
|
method: 'POST',
|
|
limit: 1500,
|
|
showLoading: true,
|
|
},
|
|
// 用户地址表-分页列表查询
|
|
addressList: {
|
|
url: '/address/list',
|
|
method: 'GET',
|
|
},
|
|
// ========================首页等展示接口===============================
|
|
// 帮助与反馈
|
|
addSuggest: {
|
|
url: '/index/addSuggest',
|
|
method: 'POST',
|
|
limit: 1500,
|
|
showLoading: true,
|
|
},
|
|
// 铝价接口
|
|
getAlPrice: {
|
|
url: '/index/alprice',
|
|
method: 'POST',
|
|
},
|
|
// 获取个人信息
|
|
getUserInfo: {
|
|
url: '/index/index',
|
|
method: 'POST',
|
|
auth : true,
|
|
},
|
|
// 我的头像昵称,平台客户电话等信息
|
|
getImagePhoneOther: {
|
|
url: '/index/getIndex',
|
|
method: 'POST',
|
|
},
|
|
// 我的订单列表
|
|
myOrderlist: {
|
|
url: '/product/myOrderlist',
|
|
method: 'GET',
|
|
auth : true,
|
|
},
|
|
// 采购商根据订单id查询订单信息
|
|
getMyOrderInfo: {
|
|
url: '/product/myOrderlist',
|
|
method: 'GET',
|
|
},
|
|
// 供应商根据挂单id查询挂单详情的接口
|
|
getProductInfo: {
|
|
url: '/product/myOrderlist',
|
|
method: 'GET',
|
|
},
|
|
// 获取banner列表
|
|
bannerList: {
|
|
url: '/index/bannerList',
|
|
method: 'POST',
|
|
},
|
|
|
|
|
|
// 规格分页列表查询
|
|
specsList: {
|
|
url: '/product/specsList',
|
|
method: 'GET',
|
|
},
|
|
|
|
|
|
// 新铝价接口
|
|
alpriceNew: {
|
|
url: '/index/alpriceNew',
|
|
method: 'POST',
|
|
},
|
|
// 查询仓库地址
|
|
confAddressList : {
|
|
url: '/address/confAddressList',
|
|
method: 'GET',
|
|
},
|
|
}
|
|
|
|
|
|
export function api(key, data, callback, loadingTitle) {
|
|
let req = config[key]
|
|
|
|
if (!req) {
|
|
console.error('无效key' + key);
|
|
return
|
|
}
|
|
|
|
if (typeof callback == 'string') {
|
|
loadingTitle = callback
|
|
}
|
|
|
|
if (typeof data == 'function') {
|
|
callback = data
|
|
data = {}
|
|
}
|
|
|
|
// 接口限流
|
|
if (req.limit) {
|
|
let storageKey = req.url
|
|
let storage = limit[storageKey]
|
|
if (storage && new Date().getTime() - storage < req.limit) {
|
|
return
|
|
}
|
|
limit[storageKey] = new Date().getTime()
|
|
}
|
|
|
|
//必须登录
|
|
if (req.auth) {
|
|
if (!uni.getStorageSync('token')) {
|
|
uni.navigateTo({
|
|
url: '/pages_order/auth/loginAndRegisterAndForgetPassword'
|
|
})
|
|
console.error('需要登录')
|
|
return
|
|
}
|
|
}
|
|
|
|
// 接口防抖
|
|
if (req.debounce) {
|
|
|
|
let storageKey = req.url
|
|
let storage = debounce[storageKey]
|
|
|
|
if (storage) {
|
|
clearTimeout(storage)
|
|
}
|
|
|
|
debounce[storageKey] = setTimeout(() => {
|
|
|
|
clearTimeout(storage)
|
|
|
|
delete debounce[storageKey]
|
|
|
|
http.http(req.url, data, callback, req.method,
|
|
loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
|
|
}, req.debounce)
|
|
|
|
return
|
|
}
|
|
|
|
http.http(req.url, data, callback, req.method,
|
|
loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
|
|
}
|
|
|
|
|
|
export default api
|