import store from 'store/index.js';
import {
Toast
} from 'vue'
export default (url, method, params) => {
if (!params) {
params = {}
}
if (!params['admin_id'] && uni.getStorageSync('userInfo')) {
params['admin_id'] = store.state.userInfo.id
}
return new Promise((resolve, reject) => {
uni.request({
url: "地址" + url,
method: method,
header: {
"Content-Type": "application/x-www-form-urlencoded"
},
data: {
...params
},
success(res) {
const {
code,
msg,
data
} = res.data
msg && uni.showToast({
title: res.data.msg,
icon: 'none'
})
switch (code) {
case 0:
return;
}
resolve(res.data.data);
},
fail(err) {
uni.showToast({
title: err,
icon: 'none'
})
console.log(err, 'err')
reject(err);
},
complete() {
}
});
});
};
import request from "./request.js"
export default {
loginByUsername(params) {
return request("/account/loginByAccount", "POST", params)
}
}
import api from './request/api.js';
Vue.prototype.$apis = api
this.$apis.loginByUsername(userInfo).then(res =>{
})