You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

35 lines
720 B

import http from './http.js'
const config = {
// 微信登录
wxLogin : {url : '/api/wxLogin', method : 'POST', auth : false},
// 2 用户支付
createOrder : {url : '/api/createOrder', method : 'POST', auth : true},
}
export function api(key, data, callback, loadingTitle){
if (!config[key]) {
return console.error('无效key' + key);
}
if (config[key].auth) {
if (!localStorage.getItem('token')) {
uni.navigateTo({
url: '/pages/login/mobile'
})
console.error('需要登录')
return {
then() {}
};
}
}
http.http(config[key].url, data, callback, config[key].method,
loadingTitle || config[key].showLoading, loadingTitle || config[key].loadingTitle)
}
export default api