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.
|
|
|
import Vue from 'vue'
|
|
|
|
let baseUrl = 'https://www.xttoo.com/';
|
|
|
|
Vue.prototype.$baseUrl = baseUrl;
|
|
|
|
|
|
|
|
export function request(prams) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
let url;
|
|
|
|
url = baseUrl + prams.url;
|
|
|
|
uni.request({
|
|
|
|
url: url,
|
|
|
|
data: prams.data,
|
|
|
|
method: prams.method,
|
|
|
|
header: {
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
|
|
|
|
},
|
|
|
|
success: (res) => {
|
|
|
|
if (res.data.code == 1){
|
|
|
|
resolve(res.data);
|
|
|
|
} else {
|
|
|
|
reject(res.data);
|
|
|
|
uni.showToast({
|
|
|
|
icon: "none",
|
|
|
|
title: res.data.msg,
|
|
|
|
duration: 3000
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
fail: (err) => {
|
|
|
|
reject(err);
|
|
|
|
},
|
|
|
|
complete: () => {
|
|
|
|
//console.log('请求完成')
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
}
|