1234567891011121314151617181920212223242526 |
- const axios_instance = axios.create({
- baseURL: baseUrl + "mobile",
- timeout: 30000,
- headers: {'X-Requested-With':'XMLHttpRequest'},
- withCredentials: true,
- });
- async function postJson(url,data,error) {
- return new Promise((resolve, reject) => {
- axios_instance.post(url, JSON.stringify(data), {
- headers: { 'Content-Type': 'application/json;charset=UTF-8' }
- }).then((result) => {
- const data = result.data;
- if (data.code === 1) {
- if (typeof error === 'function') {
- return error(data);
- } else {
- vant.showToast(data.msg);
- }
- } else if (data.code === 401) {
- location.href = '/mobile/login/login';
- }
- return resolve(data);
- });
- });
- }
|