|
|
- 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
|